예제 #1
0
 /**
  * @param string $entityType
  * @param object $entity
  * @param array $arguments
  * @return object
  * @throws \Exception
  */
 public function execute($entityType, $entity, $arguments = [])
 {
     $entityMetadata = $this->metadataPool->getMetadata($entityType);
     $linkField = $entityMetadata->getLinkField();
     $connection = $entityMetadata->getEntityConnection();
     $oldStores = $this->resourcePage->lookupStoreIds((int) $entity->getId());
     $newStores = (array) $entity->getStores();
     if (empty($newStores)) {
         $newStores = (array) $entity->getStoreId();
     }
     $table = $this->resourcePage->getTable('cms_page_store');
     $delete = array_diff($oldStores, $newStores);
     if ($delete) {
         $where = [$linkField . ' = ?' => (int) $entity->getData($linkField), 'store_id IN (?)' => $delete];
         $connection->delete($table, $where);
     }
     $insert = array_diff($newStores, $oldStores);
     if ($insert) {
         $data = [];
         foreach ($insert as $storeId) {
             $data[] = [$linkField => (int) $entity->getData($linkField), 'store_id' => (int) $storeId];
         }
         $connection->insertMultiple($table, $data);
     }
     return $entity;
 }
예제 #2
0
 /**
  * @param string $entityType
  * @param object $entity
  * @return object
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute($entityType, $entity)
 {
     if ($entity->getId()) {
         $stores = $this->resourcePage->lookupStoreIds((int) $entity->getId());
         $entity->setData('store_id', $stores);
     }
     return $entity;
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function lookupStoreIds($pageId)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'lookupStoreIds');
     if (!$pluginInfo) {
         return parent::lookupStoreIds($pageId);
     } else {
         return $this->___callPlugins('lookupStoreIds', func_get_args(), $pluginInfo);
     }
 }