public function DraggableViewsSyncExtend::extendPush in CMS Content Sync 8
Same name and namespace in other branches
- 2.1.x modules/cms_content_sync_draggableviews/src/EventSubscriber/DraggableViewsSyncExtend.php \Drupal\cms_content_sync_draggableviews\EventSubscriber\DraggableViewsSyncExtend::extendPush()
- 2.0.x modules/cms_content_sync_draggableviews/src/EventSubscriber/DraggableViewsSyncExtend.php \Drupal\cms_content_sync_draggableviews\EventSubscriber\DraggableViewsSyncExtend::extendPush()
Alter the push to include the draggable views settings, if enabled for the entity type.
Parameters
\Drupal\cms_content_sync\Event\BeforeEntityPush $event:
Throws
\Drupal\Component\Plugin\Exception\PluginNotFoundException
File
- modules/
cms_content_sync_draggableviews/ src/ EventSubscriber/ DraggableViewsSyncExtend.php, line 82
Class
- DraggableViewsSyncExtend
- Event subscriptions for events dispatched by Content Sync.
Namespace
Drupal\cms_content_sync_draggableviews\EventSubscriberCode
public function extendPush(BeforeEntityPush $event) {
$intent = $event->intent;
$entity = $event->entity;
if (!$this
->supportsEntityType($entity
->getEntityTypeId())) {
return;
}
$connection = Database::getConnection();
$query = $connection
->select('draggableviews_structure', 'dvs');
$query
->condition('dvs.entity_id', $entity
->id());
$query
->fields('dvs', [
'view_name',
'view_display',
'args',
'weight',
'parent',
]);
$result = $query
->execute();
$result
->setFetchMode(\PDO::FETCH_ASSOC);
$result = $result
->fetchAll();
$values = [];
foreach ($result as $row) {
$values[$row['view_name']][$row['view_display']] = [
'args' => $row['args'],
'weight' => $row['weight'],
'parent' => 0,
];
}
if (!count($values)) {
$intent
->setProperty(self::PROPERTY_NAME, NULL);
return;
}
$intent
->setProperty(self::PROPERTY_NAME, $values);
}