function hook_paragraphs_ee_widget_access in Paragraphs Editor Enhancements 8
Set access result for modifications made to widgets by paragraphs_ee.
Parameters
array $elements: The field widget form elements as constructed by \Drupal\Core\Field\WidgetBase::formMultipleElements().
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
array $context: An associative array containing the following key-value pairs:
- form: The form structure to which widgets are being attached. This may be a full form structure, or a sub-element of a larger form.
- widget: The widget plugin instance.
- items: The field values, as a \Drupal\Core\Field\FieldItemListInterface object.
- default: A boolean indicating whether the form is being shown as a dummy form to set default values.
2 functions implement hook_paragraphs_ee_widget_access()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- paragraphs_ee_paragraphs_ee_widget_access in ./
paragraphs_ee.module - Implements hook_paragraphs_ee_widget_access().
- paragraphs_ee_sets_paragraphs_ee_widget_access in modules/
paragraphs_ee_sets/ paragraphs_ee_sets.module - Implements hook_paragraphs_ee_widget_access().
1 invocation of hook_paragraphs_ee_widget_access()
File
- ./
paragraphs_ee.api.php, line 33 - Hooks for the paragraphs_ee module.
Code
function hook_paragraphs_ee_widget_access(array $elements, FormStateInterface $form_state, array $context) {
/** @var \Drupal\entity_reference_revisions\EntityReferenceRevisionsFieldItemList $items */
$items = $context['items'];
if (empty($items)) {
return AccessResult::forbidden('No items available in widget.');
}
return AccessResult::neutral();
}