Exemplo n.º 1
0
 public function addRepository(Repository $repository)
 {
     if ($repository->getName() == '') {
         throw new AnyContentClientException('Cannot add repository without name');
     }
     $this->repositories[$repository->getName()] = $repository;
     if ($repository instanceof CachingRepository) {
         $repository->setCacheProvider($this->getCacheProvider());
     }
     return $repository;
 }
 /**
  * @param $configTypeName
  *
  * @return \CMDL\ConfigTypeDefinition|ContentTypeDefinition|\CMDL\DataTypeDefinition|null
  * @throws AnyContentClientException
  * @throws \CMDL\CMDLParserException
  */
 public function getConfigTypeDefinition($configTypeName)
 {
     if ($this->getConfiguration()->hasConfigType($configTypeName)) {
         $cacheKey = '[cmdl][config][' . $configTypeName . ']';
         if ($this->repository) {
             $cacheKey = '[' . $this->repository->getName() . ']' . $cacheKey;
         }
         if ($this->cmdlCachingCheckLastModifiedDate) {
             $cacheKey .= '[' . $this->getCMDLLastModifiedDate(null, $configTypeName) . ']';
         }
         if ($this->getCMDLCache()->contains($cacheKey)) {
             return unserialize($this->getCMDLCache()->fetch($cacheKey));
         }
         $cmdl = $this->getCMDLForConfigType($configTypeName);
         if ($cmdl) {
             $parser = $this->getParser();
             $definition = $parser->parseCMDLString($cmdl, $configTypeName, null, 'config');
             if ($definition) {
                 $this->getCMDLCache()->save($cacheKey, serialize($definition), (int) $this->cmdlCaching);
                 return $definition;
             }
         }
     }
     throw new AnyContentClientException('Unknown config type ' . $configTypeName);
 }
 /**
  * @param $configTypeName
  *
  * @return \CMDL\ConfigTypeDefinition|ContentTypeDefinition|\CMDL\DataTypeDefinition|null
  * @throws AnyContentClientException
  * @throws \CMDL\CMDLParserException
  */
 public function getConfigTypeDefinition($configTypeName)
 {
     if ($this->getConfiguration()->hasConfigType($configTypeName)) {
         $cacheKey = '[cmdl][config][' . $configTypeName . ']';
         if ($this->repository) {
             $cacheKey = '[' . $this->repository->getName() . ']' . $cacheKey;
         }
         if ($this->getCMDLCache()->contains($cacheKey)) {
             return $this->getCMDLCache()->fetch($cacheKey);
         }
         $cmdl = $this->getCMDLForConfigType($configTypeName);
         if ($cmdl) {
             $parser = $this->getParser();
             $definition = $parser->parseCMDLString($cmdl, $configTypeName, null, 'config');
             if ($definition) {
                 //$this->contentTypeDefinitions[$configTypeName]['definition'] = $definition;
                 $this->getCMDLCache()->save($cacheKey, $definition, (int) $this->cmdlCaching);
                 return $definition;
             }
         }
     }
     throw new AnyContentClientException('Unknown config type ' . $configTypeName);
 }
 public function getConfigTypeAccessHash(Repository $repository, $configTypeName)
 {
     return md5($repository->getName() . '-contentType-' . $configTypeName);
 }