Пример #1
0
 /**
  * Creates the new tag.
  *
  * @param \Netgen\TagsBundle\SPI\Persistence\Tags\CreateStruct $createStruct
  *
  * @return \Netgen\TagsBundle\SPI\Persistence\Tags\Tag The newly created tag
  */
 public function create(CreateStruct $createStruct)
 {
     $parentTagData = null;
     if (!empty($createStruct->parentTagId)) {
         $parentTagData = $this->gateway->getBasicTagData($createStruct->parentTagId);
     }
     $newTagId = $this->gateway->create($createStruct, $parentTagData);
     $this->updateSubtreeModificationTime($newTagId);
     return $this->load($newTagId);
 }
Пример #2
0
 /**
  * Creates a new tag using the given $createStruct below $parentTag.
  *
  * @throws \RuntimeException
  *
  * @param \Netgen\TagsBundle\SPI\Persistence\Tags\CreateStruct $createStruct
  * @param array $parentTag
  *
  * @return int
  */
 public function create(CreateStruct $createStruct, array $parentTag = null)
 {
     try {
         return $this->innerGateway->create($createStruct, $parentTag);
     } catch (DBALException $e) {
         throw new RuntimeException('Database error', 0, $e);
     } catch (PDOException $e) {
         throw new RuntimeException('Database error', 0, $e);
     }
 }