You are here

public function DataPolicy::revisionsOverviewPage in Open Social 8.5

Same name and namespace in other branches
  1. 8.9 modules/custom/social_gdpr/src/Controller/DataPolicy.php \Drupal\social_gdpr\Controller\DataPolicy::revisionsOverviewPage()
  2. 8.2 modules/custom/social_gdpr/src/Controller/DataPolicy.php \Drupal\social_gdpr\Controller\DataPolicy::revisionsOverviewPage()
  3. 8.3 modules/custom/social_gdpr/src/Controller/DataPolicy.php \Drupal\social_gdpr\Controller\DataPolicy::revisionsOverviewPage()
  4. 8.4 modules/custom/social_gdpr/src/Controller/DataPolicy.php \Drupal\social_gdpr\Controller\DataPolicy::revisionsOverviewPage()
  5. 8.6 modules/custom/social_gdpr/src/Controller/DataPolicy.php \Drupal\social_gdpr\Controller\DataPolicy::revisionsOverviewPage()
  6. 8.7 modules/custom/social_gdpr/src/Controller/DataPolicy.php \Drupal\social_gdpr\Controller\DataPolicy::revisionsOverviewPage()
  7. 8.8 modules/custom/social_gdpr/src/Controller/DataPolicy.php \Drupal\social_gdpr\Controller\DataPolicy::revisionsOverviewPage()
  8. 10.0.x modules/custom/social_gdpr/src/Controller/DataPolicy.php \Drupal\social_gdpr\Controller\DataPolicy::revisionsOverviewPage()
  9. 10.1.x modules/custom/social_gdpr/src/Controller/DataPolicy.php \Drupal\social_gdpr\Controller\DataPolicy::revisionsOverviewPage()

Generates an overview table of older revisions of a Data policy.

Return value

array An array as expected by drupal_render().

Overrides DataPolicy::revisionsOverviewPage

1 string reference to 'DataPolicy::revisionsOverviewPage'
social_gdpr.routing.yml in modules/custom/social_gdpr/social_gdpr.routing.yml
modules/custom/social_gdpr/social_gdpr.routing.yml

File

modules/custom/social_gdpr/src/Controller/DataPolicy.php, line 46

Class

DataPolicy
Class DataPolicy.

Namespace

Drupal\social_gdpr\Controller

Code

public function revisionsOverviewPage() {
  $build = parent::revisionsOverviewPage();
  $routes = [
    'view' => 'social_gdpr.data_policy.revision',
    'edit' => 'social_gdpr.data_policy.revision_edit',
    'delete' => 'social_gdpr.data_policy.revision_delete',
  ];
  foreach ($build['data_policy_revisions_table']['#rows'] as &$row) {
    foreach ($row[1]['data']['#links'] as $operation => &$link) {

      /** @var \Drupal\Core\Url $url */
      $url =& $link['url'];
      if ($operation == 'revert') {
        if ($url
          ->getRouteName() == 'entity.data_policy.revision_revert') {
          $route_name = 'social_gdpr.data_policy.revision_revert';
        }
        else {
          $route_name = 'social_gdpr.data_policy.translation_revert';
        }
        $link['url'] = Url::fromRoute($route_name, $url
          ->getRouteParameters());
        $link['attributes'] = [
          'class' => [
            'use-ajax',
          ],
          'data-dialog-type' => 'modal',
          'data-dialog-options' => Json::encode([
            'dialogClass' => 'social-dialog',
            'title' => '',
            'width' => 360,
          ]),
        ];
      }
      if (isset($routes[$operation])) {
        $link['url'] = Url::fromRoute($routes[$operation], $link['url']
          ->getRouteParameters());
      }
    }

    /** @var \Drupal\Core\Url $url */
    $url =& $row[1]['data']['#links']['view']['url'];
    $parameters = $url
      ->getRouteParameters();
    $row = [
      'data' => $row,
      'class' => [
        'revision-' . $parameters['data_policy_revision'],
      ],
    ];
  }
  return $build;
}