/** * This method generates the class schema object, which is passed to the template * it keeps all methods and properties including user modified method bodies and * comments needed to create a domain object class file * * @param \EBT\ExtensionBuilder\Domain\Model\DomainObject $domainObject * @param \EBT\ExtensionBuilder\Domain\Model\File $existingClassFileObject * * @return \EBT\ExtensionBuilder\Domain\Model\File */ public function generateModelClassFileObject($domainObject, $modelClassTemplatePath, $existingClassFileObject = null) { $this->classObject = null; $this->templateFileObject = $this->parserService->parseFile($modelClassTemplatePath); $this->templateClassObject = $this->templateFileObject->getFirstClass(); if ($existingClassFileObject) { $this->classFileObject = $existingClassFileObject; $this->classObject = $existingClassFileObject->getFirstClass(); if ($this->classFileObject->getNamespace() === false) { $nameSpace = new \EBT\ExtensionBuilder\Domain\Model\NamespaceObject('dummy'); $this->classFileObject->addNamespace($nameSpace); } } if ($this->classObject == null) { $this->createNewModelClassObject($domainObject); } if (!$this->classObject->hasDescription() && $domainObject->getDescription()) { $this->classObject->setDescription($domainObject->getDescription()); } $this->addInitStorageObjectCalls($domainObject); foreach ($domainObject->getProperties() as $domainProperty) { $this->addClassProperty($domainProperty); if ($domainProperty->isNew()) { $this->setPropertyRelatedMethods($domainProperty); } } $this->classFileObject->getNamespace()->setName($this->extension->getNamespaceName() . '\\Domain\\Model')->setClasses(array($this->classObject)); return $this->classFileObject; }
/** * This method generates the class schema object, which is passed to the template * it keeps all methods and properties including user modified method bodies and * comments needed to create a domain object class file * * @param \EBT\ExtensionBuilder\Domain\Model\DomainObject $domainObject * @param boolean $mergeWithExistingClass * * @return \EBT\ExtensionBuilder\Domain\Model\File */ public function generateModelClassFileObject($domainObject, $modelClassTemplatePath, $mergeWithExistingClass) { $this->classObject = NULL; $fullQualifiedClassName = $domainObject->getFullQualifiedClassName(); $this->templateFileObject = $this->parserService->parseFile($modelClassTemplatePath); $this->templateClassObject = $this->templateFileObject->getFirstClass(); if ($mergeWithExistingClass) { try { $this->classFileObject = $this->roundTripService->getDomainModelClassFile($domainObject); if (!is_null($this->classFileObject)) { $this->classObject = $this->classFileObject->getFirstClass(); } } catch (\Exception $e) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Class ' . $fullQualifiedClassName . ' could not be imported: ' . $e->getMessage(), 'extension_builder', 2); } } if ($this->classObject == NULL) { $this->createNewModelClassObject($domainObject); } if (!$this->classObject->hasDescription() && $domainObject->getDescription()) { $this->classObject->setDescription($domainObject->getDescription()); } $this->addInitStorageObjectCalls($domainObject); foreach ($domainObject->getProperties() as $domainProperty) { $this->addClassProperty($domainProperty); if ($domainProperty->isNew()) { $this->setPropertyRelatedMethods($domainProperty); } } $this->classFileObject->getNamespace()->setName($this->extension->getNamespaceName() . '\\Domain\\Model')->setClasses(array($this->classObject)); return $this->classFileObject; }