/** * @param \EBT\ExtensionBuilder\Domain\Model\Extension $extension * @param array $propertyConfiguration * @return void */ protected function setExtensionProperties(&$extension, $propertyConfiguration) { // name $extension->setName(trim($propertyConfiguration['name'])); // description $extension->setDescription($propertyConfiguration['description']); // extensionKey $extension->setExtensionKey(trim($propertyConfiguration['extensionKey'])); // vendorName $extension->setVendorName(trim($propertyConfiguration['vendorName'])); if (!empty($propertyConfiguration['emConf']['sourceLanguage'])) { $extension->setSourceLanguage($propertyConfiguration['emConf']['sourceLanguage']); } if ($propertyConfiguration['emConf']['disableVersioning']) { $extension->setSupportVersioning(false); } if ($propertyConfiguration['emConf']['disableLocalization']) { $extension->setSupportLocalization(false); } if (!empty($propertyConfiguration['emConf']['skipGenerateDocumentationTemplate'])) { $extension->setGenerateDocumentationTemplate(false); } // various extension properties $extension->setVersion($propertyConfiguration['emConf']['version']); if (!empty($propertyConfiguration['emConf']['dependsOn'])) { $dependencies = array(); $lines = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $propertyConfiguration['emConf']['dependsOn']); foreach ($lines as $line) { if (strpos($line, '=>')) { list($extensionKey, $version) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('=>', $line); $dependencies[$extensionKey] = $version; } } $extension->setDependencies($dependencies); } if (!empty($propertyConfiguration['emConf']['targetVersion'])) { $extension->setTargetVersion(floatval($propertyConfiguration['emConf']['targetVersion'])); } if (!empty($propertyConfiguration['emConf']['custom_category'])) { $category = $propertyConfiguration['emConf']['custom_category']; } else { $category = $propertyConfiguration['emConf']['category']; } $extension->setCategory($category); // state $state = 0; switch ($propertyConfiguration['emConf']['state']) { case 'alpha': $state = \EBT\ExtensionBuilder\Domain\Model\Extension::STATE_ALPHA; break; case 'beta': $state = \EBT\ExtensionBuilder\Domain\Model\Extension::STATE_BETA; break; case 'stable': $state = \EBT\ExtensionBuilder\Domain\Model\Extension::STATE_STABLE; break; case 'experimental': $state = \EBT\ExtensionBuilder\Domain\Model\Extension::STATE_EXPERIMENTAL; break; case 'test': $state = \EBT\ExtensionBuilder\Domain\Model\Extension::STATE_TEST; break; } $extension->setState($state); if (!empty($propertyConfiguration['originalExtensionKey'])) { // handle renaming of extensions // original extensionKey $extension->setOriginalExtensionKey($propertyConfiguration['originalExtensionKey']); \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Extension setOriginalExtensionKey:' . $extension->getOriginalExtensionKey(), 'extbase', 0, $propertyConfiguration); } if (!empty($propertyConfiguration['originalExtensionKey']) && $extension->getOriginalExtensionKey() != $extension->getExtensionKey()) { $settings = $this->configurationManager->getExtensionSettings($extension->getOriginalExtensionKey()); // if an extension was renamed, a new extension dir is created and we // have to copy the old settings file to the new extension dir copy($this->configurationManager->getSettingsFile($extension->getOriginalExtensionKey()), $this->configurationManager->getSettingsFile($extension->getExtensionKey())); } else { $settings = $this->configurationManager->getExtensionSettings($extension->getExtensionKey()); } if (!empty($settings)) { $extension->setSettings($settings); \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('Extension settings:' . $extension->getExtensionKey(), 'extbase', 0, $extension->getSettings()); } }
/** * If a JSON file is found in the extensions directory the previous version * of the extension is build to compare it with the new configuration coming * from the extension builder input * * @param \EBT\ExtensionBuilder\Domain\Model\Extension $extension */ public function initialize(Model\Extension $extension) { $this->extension = $extension; $this->extensionDirectory = $this->extension->getExtensionDir(); if (!$this->parserService instanceof \EBT\ExtensionBuilder\Service\Parser) { $this->injectParserService(GeneralUtility::makeInstance('EBT\\ExtensionBuilder\\Service\\Parser')); } $this->settings = $this->configurationManager->getExtensionBuilderSettings(); // defaults $this->previousExtensionDirectory = $this->extensionDirectory; $this->previousExtensionKey = $this->extension->getExtensionKey(); if ($extension->isRenamed()) { $this->previousExtensionDirectory = $extension->getPreviousExtensionDirectory(); $this->previousExtensionKey = $extension->getOriginalExtensionKey(); $this->extensionRenamed = true; GeneralUtility::devlog('Extension renamed: ' . $this->previousExtensionKey . ' => ' . $this->extension->getExtensionKey(), 'extension_builder', 1, array('$previousExtensionDirectory ' => $this->previousExtensionDirectory)); } // Rename the old kickstarter.json file to ExtensionBuilder.json if (file_exists($this->previousExtensionDirectory . 'kickstarter.json')) { rename($this->previousExtensionDirectory . 'kickstarter.json', $this->previousExtensionDirectory . ConfigurationManager::EXTENSION_BUILDER_SETTINGS_FILE); } if (file_exists($this->previousExtensionDirectory . ConfigurationManager::EXTENSION_BUILDER_SETTINGS_FILE)) { $extensionSchemaBuilder = GeneralUtility::makeInstance('EBT\\ExtensionBuilder\\Service\\ExtensionSchemaBuilder'); $jsonConfig = $this->configurationManager->getExtensionBuilderConfiguration($this->previousExtensionKey, false); GeneralUtility::devlog('old JSON:' . $this->previousExtensionDirectory . 'ExtensionBuilder.json', 'extension_builder', 0, $jsonConfig); $this->previousExtension = $extensionSchemaBuilder->build($jsonConfig); $previousDomainObjects = $this->previousExtension->getDomainObjects(); /** @var $previousDomainObjects \EBT\ExtensionBuilder\Domain\Model\DomainObject[] */ foreach ($previousDomainObjects as $oldDomainObject) { $this->previousDomainObjects[$oldDomainObject->getUniqueIdentifier()] = $oldDomainObject; $this->log('Old domain object: ' . $oldDomainObject->getName() . ' - ' . $oldDomainObject->getUniqueIdentifier(), 0, $jsonConfig); } /** * now we store all renamed domainObjects in an array to enable * detection of renaming in relationProperties (property->getForeignModel) * we also build an array with the new unique identifiers to detect * deleting of domainObjects */ $currentDomainsObjects = array(); foreach ($this->extension->getDomainObjects() as $domainObject) { /** @var \EBT\ExtensionBuilder\Domain\Model\DomainObject $domainObject */ if (isset($this->previousDomainObjects[$domainObject->getUniqueIdentifier()])) { if ($this->previousDomainObjects[$domainObject->getUniqueIdentifier()]->getName() != $domainObject->getName()) { $renamedDomainObjects[$domainObject->getUniqueIdentifier()] = $domainObject; } } $currentDomainsObjects[$domainObject->getUniqueIdentifier()] = $domainObject; } // remove deleted objects foreach ($previousDomainObjects as $oldDomainObject) { if (!isset($currentDomainsObjects[$oldDomainObject->getUniqueIdentifier()])) { $this->removeDomainObjectFiles($oldDomainObject); } } } }