public function getStatusMessage()
 {
     $statusMessage = '';
     $this->checkForDbUpdate($this->extension->getExtensionKey(), $this->extension->getExtensionDir() . 'ext_tables.sql');
     if ($this->dbUpdateNeeded) {
         $statusMessage .= '<p>Database has to be updated!</p>';
         $typeInfo = array('add' => 'Add fields', 'change' => 'Change fields', 'create_table' => 'Create tables');
         $statusMessage .= '<div id="dbUpdateStatementsWrapper"><table>';
         foreach ($this->updateStatements as $type => $statements) {
             $statusMessage .= '<tr><td></td><td style="text-align:left;padding-left:15px">' . $typeInfo[$type] . ':</td></tr>';
             foreach ($statements as $key => $statement) {
                 if ($type == 'add') {
                     $statusMessage .= '<tr><td><input type="checkbox" name="dbUpdateStatements[]" value="' . $key . '" checked="checked" /></td><td style="text-align:left;padding-left:15px">' . $statement . '</td></tr>';
                 } elseif ($type === 'change') {
                     $statusMessage .= '<tr><td><input type="checkbox" name="dbUpdateStatements[]" value="' . $key . '" checked="checked" /></td><td style="text-align:left;padding-left:15px">' . $statement . '</td></tr>';
                     $statusMessage .= '<tr><td></td><td style="text-align:left;padding-left:15px">Current value: ' . $this->updateStatements['change_currentValue'][$key] . '</td></tr>';
                 } elseif ($type === 'create_table') {
                     $statusMessage .= '<tr><td><input type="checkbox" name="dbUpdateStatements[]" value="' . $key . '" checked="checked" /></td><td style="text-align:left;padding-left:15px;">' . nl2br($statement) . '</td></tr>';
                 }
             }
         }
         $statusMessage .= '</table></div>';
     }
     if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($this->extension->getExtensionKey())) {
         $statusMessage .= '<p>Your Extension is not installed yet.</p>';
     }
     return $statusMessage;
 }
Пример #2
0
 protected function tearDown()
 {
     if (!empty($this->extension) && $this->extension->getExtensionKey() != null) {
         GeneralUtility::rmdir($this->extension->getExtensionDir(), true);
     }
     parent::tearDown();
 }
Пример #3
0
 /**
  *
  * create a new class object based on the template and the related domain object
  *
  * @param \EBT\ExtensionBuilder\Domain\Model\DomainObject $domainObject
  *
  * @return void
  */
 protected function createNewModelClassObject($domainObject)
 {
     $this->classFileObject = clone $this->templateFileObject;
     $this->classObject = clone $this->templateFileObject->getFirstClass();
     $this->classObject->resetAll();
     // start with plain class
     $this->classObject->setName($domainObject->getName());
     if ($domainObject->isEntity()) {
         $parentClass = $domainObject->getParentClass();
         if (empty($parentClass)) {
             $parentClass = $this->configurationManager->getParentClassForEntityObject($this->extension->getExtensionKey());
         }
     } else {
         $parentClass = $this->configurationManager->getParentClassForValueObject($this->extension->getExtensionKey());
     }
     $this->classObject->setParentClassName($parentClass);
     $this->classObject->setDescription($domainObject->getDescription());
 }
Пример #4
0
 /**
  * @param \EBT\ExtensionBuilder\Domain\Model\Extension $extension
  * @param string $codeTemplateRootPath
  * @return void
  */
 public function createInitialSettingsFile($extension, $codeTemplateRootPath)
 {
     GeneralUtility::mkdir_deep($extension->getExtensionDir(), self::SETTINGS_DIR);
     $settings = file_get_contents($codeTemplateRootPath . 'Configuration/ExtensionBuilder/settings.yamlt');
     $settings = str_replace('{extension.extensionKey}', $extension->getExtensionKey(), $settings);
     $settings = str_replace('{f:format.date(format:\'Y-m-d\\TH:i:s\\Z\',date:\'now\')}', date('Y-m-d\\TH:i:s\\Z'), $settings);
     GeneralUtility::writeFile($extension->getExtensionDir() . self::SETTINGS_DIR . 'settings.yaml', $settings);
 }
