/**
  * {@inheritdoc}
  */
 public function validate(EmbridgeAssetEntityInterface $asset, $validators = array())
 {
     // Call the validation functions specified by this function's caller.
     $errors = array();
     foreach ($validators as $function => $args) {
         if (method_exists($this, $function)) {
             array_unshift($args, $asset);
             $errors = array_merge($errors, call_user_func_array(array($this, $function), $args));
         }
     }
     // Let other modules perform validation on the new file.
     return array_merge($errors, $this->moduleHandler->invokeAll('embridge_asset_validate', array($asset)));
 }
 /**
  * {@inheritdoc}
  */
 public function checkAccess(EntityInterface $entity, Route $route, AccountInterface $account, $operation, $graph_name)
 {
     if (!$entity) {
         return FALSE;
     }
     // For now, we only have the view operation but this is not the only
     // operation so we will check anyway.
     $map = ['view' => 'view all graphs'];
     $entity_type_id = $entity->getEntityTypeId();
     $type_map = ['view' => "view {$entity_type_id} {$graph_name} graph"];
     // If the operation is not supported, do not allow access.
     if (!isset($map[$operation]) || !isset($type_map[$operation])) {
         return FALSE;
     }
     // @todo: This probably needs to be cached manually creating a cid.
     // @see: \Drupal\node\Access\NodeRevisionAccessCheck::checkAccess().
     // @todo: This needs also to check cache for cached permission.
     // @see: \Drupal\Core\Entity\EntityAccessControlHandler::access().
     $has_permission = $account->hasPermission($map[$operation]) || $account->hasPermission($type_map[$operation]);
     $access = $has_permission ? AccessResult::allowed() : AccessResult::neutral();
     $arguments = [$entity, $operation, $account, $graph_name];
     $access_array = array_merge([$access], $this->moduleHandler->invokeAll('entity_graph_access', $arguments), $this->moduleHandler->invokeAll($entity_type_id . '_graph_access', $arguments));
     $return = $this->processAccessHookResults($access_array);
     return $return->isAllowed();
 }
示例#3
0
 /**
  * Test invoke all.
  *
  * @covers ::invokeAll
  */
 public function testInvokeAll()
 {
     $this->moduleHandler->addModule('module_handler_test_all1', 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test_all1');
     $this->moduleHandler->addModule('module_handler_test_all2', 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test_all2');
     $this->assertEquals(array(TRUE, TRUE, TRUE), $this->moduleHandler->invokeAll('hook', array(TRUE)));
 }