You are here

class FormModePageAccessCheck in Flexiform 8

Checks access for displaying configuration translation page.

Hierarchy

Expanded class hierarchy of FormModePageAccessCheck

1 string reference to 'FormModePageAccessCheck'
flexiform.services.yml in ./flexiform.services.yml
flexiform.services.yml
1 service uses FormModePageAccessCheck
flexiform.form_mode_page_access_checker in ./flexiform.services.yml
Drupal\flexiform\Access\FormModePageAccessCheck

File

src/Access/FormModePageAccessCheck.php, line 14

Namespace

Drupal\flexiform\Access
View source
class FormModePageAccessCheck implements AccessInterface {

  /**
   * Flexiform form mode access callback.
   */
  public function access(EntityFormMode $form_mode, Request $request, AccountInterface $account) {
    $entities = $this
      ->getProvidedEntities($form_mode, $request);
    $access_result = NULL;
    foreach ($entities as $entity) {
      if (!isset($access_result)) {
        $access_result = $entity
          ->access('edit', $account, TRUE);
      }
      else {
        $access_result
          ->andIf($entity
          ->access('edit', $account, TRUE));
      }
    }
    return $access_result;
  }

  /**
   * Get the provided entities.
   *
   * @return \Drupal\Core\Entity\EntityInterface[]
   *   An array of provided entities keyed by machine name.
   */
  protected function getProvidedEntities(EntityFormMode $form_mode, Request $request) {
    $route_match = RouteMatch::createFromRequest($request);
    $settings = $form_mode
      ->getThirdPartySetting('flexiform', 'exposure');
    $provided = [];
    $provided['base_entity'] = $route_match
      ->getParameter('base_entity');
    foreach ($settings['parameters'] as $namespace => $info) {
      if ($provided_entity = $route_match
        ->getParameter($namespace)) {
        $provided[$namespace] = $provided_entity;
      }
    }
    return $provided;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FormModePageAccessCheck::access public function Flexiform form mode access callback.
FormModePageAccessCheck::getProvidedEntities protected function Get the provided entities.