Пример #5
0
 /**
  * @return string
  */
 public function getRecordType()
 {
     $recordType = 'Tx_' . GeneralUtility::underscoredToUpperCamelCase($this->extension->getExtensionKey()) . '_' . $this->getName();
     return $recordType;
 }
Пример #6
0
 public function tearDown()
 {
     if (!empty($this->extension) && $this->extension->getExtensionKey() != NULL) {
         GeneralUtility::rmdir($this->extension->getExtensionDir(), TRUE);
     }
 }
 /**
  * @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());
     }
 }
Пример #8
0
 /**
  * Validate the given extension
  *
  * @param \EBT\ExtensionBuilder\Domain\Model\Extension $extension
  * @return array[]
  */
 public function isValid($extension)
 {
     $extensionSettings = $extension->getSettings();
     GeneralUtility::devLog('isValid: settings', 'extension_builder', 0, $extension->getSettings());
     if (isset($extensionSettings['ignoreWarnings'])) {
         $this->warningsToIgnore = $extensionSettings['ignoreWarnings'];
     }
     $this->validationResult = array('errors' => array(), 'warnings' => array());
     $this->validateExtensionKey($extension->getExtensionKey());
     $this->checkExistingExtensions($extension);
     $this->validatePlugins($extension);
     $this->validateBackendModules($extension);
     $this->validateDomainObjects($extension);
     if (!empty($this->warningsToIgnore)) {
         $warningsToKeep = array();
         foreach ($this->validationResult['warnings'] as $warning) {
             /* @var ExtensionException $warning */
             GeneralUtility::devLog('warning: ' . $warning->getCode(), 'extension_builder', 0, $this->warningsToIgnore);
             if (!in_array($warning->getCode(), $this->warningsToIgnore)) {
                 $warningsToKeep[] = $warning;
             }
         }
         $this->validationResult['warnings'] = $warningsToKeep;
     }
     return $this->validationResult;
 }
Пример #9
0
 /**
  *
  * @param \EBT\ExtensionBuilder\Domain\Model\Extension $extension
  * @param string $backupDir
  *
  * @return void
  */
 static function backupExtension(Model\Extension $extension, $backupDir)
 {
     if (empty($backupDir)) {
         throw new \Exception('Please define a backup directory in extension configuration!');
     } elseif (!GeneralUtility::validPathStr($backupDir)) {
         throw new \Exception('Backup directory is not a valid path: ' . $backupDir);
     } elseif (GeneralUtility::isAbsPath($backupDir)) {
         if (!GeneralUtility::isAllowedAbsPath($backupDir)) {
             throw new \Exception('Backup directory is not an allowed absolute path: ' . $backupDir);
         }
     } else {
         $backupDir = PATH_site . $backupDir;
     }
     if (strrpos($backupDir, '/') < strlen($backupDir) - 1) {
         $backupDir .= '/';
     }
     if (!is_dir($backupDir)) {
         throw new \Exception('Backup directory does not exist: ' . $backupDir);
     } elseif (!is_writable($backupDir)) {
         throw new \Exception('Backup directory is not writable: ' . $backupDir);
     }
     $backupDir .= $extension->getExtensionKey();
     // create a subdirectory for this extension
     if (!is_dir($backupDir)) {
         GeneralUtility::mkdir($backupDir);
     }
     if (strrpos($backupDir, '/') < strlen($backupDir) - 1) {
         $backupDir .= '/';
     }
     $backupDir .= date('Y-m-d-') . time();
     if (!is_dir($backupDir)) {
         GeneralUtility::mkdir($backupDir);
     }
     $extensionDir = substr($extension->getExtensionDir(), 0, strlen($extension->getExtensionDir()) - 1);
     try {
         self::recurse_copy($extensionDir, $backupDir);
     } catch (\Exception $e) {
         throw new \Exception('Code generation aborted:' . $e->getMessage());
     }
     self::log('Backup created in ' . $backupDir);
 }
Пример #10
0
 protected function tearDown()
 {
     if (isset($this->extension) && $this->extension->getExtensionKey() != NULL) {
         GeneralUtility::rmdir($this->extension->getExtensionDir(), TRUE);
     }
 }