コード例 #1
0
 /**
  * {@inheritDoc}
  */
 public function getModelFromClipboardItem(ItemInterface $item)
 {
     $modelId = $item->getModelId();
     if (!$modelId) {
         return null;
     }
     $environment = $this->getEnvironment();
     $dataProvider = $environment->getDataProvider($modelId->getDataProviderName());
     $config = $dataProvider->getEmptyConfig()->setId($modelId->getId());
     $model = $dataProvider->fetch($config);
     return $model;
 }
コード例 #2
0
ファイル: Item.php プロジェクト: designs2/dc-general
 /**
  * {@inheritdoc}
  */
 public function equals(ItemInterface $item)
 {
     // It is exactly the same item
     if ($this === $item) {
         return true;
     }
     return !($this->getAction() !== $item->getAction() || $this->getParentId() && !$item->getParentId() || !$this->getParentId() && $item->getParentId() || $this->getParentId() && !$this->getParentId()->equals($item->getParentId()) || !$this->getModelId()->equals($item->getModelId()));
 }
コード例 #3
0
ファイル: Clipboard.php プロジェクト: davidmaack/dc-general
 /**
  * {@inheritDoc}
  */
 public function has(ItemInterface $item)
 {
     $clipboardId = $item->getClipboardId();
     if (!isset($this->items[$clipboardId])) {
         return false;
     }
     $existingItem = $this->items[$clipboardId];
     return $existingItem->equals($item);
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  *
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function equals(ItemInterface $item)
 {
     // It is exactly the same item.
     if ($this === $item) {
         return true;
     }
     // The actions are not equal.
     if ($this->getAction() !== $item->getAction()) {
         return false;
     }
     // One has a parent ID, the other not.
     if ($this->getParentId() && !$item->getParentId() || !$this->getParentId() && $item->getParentId()) {
         return false;
     }
     // The parent IDs are not equal.
     if ($this->getParentId() && !$this->getParentId()->equals($item->getParentId())) {
         return false;
     }
     // One has a model ID, the other not.
     if ($this->getModelId() && !$item->getModelId() || !$this->getModelId() && $item->getModelId()) {
         return false;
     }
     // Both have no model id and the data provider is different.
     if (!($this->getModelId() || $item->getModelId())) {
         return $this->getDataProviderName() === $item->getDataProviderName();
     }
     // The model IDs are not equal
     return $this->getModelId()->equals($item->getModelId());
 }
コード例 #5
0
ファイル: Clipboard.php プロジェクト: designs2/dc-general
 /**
  * {@inheritDoc}
  */
 public function has(ItemInterface $item)
 {
     $serializedId = $item->getModelId()->getSerialized();
     if (!isset($this->items[$serializedId])) {
         return false;
     }
     $existingItem = $this->items[$serializedId];
     return $existingItem->equals($item);
 }