/** * * @param \EBT\ExtensionBuilder\Domain\Model\DomainObject $domainObject * * @return \EBT\ExtensionBuilder\Domain\Model\File|null */ public function getControllerClassFile(Model\DomainObject $currentDomainObject) { $extensionDir = $this->previousExtensionDirectory; if (isset($this->previousDomainObjects[$currentDomainObject->getUniqueIdentifier()])) { $oldDomainObject = $this->previousDomainObjects[$currentDomainObject->getUniqueIdentifier()]; $fileName = FileGenerator::getFolderForClassFile($extensionDir, 'Controller', false); $fileName .= $oldDomainObject->getName() . 'Controller.php'; if (file_exists($fileName)) { $this->classFileObject = $this->parserService->parseFile($fileName); $this->classObject = $this->classFileObject->getFirstClass(); $this->classObject->setName($currentDomainObject->getName() . 'Controller'); if ($oldDomainObject->getName() != $currentDomainObject->getName() || $this->extensionRenamed) { $this->mapOldControllerToCurrentClassObject($oldDomainObject, $currentDomainObject); } elseif ($oldDomainObject->isAggregateRoot() && !$currentDomainObject->isAggregateRoot()) { $injectMethodName = 'inject' . GeneralUtility::lcfirst($oldDomainObject->getName()) . 'Repository'; $this->classObject->removeMethod($injectMethodName); } $newActions = array(); foreach ($currentDomainObject->getActions() as $newAction) { $newActions[$newAction->getName()] = $newAction; } $oldActions = $oldDomainObject->getActions(); if (isset($this->previousDomainObjects[$currentDomainObject->getUniqueIdentifier()])) { // now we remove old action methods foreach ($oldActions as $oldAction) { if (!isset($newActions[$oldAction->getName()])) { // an action was removed $this->classObject->removeMethod($oldAction->getName() . 'Action'); $this->log('Action method removed:' . $oldAction->getName(), 0, $this->classObject->getMethods()); } } // we don't have to add new ones, this will be done automatically by the class builder } if ($this->extension->vendorNameChanged()) { $this->updateVendorName(); } $this->classFileObject->setClasses(array($this->classObject)); return $this->classFileObject; } else { GeneralUtility::devLog('class file didn\'t exist:' . $fileName, 'extension_builder', 2); return null; } } else { $fileName = FileGenerator::getFolderForClassFile($extensionDir, 'Controller', false); $fileName .= $currentDomainObject->getName() . 'Controller.php'; if (file_exists($fileName)) { $this->classFileObject = $this->parserService->parseFile($fileName); $this->classObject = $this->classFileObject->getFirstClass(); $this->classObject->setFileName($fileName); $className = $currentDomainObject->getControllerClassName(); $this->classObject->setName($className); if ($this->extension->vendorNameChanged()) { $this->updateVendorName(); } $this->classFileObject->setClasses(array($this->classObject)); return $this->classFileObject; } else { $this->log('No existing controller class:' . $fileName, 2); } } $this->log('No existing controller class:' . $currentDomainObject->getName(), 2); return null; }