class DisabledEntity in Acquia Content Hub 8.2
Place auto_updated_disabled entities into the dependency stack.
Hierarchy
- class \Drupal\acquia_contenthub_subscriber\EventSubscriber\EntityDataTamper\DisabledEntity implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of DisabledEntity
1 string reference to 'DisabledEntity'
- acquia_contenthub_subscriber.services.yml in modules/
acquia_contenthub_subscriber/ acquia_contenthub_subscriber.services.yml - modules/acquia_contenthub_subscriber/acquia_contenthub_subscriber.services.yml
1 service uses DisabledEntity
File
- modules/
acquia_contenthub_subscriber/ src/ EventSubscriber/ EntityDataTamper/ DisabledEntity.php, line 14
Namespace
Drupal\acquia_contenthub_subscriber\EventSubscriber\EntityDataTamperView source
class DisabledEntity implements EventSubscriberInterface {
/**
* The subscriber tracker.
*
* @var \Drupal\acquia_contenthub_subscriber\SubscriberTracker
*/
protected $tracker;
/**
* DisabledEntity constructor.
*
* @param \Drupal\acquia_contenthub_subscriber\SubscriberTracker $tracker
* Subscriber tracker.
*/
public function __construct(SubscriberTracker $tracker) {
$this->tracker = $tracker;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[AcquiaContentHubEvents::ENTITY_DATA_TAMPER][] = [
'onDataTamper',
100,
];
return $events;
}
/**
* Tamper with CDF data before its imported.
*
* @param \Drupal\acquia_contenthub\Event\EntityDataTamperEvent $event
* The data tamper event.
*
* @throws \Exception
*/
public function onDataTamper(EntityDataTamperEvent $event) {
$cdf = $event
->getCdf();
foreach ($cdf
->getEntities() as $object) {
$uuid = $object
->getUuid();
// @todo we want to compare by hashes eventually.
if (!$this->tracker
->isTracked($uuid)) {
continue;
}
if ($this->tracker
->getStatusByUuid($uuid) !== SubscriberTracker::AUTO_UPDATE_DISABLED) {
continue;
}
$entity = $this->tracker
->getEntityByRemoteIdAndHash($uuid);
if ($entity) {
$wrapper = new DependentEntityWrapper($entity);
$wrapper
->setRemoteUuid($uuid);
$event
->getStack()
->addDependency($wrapper);
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DisabledEntity:: |
protected | property | The subscriber tracker. | |
DisabledEntity:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
DisabledEntity:: |
public | function | Tamper with CDF data before its imported. | |
DisabledEntity:: |
public | function | DisabledEntity constructor. |