trait FieldStorageDefinitionEventSubscriberTrait
Same name in other branches
- 9 core/lib/Drupal/Core/Field/FieldStorageDefinitionEventSubscriberTrait.php \Drupal\Core\Field\FieldStorageDefinitionEventSubscriberTrait
- 10 core/lib/Drupal/Core/Field/FieldStorageDefinitionEventSubscriberTrait.php \Drupal\Core\Field\FieldStorageDefinitionEventSubscriberTrait
- 11.x core/lib/Drupal/Core/Field/FieldStorageDefinitionEventSubscriberTrait.php \Drupal\Core\Field\FieldStorageDefinitionEventSubscriberTrait
Helper methods for FieldStorageDefinitionListenerInterface.
This allows a class implementing FieldStorageDefinitionListenerInterface to subscribe and react to field storage definition events.
Hierarchy
- trait \Drupal\Core\Field\FieldStorageDefinitionEventSubscriberTrait
See also
\Symfony\Component\EventDispatcher\EventSubscriberInterface
\Drupal\Core\Field\FieldStorageDefinitionListenerInterface
1 file declares its use of FieldStorageDefinitionEventSubscriberTrait
- EntityTestDefinitionSubscriber.php in core/
modules/ system/ tests/ modules/ entity_test/ src/ EntityTestDefinitionSubscriber.php
File
-
core/
lib/ Drupal/ Core/ Field/ FieldStorageDefinitionEventSubscriberTrait.php, line 14
Namespace
Drupal\Core\FieldView source
trait FieldStorageDefinitionEventSubscriberTrait {
/**
* Returns the subscribed events.
*
* @return array
* An array of subscribed event names.
*
* @see \Symfony\Component\EventDispatcher\EventSubscriberInterface::getSubscribedEvents()
*/
public static function getFieldStorageDefinitionEvents() {
$event = [
'onFieldStorageDefinitionEvent',
100,
];
$events[FieldStorageDefinitionEvents::CREATE][] = $event;
$events[FieldStorageDefinitionEvents::UPDATE][] = $event;
$events[FieldStorageDefinitionEvents::DELETE][] = $event;
return $events;
}
/**
* Listener method for any field storage definition event.
*
* @param \Drupal\Core\Field\FieldStorageDefinitionEvent $event
* The field storage definition event object.
* @param string $event_name
* The event name.
*/
public function onFieldStorageDefinitionEvent(FieldStorageDefinitionEvent $event, $event_name) {
switch ($event_name) {
case FieldStorageDefinitionEvents::CREATE:
$this->onFieldStorageDefinitionCreate($event->getFieldStorageDefinition());
break;
case FieldStorageDefinitionEvents::UPDATE:
$this->onFieldStorageDefinitionUpdate($event->getFieldStorageDefinition(), $event->getOriginal());
break;
case FieldStorageDefinitionEvents::DELETE:
$this->onFieldStorageDefinitionDelete($event->getFieldStorageDefinition());
break;
}
}
/**
* {@inheritdoc}
*/
public function onFieldStorageDefinitionCreate(FieldStorageDefinitionInterface $storage_definition) {
}
/**
* {@inheritdoc}
*/
public function onFieldStorageDefinitionUpdate(FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original) {
}
/**
* {@inheritdoc}
*/
public function onFieldStorageDefinitionDelete(FieldStorageDefinitionInterface $storage_definition) {
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overrides |
---|---|---|---|---|
FieldStorageDefinitionEventSubscriberTrait::getFieldStorageDefinitionEvents | public static | function | Returns the subscribed events. | |
FieldStorageDefinitionEventSubscriberTrait::onFieldStorageDefinitionCreate | public | function | 1 | |
FieldStorageDefinitionEventSubscriberTrait::onFieldStorageDefinitionDelete | public | function | 1 | |
FieldStorageDefinitionEventSubscriberTrait::onFieldStorageDefinitionEvent | public | function | Listener method for any field storage definition event. | |
FieldStorageDefinitionEventSubscriberTrait::onFieldStorageDefinitionUpdate | public | function | 1 |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.