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

getById() public static method

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

Usage Example

Beispiel #1
0
 /**
  * Loads a list of static routes for the specicifies parameters, returns an array of Element\Note elements
  *
  * @return array
  */
 public function load()
 {
     $notesData = $this->db->fetchCol("SELECT id FROM notes" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     $notes = [];
     foreach ($notesData as $noteData) {
         if ($note = Model\Element\Note::getById($noteData)) {
             $notes[] = $note;
         }
     }
     $this->model->setNotes($notes);
     return $notes;
 }