class FormModePageAccessCheck in Flexiform 8
Checks access for displaying configuration translation page.
Hierarchy
- class \Drupal\flexiform\Access\FormModePageAccessCheck implements AccessInterface
Expanded class hierarchy of FormModePageAccessCheck
1 string reference to 'FormModePageAccessCheck'
1 service uses FormModePageAccessCheck
File
- src/
Access/ FormModePageAccessCheck.php, line 14
Namespace
Drupal\flexiform\AccessView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FormModePageAccessCheck:: |
public | function | Flexiform form mode access callback. | |
FormModePageAccessCheck:: |
protected | function | Get the provided entities. |