コード例 #1
0
 /**
  * Will add a structure entry to the map.
  *
  * @param \TechDivision\PBC\Entities\Definitions\Structure $structure The structure to add
  *
  * @return bool
  */
 public function add(Structure $structure)
 {
     // The the entry
     $this->map[$structure->getIdentifier()] = array('cTime' => $structure->getCTime(), 'identifier' => $structure->getIdentifier(), 'path' => $structure->getPath(), 'type' => $structure->getType(), 'hasContracts' => $structure->hasContracts(), 'enforced' => $structure->isEnforced());
     // Persist the map
     return $this->save();
 }
コード例 #2
0
 /**
  * Will create an altered definition of the structure defined in the $mapEntry variable.
  * Will also add it to the cache map
  *
  * @param \TechDivision\PBC\Entities\Definitions\Structure $mapEntry        Entry of a StructureMap we want created
  * @param boolean                                          $createRecursive If contract inheritance is enabled
  *
  * @throws \TechDivision\PBC\Exceptions\GeneratorException
  *
  * @return boolean
  */
 public function create(Structure $mapEntry, $createRecursive = false)
 {
     // We know what we are searching for and we got a fine factory so lets get us a parser
     $structureParserFactory = new StructureParserFactory();
     $parser = $structureParserFactory->getInstance($mapEntry->getType(), $mapEntry->getPath(), $this->config, $this->structureMap, $this->structureDefinitionHierarchy);
     // Lets get the definition we are looking for
     $structureDefinition = $parser->getDefinition($mapEntry->getIdentifier(), $createRecursive);
     if (!$structureDefinition instanceof StructureDefinitionInterface) {
         return false;
     }
     $qualifiedName = $structureDefinition->getQualifiedName();
     $filePath = $this->createFilePath($qualifiedName, $mapEntry->getPath());
     $tmp = $this->createFileFromDefinition($filePath, $structureDefinition);
     if ($tmp === false) {
         throw new GeneratorException('Could not create contracted definition for ' . $qualifiedName);
     }
     // Now get our new file into the cacheMap
     $this->cache->add(new Structure(filectime($mapEntry->getPath()), $qualifiedName, $filePath, $structureDefinition->getType()));
     // Still here? Than everything worked out great.
     return true;
 }