We're using panels with page manager and want to restrict access to pages based on user roles and/or language.

In a nutshell we will have many home pages for various regions. Each home page will be its own page in page manager. Variants will not be used. The admin of one region should only see the pages referring to their region, but I can't seem to find a way to limit what can be seen in the page manager list on /admin/structure/page_manager we've looked into the code of the pagemanager_ui module but we can't see any way to hook into it. We saw that PageListBuilder.php seems to generate the table on that page but I'm not sure of a hook we can use to check for permissions line by line of the pages it's building the rows for.

I suppose in this function

  public function buildRow(EntityInterface $entity) {
    /** @var \Drupal\page_manager\PageInterface $entity */
    $row['label'] = $entity->label();
    $row['id'] = $entity->id();
    $row['path'] = $this->getPath($entity);

    return $row + parent::buildRow($entity);

we could rewrite it to check for permissions before adding the row. But I'm not sure if it's a good idea to rewrite core code like that. Also if I wrote a patch it seems like this would be too specific.

Is there a way to limit the pages that a user sees in /admin/structure/page_manager based on their roles/permissions?

UPDATE: If we were to make a new PageListBuilder class in our custom module, how would we get it to overwrite the default class and use our own instead?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.