getId() публичный Метод

A string that uniquely identifies an item.
public getId ( ) : string
Результат string
Пример #1
0
 /**
  * Gets the attributes of an item.
  *
  * @param ItemInterface $item
  *
  * @return array
  */
 protected function getItemAttributes(ItemInterface $item)
 {
     $result = $item->getAttributes();
     $result['id'] = $item->getId();
     $result['content'] = $item->getContent();
     $result['collection'] = $item->getCollection();
     $result['path'] = $item->getPath(ItemInterface::SNAPSHOT_PATH_RELATIVE);
     return $result;
 }
Пример #2
0
 /**
  * Sets an item.
  *
  * @param Yosymfony\Spress\Core\DataSource\ItemInterface
  *
  * @throws \RuntimeException If the item has been registered previously in another collection
  */
 public function set(ItemInterface $item)
 {
     $id = $item->getId();
     $collectionName = $item->getCollection();
     $this->items[$id] = $item;
     if (isset($this->idCollections[$id]) && $this->idCollections[$id] !== $collectionName) {
         throw new \RuntimeException(sprintf('The item with id: "%s" has been registered previously with another collection.', $id));
     }
     if (isset($this->itemCollections[$collectionName]) === false) {
         $this->itemCollections[$collectionName] = [];
     }
     $this->itemCollections[$collectionName][$id] = $item;
     $this->idCollections[$id] = $collectionName;
 }
Пример #3
0
 /**
  * Sets an include item.
  *
  * @param Yosymfony\Spress\Core\DataSource\ItemInterface $item
  */
 public function setInclude(ItemInterface $item)
 {
     $this->includes[$item->getId()] = $item;
 }
Пример #4
0
 protected function getItemAttributes(ItemInterface $item)
 {
     $result = $item->getAttributes();
     $result['id'] = $item->getId();
     $result['content'] = $item->getContent();
     $result['collection'] = $item->getCollection();
     $result['path'] = $item->getPath(ItemInterface::SNAPSHOT_PATH_RELATIVE);
     $result['relationships'] = [];
     $relationships = $item->getRelationshipCollection();
     foreach ($relationships as $name => $items) {
         if (isset($result['relationships'][$name]) === false) {
             $result['relationships'][$name] = [];
         }
         foreach ($items as $relItem) {
             $relAttributes = $relItem->getAttributes();
             $relAttributes['id'] = $relItem->getId();
             $relAttributes['content'] = $relItem->getContent();
             $relAttributes['collection'] = $relItem->getCollection();
             $relAttributes['path'] = $relItem->getPath(ItemInterface::SNAPSHOT_PATH_RELATIVE);
             $result['relationships'][$name][] = $relAttributes;
         }
     }
     return $result;
 }