/** * {@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; }
/** * {@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())); }
/** * {@inheritDoc} */ public function has(ItemInterface $item) { $clipboardId = $item->getClipboardId(); if (!isset($this->items[$clipboardId])) { return false; } $existingItem = $this->items[$clipboardId]; return $existingItem->equals($item); }
/** * {@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()); }
/** * {@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); }