You are here

class FeedAddAccessCheck in Feeds 8.3

Access check for feeds link add list routes.

Hierarchy

Expanded class hierarchy of FeedAddAccessCheck

1 string reference to 'FeedAddAccessCheck'
feeds.services.yml in ./feeds.services.yml
feeds.services.yml
1 service uses FeedAddAccessCheck
access_check.feeds.feed_add in ./feeds.services.yml
Drupal\feeds\Access\FeedAddAccessCheck

File

src/Access/FeedAddAccessCheck.php, line 13

Namespace

Drupal\feeds\Access
View source
class FeedAddAccessCheck implements AccessInterface {

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Constructs a FeedAddAccessCheck object.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * {@inheritdoc}
   */
  public function access(AccountInterface $account) {

    // @todo Perhaps read config directly rather than load all feed types.
    $access_control_handler = $this->entityTypeManager
      ->getAccessControlHandler('feeds_feed');
    foreach ($this->entityTypeManager
      ->getStorage('feeds_feed_type')
      ->loadByProperties([
      'status' => TRUE,
    ]) as $feed_type) {
      $access = $access_control_handler
        ->createAccess($feed_type
        ->id(), $account, [], TRUE);
      if ($access
        ->isAllowed()) {
        return $access;
      }
    }
    return AccessResult::neutral();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FeedAddAccessCheck::$entityTypeManager protected property The entity type manager.
FeedAddAccessCheck::access public function
FeedAddAccessCheck::__construct public function Constructs a FeedAddAccessCheck object.