Pimcore\Model\Element\Tag::getById PHP Method

getById() public static method

public static getById ( $id ) : Pimcore\Model\Element\Tag
$id
return Pimcore\Model\Element\Tag
    public static function getById($id)
    {
        try {
            $tag = new self();
            $tag->getDao()->getById($id);
            return $tag;
        } catch (\Exception $e) {
            return null;
        }
    }

Usage Example

Example #1
0
File: Dao.php Project: sfie/pimcore
 /**
  * Loads a list of tags for the specifies parameters, returns an array of Element\Tag elements
  *
  * @return array
  */
 public function load()
 {
     $tagsData = $this->db->fetchCol("SELECT id FROM tags" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     $tags = array();
     foreach ($tagsData as $tagData) {
         if ($tag = Model\Element\Tag::getById($tagData)) {
             $tags[] = $tag;
         }
     }
     $this->model->setTags($tags);
     return $tags;
 }
All Usage Examples Of Pimcore\Model\Element\Tag::getById