├── .gitignore ├── .php_cs.dist ├── LICENSE ├── README.md ├── composer.json ├── res └── php │ └── autoload-include.tmpl.php └── src ├── Config.php ├── IncludeFile.php ├── IncludeFile ├── ActiveTypo3ExtensionsToken.php └── TokenInterface.php ├── Plugin.php └── PluginImplementation.php /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | /composer.lock 3 | /res/php/autoload-include.php 4 | /.php_cs.cache 5 | -------------------------------------------------------------------------------- /.php_cs.dist: -------------------------------------------------------------------------------- 1 | setRiskyAllowed(true) 4 | ->setRules([ 5 | '@PSR2' => true, 6 | 'array_syntax' => [ 7 | 'syntax' => 'short', 8 | ], 9 | 'binary_operator_spaces' => true, 10 | 'concat_space' => [ 11 | 'spacing' => 'one', 12 | ], 13 | 'function_typehint_space' => true, 14 | 'hash_to_slash_comment' => true, 15 | 'linebreak_after_opening_tag' => true, 16 | 'lowercase_cast' => true, 17 | 'method_separation' => true, 18 | 'native_function_casing' => true, 19 | 'new_with_braces' => true, 20 | 'no_alias_functions' => true, 21 | 'no_blank_lines_after_class_opening' => true, 22 | 'no_blank_lines_after_phpdoc' => true, 23 | 'no_blank_lines_before_namespace' => true, 24 | 'no_empty_comment' => true, 25 | 'no_empty_phpdoc' => true, 26 | 'no_empty_statement' => true, 27 | 'no_extra_consecutive_blank_lines' => [ 28 | 'continue', 29 | 'curly_brace_block', 30 | 'extra', 31 | 'parenthesis_brace_block', 32 | 'square_brace_block', 33 | 'throw', 34 | ], 35 | 'no_leading_import_slash' => true, 36 | 'no_leading_namespace_whitespace' => true, 37 | 'no_multiline_whitespace_around_double_arrow' => true, 38 | 'no_multiline_whitespace_before_semicolons' => true, 39 | 'no_short_bool_cast' => true, 40 | 'no_singleline_whitespace_before_semicolons' => true, 41 | 'no_trailing_comma_in_list_call' => true, 42 | 'no_trailing_comma_in_singleline_array' => true, 43 | 'no_unneeded_control_parentheses' => [ 44 | 'break', 45 | 'clone', 46 | 'continue', 47 | 'echo_print', 48 | 'return', 49 | 'switch_case', 50 | ], 51 | 'no_unreachable_default_argument_value' => true, 52 | 'no_unused_imports' => true, 53 | 'no_useless_else' => true, 54 | 'no_useless_return' => true, 55 | 'no_whitespace_before_comma_in_array' => true, 56 | 'no_whitespace_in_blank_line' => true, 57 | 'normalize_index_brace' => true, 58 | 'ordered_imports' => true, 59 | 'phpdoc_add_missing_param_annotation' => true, 60 | 'phpdoc_no_package' => true, 61 | 'phpdoc_order' => true, 62 | 'phpdoc_scalar' => true, 63 | 'phpdoc_types' => true, 64 | 'self_accessor' => true, 65 | 'short_scalar_cast' => true, 66 | 'single_quote' => true, 67 | 'standardize_not_equals' => true, 68 | 'ternary_operator_spaces' => true, 69 | 'trailing_comma_in_multiline_array' => true, 70 | 'whitespace_after_comma_in_array' => true, 71 | ]) 72 | ->setFinder( 73 | PhpCsFixer\Finder::create() 74 | ->in(__DIR__) 75 | ->exclude('vendor') 76 | ); 77 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Helmut Hummel 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TYPO3 Console Plugin 2 | 3 | Installer plugin for [helhum/typo3-console](https://github.com/helhum/typo3_console), 4 | to ease usage of this package without the need to specify scripts in your root composer.json 5 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "helhum/typo3-console-plugin", 3 | "type": "composer-plugin", 4 | "license": "MIT", 5 | "description": "Installer plugin for helhum/typo3-console, to ease usage without the need to specify scripts in your root composer.json", 6 | "keywords": [ 7 | "typo3 console", "composer", "plugin" 8 | ], 9 | "homepage": "https://github.com/helhum/typo3-console-plugin", 10 | "authors": [ 11 | { 12 | "name": "Helmut Hummel", 13 | "email": "info@helhum.io" 14 | } 15 | ], 16 | "autoload": { 17 | "psr-4": { 18 | "Helhum\\Typo3ConsolePlugin\\": "src/" 19 | } 20 | }, 21 | "require": { 22 | "php": "^7.0", 23 | "typo3/cms-composer-installers": "^1.4 || ^2.0 || ^3.0@dev", 24 | "composer-plugin-api": "^1.0 || ^2.0" 25 | }, 26 | "require-dev": { 27 | "composer/composer": "^1.10@dev || ^2.0@dev" 28 | }, 29 | "extra": { 30 | "class": "Helhum\\Typo3ConsolePlugin\\Plugin", 31 | "branch-alias": { 32 | "dev-master": "2.x-dev" 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /res/php/autoload-include.tmpl.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * For the full copyright and license information, please view the LICENSE 11 | * file that was distributed with this source code. 12 | */ 13 | 14 | class Config 15 | { 16 | const RELATIVE_PATHS = 1; 17 | 18 | /** 19 | * @var array 20 | */ 21 | public static $defaultConfig = [ 22 | 'install-binary' => true, 23 | 'install-extension-dummy' => true, 24 | 'active-typo3-extensions' => [], 25 | ]; 26 | 27 | /** 28 | * @var array 29 | */ 30 | protected $config; 31 | 32 | /** 33 | * @var string 34 | */ 35 | protected $baseDir; 36 | 37 | /** 38 | * @param string $baseDir 39 | */ 40 | public function __construct($baseDir = null) 41 | { 42 | $this->baseDir = $baseDir; 43 | // load defaults 44 | $this->config = static::$defaultConfig; 45 | } 46 | 47 | /** 48 | * Merges new config values with the existing ones (overriding) 49 | * 50 | * @param array $config 51 | */ 52 | public function merge($config) 53 | { 54 | // override defaults with given config 55 | if (!empty($config['extra']['helhum/typo3-console']) && is_array($config['extra']['helhum/typo3-console'])) { 56 | foreach ($config['extra']['helhum/typo3-console'] as $key => $val) { 57 | $this->config[$key] = $val; 58 | } 59 | } 60 | } 61 | 62 | /** 63 | * Returns a setting 64 | * 65 | * @param string $key 66 | * @param int $flags Options (see class constants) 67 | * @throws \RuntimeException 68 | * @return mixed 69 | */ 70 | public function get(string $key, int $flags = 0) 71 | { 72 | switch ($key) { 73 | case 'some-dir': 74 | $val = rtrim($this->process($this->config[$key], $flags), '/\\'); 75 | return ($flags & self::RELATIVE_PATHS === 1) ? $val : $this->realpath($val); 76 | default: 77 | if (!isset($this->config[$key])) { 78 | return null; 79 | } 80 | if (!is_string($this->config[$key])) { 81 | return $this->config[$key]; 82 | } 83 | return $this->process($this->config[$key], $flags); 84 | } 85 | } 86 | 87 | /** 88 | * @param int $flags Options (see class constants) 89 | * @return array 90 | */ 91 | public function all(int $flags = 0): array 92 | { 93 | $all = []; 94 | foreach (array_keys($this->config) as $key) { 95 | $all['config'][$key] = $this->get($key, $flags); 96 | } 97 | 98 | return $all; 99 | } 100 | 101 | /** 102 | * @return array 103 | */ 104 | public function raw(): array 105 | { 106 | return [ 107 | 'config' => $this->config, 108 | ]; 109 | } 110 | 111 | /** 112 | * Checks whether a setting exists 113 | * 114 | * @param string $key 115 | * @return bool 116 | */ 117 | public function has(string $key): bool 118 | { 119 | return array_key_exists($key, $this->config); 120 | } 121 | 122 | /** 123 | * Replaces {$refs} inside a config string 124 | * 125 | * @param string $value a config string that can contain {$refs-to-other-config} 126 | * @param int $flags Options (see class constants) 127 | * @return string 128 | */ 129 | protected function process(string $value, int $flags) 130 | { 131 | return preg_replace_callback('#\{\$(.+)\}#', 132 | function ($match) use ($flags) { 133 | return $this->get($match[1], $flags); 134 | }, 135 | $value); 136 | } 137 | 138 | /** 139 | * Turns relative paths in absolute paths without realpath() 140 | * 141 | * Since the dirs might not exist yet we can not call realpath or it will fail. 142 | * 143 | * @param string $path 144 | * @return string 145 | */ 146 | protected function realpath(string $path): string 147 | { 148 | if ($path === '') { 149 | return $this->baseDir; 150 | } 151 | 152 | if ($path[0] === '/' || (!empty($path[1]) && $path[1] === ':')) { 153 | return $path; 154 | } 155 | 156 | return $this->baseDir . '/' . $path; 157 | } 158 | 159 | /** 160 | * @return string 161 | */ 162 | public function getBaseDir(): string 163 | { 164 | return $this->baseDir; 165 | } 166 | 167 | /** 168 | * @param \Composer\IO\IOInterface $io 169 | * @param \Composer\Config $composerConfig 170 | * @throws \RuntimeException 171 | * @throws \InvalidArgumentException 172 | * @return Config 173 | */ 174 | public static function load(\Composer\IO\IOInterface $io, \Composer\Config $composerConfig): Config 175 | { 176 | static $config; 177 | if ($config === null) { 178 | $baseDir = realpath(substr($composerConfig->get('vendor-dir'), 0, -strlen($composerConfig->get('vendor-dir', self::RELATIVE_PATHS)))); 179 | $localConfig = \Composer\Factory::getComposerFile(); 180 | $file = new \Composer\Json\JsonFile($localConfig, null, $io); 181 | 182 | $config = new static($baseDir); 183 | $config->merge($file->read()); 184 | } 185 | return $config; 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /src/IncludeFile.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * For the full copyright and license information, please view the LICENSE 11 | * file that was distributed with this source code. 12 | */ 13 | 14 | use Composer\Composer; 15 | use Composer\IO\IOInterface; 16 | use Composer\Util\Filesystem; 17 | use Helhum\Typo3ConsolePlugin\IncludeFile\TokenInterface; 18 | 19 | class IncludeFile 20 | { 21 | const INCLUDE_FILE = '/helhum/console-autoload-include.php'; 22 | const INCLUDE_FILE_TEMPLATE = '/res/php/autoload-include.tmpl.php'; 23 | 24 | /** 25 | * @var IOInterface 26 | */ 27 | private $io; 28 | 29 | /** 30 | * @var TokenInterface[] 31 | */ 32 | private $tokens; 33 | 34 | /** 35 | * @var Filesystem 36 | */ 37 | private $filesystem; 38 | 39 | /** 40 | * @var Composer 41 | */ 42 | private $composer; 43 | 44 | /** 45 | * IncludeFile constructor. 46 | * 47 | * @param IOInterface $io 48 | * @param Composer $composer 49 | * @param TokenInterface[] $tokens 50 | * @param Filesystem $filesystem 51 | */ 52 | public function __construct(IOInterface $io, Composer $composer, array $tokens, Filesystem $filesystem = null) 53 | { 54 | $this->io = $io; 55 | $this->composer = $composer; 56 | $this->tokens = $tokens; 57 | $this->filesystem = $this->filesystem ?: new Filesystem(); 58 | } 59 | 60 | public function register() 61 | { 62 | $this->io->writeError('Register typo3/console-plugin file in root package autoload definition', true, IOInterface::VERBOSE); 63 | 64 | // Generate and write the file 65 | $includeFile = $this->composer->getConfig()->get('vendor-dir') . self::INCLUDE_FILE; 66 | file_put_contents($includeFile, $this->getIncludeFileContent()); 67 | 68 | // Register the file in the root package 69 | $rootPackage = $this->composer->getPackage(); 70 | $autoloadDefinition = $rootPackage->getAutoload(); 71 | $autoloadDefinition['files'][] = $includeFile; 72 | $rootPackage->setAutoload($autoloadDefinition); 73 | 74 | // Load it to expose the paths to further plugin functionality 75 | require $includeFile; 76 | } 77 | 78 | /** 79 | * Constructs the include file content 80 | * 81 | * @throws \RuntimeException 82 | * @throws \InvalidArgumentException 83 | * @return string 84 | */ 85 | protected function getIncludeFileContent(): string 86 | { 87 | $includeFileTemplate = $this->filesystem->normalizePath(__DIR__ . '/../' . self::INCLUDE_FILE_TEMPLATE); 88 | $includeFileContent = file_get_contents($includeFileTemplate); 89 | foreach ($this->tokens as $token) { 90 | $includeFileContent = self::replaceToken($token->getName(), $token->getContent(), $includeFileContent); 91 | } 92 | return $includeFileContent; 93 | } 94 | 95 | /** 96 | * Replaces a token in the subject (PHP code) 97 | * 98 | * @param string $name 99 | * @param string $content 100 | * @param string $subject 101 | * @return string 102 | */ 103 | private static function replaceToken($name, $content, $subject): string 104 | { 105 | return str_replace('\'{$' . $name . '}\'', $content, $subject); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/IncludeFile/ActiveTypo3ExtensionsToken.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * For the full copyright and license information, please view the LICENSE 11 | * file that was distributed with this source code. 12 | */ 13 | 14 | use Composer\Composer; 15 | use Composer\IO\IOInterface; 16 | use Composer\Package\PackageInterface; 17 | use Helhum\Typo3ConsolePlugin\Config; 18 | 19 | class ActiveTypo3ExtensionsToken implements TokenInterface 20 | { 21 | /** 22 | * @var string 23 | */ 24 | private $name = 'active-typo3-extensions'; 25 | 26 | /** 27 | * @var Config 28 | */ 29 | private $config; 30 | 31 | /** 32 | * @var Composer 33 | */ 34 | private $composer; 35 | 36 | /** 37 | * @var IOInterface 38 | */ 39 | private $io; 40 | 41 | /** 42 | * @var bool 43 | */ 44 | private $isDevMode; 45 | 46 | /** 47 | * ActiveTypo3ExtensionsToken constructor. 48 | * 49 | * @param IOInterface $io 50 | * @param Composer $composer 51 | * @param Config $config 52 | * @param bool $isDevMode 53 | */ 54 | public function __construct(IOInterface $io, Composer $composer, Config $config, $isDevMode = false) 55 | { 56 | $this->io = $io; 57 | $this->config = $config; 58 | $this->composer = $composer; 59 | $this->isDevMode = $isDevMode; 60 | } 61 | 62 | /** 63 | * @return string 64 | */ 65 | public function getName(): string 66 | { 67 | return $this->name; 68 | } 69 | 70 | /** 71 | * @throws \RuntimeException 72 | * @return string 73 | */ 74 | public function getContent(): string 75 | { 76 | $this->io->writeError('Writing TYPO3_ACTIVE_FRAMEWORK_EXTENSIONS environment variable', true, IOInterface::VERBOSE); 77 | $configuredActiveTypo3Extensions = $this->config->get('active-typo3-extensions'); 78 | if (!is_array($configuredActiveTypo3Extensions)) { 79 | $this->io->writeError(sprintf('Extra section "active-typo3-extensions" must be array, "%s" given!', gettype($configuredActiveTypo3Extensions))); 80 | $configuredActiveTypo3Extensions = []; 81 | } 82 | if (count($configuredActiveTypo3Extensions) > 0) { 83 | $this->io->writeError('Extra section "active-typo3-extensions" has been deprecated!'); 84 | $this->io->writeError('Please just add typo3/cms framework packages to the require section in your composer.json of any package.'); 85 | } 86 | $activeTypo3Extensions = array_unique(array_merge($configuredActiveTypo3Extensions, $this->getActiveCoreExtensionKeysFromComposer())); 87 | asort($activeTypo3Extensions); 88 | $this->io->writeError('The following TYPO3 core extensions are marked as active: ' . implode(', ', $activeTypo3Extensions), true, IOInterface::VERBOSE); 89 | return var_export(implode(',', $activeTypo3Extensions), true); 90 | } 91 | 92 | /** 93 | * @return array 94 | */ 95 | private function getActiveCoreExtensionKeysFromComposer(): array 96 | { 97 | $this->io->writeError('Determine dependencies to typo3/cms framework packages.', true, IOInterface::VERY_VERBOSE); 98 | $typo3Package = $this->composer->getRepositoryManager()->getLocalRepository()->findPackage('typo3/cms', '*'); 99 | if ($typo3Package) { 100 | $coreExtensionKeys = $this->getCoreExtensionKeysFromTypo3Package($typo3Package); 101 | } else { 102 | $coreExtensionKeys = $this->getCoreExtensionKeysFromInstalledPackages(); 103 | } 104 | return $coreExtensionKeys; 105 | } 106 | 107 | /** 108 | * @param PackageInterface $typo3Package 109 | * @return array 110 | */ 111 | private function getCoreExtensionKeysFromTypo3Package(PackageInterface $typo3Package): array 112 | { 113 | $coreExtensionKeys = []; 114 | $frameworkPackages = []; 115 | foreach ($typo3Package->getReplaces() as $name => $_) { 116 | if (is_string($name) && strpos($name, 'typo3/cms-') === 0) { 117 | $frameworkPackages[] = $name; 118 | } 119 | } 120 | $installedPackages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages(); 121 | $rootPackage = $this->composer->getPackage(); 122 | $installedPackages[$rootPackage->getName()] = $rootPackage; 123 | foreach ($installedPackages as $package) { 124 | $requires = $package->getRequires(); 125 | if ($package === $rootPackage && $this->isDevMode) { 126 | $requires = array_merge($requires, $package->getDevRequires()); 127 | } 128 | foreach ($requires as $name => $link) { 129 | if (is_string($name) && in_array($name, $frameworkPackages, true)) { 130 | $extensionKey = $this->determineExtKeyFromPackageName($name); 131 | $this->io->writeError(sprintf('The package "%s" requires: "%s"', $package->getName(), $name), true, IOInterface::DEBUG); 132 | $this->io->writeError(sprintf('The extension key for package "%s" is: "%s"', $name, $extensionKey), true, IOInterface::DEBUG); 133 | $coreExtensionKeys[$name] = $extensionKey; 134 | } 135 | } 136 | } 137 | return $coreExtensionKeys; 138 | } 139 | 140 | /** 141 | * @return array 142 | */ 143 | private function getCoreExtensionKeysFromInstalledPackages(): array 144 | { 145 | $corePackages = []; 146 | $installedPackages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages(); 147 | foreach ($installedPackages as $package) { 148 | if ($package->getType() === 'typo3-cms-framework') { 149 | $extensionKey = $this->determineExtKeyFromPackageName($package->getName()); 150 | $this->io->writeError(sprintf('The framework package "%s" is installed.', $package->getName()), true, IOInterface::DEBUG); 151 | $this->io->writeError(sprintf('The extension key for package "%s" is: "%s"', $package->getName(), $extensionKey), true, IOInterface::DEBUG); 152 | $corePackages[$package->getName()] = $extensionKey; 153 | } 154 | } 155 | return $corePackages; 156 | } 157 | 158 | /** 159 | * @param string $packageName 160 | * @return string 161 | */ 162 | private function determineExtKeyFromPackageName(string $packageName): string 163 | { 164 | return str_replace(['typo3/cms-', '-'], ['', '_'], $packageName); 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /src/IncludeFile/TokenInterface.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * For the full copyright and license information, please view the LICENSE 11 | * file that was distributed with this source code. 12 | */ 13 | 14 | interface TokenInterface 15 | { 16 | /** 17 | * The name of the token that shall be replaced 18 | * 19 | * @return string 20 | */ 21 | public function getName(): string; 22 | 23 | /** 24 | * The content the token should be replaced with 25 | * 26 | * @return string 27 | */ 28 | public function getContent(): string; 29 | } 30 | -------------------------------------------------------------------------------- /src/Plugin.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * For the full copyright and license information, please view the LICENSE 11 | * file that was distributed with this source code. 12 | */ 13 | 14 | use Composer\Composer; 15 | use Composer\EventDispatcher\EventSubscriberInterface; 16 | use Composer\IO\IOInterface; 17 | use Composer\Plugin\PluginInterface; 18 | use Composer\Script\Event; 19 | use Composer\Script\ScriptEvents; 20 | 21 | class Plugin implements PluginInterface, EventSubscriberInterface 22 | { 23 | /** 24 | * @var PluginImplementation 25 | */ 26 | private $pluginImplementation; 27 | 28 | /** 29 | * @var array 30 | */ 31 | private $handledEvents = []; 32 | 33 | /** 34 | * {@inheritDoc} 35 | */ 36 | public static function getSubscribedEvents() 37 | { 38 | return [ 39 | ScriptEvents::PRE_AUTOLOAD_DUMP => ['listen'], 40 | ScriptEvents::POST_AUTOLOAD_DUMP => ['listen'], 41 | ]; 42 | } 43 | 44 | /** 45 | * {@inheritdoc} 46 | */ 47 | public function activate(Composer $composer, IOInterface $io) 48 | { 49 | $composer->getEventDispatcher()->addSubscriber($this); 50 | } 51 | 52 | public function deactivate(Composer $composer, IOInterface $io) 53 | { 54 | // Nothing to do 55 | } 56 | 57 | public function uninstall(Composer $composer, IOInterface $io) 58 | { 59 | // Nothing to do 60 | } 61 | 62 | /** 63 | * Listens to Composer events. 64 | * 65 | * This method is very minimalist on purpose. We want to load the actual 66 | * implementation only after updating the Composer packages so that we get 67 | * the updated version (if available). 68 | * 69 | * @param Event $event The Composer event. 70 | */ 71 | public function listen(Event $event) 72 | { 73 | if (!empty($this->handledEvents[$event->getName()])) { 74 | return; 75 | } 76 | $this->handledEvents[$event->getName()] = true; 77 | // Plugin has been uninstalled 78 | if (!file_exists(__FILE__) || !file_exists(__DIR__ . '/PluginImplementation.php')) { 79 | return; 80 | } 81 | 82 | // Load the implementation only after updating Composer so that we get 83 | // the new version of the plugin when a new one was installed 84 | if (null === $this->pluginImplementation) { 85 | $this->pluginImplementation = new PluginImplementation($event); 86 | } 87 | 88 | switch ($event->getName()) { 89 | case ScriptEvents::PRE_AUTOLOAD_DUMP: 90 | $this->pluginImplementation->preAutoloadDump(); 91 | break; 92 | case ScriptEvents::POST_AUTOLOAD_DUMP: 93 | $this->pluginImplementation->postAutoloadDump(); 94 | break; 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/PluginImplementation.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * For the full copyright and license information, please view the LICENSE 11 | * file that was distributed with this source code. 12 | */ 13 | 14 | use Composer\Script\Event; 15 | use Composer\Util\Filesystem; 16 | use Helhum\Typo3ConsolePlugin\IncludeFile\ActiveTypo3ExtensionsToken; 17 | 18 | class PluginImplementation 19 | { 20 | /** 21 | * @var Event 22 | */ 23 | private $event; 24 | 25 | /** 26 | * @var IncludeFile 27 | */ 28 | private $includeFile; 29 | 30 | /** 31 | * @param Event $event 32 | * @param IncludeFile $includeFile 33 | */ 34 | public function __construct(Event $event, IncludeFile $includeFile = null) 35 | { 36 | $this->event = $event; 37 | $this->includeFile = $includeFile 38 | ?: new IncludeFile( 39 | $event->getIO(), 40 | $event->getComposer(), 41 | [ 42 | new ActiveTypo3ExtensionsToken($event->getIO(), $event->getComposer(), Config::load($event->getIO(), $event->getComposer()->getConfig()), $event->isDevMode()), 43 | ], 44 | new Filesystem() 45 | ); 46 | } 47 | 48 | public function preAutoloadDump() 49 | { 50 | $this->includeFile->register(); 51 | } 52 | 53 | /** 54 | * Action called after autoload dump 55 | */ 56 | public function postAutoloadDump() 57 | { 58 | } 59 | } 60 | --------------------------------------------------------------------------------