Same name in other branches
- 8.x-1.x entity_clone.api.php \MyEntityCloneEventSubscriber
Event subscribers for Entity Clone.
Service definition for my_module.services.yml:
```yaml
my_module.my_event_subscriber:
class: Drupal\my_module\EventSubscriber\MyEntityCloneEventSubscriber
tags:
- { name: event_subscriber }
```
Code for src/EventSubscriber/MyEntityCloneEventSubscriber.php
<?php
namespace Drupal\my_module\EventSubscriber;
?>
Hierarchy
- class \MyEntityCloneEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of MyEntityCloneEventSubscriber
Fichier
-
./
entity_clone.api.php, line 36
View source
class MyEntityCloneEventSubscriber implements EventSubscriberInterface {
/**
* An example event subscriber.
*
* Dispatched before an entity is cloned and saved.
*
* @see \Drupal\entity_clone\Event\EntityCloneEvents::PRE_CLONE
*/
public function myPreClone(EntityCloneEvent $event) : void {
$original = $event->getEntity();
$newEntity = $event->getClonedEntity();
}
/**
* An example event subscriber.
*
* Dispatched after an entity is cloned and saved.
*
* @see \Drupal\entity_clone\Event\EntityCloneEvents::POST_CLONE
*/
public function myPostClone(EntityCloneEvent $event) : void {
$original = $event->getEntity();
$newEntity = $event->getClonedEntity();
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() : array {
$events[EntityCloneEvents::PRE_CLONE][] = [
'myPreClone',
];
$events[EntityCloneEvents::POST_CLONE][] = [
'myPostClone',
];
return $events;
}
}
Members
Titre Trier par ordre décroissant | Modifiers | Object type | Résumé |
---|---|---|---|
MyEntityCloneEventSubscriber::getSubscribedEvents | public static | function | |
MyEntityCloneEventSubscriber::myPostClone | public | function | An example event subscriber. |
MyEntityCloneEventSubscriber::myPreClone | public | function | An example event subscriber. |