Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function validateReferenceableNewEntities(array $entities)
 {
     $entities = parent::validateReferenceableNewEntities($entities);
     $entities = array_filter($entities, function ($file) {
         /** @var \Drupal\file\FileInterface $file */
         return $file->isPermanent() || $file->getOwnerId() === $this->currentUser->id();
     });
     return $entities;
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function validateReferenceableNewEntities(array $entities)
 {
     $entities = parent::validateReferenceableNewEntities($entities);
     // Mirror the conditions checked in buildEntityQuery().
     if (!$this->currentUser->hasPermission('administer comments')) {
         $entities = array_filter($entities, function ($comment) {
             /** @var \Drupal\comment\CommentInterface $comment */
             return $comment->isPublished();
         });
     }
     return $entities;
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function validateReferenceableNewEntities(array $entities)
 {
     $entities = parent::validateReferenceableNewEntities($entities);
     // Mirror the conditions checked in buildEntityQuery().
     if (!$this->currentUser->hasPermission('bypass node access') && !count($this->moduleHandler->getImplementations('node_grants'))) {
         $entities = array_filter($entities, function ($node) {
             /** @var \Drupal\node\NodeInterface $node */
             return $node->isPublished();
         });
     }
     return $entities;
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function validateReferenceableNewEntities(array $entities)
 {
     $entities = parent::validateReferenceableNewEntities($entities);
     // Mirror the conditions checked in buildEntityQuery().
     if (!empty($this->configuration['handler_settings']['filter']['role'])) {
         $entities = array_filter($entities, function ($user) {
             /** @var \Drupal\user\UserInterface $user */
             return !empty(array_intersect($user->getRoles(), $this->configuration['handler_settings']['filter']['role']));
         });
     }
     if (!$this->currentUser->hasPermission('administer users')) {
         $entities = array_filter($entities, function ($user) {
             /** @var \Drupal\user\UserInterface $user */
             return $user->isActive();
         });
     }
     return $entities;
 }