/** * @param integer $id * @return Glossary */ public static function getById($id) { $glossary = new self(); $glossary->setId(intval($id)); $glossary->getDao()->getById(); return $glossary; }
/** * @param string $key * @param boolean $returnObject * @return mixed|null */ public static function get($key, $returnObject = FALSE) { $cacheKey = $key . '~~~'; if (array_key_exists($cacheKey, self::$nameIdMappingCache)) { $entry = self::getById(self::$nameIdMappingCache[$cacheKey]); if ($returnObject) { return $entry; } return $entry instanceof Configuration ? $entry->getData() : NULL; } $configurationEntry = new self(); try { $configurationEntry->getDao()->getByKey($key); } catch (\Exception $e) { return NULL; } if ($configurationEntry->getId() > 0) { self::$nameIdMappingCache[$cacheKey] = $configurationEntry->getId(); $entry = self::getById($configurationEntry->getId()); if ($returnObject) { return $entry; } return $entry instanceof Configuration ? $entry->getData() : NULL; } }
/** * @param integer $id * @return Redirect */ public static function getById($id) { $redirect = new self(); $redirect->setId(intval($id)); $redirect->getDao()->getById(); return $redirect; }
/** * Static helper to get the dependencies for the given sourceId & type * * @param integer $id * @param string $type * @return Dependency */ public static function getBySourceId($id, $type) { $d = new self(); $d->setSourceId($id); $d->setSourceType($type); $d->getDao()->getBySourceId(); return $d; }
/** * @static * @param $id * @return Element\Note */ public static function getById($id) { try { $note = new self(); $note->getDao()->getById($id); return $note; } catch (\Exception $e) { return null; } }
/** * @param $addr * @return null|Blacklist */ public static function getByAddress($addr) { try { $address = new self(); $address->getDao()->getByAddress($addr); return $address; } catch (\Exception $e) { return null; } }
/** * @param $name * @return Config * @throws \Exception */ public static function getByName($name) { try { $tag = new self(); $tag->getDao()->getByName($name); } catch (\Exception $e) { return null; } return $tag; }
/** * @param $cid * @param $ctype * @param $workflowId * @return null|WorkflowState */ public static function getByPrimary($cid, $ctype, $workflowId) { try { $workflowState = new self(); $workflowState->getDao()->getByPrimary($cid, $ctype, $workflowId); return $workflowState; } catch (\Exception $e) { return null; } }
/** * @param $name * @return null|Config */ public static function getByName($name) { try { $letter = new self(); $letter->getDao()->getByName($name); } catch (\Exception $e) { return null; } return $letter; }
/** * @static * @param $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; } }
/** * @param $name * @return GroupConfig */ public static function getByName($name) { try { $config = new self(); $config->setName($name); $config->getDao()->getByName(); return $config; } catch (\Exception $e) { } }
/** * Static helper to retrieve an instance of Document\DocType by the given ID * * @param integer $id * @return DocType */ public static function getById($id) { $docType = new self(); $docType->setId(intval($id)); try { $docType->getDao()->getById(); } catch (\Exception $e) { return null; } return $docType; }
/** * @param $id * @return null|Persona */ public static function getById($id) { try { $persona = new self(); $persona->setId(intval($id)); $persona->getDao()->getById(); return $persona; } catch (\Exception $e) { return null; } }
/** * @param string $name * @return WebsiteSetting */ public static function getByName($name, $siteId = null) { // create a tmp object to obtain the id $setting = new self(); try { $setting->getDao()->getByName($name, $siteId); } catch (\Exception $e) { \Logger::error($e); return null; } return $setting; }
/** * @param $category * @param $action * @param $label * @param $day * @param $month * @param $year * @return Event */ public static function getByDate($category, $action, $label, $day, $month, $year) { $event = new self(); try { $event->getDao()->getByDate($category, $action, $label, $day, $month, $year); } catch (\Exception $e) { $event->setTimestamp(mktime(1, 0, 0, $month, $day, $year)); $event->setCategory($category); $event->setAction($action); $event->setLabel($label); } return $event; }
/** * @param integer $id * @return 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; }
/** * @param string $id * @return Unit */ public static function getById($id) { $cacheKey = Unit\Dao::TABLE_NAME . "_" . $id; try { $unit = \Zend_Registry::get($cacheKey); } catch (\Exception $e) { try { $unit = new self(); $unit->getDao()->getById($id); \Zend_Registry::set($cacheKey, $unit); } catch (\Exception $ex) { \Logger::debug($ex->getMessage()); return null; } } return $unit; }
/** * @param $name * @return null|Config */ public static function getByName($name) { $cacheKey = "videothumb_" . crc32($name); try { $thumbnail = \Zend_Registry::get($cacheKey); if (!$thumbnail) { throw new \Exception("Thumbnail in registry is null"); } } catch (\Exception $e) { try { $thumbnail = new self(); $thumbnail->getDao()->getByName($name); \Zend_Registry::set($cacheKey, $thumbnail); } catch (\Exception $e) { return null; } } return $thumbnail; }
/** * @param $id * @return mixed|null|CustomLayout * @throws \Exception */ public static function getById($id) { if ($id === null) { throw new \Exception("CustomLayout id is null"); } $cacheKey = "customlayout_" . $id; try { $customLayout = \Zend_Registry::get($cacheKey); if (!$customLayout) { throw new \Exception("Custom Layout in registry is null"); } } catch (\Exception $e) { try { $customLayout = new self(); $customLayout->getDao()->getById($id); Object\Service::synchronizeCustomLayout($customLayout); \Zend_Registry::set($cacheKey, $customLayout); } catch (\Exception $e) { \Logger::error($e); return null; } } return $customLayout; }
/** * @param string $key * @return self */ public static function getByKey($key) { $cacheKey = "property_predefined_" . $key; try { $property = \Zend_Registry::get($cacheKey); if (!$property) { throw new \Exception("Predefined property in registry is null"); } } catch (\Exception $e) { $property = new self(); $property->setKey($key); $property->getDao()->getByKey(); \Zend_Registry::set($cacheKey, $property); } return $property; }
/** * @param $name * @return null|Config */ public static function getByName($name) { $cacheKey = "imagethumb_" . crc32($name); try { $thumbnail = \Zend_Registry::get($cacheKey); $thumbnail->setName($name); if (!$thumbnail) { throw new \Exception("Thumbnail in registry is null"); } } catch (\Exception $e) { try { $thumbnail = new self(); $thumbnail->setName($name); $thumbnail->getDao()->getByName(); \Zend_Registry::set($cacheKey, $thumbnail); } catch (\Exception $e) { return null; } } // only return clones of configs, this is necessary since we cache the configs in the registry (see above) // sometimes, e.g. when using the cropping tools, the thumbnail configuration is modified on-the-fly, since // pass-by-reference this modifications would then go to the cache/registry (singleton), by cloning the config // we can bypass this problem in an elegant way without parsing the XML config again and again $clone = clone $thumbnail; return $clone; }
/** * @param string $name * @return self */ public static function getByName($name) { $class = new self(); try { $class->getDao()->getByName($name); } catch (\Exception $e) { \Logger::error($e); return null; } // to have a singleton in a way. like all instances of Element\ElementInterface do also, like Object\AbstractObject if ($class->getId() > 0) { return self::getById($class->getId()); } }
/** * @param string $key * @return self */ public static function getByName($name, $language = "") { try { $metadata = new self(); $metadata->setName($name); $metadata->getDao()->getByNameAndLanguage($name, $language); return $metadata; } catch (\Exception $e) { return null; } }
/** * @param $element * @return Data */ public static function getForElement($element) { $data = new self(); $data->getDao()->getForElement($element); return $data; }
/** * @param string $key * @return self */ public static function getByName($name, $language = "") { $metadata = new self(); $metadata->setName($name); $metadata->getDao()->getByNameAndLanguage($name, $language); return $metadata; }
/** * @param string $name * @return Staticroute */ public static function getByName($name, $siteId = null) { $cacheKey = $name . "~~~" . $siteId; // check if pimcore already knows the id for this $name, if yes just return it if (array_key_exists($cacheKey, self::$nameIdMappingCache)) { return self::getById(self::$nameIdMappingCache[$cacheKey]); } // create a tmp object to obtain the id $route = new self(); try { $route->getDao()->getByName($name, $siteId); } catch (\Exception $e) { \Logger::warn($e); return null; } // to have a singleton in a way. like all instances of Element\ElementInterface do also, like Object\AbstractObject if ($route->getId() > 0) { // add it to the mini-per request cache self::$nameIdMappingCache[$cacheKey] = $route->getId(); return self::getById($route->getId()); } }
/** * @param $name * @return null|Config */ public static function getByName($name) { try { $report = new self(); $report->getDao()->getByName($name); } catch (\Exception $e) { return null; } return $report; }
/** * @param string $path * @return self */ public static function getByPath($path) { $path = Model\Element\Service::correctPath($path); try { $object = new self(); if (Tool::isValidPath($path)) { $object->getDao()->getByPath($path); return self::getById($object->getId()); } } catch (\Exception $e) { \Logger::warning($e->getMessage()); } return null; }
/** * @param $uuid * @return mixed */ public static function getByUuid($uuid) { $self = new self(); return $self->getDao()->getByUuid($uuid); }
/** * @param integer $id * @return Version */ public static function getById($id) { $version = new self(); $version->getDao()->getById($id); return $version; }