/**
  * Will add a structure entry to the map.
  *
  * @param \AppserverIo\Doppelgaenger\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(), 'hasAnnotations' => $structure->hasAnnotations(), 'enforced' => $structure->isEnforced());
     // Persist the map
     return $this->save();
 }
Esempio n. 2
0
 /**
  * Will create an altered definition of the structure defined in the $mapEntry variable.
  * Will also add it to the cache map
  *
  * @param \AppserverIo\Doppelgaenger\Entities\Definitions\Structure $mapEntry        Entry of a StructureMap we want created
  * @param boolean                                                   $createRecursive If contract inheritance is enabled
  *
  * @throws \AppserverIo\Doppelgaenger\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) {
         // we did not get what we need, so fail
         return false;
     }
     $qualifiedName = $structureDefinition->getQualifiedName();
     $filePath = $this->createFilePath($qualifiedName, $mapEntry->getPath());
     $tmp = $this->createFileFromDefinition($filePath, $structureDefinition);
     if ($tmp === false) {
         // we were not able to create a new definition file, fail
         throw new GeneratorException(sprintf('Could not create altered definition for %s', $qualifiedName));
     }
     // Now get our new file into the cacheMap
     $this->cacheMap->add(new Structure(filectime($mapEntry->getPath()), $qualifiedName, $filePath, $structureDefinition->getType()));
     // Still here? Than everything worked out great.
     return true;
 }