Pimcore\Model\Schedule\Task::getById PHP Метод

getById() публичный статический Метод

public static getById ( integer $id ) : Schedule\Task
$id integer
Результат Schedule\Task
    public static function getById($id)
    {
        $cacheKey = "scheduled_task_" . $id;
        try {
            $task = \Zend_Registry::get($cacheKey);
            if (!$task) {
                throw new \Exception("Scheduled Task in Registry is not valid");
            }
        } catch (\Exception $e) {
            $task = new self();
            $task->getDao()->getById(intval($id));
            \Zend_Registry::set($cacheKey, $task);
        }
        return $task;
    }

Usage Example

Пример #1
0
 /**
  * Loads a list of thumanils for the specicifies parameters, returns an array of Schedule\Task elements
  *
  * @return array
  */
 public function load()
 {
     $tasks = array();
     $tasksData = $this->db->fetchCol("SELECT id FROM schedule_tasks" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     foreach ($tasksData as $taskData) {
         $tasks[] = Model\Schedule\Task::getById($taskData);
     }
     $this->model->setTasks($tasks);
     return $tasks;
 }