arch-8.x-1.x-dev/modules/order/src/Access/OrderAddAccessCheck.php

modules/order/src/Access/OrderAddAccessCheck.php
<?php

namespace Drupal\arch_order\Access;

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Routing\Access\AccessInterface;
use Drupal\Core\Session\AccountInterface;

/**
 * Determines access to for product add pages.
 *
 * @ingroup product_access
 */
class OrderAddAccessCheck implements AccessInterface {

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

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

  /**
   * Checks access to the product add page for the product type.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The currently logged in account.
   *
   * @return string
   *   A \Drupal\Core\Access\AccessInterface constant value.
   */
  public function access(AccountInterface $account) {
    $access_control_handler = $this->entityTypeManager->getAccessControlHandler('order');

    $access = $access_control_handler->createAccess(NULL, $account, [], TRUE);
    if ($access && $access->isAllowed()) {
      return $access;
    }

    // No opinion.
    return AccessResult::neutral();
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc