You are here

protected function MenuTreeResource::addAccess in REST Menu Tree 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/rest/resource/MenuTreeResource.php \Drupal\rest_menu_tree\Plugin\rest\resource\MenuTreeResource::addAccess()

Add Access.

Ensure that every item has an access result, if possible.

1 call to MenuTreeResource::addAccess()
MenuTreeResource::get in src/Plugin/rest/resource/MenuTreeResource.php

File

src/Plugin/rest/resource/MenuTreeResource.php, line 141

Class

MenuTreeResource
Provides a resource to get view modes by entity and bundle.

Namespace

Drupal\rest_menu_tree\Plugin\rest\resource

Code

protected function addAccess(array $data) {
  foreach ($data as $value) {
    if ($value->access === NULL && $value->link instanceof AccessibleInterface) {
      $value->access = $value->link
        ->access('view', NULL, TRUE);
    }
    if ($value->subtree) {
      $this
        ->addAccess($value->subtree);
    }
  }
}