public function __construct($p_templateIdOrName = null, $p_themePath = null)
{
$this->m_properties = array();
$this->m_customProperties['name'] = 'getValue';
$this->m_customProperties['identifier'] = 'getId';
$this->m_customProperties['type'] = 'getTemplateType';
$this->m_customProperties['defined'] = 'defined';
$this->m_customProperties['theme_dir'] = 'getThemeDir';
$this->_map = array("frontPage" => "issue", "errorPage" => "default", "sectionPage" => "section", "issuePage" => "issue", "articlePage" => "article");
if ((is_string($p_templateIdOrName) || is_int($p_templateIdOrName)) && !empty($p_templateIdOrName)) {
$cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
$cacheKey = $cacheService->getCacheKey(array('MetaTemplate', $p_templateIdOrName, $p_themePath), 'template');
if ($cacheService->contains($cacheKey)) {
$this->m_dbObject = $cacheService->fetch($cacheKey);
} else {
$filePath = is_numeric($p_templateIdOrName) ? $p_templateIdOrName : $p_themePath . $p_templateIdOrName;
$resourceId = new ResourceId('template_engine/metaclasses/MetaTemplate');
/* @var $syncResourceService ISyncResourceService */
$syncResourceService = $resourceId->getService(ISyncResourceService::NAME);
$this->m_dbObject = $syncResourceService->findByPathOrId($filePath);
$cacheService->save($cacheKey, $this->m_dbObject);
}
if (is_null($this->m_dbObject)) {
$pathRsc = new Resource();
$pathRsc->setName('buildPage');
$filePath = CS_PATH_TEMPLATES . DIR_SEP . $p_themePath . $p_templateIdOrName;
if (!is_numeric($p_templateIdOrName) && !is_null($p_themePath) && file_exists($filePath)) {
$pathRsc->setPath($p_themePath . $p_templateIdOrName);
$this->m_dbObject = $syncResourceService->getSynchronized($pathRsc);
} else {
$this->m_dbObject = $pathRsc;
}
}
}
}