Пример #1
0
 /**
  * Loads a tag object from its $tagId.
  *
  * Optionally a translation filter may be specified. If specified only the
  * translations with the listed language codes will be retrieved. If not,
  * all translations will be retrieved.
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If the specified tag is not found
  *
  * @param mixed $tagId
  * @param string[] $translations
  * @param bool $useAlwaysAvailable
  *
  * @return \Netgen\TagsBundle\SPI\Persistence\Tags\Tag
  */
 public function load($tagId, array $translations = null, $useAlwaysAvailable = true)
 {
     $rows = $this->gateway->getFullTagData($tagId, $translations, $useAlwaysAvailable);
     if (empty($rows)) {
         throw new NotFoundException('tag', $tagId);
     }
     $tag = $this->mapper->extractTagListFromRows($rows);
     return reset($tag);
 }
Пример #2
0
 /**
  * Returns an array with full tag data.
  *
  * @throws \RuntimeException
  *
  * @param mixed $tagId
  * @param string[] $translations
  * @param bool $useAlwaysAvailable
  *
  * @return array
  */
 public function getFullTagData($tagId, array $translations = null, $useAlwaysAvailable = true)
 {
     try {
         return $this->innerGateway->getFullTagData($tagId, $translations, $useAlwaysAvailable);
     } catch (DBALException $e) {
         throw new RuntimeException('Database error', 0, $e);
     } catch (PDOException $e) {
         throw new RuntimeException('Database error', 0, $e);
     }
 }