/** * Loads the workflow into the manager * @throws \Exception */ private function initWorkflow() { $config = Workflow\Config::getElementWorkflowConfig($this->element); $this->workflow = Workflow\Factory::getWorkflowFromConfig($config); if (!$this->workflow) { throw new \Exception("Cannot load workflow configuration for object [{$this->element->getId()}] of type [{$this->element->getType()}]"); } }
/** * @see Object\ClassDefinition\Data::getDataForEditmode * @param Asset|Document|Object\AbstractObject $data * @param null|Model\Object\AbstractObject $object * @return array */ public function getDataForEditmode($data, $object = null) { if ($data instanceof Element\ElementInterface) { $r = array("id" => $data->getId(), "path" => $data->getFullPath(), "subtype" => $data->getType(), "type" => Element\Service::getElementType($data)); return $r; } return; }
/** * Static helper to get an asset by the passed id (returned is not the concrete asset like Asset\Folder!) * * @param integer $id * @return Asset */ public static function getById($id) { $id = intval($id); if ($id < 1) { return null; } $cacheKey = "asset_" . $id; try { $asset = \Zend_Registry::get($cacheKey); if (!$asset) { throw new \Exception("Asset in registry is null"); } } catch (\Exception $e) { try { if (!($asset = Cache::load($cacheKey))) { $asset = new Asset(); $asset->getResource()->getById($id); $mappingClass = "\\Pimcore\\Model\\Asset\\" . ucfirst($asset->getType()); $typeClass = Tool::getModelClassMapping($mappingClass); if (Tool::classExists($typeClass)) { $asset = new $typeClass(); \Zend_Registry::set($cacheKey, $asset); $asset->getResource()->getById($id); Cache::save($asset, $cacheKey); } } else { \Zend_Registry::set($cacheKey, $asset); } } catch (\Exception $e) { \Logger::warning($e->getMessage()); return null; } } if (!$asset) { return null; } return $asset; }
/** * Static helper to get an asset by the passed id (returned is not the concrete asset like Asset\Folder!) * * @param integer $id * @return Asset */ public static function getById($id) { $id = intval($id); if ($id < 1) { return null; } $cacheKey = "asset_" . $id; try { $asset = \Zend_Registry::get($cacheKey); if (!$asset) { throw new \Exception("Asset in registry is null"); } } catch (\Exception $e) { try { if (!($asset = \Pimcore\Cache::load($cacheKey))) { $asset = new Asset(); $asset->getDao()->getById($id); $className = "Pimcore\\Model\\Asset\\" . ucfirst($asset->getType()); $asset = \Pimcore::getDiContainer()->make($className); \Zend_Registry::set($cacheKey, $asset); $asset->getDao()->getById($id); \Pimcore\Cache::save($asset, $cacheKey); } else { \Zend_Registry::set($cacheKey, $asset); } } catch (\Exception $e) { \Logger::warning($e->getMessage()); return null; } } if (!$asset) { return null; } return $asset; }