Example #1
0
 /**
  * @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;
     }
 }
Example #3
0
 /**
  * @param integer $id
  * @return Redirect
  */
 public static function getById($id)
 {
     $redirect = new self();
     $redirect->setId(intval($id));
     $redirect->getDao()->getById();
     return $redirect;
 }
Example #4
0
 /**
  * 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;
 }
Example #5
0
 /**
  * @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;
     }
 }
Example #6
0
 /**
  * @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;
     }
 }
Example #7
0
 /**
  * @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;
 }
Example #8
0
 /**
  * @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;
     }
 }
Example #9
0
 /**
  * @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;
 }
Example #10
0
 /**
  * @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;
     }
 }
Example #11
0
 /**
  * @param $name
  * @return GroupConfig
  */
 public static function getByName($name)
 {
     try {
         $config = new self();
         $config->setName($name);
         $config->getDao()->getByName();
         return $config;
     } catch (\Exception $e) {
     }
 }
Example #12
0
 /**
  * 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;
 }
Example #13
0
 /**
  * @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;
     }
 }
Example #14
0
 /**
  * @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;
 }
Example #15
0
 /**
  * @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;
 }
Example #16
0
 /**
  * @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;
 }
Example #17
0
 /**
  * @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;
 }
Example #18
0
 /**
  * @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;
 }
Example #19
0
 /**
  * @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;
 }
Example #20
0
 /**
  * @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;
 }
Example #21
0
 /**
  * @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;
 }
Example #22
0
 /**
  * @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());
     }
 }
Example #23
0
 /**
  * @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;
     }
 }
Example #24
0
 /**
  * @param $element
  * @return Data
  */
 public static function getForElement($element)
 {
     $data = new self();
     $data->getDao()->getForElement($element);
     return $data;
 }
Example #25
0
 /**
  * @param string $key
  * @return self
  */
 public static function getByName($name, $language = "")
 {
     $metadata = new self();
     $metadata->setName($name);
     $metadata->getDao()->getByNameAndLanguage($name, $language);
     return $metadata;
 }
Example #26
0
 /**
  * @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());
     }
 }
Example #27
0
 /**
  * @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;
 }
Example #28
0
 /**
  * @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;
 }
Example #29
0
 /**
  * @param $uuid
  * @return mixed
  */
 public static function getByUuid($uuid)
 {
     $self = new self();
     return $self->getDao()->getByUuid($uuid);
 }
Example #30
0
 /**
  * @param integer $id
  * @return Version
  */
 public static function getById($id)
 {
     $version = new self();
     $version->getDao()->getById($id);
     return $version;
 }