예제 #1
0
 /**
  * @param $fileName
  * @param string $subFolder
  * @return \EBT\ExtensionBuilder\Domain\Model\File
  */
 protected function parseAndWrite($fileName, $subFolder = '')
 {
     $classFilePath = $this->fixturesPath . $subFolder . $fileName;
     $this->assertTrue(file_exists($classFilePath));
     $fileHandler = fopen($classFilePath, 'r');
     $classFileObject = $this->parserService->parseFile($classFilePath);
     $newClassFilePath = $this->tmpDir . $fileName;
     file_put_contents($newClassFilePath, $this->printerService->renderFileObject($classFileObject, true));
     return $classFileObject;
 }
예제 #2
0
 /**
  * Generates the code for the repository class
  * Either from domainRepository template or from class partial
  *
  * @param \EBT\ExtensionBuilder\Domain\Model\DomainObject $domainObject
  * @param bool $mergeWithExistingClass
  *
  * @return string
  */
 public function generateDomainRepositoryCode(\EBT\ExtensionBuilder\Domain\Model\DomainObject $domainObject)
 {
     $repositoryTemplateClassPath = $this->codeTemplateRootPath . 'Classes/Domain/Repository/Repository.phpt';
     $existingClassFileObject = null;
     if ($this->roundTripEnabled) {
         $existingClassFileObject = $this->roundTripService->getRepositoryClassFile($domainObject);
     }
     $repositoryClassFileObject = $this->classBuilder->generateRepositoryClassFileObject($domainObject, $repositoryTemplateClassPath, $existingClassFileObject);
     if ($repositoryClassFileObject) {
         $this->addLicenseHeader($repositoryClassFileObject->getFirstClass());
         return $this->printerService->renderFileObject($repositoryClassFileObject, true);
     } else {
         throw new \Exception('Class file for repository could not be generated');
     }
 }