/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $pluginInformation = []; $controllerPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Controller/'; $controllers = FileUtility::getBaseFilesRecursivelyInDir($controllerPath, 'php'); foreach ($controllers as $controller) { $controllerName = ClassNamingUtility::getFqnByPath($loader->getVendorName(), $loader->getExtensionKey(), 'Controller/' . $controller); if (!$loader->isInstantiableClass($controllerName)) { continue; } $controllerKey = str_replace('/', '\\', $controller); $controllerKey = str_replace('Controller', '', $controllerKey); $methods = ReflectionUtility::getPublicMethods($controllerName); foreach ($methods as $method) { /** @var $method \TYPO3\CMS\Extbase\Reflection\MethodReflection */ if ($method->isTaggedWith('plugin')) { $pluginKeys = GeneralUtility::trimExplode(' ', implode(' ', $method->getTagValues('plugin')), true); $actionName = str_replace('Action', '', $method->getName()); foreach ($pluginKeys as $pluginKey) { $pluginInformation = $this->addPluginInformation($pluginInformation, $pluginKey, $controllerKey, $actionName, $method->isTaggedWith('noCache')); } } } } return $pluginInformation; }
/** * Add the label to a XML file * * @param string $extensionKey * @param string $key * @param string $default * * @return NULL */ public function addLabel($extensionKey, $key, $default) { // Excelude if (!strlen($default)) { return; } if (!strlen($key)) { return; } if (!strlen($extensionKey)) { return; } if (GeneralUtility::isFirstPartOfStr($key, 'LLL:')) { return; } $absolutePath = $this->getAbsoluteFilename($extensionKey); $content = GeneralUtility::getUrl($absolutePath); if (strpos($content, ' index="' . $key . '"') !== false || trim($content) === '') { return; } $replace = '<languageKey index="default" type="array">' . LF . TAB . TAB . TAB . '<label index="' . $key . '">' . $this->wrapCdata($default) . '</label>'; $content = str_replace('<languageKey index="default" type="array">', $replace, $content); FileUtility::writeFileAndCreateFolder($absolutePath, $content); $this->clearCache(); }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $grids = []; if (!ExtensionManagementUtility::isLoaded('gridelements')) { return $grids; } $commandPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Resources/Private/Grids/'; $files = FileUtility::getBaseFilesWithExtensionInDir($commandPath, 'ts,txt'); foreach ($files as $file) { $pathInfo = PathUtility::pathinfo($file); $iconPath = 'EXT:' . $loader->getExtensionKey() . '/Resources/Public/Icons/Grids/' . $pathInfo['filename'] . '.'; $extension = IconUtility::getIconFileExtension(GeneralUtility::getFileAbsFileName($iconPath)); $translationKey = 'grid.' . $pathInfo['filename']; if ($type === LoaderInterface::EXT_TABLES) { TranslateUtility::assureLabel($translationKey, $loader->getExtensionKey(), $pathInfo['filename']); } $path = 'EXT:' . $loader->getExtensionKey() . '/Resources/Private/Grids/' . $file; $icon = $extension ? $iconPath . $extension : false; $label = TranslateUtility::getLllString($translationKey, $loader->getExtensionKey()); $content = GeneralUtility::getUrl(GeneralUtility::getFileAbsFileName($path)); $flexForm = 'EXT:' . $loader->getExtensionKey() . '/Configuration/FlexForms/Grids/' . $pathInfo['filename'] . '.xml'; $flexFormFile = GeneralUtility::getFileAbsFileName($flexForm); $flexFormContent = is_file($flexFormFile) ? GeneralUtility::getUrl($flexFormFile) : false; $grids[] = $this->getPageTsConfig($pathInfo['filename'], $label, $content, $icon, $flexFormContent); } return $grids; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $autoLoader * @param int $type * * @return array */ public function prepareLoader(Loader $autoLoader, $type) { $slots = []; $slotPath = ExtensionManagementUtility::extPath($autoLoader->getExtensionKey()) . 'Classes/Slots/'; $slotClasses = FileUtility::getBaseFilesInDir($slotPath, 'php'); foreach ($slotClasses as $slot) { $slotClass = ClassNamingUtility::getFqnByPath($autoLoader->getVendorName(), $autoLoader->getExtensionKey(), 'Slots/' . $slot); if (!$autoLoader->isInstantiableClass($slotClass)) { continue; } $methods = ReflectionUtility::getPublicMethods($slotClass); foreach ($methods as $methodReflection) { /** @var MethodReflection $methodReflection */ $tagConfiguration = ReflectionUtility::getTagConfiguration($methodReflection, ['signalClass', 'signalName', 'signalPriority']); foreach ($tagConfiguration['signalClass'] as $key => $signalClass) { if (!isset($tagConfiguration['signalName'][$key])) { continue; } $priority = isset($tagConfiguration['signalPriority'][$key]) ? $tagConfiguration['signalPriority'][$key] : 0; $priority = MathUtility::forceIntegerInRange($priority, 0, 100); $slots[$priority][] = ['signalClassName' => trim($signalClass, '\\'), 'signalName' => $tagConfiguration['signalName'][$key], 'slotClassNameOrObject' => $slotClass, 'slotMethodName' => $methodReflection->getName()]; } } } $slots = $this->flattenSlotsByPriority($slots); return $slots; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $autoLoader * @param int $type * * @return array */ public function prepareLoader(Loader $autoLoader, $type) { $slots = []; $slotPath = ExtensionManagementUtility::extPath($autoLoader->getExtensionKey()) . 'Classes/Slots/'; $slotClasses = FileUtility::getBaseFilesInDir($slotPath, 'php'); $extKey = GeneralUtility::underscoredToUpperCamelCase($autoLoader->getExtensionKey()); foreach ($slotClasses as $slot) { $slotClass = $autoLoader->getVendorName() . '\\' . $extKey . '\\Slots\\' . $slot; if (!$autoLoader->isInstantiableClass($slotClass)) { continue; } $methods = ReflectionUtility::getPublicMethods($slotClass); foreach ($methods as $methodReflection) { /** @var MethodReflection $methodReflection */ $tagConfiguration = ReflectionUtility::getTagConfiguration($methodReflection, ['signalClass', 'signalName']); foreach ($tagConfiguration['signalClass'] as $key => $signalClass) { if (!isset($tagConfiguration['signalName'][$key])) { continue; } $slots[] = ['signalClassName' => trim($signalClass, '\\'), 'signalName' => $tagConfiguration['signalName'][$key], 'slotClassNameOrObject' => $slotClass, 'slotMethodName' => $methodReflection->getName()]; } } } return $slots; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $hooks = []; $folder = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Hooks/'; $files = FileUtility::getBaseFilesInDir($folder, 'php'); foreach ($files as $hookFile) { $hookClass = ClassNamingUtility::getFqnByPath($loader->getVendorName(), $loader->getExtensionKey(), 'Hooks/' . $hookFile); if (!$loader->isInstantiableClass($hookClass)) { continue; } $classReflection = ReflectionUtility::createReflectionClass($hookClass); // add class hook $tagConfiguration = ReflectionUtility::getTagConfiguration($classReflection, ['hook']); if (sizeof($tagConfiguration['hook'])) { $hooks[] = ['locations' => $tagConfiguration['hook'], 'configuration' => $hookClass]; } // add method hooks foreach ($classReflection->getMethods(MethodReflection::IS_PUBLIC) as $methodReflection) { /** @var $methodReflection \TYPO3\CMS\Extbase\Reflection\MethodReflection */ $tagConfiguration = ReflectionUtility::getTagConfiguration($methodReflection, ['hook']); if (sizeof($tagConfiguration['hook'])) { $hooks[] = ['locations' => $tagConfiguration['hook'], 'configuration' => $hookClass . '->' . $methodReflection->getName()]; } } } return $hooks; }
/** * Create default file * * @param string $extensionKey * * @return bool */ public function createFileIfNotExists($extensionKey) { $fileName = $this->getAbsoluteFilename($extensionKey); if (is_file($fileName)) { return true; } return FileUtility::writeFileAndCreateFolder($fileName, $this->getBaseFileContent($extensionKey)); }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $scripts = []; $folder = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Resources/Private/Php/eID/'; $files = FileUtility::getBaseFilesInDir($folder, 'php'); foreach ($files as $eIdFile) { $scripts[] = ['name' => $eIdFile, 'path' => 'EXT:' . $loader->getExtensionKey() . '/Resources/Private/Php/eID/' . $eIdFile . '.php']; } return $scripts; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $autoLoader * @param int $type * * @return array */ public function prepareLoader(Loader $autoLoader, $type) { $servicePath = ExtensionManagementUtility::extPath($autoLoader->getExtensionKey()) . 'Classes/Service/Soap/'; $serviceClasses = FileUtility::getBaseFilesRecursivelyInDir($servicePath, 'php'); $info = []; foreach ($serviceClasses as $service) { $serviceClass = ClassNamingUtility::getFqnByPath($autoLoader->getVendorName(), $autoLoader->getExtensionKey(), 'Service/Soap/' . $service); $info[lcfirst($service)] = $serviceClass; } return $info; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $autoLoader * @param int $type * * @return array */ public function prepareLoader(Loader $autoLoader, $type) { $servicePath = ExtensionManagementUtility::extPath($autoLoader->getExtensionKey()) . 'Classes/Service/Soap/'; $serviceClasses = FileUtility::getBaseFilesRecursivelyInDir($servicePath, 'php'); $extKey = GeneralUtility::underscoredToUpperCamelCase($autoLoader->getExtensionKey()); $info = []; foreach ($serviceClasses as $service) { $serviceClass = $autoLoader->getVendorName() . '\\' . $extKey . '\\Service\\Soap\\' . $service; $info[lcfirst($service)] = $serviceClass; } return $info; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $autoLoader * @param int $type * * @return array */ public function prepareLoader(Loader $autoLoader, $type) { $classes = []; $converterPath = ExtensionManagementUtility::extPath($autoLoader->getExtensionKey()) . 'Classes/Property/TypeConverter/'; $converterClasses = FileUtility::getBaseFilesRecursivelyInDir($converterPath, 'php', true); foreach ($converterClasses as $converterClass) { $converterClass = ClassNamingUtility::getFqnByPath($autoLoader->getVendorName(), $autoLoader->getExtensionKey(), 'Property/TypeConverter/' . $converterClass); if ($autoLoader->isInstantiableClass($converterClass)) { $classes[] = $converterClass; } } return $classes; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $autoLoader * @param int $type * * @return array */ public function prepareLoader(Loader $autoLoader, $type) { $classes = []; $converterPath = ExtensionManagementUtility::extPath($autoLoader->getExtensionKey()) . 'Classes/Property/TypeConverter/'; $converterClasses = FileUtility::getBaseFilesRecursivelyInDir($converterPath, 'php', true); $extKey = GeneralUtility::underscoredToUpperCamelCase($autoLoader->getExtensionKey()); foreach ($converterClasses as $converterClass) { $converterClass = $autoLoader->getVendorName() . '\\' . $extKey . '\\Property\\TypeConverter\\' . str_replace('/', '\\', $converterClass); if ($autoLoader->isInstantiableClass($converterClass)) { $classes[] = $converterClass; } } return $classes; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $classNames = []; $alternativeImpPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/AlternativeImplementations/'; $alternativeClasses = FileUtility::getBaseFilesInDir($alternativeImpPath, 'php'); foreach ($alternativeClasses as $aic) { $aicClass = ClassNamingUtility::getFqnByPath($loader->getVendorName(), $loader->getExtensionKey(), 'AlternativeImplementations/' . $aic); if (!$loader->isInstantiableClass($aicClass)) { continue; } $classNames[] = ['originalName' => ReflectionUtility::getParentClassName($aicClass), 'alternativeClassName' => $aicClass]; } return $classNames; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $classNames = []; $alternativeImpPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/AlternativeImplementations/'; $alternativeClasses = FileUtility::getBaseFilesInDir($alternativeImpPath, 'php'); $extKey = GeneralUtility::underscoredToUpperCamelCase($loader->getExtensionKey()); foreach ($alternativeClasses as $aic) { $aicClass = $loader->getVendorName() . '\\' . $extKey . '\\AlternativeImplementations\\' . $aic; if (!$loader->isInstantiableClass($aicClass)) { continue; } $classNames[] = ['originalName' => ReflectionUtility::getParentClassName($aicClass), 'alternativeClassName' => $aicClass]; } return $classNames; }
/** * Get all the complex data and information for the loader. * This return value will be cached and stored in the core_cache of TYPO3. * There is no file monitoring for this cache. * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $backendLayouts = array(); $commandPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Resources/Private/BackendLayouts/'; $backendLayoutFiles = FileUtility::getBaseFilesWithExtensionInDir($commandPath, 'ts,txt'); foreach ($backendLayoutFiles as $file) { $pathInfo = PathUtility::pathinfo($file); $iconPath = 'EXT:' . $loader->getExtensionKey() . '/Resources/Public/Icons/BackendLayouts/' . $pathInfo['filename'] . '.'; $extension = IconUtility::getIconFileExtension(GeneralUtility::getFileAbsFileName($iconPath)); $translationKey = 'backendLayout.' . $pathInfo['basename']; if ($type === LoaderInterface::EXT_TABLES) { TranslateUtility::assureLabel($translationKey, $loader->getExtensionKey(), $pathInfo['filename']); } $backendLayouts[] = array('path' => 'EXT:' . $loader->getExtensionKey() . '/Resources/Private/BackendLayouts/' . $file, 'filename' => $pathInfo['filename'], 'icon' => $extension ? $iconPath . $extension : FALSE, 'label' => TranslateUtility::getLllString($translationKey, $loader->getExtensionKey()), 'extension' => $loader->getExtensionKey()); } return $backendLayouts; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $autoLoader * @param int $type * * @return array */ public function prepareLoader(Loader $autoLoader, $type) { $servicePath = ExtensionManagementUtility::extPath($autoLoader->getExtensionKey()) . 'Classes/Service/Json/'; $serviceClasses = FileUtility::getBaseFilesRecursivelyInDir($servicePath, 'php'); $info = []; foreach ($serviceClasses as $service) { $serviceClass = ClassNamingUtility::getFqnByPath($autoLoader->getVendorName(), $autoLoader->getExtensionKey(), 'Service/Json/' . $service); $legacyServiceName = lcfirst($service); if (array_key_exists($legacyServiceName, $info)) { trigger_error('Service "' . $service . '" already defined in: ' . $info[$legacyServiceName] . '!"', E_USER_NOTICE); } $info[$legacyServiceName] = $serviceClass; $serviceName = $autoLoader->getExtensionKey() . '/' . $service; $info[$serviceName] = $serviceClass; } return $info; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $classNames = []; $commandPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Command/'; $controllers = FileUtility::getBaseFilesInDir($commandPath, 'php'); foreach ($controllers as $controller) { if ($controller === 'AbstractCommandController') { continue; } $className = $loader->getVendorName() . '\\' . ucfirst(GeneralUtility::underscoredToUpperCamelCase($loader->getExtensionKey())) . '\\Command\\' . $controller; if (!$loader->isInstantiableClass($className)) { continue; } $classNames[] = $className; } return $classNames; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $return = []; if ($type === LoaderInterface::EXT_TABLES) { return $return; } $xClassesPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Xclass/'; $xClasses = FileUtility::getBaseFilesRecursivelyInDir($xClassesPath, 'php'); foreach ($xClasses as $xClass) { $className = ClassNamingUtility::getFqnByPath($loader->getVendorName(), $loader->getExtensionKey(), 'Xclass/' . $xClass); if (!$loader->isInstantiableClass($className)) { continue; } $return[] = ['source' => ReflectionUtility::getParentClassName($className), 'target' => $className]; } return $return; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $classNames = []; $commandPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Command/'; $controllers = FileUtility::getBaseFilesInDir($commandPath, 'php'); foreach ($controllers as $controller) { if ($controller === 'AbstractCommandController') { continue; } $className = ClassNamingUtility::getFqnByPath($loader->getVendorName(), $loader->getExtensionKey(), 'Command/' . $controller); if (!$loader->isInstantiableClass($className)) { continue; } $classNames[] = $className; } return $classNames; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $configuration = []; $modelPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Domain/Model/'; if (!is_dir($modelPath)) { return $configuration; } $models = FileUtility::getBaseFilesRecursivelyInDir($modelPath, 'php'); foreach ($models as $model) { $className = ClassNamingUtility::getFqnByPath($loader->getVendorName(), $loader->getExtensionKey(), 'Domain/Model/' . $model); if (SmartObjectManager::isSmartObjectClass($className)) { $configuration[] = $className; } } // already add for the following processes $this->addClassesToSmartRegister($configuration); return $configuration; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $configuration = []; $modelPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Domain/Model/'; if (!is_dir($modelPath)) { return $configuration; } $models = FileUtility::getBaseFilesInDir($modelPath, 'php'); foreach ($models as $model) { $className = $loader->getVendorName() . '\\' . ucfirst(GeneralUtility::underscoredToUpperCamelCase($loader->getExtensionKey())) . '\\Domain\\Model\\' . $model; if (SmartObjectManager::isSmartObjectClass($className)) { $configuration[] = $className; } } // already add for the following processes $this->addClassesToSmartRegister($configuration); return $configuration; }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $return = []; if ($type === LoaderInterface::EXT_TABLES) { return $return; } $xClassesPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Xclass/'; $xClasses = FileUtility::getBaseFilesRecursivelyInDir($xClassesPath, 'php'); $extKey = GeneralUtility::underscoredToUpperCamelCase($loader->getExtensionKey()); foreach ($xClasses as $xClass) { $xclassName = $loader->getVendorName() . '\\' . $extKey . '\\Xclass\\' . str_replace('/', '\\', $xClass); if (!$loader->isInstantiableClass($xclassName)) { continue; } $return[] = ['source' => ReflectionUtility::getParentClassName($xclassName), 'target' => $xclassName]; } return $return; }
/** * Add the label * * @param string $extensionKey * @param string $key * @param string $default * * @return bool */ public function addLabel($extensionKey, $key, $default) { // Exclude if (!strlen($default)) { return; } if (!strlen($key)) { return; } if (!strlen($extensionKey)) { return; } $absolutePath = $this->getAbsoluteFilename($extensionKey); include $absolutePath; $LOCAL_LANG['default'][$key] = $default; FileUtility::writeFileAndCreateFolder($absolutePath, $this->getPhpContentByLabels($LOCAL_LANG)); $this->clearCache(); }
/** * Add the Label to the local lang XLIFF * * @param string $extensionKey * @param string $key * @param string $default * * @return NULL */ public function addLabel($extensionKey, $key, $default) { // Exclude if (!strlen($default)) { return; } if (!strlen($key)) { return; } if (!strlen($extensionKey)) { return; } $absolutePath = $this->getAbsoluteFilename($extensionKey); $content = GeneralUtility::getUrl($absolutePath); $replace = '<body>' . LF . TAB . TAB . TAB . '<trans-unit id="' . $key . '"><source><![CDATA[' . $default . ']]></source></trans-unit>'; $content = str_replace('<body>', $replace, $content); FileUtility::writeFileAndCreateFolder($absolutePath, $content); $this->clearCache(); }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $flexForms = []; $flexFormPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Configuration/FlexForms/'; // Plugins $extensionName = GeneralUtility::underscoredToUpperCamelCase($loader->getExtensionKey()); $flexFormsFiles = FileUtility::getBaseFilesInDir($flexFormPath, 'xml'); foreach ($flexFormsFiles as $fileKey) { $pluginSignature = strtolower($extensionName . '_' . $fileKey); $flexForms[] = ['pluginSignature' => $pluginSignature, 'path' => 'FILE:EXT:' . $loader->getExtensionKey() . '/Configuration/FlexForms/' . $fileKey . '.xml']; } // Content $flexFormsFiles = FileUtility::getBaseFilesInDir($flexFormPath . 'Content/', 'xml'); foreach ($flexFormsFiles as $fileKey) { $contentSignature = strtolower($loader->getExtensionKey() . '_' . GeneralUtility::camelCaseToLowerCaseUnderscored($fileKey)); $flexForms[] = ['contentSignature' => $contentSignature, 'path' => 'FILE:EXT:' . $loader->getExtensionKey() . '/Configuration/FlexForms/Content/' . $fileKey . '.xml']; } return $flexForms; }
/** * Add the Label to the local lang XLIFF * * @param string $extensionKey * @param string $key * @param string $default * * @return NULL */ public function addLabel($extensionKey, $key, $default) { // Exclude if (!strlen($default)) { return; } if (!strlen($key)) { return; } if (!strlen($extensionKey)) { return; } $absolutePath = $this->getAbsoluteFilename($extensionKey); $content = GeneralUtility::getUrl($absolutePath); if (strpos($content, ' id="' . $key . '"') !== false || trim($content) === '') { return; } $replace = '<body>' . LF . TAB . TAB . TAB . '<trans-unit id="' . $key . '"><source>' . $this->wrapCdata($default) . '</source></trans-unit>'; $content = str_replace('<body>', $replace, $content); FileUtility::writeFileAndCreateFolder($absolutePath, $content); $this->clearCache(); }
/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array $loaderInformation */ public function prepareLoader(Loader $loader, $type) { $aspects = []; $aspectPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Aspect/'; $aspectClasses = FileUtility::getBaseFilesInDir($aspectPath, 'php'); $extKey = GeneralUtility::underscoredToUpperCamelCase($loader->getExtensionKey()); foreach ($aspectClasses as $aspect) { $aspectClass = ClassNamingUtility::getFqnByPath($loader->getVendorName(), $loader->getExtensionKey(), 'Aspect/' . $aspect); if (!$loader->isInstantiableClass($aspectClass)) { continue; } try { $methods = ReflectionUtility::getPublicMethods($aspectClass); foreach ($methods as $methodReflection) { /** @var $methodReflection \TYPO3\CMS\Extbase\Reflection\MethodReflection */ $tagConfiguration = ReflectionUtility::getTagConfiguration($methodReflection, ['aspectClass', 'aspectJoinPoint', 'aspectAdvice']); foreach ($tagConfiguration['aspectClass'] as $key => $aspectClass) { if (!isset($tagConfiguration['aspectJoinPoint'][$key]) || !isset($tagConfiguration['aspectAdvice'][$key])) { continue; } $aspectClassName = trim($aspectClass, '\\'); $aspectJoinPoint = trim($tagConfiguration['aspectJoinPoint'][$key]); // check only if class exists if (!$loader->isInstantiableClass($aspectClassName)) { continue; } $aspectJpArguments = $this->getMethodArgumentsFromClassMethod($aspectClassName, $aspectJoinPoint); $aspects[] = ['aspectClassName' => $aspectClassName, 'aspectJoinPoint' => $aspectJoinPoint, 'aspectJoinPointArguments' => $aspectJpArguments, 'aspectAdvice' => trim($tagConfiguration['aspectAdvice'][$key]), 'originClassName' => $aspectClass, 'originMethodName' => $methodReflection->getName()]; } } } catch (\Exception $e) { // Class or file is not available for Aspects $aspectClassName continue; } } return $aspects; }
/** * Check and create the TCA information * disable this for better performance */ public static function checkAndCreateTcaInformation() { $register = SmartObjectRegister::getRegister(); $baseTemplatePath = ExtensionManagementUtility::extPath('autoloader', 'Resources/Private/Templates/TcaFiles/'); $defaultTemplate = GeneralUtility::getUrl($baseTemplatePath . 'Default.tmpl'); $overrideTemplate = GeneralUtility::getUrl($baseTemplatePath . 'Override.tmpl'); $search = ['__modelName__', '__tableName__', '__extensionKey__']; foreach ($register as $model) { $extensionKey = ClassNamingUtility::getExtensionKeyByModel($model); $basePath = ExtensionManagementUtility::extPath($extensionKey) . 'Configuration/TCA/'; $tableName = ModelUtility::getTableNameByModelReflectionAnnotation($model); if ($tableName !== '') { $tcaFileName = $basePath . 'Overrides/' . $tableName . '.php'; $template = $overrideTemplate; } else { $tableName = ModelUtility::getTableNameByModelName($model); $tcaFileName = $basePath . $tableName . '.php'; $template = $defaultTemplate; } if (!is_file($tcaFileName)) { $replace = [str_replace('\\', '\\\\', $model), $tableName, $extensionKey]; $content = str_replace($search, $replace, $template); FileUtility::writeFileAndCreateFolder($tcaFileName, $content); } } }
/** * Check if the given file is already existing * * @param $path * @param $modelClass * * @return void */ protected function checkCshFile($path, $modelClass) { if (is_file($path)) { return; } $dir = PathUtility::dirname($path); if (!is_dir($dir)) { GeneralUtility::mkdir_deep($dir); } $information = SmartObjectInformationService::getInstance()->getCustomModelFieldTca($modelClass); $properties = array_keys($information); $templatePath = 'Resources/Private/Templates/ContextSensitiveHelp/LanguageDescription.xml'; $standaloneView = GeneralUtility::makeInstance('TYPO3\\CMS\\Fluid\\View\\StandaloneView'); $standaloneView->setTemplatePathAndFilename(ExtensionManagementUtility::extPath('autoloader', $templatePath)); $standaloneView->assign('properties', $properties); $content = $standaloneView->render(); FileUtility::writeFileAndCreateFolder($path, $content); }
/** * Write the given content object template to the target path * * @param string $name * @param string $absoluteTargetPath */ protected function writeContentTemplateToTarget($name, $absoluteTargetPath) { $template = GeneralUtility::getUrl(ExtensionManagementUtility::extPath('autoloader', 'Resources/Private/Templates/ContentObjects/' . $name . '.html')); FileUtility::writeFileAndCreateFolder($absoluteTargetPath, $template); }