diff --git a/.github/ISSUE_TEMPLATE b/.github/ISSUE_TEMPLATE new file mode 100644 index 000000000..fdf819bc9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE @@ -0,0 +1,41 @@ +### Issue title + +The issue title should comply with the following structure: + +[ *ISSUE-GROUP* ] Short description + +The *ISSUE-GROUP* should be one of: + +* `command:name` +* `console` +* `helper` +* `standard` +* `template` +* `translation` +* `test` +* `docs` + +### Problem/Motivation +A brief statement describing why the issue was filed. + +**Details to include:** +- Why are we doing this? Above all, a summary should explain why a change is needed, in a few short sentences. + +### How to reproduce +Include steps related how to reproduce. + +**Details to include:** +- Drupal version (you can obtain this by running `drupal site:status`). +- Console version (you can obtain this by running `composer show | grep drupal/console`). +- Console Launcher version (you can obtain this by running outside of a drupal site `drupal --version`). +- Steps to reproduce +- Include screen-shot or video whenever necessary. + +### Solution +A brief description of the proposed fix. + +**Details to include:** +- A short summary of the approach proposed or used in the PR. +- Approaches that have been tried and ruled out. +- Links to relevant API documentation or other resources. +- Known workarounds. diff --git a/.gitignore b/.gitignore index cd0a01892..4c2775433 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /.rules # Composer +composer.lock /vendor /bin/phpunit /bin/jsonlint @@ -11,6 +12,12 @@ /bin/pdepend /bin/php-cs-fixer /bin/phpmd +/bin/php-parse +/bin/psysh +PATCHES.txt + +# Develop +autoload.local.php # Binaries /box.phar @@ -25,14 +32,6 @@ /core /nbproject/ -composer.phar - -.idea/DrupalConsole.iml - -.idea/modules.xml - -.idea/php.xml - -.idea/vcs.xml - -.idea/workspace.xml +# drupal/console-extend-plugin generated files +extend.console.*.yml +*-console.services.yml diff --git a/.php_cs b/.php_cs index 9e1054c9a..f396a6704 100644 --- a/.php_cs +++ b/.php_cs @@ -1,4 +1,10 @@ level(Symfony\CS\FixerInterface::PSR2_LEVEL); +return PhpCsFixer\Config::create() + ->setRules( + [ + '@PSR2' => true, + 'array_syntax' => ['syntax' => 'short'], + ] + ) + ->setUsingCache(false); diff --git a/.travis.yml b/.travis.yml index e99ed99d3..e0ae1423e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,14 +5,16 @@ language: php php: - 5.5.9 - 5.6 - - 7 + - 7.0 + - 7.1 - hhvm matrix: fast_finish: true allow_failures: - php: hhvm - - php: 7 + - php: 7.0 + - php: 7.1 env: global: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d11bb3d37..c1fb6de9b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,11 +35,12 @@ A brief statement describing why the issue was filed. - Why are we doing this? Above all, a summary should explain why a change is needed, in a few short sentences. ### How to reproduce -Include steps related how to reproduce. +Include steps related how to reproduce. **Details to include:** -- Drupal version (you can obtain this by running `drupal site:status`). -- Console version (you can obtain this by running `drupal --version`). +- Drupal version (you can obtain this by running `drupal site:status`). +- Console version (you can obtain this by running `composer show | grep drupal/console`). +- Console Launcher version (you can obtain this by running outside of a drupal site `drupal --version`). - Steps to reproduce - Include screen-shot or video whenever necessary. diff --git a/README.md b/README.md index 046b27cd5..f94f86818 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,12 @@ **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* -- [Drupal Console](#drupal-console) + - [Drupal Console](#drupal-console) - [Required PHP version](#required-php-version) - [Drupal Console documentation](#documentation) - - [Download as new dependency](#download-as-new-dependency) - - [Fix download the latest version](#fix-download-the-latest-version) - - [Download using DrupalComposer](#download-using-drupalcomposer) - - [Install Drupal Console Launcher](#install-drupal-console-launcher) - - [Run Drupal Console](#running-drupal-console) + - [Download Drupal Console](#download) + - [Run Drupal Console](#run) + - [Contributors](#contributors) - [Supporting organizations](#supporting-organizations) @@ -18,13 +16,13 @@ Drupal Console ============================================= [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/hechoendrupal/DrupalConsole) -[![Build Status](https://travis-ci.org/hechoendrupal/DrupalConsole.svg?branch=master)](https://travis-ci.org/hechoendrupal/DrupalConsole) +[![Build Status](https://travis-ci.org/hechoendrupal/drupal-console.svg?branch=master)](https://travis-ci.org/hechoendrupal/drupal-console) [![Latest Stable Version](https://poser.pugx.org/drupal/console/v/stable.svg)](https://packagist.org/packages/drupal/console) [![Latest Unstable Version](https://poser.pugx.org/drupal/console/v/unstable.svg)](https://packagist.org/packages/drupal/console) [![Software License](https://img.shields.io/badge/license-GPL%202.0+-blue.svg)](https://packagist.org/packages/drupal/console) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/d0f089ff-a6e9-4ba4-b353-cb68173c7d90/mini.png)](https://insight.sensiolabs.com/projects/d0f089ff-a6e9-4ba4-b353-cb68173c7d90) -The Drupal Console is a CLI tool to generate boilerplate code, interact and debug Drupal 8. +The Drupal CLI. A tool to generate boilerplate code, interact with and debug Drupal. ## Latest Version Details of the latest version can be found on the Drupal Console project page under https://drupalconsole.com/. @@ -40,78 +38,36 @@ More information about using this project at the [official documentation](http:/ ## Required PHP Version PHP 5.5.9 or higher is required to use the Drupal Console application. -## Download as new dependency -``` -# Change directory to Drupal site -cd /path/to/drupal8.dev - -# Download DrupalConsole -composer require drupal/console:~1.0 \ ---prefer-dist \ ---optimize-autoloader \ ---sort-packages -``` - -## Fix download the latest version - -Drupal 8 include some outdated libraries of Symfony 2.7.x, as result you get an old release of Drupal Console. - -To fix that, execute the following command and you will get the latest release of Drupal Console. -``` -composer update drupal/console --with-dependencies -``` - -## Download using DrupalComposer -``` -composer create-project \ -drupal-composer/drupal-project:8.x-dev \ -drupal8.dev \ ---prefer-dist \ ---no-progress \ ---no-interaction -``` +## Download -## Install Drupal Console Launcher -``` -# Run this in your terminal to get the latest version: -curl https://drupalconsole.com/installer -L -o drupal.phar - -# Or if you don't have curl: -php -r "readfile('https://drupalconsole.com/installer');" > drupal.phar - -# Accessing from anywhere on your system: -mv drupal.phar /usr/local/bin/drupal +[Install Drupal Console Using Composer](https://docs.drupalconsole.com/en/getting/composer.html) -# Apply executable permissions on the downloaded file: -chmod +x /usr/local/bin/drupal +[Install Drupal Console Launcher](https://docs.drupalconsole.com/en/getting/launcher.html) -# Copy configuration files. -drupal init --override +[Installing Drupal Console on Windows](https://docs.drupalconsole.com/en/getting/windows.html) -# Check and validate system requirements -drupal check +## Run +Using the DrupalConsole Launcher ``` +drupal +``` -## Run Drupal Console -We highly recommend you to install the global executable, but if is not installed, then you can run DrupalConsole by: +We highly recommend you to install the global executable, but if is not installed, you can run Drupal Console depending on your installation by executing: -Using default Drupal + DrupalConsole ``` vendor/bin/drupal -``` -Using DrupalComposer -Change directory `web`, `docroot` or any other. -``` -../vendor/bin/drupal +# or +vendor/drupal/console/bin/drupal +# or +bin/drupal ``` - ## Drupal Console Support You can ask for support at Drupal Console gitter chat room [http://bit.ly/console-support](http://bit.ly/console-support). -## Getting The Project To Contribute - -For information about how to run this project for development follow instructions at [setup instructions](https://gist.github.com/jmolivas/97bbd07f328217be3564a434c5bd2618). +## Contribute to Drupal Console +* [Getting the project](https://docs.drupalconsole.com/en/contributing/getting-the-project.html) +* [Running the project](https://docs.drupalconsole.com/en/contributing/running-the-project.html) ## Enabling Autocomplete ``` @@ -130,14 +86,16 @@ source "$HOME/.console/console.rc" 2>/dev/null ln -s ~/.console/drupal.fish ~/.config/fish/completions/drupal.fish ``` +## Contributors + +[Full list of contributors](https://drupalconsole.com/contributors) + ## Supporting Organizations [![weKnow](https://www.drupal.org/files/weKnow-logo_5.png)](http://weknowinc.com) [![Anexus](https://www.drupal.org/files/anexus-logo.png)](http://www.anexusit.com/) -[![Indava](https://www.drupal.org/files/indava-logo.png)](http://www.indava.com/) - -[![FFW](https://www.drupal.org/files/ffw-logo.png)](https://ffwagency.com) +[All supporting organizations](https://drupalconsole.com/supporting-organizations) > Drupal is a registered trademark of Dries Buytaert. diff --git a/Test/Generator/ProfileGeneratorTest.php b/Test/Generator/ProfileGeneratorTest.php index 15735a4b6..c6ea12ddd 100644 --- a/Test/Generator/ProfileGeneratorTest.php +++ b/Test/Generator/ProfileGeneratorTest.php @@ -37,6 +37,7 @@ public function testGenerateProfile( $description, $core, $dependencies, + $themes, $distribution ) { $generator = new ProfileGenerator(); @@ -51,6 +52,7 @@ public function testGenerateProfile( $description, $core, $dependencies, + $themes, $distribution ); diff --git a/autoload.local.php.dist b/autoload.local.php.dist new file mode 100644 index 000000000..d73d40900 --- /dev/null +++ b/autoload.local.php.dist @@ -0,0 +1,3 @@ +get('root', getcwd()); + +$drupalFinder = new DrupalFinder(); +if (!$drupalFinder->locateRoot($root)) { + $io->error('DrupalConsole must be executed within a Drupal Site.'); exit(1); } -$argvInputReader = new ArgvInputReader(); -if ($root === $appRoot && $argvInputReader->get('root')) { - $appRoot = $argvInputReader->get('root'); - if (is_dir($appRoot)) { - chdir($appRoot); - } - else { - $appRoot = $root; - } +chdir($drupalFinder->getDrupalRoot()); +$configurationManager = new ConfigurationManager(); +$configuration = $configurationManager + ->loadConfigurationFromDirectory($drupalFinder->getComposerRoot()); + +$debug = $argvInputReader->get('debug', false); +if ($configuration && $options = $configuration->get('application.options') ?: []) { + $argvInputReader->setOptionsFromConfiguration($options); } $argvInputReader->setOptionsAsArgv(); -$drupal = new Drupal($autoload, $root, $appRoot); +if ($debug){ + $io->writeln( + sprintf( + '%s version %s', + Application::NAME, + Application::VERSION + ) + ); +} + +$drupal = new Drupal($autoload, $drupalFinder); $container = $drupal->boot(); if (!$container) { - echo ' In order to list all of the available commands you should try: ' . PHP_EOL . - ' Copy config files: drupal init ' . PHP_EOL . - ' Install Drupal site: drupal site:install ' . PHP_EOL; + $io->error('Something was wrong. Drupal can not be bootstrap.'); exit(1); } -$configuration = $container->get('console.configuration_manager') - ->getConfiguration(); - -$translator = $container->get('console.translator_manager'); - -if ($options = $configuration->get('application.options') ?: []) { - $argvInputReader->setOptionsFromConfiguration($options); -} -$argvInputReader->setOptionsAsArgv(); - $application = new Application($container); $application->setDefaultCommand('about'); $application->run( diff --git a/composer.json b/composer.json index f9cb8fab2..071d9f935 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { "name": "drupal/console", - "description": "The Drupal Console is a CLI tool to generate boilerplate code, interact and debug Drupal 8.", + "description": "The Drupal CLI. A tool to generate boilerplate code, interact with and debug Drupal.", "keywords": ["Drupal", "Console", "Development", "Symfony"], "homepage": "http://drupalconsole.com/", - "type": "project", + "type": "library", "license": "GPL-2.0+", "authors": [ { @@ -37,20 +37,20 @@ }, "require": { "php": "^5.5.9 || ^7.0", - "alchemy/zippy": "0.3.5", + "alchemy/zippy": "0.4.3", "composer/installers": "~1.0", - "drupal/console-core" : "^1.0", - "symfony/css-selector": "~2.8", - "symfony/debug": "~2.6|~2.8", - "symfony/dom-crawler": "~2.7|~2.8", - "symfony/http-foundation": "~2.8", - "phpseclib/phpseclib": "2.*", - "stecman/symfony-console-completion": "^0.5.1", - "guzzlehttp/guzzle": "~6.1", + "doctrine/annotations": "^1.2", + "doctrine/collections": "^1.3", + "drupal/console-core": "1.0.0-rc26", + "drupal/console-dotenv": "~0", + "drupal/console-extend-plugin": "~0", "gabordemooij/redbean": "~4.3", - "doctrine/annotations": "1.2.*", - "dflydev/placeholder-resolver": "~1.0", - "symfony/expression-language": "^2.8" + "guzzlehttp/guzzle": "~6.1", + "psy/psysh": "0.6.* || ~0.8", + "symfony/css-selector": "~2.8|~3.0", + "symfony/dom-crawler": "~2.8|~3.0", + "symfony/expression-language": "~2.8|~3.0", + "symfony/http-foundation": "~2.8|~3.0" }, "require-dev": { "phpunit/phpunit": "~4.8", @@ -58,7 +58,8 @@ }, "bin": ["bin/drupal"], "config": { - "bin-dir": "bin/" + "bin-dir": "bin/", + "sort-packages": true }, "minimum-stability": "dev", "prefer-stable": true, diff --git a/composer.lock b/composer.lock deleted file mode 100644 index b8d7ecab2..000000000 --- a/composer.lock +++ /dev/null @@ -1,4762 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", - "This file is @generated automatically" - ], - "hash": "0a89e181c2c2172473b3893dd082c2cf", - "content-hash": "cb0623dd2ffa75e54144335607995cf5", - "packages": [ - { - "name": "alchemy/zippy", - "version": "0.3.5", - "source": { - "type": "git", - "url": "https://github.com/alchemy-fr/Zippy.git", - "reference": "92c773f7bbe47fdb30c61dbaea3dcbf4dd13a40a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/alchemy-fr/Zippy/zipball/92c773f7bbe47fdb30c61dbaea3dcbf4dd13a40a", - "reference": "92c773f7bbe47fdb30c61dbaea3dcbf4dd13a40a", - "shasum": "" - }, - "require": { - "doctrine/collections": "~1.0", - "ext-mbstring": "*", - "php": ">=5.3.3", - "symfony/filesystem": "^2.0.5|^3.0", - "symfony/process": "^2.1|^3.0" - }, - "require-dev": { - "ext-zip": "*", - "guzzle/guzzle": "~3.0", - "phpunit/phpunit": "^4.0|^5.0", - "symfony/finder": "^2.0.5|^3.0" - }, - "suggest": { - "ext-zip": "To use the ZipExtensionAdapter", - "guzzle/guzzle": "To use the GuzzleTeleporter" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.2.x-dev" - } - }, - "autoload": { - "psr-4": { - "Alchemy\\Zippy\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Alchemy", - "email": "dev.team@alchemy.fr", - "homepage": "http://www.alchemy.fr/" - } - ], - "description": "Zippy, the archive manager companion", - "keywords": [ - "bzip", - "compression", - "tar", - "zip" - ], - "time": "2016-02-15 22:46:40" - }, - { - "name": "composer/installers", - "version": "v1.2.0", - "source": { - "type": "git", - "url": "https://github.com/composer/installers.git", - "reference": "d78064c68299743e0161004f2de3a0204e33b804" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/installers/zipball/d78064c68299743e0161004f2de3a0204e33b804", - "reference": "d78064c68299743e0161004f2de3a0204e33b804", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.0" - }, - "replace": { - "roundcube/plugin-installer": "*", - "shama/baton": "*" - }, - "require-dev": { - "composer/composer": "1.0.*@dev", - "phpunit/phpunit": "4.1.*" - }, - "type": "composer-plugin", - "extra": { - "class": "Composer\\Installers\\Plugin", - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-4": { - "Composer\\Installers\\": "src/Composer/Installers" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Kyle Robinson Young", - "email": "kyle@dontkry.com", - "homepage": "https://github.com/shama" - } - ], - "description": "A multi-framework Composer library installer", - "homepage": "https://composer.github.io/installers/", - "keywords": [ - "Craft", - "Dolibarr", - "Hurad", - "ImageCMS", - "MODX Evo", - "Mautic", - "OXID", - "Plentymarkets", - "RadPHP", - "SMF", - "Thelia", - "WolfCMS", - "agl", - "aimeos", - "annotatecms", - "attogram", - "bitrix", - "cakephp", - "chef", - "cockpit", - "codeigniter", - "concrete5", - "croogo", - "dokuwiki", - "drupal", - "elgg", - "expressionengine", - "fuelphp", - "grav", - "installer", - "joomla", - "kohana", - "laravel", - "lithium", - "magento", - "mako", - "mediawiki", - "modulework", - "moodle", - "phpbb", - "piwik", - "ppi", - "puppet", - "reindex", - "roundcube", - "shopware", - "silverstripe", - "symfony", - "typo3", - "wordpress", - "yawik", - "zend", - "zikula" - ], - "time": "2016-08-13 20:53:52" - }, - { - "name": "dflydev/dot-access-configuration", - "version": "v1.0.1", - "source": { - "type": "git", - "url": "https://github.com/dflydev/dflydev-dot-access-configuration.git", - "reference": "9b65c83159c9003e00284ea1144ad96b69d9c8b9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/dflydev/dflydev-dot-access-configuration/zipball/9b65c83159c9003e00284ea1144ad96b69d9c8b9", - "reference": "9b65c83159c9003e00284ea1144ad96b69d9c8b9", - "shasum": "" - }, - "require": { - "dflydev/dot-access-data": "1.*", - "dflydev/placeholder-resolver": "1.*", - "php": ">=5.3.2" - }, - "require-dev": { - "symfony/yaml": "~2.1" - }, - "suggest": { - "symfony/yaml": "Required for using the YAML Configuration Builders" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-0": { - "Dflydev\\DotAccessConfiguration": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Dragonfly Development Inc.", - "email": "info@dflydev.com", - "homepage": "http://dflydev.com" - }, - { - "name": "Beau Simensen", - "email": "beau@dflydev.com", - "homepage": "http://beausimensen.com" - } - ], - "description": "Given a deep data structure representing a configuration, access configuration by dot notation.", - "homepage": "https://github.com/dflydev/dflydev-dot-access-configuration", - "keywords": [ - "config", - "configuration" - ], - "time": "2014-11-14 03:26:12" - }, - { - "name": "dflydev/dot-access-data", - "version": "v1.0.1", - "source": { - "type": "git", - "url": "https://github.com/dflydev/dflydev-dot-access-data.git", - "reference": "7a0960d088119818ce7687d200c363b01d183cbe" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/dflydev/dflydev-dot-access-data/zipball/7a0960d088119818ce7687d200c363b01d183cbe", - "reference": "7a0960d088119818ce7687d200c363b01d183cbe", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-0": { - "Dflydev\\DotAccessData": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Dragonfly Development Inc.", - "email": "info@dflydev.com", - "homepage": "http://dflydev.com" - }, - { - "name": "Beau Simensen", - "email": "beau@dflydev.com", - "homepage": "http://beausimensen.com" - } - ], - "description": "Given a deep data structure, access data by dot notation.", - "homepage": "https://github.com/dflydev/dflydev-dot-access-data", - "keywords": [ - "access", - "data", - "dot", - "notation" - ], - "time": "2015-08-13 03:51:18" - }, - { - "name": "dflydev/placeholder-resolver", - "version": "v1.0.2", - "source": { - "type": "git", - "url": "https://github.com/dflydev/dflydev-placeholder-resolver.git", - "reference": "c498d0cae91b1bb36cc7d60906dab8e62bb7c356" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/dflydev/dflydev-placeholder-resolver/zipball/c498d0cae91b1bb36cc7d60906dab8e62bb7c356", - "reference": "c498d0cae91b1bb36cc7d60906dab8e62bb7c356", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-0": { - "Dflydev\\PlaceholderResolver": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Dragonfly Development Inc.", - "email": "info@dflydev.com", - "homepage": "http://dflydev.com" - }, - { - "name": "Beau Simensen", - "email": "beau@dflydev.com", - "homepage": "http://beausimensen.com" - } - ], - "description": "Given a data source representing key => value pairs, resolve placeholders like ${foo.bar} to the value associated with the 'foo.bar' key in the data source.", - "homepage": "https://github.com/dflydev/dflydev-placeholder-resolver", - "keywords": [ - "placeholder", - "resolver" - ], - "time": "2012-10-28 21:08:28" - }, - { - "name": "doctrine/annotations", - "version": "v1.2.7", - "source": { - "type": "git", - "url": "https://github.com/doctrine/annotations.git", - "reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/f25c8aab83e0c3e976fd7d19875f198ccf2f7535", - "reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535", - "shasum": "" - }, - "require": { - "doctrine/lexer": "1.*", - "php": ">=5.3.2" - }, - "require-dev": { - "doctrine/cache": "1.*", - "phpunit/phpunit": "4.*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "psr-0": { - "Doctrine\\Common\\Annotations\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Docblock Annotations Parser", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "annotations", - "docblock", - "parser" - ], - "time": "2015-08-31 12:32:49" - }, - { - "name": "doctrine/collections", - "version": "v1.3.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/collections.git", - "reference": "6c1e4eef75f310ea1b3e30945e9f06e652128b8a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/collections/zipball/6c1e4eef75f310ea1b3e30945e9f06e652128b8a", - "reference": "6c1e4eef75f310ea1b3e30945e9f06e652128b8a", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "psr-0": { - "Doctrine\\Common\\Collections\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Collections Abstraction library", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "array", - "collections", - "iterator" - ], - "time": "2015-04-14 22:21:58" - }, - { - "name": "doctrine/lexer", - "version": "v1.0.1", - "source": { - "type": "git", - "url": "https://github.com/doctrine/lexer.git", - "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c", - "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "Doctrine\\Common\\Lexer\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "lexer", - "parser" - ], - "time": "2014-09-09 13:34:57" - }, - { - "name": "drupal/console-core", - "version": "1.0.0-rc6", - "source": { - "type": "git", - "url": "https://github.com/hechoendrupal/drupal-console-core.git", - "reference": "105bf5845f17b336c9a62fbd3e576eaea0eb91d5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/hechoendrupal/drupal-console-core/zipball/105bf5845f17b336c9a62fbd3e576eaea0eb91d5", - "reference": "105bf5845f17b336c9a62fbd3e576eaea0eb91d5", - "shasum": "" - }, - "require": { - "dflydev/dot-access-configuration": "1.*", - "drupal/console-en": "~1.0", - "php": "^5.5.9 || ^7.0", - "stecman/symfony-console-completion": "^0.5.1", - "symfony/config": "~2.8", - "symfony/console": "~2.8", - "symfony/dependency-injection": "~2.8", - "symfony/event-dispatcher": "~2.8", - "symfony/filesystem": "~2.8", - "symfony/finder": "~2.8", - "symfony/process": "~2.8", - "symfony/translation": "~2.8", - "symfony/yaml": "~2.8", - "twig/twig": "^1.23.1" - }, - "type": "project", - "autoload": { - "files": [ - "src/constants.php", - "src/functions.php" - ], - "psr-4": { - "Drupal\\Console\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0+" - ], - "authors": [ - { - "name": "David Flores", - "email": "dmousex@gmail.com", - "homepage": "http://dmouse.net" - }, - { - "name": "Jesus Manuel Olivas", - "email": "jesus.olivas@gmail.com", - "homepage": "http://jmolivas.com" - }, - { - "name": "Drupal Console Contributors", - "homepage": "https://github.com/hechoendrupal/DrupalConsole/graphs/contributors" - }, - { - "name": "Eduardo Garcia", - "email": "enzo@enzolutions.com", - "homepage": "http://enzolutions.com/" - }, - { - "name": "Omar Aguirre", - "email": "omersguchigu@gmail.com" - } - ], - "description": "Drupal Console Core", - "homepage": "http://drupalconsole.com/", - "keywords": [ - "console", - "development", - "drupal", - "symfony" - ], - "time": "2016-10-17 16:55:41" - }, - { - "name": "drupal/console-en", - "version": "1.0.0-rc2", - "source": { - "type": "git", - "url": "https://github.com/hechoendrupal/drupal-console-en.git", - "reference": "d95f7673ce0d3253efb7ce054a2bf13e6cf9c773" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/hechoendrupal/drupal-console-en/zipball/d95f7673ce0d3253efb7ce054a2bf13e6cf9c773", - "reference": "d95f7673ce0d3253efb7ce054a2bf13e6cf9c773", - "shasum": "" - }, - "type": "drupal-console-language", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0+" - ], - "authors": [ - { - "name": "David Flores", - "email": "dmousex@gmail.com", - "homepage": "http://dmouse.net" - }, - { - "name": "Jesus Manuel Olivas", - "email": "jesus.olivas@gmail.com", - "homepage": "http://jmolivas.com" - }, - { - "name": "Drupal Console Contributors", - "homepage": "https://github.com/hechoendrupal/DrupalConsole/graphs/contributors" - }, - { - "name": "Eduardo Garcia", - "email": "enzo@enzolutions.com", - "homepage": "http://enzolutions.com/" - }, - { - "name": "Omar Aguirre", - "email": "omersguchigu@gmail.com" - } - ], - "description": "Drupal Console English Language", - "homepage": "http://drupalconsole.com/", - "keywords": [ - "console", - "development", - "drupal", - "symfony" - ], - "time": "2016-10-17 16:30:14" - }, - { - "name": "gabordemooij/redbean", - "version": "v4.3.2", - "source": { - "type": "git", - "url": "https://github.com/gabordemooij/redbean.git", - "reference": "72368f15cedfa7990c7fb228e47d2f00c7f49d4f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/gabordemooij/redbean/zipball/72368f15cedfa7990c7fb228e47d2f00c7f49d4f", - "reference": "72368f15cedfa7990c7fb228e47d2f00c7f49d4f", - "shasum": "" - }, - "require": { - "php": ">=5.3.4" - }, - "type": "library", - "autoload": { - "psr-4": { - "RedBeanPHP\\": "RedBeanPHP" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "New BSD and GPLv2" - ], - "authors": [ - { - "name": "Gabor de Mooij", - "email": "gabor@redbeanphp.com", - "homepage": "http://redbeanphp.com" - } - ], - "description": "RedBeanPHP ORM", - "homepage": "http://redbeanphp.com/", - "keywords": [ - "orm" - ], - "time": "2016-05-01 10:27:43" - }, - { - "name": "guzzlehttp/guzzle", - "version": "6.2.2", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "ebf29dee597f02f09f4d5bbecc68230ea9b08f60" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/ebf29dee597f02f09f4d5bbecc68230ea9b08f60", - "reference": "ebf29dee597f02f09f4d5bbecc68230ea9b08f60", - "shasum": "" - }, - "require": { - "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.3.1", - "php": ">=5.5" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "^4.0", - "psr/log": "^1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "6.2-dev" - } - }, - "autoload": { - "files": [ - "src/functions_include.php" - ], - "psr-4": { - "GuzzleHttp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle is a PHP HTTP client library", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ], - "time": "2016-10-08 15:01:37" - }, - { - "name": "guzzlehttp/promises", - "version": "1.2.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/promises.git", - "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/c10d860e2a9595f8883527fa0021c7da9e65f579", - "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579", - "shasum": "" - }, - "require": { - "php": ">=5.5.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle promises library", - "keywords": [ - "promise" - ], - "time": "2016-05-18 16:56:05" - }, - { - "name": "guzzlehttp/psr7", - "version": "1.3.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", - "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", - "shasum": "" - }, - "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0" - }, - "provide": { - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "PSR-7 message implementation", - "keywords": [ - "http", - "message", - "stream", - "uri" - ], - "time": "2016-06-24 23:00:38" - }, - { - "name": "ircmaxell/password-compat", - "version": "v1.0.4", - "source": { - "type": "git", - "url": "https://github.com/ircmaxell/password_compat.git", - "reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ircmaxell/password_compat/zipball/5c5cde8822a69545767f7c7f3058cb15ff84614c", - "reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c", - "shasum": "" - }, - "require-dev": { - "phpunit/phpunit": "4.*" - }, - "type": "library", - "autoload": { - "files": [ - "lib/password.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Anthony Ferrara", - "email": "ircmaxell@php.net", - "homepage": "http://blog.ircmaxell.com" - } - ], - "description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash", - "homepage": "https://github.com/ircmaxell/password_compat", - "keywords": [ - "hashing", - "password" - ], - "time": "2014-11-20 16:49:30" - }, - { - "name": "phpseclib/phpseclib", - "version": "2.0.4", - "source": { - "type": "git", - "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "ab8028c93c03cc8d9c824efa75dc94f1db2369bf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/ab8028c93c03cc8d9c824efa75dc94f1db2369bf", - "reference": "ab8028c93c03cc8d9c824efa75dc94f1db2369bf", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phing/phing": "~2.7", - "phpunit/phpunit": "~4.0", - "sami/sami": "~2.0", - "squizlabs/php_codesniffer": "~2.0" - }, - "suggest": { - "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.", - "ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.", - "ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.", - "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations." - }, - "type": "library", - "autoload": { - "files": [ - "phpseclib/bootstrap.php" - ], - "psr-4": { - "phpseclib\\": "phpseclib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jim Wigginton", - "email": "terrafrost@php.net", - "role": "Lead Developer" - }, - { - "name": "Patrick Monnerat", - "email": "pm@datasphere.ch", - "role": "Developer" - }, - { - "name": "Andreas Fischer", - "email": "bantu@phpbb.com", - "role": "Developer" - }, - { - "name": "Hans-Jürgen Petrich", - "email": "petrich@tronic-media.com", - "role": "Developer" - }, - { - "name": "Graham Campbell", - "email": "graham@alt-three.com", - "role": "Developer" - } - ], - "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.", - "homepage": "http://phpseclib.sourceforge.net", - "keywords": [ - "BigInteger", - "aes", - "asn.1", - "asn1", - "blowfish", - "crypto", - "cryptography", - "encryption", - "rsa", - "security", - "sftp", - "signature", - "signing", - "ssh", - "twofish", - "x.509", - "x509" - ], - "time": "2016-10-04 00:57:04" - }, - { - "name": "psr/http-message", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP messages", - "homepage": "https://github.com/php-fig/http-message", - "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" - ], - "time": "2016-08-06 14:39:51" - }, - { - "name": "psr/log", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "time": "2016-10-10 12:19:37" - }, - { - "name": "stecman/symfony-console-completion", - "version": "0.5.1", - "source": { - "type": "git", - "url": "https://github.com/stecman/symfony-console-completion.git", - "reference": "1a9fc7ab4820cd1aabbdc584c6b25d221e7b6cb5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/stecman/symfony-console-completion/zipball/1a9fc7ab4820cd1aabbdc584c6b25d221e7b6cb5", - "reference": "1a9fc7ab4820cd1aabbdc584c6b25d221e7b6cb5", - "shasum": "" - }, - "require": { - "php": ">=5.3.2", - "symfony/console": "~2.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.5.x-dev" - } - }, - "autoload": { - "psr-4": { - "Stecman\\Component\\Symfony\\Console\\BashCompletion\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Stephen Holdaway", - "email": "stephen@stecman.co.nz" - } - ], - "description": "Automatic BASH completion for Symfony Console Component based applications.", - "time": "2015-05-07 12:21:50" - }, - { - "name": "symfony/config", - "version": "v2.8.12", - "source": { - "type": "git", - "url": "https://github.com/symfony/config.git", - "reference": "f8b1922bbda9d2ac86aecd649399040bce849fde" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/f8b1922bbda9d2ac86aecd649399040bce849fde", - "reference": "f8b1922bbda9d2ac86aecd649399040bce849fde", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "symfony/filesystem": "~2.3|~3.0.0" - }, - "suggest": { - "symfony/yaml": "To use the yaml reference dumper" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Config\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Config Component", - "homepage": "https://symfony.com", - "time": "2016-09-14 20:31:12" - }, - { - "name": "symfony/console", - "version": "v2.8.12", - "source": { - "type": "git", - "url": "https://github.com/symfony/console.git", - "reference": "d7a5a88178f94dcc29531ea4028ea614e35452d4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/d7a5a88178f94dcc29531ea4028ea614e35452d4", - "reference": "d7a5a88178f94dcc29531ea4028ea614e35452d4", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "symfony/debug": "~2.7,>=2.7.2|~3.0.0", - "symfony/polyfill-mbstring": "~1.0" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.1|~3.0.0", - "symfony/process": "~2.1|~3.0.0" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/process": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Console\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Console Component", - "homepage": "https://symfony.com", - "time": "2016-09-28 00:10:16" - }, - { - "name": "symfony/css-selector", - "version": "v2.8.12", - "source": { - "type": "git", - "url": "https://github.com/symfony/css-selector.git", - "reference": "71c8c3a04c126300c37089b1baa7c6322dfb845f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/71c8c3a04c126300c37089b1baa7c6322dfb845f", - "reference": "71c8c3a04c126300c37089b1baa7c6322dfb845f", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\CssSelector\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jean-François Simon", - "email": "jeanfrancois.simon@sensiolabs.com" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony CssSelector Component", - "homepage": "https://symfony.com", - "time": "2016-09-06 10:55:00" - }, - { - "name": "symfony/debug", - "version": "v2.8.12", - "source": { - "type": "git", - "url": "https://github.com/symfony/debug.git", - "reference": "8c29235936a47473af16fb91c7c4b7b193c5693c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/8c29235936a47473af16fb91c7c4b7b193c5693c", - "reference": "8c29235936a47473af16fb91c7c4b7b193c5693c", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "psr/log": "~1.0" - }, - "conflict": { - "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" - }, - "require-dev": { - "symfony/class-loader": "~2.2|~3.0.0", - "symfony/http-kernel": "~2.3.24|~2.5.9|~2.6,>=2.6.2|~3.0.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Debug\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Debug Component", - "homepage": "https://symfony.com", - "time": "2016-09-06 10:55:00" - }, - { - "name": "symfony/dependency-injection", - "version": "v2.8.12", - "source": { - "type": "git", - "url": "https://github.com/symfony/dependency-injection.git", - "reference": "ee9ec9ac2b046462d341e9de7c4346142d335e75" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/ee9ec9ac2b046462d341e9de7c4346142d335e75", - "reference": "ee9ec9ac2b046462d341e9de7c4346142d335e75", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "conflict": { - "symfony/expression-language": "<2.6" - }, - "require-dev": { - "symfony/config": "~2.2|~3.0.0", - "symfony/expression-language": "~2.6|~3.0.0", - "symfony/yaml": "~2.3.42|~2.7.14|~2.8.7|~3.0.7" - }, - "suggest": { - "symfony/config": "", - "symfony/expression-language": "For using expressions in service container configuration", - "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", - "symfony/yaml": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\DependencyInjection\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony DependencyInjection Component", - "homepage": "https://symfony.com", - "time": "2016-09-24 09:47:20" - }, - { - "name": "symfony/dom-crawler", - "version": "v2.8.12", - "source": { - "type": "git", - "url": "https://github.com/symfony/dom-crawler.git", - "reference": "aac03b7ea2a7adff10a3599d614e79e6101230ab" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/aac03b7ea2a7adff10a3599d614e79e6101230ab", - "reference": "aac03b7ea2a7adff10a3599d614e79e6101230ab", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "symfony/polyfill-mbstring": "~1.0" - }, - "require-dev": { - "symfony/css-selector": "~2.8|~3.0.0" - }, - "suggest": { - "symfony/css-selector": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\DomCrawler\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony DomCrawler Component", - "homepage": "https://symfony.com", - "time": "2016-07-30 07:20:35" - }, - { - "name": "symfony/event-dispatcher", - "version": "v2.8.12", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "889983a79a043dfda68f38c38b6dba092dd49cd8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/889983a79a043dfda68f38c38b6dba092dd49cd8", - "reference": "889983a79a043dfda68f38c38b6dba092dd49cd8", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.0,>=2.0.5|~3.0.0", - "symfony/dependency-injection": "~2.6|~3.0.0", - "symfony/expression-language": "~2.6|~3.0.0", - "symfony/stopwatch": "~2.3|~3.0.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\EventDispatcher\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony EventDispatcher Component", - "homepage": "https://symfony.com", - "time": "2016-07-28 16:56:28" - }, - { - "name": "symfony/expression-language", - "version": "v2.8.12", - "source": { - "type": "git", - "url": "https://github.com/symfony/expression-language.git", - "reference": "50c990ebd047e78b754aefee7b657aa5744e7068" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/expression-language/zipball/50c990ebd047e78b754aefee7b657aa5744e7068", - "reference": "50c990ebd047e78b754aefee7b657aa5744e7068", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\ExpressionLanguage\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony ExpressionLanguage Component", - "homepage": "https://symfony.com", - "time": "2016-09-06 10:55:00" - }, - { - "name": "symfony/filesystem", - "version": "v2.8.12", - "source": { - "type": "git", - "url": "https://github.com/symfony/filesystem.git", - "reference": "44b499521defddf2eae17a18c811bbdae4f98bdf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/44b499521defddf2eae17a18c811bbdae4f98bdf", - "reference": "44b499521defddf2eae17a18c811bbdae4f98bdf", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Filesystem\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Filesystem Component", - "homepage": "https://symfony.com", - "time": "2016-09-06 10:55:00" - }, - { - "name": "symfony/finder", - "version": "v2.8.12", - "source": { - "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "bc24c8f5674c6f6841f2856b70e5d60784be5691" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/bc24c8f5674c6f6841f2856b70e5d60784be5691", - "reference": "bc24c8f5674c6f6841f2856b70e5d60784be5691", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Finder\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Finder Component", - "homepage": "https://symfony.com", - "time": "2016-09-28 00:10:16" - }, - { - "name": "symfony/http-foundation", - "version": "v2.8.12", - "source": { - "type": "git", - "url": "https://github.com/symfony/http-foundation.git", - "reference": "91f87d27e9fe99435278c337375b0dce292fe0e2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/91f87d27e9fe99435278c337375b0dce292fe0e2", - "reference": "91f87d27e9fe99435278c337375b0dce292fe0e2", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "symfony/polyfill-mbstring": "~1.1", - "symfony/polyfill-php54": "~1.0", - "symfony/polyfill-php55": "~1.0" - }, - "require-dev": { - "symfony/expression-language": "~2.4|~3.0.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\HttpFoundation\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony HttpFoundation Component", - "homepage": "https://symfony.com", - "time": "2016-09-21 19:04:07" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.2.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "dff51f72b0706335131b00a7f49606168c582594" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/dff51f72b0706335131b00a7f49606168c582594", - "reference": "dff51f72b0706335131b00a7f49606168c582594", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "time": "2016-05-18 14:26:46" - }, - { - "name": "symfony/polyfill-php54", - "version": "v1.2.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php54.git", - "reference": "34d761992f6f2cc6092cc0e5e93f38b53ba5e4f1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php54/zipball/34d761992f6f2cc6092cc0e5e93f38b53ba5e4f1", - "reference": "34d761992f6f2cc6092cc0e5e93f38b53ba5e4f1", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php54\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "time": "2016-05-18 14:26:46" - }, - { - "name": "symfony/polyfill-php55", - "version": "v1.2.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php55.git", - "reference": "bf2ff9ad6be1a4772cb873e4eea94d70daa95c6d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php55/zipball/bf2ff9ad6be1a4772cb873e4eea94d70daa95c6d", - "reference": "bf2ff9ad6be1a4772cb873e4eea94d70daa95c6d", - "shasum": "" - }, - "require": { - "ircmaxell/password-compat": "~1.0", - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php55\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "time": "2016-05-18 14:26:46" - }, - { - "name": "symfony/process", - "version": "v2.8.12", - "source": { - "type": "git", - "url": "https://github.com/symfony/process.git", - "reference": "024de37f8a6b9e5e8244d9eb3fcf3e467dd2a93f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/024de37f8a6b9e5e8244d9eb3fcf3e467dd2a93f", - "reference": "024de37f8a6b9e5e8244d9eb3fcf3e467dd2a93f", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Process\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Process Component", - "homepage": "https://symfony.com", - "time": "2016-09-29 14:03:54" - }, - { - "name": "symfony/translation", - "version": "v2.8.12", - "source": { - "type": "git", - "url": "https://github.com/symfony/translation.git", - "reference": "bf0ff95faa9b6c0708efc1986255e3608d0ed3c7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/bf0ff95faa9b6c0708efc1986255e3608d0ed3c7", - "reference": "bf0ff95faa9b6c0708efc1986255e3608d0ed3c7", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "symfony/polyfill-mbstring": "~1.0" - }, - "conflict": { - "symfony/config": "<2.7" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.8", - "symfony/intl": "~2.4|~3.0.0", - "symfony/yaml": "~2.2|~3.0.0" - }, - "suggest": { - "psr/log": "To use logging capability in translator", - "symfony/config": "", - "symfony/yaml": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Translation\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Translation Component", - "homepage": "https://symfony.com", - "time": "2016-09-06 10:55:00" - }, - { - "name": "symfony/yaml", - "version": "v2.8.12", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "e7540734bad981fe59f8ef14b6fc194ae9df8d9c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/e7540734bad981fe59f8ef14b6fc194ae9df8d9c", - "reference": "e7540734bad981fe59f8ef14b6fc194ae9df8d9c", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "time": "2016-09-02 01:57:56" - }, - { - "name": "twig/twig", - "version": "v1.26.1", - "source": { - "type": "git", - "url": "https://github.com/twigphp/Twig.git", - "reference": "a09d8ee17ac1cfea29ed60c83960ad685c6a898d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/a09d8ee17ac1cfea29ed60c83960ad685c6a898d", - "reference": "a09d8ee17ac1cfea29ed60c83960ad685c6a898d", - "shasum": "" - }, - "require": { - "php": ">=5.2.7" - }, - "require-dev": { - "symfony/debug": "~2.7", - "symfony/phpunit-bridge": "~2.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.26-dev" - } - }, - "autoload": { - "psr-0": { - "Twig_": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { - "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com", - "role": "Project Founder" - }, - { - "name": "Twig Team", - "homepage": "http://twig.sensiolabs.org/contributors", - "role": "Contributors" - } - ], - "description": "Twig, the flexible, fast, and secure template language for PHP", - "homepage": "http://twig.sensiolabs.org", - "keywords": [ - "templating" - ], - "time": "2016-10-05 18:57:41" - } - ], - "packages-dev": [ - { - "name": "asm89/stack-cors", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/asm89/stack-cors.git", - "reference": "3ae8ef219bb4c9a6caf857421719aa07fa7776cc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/asm89/stack-cors/zipball/3ae8ef219bb4c9a6caf857421719aa07fa7776cc", - "reference": "3ae8ef219bb4c9a6caf857421719aa07fa7776cc", - "shasum": "" - }, - "require": { - "php": ">=5.3.2", - "symfony/http-foundation": "~2.1|~3.0", - "symfony/http-kernel": "~2.1|~3.0" - }, - "type": "library", - "autoload": { - "psr-0": { - "Asm89\\Stack": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Alexander", - "email": "iam.asm89@gmail.com" - } - ], - "description": "Cross-origin resource sharing library and stack middleware", - "homepage": "https://github.com/asm89/stack-cors", - "keywords": [ - "cors", - "stack" - ], - "time": "2016-08-01 12:05:04" - }, - { - "name": "composer/semver", - "version": "1.4.2", - "source": { - "type": "git", - "url": "https://github.com/composer/semver.git", - "reference": "c7cb9a2095a074d131b65a8a0cd294479d785573" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/c7cb9a2095a074d131b65a8a0cd294479d785573", - "reference": "c7cb9a2095a074d131b65a8a0cd294479d785573", - "shasum": "" - }, - "require": { - "php": "^5.3.2 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.5 || ^5.0.5", - "phpunit/phpunit-mock-objects": "2.3.0 || ^3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Composer\\Semver\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nils Adermann", - "email": "naderman@naderman.de", - "homepage": "http://www.naderman.de" - }, - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - }, - { - "name": "Rob Bast", - "email": "rob.bast@gmail.com", - "homepage": "http://robbast.nl" - } - ], - "description": "Semver library that offers utilities, version constraint parsing and validation.", - "keywords": [ - "semantic", - "semver", - "validation", - "versioning" - ], - "time": "2016-08-30 16:08:34" - }, - { - "name": "doctrine/cache", - "version": "v1.6.1", - "source": { - "type": "git", - "url": "https://github.com/doctrine/cache.git", - "reference": "b6f544a20f4807e81f7044d31e679ccbb1866dc3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/b6f544a20f4807e81f7044d31e679ccbb1866dc3", - "reference": "b6f544a20f4807e81f7044d31e679ccbb1866dc3", - "shasum": "" - }, - "require": { - "php": "~5.5|~7.0" - }, - "conflict": { - "doctrine/common": ">2.2,<2.4" - }, - "require-dev": { - "phpunit/phpunit": "~4.8|~5.0", - "predis/predis": "~1.0", - "satooshi/php-coveralls": "~0.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.6.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Caching library offering an object-oriented API for many cache backends", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "cache", - "caching" - ], - "time": "2016-10-29 11:16:17" - }, - { - "name": "doctrine/common", - "version": "v2.5.3", - "source": { - "type": "git", - "url": "https://github.com/doctrine/common.git", - "reference": "10f1f19651343f87573129ca970aef1a47a6f29e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/common/zipball/10f1f19651343f87573129ca970aef1a47a6f29e", - "reference": "10f1f19651343f87573129ca970aef1a47a6f29e", - "shasum": "" - }, - "require": { - "doctrine/annotations": "1.*", - "doctrine/cache": "1.*", - "doctrine/collections": "1.*", - "doctrine/inflector": "1.*", - "doctrine/lexer": "1.*", - "php": ">=5.3.2" - }, - "require-dev": { - "phpunit/phpunit": "~3.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.5.x-dev" - } - }, - "autoload": { - "psr-0": { - "Doctrine\\Common\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Common Library for Doctrine projects", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "annotations", - "collections", - "eventmanager", - "persistence", - "spl" - ], - "time": "2015-12-25 13:10:16" - }, - { - "name": "doctrine/inflector", - "version": "v1.1.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/inflector.git", - "reference": "90b2128806bfde671b6952ab8bea493942c1fdae" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/inflector/zipball/90b2128806bfde671b6952ab8bea493942c1fdae", - "reference": "90b2128806bfde671b6952ab8bea493942c1fdae", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "require-dev": { - "phpunit/phpunit": "4.*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, - "autoload": { - "psr-0": { - "Doctrine\\Common\\Inflector\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Common String Manipulations with regard to casing and singular/plural rules.", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "inflection", - "pluralize", - "singularize", - "string" - ], - "time": "2015-11-06 14:35:42" - }, - { - "name": "doctrine/instantiator", - "version": "1.0.5", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", - "shasum": "" - }, - "require": { - "php": ">=5.3,<8.0-DEV" - }, - "require-dev": { - "athletic/athletic": "~0.1.8", - "ext-pdo": "*", - "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", - "keywords": [ - "constructor", - "instantiate" - ], - "time": "2015-06-14 21:17:01" - }, - { - "name": "drupal/core", - "version": "8.2.2", - "source": { - "type": "git", - "url": "https://github.com/drupal-composer/drupal-core.git", - "reference": "399b52eee9e80492ce6928d6784a8399e0da961c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/drupal-composer/drupal-core/zipball/399b52eee9e80492ce6928d6784a8399e0da961c", - "reference": "399b52eee9e80492ce6928d6784a8399e0da961c", - "shasum": "" - }, - "require": { - "asm89/stack-cors": "~1.0", - "composer/semver": "~1.0", - "doctrine/annotations": "1.2.*", - "doctrine/common": "2.5.*", - "easyrdf/easyrdf": "0.9.*", - "egulias/email-validator": "1.2.*", - "guzzlehttp/guzzle": "^6.2.1", - "masterminds/html5": "~2.1", - "paragonie/random_compat": "~1.0", - "php": ">=5.5.9", - "stack/builder": "1.0.*", - "symfony-cmf/routing": "~1.4", - "symfony/class-loader": "~2.8", - "symfony/console": "~2.8", - "symfony/dependency-injection": "~2.8", - "symfony/event-dispatcher": "~2.8", - "symfony/http-foundation": "~2.8", - "symfony/http-kernel": "~2.8", - "symfony/polyfill-iconv": "~1.0", - "symfony/process": "~2.8", - "symfony/psr-http-message-bridge": "v0.2", - "symfony/routing": "~2.8", - "symfony/serializer": "~2.8", - "symfony/translation": "~2.8", - "symfony/validator": "~2.8", - "symfony/yaml": "~2.8", - "twig/twig": "^1.23.1", - "zendframework/zend-diactoros": "~1.1", - "zendframework/zend-feed": "~2.4" - }, - "replace": { - "drupal/action": "self.version", - "drupal/aggregator": "self.version", - "drupal/automated_cron": "self.version", - "drupal/ban": "self.version", - "drupal/bartik": "self.version", - "drupal/basic_auth": "self.version", - "drupal/big_pipe": "self.version", - "drupal/block": "self.version", - "drupal/block_content": "self.version", - "drupal/block_place": "self.version", - "drupal/book": "self.version", - "drupal/breakpoint": "self.version", - "drupal/ckeditor": "self.version", - "drupal/classy": "self.version", - "drupal/color": "self.version", - "drupal/comment": "self.version", - "drupal/config": "self.version", - "drupal/config_translation": "self.version", - "drupal/contact": "self.version", - "drupal/content_moderation": "self.version", - "drupal/content_translation": "self.version", - "drupal/contextual": "self.version", - "drupal/core-annotation": "self.version", - "drupal/core-assertion": "self.version", - "drupal/core-bridge": "self.version", - "drupal/core-datetime": "self.version", - "drupal/core-dependency-injection": "self.version", - "drupal/core-diff": "self.version", - "drupal/core-discovery": "self.version", - "drupal/core-event-dispatcher": "self.version", - "drupal/core-file-cache": "self.version", - "drupal/core-filesystem": "self.version", - "drupal/core-gettext": "self.version", - "drupal/core-graph": "self.version", - "drupal/core-http-foundation": "self.version", - "drupal/core-php-storage": "self.version", - "drupal/core-plugin": "self.version", - "drupal/core-proxy-builder": "self.version", - "drupal/core-render": "self.version", - "drupal/core-serialization": "self.version", - "drupal/core-transliteration": "self.version", - "drupal/core-utility": "self.version", - "drupal/core-uuid": "self.version", - "drupal/datetime": "self.version", - "drupal/datetime_range": "self.version", - "drupal/dblog": "self.version", - "drupal/dynamic_page_cache": "self.version", - "drupal/editor": "self.version", - "drupal/entity_reference": "self.version", - "drupal/field": "self.version", - "drupal/field_ui": "self.version", - "drupal/file": "self.version", - "drupal/filter": "self.version", - "drupal/forum": "self.version", - "drupal/hal": "self.version", - "drupal/help": "self.version", - "drupal/history": "self.version", - "drupal/image": "self.version", - "drupal/inline_form_errors": "self.version", - "drupal/language": "self.version", - "drupal/link": "self.version", - "drupal/locale": "self.version", - "drupal/menu_link_content": "self.version", - "drupal/menu_ui": "self.version", - "drupal/migrate": "self.version", - "drupal/migrate_drupal": "self.version", - "drupal/migrate_drupal_ui": "self.version", - "drupal/minimal": "self.version", - "drupal/node": "self.version", - "drupal/options": "self.version", - "drupal/outside_in": "self.version", - "drupal/page_cache": "self.version", - "drupal/path": "self.version", - "drupal/quickedit": "self.version", - "drupal/rdf": "self.version", - "drupal/responsive_image": "self.version", - "drupal/rest": "self.version", - "drupal/search": "self.version", - "drupal/serialization": "self.version", - "drupal/seven": "self.version", - "drupal/shortcut": "self.version", - "drupal/simpletest": "self.version", - "drupal/standard": "self.version", - "drupal/stark": "self.version", - "drupal/statistics": "self.version", - "drupal/syslog": "self.version", - "drupal/system": "self.version", - "drupal/taxonomy": "self.version", - "drupal/telephone": "self.version", - "drupal/text": "self.version", - "drupal/toolbar": "self.version", - "drupal/tour": "self.version", - "drupal/tracker": "self.version", - "drupal/update": "self.version", - "drupal/user": "self.version", - "drupal/views": "self.version", - "drupal/views_ui": "self.version" - }, - "require-dev": { - "behat/mink": "~1.7", - "behat/mink-goutte-driver": "~1.2", - "jcalderonzumba/gastonjs": "~1.0.2", - "jcalderonzumba/mink-phantomjs-driver": "~0.3.1", - "mikey179/vfsstream": "~1.2", - "phpunit/phpunit": "~4.8", - "symfony/css-selector": "~2.8" - }, - "type": "drupal-core", - "autoload": { - "psr-4": { - "Drupal\\Core\\": "lib/Drupal/Core", - "Drupal\\Component\\": "lib/Drupal/Component", - "Drupal\\Driver\\": "../drivers/lib/Drupal/Driver" - }, - "classmap": [ - "lib/Drupal.php", - "lib/Drupal/Component/Utility/Timer.php", - "lib/Drupal/Component/Utility/Unicode.php", - "lib/Drupal/Core/Database/Database.php", - "lib/Drupal/Core/DrupalKernel.php", - "lib/Drupal/Core/DrupalKernelInterface.php", - "lib/Drupal/Core/Site/Settings.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0+" - ], - "description": "Drupal is an open source content management platform powering millions of websites and applications.", - "time": "2016-11-02 17:43:45" - }, - { - "name": "easyrdf/easyrdf", - "version": "0.9.1", - "source": { - "type": "git", - "url": "https://github.com/njh/easyrdf.git", - "reference": "acd09dfe0555fbcfa254291e433c45fdd4652566" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/njh/easyrdf/zipball/acd09dfe0555fbcfa254291e433c45fdd4652566", - "reference": "acd09dfe0555fbcfa254291e433c45fdd4652566", - "shasum": "" - }, - "require": { - "ext-mbstring": "*", - "ext-pcre": "*", - "php": ">=5.2.8" - }, - "require-dev": { - "phpunit/phpunit": "~3.5", - "sami/sami": "~1.4", - "squizlabs/php_codesniffer": "~1.4.3" - }, - "suggest": { - "ml/json-ld": "~1.0" - }, - "type": "library", - "autoload": { - "psr-0": { - "EasyRdf_": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Nicholas Humfrey", - "email": "njh@aelius.com", - "homepage": "http://www.aelius.com/njh/", - "role": "Developer" - }, - { - "name": "Alexey Zakhlestin", - "email": "indeyets@gmail.com", - "role": "Developer" - } - ], - "description": "EasyRdf is a PHP library designed to make it easy to consume and produce RDF.", - "homepage": "http://www.easyrdf.org/", - "keywords": [ - "Linked Data", - "RDF", - "Semantic Web", - "Turtle", - "rdfa", - "sparql" - ], - "time": "2015-02-27 09:45:49" - }, - { - "name": "egulias/email-validator", - "version": "1.2.13", - "source": { - "type": "git", - "url": "https://github.com/egulias/EmailValidator.git", - "reference": "b8bb147f46cc9790326ce2440a13be06cc5a63bb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/b8bb147f46cc9790326ce2440a13be06cc5a63bb", - "reference": "b8bb147f46cc9790326ce2440a13be06cc5a63bb", - "shasum": "" - }, - "require": { - "doctrine/lexer": "^1.0.1", - "php": ">= 5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.24" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "Egulias\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Eduardo Gulias Davis" - } - ], - "description": "A library for validating emails", - "homepage": "https://github.com/egulias/EmailValidator", - "keywords": [ - "email", - "emailvalidation", - "emailvalidator", - "validation", - "validator" - ], - "time": "2016-07-03 21:52:18" - }, - { - "name": "masterminds/html5", - "version": "2.2.2", - "source": { - "type": "git", - "url": "https://github.com/Masterminds/html5-php.git", - "reference": "7866e93dcf0245de22378414e0c2c7350abc45af" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/7866e93dcf0245de22378414e0c2c7350abc45af", - "reference": "7866e93dcf0245de22378414e0c2c7350abc45af", - "shasum": "" - }, - "require": { - "ext-libxml": "*", - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "4.*", - "sami/sami": "~2.0", - "satooshi/php-coveralls": "1.0.*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2-dev" - } - }, - "autoload": { - "psr-4": { - "Masterminds\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Matt Butcher", - "email": "technosophos@gmail.com" - }, - { - "name": "Asmir Mustafic", - "email": "goetas@gmail.com" - }, - { - "name": "Matt Farina", - "email": "matt@mattfarina.com" - } - ], - "description": "An HTML5 parser and serializer.", - "homepage": "http://masterminds.github.io/html5-php", - "keywords": [ - "HTML5", - "dom", - "html", - "parser", - "querypath", - "serializer", - "xml" - ], - "time": "2016-09-22 11:01:11" - }, - { - "name": "paragonie/random_compat", - "version": "v1.4.1", - "source": { - "type": "git", - "url": "https://github.com/paragonie/random_compat.git", - "reference": "c7e26a21ba357863de030f0b9e701c7d04593774" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/c7e26a21ba357863de030f0b9e701c7d04593774", - "reference": "c7e26a21ba357863de030f0b9e701c7d04593774", - "shasum": "" - }, - "require": { - "php": ">=5.2.0" - }, - "require-dev": { - "phpunit/phpunit": "4.*|5.*" - }, - "suggest": { - "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." - }, - "type": "library", - "autoload": { - "files": [ - "lib/random.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com" - } - ], - "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", - "keywords": [ - "csprng", - "pseudorandom", - "random" - ], - "time": "2016-03-18 20:34:03" - }, - { - "name": "phpdocumentor/reflection-common", - "version": "1.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c", - "shasum": "" - }, - "require": { - "php": ">=5.5" - }, - "require-dev": { - "phpunit/phpunit": "^4.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "time": "2015-12-27 11:43:31" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "3.1.1", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e", - "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e", - "shasum": "" - }, - "require": { - "php": ">=5.5", - "phpdocumentor/reflection-common": "^1.0@dev", - "phpdocumentor/type-resolver": "^0.2.0", - "webmozart/assert": "^1.0" - }, - "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^4.4" - }, - "type": "library", - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2016-09-30 07:12:33" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "0.2", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "b39c7a5b194f9ed7bd0dd345c751007a41862443" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/b39c7a5b194f9ed7bd0dd345c751007a41862443", - "reference": "b39c7a5b194f9ed7bd0dd345c751007a41862443", - "shasum": "" - }, - "require": { - "php": ">=5.5", - "phpdocumentor/reflection-common": "^1.0" - }, - "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^5.2||^4.8.24" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "time": "2016-06-10 07:14:17" - }, - { - "name": "phpspec/prophecy", - "version": "v1.6.1", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "58a8137754bc24b25740d4281399a4a3596058e0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/58a8137754bc24b25740d4281399a4a3596058e0", - "reference": "58a8137754bc24b25740d4281399a4a3596058e0", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2", - "sebastian/comparator": "^1.1", - "sebastian/recursion-context": "^1.0" - }, - "require-dev": { - "phpspec/phpspec": "^2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.6.x-dev" - } - }, - "autoload": { - "psr-0": { - "Prophecy\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "time": "2016-06-07 08:13:47" - }, - { - "name": "phpunit/php-code-coverage", - "version": "2.2.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "~1.3", - "sebastian/environment": "^1.3.2", - "sebastian/version": "~1.0" - }, - "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4" - }, - "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.2.1", - "ext-xmlwriter": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "time": "2015-10-06 15:47:00" - }, - { - "name": "phpunit/php-file-iterator", - "version": "1.4.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "time": "2015-06-21 13:08:43" - }, - { - "name": "phpunit/php-text-template", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "time": "2015-06-21 13:50:34" - }, - { - "name": "phpunit/php-timer", - "version": "1.0.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/38e9124049cf1a164f1e4537caf19c99bf1eb260", - "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4|~5" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "time": "2016-05-12 18:03:57" - }, - { - "name": "phpunit/php-token-stream", - "version": "1.4.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", - "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "time": "2015-09-15 10:49:45" - }, - { - "name": "phpunit/phpunit", - "version": "4.8.27", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "c062dddcb68e44b563f66ee319ddae2b5a322a90" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c062dddcb68e44b563f66ee319ddae2b5a322a90", - "reference": "c062dddcb68e44b563f66ee319ddae2b5a322a90", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "php": ">=5.3.3", - "phpspec/prophecy": "^1.3.1", - "phpunit/php-code-coverage": "~2.1", - "phpunit/php-file-iterator": "~1.4", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "~2.3", - "sebastian/comparator": "~1.1", - "sebastian/diff": "~1.2", - "sebastian/environment": "~1.3", - "sebastian/exporter": "~1.2", - "sebastian/global-state": "~1.0", - "sebastian/version": "~1.0", - "symfony/yaml": "~2.1|~3.0" - }, - "suggest": { - "phpunit/php-invoker": "~1.1" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.8.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "time": "2016-07-21 06:48:14" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "2.3.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": ">=5.3.3", - "phpunit/php-text-template": "~1.2", - "sebastian/exporter": "~1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "time": "2015-10-02 06:51:40" - }, - { - "name": "sebastian/comparator", - "version": "1.2.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "937efb279bd37a375bcadf584dec0726f84dbf22" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22", - "reference": "937efb279bd37a375bcadf584dec0726f84dbf22", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "time": "2015-07-26 15:48:44" - }, - { - "name": "sebastian/diff", - "version": "1.4.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e", - "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff" - ], - "time": "2015-12-08 07:14:41" - }, - { - "name": "sebastian/environment", - "version": "1.3.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/be2c607e43ce4c89ecd60e75c6a85c126e754aea", - "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea", - "shasum": "" - }, - "require": { - "php": "^5.3.3 || ^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "time": "2016-08-18 05:49:44" - }, - { - "name": "sebastian/exporter", - "version": "1.2.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/42c4c2eec485ee3e159ec9884f95b431287edde4", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~1.0" - }, - "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "time": "2016-06-17 09:04:28" - }, - { - "name": "sebastian/global-state", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "time": "2015-10-12 03:26:01" - }, - { - "name": "sebastian/recursion-context", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "913401df809e99e4f47b27cdd781f4a258d58791" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/913401df809e99e4f47b27cdd781f4a258d58791", - "reference": "913401df809e99e4f47b27cdd781f4a258d58791", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2015-11-11 19:50:13" - }, - { - "name": "sebastian/version", - "version": "1.0.6", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "shasum": "" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "time": "2015-06-21 13:59:46" - }, - { - "name": "stack/builder", - "version": "v1.0.4", - "source": { - "type": "git", - "url": "https://github.com/stackphp/builder.git", - "reference": "59fcc9b448a8ce5e338a04c4e2e4aca893e83425" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/stackphp/builder/zipball/59fcc9b448a8ce5e338a04c4e2e4aca893e83425", - "reference": "59fcc9b448a8ce5e338a04c4e2e4aca893e83425", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "symfony/http-foundation": "~2.1|~3.0", - "symfony/http-kernel": "~2.1|~3.0" - }, - "require-dev": { - "silex/silex": "~1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-0": { - "Stack": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Igor Wiedler", - "email": "igor@wiedler.ch" - } - ], - "description": "Builder for stack middlewares based on HttpKernelInterface.", - "keywords": [ - "stack" - ], - "time": "2016-06-02 06:58:42" - }, - { - "name": "symfony-cmf/routing", - "version": "1.4.0", - "source": { - "type": "git", - "url": "https://github.com/symfony-cmf/Routing.git", - "reference": "b93704ca098334f56e9b317932f21a4362e620db" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony-cmf/Routing/zipball/b93704ca098334f56e9b317932f21a4362e620db", - "reference": "b93704ca098334f56e9b317932f21a4362e620db", - "shasum": "" - }, - "require": { - "php": "^5.3.9|^7.0", - "psr/log": "1.*", - "symfony/http-kernel": "^2.2|3.*", - "symfony/routing": "^2.2|3.*" - }, - "require-dev": { - "friendsofsymfony/jsrouting-bundle": "^1.1", - "symfony-cmf/testing": "^1.3", - "symfony/config": "^2.2|3.*", - "symfony/dependency-injection": "^2.0.5|3.*", - "symfony/event-dispatcher": "^2.1|3.*" - }, - "suggest": { - "symfony/event-dispatcher": "DynamicRouter can optionally trigger an event at the start of matching. Minimal version (~2.1)" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Cmf\\Component\\Routing\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony CMF Community", - "homepage": "https://github.com/symfony-cmf/Routing/contributors" - } - ], - "description": "Extends the Symfony2 routing component for dynamic routes and chaining several routers", - "homepage": "http://cmf.symfony.com", - "keywords": [ - "database", - "routing" - ], - "time": "2016-03-31 09:11:39" - }, - { - "name": "symfony/class-loader", - "version": "v2.8.13", - "source": { - "type": "git", - "url": "https://github.com/symfony/class-loader.git", - "reference": "fb50892408036f9f431b563aac51a3f2f0087e81" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/class-loader/zipball/fb50892408036f9f431b563aac51a3f2f0087e81", - "reference": "fb50892408036f9f431b563aac51a3f2f0087e81", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "symfony/polyfill-apcu": "~1.1" - }, - "require-dev": { - "symfony/finder": "~2.0,>=2.0.5|~3.0.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\ClassLoader\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony ClassLoader Component", - "homepage": "https://symfony.com", - "time": "2016-09-06 23:19:39" - }, - { - "name": "symfony/http-kernel", - "version": "v2.8.12", - "source": { - "type": "git", - "url": "https://github.com/symfony/http-kernel.git", - "reference": "0e39ed020c6a4bfb888974414fbfe2779637a487" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/0e39ed020c6a4bfb888974414fbfe2779637a487", - "reference": "0e39ed020c6a4bfb888974414fbfe2779637a487", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "psr/log": "~1.0", - "symfony/debug": "~2.6,>=2.6.2", - "symfony/event-dispatcher": "~2.6,>=2.6.7|~3.0.0", - "symfony/http-foundation": "~2.7.15|~2.8.8|~3.0.8" - }, - "conflict": { - "symfony/config": "<2.7" - }, - "require-dev": { - "symfony/browser-kit": "~2.3|~3.0.0", - "symfony/class-loader": "~2.1|~3.0.0", - "symfony/config": "~2.8", - "symfony/console": "~2.3|~3.0.0", - "symfony/css-selector": "~2.0,>=2.0.5|~3.0.0", - "symfony/dependency-injection": "~2.8|~3.0.0", - "symfony/dom-crawler": "~2.0,>=2.0.5|~3.0.0", - "symfony/expression-language": "~2.4|~3.0.0", - "symfony/finder": "~2.0,>=2.0.5|~3.0.0", - "symfony/process": "~2.0,>=2.0.5|~3.0.0", - "symfony/routing": "~2.8|~3.0.0", - "symfony/stopwatch": "~2.3|~3.0.0", - "symfony/templating": "~2.2|~3.0.0", - "symfony/translation": "~2.0,>=2.0.5|~3.0.0", - "symfony/var-dumper": "~2.6|~3.0.0" - }, - "suggest": { - "symfony/browser-kit": "", - "symfony/class-loader": "", - "symfony/config": "", - "symfony/console": "", - "symfony/dependency-injection": "", - "symfony/finder": "", - "symfony/var-dumper": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\HttpKernel\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony HttpKernel Component", - "homepage": "https://symfony.com", - "time": "2016-10-03 18:44:05" - }, - { - "name": "symfony/polyfill-apcu", - "version": "v1.2.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-apcu.git", - "reference": "6d58bceaeea2c2d3eb62503839b18646e161cd6b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-apcu/zipball/6d58bceaeea2c2d3eb62503839b18646e161cd6b", - "reference": "6d58bceaeea2c2d3eb62503839b18646e161cd6b", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2-dev" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting apcu_* functions to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "apcu", - "compatibility", - "polyfill", - "portable", - "shim" - ], - "time": "2016-05-18 14:26:46" - }, - { - "name": "symfony/polyfill-iconv", - "version": "v1.2.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-iconv.git", - "reference": "b287e8554b1ffd9b5b20b5df940d906930ff4a10" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/b287e8554b1ffd9b5b20b5df940d906930ff4a10", - "reference": "b287e8554b1ffd9b5b20b5df940d906930ff4a10", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-iconv": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Iconv\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Iconv extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "iconv", - "polyfill", - "portable", - "shim" - ], - "time": "2016-05-18 14:26:46" - }, - { - "name": "symfony/psr-http-message-bridge", - "version": "v0.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/psr-http-message-bridge.git", - "reference": "dc7e308e1dc2898a46776e2221a643cb08315453" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/dc7e308e1dc2898a46776e2221a643cb08315453", - "reference": "dc7e308e1dc2898a46776e2221a643cb08315453", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "psr/http-message": "~1.0", - "symfony/http-foundation": "~2.3|~3.0" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7|~3.0" - }, - "suggest": { - "zendframework/zend-diactoros": "To use the Zend Diactoros factory" - }, - "type": "symfony-bridge", - "autoload": { - "psr-4": { - "Symfony\\Bridge\\PsrHttpMessage\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "PSR HTTP message bridge", - "homepage": "http://symfony.com", - "keywords": [ - "http", - "http-message", - "psr-7" - ], - "time": "2015-05-29 17:57:12" - }, - { - "name": "symfony/routing", - "version": "v2.8.13", - "source": { - "type": "git", - "url": "https://github.com/symfony/routing.git", - "reference": "6cee3ed22c778a7410119a3d51a20f60252a156c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/6cee3ed22c778a7410119a3d51a20f60252a156c", - "reference": "6cee3ed22c778a7410119a3d51a20f60252a156c", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "conflict": { - "symfony/config": "<2.7" - }, - "require-dev": { - "doctrine/annotations": "~1.0", - "doctrine/common": "~2.2", - "psr/log": "~1.0", - "symfony/config": "~2.7|~3.0.0", - "symfony/expression-language": "~2.4|~3.0.0", - "symfony/http-foundation": "~2.3|~3.0.0", - "symfony/yaml": "~2.0,>=2.0.5|~3.0.0" - }, - "suggest": { - "doctrine/annotations": "For using the annotation loader", - "symfony/config": "For using the all-in-one router or any loader", - "symfony/dependency-injection": "For loading routes from a service", - "symfony/expression-language": "For using expression matching", - "symfony/http-foundation": "For using a Symfony Request object", - "symfony/yaml": "For using the YAML loader" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Routing\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Routing Component", - "homepage": "https://symfony.com", - "keywords": [ - "router", - "routing", - "uri", - "url" - ], - "time": "2016-08-16 14:56:08" - }, - { - "name": "symfony/serializer", - "version": "v2.8.13", - "source": { - "type": "git", - "url": "https://github.com/symfony/serializer.git", - "reference": "fad6992cd308b6c2484186fd980b221ebcb0ed37" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/serializer/zipball/fad6992cd308b6c2484186fd980b221ebcb0ed37", - "reference": "fad6992cd308b6c2484186fd980b221ebcb0ed37", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "symfony/polyfill-php55": "~1.0" - }, - "require-dev": { - "doctrine/annotations": "~1.0", - "doctrine/cache": "~1.0", - "symfony/config": "~2.2|~3.0.0", - "symfony/property-access": "~2.3|~3.0.0", - "symfony/yaml": "~2.0,>=2.0.5|~3.0.0" - }, - "suggest": { - "doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.", - "doctrine/cache": "For using the default cached annotation reader and metadata cache.", - "symfony/config": "For using the XML mapping loader.", - "symfony/property-access": "For using the ObjectNormalizer.", - "symfony/yaml": "For using the default YAML mapping loader." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Serializer\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Serializer Component", - "homepage": "https://symfony.com", - "time": "2016-09-24 09:47:20" - }, - { - "name": "symfony/validator", - "version": "v2.8.13", - "source": { - "type": "git", - "url": "https://github.com/symfony/validator.git", - "reference": "987bf3a7d585680773bc79f6cf3d9e78340cb02c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/validator/zipball/987bf3a7d585680773bc79f6cf3d9e78340cb02c", - "reference": "987bf3a7d585680773bc79f6cf3d9e78340cb02c", - "shasum": "" - }, - "require": { - "php": ">=5.3.9", - "symfony/polyfill-mbstring": "~1.0", - "symfony/translation": "~2.4|~3.0.0" - }, - "require-dev": { - "doctrine/annotations": "~1.0", - "doctrine/cache": "~1.0", - "egulias/email-validator": "~1.2,>=1.2.1", - "symfony/config": "~2.2|~3.0.0", - "symfony/expression-language": "~2.4|~3.0.0", - "symfony/http-foundation": "~2.3|~3.0.0", - "symfony/intl": "~2.7.4|~2.8|~3.0.0", - "symfony/property-access": "~2.3|~3.0.0", - "symfony/yaml": "~2.0,>=2.0.5|~3.0.0" - }, - "suggest": { - "doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.", - "doctrine/cache": "For using the default cached annotation reader and metadata cache.", - "egulias/email-validator": "Strict (RFC compliant) email validation", - "symfony/config": "", - "symfony/expression-language": "For using the 2.4 Expression validator", - "symfony/http-foundation": "", - "symfony/intl": "", - "symfony/property-access": "For using the 2.4 Validator API", - "symfony/yaml": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Validator\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Validator Component", - "homepage": "https://symfony.com", - "time": "2016-10-19 22:37:24" - }, - { - "name": "webmozart/assert", - "version": "1.1.0", - "source": { - "type": "git", - "url": "https://github.com/webmozart/assert.git", - "reference": "bb2d123231c095735130cc8f6d31385a44c7b308" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/bb2d123231c095735130cc8f6d31385a44c7b308", - "reference": "bb2d123231c095735130cc8f6d31385a44c7b308", - "shasum": "" - }, - "require": { - "php": "^5.3.3|^7.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.6", - "sebastian/version": "^1.0.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2-dev" - } - }, - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "time": "2016-08-09 15:02:57" - }, - { - "name": "zendframework/zend-diactoros", - "version": "1.3.7", - "source": { - "type": "git", - "url": "https://github.com/zendframework/zend-diactoros.git", - "reference": "969ff423d3f201da3ff718a5831bb999bb0669b0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/969ff423d3f201da3ff718a5831bb999bb0669b0", - "reference": "969ff423d3f201da3ff718a5831bb999bb0669b0", - "shasum": "" - }, - "require": { - "php": "^5.4 || ^7.0", - "psr/http-message": "~1.0" - }, - "provide": { - "psr/http-message-implementation": "~1.0.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.6 || ^5.5", - "squizlabs/php_codesniffer": "^2.3.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev", - "dev-develop": "1.4-dev" - } - }, - "autoload": { - "psr-4": { - "Zend\\Diactoros\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-2-Clause" - ], - "description": "PSR HTTP Message implementations", - "homepage": "https://github.com/zendframework/zend-diactoros", - "keywords": [ - "http", - "psr", - "psr-7" - ], - "time": "2016-10-11 13:25:21" - }, - { - "name": "zendframework/zend-escaper", - "version": "2.5.2", - "source": { - "type": "git", - "url": "https://github.com/zendframework/zend-escaper.git", - "reference": "2dcd14b61a72d8b8e27d579c6344e12c26141d4e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-escaper/zipball/2dcd14b61a72d8b8e27d579c6344e12c26141d4e", - "reference": "2dcd14b61a72d8b8e27d579c6344e12c26141d4e", - "shasum": "" - }, - "require": { - "php": ">=5.5" - }, - "require-dev": { - "fabpot/php-cs-fixer": "1.7.*", - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.5-dev", - "dev-develop": "2.6-dev" - } - }, - "autoload": { - "psr-4": { - "Zend\\Escaper\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "homepage": "https://github.com/zendframework/zend-escaper", - "keywords": [ - "escaper", - "zf2" - ], - "time": "2016-06-30 19:48:38" - }, - { - "name": "zendframework/zend-feed", - "version": "2.7.0", - "source": { - "type": "git", - "url": "https://github.com/zendframework/zend-feed.git", - "reference": "12b328d382aa5200f1de53d4147033b885776b67" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-feed/zipball/12b328d382aa5200f1de53d4147033b885776b67", - "reference": "12b328d382aa5200f1de53d4147033b885776b67", - "shasum": "" - }, - "require": { - "php": "^5.5 || ^7.0", - "zendframework/zend-escaper": "^2.5", - "zendframework/zend-stdlib": "^2.7 || ^3.0" - }, - "require-dev": { - "fabpot/php-cs-fixer": "1.7.*", - "phpunit/phpunit": "~4.0", - "psr/http-message": "^1.0", - "zendframework/zend-cache": "^2.5", - "zendframework/zend-db": "^2.5", - "zendframework/zend-http": "^2.5", - "zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3", - "zendframework/zend-validator": "^2.5" - }, - "suggest": { - "psr/http-message": "PSR-7 ^1.0, if you wish to use Zend\\Feed\\Reader\\Http\\Psr7ResponseDecorator", - "zendframework/zend-cache": "Zend\\Cache component, for optionally caching feeds between requests", - "zendframework/zend-db": "Zend\\Db component, for use with PubSubHubbub", - "zendframework/zend-http": "Zend\\Http for PubSubHubbub, and optionally for use with Zend\\Feed\\Reader", - "zendframework/zend-servicemanager": "Zend\\ServiceManager component, for easily extending ExtensionManager implementations", - "zendframework/zend-validator": "Zend\\Validator component, for validating email addresses used in Atom feeds and entries ehen using the Writer subcomponent" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.7-dev", - "dev-develop": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Zend\\Feed\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "description": "provides functionality for consuming RSS and Atom feeds", - "homepage": "https://github.com/zendframework/zend-feed", - "keywords": [ - "feed", - "zf2" - ], - "time": "2016-02-11 18:54:29" - }, - { - "name": "zendframework/zend-stdlib", - "version": "3.1.0", - "source": { - "type": "git", - "url": "https://github.com/zendframework/zend-stdlib.git", - "reference": "debedcfc373a293f9250cc9aa03cf121428c8e78" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-stdlib/zipball/debedcfc373a293f9250cc9aa03cf121428c8e78", - "reference": "debedcfc373a293f9250cc9aa03cf121428c8e78", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0" - }, - "require-dev": { - "athletic/athletic": "~0.1", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "^2.6.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.1-dev", - "dev-develop": "3.2-dev" - } - }, - "autoload": { - "psr-4": { - "Zend\\Stdlib\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "homepage": "https://github.com/zendframework/zend-stdlib", - "keywords": [ - "stdlib", - "zf2" - ], - "time": "2016-09-13 14:38:50" - } - ], - "aliases": [], - "minimum-stability": "dev", - "stability-flags": [], - "prefer-stable": true, - "prefer-lowest": false, - "platform": { - "php": "^5.5.9 || ^7.0" - }, - "platform-dev": [] -} diff --git a/config.yml b/config.yml index 0db654316..84bc95aa0 100644 --- a/config.yml +++ b/config.yml @@ -2,8 +2,4 @@ application: autowire: commands: forced: {} - name: - 'develop:example': - class: '\Drupal\Console\Command\Develop\ExampleCommand' - 'develop:example:container:aware': - class: '\Drupal\Console\Command\Develop\ExampleContainerAwareCommand' + name: {} diff --git a/config/services/drupal-console/cache.yml b/config/services/cache.yml similarity index 66% rename from config/services/drupal-console/cache.yml rename to config/services/cache.yml index 1f4df9099..b45064079 100644 --- a/config/services/drupal-console/cache.yml +++ b/config/services/cache.yml @@ -1,10 +1,11 @@ services: - console.cache_context_debug: - class: Drupal\Console\Command\Cache\ContextDebugCommand - tags: - - { name: drupal.command } console.cache_rebuild: class: Drupal\Console\Command\Cache\RebuildCommand arguments: ['@console.drupal_api', '@console.site', '@class_loader', '@request_stack'] tags: - { name: drupal.command } + console.cache_tag_invalidate: + class: Drupal\Console\Command\Cache\TagInvalidateCommand + arguments: ['@cache_tags.invalidator'] + tags: + - { name: drupal.command } diff --git a/config/services/drupal-console/config.yml b/config/services/config.yml similarity index 80% rename from config/services/drupal-console/config.yml rename to config/services/config.yml index 469d1ef3f..422aa2715 100644 --- a/config/services/drupal-console/config.yml +++ b/config/services/config.yml @@ -1,9 +1,4 @@ services: - console.config_debug: - class: Drupal\Console\Command\Config\DebugCommand - arguments: ['@config.factory', '@config.storage'] - tags: - - { name: drupal.command } console.config_delete: class: Drupal\Console\Command\Config\DeleteCommand arguments: ['@config.factory', '@config.storage', '@config.storage.sync'] @@ -21,17 +16,17 @@ services: - { name: drupal.command } console.config_export: class: Drupal\Console\Command\Config\ExportCommand - arguments: ['@config.manager'] + arguments: ['@config.manager', '@config.storage'] tags: - { name: drupal.command } console.config_export_content_type: class: Drupal\Console\Command\Config\ExportContentTypeCommand - arguments: ['@entity_type.manager', '@config.storage'] + arguments: ['@entity_type.manager', '@config.storage', '@console.extension_manager'] tags: - { name: drupal.command } console.config_export_single: class: Drupal\Console\Command\Config\ExportSingleCommand - arguments: ['@entity_type.manager', '@config.storage'] + arguments: ['@entity_type.manager', '@config.storage', '@console.extension_manager'] tags: - { name: drupal.command } console.config_export_view: @@ -54,8 +49,7 @@ services: arguments: ['@config.storage', '@config.factory'] tags: - { name: drupal.command } - console.config_settings_debug: - class: Drupal\Console\Command\Config\SettingsDebugCommand - arguments: ['@settings'] + console.config_validate: + class: Drupal\Console\Command\Config\ValidateCommand tags: - { name: drupal.command } diff --git a/config/services/drupal-console/create.yml b/config/services/create.yml similarity index 100% rename from config/services/drupal-console/create.yml rename to config/services/create.yml diff --git a/config/services/drupal-console/cron.yml b/config/services/cron.yml similarity index 71% rename from config/services/drupal-console/cron.yml rename to config/services/cron.yml index 981e551f3..bbd8536d9 100644 --- a/config/services/drupal-console/cron.yml +++ b/config/services/cron.yml @@ -1,9 +1,4 @@ services: - console.cron_debug: - class: Drupal\Console\Command\Cron\DebugCommand - arguments: ['@module_handler'] - tags: - - { name: drupal.command } console.cron_execute: class: Drupal\Console\Command\Cron\ExecuteCommand arguments: ['@module_handler', '@lock', '@state', '@console.chain_queue'] diff --git a/config/services/drupal-console/database.yml b/config/services/database.yml similarity index 76% rename from config/services/drupal-console/database.yml rename to config/services/database.yml index ffeb73e6e..902995f57 100644 --- a/config/services/drupal-console/database.yml +++ b/config/services/database.yml @@ -1,8 +1,17 @@ services: + console.database_add: + class: Drupal\Console\Command\Database\AddCommand + arguments: ['@console.database_settings_generator'] + tags: + - { name: drupal.command } console.database_client: class: Drupal\Console\Command\Database\ClientCommand tags: - { name: drupal.command } + console.database_query: + class: Drupal\Console\Command\Database\QueryCommand + tags: + - { name: drupal.command } console.database_connect: class: Drupal\Console\Command\Database\ConnectCommand tags: @@ -22,8 +31,8 @@ services: arguments: ['@database'] tags: - { name: drupal.command } - console.database_log_debug: - class: Drupal\Console\Command\Database\LogDebugCommand + console.database_log_poll: + class: Drupal\Console\Command\Database\LogPollCommand arguments: ['@database', '@date.formatter', '@entity_type.manager', '@string_translation'] tags: - { name: drupal.command } @@ -32,8 +41,3 @@ services: arguments: ['@app.root'] tags: - { name: drupal.command } - console.database_table_debug: - class: Drupal\Console\Command\Database\TableDebugCommand - arguments: ['@console.redbean', '@database'] - tags: - - { name: drupal.command } diff --git a/config/services/debug.yml b/config/services/debug.yml new file mode 100644 index 000000000..c4dc39559 --- /dev/null +++ b/config/services/debug.yml @@ -0,0 +1,139 @@ +services: + console.container_debug: + class: Drupal\Console\Command\Debug\ContainerCommand + tags: + - { name: drupal.command } + console.event_debug: + class: Drupal\Console\Command\Debug\EventCommand + arguments: ['@event_dispatcher'] + tags: + - { name: drupal.command } + console.permission_debug: + class: Drupal\Console\Command\Debug\PermissionCommand + tags: + - { name: drupal.command } + console.plugin_debug: + class: Drupal\Console\Command\Debug\PluginCommand + tags: + - { name: drupal.command } + console.update_debug: + class: Drupal\Console\Command\Debug\UpdateCommand + arguments: ['@console.site', '@update.post_update_registry'] + tags: + - { name: drupal.command } + console.user_debug: + class: Drupal\Console\Command\Debug\UserCommand + arguments: ['@entity_type.manager','@entity.query', '@console.drupal_api'] + tags: + - { name: drupal.command } + console.views_debug: + class: Drupal\Console\Command\Debug\ViewsCommand + arguments: ['@entity_type.manager'] + tags: + - { name: drupal.command } + console.views_plugins_debug: + class: Drupal\Console\Command\Debug\ViewsPluginsCommand + tags: + - { name: drupal.command } + console.state_debug: + class: Drupal\Console\Command\Debug\StateCommand + arguments: ['@state', '@keyvalue'] + tags: + - { name: drupal.command } + console.theme_debug: + class: Drupal\Console\Command\Debug\ThemeCommand + arguments: ['@config.factory', '@theme_handler'] + tags: + - { name: drupal.command } + console.router_debug: + class: Drupal\Console\Command\Debug\RouterCommand + arguments: ['@router.route_provider'] + tags: + - { name: drupal.command } + console.queue_debug: + class: Drupal\Console\Command\Debug\QueueCommand + arguments: ['@plugin.manager.queue_worker'] + tags: + - { name: drupal.command } + console.libraries_debug: + class: Drupal\Console\Command\Debug\LibrariesCommand + arguments: ['@module_handler', '@theme_handler', '@library.discovery', '@app.root'] + tags: + - { name: drupal.command } + console.module_debug: + class: Drupal\Console\Command\Debug\ModuleCommand + arguments: ['@console.configuration_manager', '@console.site', '@http_client'] + tags: + - { name: drupal.command } + console.image_styles_debug: + class: Drupal\Console\Command\Debug\ImageStylesCommand + arguments: ['@entity_type.manager'] + tags: + - { name: drupal.command } + console.entity_debug: + class: Drupal\Console\Command\Debug\EntityCommand + arguments: ['@entity_type.repository', '@entity_type.manager'] + tags: + - { name: drupal.command } + console.database_log_debug: + class: Drupal\Console\Command\Debug\DatabaseLogCommand + arguments: ['@database', '@date.formatter', '@entity_type.manager', '@string_translation'] + tags: + - { name: drupal.command } + console.database_table_debug: + class: Drupal\Console\Command\Debug\DatabaseTableCommand + arguments: ['@console.redbean', '@database'] + tags: + - { name: drupal.command } + console.cron_debug: + class: Drupal\Console\Command\Debug\CronCommand + arguments: ['@module_handler'] + tags: + - { name: drupal.command } + console.breakpoints_debug: + class: Drupal\Console\Command\Debug\BreakpointsCommand + arguments: ['@?breakpoint.manager', '@app.root'] + tags: + - { name: drupal.command } + console.cache_context_debug: + class: Drupal\Console\Command\Debug\CacheContextCommand + tags: + - { name: drupal.command } + console.config_debug: + class: Drupal\Console\Command\Debug\ConfigCommand + arguments: ['@config.factory', '@config.storage'] + tags: + - { name: drupal.command } + console.config_settings_debug: + class: Drupal\Console\Command\Debug\ConfigSettingsCommand + arguments: ['@settings'] + tags: + - { name: drupal.command } + console.config_validate_debug: + class: Drupal\Console\Command\Debug\ConfigValidateCommand + tags: + - { name: drupal.command } + console.multisite_debug: + class: Drupal\Console\Command\Debug\MultisiteCommand + arguments: ['@app.root'] + tags: + - { name: drupal.command } + console.migrate_debug: + class: Drupal\Console\Command\Debug\MigrateCommand + arguments: ['@?plugin.manager.migration'] + tags: + - { name: drupal.command } + console.rest_debug: + class: Drupal\Console\Command\Debug\RestCommand + arguments: ['@?plugin.manager.rest'] + tags: + - { name: drupal.command } + console.test_debug: + class: Drupal\Console\Command\Debug\TestCommand + arguments: ['@?test_discovery'] + tags: + - { name: drupal.command } + console.feature_debug: + class: Drupal\Console\Command\Debug\FeaturesCommand + tags: + - { name: drupal.command } diff --git a/config/services/drupal-console/chain.yml b/config/services/drupal-console/chain.yml deleted file mode 100644 index ea5d08b24..000000000 --- a/config/services/drupal-console/chain.yml +++ /dev/null @@ -1,11 +0,0 @@ -services: - console.chain: - class: Drupal\Console\Command\Chain\ChainCommand - arguments: ['@console.chain_queue', '@console.configuration_manager', '@app.root', '@console.extension_manager'] - tags: - - { name: drupal.command } - console.chain_debug: - class: Drupal\Console\Command\Chain\ChainDebugCommand - arguments: ['@console.configuration_manager', '@console.extension_manager'] - tags: - - { name: drupal.command } diff --git a/config/services/drupal-console/develop.yml b/config/services/drupal-console/develop.yml deleted file mode 100644 index 3076e547c..000000000 --- a/config/services/drupal-console/develop.yml +++ /dev/null @@ -1,39 +0,0 @@ -services: - console.generate_doc_cheatsheet: - class: Drupal\Console\Command\Develop\GenerateDocCheatsheetCommand - tags: - - { name: drupal.command } - console.generate_doc_dash: - class: Drupal\Console\Command\Develop\GenerateDocDashCommand - arguments: ['@console.renderer', '@console.root'] - tags: - - { name: drupal.command } - console.generate_doc_data: - class: Drupal\Console\Command\Develop\GenerateDocDataCommand - tags: - - { name: drupal.command } - console.generate_doc_gitbook: - class: Drupal\Console\Command\Develop\GenerateDocGitbookCommand - arguments: ['@console.renderer'] - tags: - - { name: drupal.command } - console.translation_cleanup: - class: Drupal\Console\Command\Develop\TranslationCleanupCommand - arguments: ['@console.root', '@console.configuration_manager'] - tags: - - { name: drupal.command } - console.translation_pending: - class: Drupal\Console\Command\Develop\TranslationPendingCommand - arguments: ['@console.root', '@console.configuration_manager', '@console.nested_array'] - tags: - - { name: drupal.command } - console.translation_stats: - class: Drupal\Console\Command\Develop\TranslationStatsCommand - arguments: ['@console.root', '@console.configuration_manager', '@console.renderer', '@console.nested_array'] - tags: - - { name: drupal.command } - console.translation_sync: - class: Drupal\Console\Command\Develop\TranslationSyncCommand - arguments: ['@console.root', '@console.configuration_manager'] - tags: - - { name: drupal.command } diff --git a/config/services/drupal-console/libraries.yml b/config/services/drupal-console/libraries.yml deleted file mode 100644 index 65bb723f7..000000000 --- a/config/services/drupal-console/libraries.yml +++ /dev/null @@ -1,6 +0,0 @@ -services: - console.libraries_debug: - class: Drupal\Console\Command\Libraries\DebugCommand - arguments: ['@module_handler', '@theme_handler', '@library.discovery', '@app.root'] - tags: - - { name: drupal.command } diff --git a/config/services/drupal-console/misc.yml b/config/services/drupal-console/misc.yml deleted file mode 100644 index ebc903e73..000000000 --- a/config/services/drupal-console/misc.yml +++ /dev/null @@ -1,19 +0,0 @@ -services: - console.container_debug: - class: Drupal\Console\Command\ContainerDebugCommand - tags: - - { name: drupal.command } - console.plugin_debug: - class: Drupal\Console\Command\PluginDebugCommand - tags: - - { name: drupal.command } - console.event_debug: - class: Drupal\Console\Command\EventDebugCommand - arguments: ['@event_dispatcher'] - tags: - - { name: drupal.command } -# console.devel_dumper: -# class: Drupal\Console\Command\DumperCommand -# arguments: ['@app.root'] -# tags: -# - { name: drupal.command } diff --git a/config/services/drupal-console/multisite.yml b/config/services/drupal-console/multisite.yml deleted file mode 100644 index 314d7a2db..000000000 --- a/config/services/drupal-console/multisite.yml +++ /dev/null @@ -1,11 +0,0 @@ -services: - console.multisite_debug: - class: Drupal\Console\Command\Multisite\DebugCommand - arguments: ['@app.root'] - tags: - - { name: drupal.command } - console.multisite_new: - class: Drupal\Console\Command\Multisite\NewCommand - arguments: ['@app.root'] - tags: - - { name: drupal.command } diff --git a/config/services/drupal-console/yaml.yml b/config/services/drupal-console/yaml.yml deleted file mode 100644 index 0e0c60944..000000000 --- a/config/services/drupal-console/yaml.yml +++ /dev/null @@ -1,35 +0,0 @@ -services: - console.yaml_diff: - class: Drupal\Console\Command\Yaml\DiffCommand - arguments: ['@console.nested_array'] - tags: - - { name: drupal.command } - console.yaml_get_value: - class: Drupal\Console\Command\Yaml\GetValueCommand - arguments: ['@console.nested_array'] - tags: - - { name: drupal.command } - console.yaml_merge: - class: Drupal\Console\Command\Yaml\MergeCommand - tags: - - { name: drupal.command } - console.yaml_split: - class: Drupal\Console\Command\Yaml\SplitCommand - arguments: ['@console.nested_array'] - tags: - - { name: drupal.command } - console.yaml_update_key: - class: Drupal\Console\Command\Yaml\UpdateKeyCommand - arguments: ['@console.nested_array'] - tags: - - { name: drupal.command } - console.yaml_update_value: - class: Drupal\Console\Command\Yaml\UpdateValueCommand - arguments: ['@console.nested_array'] - tags: - - { name: drupal.command } - console.yaml_unset_key: - class: Drupal\Console\Command\Yaml\UnsetKeyCommand - arguments: ['@console.nested_array'] - tags: - - { name: drupal.command } diff --git a/config/services/drupal-core/breakpoint.yml b/config/services/drupal-core/breakpoint.yml deleted file mode 100644 index 609e495d5..000000000 --- a/config/services/drupal-core/breakpoint.yml +++ /dev/null @@ -1,6 +0,0 @@ -services: - console.breakpoints_debug: - class: Drupal\Console\Command\Breakpoints\DebugCommand - arguments: ['@breakpoint.manager', '@app.root'] - tags: - - { name: drupal.command } diff --git a/config/services/drupal-core/migrate.yml b/config/services/drupal-core/migrate.yml deleted file mode 100644 index 17fb889bb..000000000 --- a/config/services/drupal-core/migrate.yml +++ /dev/null @@ -1,16 +0,0 @@ -services: - migrate_execute: - class: Drupal\Console\Command\Migrate\ExecuteCommand - arguments: ['@plugin.manager.migration'] - tags: - - { name: drupal.command } - migrate_debug: - class: Drupal\Console\Command\Migrate\DebugCommand - arguments: ['@plugin.manager.migration'] - tags: - - { name: drupal.command } - migrate_setup: - class: Drupal\Console\Command\Migrate\SetupCommand - arguments: ['@state', '@plugin.manager.migration'] - tags: - - { name: drupal.command } diff --git a/config/services/drupal-core/rest.yml b/config/services/drupal-core/rest.yml deleted file mode 100644 index 37667c040..000000000 --- a/config/services/drupal-core/rest.yml +++ /dev/null @@ -1,16 +0,0 @@ -services: - rest_debug: - class: Drupal\Console\Command\Rest\DebugCommand - arguments: ['@plugin.manager.rest'] - tags: - - { name: drupal.command } - rest_disable: - class: Drupal\Console\Command\Rest\DisableCommand - arguments: ['@config.factory', '@plugin.manager.rest'] - tags: - - { name: drupal.command } - rest_enable: - class: Drupal\Console\Command\Rest\EnableCommand - arguments: ['@plugin.manager.rest', '@authentication_collector', '@config.factory'] - tags: - - { name: drupal.command } diff --git a/config/services/drupal-core/simpletest.yml b/config/services/drupal-core/simpletest.yml deleted file mode 100644 index 20d3f34b8..000000000 --- a/config/services/drupal-core/simpletest.yml +++ /dev/null @@ -1,11 +0,0 @@ -services: - test_debug: - class: Drupal\Console\Command\Test\DebugCommand - arguments: ['@test_discovery'] - tags: - - { name: drupal.command } - test_run: - class: Drupal\Console\Command\Test\RunCommand - arguments: ['@app.root', '@test_discovery', '@module_handler', '@date.formatter'] - tags: - - { name: drupal.command } diff --git a/config/services/drupal-console/entity.yml b/config/services/entity.yml similarity index 83% rename from config/services/drupal-console/entity.yml rename to config/services/entity.yml index a81a0eaa3..58b018879 100644 --- a/config/services/drupal-console/entity.yml +++ b/config/services/entity.yml @@ -3,4 +3,4 @@ services: class: Drupal\Console\Command\Entity\DeleteCommand arguments: ['@entity_type.repository', '@entity_type.manager'] tags: - - { name: drupal.command } \ No newline at end of file + - { name: drupal.command } diff --git a/config/services/feature.yml b/config/services/feature.yml new file mode 100644 index 000000000..3a3574131 --- /dev/null +++ b/config/services/feature.yml @@ -0,0 +1,5 @@ +services: + console.feature_import: + class: Drupal\Console\Command\Features\ImportCommand + tags: + - { name: drupal.command } diff --git a/config/services/drupal-console/field.yml b/config/services/field.yml similarity index 100% rename from config/services/drupal-console/field.yml rename to config/services/field.yml diff --git a/config/services/drupal-console/generate.yml b/config/services/generate.yml similarity index 90% rename from config/services/drupal-console/generate.yml rename to config/services/generate.yml index 18f88ef35..49ba21d90 100644 --- a/config/services/drupal-console/generate.yml +++ b/config/services/generate.yml @@ -1,7 +1,7 @@ services: console.generate_module: class: Drupal\Console\Command\Generate\ModuleCommand - arguments: ['@console.module_generator', '@console.validator', '@app.root', '@console.string_converter', '@console.drupal_api', '@http_client', '@console.site'] + arguments: ['@console.module_generator', '@console.validator', '@app.root', '@console.string_converter', '@console.drupal_api'] tags: - { name: drupal.command } console.generate_modulefile: @@ -47,7 +47,7 @@ services: - { name: drupal.command } console.generate_permissions: class: Drupal\Console\Command\Generate\PermissionCommand - arguments: ['@console.extension_manager', '@console.string_converter'] + arguments: ['@console.extension_manager', '@console.string_converter', '@console.permission_generator'] tags: - { name: drupal.command } console.generate_event_subscriber: @@ -105,6 +105,16 @@ services: arguments: ['@console.extension_manager', '@console.plugin_mail_generator','@console.string_converter', '@console.validator', '@console.chain_queue'] tags: - { name: drupal.command } + console.generate_plugin_migrate_source: + class: Drupal\Console\Command\Generate\PluginMigrateSourceCommand + arguments: ['@config.factory', '@console.chain_queue', '@console.plugin_migrate_source_generator', '@entity_type.manager', '@console.extension_manager', '@console.validator', '@console.string_converter', '@plugin.manager.element_info'] + tags: + - { name: drupal.command } + console.generate_plugin_migrate_process: + class: Drupal\Console\Command\Generate\PluginMigrateProcessCommand + arguments: [ '@console.plugin_migrate_process_generator', '@console.chain_queue', '@console.extension_manager', '@console.string_converter'] + tags: + - { name: drupal.command } console.generate_plugin_rest_resource: class: Drupal\Console\Command\Generate\PluginRestResourceCommand arguments: ['@console.extension_manager', '@console.plugin_rest_resource_generator','@console.string_converter', '@console.chain_queue'] @@ -137,7 +147,7 @@ services: - { name: drupal.command } console.generate_profile: class: Drupal\Console\Command\Generate\ProfileCommand - arguments: ['@console.extension_manager', '@console.profile_generator', '@console.string_converter', '@console.validator', '@app.root', '@console.site', '@http_client'] + arguments: ['@console.extension_manager', '@console.profile_generator', '@console.string_converter', '@console.validator', '@app.root'] tags: - { name: drupal.command } console.generate_route_subscriber: @@ -172,7 +182,7 @@ services: - { name: drupal.command } console.generate_command: class: Drupal\Console\Command\Generate\CommandCommand - arguments: ['@console.command_generator', '@console.extension_manager', '@console.validator', '@console.string_converter' ] + arguments: ['@console.command_generator', '@console.extension_manager', '@console.validator', '@console.string_converter', '@console.site'] tags: - { name: drupal.command } console.generate_ckeditorbutton: @@ -195,3 +205,8 @@ services: arguments: ['@console.extension_manager', '@console.entityconfig_generator', '@console.validator', '@console.string_converter'] tags: - { name: drupal.command } + console.generate_cache_context: + class: Drupal\Console\Command\Generate\CacheContextCommand + arguments: [ '@console.cache_context_generator', '@console.chain_queue', '@console.extension_manager', '@console.string_converter'] + tags: + - { name: drupal.command } diff --git a/config/services/drupal-console/generator.yml b/config/services/generator.yml similarity index 89% rename from config/services/drupal-console/generator.yml rename to config/services/generator.yml index bcd4fdc5a..d5eb5f4a5 100644 --- a/config/services/drupal-console/generator.yml +++ b/config/services/generator.yml @@ -96,6 +96,16 @@ services: arguments: ['@console.extension_manager'] tags: - { name: drupal.generator } + console.plugin_migrate_source_generator: + class: Drupal\Console\Generator\PluginMigrateSourceGenerator + arguments: ['@console.extension_manager'] + tags: + - { name: drupal.generator } + console.plugin_migrate_process_generator: + class: Drupal\Console\Generator\PluginMigrateProcessGenerator + arguments: ['@console.extension_manager'] + tags: + - { name: drupal.generator } console.plugin_rest_resource_generator: class: Drupal\Console\Generator\PluginRestResourceGenerator arguments: ['@console.extension_manager'] @@ -166,6 +176,11 @@ services: arguments: ['@console.extension_manager'] tags: - { name: drupal.generator } + console.database_settings_generator: + class: Drupal\Console\Generator\DatabaseSettingsGenerator + arguments: ['@kernel'] + tags: + - { name: drupal.generator } console.entitycontent_generator: class: Drupal\Console\Generator\EntityContentGenerator arguments: ['@console.extension_manager', '@console.site', '@console.renderer'] @@ -181,3 +196,8 @@ services: arguments: ['@console.extension_manager'] tags: - { name: drupal.generator } + console.cache_context_generator: + class: Drupal\Console\Generator\CacheContextGenerator + arguments: ['@console.extension_manager'] + tags: + - { name: drupal.generator } diff --git a/config/services/drupal-console/image.yml b/config/services/image.yml similarity index 51% rename from config/services/drupal-console/image.yml rename to config/services/image.yml index d3c5f2d73..73b5c566a 100644 --- a/config/services/drupal-console/image.yml +++ b/config/services/image.yml @@ -1,9 +1,4 @@ services: - console.image_styles_debug: - class: Drupal\Console\Command\Image\StylesDebugCommand - arguments: ['@entity_type.manager'] - tags: - - { name: drupal.command } console.image_styles_flush: class: Drupal\Console\Command\Image\StylesFlushCommand arguments: ['@entity_type.manager'] diff --git a/config/services/drupal-console/locale.yml b/config/services/locale.yml similarity index 86% rename from config/services/drupal-console/locale.yml rename to config/services/locale.yml index c88f66310..a498b84e9 100644 --- a/config/services/drupal-console/locale.yml +++ b/config/services/locale.yml @@ -1,15 +1,15 @@ services: - translation_status: + console.translation_status: class: Drupal\Console\Command\Locale\TranslationStatusCommand arguments: ['@console.site', '@console.extension_manager'] tags: - { name: drupal.command } - language_delete: + console.language_delete: class: Drupal\Console\Command\Locale\LanguageDeleteCommand arguments: ['@console.site', '@entity_type.manager', '@module_handler'] tags: - { name: drupal.command } - language_add: + console.language_add: class: Drupal\Console\Command\Locale\LanguageAddCommand arguments: ['@console.site', '@module_handler'] tags: diff --git a/config/services/migrate.yml b/config/services/migrate.yml new file mode 100644 index 000000000..71ebc4f20 --- /dev/null +++ b/config/services/migrate.yml @@ -0,0 +1,16 @@ +services: + console.migrate_rollback: + class: Drupal\Console\Command\Migrate\RollBackCommand + arguments: ['@?plugin.manager.migration'] + tags: + - { name: drupal.command } + console.migrate_execute: + class: Drupal\Console\Command\Migrate\ExecuteCommand + arguments: ['@?plugin.manager.migration'] + tags: + - { name: drupal.command } + console.migrate_setup: + class: Drupal\Console\Command\Migrate\SetupCommand + arguments: ['@state', '@?plugin.manager.migration'] + tags: + - { name: drupal.command } diff --git a/config/services/misc.yml b/config/services/misc.yml new file mode 100644 index 000000000..9fad17087 --- /dev/null +++ b/config/services/misc.yml @@ -0,0 +1,10 @@ +services: + console.devel_dumper: + class: Drupal\Console\Command\DevelDumperCommand + arguments: ['@?plugin.manager.devel_dumper'] + tags: + - { name: drupal.command } + console.shell: + class: Drupal\Console\Command\ShellCommand + tags: + - { name: drupal.command } diff --git a/config/services/drupal-console/module.yml b/config/services/module.yml similarity index 55% rename from config/services/drupal-console/module.yml rename to config/services/module.yml index 574e82970..e970203dc 100644 --- a/config/services/drupal-console/module.yml +++ b/config/services/module.yml @@ -1,36 +1,30 @@ services: - module_debug: - class: Drupal\Console\Command\Module\DebugCommand - arguments: ['@console.configuration_manager', '@console.site', '@http_client'] - tags: - - { name: drupal.command } - module_dependency_install: + console.module_dependency_install: class: Drupal\Console\Command\Module\InstallDependencyCommand arguments: ['@console.site', '@console.validator', '@module_installer', '@console.chain_queue'] tags: - { name: drupal.command } - - module_download: + console.module_download: class: Drupal\Console\Command\Module\DownloadCommand arguments: ['@console.drupal_api', '@http_client', '@app.root', '@console.extension_manager', '@console.validator', '@console.site', '@console.configuration_manager', '@console.shell_process', '@console.root'] tags: - { name: drupal.command } - module_install: - class: Drupal\Console\Command\Module\InstallCommand - arguments: ['@console.site', '@console.validator', '@module_installer', '@console.drupal_api', '@console.extension_manager', '@app.root', '@console.chain_queue'] - tags: - - { name: drupal.command } - module_path: - class: Drupal\Console\Command\Module\PathCommand - arguments: ['@console.extension_manager'] - tags: - - { name: drupal.command } - module_uninstall: + console.module_install: + class: Drupal\Console\Command\Module\InstallCommand + arguments: ['@console.site', '@console.validator', '@module_installer', '@console.drupal_api', '@console.extension_manager', '@app.root', '@console.chain_queue'] + tags: + - { name: drupal.command } + console.module_path: + class: Drupal\Console\Command\Module\PathCommand + arguments: ['@console.extension_manager'] + tags: + - { name: drupal.command } + console.module_uninstall: class: Drupal\Console\Command\Module\UninstallCommand - arguments: ['@console.site','@module_installer', '@console.chain_queue', '@config.factory'] + arguments: ['@console.site','@module_installer', '@console.chain_queue', '@config.factory', '@console.extension_manager'] tags: - { name: drupal.command } - module_update: + console.module_update: class: Drupal\Console\Command\Module\UpdateCommand arguments: ['@console.shell_process', '@console.root'] tags: diff --git a/config/services/drupal-console/node.yml b/config/services/node.yml similarity index 100% rename from config/services/drupal-console/node.yml rename to config/services/node.yml diff --git a/config/services/drupal-console/queue.yml b/config/services/queue.yml similarity index 52% rename from config/services/drupal-console/queue.yml rename to config/services/queue.yml index e73b124a1..fc41033fc 100644 --- a/config/services/drupal-console/queue.yml +++ b/config/services/queue.yml @@ -1,9 +1,4 @@ services: - console.queue_debug: - class: Drupal\Console\Command\Queue\DebugCommand - arguments: ['@plugin.manager.queue_worker'] - tags: - - { name: drupal.command } console.queue_run: class: Drupal\Console\Command\Queue\RunCommand arguments: ['@plugin.manager.queue_worker', '@queue'] diff --git a/config/services/rest.yml b/config/services/rest.yml new file mode 100644 index 000000000..3b08edefe --- /dev/null +++ b/config/services/rest.yml @@ -0,0 +1,16 @@ +services: + console.rest_disable: + class: Drupal\Console\Command\Rest\DisableCommand + arguments: ['@config.factory', '@?plugin.manager.rest'] + tags: + - { name: drupal.command } + console.rest_enable: + class: Drupal\Console\Command\Rest\EnableCommand + arguments: + - '@?plugin.manager.rest' + - '@authentication_collector' + - '@config.factory' + - "@=container.hasParameter('serializer.formats') ? parameter('serializer.formats') : []" + - '@entity.manager' + tags: + - { name: drupal.command } diff --git a/config/services/drupal-console/router.yml b/config/services/router.yml similarity index 52% rename from config/services/drupal-console/router.yml rename to config/services/router.yml index b79bf43f1..4076dc6fd 100644 --- a/config/services/drupal-console/router.yml +++ b/config/services/router.yml @@ -1,9 +1,4 @@ services: - router_debug: - class: Drupal\Console\Command\Router\DebugCommand - arguments: ['@router.route_provider'] - tags: - - { name: drupal.command } console.router_rebuild: class: Drupal\Console\Command\Router\RebuildCommand arguments: ['@router.builder'] diff --git a/config/services/simpletest.yml b/config/services/simpletest.yml new file mode 100644 index 000000000..152e315f5 --- /dev/null +++ b/config/services/simpletest.yml @@ -0,0 +1,6 @@ +services: + console.test_run: + class: Drupal\Console\Command\Test\RunCommand + arguments: ['@app.root', '@?test_discovery', '@module_handler', '@date.formatter'] + tags: + - { name: drupal.command } diff --git a/config/services/drupal-console/site.yml b/config/services/site.yml similarity index 77% rename from config/services/drupal-console/site.yml rename to config/services/site.yml index a15e9d358..17ad4e7a6 100644 --- a/config/services/drupal-console/site.yml +++ b/config/services/site.yml @@ -1,9 +1,4 @@ services: - console.site_debug: - class: Drupal\Console\Command\Site\DebugCommand - arguments: ['@console.site','@console.configuration_manager'] - tags: - - { name: drupal.command } console.site_import_local: class: Drupal\Console\Command\Site\ImportLocalCommand arguments: ['@app.root','@console.configuration_manager'] @@ -19,10 +14,6 @@ services: arguments: ['@config.factory', '@console.configuration_manager', '@app.root', '@console.chain_queue'] tags: - { name: drupal.command } -# console.site_new: -# class: Drupal\Console\Command\Site\NewCommand -# tags: -# - { name: drupal.command } console.site_statistics: class: Drupal\Console\Command\Site\StatisticsCommand arguments: ['@console.drupal_api', '@entity.query', '@console.extension_manager', '@module_handler'] diff --git a/config/services/drupal-console/state.yml b/config/services/state.yml similarity index 67% rename from config/services/drupal-console/state.yml rename to config/services/state.yml index 546996688..be8572157 100644 --- a/config/services/drupal-console/state.yml +++ b/config/services/state.yml @@ -1,9 +1,4 @@ services: - console.state_debug: - class: Drupal\Console\Command\State\DebugCommand - arguments: ['@state', '@keyvalue'] - tags: - - { name: drupal.command } console.state_delete: class: Drupal\Console\Command\State\DeleteCommand arguments: ['@state', '@keyvalue'] diff --git a/config/services/drupal-console/taxonomy.yml b/config/services/taxonomy.yml similarity index 100% rename from config/services/drupal-console/taxonomy.yml rename to config/services/taxonomy.yml diff --git a/config/services/drupal-console/theme.yml b/config/services/theme.yml similarity index 69% rename from config/services/drupal-console/theme.yml rename to config/services/theme.yml index 9306e8844..74a2ff152 100644 --- a/config/services/drupal-console/theme.yml +++ b/config/services/theme.yml @@ -1,25 +1,20 @@ services: - theme_debug: - class: Drupal\Console\Command\Theme\DebugCommand - arguments: ['@config.factory', '@theme_handler'] - tags: - - { name: drupal.command } - theme_download: + console.theme_download: class: Drupal\Console\Command\Theme\DownloadCommand arguments: ['@console.drupal_api', '@http_client', '@app.root'] tags: - { name: drupal.command } - theme_install: + console.theme_install: class: Drupal\Console\Command\Theme\InstallCommand arguments: ['@config.factory', '@theme_handler', '@console.chain_queue'] tags: - { name: drupal.command } - theme_path: + console.theme_path: class: Drupal\Console\Command\Theme\PathCommand - arguments: ['@console.extension_manager'] + arguments: ['@console.extension_manager','@theme_handler'] tags: - { name: drupal.command } - theme_uninstall: + console.theme_uninstall: class: Drupal\Console\Command\Theme\UninstallCommand arguments: ['@config.factory', '@theme_handler', '@console.chain_queue'] tags: diff --git a/config/services/drupal-console/update.yml b/config/services/update.yml similarity index 67% rename from config/services/drupal-console/update.yml rename to config/services/update.yml index 2c1c9daff..eed0fa5a8 100644 --- a/config/services/drupal-console/update.yml +++ b/config/services/update.yml @@ -1,9 +1,4 @@ services: - console.update_debug: - class: Drupal\Console\Command\Update\DebugCommand - arguments: ['@console.site', '@update.post_update_registry'] - tags: - - { name: drupal.command } console.update_entities: class: Drupal\Console\Command\Update\EntitiesCommand arguments: ['@state', '@entity.definition_update_manager', '@console.chain_queue'] @@ -13,4 +8,4 @@ services: class: Drupal\Console\Command\Update\ExecuteCommand arguments: ['@console.site', '@state', '@module_handler', '@update.post_update_registry', '@console.extension_manager', '@console.chain_queue'] tags: - - { name: drupal.command } \ No newline at end of file + - { name: drupal.command } diff --git a/config/services/drupal-console/user.yml b/config/services/user.yml similarity index 86% rename from config/services/drupal-console/user.yml rename to config/services/user.yml index bf9bc16b3..60e9da724 100644 --- a/config/services/drupal-console/user.yml +++ b/config/services/user.yml @@ -1,9 +1,4 @@ services: - console.user_debug: - class: Drupal\Console\Command\User\DebugCommand - arguments: ['@entity_type.manager','@entity.query', '@console.drupal_api'] - tags: - - { name: drupal.command } console.user_delete: class: Drupal\Console\Command\User\DeleteCommand arguments: ['@entity_type.manager','@entity.query', '@console.drupal_api'] diff --git a/config/services/drupal-console/views.yml b/config/services/views.yml similarity index 55% rename from config/services/drupal-console/views.yml rename to config/services/views.yml index 97f856b7a..9fdc6a1cd 100644 --- a/config/services/drupal-console/views.yml +++ b/config/services/views.yml @@ -9,12 +9,3 @@ services: arguments: ['@entity_type.manager', '@entity.query'] tags: - { name: drupal.command } - console.views_debug: - class: Drupal\Console\Command\Views\DebugCommand - arguments: ['@entity_type.manager'] - tags: - - { name: drupal.command } - console.views_plugins_debug: - class: Drupal\Console\Command\Views\PluginsDebugCommand - tags: - - { name: drupal.command } diff --git a/config/translations/en/yaml.unset.yml b/config/translations/en/yaml.unset.yml deleted file mode 100644 index 5d8418197..000000000 --- a/config/translations/en/yaml.unset.yml +++ /dev/null @@ -1,7 +0,0 @@ -key: - description: 'Unset a YAML key in a YAML file.' - arguments: - yaml-file: 'Path of YAML file to update' - yaml-key: 'YAML key to be unset' - messages: - unset: 'YAML file "%s" was unset successfully.' diff --git a/phpqa.yml b/phpqa.yml index c05323fc4..5998ec92a 100644 --- a/phpqa.yml +++ b/phpqa.yml @@ -17,9 +17,6 @@ application: php-cs-fixer: enabled: true exception: false - file: - config-file: .php_cs - single-execution: false options: level: psr2 arguments: @@ -36,7 +33,7 @@ application: arguments: - '-n' phpcs: - enabled: true + enabled: false exception: false options: standard: PSR2 diff --git a/services.yml b/services.yml index 05d819483..e71584db1 100644 --- a/services.yml +++ b/services.yml @@ -1,18 +1,11 @@ -imports: - - { resource: 'services-drupal-install.yml' } services: - console.input: - class: 'Symfony\Component\Console\Input\ArgvInput' - console.ouput: - class: 'Symfony\Component\Console\Output\ConsoleOutput' - console.style: - class: 'Drupal\Console\Style\DrupalStyle' - arguments: ['@console.input', '@console.ouput'] + console.root: + class: SplString console.redbean: class: RedBeanPHP\R console.validator: class: Drupal\Console\Utils\Validator - arguments: ['@console.extension_manager'] + arguments: ['@console.extension_manager', '@console.translator_manager'] console.drupal_api: class: Drupal\Console\Utils\DrupalApi arguments: ['@app.root', '@entity_type.manager', '@http_client'] diff --git a/src/Annotations/DrupalCommand.php b/src/Annotations/DrupalCommand.php index 8be4fd025..32d472436 100644 --- a/src/Annotations/DrupalCommand.php +++ b/src/Annotations/DrupalCommand.php @@ -12,7 +12,6 @@ * @Annotation * @Target("CLASS") */ - class DrupalCommand { /** @@ -29,5 +28,4 @@ class DrupalCommand * @var array */ public $dependencies; - } diff --git a/src/Annotations/DrupalCommandAnnotationReader.php b/src/Annotations/DrupalCommandAnnotationReader.php index c2e13eb13..476acb381 100644 --- a/src/Annotations/DrupalCommandAnnotationReader.php +++ b/src/Annotations/DrupalCommandAnnotationReader.php @@ -6,10 +6,11 @@ /** * Class DrupalCommandReader + * * @package Drupal\Console\Annotations */ -class DrupalCommandAnnotationReader { - +class DrupalCommandAnnotationReader +{ /** * @param $class * @return array @@ -22,7 +23,7 @@ public function readAnnotation($class) new \ReflectionClass($class), 'Drupal\\Console\\Annotations\\DrupalCommand' ); - if($drupalCommandAnnotation) { + if ($drupalCommandAnnotation) { $annotation['extension'] = $drupalCommandAnnotation->extension?:''; $annotation['extensionType'] = $drupalCommandAnnotation->extensionType?:''; $annotation['dependencies'] = $drupalCommandAnnotation->dependencies?:[]; diff --git a/src/Application.php b/src/Application.php index 8b9b21722..125f82c4b 100644 --- a/src/Application.php +++ b/src/Application.php @@ -2,17 +2,20 @@ namespace Drupal\Console; +use Doctrine\Common\Annotations\AnnotationRegistry; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\Console\Annotations\DrupalCommandAnnotationReader; use Drupal\Console\Utils\AnnotationValidator; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Application as BaseApplication; /** * Class Application + * * @package Drupal\Console */ -class Application extends ConsoleApplication +class Application extends BaseApplication { /** * @var string @@ -22,13 +25,35 @@ class Application extends ConsoleApplication /** * @var string */ - const VERSION = '1.0.0-rc6'; + const VERSION = '1.0.0-rc26'; public function __construct(ContainerInterface $container) { parent::__construct($container, $this::NAME, $this::VERSION); } + /** + * Returns the long version of the application. + * + * @return string The long application version + */ + public function getLongVersion() + { + $output = ''; + + if ('UNKNOWN' !== $this->getName()) { + if ('UNKNOWN' !== $this->getVersion()) { + $output .= sprintf('%s version %s', $this->getName(), $this->getVersion()); + } else { + $output .= sprintf('%s', $this->getName()); + } + } else { + $output .= 'Drupal Console'; + } + + return $output; + } + /** * {@inheritdoc} */ @@ -42,13 +67,9 @@ public function doRun(InputInterface $input, OutputInterface $output) if ($clear === true || $clear === 'true') { $output->write(sprintf("\033\143")); } - parent::doRun($input, $output); - if ($this->getCommandName($input) == 'list' && $this->container->hasParameter('console.warning')) { - $io = new DrupalStyle($input, $output); - $io->warning( - $this->trans($this->container->getParameter('console.warning')) - ); - } + + $exitCode = parent::doRun($input, $output); + return $exitCode; } private function registerGenerators() @@ -68,7 +89,13 @@ private function registerGenerators() continue; } - $generator = $this->container->get($name); + try { + $generator = $this->container->get($name); + } catch (\Exception $e) { + echo $name . ' - ' . $e->getMessage() . PHP_EOL; + + continue; + } if (!$generator) { continue; @@ -106,10 +133,17 @@ private function registerCommands() $serviceDefinitions = []; $annotationValidator = null; + $annotationCommandReader = null; if ($this->container->hasParameter('console.service_definitions')) { $serviceDefinitions = $this->container ->getParameter('console.service_definitions'); + /** + * @var DrupalCommandAnnotationReader $annotationCommandReader + */ + $annotationCommandReader = $this->container + ->get('console.annotation_command_reader'); + /** * @var AnnotationValidator $annotationValidator */ @@ -117,12 +151,25 @@ private function registerCommands() ->get('console.annotation_validator'); } + $aliases = $this->container->get('console.configuration_manager') + ->getConfiguration() + ->get('application.commands.aliases')?:[]; + foreach ($consoleCommands as $name) { + + AnnotationRegistry::reset(); + AnnotationRegistry::registerLoader( + [ + $this->container->get('class_loader'), + "loadClass" + ] + ); + if (!$this->container->has($name)) { continue; } - if ($annotationValidator) { + if ($annotationValidator && $annotationCommandReader) { if (!$serviceDefinition = $serviceDefinitions[$name]) { continue; } @@ -130,11 +177,23 @@ private function registerCommands() if (!$annotationValidator->isValidCommand($serviceDefinition->getClass())) { continue; } + + $annotation = $annotationCommandReader + ->readAnnotation($serviceDefinition->getClass()); + if ($annotation) { + $this->container->get('console.translator_manager') + ->addResourceTranslationsByExtension( + $annotation['extension'], + $annotation['extensionType'] + ); + } } try { $command = $this->container->get($name); } catch (\Exception $e) { + echo $name . ' - ' . $e->getMessage() . PHP_EOL; + continue; } @@ -154,6 +213,17 @@ private function registerCommands() ); } + if (array_key_exists($command->getName(), $aliases)) { + $commandAliases = array_unique(array_merge( + $command->getAliases()?$command->getAliases():[], + array_key_exists($command->getName(), $aliases)?$aliases[$command->getName()]:[] + )); + if (!is_array($commandAliases)) { + $commandAliases = [$commandAliases]; + } + $command->setAliases($commandAliases); + } + $this->add($command); } } @@ -168,9 +238,10 @@ public function getData() 'help', 'init', 'list', - // 'self-update', + 'shell', 'server' ]; + $languages = $this->container->get('console.configuration_manager') ->getConfiguration() ->get('application.languages'); @@ -233,16 +304,16 @@ public function getData() 'arguments' => $arguments, 'languages' => $languages, 'messages' => [ - 'title' => $this->trans('commands.generate.doc.gitbook.messages.title'), - 'note' => $this->trans('commands.generate.doc.gitbook.messages.note'), - 'note_description' => $this->trans('commands.generate.doc.gitbook.messages.note-description'), - 'command' => $this->trans('commands.generate.doc.gitbook.messages.command'), - 'options' => $this->trans('commands.generate.doc.gitbook.messages.options'), - 'option' => $this->trans('commands.generate.doc.gitbook.messages.option'), - 'details' => $this->trans('commands.generate.doc.gitbook.messages.details'), - 'arguments' => $this->trans('commands.generate.doc.gitbook.messages.arguments'), - 'argument' => $this->trans('commands.generate.doc.gitbook.messages.argument'), - 'examples' => $this->trans('commands.generate.doc.gitbook.messages.examples') + 'title' => $this->trans('application.gitbook.messages.title'), + 'note' => $this->trans('application.gitbook.messages.note'), + 'note_description' => $this->trans('application.gitbook.messages.note-description'), + 'command' => $this->trans('application.gitbook.messages.command'), + 'options' => $this->trans('application.gitbook.messages.options'), + 'option' => $this->trans('application.gitbook.messages.option'), + 'details' => $this->trans('application.gitbook.messages.details'), + 'arguments' => $this->trans('application.gitbook.messages.arguments'), + 'argument' => $this->trans('application.gitbook.messages.argument'), + 'examples' => $this->trans('application.gitbook.messages.examples') ], 'examples' => [] ]; @@ -310,16 +381,23 @@ private function commandData($commandName) 'key' => $commandKey, 'dashed' => str_replace(':', '-', $command->getName()), 'messages' => [ - 'usage' => $this->trans('commands.generate.doc.gitbook.messages.usage'), - 'options' => $this->trans('commands.generate.doc.gitbook.messages.options'), - 'option' => $this->trans('commands.generate.doc.gitbook.messages.option'), - 'details' => $this->trans('commands.generate.doc.gitbook.messages.details'), - 'arguments' => $this->trans('commands.generate.doc.gitbook.messages.arguments'), - 'argument' => $this->trans('commands.generate.doc.gitbook.messages.argument'), - 'examples' => $this->trans('commands.generate.doc.gitbook.messages.examples') + 'usage' => $this->trans('application.gitbook.messages.usage'), + 'options' => $this->trans('application.gitbook.messages.options'), + 'option' => $this->trans('application.gitbook.messages.option'), + 'details' => $this->trans('application.gitbook.messages.details'), + 'arguments' => $this->trans('application.gitbook.messages.arguments'), + 'argument' => $this->trans('application.gitbook.messages.argument'), + 'examples' => $this->trans('application.gitbook.messages.examples') ], ]; return $data; } + + public function setContainer($container) + { + $this->container = $container; + $this->registerGenerators(); + $this->registerCommands(); + } } diff --git a/src/Bootstrap/AddServicesCompilerPass.php b/src/Bootstrap/AddServicesCompilerPass.php index e0708bdfa..c10813262 100644 --- a/src/Bootstrap/AddServicesCompilerPass.php +++ b/src/Bootstrap/AddServicesCompilerPass.php @@ -2,12 +2,16 @@ namespace Drupal\Console\Bootstrap; -use Drupal\Console\Extension\Manager; -use Symfony\Component\DependencyInjection\ContainerBuilder; +use Drupal\Console\Utils\Site; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\Config\FileLocator; use Symfony\Component\Finder\Finder; +use Symfony\Component\Yaml\Yaml; +use Drupal\Console\Utils\TranslatorManager; +use Drupal\Console\Extension\Extension; +use Drupal\Console\Extension\Manager; /** * FindCommandsCompilerPass @@ -19,13 +23,28 @@ class AddServicesCompilerPass implements CompilerPassInterface */ protected $root; + /** + * @var string + */ + protected $appRoot; + + /** + * @var boolean + */ + protected $rebuild; + /** * AddCommandsCompilerPass constructor. - * @param string $root + * + * @param string $root + * @param string $appRoot + * @param boolean $rebuild */ - public function __construct($root) + public function __construct($root, $appRoot, $rebuild = false) { $this->root = $root; + $this->appRoot = $appRoot; + $this->rebuild = $rebuild; } /** @@ -38,46 +57,133 @@ public function process(ContainerBuilder $container) new FileLocator($this->root) ); - $loader->load($this->root. DRUPAL_CONSOLE_CORE . 'services.yml'); - $loader->load($this->root. DRUPAL_CONSOLE . 'services.yml'); - - $finder = new Finder(); - $finder->files() - ->name('*.yml') - ->in( - sprintf( - '%s/config/services/drupal-console', - $this->root.DRUPAL_CONSOLE - ) - ); - - foreach ($finder as $file) { - $loader->load($file->getPathName()); + $servicesFiles = [ + $this->root. DRUPAL_CONSOLE_CORE . 'services.yml', + $this->root. DRUPAL_CONSOLE . 'uninstall.services.yml', + $this->root. DRUPAL_CONSOLE . 'services.yml' + ]; + + foreach ($servicesFiles as $servicesFile) { + if (file_exists($servicesFile)) { + $loader->load($servicesFile); + } } + $container->get('console.configuration_manager') + ->loadConfiguration($this->root) + ->getConfiguration(); + /** - * @var Manager $extensionManager + * @var Site $site */ - $extensionManager = $container->get('console.extension_manager'); - $modules = $extensionManager->discoverModules() - ->showCore() - ->showNoCore() - ->showInstalled() - ->getList(true); - - $finder = new Finder(); - $finder->files() - ->name('*.yml') - ->in( - sprintf( - '%s/config/services/drupal-core', - $this->root.DRUPAL_CONSOLE - ) - ); - - foreach ($finder as $file) { - if (in_array($file->getBasename('.yml'), $modules)) { + $site = $container->get('console.site'); + \Drupal::getContainer()->set( + 'console.root', + $this->root + ); + + if (!$this->rebuild && $site->cachedServicesFileExists()) { + $loader->load($site->getCachedServicesFile()); + } else { + $site->removeCachedServicesFile(); + $finder = new Finder(); + $finder->files() + ->name('*.yml') + ->in( + sprintf( + '%s/config/services', + $this->root.DRUPAL_CONSOLE + ) + ); + + $servicesData = []; + foreach ($finder as $file) { $loader->load($file->getPathName()); + $servicesData = $this->extractServiceData( + $file->getPathName(), + $servicesData + ); + } + + /** + * @var Manager $extensionManager + */ + $extensionManager = $container->get('console.extension_manager'); + /** + * @var Extension[] $modules + */ + $modules = $extensionManager->discoverModules() + ->showCore() + ->showNoCore() + ->showInstalled() + ->getList(false); + + foreach ($modules as $module) { + $consoleServicesExtensionFile = $this->appRoot . '/' . + $module->getPath() . '/console.services.yml'; + if (is_file($consoleServicesExtensionFile)) { + $loader->load($consoleServicesExtensionFile); + $servicesData = $this->extractServiceData( + $consoleServicesExtensionFile, + $servicesData + ); + } + } + + /** + * @var Extension[] $themes + */ + $themes = $extensionManager->discoverThemes() + ->showNoCore() + ->showInstalled() + ->getList(false); + + foreach ($themes as $theme) { + $consoleServicesExtensionFile = $this->appRoot . '/' . + $theme->getPath() . '/console.services.yml'; + if (is_file($consoleServicesExtensionFile)) { + $loader->load($consoleServicesExtensionFile); + $servicesData = $this->extractServiceData( + $consoleServicesExtensionFile, + $servicesData + ); + } + } + + if ($servicesData) { + file_put_contents( + $site->getCachedServicesFile(), + Yaml::dump($servicesData, 4, 2) + ); + } + } + + $extendServicesFiles = [ + $this->root . DRUPAL_CONSOLE . 'extend.console.services.yml', + $this->root . DRUPAL_CONSOLE . 'extend.console.uninstall.services.yml', + ]; + + foreach ($extendServicesFiles as $extendServicesFile) { + if (file_exists($extendServicesFile)) { + $loader->load($extendServicesFile); + } + } + + $configurationManager = $container->get('console.configuration_manager'); + $directory = $configurationManager->getConsoleDirectory() . 'extend/'; + $autoloadFile = $directory . 'vendor/autoload.php'; + if (is_file($autoloadFile)) { + include_once $autoloadFile; + + $extendServicesFiles = [ + $directory . 'extend.console.services.yml', + $directory . 'extend.console.uninstall.services.yml', + ]; + + foreach ($extendServicesFiles as $extendServicesFile) { + if (file_exists($extendServicesFile)) { + $loader->load($extendServicesFile); + } } } @@ -85,5 +191,28 @@ public function process(ContainerBuilder $container) 'console.service_definitions', $container->getDefinitions() ); + + $definition = $container->getDefinition('console.translator_manager'); + $definition->setClass(TranslatorManager::class); + } + + /** + * @param $filePath + * @param $servicesData + * + * @return array + */ + protected function extractServiceData($filePath, $servicesData) + { + $serviceFileData = Yaml::parse( + file_get_contents($filePath) + ); + + $servicesData = array_merge_recursive( + $servicesData, + $serviceFileData + ); + + return $servicesData; } } diff --git a/src/Bootstrap/Drupal.php b/src/Bootstrap/Drupal.php index b38cf861e..7871548de 100644 --- a/src/Bootstrap/Drupal.php +++ b/src/Bootstrap/Drupal.php @@ -3,82 +3,181 @@ namespace Drupal\Console\Bootstrap; use Doctrine\Common\Annotations\AnnotationRegistry; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\HttpFoundation\Request; +use Drupal\Console\Core\Style\DrupalStyle; +use Drupal\Console\Core\Utils\ArgvInputReader; +use Drupal\Console\Core\Bootstrap\DrupalConsoleCore; +use Drupal\Console\Core\Utils\DrupalFinder; class Drupal { protected $autoload; - protected $root; - protected $appRoot; + + /** + * @var DrupalFinder + */ + protected $drupalFinder; /** * Drupal constructor. + * * @param $autoload - * @param $root + * @param $drupalFinder */ - public function __construct($autoload, $root, $appRoot) + public function __construct($autoload, DrupalFinder $drupalFinder) { $this->autoload = $autoload; - $this->root = $root; - $this->appRoot = $appRoot; + $this->drupalFinder = $drupalFinder; } public function boot() { + $output = new ConsoleOutput(); + $input = new ArrayInput([]); + $io = new DrupalStyle($input, $output); + $argvInputReader = new ArgvInputReader(); + $command = $argvInputReader->get('command'); + $uri = $argvInputReader->get('uri'); + $debug = $argvInputReader->get('debug', false); + + if ($debug) { + $binaryPath = $this->drupalFinder->getVendorDir() . + '/drupal/console/bin/drupal'; + $io->writeln("Per-Site path: $binaryPath"); + $io->newLine(); + } + if (!class_exists('Drupal\Core\DrupalKernel')) { - $drupal = new DrupalConsoleCore($this->root, $this->appRoot); + $io->error('Class Drupal\Core\DrupalKernel does not exist.'); + $drupal = new DrupalConsoleCore( + $this->drupalFinder->getComposerRoot(), + $this->drupalFinder->getDrupalRoot() + ); return $drupal->boot(); } try { + // Add support for Acquia Dev Desktop sites. + // Try both Mac and Windows home locations. + $home = getenv('HOME'); + if (empty($home)) { + $home = getenv('USERPROFILE'); + } + if (!empty($home)) { + $devDesktopSettingsDir = $home . "/.acquia/DevDesktop/DrupalSettings"; + if (file_exists($devDesktopSettingsDir)) { + $_SERVER['DEVDESKTOP_DRUPAL_SETTINGS_DIR'] = $devDesktopSettingsDir; + } + } + + $rebuildServicesFile = false; + if ($command=='cache:rebuild' || $command=='cr') { + $rebuildServicesFile = true; + } + + if ($debug) { + $io->writeln('➤ Creating request'); + } + + $_SERVER['HTTP_HOST'] = parse_url($uri, PHP_URL_HOST); + $_SERVER['SERVER_PORT'] = null; + $_SERVER['REQUEST_URI'] = '/'; + $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; + $_SERVER['REQUEST_METHOD'] = 'GET'; + $_SERVER['SERVER_SOFTWARE'] = null; + $_SERVER['HTTP_USER_AGENT'] = null; + $_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI'] . 'index.php'; + $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF']; + $_SERVER['SCRIPT_FILENAME'] = $this->drupalFinder->getDrupalRoot() . '/index.php'; $request = Request::createFromGlobals(); + + if ($debug) { + $io->writeln("\r\033[K\033[1A\r"); + $io->writeln('➤ Creating Drupal kernel'); + } + $drupalKernel = DrupalKernel::createFromRequest( $request, $this->autoload, 'prod', - false + false, + $this->drupalFinder->getDrupalRoot() ); + if ($debug) { + $io->writeln("\r\033[K\033[1A\r"); + $io->writeln('➤ Registering dynamic services'); + } $drupalKernel->addServiceModifier( new DrupalServiceModifier( - $this->root, + $this->drupalFinder->getComposerRoot(), + $this->drupalFinder->getDrupalRoot(), 'drupal.command', - 'drupal.generator' + 'drupal.generator', + $rebuildServicesFile ) ); + if ($debug) { + $io->writeln("\r\033[K\033[1A\r"); + $io->writeln('➤ Rebuilding container'); + } $drupalKernel->invalidateContainer(); $drupalKernel->rebuildContainer(); $drupalKernel->boot(); - $container = $drupalKernel->getContainer(); + if ($debug) { + $io->writeln("\r\033[K\033[1A\r"); + } - $container->set('console.root', $this->root); + $container = $drupalKernel->getContainer(); + $container->set( + 'console.root', + $this->drupalFinder->getComposerRoot() + ); AnnotationRegistry::registerLoader([$this->autoload, "loadClass"]); $configuration = $container->get('console.configuration_manager') - ->loadConfiguration($this->root) ->getConfiguration(); $container->get('console.translator_manager') ->loadCoreLanguage( $configuration->get('application.language'), - $this->root + $this->drupalFinder->getComposerRoot() ); + $consoleExtendConfigFile = $this->drupalFinder + ->getComposerRoot() . DRUPAL_CONSOLE + .'/extend.console.config.yml'; + if (file_exists($consoleExtendConfigFile)) { + $container->get('console.configuration_manager') + ->importConfigurationFile($consoleExtendConfigFile); + } + $container->get('console.renderer') ->setSkeletonDirs( [ - $this->root.DRUPAL_CONSOLE.'/templates/', - $this->root.DRUPAL_CONSOLE_CORE.'/templates/' + $this->drupalFinder->getComposerRoot().DRUPAL_CONSOLE.'/templates/', + $this->drupalFinder->getComposerRoot().DRUPAL_CONSOLE_CORE.'/templates/' ] ); return $container; } catch (\Exception $e) { - $drupal = new DrupalConsoleCore($this->root, $this->appRoot); - return $drupal->boot(); + if ($command == 'list') { + $io->error($e->getMessage()); + } + $drupal = new DrupalConsoleCore( + $this->drupalFinder->getComposerRoot(), + $this->drupalFinder->getDrupalRoot() + ); + $container = $drupal->boot(); + $container->set('class_loader', $this->autoload); + + return $container; } } } diff --git a/src/Bootstrap/DrupalKernel.php b/src/Bootstrap/DrupalKernel.php index 16ee21d5f..0bf201230 100644 --- a/src/Bootstrap/DrupalKernel.php +++ b/src/Bootstrap/DrupalKernel.php @@ -8,6 +8,7 @@ /** * Class DrupalKernel + * * @package Drupal\Console\Utils */ class DrupalKernel extends DrupalKernelBase @@ -22,8 +23,8 @@ class DrupalKernel extends DrupalKernelBase */ public static function createFromRequest(Request $request, $class_loader, $environment, $allow_dumping = true, $app_root = null) { - $kernel = new static($environment, $class_loader, $allow_dumping); - static::bootEnvironment(); + $kernel = new static($environment, $class_loader, $allow_dumping, $app_root); + static::bootEnvironment($app_root); $kernel->initializeSettings($request); $kernel->handle($request); return $kernel; diff --git a/src/Bootstrap/DrupalServiceModifier.php b/src/Bootstrap/DrupalServiceModifier.php index ed1f4ddab..f19310456 100644 --- a/src/Bootstrap/DrupalServiceModifier.php +++ b/src/Bootstrap/DrupalServiceModifier.php @@ -12,6 +12,11 @@ class DrupalServiceModifier implements ServiceModifierInterface */ protected $root; + /** + * @var string + */ + protected $appRoot; + /** * @var string */ @@ -22,20 +27,32 @@ class DrupalServiceModifier implements ServiceModifierInterface */ protected $generatorTag; + /** + * @var boolean + */ + protected $rebuild; + /** * DrupalServiceModifier constructor. - * @param string $root - * @param string $serviceTag - * @param string $generatorTag + * + * @param string $root + * @param string $appRoot + * @param string $serviceTag + * @param string $generatorTag + * @param boolean $rebuild */ public function __construct( $root = null, + $appRoot = null, $serviceTag, - $generatorTag + $generatorTag, + $rebuild ) { $this->root = $root; + $this->appRoot = $appRoot; $this->commandTag = $serviceTag; $this->generatorTag = $generatorTag; + $this->rebuild = $rebuild; } @@ -45,7 +62,11 @@ public function __construct( public function alter(ContainerBuilder $container) { $container->addCompilerPass( - new AddServicesCompilerPass($this->root) + new AddServicesCompilerPass( + $this->root, + $this->appRoot, + $this->rebuild + ) ); $container->addCompilerPass( new FindCommandsCompilerPass($this->commandTag) diff --git a/src/Bootstrap/FindCommandsCompilerPass.php b/src/Bootstrap/FindCommandsCompilerPass.php index be47496d7..42648b4ee 100644 --- a/src/Bootstrap/FindCommandsCompilerPass.php +++ b/src/Bootstrap/FindCommandsCompilerPass.php @@ -17,6 +17,7 @@ class FindCommandsCompilerPass implements CompilerPassInterface /** * FindCommandsCompilerPass constructor. + * * @param $serviceTag */ public function __construct($serviceTag) diff --git a/src/Bootstrap/FindGeneratorsCompilerPass.php b/src/Bootstrap/FindGeneratorsCompilerPass.php index 12081bec4..601a9d952 100644 --- a/src/Bootstrap/FindGeneratorsCompilerPass.php +++ b/src/Bootstrap/FindGeneratorsCompilerPass.php @@ -17,6 +17,7 @@ class FindGeneratorsCompilerPass implements CompilerPassInterface /** * FindCommandsCompilerPass constructor. + * * @param $serviceTag */ public function __construct($serviceTag) diff --git a/src/Command/Cache/RebuildCommand.php b/src/Command/Cache/RebuildCommand.php index 6f955d258..fb7fedfb1 100644 --- a/src/Command/Cache/RebuildCommand.php +++ b/src/Command/Cache/RebuildCommand.php @@ -11,20 +11,18 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Utils\DrupalApi; use Drupal\Console\Utils\Site; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class RebuildCommand + * * @package Drupal\Console\Command\Cache */ class RebuildCommand extends Command { - use CommandTrait; - /** * @var DrupalApi */ @@ -43,6 +41,7 @@ class RebuildCommand extends Command /** * RebuildCommand constructor. + * * @param DrupalApi $drupalApi * @param Site $site * @param $classLoader @@ -73,7 +72,7 @@ protected function configure() 'cache', InputArgument::OPTIONAL, $this->trans('commands.cache.rebuild.options.cache') - ); + )->setAliases(['cr']); } /** @@ -82,13 +81,13 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); - $cache = $input->getArgument('cache'); + $cache = $input->getArgument('cache')?:'all'; $this->site->loadLegacyFile('/core/includes/utility.inc'); if ($cache && !$this->drupalApi->isValidCache($cache)) { $io->error( sprintf( - $this->trans('commands.cache.rebuild.messages.invalid_cache'), + $this->trans('commands.cache.rebuild.messages.invalid-cache'), $cache ) ); diff --git a/src/Command/Cache/TagInvalidateCommand.php b/src/Command/Cache/TagInvalidateCommand.php new file mode 100644 index 000000000..f7a978d4c --- /dev/null +++ b/src/Command/Cache/TagInvalidateCommand.php @@ -0,0 +1,69 @@ +invalidator = $invalidator; + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('cache:tag:invalidate') + ->setDescription($this->trans('commands.cache.tag.invalidate.description')) + ->addArgument( + 'tag', + InputArgument::REQUIRED | InputArgument::IS_ARRAY, + $this->trans('commands.cache.tag.invalidate.options.tag') + ) + ->setAliases(['cti']); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + $tags = $input->getArgument('tag'); + + $io->comment( + sprintf( + $this->trans('commands.cache.tag.invalidate.messages.start'), + implode(', ', $tags) + ) + ); + + $this->invalidator->invalidateTags($tags); + $io->success($this->trans('commands.cache.tag.invalidate.messages.completed')); + } +} diff --git a/src/Command/Chain/ChainCommand.php b/src/Command/Chain/ChainCommand.php deleted file mode 100644 index fe64a849b..000000000 --- a/src/Command/Chain/ChainCommand.php +++ /dev/null @@ -1,316 +0,0 @@ -chainQueue = $chainQueue; - $this->configurationManager = $configurationManager; - $this->appRoot = $appRoot; - $this->extensionManager = $extensionManager; - parent::__construct(); - } - - /** - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('chain') - ->setDescription($this->trans('commands.chain.description')) - ->addOption( - 'file', - null, - InputOption::VALUE_OPTIONAL, - $this->trans('commands.chain.options.file') - ) - ->addOption( - 'placeholder', - null, - InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, - $this->trans('commands.chain.options.placeholder') - ); - } - - /** - * {@inheritdoc} - */ - protected function interact(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - $file = $input->getOption('file'); - - if (!$file) { - $files = $this->getChainFiles(true); - - $file = $io->choice( - $this->trans('commands.chain.questions.chain-file'), - array_values($files) - ); - } - - $file = calculateRealPath($file); - $input->setOption('file', $file); - - $chainContent = file_get_contents($file); - - $placeholder = $input->getOption('placeholder'); - $inlinePlaceHolders = $this->extractInlinePlaceHolders($chainContent); - - if (!$placeholder && $inlinePlaceHolders) { - foreach ($inlinePlaceHolders as $key => $inlinePlaceHolder) { - $inlinePlaceHolderDefault = ''; - if (strpos($inlinePlaceHolder, '|')>0) { - $placeholderParts = explode('|', $inlinePlaceHolder); - $inlinePlaceHolder = $placeholderParts[0]; - $inlinePlaceHolderDefault = $placeholderParts[1]; - $inlinePlaceHolders[$key] = $inlinePlaceHolder; - } - - $placeholder[] = sprintf( - '%s:%s', - $inlinePlaceHolder, - $io->ask( - sprintf( - 'Enter placeholder value for %s', - $inlinePlaceHolder - ), - $inlinePlaceHolderDefault - ) - ); - } - $input->setOption('placeholder', $placeholder); - } - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $interactive = false; - $learning = $input->hasOption('learning')?$input->getOption('learning'):false; - - $file = $input->getOption('file'); - - if (!$file) { - $io->error($this->trans('commands.chain.messages.missing_file')); - - return 1; - } - - $fileSystem = new Filesystem(); - - $file = calculateRealPath($file); - - if (!$fileSystem->exists($file)) { - $io->error( - sprintf( - $this->trans('commands.chain.messages.invalid_file'), - $file - ) - ); - - return 1; - } - - $placeholder = $input->getOption('placeholder'); - if ($placeholder) { - $placeholder = $this->inlineValueAsArray($placeholder); - } - - $chainContent = file_get_contents($file); - $environmentPlaceHolders = $this->extractEnvironmentPlaceHolders($chainContent); - - $envPlaceHolderMap = []; - $missingEnvironmentPlaceHolders = []; - foreach ($environmentPlaceHolders as $envPlaceHolder) { - if (!getenv($envPlaceHolder)) { - $missingEnvironmentPlaceHolders[$envPlaceHolder] = sprintf( - 'export %s=%s_VALUE', - $envPlaceHolder, - strtoupper($envPlaceHolder) - ); - - continue; - } - $envPlaceHolderMap[$envPlaceHolder] = getenv($envPlaceHolder); - } - - if ($missingEnvironmentPlaceHolders) { - $io->error( - sprintf( - $this->trans('commands.chain.messages.missing-environment-placeholders'), - implode(', ', array_keys($missingEnvironmentPlaceHolders)) - ) - ); - - $io->info($this->trans('commands.chain.messages.set-environment-placeholders')); - $io->block(array_values($missingEnvironmentPlaceHolders)); - - return 1; - } - - $envPlaceHolderData = new ArrayDataSource($envPlaceHolderMap); - $placeholderResolver = new RegexPlaceholderResolver($envPlaceHolderData, '${{', '}}'); - $chainContent = $placeholderResolver->resolvePlaceholder($chainContent); - - $inlinePlaceHolders = $this->extractInlinePlaceHolders($chainContent); - - $inlinePlaceHoldersReplacements = []; - foreach ($inlinePlaceHolders as $key => $inlinePlaceHolder) { - if (strpos($inlinePlaceHolder, '|') > 0) { - $placeholderParts = explode('|', $inlinePlaceHolder); - $inlinePlaceHoldersReplacements[] = $placeholderParts[0]; - continue; - } - $inlinePlaceHoldersReplacements[] = $inlinePlaceHolder; - } - - $chainContent = str_replace( - $inlinePlaceHolders, - $inlinePlaceHoldersReplacements, - $chainContent - ); - - $inlinePlaceHolders = $inlinePlaceHoldersReplacements; - - $inlinePlaceHolderMap = []; - foreach ($placeholder as $key => $placeholderItem) { - $inlinePlaceHolderMap = array_merge($inlinePlaceHolderMap, $placeholderItem); - } - - $missingInlinePlaceHolders = []; - foreach ($inlinePlaceHolders as $inlinePlaceHolder) { - if (!array_key_exists($inlinePlaceHolder, $inlinePlaceHolderMap)) { - $missingInlinePlaceHolders[$inlinePlaceHolder] = sprintf( - '--placeholder="%s:%s_VALUE"', - $inlinePlaceHolder, - strtoupper($inlinePlaceHolder) - ); - } - } - - if ($missingInlinePlaceHolders) { - $io->error( - sprintf( - $this->trans('commands.chain.messages.missing-inline-placeholders'), - implode(', ', array_keys($missingInlinePlaceHolders)) - ) - ); - - $io->info($this->trans('commands.chain.messages.set-inline-placeholders')); - $io->block(array_values($missingInlinePlaceHolders)); - - return 1; - } - - $inlinePlaceHolderData = new ArrayDataSource($inlinePlaceHolderMap); - $placeholderResolver = new RegexPlaceholderResolver($inlinePlaceHolderData, '%{{', '}}'); - $chainContent = $placeholderResolver->resolvePlaceholder($chainContent); - - $parser = new Parser(); - $configData = $parser->parse($chainContent); - - $commands = []; - if (array_key_exists('commands', $configData)) { - $commands = $configData['commands']; - } - - foreach ($commands as $command) { - $moduleInputs = []; - $arguments = !empty($command['arguments']) ? $command['arguments'] : []; - $options = !empty($command['options']) ? $command['options'] : []; - - foreach ($arguments as $key => $value) { - $moduleInputs[$key] = is_null($value) ? '' : $value; - } - - foreach ($options as $key => $value) { - $moduleInputs['--'.$key] = is_null($value) ? '' : $value; - } - - $parameterOptions = $input->getOptions(); - unset($parameterOptions['file']); - foreach ($parameterOptions as $key => $value) { - if ($value===true) { - $moduleInputs['--' . $key] = true; - } - } - - $this->chainQueue->addCommand( - $command['command'], - $moduleInputs, - $interactive, - $learning - ); - } - - return 0; - } -} diff --git a/src/Command/Chain/ChainDebugCommand.php b/src/Command/Chain/ChainDebugCommand.php deleted file mode 100644 index a98c45aba..000000000 --- a/src/Command/Chain/ChainDebugCommand.php +++ /dev/null @@ -1,87 +0,0 @@ -configurationManager = $configurationManager; - $this->extensionManager = $extensionManager; - parent::__construct(); - } - /** - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('chain:debug') - ->setDescription($this->trans('commands.chain.debug.description')); - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - $files = $this->getChainFiles(); - - foreach ($files as $directory => $chainFiles) { - $io->info($this->trans('commands.chain.debug.messages.directory'), false); - $io->comment($directory); - - $tableHeader = [ - $this->trans('commands.chain.debug.messages.file') - ]; - - $tableRows = []; - foreach ($chainFiles as $file) { - $tableRows[] = $file; - } - - $io->table($tableHeader, $tableRows); - } - - return 0; - } -} diff --git a/src/Command/CommandDependencies.php b/src/Command/CommandDependencies.php deleted file mode 100644 index 35dbae092..000000000 --- a/src/Command/CommandDependencies.php +++ /dev/null @@ -1,53 +0,0 @@ -reader = $reader; - } - - /** - * @param ReflectionClass $class - * @return array - */ - public function read(ReflectionClass $class) - { - /** - * @var DrupalCommand $definition - */ - $definitions = $this->reader->getClassAnnotations($class); - - $dependencies = []; - foreach ($definitions as $definition) { - if ($definition instanceof DrupalCommand) { - // var_export($class); - foreach ($definition->dependencies as $dependency) { - // echo $definition->getName() . PHP_EOL; - $dependencies[] = $dependency; - } - } - } - - return $dependencies; - } -} diff --git a/src/Command/Config/DeleteCommand.php b/src/Command/Config/DeleteCommand.php index bc4c5b602..75a05096d 100644 --- a/src/Command/Config/DeleteCommand.php +++ b/src/Command/Config/DeleteCommand.php @@ -6,42 +6,46 @@ namespace Drupal\Console\Command\Config; -use Drupal\Core\Config\FileStorage; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Yaml\Exception\RuntimeException; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; +use Drupal\Core\Config\StorageInterface; use Drupal\Core\Config\CachedStorage; use Drupal\Core\Config\ConfigFactory; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; class DeleteCommand extends Command { - use CommandTrait; - protected $allConfig = []; - /** @var ConfigFactory */ + /** + * @var ConfigFactory + */ protected $configFactory; - /** @var CachedStorage */ + /** + * @var CachedStorage + */ protected $configStorage; - /** @var FileStorage */ + /** + * @var StorageInterface + */ protected $configStorageSync; /** * DeleteCommand constructor. - * @param ConfigFactory $configFactory - * @param CachedStorage $configStorage - * @param FileStorage $configStorageSync + * + * @param ConfigFactory $configFactory + * @param CachedStorage $configStorage + * @param StorageInterface $configStorageSync */ public function __construct( - ConfigFactory $configFactory , + ConfigFactory $configFactory, CachedStorage $configStorage, - FileStorage $configStorageSync + StorageInterface $configStorageSync ) { $this->configFactory = $configFactory; $this->configStorage = $configStorage; @@ -66,7 +70,7 @@ protected function configure() 'name', InputArgument::OPTIONAL, $this->trans('commands.config.delete.arguments.name') - ); + )->setAliases(['cd']); } /** diff --git a/src/Command/Config/DiffCommand.php b/src/Command/Config/DiffCommand.php index 117154b1b..708dd5f39 100644 --- a/src/Command/Config/DiffCommand.php +++ b/src/Command/Config/DiffCommand.php @@ -12,24 +12,26 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Config\CachedStorage; use Drupal\Core\Config\ConfigManager; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; class DiffCommand extends Command { - use CommandTrait; - - /** @var CachedStorage */ + /** + * @var CachedStorage + */ protected $configStorage; - /** @var ConfigManager */ + /** + * @var ConfigManager + */ protected $configManager; /** * DiffCommand constructor. + * * @param CachedStorage $configStorage * @param ConfigManager $configManager */ @@ -74,7 +76,7 @@ protected function configure() null, InputOption::VALUE_NONE, $this->trans('commands.config.diff.options.reverse') - ); + )->setAliases(['cdi']); } /** @@ -89,7 +91,7 @@ protected function interact(InputInterface $input, OutputInterface $output) if (!$directory) { $directory = $io->choice( $this->trans('commands.config.diff.questions.directories'), - array_keys($config_directories), + $config_directories, CONFIG_SYNC_DIRECTORY ); @@ -102,8 +104,12 @@ protected function interact(InputInterface $input, OutputInterface $output) */ protected function execute(InputInterface $input, OutputInterface $output) { + global $config_directories; $io = new DrupalStyle($input, $output); - $directory = $input->getArgument('directory'); + $directory = $input->getArgument('directory') ?: CONFIG_SYNC_DIRECTORY; + if (array_key_exists($directory, $config_directories)) { + $directory = $config_directories[$directory]; + } $source_storage = new FileStorage($directory); if ($input->getOption('reverse')) { diff --git a/src/Command/Config/EditCommand.php b/src/Command/Config/EditCommand.php index 1ccb592e7..a3ef54d9f 100644 --- a/src/Command/Config/EditCommand.php +++ b/src/Command/Config/EditCommand.php @@ -17,32 +17,36 @@ use Drupal\Component\Serialization\Yaml; use Drupal\Core\Config\CachedStorage; use Drupal\Core\Config\ConfigFactory; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; -use Drupal\Console\Utils\ConfigurationManager; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; +use Drupal\Console\Core\Utils\ConfigurationManager; class EditCommand extends Command { - use CommandTrait; - - /** @var ConfigFactory */ + /** + * @var ConfigFactory + */ protected $configFactory; - /** @var CachedStorage */ + /** + * @var CachedStorage + */ protected $configStorage; - /** @var ConfigurationManager */ + /** + * @var ConfigurationManager + */ protected $configurationManager; /** * EditCommand constructor. - * @param ConfigFactory $configFactory - * @param CachedStorage $configStorage - * @param ConfigurationManager $configurationManager + * + * @param ConfigFactory $configFactory + * @param CachedStorage $configStorage + * @param ConfigurationManager $configurationManager */ public function __construct( - ConfigFactory $configFactory , + ConfigFactory $configFactory, CachedStorage $configStorage, ConfigurationManager $configurationManager ) { @@ -68,7 +72,8 @@ protected function configure() 'editor', InputArgument::OPTIONAL, $this->trans('commands.config.edit.arguments.editor') - ); + ) + ->setAliases(['ced']); } /** @@ -90,7 +95,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if (!$configName) { $io->error($this->trans('commands.config.edit.messages.no-config')); - return; + return 1; } try { @@ -99,12 +104,12 @@ protected function execute(InputInterface $input, OutputInterface $output) } catch (IOExceptionInterface $e) { $io->error($this->trans('commands.config.edit.messages.no-directory').' '.$e->getPath()); - return; + return 1; } if (!$editor) { $editor = $this->getEditor(); } - $processBuilder = new ProcessBuilder(array($editor, $configFile)); + $processBuilder = new ProcessBuilder([$editor, $configFile]); $process = $processBuilder->getProcess(); $process->setTty('true'); $process->run(); @@ -115,9 +120,13 @@ protected function execute(InputInterface $input, OutputInterface $output) $config->save(); $fileSystem->remove($configFile); } + if (!$process->isSuccessful()) { $io->error($process->getErrorOutput()); + return 1; } + + return 0; } protected function interact(InputInterface $input, OutputInterface $output) @@ -128,7 +137,7 @@ protected function interact(InputInterface $input, OutputInterface $output) if (!$configName) { $configNames = $this->configFactory->listAll(); $configName = $io->choice( - 'Choose a configuration', + $this->trans('commands.config.edit.messages.choose-configuration'), $configNames ); @@ -163,7 +172,7 @@ protected function getEditor() return trim($editor); } - $processBuilder = new ProcessBuilder(array('bash')); + $processBuilder = new ProcessBuilder(['bash']); $process = $processBuilder->getProcess(); $process->setCommandLine('echo ${EDITOR:-${VISUAL:-vi}}'); $process->run(); diff --git a/src/Command/Config/ExportCommand.php b/src/Command/Config/ExportCommand.php index c379a82e9..979aa2606 100644 --- a/src/Command/Config/ExportCommand.php +++ b/src/Command/Config/ExportCommand.php @@ -9,30 +9,39 @@ use Drupal\Core\Archiver\ArchiveTar; use Drupal\Component\Serialization\Yaml; +use Drupal\Core\Config\ConfigManagerInterface; +use Drupal\Core\Config\StorageInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Symfony\Component\Filesystem\Filesystem; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Core\Config\ConfigManager; - class ExportCommand extends Command { - use CommandTrait; - - /** @var ConfigManager */ + /** + * @var ConfigManager + */ protected $configManager; + /** + * @var StorageInterface + */ + protected $storage; + /** * ExportCommand constructor. - * @param ConfigManager $configManager + * + * @param ConfigManagerInterface $configManager + * @param StorageInterface $storage */ - public function __construct(ConfigManager $configManager ) { - $this->configManager = $configManager; + public function __construct(ConfigManagerInterface $configManager, StorageInterface $storage) + { parent::__construct(); + $this->configManager = $configManager; + $this->storage = $storage; } /** @@ -47,14 +56,25 @@ protected function configure() 'directory', null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.config.export.arguments.directory') + $this->trans('commands.config.export.options.directory') ) ->addOption( 'tar', - false, + null, InputOption::VALUE_NONE, - $this->trans('commands.config.export.arguments.tar') - ); + $this->trans('commands.config.export.options.tar') + )->addOption( + 'remove-uuid', + null, + InputOption::VALUE_NONE, + $this->trans('commands.config.export.options.remove-uuid') + )->addOption( + 'remove-config-hash', + null, + InputOption::VALUE_NONE, + $this->trans('commands.config.export.options.remove-config-hash') + ) + ->setAliases(['ce']); } /** @@ -66,16 +86,29 @@ protected function execute(InputInterface $input, OutputInterface $output) $directory = $input->getOption('directory'); $tar = $input->getOption('tar'); + $removeUuid = $input->getOption('remove-uuid'); + $removeHash = $input->getOption('remove-config-hash'); if (!$directory) { $directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY); } - if ($tar) { - if (!is_dir($directory)) { - mkdir($directory, 0777, true); - } + $fileSystem = new Filesystem(); + try { + $fileSystem->mkdir($directory); + } catch (IOExceptionInterface $e) { + $io->error( + sprintf( + $this->trans('commands.config.export.messages.error'), + $e->getPath() + ) + ); + } + + // Remove previous yaml files before creating new ones + array_map('unlink', glob($directory . '/*')); + if ($tar) { $dateTime = new \DateTime(); $archiveFile = sprintf( @@ -89,41 +122,51 @@ protected function execute(InputInterface $input, OutputInterface $output) try { // Get raw configuration data without overrides. foreach ($this->configManager->getConfigFactory()->listAll() as $name) { + $configName = "$name.yml"; $configData = $this->configManager->getConfigFactory()->get($name)->getRawData(); - $configName = sprintf('%s.yml', $name); + if ($removeUuid) { + unset($configData['uuid']); + } + if ($removeHash) { + unset($configData['_core']['default_config_hash']); + } $ymlData = Yaml::encode($configData); if ($tar) { - $archiveTar->addString( - $configName, - $ymlData - ); - continue; + $archiveTar->addString($configName, $ymlData); + } else { + file_put_contents("$directory/$configName", $ymlData); } - - $configFileName = sprintf('%s/%s', $directory, $configName); - - $fileSystem = new Filesystem(); - try { - $fileSystem->mkdir($directory); - } catch (IOExceptionInterface $e) { - $io->error( - sprintf( - $this->trans('commands.config.export.messages.error'), - $e->getPath() - ) - ); + } + // Get all override data from the remaining collections. + foreach ($this->storage->getAllCollectionNames() as $collection) { + $collection_storage = $this->storage->createCollection($collection); + foreach ($collection_storage->listAll() as $name) { + $configName = str_replace('.', '/', $collection) . "/$name.yml"; + $configData = $collection_storage->read($name); + if ($removeUuid) { + unset($configData['uuid']); + } + if ($removeHash) { + unset($configData['_core']['default_config_hash']); + } + + $ymlData = Yaml::encode($configData); + if ($tar) { + $archiveTar->addString($configName, $ymlData); + } else { + file_put_contents("$directory/$configName", $ymlData); + } } - file_put_contents($configFileName, $ymlData); } } catch (\Exception $e) { $io->error($e->getMessage()); } $io->info( - sprintf( - $this->trans('commands.config.export.messages.directory'), - $directory + sprintf( + $this->trans('commands.config.export.messages.directory'), + $directory ) ); } diff --git a/src/Command/Config/ExportContentTypeCommand.php b/src/Command/Config/ExportContentTypeCommand.php index a233a8b08..f53c3e74c 100644 --- a/src/Command/Config/ExportContentTypeCommand.php +++ b/src/Command/Config/ExportContentTypeCommand.php @@ -12,37 +12,50 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Config\CachedStorage; use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Command\Shared\ExportTrait; +use Drupal\Console\Extension\Manager; class ExportContentTypeCommand extends Command { - use CommandTrait; use ModuleTrait; use ExportTrait; - /** @var EntityTypeManager */ + /** + * @var EntityTypeManagerInterface + */ protected $entityTypeManager; - /** @var CachedStorage */ + /** + * @var CachedStorage + */ protected $configStorage; + + /** + * @var Manager + */ + protected $extensionManager; + protected $configExport; /** * ExportContentTypeCommand constructor. + * * @param EntityTypeManagerInterface $entityTypeManager - * @param CachedStorage $configStorage + * @param CachedStorage $configStorage + * @param Manager $extensionManager */ public function __construct( EntityTypeManagerInterface $entityTypeManager, - CachedStorage $configStorage + CachedStorage $configStorage, + Manager $extensionManager ) { $this->entityTypeManager = $entityTypeManager; $this->configStorage = $configStorage; + $this->extensionManager = $extensionManager; parent::__construct(); } @@ -54,19 +67,20 @@ protected function configure() $this ->setName('config:export:content:type') ->setDescription($this->trans('commands.config.export.content.type.description')) - ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) ->addArgument( 'content-type', InputArgument::REQUIRED, $this->trans('commands.config.export.content.type.arguments.content-type') )->addOption( 'optional-config', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.config.export.content.type.options.optional-config') - ); + ) + ->setAliases(['cect']); - $this->configExport = array(); + $this->configExport = []; } /** @@ -87,9 +101,8 @@ protected function interact(InputInterface $input, OutputInterface $output) // --content-type argument $contentType = $input->getArgument('content-type'); if (!$contentType) { - $entityTypeManager = $this->getDrupalService('entity_type.manager'); - $bundles_entities = $entityTypeManager->getStorage('node_type')->loadMultiple(); - $bundles = array(); + $bundles_entities = $this->entityTypeManager->getStorage('node_type')->loadMultiple(); + $bundles = []; foreach ($bundles_entities as $entity) { $bundles[$entity->id()] = $entity->label(); } @@ -127,7 +140,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $contentTypeNameConfig = $this->getConfiguration($contentTypeName); - $this->configExport[$contentTypeName] = array('data' => $contentTypeNameConfig, 'optional' => $optionalConfig); + $this->configExport[$contentTypeName] = ['data' => $contentTypeNameConfig, 'optional' => $optionalConfig]; $this->getFields($contentType, $optionalConfig); @@ -135,7 +148,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->getViewDisplays($contentType, $optionalConfig); - $this->exportConfigToModule($module, $io, $this->trans('commands.config.export.content.type.messages.content_type_exported')); + $this->exportConfigToModule($module, $io, $this->trans('commands.config.export.content.type.messages.content-type-exported')); } protected function getFields($contentType, $optional = false) @@ -148,7 +161,7 @@ protected function getFields($contentType, $optional = false) $field_name_config = $this->getConfiguration($field_name); // Only select fields related with content type if ($field_name_config['bundle'] == $contentType) { - $this->configExport[$field_name] = array('data' => $field_name_config, 'optional' => $optional); + $this->configExport[$field_name] = ['data' => $field_name_config, 'optional' => $optional]; // Include dependencies in export files if ($dependencies = $this->fetchDependencies($field_name_config, 'config')) { $this->resolveDependencies($dependencies, $optional); @@ -166,7 +179,7 @@ protected function getFormDisplays($contentType, $optional = false) $form_display_name_config = $this->getConfiguration($form_display_name); // Only select fields related with content type if ($form_display_name_config['bundle'] == $contentType) { - $this->configExport[$form_display_name] = array('data' => $form_display_name_config, 'optional' => $optional); + $this->configExport[$form_display_name] = ['data' => $form_display_name_config, 'optional' => $optional]; // Include dependencies in export files if ($dependencies = $this->fetchDependencies($form_display_name_config, 'config')) { $this->resolveDependencies($dependencies, $optional); @@ -184,7 +197,7 @@ protected function getViewDisplays($contentType, $optional = false) $view_display_name_config = $this->getConfiguration($view_display_name); // Only select fields related with content type if ($view_display_name_config['bundle'] == $contentType) { - $this->configExport[$view_display_name] = array('data' => $view_display_name_config, 'optional' => $optional); + $this->configExport[$view_display_name] = ['data' => $view_display_name_config, 'optional' => $optional]; // Include dependencies in export files if ($dependencies = $this->fetchDependencies($view_display_name_config, 'config')) { $this->resolveDependencies($dependencies, $optional); @@ -192,4 +205,4 @@ protected function getViewDisplays($contentType, $optional = false) } } } -} \ No newline at end of file +} diff --git a/src/Command/Config/ExportSingleCommand.php b/src/Command/Config/ExportSingleCommand.php index f217c44fc..b3086265a 100644 --- a/src/Command/Config/ExportSingleCommand.php +++ b/src/Command/Config/ExportSingleCommand.php @@ -12,16 +12,16 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Config\CachedStorage; -use Drupal\Console\Style\DrupalStyle; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Command\Shared\ExportTrait; +use Drupal\Console\Extension\Manager; +use Webmozart\PathUtil\Path; class ExportSingleCommand extends Command { - use CommandTrait; use ExportTrait; /** @@ -29,25 +29,38 @@ class ExportSingleCommand extends Command */ protected $definitions; - /** @var EntityTypeManagerInterface */ + /** + * @var EntityTypeManagerInterface + */ protected $entityTypeManager; - /** @var CachedStorage */ + /** + * @var CachedStorage + */ protected $configStorage; + /** + * @var Manager + */ + protected $extensionManager; + protected $configExport; /** * ExportSingleCommand constructor. + * * @param EntityTypeManagerInterface $entityTypeManager - * @param CachedStorage $configStorage + * @param CachedStorage $configStorage + * @param Manager $extensionManager */ public function __construct( EntityTypeManagerInterface $entityTypeManager, - CachedStorage $configStorage + CachedStorage $configStorage, + Manager $extensionManager ) { $this->entityTypeManager = $entityTypeManager; $this->configStorage = $configStorage; + $this->extensionManager = $extensionManager; parent::__construct(); } @@ -57,39 +70,45 @@ public function __construct( protected function configure() { $this - ->setName('config:export:single') - ->setDescription($this->trans('commands.config.export.single.description')) - ->addArgument( - 'config-name', - InputArgument::REQUIRED, - $this->trans('commands.config.export.single.arguments.config-name') - ) - ->addOption( - 'directory', - '', - InputOption::VALUE_OPTIONAL, - $this->trans('commands.config.export.arguments.directory') - ) - ->addOption( - 'include-dependencies', - '', - InputOption::VALUE_NONE, - $this->trans('commands.config.export.single.options.include-dependencies') - )->addOption( - 'module', '', - InputOption::VALUE_OPTIONAL, - $this->trans('commands.common.options.module') - )->addOption( - 'optional-config', - '', - InputOption::VALUE_OPTIONAL, - $this->trans('commands.config.export.single.options.optional-config') - )->addOption( - 'remove-uuid', - '', - InputOption::VALUE_NONE, - $this->trans('commands.config.export.single.options.remove-uuid') - ); + ->setName('config:export:single') + ->setDescription($this->trans('commands.config.export.single.description')) + ->addOption( + 'name', + null, + InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, + $this->trans('commands.config.export.single.options.name') + )->addOption( + 'directory', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.config.export.arguments.directory') + )->addOption( + 'module', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.common.options.module') + )->addOption( + 'include-dependencies', + null, + InputOption::VALUE_NONE, + $this->trans('commands.config.export.single.options.include-dependencies') + )->addOption( + 'optional', + null, + InputOption::VALUE_NONE, + $this->trans('commands.config.export.single.options.optional') + )->addOption( + 'remove-uuid', + null, + InputOption::VALUE_NONE, + $this->trans('commands.config.export.single.options.remove-uuid') + )->addOption( + 'remove-config-hash', + null, + InputOption::VALUE_NONE, + $this->trans('commands.config.export.single.options.remove-config-hash') + ) + ->setAliases(['ces']); } /* @@ -103,15 +122,15 @@ protected function getConfigTypes() } } $entity_types = array_map( - function ($definition) { - return $definition->getLabel(); - }, $this->definitions + function ($definition) { + return $definition->getLabel(); + }, $this->definitions ); uasort($entity_types, 'strnatcasecmp'); - $config_types = array( - 'system.simple' => $this->trans('commands.config.export.single.options.simple-configuration'), - ) + $entity_types; + $config_types = [ + 'system.simple' => $this->trans('commands.config.export.single.options.simple-configuration'), + ] + $entity_types; return $config_types; } @@ -121,7 +140,7 @@ function ($definition) { */ protected function getConfigNames($config_type) { - + $names = []; // For a given entity type, load all entities. if ($config_type && $config_type !== 'system.simple') { $entity_storage = $this->entityTypeManager->getStorage($config_type); @@ -135,9 +154,9 @@ protected function getConfigNames($config_type) else { // Gather the config entity prefixes. $config_prefixes = array_map( - function ($definition) { - return $definition->getConfigPrefix() . '.'; - }, $this->definitions + function ($definition) { + return $definition->getConfigPrefix() . '.'; + }, $this->definitions ); // Find all config, and then filter our anything matching a config prefix. @@ -164,50 +183,56 @@ protected function interact(InputInterface $input, OutputInterface $output) $config_types = $this->getConfigTypes(); - $config_name = $input->getArgument('config-name'); - if (!$config_name) { - $config_type = $io->choiceNoList( - $this->trans('commands.config.export.single.questions.config-type'), - array_keys($config_types), - $this->trans('commands.config.export.single.options.simple-configuration') + $name = $input->getOption('name'); + if (!$name) { + $type = $io->choiceNoList( + $this->trans('commands.config.export.single.questions.config-type'), + array_keys($config_types), + 'system.simple' ); - $config_names = $this->getConfigNames($config_type); + $names = $this->getConfigNames($type); - $config_name = $io->choiceNoList( - $this->trans('commands.config.export.single.questions.config-name'), - array_keys($config_names) + $name = $io->choiceNoList( + $this->trans('commands.config.export.single.questions.name'), + array_keys($names) ); - if ($config_type !== 'system.simple') { - $definition = $this->entityTypeManager->getDefinition($config_type); - $config_name = $definition->getConfigPrefix() . '.' . $config_name; + if ($type !== 'system.simple') { + $definition = $this->entityTypeManager->getDefinition($type); + $name = $definition->getConfigPrefix() . '.' . $name; } - $input->setArgument('config-name', $config_name); + $input->setOption('name', [$name]); } $module = $input->getOption('module'); - if ($module) { - $optionalConfig = $input->getOption('optional-config'); + $optionalConfig = $input->getOption('optional'); if (!$optionalConfig) { $optionalConfig = $io->confirm( - $this->trans('commands.config.export.single.questions.optional-config'), - true + $this->trans('commands.config.export.single.questions.optional'), + true ); - $input->setOption('optional-config', $optionalConfig); + $input->setOption('optional', $optionalConfig); } } + if (!$input->getOption('remove-uuid')) { $removeUuid = $io->confirm( - $this->trans('commands.config.export.single.questions.remove-uuid'), - true + $this->trans('commands.config.export.single.questions.remove-uuid'), + true ); $input->setOption('remove-uuid', $removeUuid); } + if (!$input->getOption('remove-config-hash')) { + $removeHash = $io->confirm( + $this->trans('commands.config.export.single.questions.remove-config-hash'), + true + ); + $input->setOption('remove-config-hash', $removeHash); + } } - /** * {@inheritdoc} */ @@ -217,40 +242,63 @@ protected function execute(InputInterface $input, OutputInterface $output) $directory = $input->getOption('directory'); $module = $input->getOption('module'); - $configName = $input->getArgument('config-name'); - $optionalConfig = $input->getOption('optional-config'); + $name = $input->getOption('name'); + $optional = $input->getOption('optional'); $removeUuid = $input->getOption('remove-uuid'); + $removeHash = $input->getOption('remove-config-hash'); + $includeDependencies = $input->getOption('include-dependencies'); + + foreach ($name as $nameItem) { + $config = $this->getConfiguration( + $nameItem, + $removeUuid, + $removeHash + ); - if (!$removeUuid) { - $config = $this->getConfiguration($configName, true); - } else { - $config = $this->getConfiguration($configName, false); - } - if ($config) { - if (!$directory) { - $directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY); - } - - $this->configExport[$configName] = array('data' => $config, 'optional' => $optionalConfig); + if ($config) { + $this->configExport[$nameItem] = [ + 'data' => $config, + 'optional' => $optional + ]; - if ($input->getOption('include-dependencies')) { - // Include config dependencies in export files - if ($dependencies = $this->fetchDependencies($config, 'config')) { - $this->resolveDependencies($dependencies, $optionalConfig); + if ($includeDependencies) { + // Include config dependencies in export files + if ($dependencies = $this->fetchDependencies($config, 'config')) { + $this->resolveDependencies($dependencies, $optional); + } } + } else { + $io->error($this->trans('commands.config.export.single.messages.config-not-found')); } - } else { - $io->error($this->trans('commands.config.export.single.messages.config-not-found')); } - if (!$module) { - if (!$directory) { - $directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY); - } + if ($module) { + $this->exportConfigToModule( + $module, + $io, + $this->trans( + 'commands.config.export.single.messages.config-exported' + ) + ); + + return 0; + } - $this->exportConfig($directory, $io, $this->trans('commands.config.export.single.messages.config_exported')); + if (!is_dir($directory)) { + $directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY); } else { - $this->exportConfigToModule($module, $io, $this->trans('commands.config.export.single.messages.config_exported')); + $directory = Path::canonicalize($directory); + if (!file_exists($directory)) { + mkdir($directory, 0755, true); + } } + + $this->exportConfig( + $directory, + $io, + $this->trans('commands.config.export.single.messages.config-exported') + ); + + return 0; } } diff --git a/src/Command/Config/ExportViewCommand.php b/src/Command/Config/ExportViewCommand.php index 1f15a87ca..87df39718 100644 --- a/src/Command/Config/ExportViewCommand.php +++ b/src/Command/Config/ExportViewCommand.php @@ -11,38 +11,43 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Config\CachedStorage; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Command\Shared\ExportTrait; use Drupal\Console\Extension\Manager; class ExportViewCommand extends Command { - use CommandTrait; use ModuleTrait; use ExportTrait; protected $configExport; - /** @var EntityTypeManagerInterface */ + /** + * @var EntityTypeManagerInterface + */ protected $entityTypeManager; - /** @var CachedStorage */ + /** + * @var CachedStorage + */ protected $configStorage; - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** * ExportViewCommand constructor. + * * @param EntityTypeManagerInterface $entityTypeManager - * @param CachedStorage $configStorage - * @param Manager $extensionManager + * @param CachedStorage $configStorage + * @param Manager $extensionManager */ public function __construct( EntityTypeManagerInterface $entityTypeManager, @@ -62,7 +67,7 @@ protected function configure() ->setName('config:export:view') ->setDescription($this->trans('commands.config.export.view.description')) ->addOption( - 'module', '', + 'module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module') ) @@ -73,16 +78,17 @@ protected function configure() ) ->addOption( 'optional-config', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.config.export.view.options.optional-config') ) ->addOption( 'include-module-dependencies', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.config.export.view.options.include-module-dependencies') - ); + ) + ->setAliases(['cev']); } /** @@ -103,7 +109,6 @@ protected function interact(InputInterface $input, OutputInterface $output) // view-id argument $viewId = $input->getArgument('view-id'); if (!$viewId) { - $views = $this->entityTypeManager->getStorage('view')->loadMultiple(); $viewList = []; @@ -151,7 +156,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $viewNameConfig = $this->getConfiguration($viewTypeName); - $this->configExport[$viewTypeName] = array('data' => $viewNameConfig, 'optional' => $optionalConfig); + $this->configExport[$viewTypeName] = ['data' => $viewNameConfig, 'optional' => $optionalConfig]; // Include config dependencies in export files if ($dependencies = $this->fetchDependencies($viewNameConfig, 'config')) { @@ -165,6 +170,6 @@ protected function execute(InputInterface $input, OutputInterface $output) } } - $this->exportConfigToModule($module, $io, $this->trans('commands.views.export.messages.view_exported')); + $this->exportConfigToModule($module, $io, $this->trans('commands.views.export.messages.view-exported')); } } diff --git a/src/Command/Config/ImportCommand.php b/src/Command/Config/ImportCommand.php index 5ee0a2d57..90eeb26fa 100644 --- a/src/Command/Config/ImportCommand.php +++ b/src/Command/Config/ImportCommand.php @@ -6,17 +6,13 @@ namespace Drupal\Console\Command\Config; -use Symfony\Component\Config\Definition\Exception\Exception; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Yaml\Parser; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Config\CachedStorage; use Drupal\Core\Config\ConfigManager; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Core\Config\ConfigImporterException; use Drupal\Core\Config\ConfigImporter; use Drupal\Core\Config\FileStorage; @@ -24,16 +20,19 @@ class ImportCommand extends Command { - use CommandTrait; - - /** @var CachedStorage */ + /** + * @var CachedStorage + */ protected $configStorage; - /** @var ConfigManager */ + /** + * @var ConfigManager + */ protected $configManager; /** * ImportCommand constructor. + * * @param CachedStorage $configStorage * @param ConfigManager $configManager */ @@ -68,10 +67,11 @@ protected function configure() ) ->addOption( 'remove-files', - false, + null, InputOption::VALUE_NONE, $this->trans('commands.config.import.options.remove-files') - ); + ) + ->setAliases(['ci']); } /** @@ -100,6 +100,8 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($this->configImport($io, $storage_comparer)) { $io->success($this->trans('commands.config.import.messages.imported')); + } else { + return 1; } } @@ -122,10 +124,11 @@ private function configImport(DrupalStyle $io, StorageComparer $storage_comparer $io->success($this->trans('commands.config.import.messages.already-imported')); } else { try { - $config_importer->import(); $io->info($this->trans('commands.config.import.messages.importing')); + $config_importer->import(); + return true; } catch (ConfigImporterException $e) { - $message = 'The import failed due for the following reasons:' . "\n"; + $message = $this->trans('commands.config.import.messages.import-fail') . "\n"; $message .= implode("\n", $config_importer->getErrors()); $io->error( sprintf( diff --git a/src/Command/Config/ImportSingleCommand.php b/src/Command/Config/ImportSingleCommand.php index 3b080c3b2..5854fc80a 100644 --- a/src/Command/Config/ImportSingleCommand.php +++ b/src/Command/Config/ImportSingleCommand.php @@ -6,32 +6,35 @@ */ namespace Drupal\Console\Command\Config; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Yaml\Parser; -use Symfony\Component\Console\Command\Command; +use Drupal\config\StorageReplaceDataWrapper; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Core\Config\CachedStorage; -use Drupal\Core\Config\ConfigManager; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; use Drupal\Core\Config\ConfigImporter; use Drupal\Core\Config\ConfigImporterException; +use Drupal\Core\Config\ConfigManager; use Drupal\Core\Config\StorageComparer; -use Drupal\config\StorageReplaceDataWrapper; +use Drupal\Console\Core\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Yaml\Parser; +use Webmozart\PathUtil\Path; class ImportSingleCommand extends Command { - use CommandTrait; - - /** @var CachedStorage */ + /** + * @var CachedStorage + */ protected $configStorage; - /** @var ConfigManager */ + /** + * @var ConfigManager + */ protected $configManager; /** * ImportSingleCommand constructor. + * * @param CachedStorage $configStorage * @param ConfigManager $configManager */ @@ -52,14 +55,18 @@ protected function configure() $this ->setName('config:import:single') ->setDescription($this->trans('commands.config.import.single.description')) - ->addArgument( - 'name', InputArgument::REQUIRED, - $this->trans('commands.config.import.single.arguments.name') + ->addOption( + 'file', + null, + InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, + $this->trans('commands.config.import.single.options.file') + )->addOption( + 'directory', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.config.import.arguments.directory') ) - ->addArgument( - 'file', InputArgument::REQUIRED, - $this->trans('commands.config.import.single.arguments.file') - ); + ->setAliases(['cis']); } /** @@ -69,38 +76,58 @@ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); - $configName = $input->getArgument('name'); - $fileName = $input->getArgument('file'); + $file = $input->getOption('file'); + $directory = $input->getOption('directory'); - $ymlFile = new Parser(); + if (!$file) { + $io->error($this->trans('commands.config.import.single..message.missing-file')); - if (!empty($fileName) && file_exists($fileName)) { - $value = $ymlFile->parse(file_get_contents($fileName)); - } else { - $value = $ymlFile->parse(stream_get_contents(fopen("php://stdin", "r"))); + return 1; } - - if (empty($value)) { - $io->error($this->trans('commands.config.import.single.messages.empty-value')); - - return; + if ($directory) { + $directory = Path::canonicalize($directory); } + $names = []; try { - $source_storage = new StorageReplaceDataWrapper($this->configStorage); - $source_storage->replaceData($configName, $value); - $storage_comparer = new StorageComparer( + $source_storage = new StorageReplaceDataWrapper( + $this->configStorage + ); + + foreach ($file as $fileItem) { + $configFile = $fileItem; + if ($directory) { + $configFile = Path::canonicalize($directory) . '/' . $fileItem; + } + + if (file_exists($configFile)) { + $name = Path::getFilenameWithoutExtension($configFile); + $ymlFile = new Parser(); + $value = $ymlFile->parse(file_get_contents($configFile)); + $source_storage->delete($name); + $source_storage->write($name, $value); + $names[] = $name; + continue; + } + + $io->error($this->trans('commands.config.import.single.messages.empty-value')); + return 1; + } + + $storageComparer = new StorageComparer( $source_storage, $this->configStorage, $this->configManager ); - if ($this->configImport($io, $storage_comparer)) { + if ($this->configImport($io, $storageComparer)) { $io->success( sprintf( - $this->trans('commands.config.import.single.messages.success'), - $configName + $this->trans( + 'commands.config.import.single.messages.success' + ), + implode(',', $names) ) ); } @@ -111,10 +138,10 @@ protected function execute(InputInterface $input, OutputInterface $output) } } - private function configImport($io, StorageComparer $storage_comparer) + private function configImport($io, StorageComparer $storageComparer) { - $config_importer = new ConfigImporter( - $storage_comparer, + $configImporter = new ConfigImporter( + $storageComparer, \Drupal::service('event_dispatcher'), \Drupal::service('config.manager'), \Drupal::lock(), @@ -125,23 +152,25 @@ private function configImport($io, StorageComparer $storage_comparer) \Drupal::service('string_translation') ); - if ($config_importer->alreadyImporting()) { + if ($configImporter->alreadyImporting()) { $io->success($this->trans('commands.config.import.messages.already-imported')); } else { try { - if ($config_importer->validate()) { - $sync_steps = $config_importer->initialize(); + if ($configImporter->validate()) { + $sync_steps = $configImporter->initialize(); foreach ($sync_steps as $step) { - $context = array(); + $context = []; do { - $config_importer->doSyncStep($step, $context); + $configImporter->doSyncStep($step, $context); } while ($context['finished'] < 1); } + + return true; } } catch (ConfigImporterException $e) { - $message = 'The import failed due for the following reasons:' . "\n"; - $message .= implode("\n", $config_importer->getErrors()); + $message = $this->trans('commands.config.import.messages.import-fail') . "\n"; + $message .= implode("\n", $configImporter->getErrors()); $io->error( sprintf( $this->trans('commands.site.import.local.messages.error-writing'), @@ -165,20 +194,22 @@ private function configImport($io, StorageComparer $storage_comparer) protected function interact(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); - $name = $input->getArgument('name'); - if (!$name) { - $name = $io->ask( - $this->trans('commands.config.import.single.questions.name') - ); - $input->setArgument('name', $name); - } + $file = $input->getOption('file'); + $directory = $input->getOption('directory'); - $file = $input->getArgument('file'); if (!$file) { $file = $io->ask( $this->trans('commands.config.import.single.questions.file') ); - $input->setArgument('file', $file); + $input->setOption('file', [$file]); + + if (!$directory && !Path::isAbsolute($file)) { + $directory = $io->ask( + $this->trans('commands.config.import.single.questions.directory') + ); + + $input->setOption('directory', $directory); + } } } } diff --git a/src/Command/Config/OverrideCommand.php b/src/Command/Config/OverrideCommand.php index dd6c40c24..e1f1b2beb 100644 --- a/src/Command/Config/OverrideCommand.php +++ b/src/Command/Config/OverrideCommand.php @@ -10,24 +10,26 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Config\CachedStorage; use Drupal\Core\Config\ConfigFactory; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; class OverrideCommand extends Command { - use CommandTrait; - - /** @var CachedStorage */ + /** + * @var CachedStorage + */ protected $configStorage; - /** @var ConfigFactory */ + /** + * @var ConfigFactory + */ protected $configFactory; /** * OverrideCommand constructor. + * * @param CachedStorage $configStorage * @param ConfigFactory $configFactory */ @@ -50,8 +52,16 @@ protected function configure() InputArgument::REQUIRED, $this->trans('commands.config.override.arguments.name') ) - ->addArgument('key', InputArgument::REQUIRED, $this->trans('commands.config.override.arguments.key')) - ->addArgument('value', InputArgument::REQUIRED, $this->trans('commands.config.override.arguments.value')); + ->addArgument( + 'key', + InputArgument::REQUIRED, + $this->trans('commands.config.override.arguments.key')) + ->addArgument( + 'value', + InputArgument::REQUIRED, + $this->trans('commands.config.override.arguments.value') + ) + ->setAliases(['co']); } /** diff --git a/src/Command/Config/PrintConfigValidationTrait.php b/src/Command/Config/PrintConfigValidationTrait.php new file mode 100644 index 000000000..16a54f92f --- /dev/null +++ b/src/Command/Config/PrintConfigValidationTrait.php @@ -0,0 +1,26 @@ +info($this->trans('commands.config.validate.messages.success')); + return 0; + } + + foreach ($valid as $key => $error) { + $io->warning($key . ': ' . $error); + } + return 1; + } +} diff --git a/src/Command/Config/SettingsDebugCommand.php b/src/Command/Config/SettingsDebugCommand.php deleted file mode 100644 index a9cc8fb81..000000000 --- a/src/Command/Config/SettingsDebugCommand.php +++ /dev/null @@ -1,68 +0,0 @@ -settings = $settings;; - parent::__construct(); - } - /** - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('config:settings:debug') - ->setDescription($this->trans('commands.config.settings.debug.description')) - ->setHelp($this->trans('commands.config.settings.debug.help')); - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $settingKeys = array_keys($this->settings->getAll()); - $dumper = new Dumper(); - - $io->newLine(); - $io->info($this->trans('commands.config.settings.debug.messages.current')); - $io->newLine(); - - foreach ($settingKeys as $settingKey) { - $io->comment($settingKey, false); - $io->simple($dumper->dump($this->settings->get($settingKey), 10)); - } - $io->newLine(); - } -} diff --git a/src/Command/Config/ValidateCommand.php b/src/Command/Config/ValidateCommand.php new file mode 100644 index 000000000..a356d946c --- /dev/null +++ b/src/Command/Config/ValidateCommand.php @@ -0,0 +1,68 @@ +setName('config:validate') + ->setDescription($this->trans('commands.config.validate.description')) + ->addArgument( + 'name', + InputArgument::REQUIRED + )->setAliases(['cv']); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + + /** + * @var TypedConfigManagerInterface $typedConfigManager + */ + $typedConfigManager = $this->get('config.typed'); + + $io = new DrupalStyle($input, $output); + + //Test the config name and see if a schema exists, if not it will fail + $name = $input->getArgument('name'); + if (!$typedConfigManager->hasConfigSchema($name)) { + $io->warning($this->trans('commands.config.validate.messages.no-conf')); + return 1; + } + + //Get the config data from the factory + $configFactory = $this->get('config.factory'); + $config_data = $configFactory->get($name)->get(); + + return $this->printResults($this->checkConfigSchema($typedConfigManager, $name, $config_data), $io); + } +} diff --git a/src/Command/ContainerDebugCommand.php b/src/Command/ContainerDebugCommand.php deleted file mode 100644 index 9e49af0b4..000000000 --- a/src/Command/ContainerDebugCommand.php +++ /dev/null @@ -1,156 +0,0 @@ -setName('container:debug') - ->setDescription($this->trans('commands.container.debug.description')) - ->addOption( - 'parameters', - null, - InputOption::VALUE_NONE, - $this->trans('commands.container.debug.arguments.service') - ) - ->addArgument( - 'service', - InputArgument::OPTIONAL, - $this->trans('commands.container.debug.arguments.service') - ); - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - $service = $input->getArgument('service'); - $parameters = $input->getOption('parameters'); - - if ($parameters) { - $parameterList = $this->getParameterList(); - ksort($parameterList); - $io->write(Yaml::dump(['parameters' => $parameterList], 4, 2)); - - return 0; - } - - $tableHeader = []; - if ($service) { - $tableRows = $this->getServiceDetail($service); - $io->table($tableHeader, $tableRows, 'compact'); - - return 0; - } - - $tableHeader = [ - $this->trans('commands.container.debug.messages.service_id'), - $this->trans('commands.container.debug.messages.class_name') - ]; - - $tableRows = $this->getServiceList(); - $io->table($tableHeader, $tableRows, 'compact'); - - return 0; - } - - private function getServiceList() - { - $services = []; - $serviceDefinitions = $this->container - ->getParameter('console.service_definitions'); - - foreach ($serviceDefinitions as $serviceId => $serviceDefinition) { - $services[] = [$serviceId, $serviceDefinition->getClass()]; - } - return $services; - } - - private function getServiceDetail($service) - { - $serviceInstance = $this->get($service); - $serviceDetail = []; - - if ($serviceInstance) { - $serviceDetail[] = [ - $this->trans('commands.container.debug.messages.service'), - $service - ]; - $serviceDetail[] = [ - $this->trans('commands.container.debug.messages.class'), - get_class($serviceInstance) - ]; - $serviceDetail[] = [ - $this->trans('commands.container.debug.messages.interface'), - Yaml::dump(class_implements($serviceInstance)) - ]; - if ($parent = get_parent_class($serviceInstance)) { - $serviceDetail[] = [ - $this->trans('commands.container.debug.messages.parent'), - $parent - ]; - } - if ($vars = get_class_vars($serviceInstance)) { - $serviceDetail[] = [ - $this->trans('commands.container.debug.messages.variables'), - Yaml::dump($vars) - ]; - } - if ($methods = get_class_methods($serviceInstance)) { - $serviceDetail[] = [ - $this->trans('commands.container.debug.messages.methods'), - Yaml::dump($methods) - ]; - } - } - - return $serviceDetail; - } - - private function getParameterList() - { - $parameters = array_filter( - $this->container->getParameterBag()->all(), function ($name) { - if (preg_match('/^container\./', $name)) { - return false; - } - if (preg_match('/^drupal\./', $name)) { - return false; - } - if (preg_match('/^console\./', $name)) { - return false; - } - return true; - }, ARRAY_FILTER_USE_KEY - ); - - return $parameters; - } -} diff --git a/src/Command/Create/CommentsCommand.php b/src/Command/Create/CommentsCommand.php index 9d3e6e2d6..4358a8947 100644 --- a/src/Command/Create/CommentsCommand.php +++ b/src/Command/Create/CommentsCommand.php @@ -9,20 +9,19 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Command\Shared\CreateTrait; use Drupal\Console\Utils\Create\CommentData; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class CommentsCommand + * * @package Drupal\Console\Command\Generate */ class CommentsCommand extends Command { use CreateTrait; - use CommandTrait; /** * @var CommentData @@ -31,6 +30,7 @@ class CommentsCommand extends Command /** * CommentsCommand constructor. + * * @param CommentData $createCommentData */ public function __construct(CommentData $createCommentData) @@ -70,7 +70,7 @@ protected function configure() null, InputOption::VALUE_OPTIONAL, $this->trans('commands.create.comments.options.time-range') - ); + )->setAliases(['crc']); } /** @@ -116,7 +116,7 @@ protected function interact(InputInterface $input, OutputInterface $output) array_values($timeRanges) ); - $input->setOption('time-range', array_search($timeRange, $timeRanges)); + $input->setOption('time-range', array_search($timeRange, $timeRanges)); } } diff --git a/src/Command/Create/NodesCommand.php b/src/Command/Create/NodesCommand.php index 7467a91fb..93d9e6cdc 100644 --- a/src/Command/Create/NodesCommand.php +++ b/src/Command/Create/NodesCommand.php @@ -11,21 +11,27 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Annotations\DrupalCommand; use Drupal\Console\Command\Shared\CreateTrait; use Drupal\Console\Utils\Create\NodeData; use Drupal\Console\Utils\DrupalApi; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; +use Drupal\Core\Language\LanguageInterface; /** * Class NodesCommand + * * @package Drupal\Console\Command\Generate + * + * @DrupalCommand( + * extension = "node", + * extensionType = "module" + * ) */ class NodesCommand extends Command { use CreateTrait; - use CommandTrait; /** * @var DrupalApi @@ -38,6 +44,7 @@ class NodesCommand extends Command /** * NodesCommand constructor. + * * @param DrupalApi $drupalApi * @param NodeData $createNodeData */ @@ -80,7 +87,13 @@ protected function configure() null, InputOption::VALUE_OPTIONAL, $this->trans('commands.create.nodes.options.time-range') - ); + ) + ->addOption( + 'language', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.create.nodes.options.language') + )->setAliases(['crn']); } /** @@ -138,7 +151,36 @@ function ($contentType) use ($bundles) { array_values($timeRanges) ); - $input->setOption('time-range', array_search($timeRange, $timeRanges)); + $input->setOption('time-range', array_search($timeRange, $timeRanges)); + } + + // Language module is enabled or not. + $languageModuleEnabled = \Drupal::moduleHandler() + ->moduleExists('language'); + + // If language module is enabled. + if ($languageModuleEnabled) { + // Get available languages on site. + $languages = \Drupal::languageManager()->getLanguages(); + // Holds the available languages. + $language_list = []; + + foreach ($languages as $lang) { + $language_list[$lang->getId()] = $lang->getName(); + } + + $language = $input->getOption('language'); + // If no language option or invalid language code in option. + if (!$language || !array_key_exists($language, $language_list)) { + $language = $io->choice( + $this->trans('commands.create.nodes.questions.language'), + $language_list + ); + } + $input->setOption('language', $language); + } else { + // If 'language' module is not enabled. + $input->setOption('language', LanguageInterface::LANGCODE_NOT_SPECIFIED); } } @@ -154,6 +196,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $titleWords = $input->getOption('title-words')?:5; $timeRange = $input->getOption('time-range')?:31536000; $available_types = array_keys($this->drupalApi->getBundles()); + $language = $input->getOption('language')?:'und'; foreach ($contentTypes as $type) { if (!in_array($type, $available_types)) { @@ -169,8 +212,11 @@ protected function execute(InputInterface $input, OutputInterface $output) $contentTypes, $limit, $titleWords, - $timeRange + $timeRange, + $language ); + + $nodes = is_array($nodes) ? $nodes : [$nodes]; $tableHeader = [ $this->trans('commands.create.nodes.messages.node-id'), diff --git a/src/Command/Create/TermsCommand.php b/src/Command/Create/TermsCommand.php index ef1139c62..213f2e21c 100644 --- a/src/Command/Create/TermsCommand.php +++ b/src/Command/Create/TermsCommand.php @@ -11,20 +11,24 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Annotations\DrupalCommand; use Drupal\Console\Utils\Create\TermData; use Drupal\Console\Utils\DrupalApi; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class TermsCommand + * * @package Drupal\Console\Command\Generate + * + * @DrupalCommand( + * extension = "taxonomy", + * extensionType = "module" + * ) */ class TermsCommand extends Command { - use CommandTrait; - /** * @var DrupalApi */ @@ -36,6 +40,7 @@ class TermsCommand extends Command /** * TermsCommand constructor. + * * @param DrupalApi $drupalApi * @param TermData $createTermData */ @@ -72,7 +77,7 @@ protected function configure() null, InputOption::VALUE_OPTIONAL, $this->trans('commands.create.terms.options.name-words') - ); + )->setAliases(['crt']); } /** @@ -144,9 +149,9 @@ protected function execute(InputInterface $input, OutputInterface $output) ); $tableHeader = [ - $this->trans('commands.create.terms.messages.term-id'), - $this->trans('commands.create.terms.messages.vocabulary'), - $this->trans('commands.create.terms.messages.name'), + $this->trans('commands.create.terms.messages.term-id'), + $this->trans('commands.create.terms.messages.vocabulary'), + $this->trans('commands.create.terms.messages.name'), ]; $io->table($tableHeader, $terms['success']); diff --git a/src/Command/Create/UsersCommand.php b/src/Command/Create/UsersCommand.php index 5cb98ac30..281c886d5 100644 --- a/src/Command/Create/UsersCommand.php +++ b/src/Command/Create/UsersCommand.php @@ -11,21 +11,20 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Command\Shared\CreateTrait; use Drupal\Console\Utils\Create\UserData; use Drupal\Console\Utils\DrupalApi; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class UsersCommand + * * @package Drupal\Console\Command\Create */ class UsersCommand extends Command { use CreateTrait; - use CommandTrait; /** * @var DrupalApi @@ -38,6 +37,7 @@ class UsersCommand extends Command /** * UsersCommand constructor. + * * @param DrupalApi $drupalApi * @param UserData $createUserData */ @@ -80,7 +80,7 @@ protected function configure() null, InputOption::VALUE_OPTIONAL, $this->trans('commands.create.users.options.time-range') - ); + )->setAliases(['cru']); } /** @@ -138,7 +138,7 @@ function ($role) use ($roles) { array_values($timeRanges) ); - $input->setOption('time-range', array_search($timeRange, $timeRanges)); + $input->setOption('time-range', array_search($timeRange, $timeRanges)); } } diff --git a/src/Command/Create/VocabulariesCommand.php b/src/Command/Create/VocabulariesCommand.php index 5b1edba7b..a8dca8b90 100644 --- a/src/Command/Create/VocabulariesCommand.php +++ b/src/Command/Create/VocabulariesCommand.php @@ -7,22 +7,21 @@ namespace Drupal\Console\Command\Create; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Shared\CommandTrait; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Utils\Create\VocabularyData; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class VocabulariesCommand + * * @package Drupal\Console\Command\Generate */ class VocabulariesCommand extends Command { - use CommandTrait; - /** * @var VocabularyData */ @@ -30,6 +29,7 @@ class VocabulariesCommand extends Command /** * UsersCommand constructor. + * * @param $vocabularyData */ public function __construct(VocabularyData $vocabularyData) @@ -57,7 +57,7 @@ protected function configure() null, InputOption::VALUE_OPTIONAL, $this->trans('commands.create.vocabularies.options.name-words') - ); + )->setAliases(['crv']); } /** diff --git a/src/Command/Cron/ExecuteCommand.php b/src/Command/Cron/ExecuteCommand.php index d676d4904..cb62af297 100644 --- a/src/Command/Cron/ExecuteCommand.php +++ b/src/Command/Cron/ExecuteCommand.php @@ -10,18 +10,15 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Lock\LockBackendInterface; use Drupal\Core\State\StateInterface; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Style\DrupalStyle; +use Drupal\Console\Core\Utils\ChainQueue; class ExecuteCommand extends Command { - use CommandTrait; - /** * @var ModuleHandlerInterface */ @@ -44,9 +41,10 @@ class ExecuteCommand extends Command /** * DebugCommand constructor. + * * @param ModuleHandlerInterface $moduleHandler * @param LockBackendInterface $lock - * @param StateInterface $state + * @param StateInterface $state * @param ChainQueue $chainQueue */ public function __construct( @@ -72,9 +70,10 @@ protected function configure() ->setDescription($this->trans('commands.cron.execute.description')) ->addArgument( 'module', - InputArgument::IS_ARRAY | InputArgument::REQUIRED, + InputArgument::IS_ARRAY | InputArgument::OPTIONAL, $this->trans('commands.common.options.module') - ); + ) + ->setAliases(['croe']); } /** @@ -91,7 +90,7 @@ protected function execute(InputInterface $input, OutputInterface $output) return 1; } - if (in_array('all', $modules)) { + if ($modules === null || in_array('all', $modules)) { $modules = $this->moduleHandler->getImplementations('cron'); } diff --git a/src/Command/Cron/ReleaseCommand.php b/src/Command/Cron/ReleaseCommand.php index 1debe4da0..0554cde06 100644 --- a/src/Command/Cron/ReleaseCommand.php +++ b/src/Command/Cron/ReleaseCommand.php @@ -10,16 +10,14 @@ use Symfony\Component\Config\Definition\Exception\Exception; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Lock\LockBackendInterface; -use Drupal\Console\Utils\ChainQueue; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Utils\ChainQueue; +use Drupal\Console\Core\Command\Shared\CommandTrait; +use Drupal\Console\Core\Style\DrupalStyle; class ReleaseCommand extends Command { - use CommandTrait; - /** * @var LockBackendInterface */ @@ -32,6 +30,7 @@ class ReleaseCommand extends Command /** * ReleaseCommand constructor. + * * @param LockBackendInterface $lock * @param ChainQueue $chainQueue */ @@ -51,7 +50,8 @@ protected function configure() { $this ->setName('cron:release') - ->setDescription($this->trans('commands.cron.release.description')); + ->setDescription($this->trans('commands.cron.release.description')) + ->setAliases(['cror']); } /** diff --git a/src/Command/Database/AddCommand.php b/src/Command/Database/AddCommand.php new file mode 100644 index 000000000..38b8593d1 --- /dev/null +++ b/src/Command/Database/AddCommand.php @@ -0,0 +1,171 @@ +generator = $generator; + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('database:add') + ->setDescription($this->trans('commands.database.add.description')) + ->addOption( + 'database', + null, + InputOption::VALUE_REQUIRED, + $this->trans('commands.database.add.options.database') + ) + ->addOption( + 'username', + null, + InputOption::VALUE_REQUIRED, + $this->trans('commands.database.add.options.username') + ) + ->addOption( + 'password', + null, + InputOption::VALUE_REQUIRED, + $this->trans('commands.database.add.options.password') + ) + ->addOption( + 'prefix', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.database.add.options.prefix') + ) + ->addOption( + 'host', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.database.add.options.host') + ) + ->addOption( + 'port', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.database.add.options.port') + ) + ->addOption( + 'driver', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.database.add.options.driver') + ) + ->setHelp($this->trans('commands.database.add.help')) + ->setAliases(['dba']); + } + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + $result = $this + ->generator + ->generate($input->getOptions()); + if (!$result) { + $io->error($this->trans('commands.database.add.error')); + } + } + + /** + * {@inheritdoc} + */ + protected function interact(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + $database = $input->getOption('database'); + if (!$database) { + $database = $io->ask( + $this->trans('commands.database.add.questions.database'), + 'migrate_db' + ); + } + $input->setOption('database', $database); + $username = $input->getOption('username'); + if (!$username) { + $username = $io->ask( + $this->trans('commands.database.add.questions.username'), + '' + ); + } + $input->setOption('username', $username); + $password = $input->getOption('password'); + if (!$password) { + $password = $io->ask( + $this->trans('commands.database.add.questions.password'), + '' + ); + } + $input->setOption('password', $password); + $prefix = $input->getOption('prefix'); + if (!$prefix) { + $prefix = $io->ask( + $this->trans('commands.database.add.questions.prefix'), + false + ); + } + $input->setOption('prefix', $prefix); + $host = $input->getOption('host'); + if (!$host) { + $host = $io->ask( + $this->trans('commands.database.add.questions.host'), + 'localhost' + ); + } + $input->setOption('host', $host); + $port = $input->getOption('port'); + if (!$port) { + $port = $io->ask( + $this->trans('commands.database.add.questions.port'), + 3306 + ); + } + $input->setOption('port', $port); + $driver = $input->getOption('driver'); + if (!$driver) { + $driver = $io->ask( + $this->trans('commands.database.add.questions.driver'), + 'mysql' + ); + } + $input->setOption('driver', $driver); + } +} diff --git a/src/Command/Database/ClientCommand.php b/src/Command/Database/ClientCommand.php index d6a4a494f..4d679f472 100644 --- a/src/Command/Database/ClientCommand.php +++ b/src/Command/Database/ClientCommand.php @@ -11,15 +11,13 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Process\ProcessBuilder; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Command\Shared\ConnectTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; class ClientCommand extends Command { use ConnectTrait; - use CommandTrait; /** * {@inheritdoc} @@ -35,7 +33,8 @@ protected function configure() $this->trans('commands.database.client.arguments.database'), 'default' ) - ->setHelp($this->trans('commands.database.client.help')); + ->setHelp($this->trans('commands.database.client.help')) + ->setAliases(['dbc']); } /** diff --git a/src/Command/Database/ConnectCommand.php b/src/Command/Database/ConnectCommand.php index 9db250b42..229b6a1a6 100644 --- a/src/Command/Database/ConnectCommand.php +++ b/src/Command/Database/ConnectCommand.php @@ -10,14 +10,12 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Command\Shared\ConnectTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; class ConnectCommand extends Command { - use CommandTrait; use ConnectTrait; /** @@ -34,7 +32,8 @@ protected function configure() $this->trans('commands.database.connect.arguments.database'), 'default' ) - ->setHelp($this->trans('commands.database.connect.help')); + ->setHelp($this->trans('commands.database.connect.help')) + ->setAliases(['dbco']); } /** diff --git a/src/Command/Database/DatabaseLogBase.php b/src/Command/Database/DatabaseLogBase.php new file mode 100644 index 000000000..7adff8a84 --- /dev/null +++ b/src/Command/Database/DatabaseLogBase.php @@ -0,0 +1,280 @@ +database = $database; + $this->dateFormatter = $dateFormatter; + $this->entityTypeManager = $entityTypeManager; + $this->stringTranslation = $stringTranslation; + $this->userStorage = $this->entityTypeManager->getStorage('user'); + $this->severityList = RfcLogLevel::getLevels(); + parent::__construct(); + } + + /** + * addDefaultLoggingOptions. + */ + protected function addDefaultLoggingOptions() + { + $this + ->addOption( + 'type', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.database.log.common.options.type') + ) + ->addOption( + 'severity', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.database.log.common.options.severity') + ) + ->addOption( + 'user-id', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.database.log.common.options.user-id') + ); + } + + /** + * @param InputInterface $input + */ + protected function getDefaultOptions(InputInterface $input) + { + $this->eventType = $input->getOption('type'); + $this->eventSeverity = $input->getOption('severity'); + $this->userId = $input->getOption('user-id'); + } + + /** + * @param DrupalStyle $io + * @param null $offset + * @param int $range + * @return bool|\Drupal\Core\Database\Query\SelectInterface + */ + protected function makeQuery(DrupalStyle $io, $offset = null, $range = 1000) + { + $query = $this->database->select('watchdog', 'w'); + $query->fields( + 'w', + [ + 'wid', + 'uid', + 'severity', + 'type', + 'timestamp', + 'message', + 'variables', + ] + ); + + if ($this->eventType) { + $query->condition('type', $this->eventType); + } + + if ($this->eventSeverity) { + if (!in_array($this->eventSeverity, $this->severityList)) { + $io->error( + sprintf( + $this->trans('database.log.common.messages.invalid-severity'), + $this->eventSeverity + ) + ); + return false; + } + $query->condition( + 'severity', + array_search( + $this->eventSeverity, + $this->severityList + ) + ); + } + + if ($this->userId) { + $query->condition('uid', $this->userId); + } + + $query->orderBy('wid', 'ASC'); + + if ($offset) { + $query->range($offset, $range); + } + + return $query; + } + + /** + * Generic logging table header + * + * @return array + */ + protected function createTableHeader() + { + return [ + $this->trans('commands.database.log.common.messages.event-id'), + $this->trans('commands.database.log.common.messages.type'), + $this->trans('commands.database.log.common.messages.date'), + $this->trans('commands.database.log.common.messages.message'), + $this->trans('commands.database.log.common.messages.user'), + $this->trans('commands.database.log.common.messages.severity'), + ]; + } + + /** + * @param \stdClass $dblog + * @return array + */ + protected function createTableRow(\stdClass $dblog) + { + + /** + * @var User $user + */ + $user = $this->userStorage->load($dblog->uid); + + return [ + $dblog->wid, + $dblog->type, + $this->dateFormatter->format($dblog->timestamp, 'short'), + Unicode::truncate( + Html::decodeEntities(strip_tags($this->formatMessage($dblog))), + 500, + true, + true + ), + $user->getUsername() . ' (' . $user->id() . ')', + $this->severityList[$dblog->severity]->render(), + ]; + } + + /** + * Formats a database log message. + * + * @param $event + * The record from the watchdog table. The object properties are: wid, uid, + * severity, type, timestamp, message, variables, link, name. + * + * @return string|false + * The formatted log message or FALSE if the message or variables properties + * are not set. + */ + protected function formatMessage(\stdClass $event) + { + $message = false; + + // Check for required properties. + if (isset($event->message, $event->variables)) { + // Messages without variables or user specified text. + if ($event->variables === 'N;') { + return $event->message; + } + + return $this->stringTranslation->translate( + $event->message, + unserialize($event->variables) + ); + } + + return $message; + } + + /** + * @param $dblog + * @return array + */ + protected function formatSingle($dblog) + { + return array_combine( + $this->createTableHeader(), + $this->createTableRow($dblog) + ); + } +} diff --git a/src/Command/Database/DropCommand.php b/src/Command/Database/DropCommand.php index 66857dbc6..4e1e736c0 100644 --- a/src/Command/Database/DropCommand.php +++ b/src/Command/Database/DropCommand.php @@ -10,19 +10,18 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Database\Connection; -use Drupal\Console\Command\Shared\CommandTrait; use Drupal\Console\Command\Shared\ConnectTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class DropCommand + * * @package Drupal\Console\Command\Database */ class DropCommand extends Command { - use CommandTrait; use ConnectTrait; /** @@ -32,9 +31,11 @@ class DropCommand extends Command /** * DropCommand constructor. + * * @param Connection $database */ - public function __construct(Connection $database) { + public function __construct(Connection $database) + { $this->database = $database; parent::__construct(); } @@ -53,7 +54,8 @@ protected function configure() $this->trans('commands.database.drop.arguments.database'), 'default' ) - ->setHelp($this->trans('commands.database.drop.help')); + ->setHelp($this->trans('commands.database.drop.help')) + ->setAliases(['dbd']); } /** @@ -74,7 +76,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $databaseConnection['database'] ), true - )) { + ) + ) { return 1; } } diff --git a/src/Command/Database/DumpCommand.php b/src/Command/Database/DumpCommand.php index c7f6bb67a..8aeb7fbd4 100644 --- a/src/Command/Database/DumpCommand.php +++ b/src/Command/Database/DumpCommand.php @@ -11,15 +11,13 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Command\Shared\ConnectTrait; -use Drupal\Console\Utils\ShellProcess; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Utils\ShellProcess; +use Drupal\Console\Core\Style\DrupalStyle; class DumpCommand extends Command { - use CommandTrait; use ConnectTrait; @@ -31,6 +29,7 @@ class DumpCommand extends Command /** * DumpCommand constructor. + * * @param $appRoot * @param ShellProcess $shellProcess */ @@ -61,15 +60,16 @@ protected function configure() 'file', null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.database.dump.option.file') + $this->trans('commands.database.dump.options.file') ) ->addOption( 'gz', - false, + null, InputOption::VALUE_NONE, - $this->trans('commands.database.dump.option.gz') + $this->trans('commands.database.dump.options.gz') ) - ->setHelp($this->trans('commands.database.dump.help')); + ->setHelp($this->trans('commands.database.dump.help')) + ->setAliases(['dbdu']); } /** @@ -100,7 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($databaseConnection['driver'] == 'mysql') { $command = sprintf( - 'mysqldump --user=%s --password=%s --host=%s --port=%s %s > %s', + 'mysqldump --user="%s" --password="%s" --host="%s" --port="%s" "%s" > "%s"', $databaseConnection['username'], $databaseConnection['password'], $databaseConnection['host'], @@ -110,7 +110,7 @@ protected function execute(InputInterface $input, OutputInterface $output) ); } elseif ($databaseConnection['driver'] == 'pgsql') { $command = sprintf( - 'PGPASSWORD="%s" pg_dumpall -w -U %s -h %s -p %s -l %s -f %s', + 'PGPASSWORD="%s" pg_dumpall -w -U "%s" -h "%s" -p "%s" -l "%s" -f "%s"', $databaseConnection['password'], $databaseConnection['username'], $databaseConnection['host'], @@ -125,18 +125,23 @@ protected function execute(InputInterface $input, OutputInterface $output) } if ($this->shellProcess->exec($command, $this->appRoot)) { - $resultFile = $file; - if ($gz) { - $resultFile = $file . ".gz"; - file_put_contents( - $resultFile, - gzencode( - file_get_contents( - $file) - ) - ); - unlink($file); - } + $resultFile = $file; + if ($gz) { + if (substr($file, -3) != '.gz') { + $resultFile = $file . ".gz"; + } + file_put_contents( + $resultFile, + gzencode( + file_get_contents( + $file + ) + ) + ); + if ($resultFile != $file) { + unlink($file); + } + } $io->success( sprintf( diff --git a/src/Command/Database/LogClearCommand.php b/src/Command/Database/LogClearCommand.php index 0aef41e82..87dcdb536 100644 --- a/src/Command/Database/LogClearCommand.php +++ b/src/Command/Database/LogClearCommand.php @@ -11,16 +11,14 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Database\Connection; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Shared\CommandTrait; use Drupal\Core\Logger\RfcLogLevel; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; class LogClearCommand extends Command { - use CommandTrait; - /** * @var Connection */ @@ -28,9 +26,11 @@ class LogClearCommand extends Command /** * LogClearCommand constructor. + * * @param Connection $database */ - public function __construct(Connection $database) { + public function __construct(Connection $database) + { $this->database = $database; parent::__construct(); } @@ -50,22 +50,23 @@ protected function configure() ) ->addOption( 'type', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.database.log.clear.options.type') ) ->addOption( 'severity', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.database.log.clear.options.severity') ) ->addOption( 'user-id', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.database.log.clear.options.user-id') - ); + ) + ->setAliases(['dblc']); } /** @@ -120,7 +121,7 @@ private function clearEvent(DrupalStyle $io, $eventId) } /** - * @param DrupalStyle $io + * @param DrupalStyle $io * @param $eventType * @param $eventSeverity * @param $userId diff --git a/src/Command/Database/LogDebugCommand.php b/src/Command/Database/LogDebugCommand.php deleted file mode 100644 index dc02baacf..000000000 --- a/src/Command/Database/LogDebugCommand.php +++ /dev/null @@ -1,305 +0,0 @@ -database = $database; - $this->dateFormatter = $dateFormatter; - $this->entityTypeManager = $entityTypeManager; - $this->stringTranslation = $stringTranslation; - parent::__construct(); - } - - /** - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('database:log:debug') - ->setDescription($this->trans('commands.database.log.debug.description')) - ->addArgument( - 'event-id', - InputArgument::OPTIONAL, - $this->trans('commands.database.log.debug.arguments.event-id') - ) - ->addOption( - 'type', - '', - InputOption::VALUE_OPTIONAL, - $this->trans('commands.database.log.debug.options.type') - ) - ->addOption( - 'severity', - '', - InputOption::VALUE_OPTIONAL, - $this->trans('commands.database.log.debug.options.severity') - ) - ->addOption( - 'user-id', - '', - InputOption::VALUE_OPTIONAL, - $this->trans('commands.database.log.debug.options.user-id') - ) - ->addOption( - 'asc', - false, - InputOption::VALUE_NONE, - $this->trans('commands.database.log.debug.options.asc') - ) - ->addOption( - 'limit', - null, - InputOption::VALUE_OPTIONAL, - $this->trans('commands.database.log.debug.options.limit') - ) - ->addOption( - 'offset', - null, - InputOption::VALUE_OPTIONAL, - $this->trans('commands.database.log.debug.options.offset'), - 0 - ); - ; - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $eventId = $input->getArgument('event-id'); - $eventType = $input->getOption('type'); - $eventSeverity = $input->getOption('severity'); - $userId = $input->getOption('user-id'); - $asc = $input->getOption('asc'); - $limit = $input->getOption('limit'); - $offset = $input->getOption('offset'); - - if ($eventId) { - $this->getEventDetails($io, $eventId); - } else { - $this->getAllEvents($io, $eventType, $eventSeverity, $userId, $asc, $offset, $limit); - } - - return 0; - } - - /** - * @param $io - * @param $eventId - * @return bool - */ - private function getEventDetails(DrupalStyle $io, $eventId) - { - $userStorage = $this->entityTypeManager->getStorage('user'); - $severity = RfcLogLevel::getLevels(); - - $dblog = $this->database - ->query( - 'SELECT w.*, u.uid FROM {watchdog} w LEFT JOIN {users} u ON u.uid = w.uid WHERE w.wid = :id', - [':id' => $eventId] - ) - ->fetchObject(); - - if (!$dblog) { - $io->error( - sprintf( - $this->trans('commands.database.log.debug.messages.not-found'), - $eventId - ) - ); - - return false; - } - - $user = $userStorage->load($dblog->uid); - - $configuration = [ - $this->trans('commands.database.log.debug.messages.event-id') => $eventId, - $this->trans('commands.database.log.debug.messages.type') => $dblog->type, - $this->trans('commands.database.log.debug.messages.date') => $this->dateFormatter->format($dblog->timestamp, 'short'), - $this->trans('commands.database.log.debug.messages.user') => $user->getUsername() . ' (' . $user->id() .')', - $this->trans('commands.database.log.debug.messages.severity') => (string) $severity[$dblog->severity], - $this->trans('commands.database.log.debug.messages.message') => Html::decodeEntities(strip_tags($this->formatMessage($dblog))) - ]; - - $io->writeln(Yaml::encode($configuration)); - - return true; - } - - private function getAllEvents(DrupalStyle $io, $eventType, $eventSeverity, $userId, $asc, $offset, $limit) - { - $userStorage = $this->entityTypeManager->getStorage('user'); - $severity = RfcLogLevel::getLevels(); - - $query = $this->database->select('watchdog', 'w'); - $query->fields( - 'w', - [ - 'wid', - 'uid', - 'severity', - 'type', - 'timestamp', - 'message', - 'variables', - ] - ); - - if ($eventType) { - $query->condition('type', $eventType); - } - - if ($eventSeverity) { - if (!in_array($eventSeverity, $severity)) { - $io->error( - sprintf( - $this->trans('commands.database.log.debug.messages.invalid-severity'), - $eventSeverity - ) - ); - - return false; - } - - $query->condition('severity', array_search($eventSeverity, $severity)); - } - - if ($userId) { - $query->condition('uid', $userId); - } - - if ($asc) { - $query->orderBy('wid', 'ASC'); - } else { - $query->orderBy('wid', 'DESC'); - } - - if ($limit) { - $query->range($offset, $limit); - } - - $result = $query->execute(); - - $tableHeader = [ - $this->trans('commands.database.log.debug.messages.event-id'), - $this->trans('commands.database.log.debug.messages.type'), - $this->trans('commands.database.log.debug.messages.date'), - $this->trans('commands.database.log.debug.messages.message'), - $this->trans('commands.database.log.debug.messages.user'), - $this->trans('commands.database.log.debug.messages.severity'), - ]; - - $tableRows = []; - foreach ($result as $dblog) { - $user= $userStorage->load($dblog->uid); - - $tableRows[] = [ - $dblog->wid, - $dblog->type, - $this->dateFormatter->format($dblog->timestamp, 'short'), - Unicode::truncate(Html::decodeEntities(strip_tags($this->formatMessage($dblog))), 56, true, true), - $user->getUsername() . ' (' . $user->id() .')', - $severity[$dblog->severity] - ]; - } - - $io->table( - $tableHeader, - $tableRows - ); - - return true; - } - - /** - * Formats a database log message. - * - * @param $event - * The record from the watchdog table. The object properties are: wid, uid, - * severity, type, timestamp, message, variables, link, name. - * - * @return string|false - * The formatted log message or FALSE if the message or variables properties - * are not set. - */ - private function formatMessage($event) - { - $message = false; - - // Check for required properties. - if (isset($event->message) && isset($event->variables)) { - // Messages without variables or user specified text. - if ($event->variables === 'N;') { - return $event->message; - } - - return $this->stringTranslation->translate( - $event->message, unserialize($event->variables) - ); - } - - return $message; - } -} diff --git a/src/Command/Database/LogPollCommand.php b/src/Command/Database/LogPollCommand.php new file mode 100644 index 000000000..eee78b5cc --- /dev/null +++ b/src/Command/Database/LogPollCommand.php @@ -0,0 +1,87 @@ +note($this->trans('commands.database.log.poll.messages.warning')); + + $this->getDefaultOptions($input); + $this->duration = $input->getArgument('duration'); + + $this->pollForEvents($io); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('database:log:poll') + ->setDescription($this->trans('commands.database.log.poll.description')); + + $this->addDefaultLoggingOptions(); + + $this->addArgument( + 'duration', + InputArgument::OPTIONAL, + $this->trans('commands.database.log.poll.arguments.duration'), + '10' + )->setAliases(['dblp']); + } + + /** + * @param DrupalStyle $io + */ + protected function pollForEvents(DrupalStyle $io) + { + $query = $this->makeQuery($io)->countQuery(); + $results = $query->execute()->fetchAssoc(); + $count = $results['expression'] - 1;//minus 1 so the newest message always prints + + $tableHeader = $this->createTableHeader(); + + //Poll, force no wait on first loop + $lastExec = time() - $this->duration; + while (1) { + if (time() > $lastExec + $this->duration) { + //Print out any new db logs + $query = $this->makeQuery($io, $count); + $results = $query->execute()->fetchAll(); + $count += count($results); + $tableRows = []; + foreach ($results as $r) { + $tableRows[] = $this->createTableRow($r); + } + if (!empty($tableRows)) { + $io->table($tableHeader, $tableRows); + } + //update the last exec time + $lastExec = time(); + } + } + } +} diff --git a/src/Command/Database/QueryCommand.php b/src/Command/Database/QueryCommand.php new file mode 100644 index 000000000..281dc3aef --- /dev/null +++ b/src/Command/Database/QueryCommand.php @@ -0,0 +1,134 @@ +setName('database:query') + ->setDescription($this->trans('commands.database.query.description')) + ->addArgument( + 'query', + InputArgument::REQUIRED, + $this->trans('commands.database.query.arguments.query') + ) + ->addArgument( + 'database', + InputArgument::OPTIONAL, + $this->trans('commands.database.query.arguments.database'), + 'default' + ) + ->addOption('quick', null, InputOption::VALUE_NONE, $this->trans('commands.database.query.options.quick')) + ->addOption('debug', null, InputOption::VALUE_NONE, $this->trans('commands.database.query.options.debug')) + ->addOption('html', null, InputOption::VALUE_NONE, $this->trans('commands.database.query.options.html')) + ->addOption('xml', null, InputOption::VALUE_NONE, $this->trans('commands.database.query.options.xml')) + ->addOption('raw', null, InputOption::VALUE_NONE, $this->trans('commands.database.query.options.raw')) + ->addOption('vertical', null, InputOption::VALUE_NONE, $this->trans('commands.database.query.options.vertical')) + ->addOption('batch', null, InputOption::VALUE_NONE, $this->trans('commands.database.query.options.batch')) + + ->setHelp($this->trans('commands.database.query.help')) + ->setAliases(['dbq']); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + $query = $input->getArgument('query'); + $database = $input->getArgument('database'); + $learning = $input->getOption('learning'); + + $databaseConnection = $this->resolveConnection($io, $database); + + $connection = sprintf( + '%s -A --database=%s --user=%s --password=%s --host=%s --port=%s', + $databaseConnection['driver'], + $databaseConnection['database'], + $databaseConnection['username'], + $databaseConnection['password'], + $databaseConnection['host'], + $databaseConnection['port'] + ); + + $args = explode(' ', $connection); + $args[] = sprintf('--execute=%s', $query); + + $opts = ["quick", "debug", "html", "xml", "raw", "vertical", "batch"]; + array_walk( + $opts, function ($opt) use ($input, &$args) { + if ($input->getOption($opt)) { + switch ($opt) { + case "quick": + $args[] = "--quick"; + break; + case "debug": + $args[] = "-T"; + break; + case "html": + $args[] = "-H"; + break; + case "xml": + $args[] = "-X"; + break; + case "raw": + $args[] = "--raw"; + break; + case "vertical": + $args[] = "-E"; + break; + case "batch": + $args[] = "--batch"; + break; + } + } + } + ); + + if ($learning) { + $io->commentBlock( + implode(" ", $args) + ); + } + + $processBuilder = new ProcessBuilder([]); + $processBuilder->setArguments($args); + $process = $processBuilder->getProcess(); + $process->setTty('true'); + $process->run(); + + if (!$process->isSuccessful()) { + throw new \RuntimeException($process->getErrorOutput()); + } + + return 0; + } +} diff --git a/src/Command/Database/RestoreCommand.php b/src/Command/Database/RestoreCommand.php index a62f8ec77..673b8edb0 100644 --- a/src/Command/Database/RestoreCommand.php +++ b/src/Command/Database/RestoreCommand.php @@ -12,14 +12,12 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Process\ProcessBuilder; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Command\Shared\ConnectTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; class RestoreCommand extends Command { - use CommandTrait; use ConnectTrait; /** @@ -29,9 +27,11 @@ class RestoreCommand extends Command /** * RestoreCommand constructor. + * * @param string $appRoot */ - public function __construct($appRoot) { + public function __construct($appRoot) + { $this->appRoot = $appRoot; parent::__construct(); } @@ -56,7 +56,8 @@ protected function configure() InputOption::VALUE_REQUIRED, $this->trans('commands.database.restore.options.file') ) - ->setHelp($this->trans('commands.database.restore.help')); + ->setHelp($this->trans('commands.database.restore.help')) + ->setAliases(['dbr']); } /** diff --git a/src/Command/Breakpoints/DebugCommand.php b/src/Command/Debug/BreakpointsCommand.php similarity index 73% rename from src/Command/Breakpoints/DebugCommand.php rename to src/Command/Debug/BreakpointsCommand.php index 714dfd2c4..acf8d362b 100644 --- a/src/Command/Breakpoints/DebugCommand.php +++ b/src/Command/Debug/BreakpointsCommand.php @@ -2,20 +2,19 @@ /** * @file - * Contains \Drupal\Console\Command\Breakpoints\DebugCommand. + * Contains \Drupal\Console\Command\Debug\BreakpointsCommand. */ -namespace Drupal\Console\Command\Breakpoints; +namespace Drupal\Console\Command\Debug; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\breakpoint\BreakpointManagerInterface; use Symfony\Component\Yaml\Yaml; -use Drupal\Console\Command\Shared\CommandTrait; use Drupal\Console\Annotations\DrupalCommand; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * @DrupalCommand( @@ -23,10 +22,8 @@ * extensionType = "module" * ) */ -class DebugCommand extends Command +class BreakpointsCommand extends Command { - use CommandTrait; - /** * @var BreakpointManagerInterface */ @@ -38,7 +35,8 @@ class DebugCommand extends Command protected $appRoot; /** - * DebugCommand constructor. + * BreakpointsCommand constructor. + * * @param BreakpointManagerInterface $breakpointManager * @param string $appRoot */ @@ -57,13 +55,13 @@ public function __construct( protected function configure() { $this - ->setName('breakpoints:debug') - ->setDescription($this->trans('commands.breakpoints.debug.description')) + ->setName('debug:breakpoints') + ->setDescription($this->trans('commands.debug.breakpoints.description')) ->addArgument( 'group', InputArgument::OPTIONAL, - $this->trans('commands.breakpoints.debug.options.group-name') - ); + $this->trans('commands.debug.breakpoints.options.group-name') + )->setAliases(['dbre']); } /** @@ -86,7 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $groups = array_keys($this->breakpointManager->getGroups()); $tableHeader = [ - $this->trans('commands.breakpoints.debug.messages.name'), + $this->trans('commands.debug.breakpoints.messages.name'), ]; $io->table($tableHeader, $groups, 'compact'); @@ -105,12 +103,7 @@ private function getBreakpointByName($group) array_values($this->breakpointManager->getGroupProviders($group)) ); - if ($typeExtension == 'theme') { - $projectPath = drupal_get_path('theme', $group); - } - if ($typeExtension == 'module') { - $projectPath = drupal_get_path('module', $group); - } + $projectPath = drupal_get_path($typeExtension, $group); $extensionFile = sprintf( '%s/%s/%s.breakpoints.yml', diff --git a/src/Command/Cache/ContextDebugCommand.php b/src/Command/Debug/CacheContextCommand.php similarity index 56% rename from src/Command/Cache/ContextDebugCommand.php rename to src/Command/Debug/CacheContextCommand.php index 0c9e219fa..dbbc5be94 100644 --- a/src/Command/Cache/ContextDebugCommand.php +++ b/src/Command/Debug/CacheContextCommand.php @@ -2,34 +2,32 @@ /** * @file - * Contains \Drupal\Console\Command\Cache\ContextDebugCommand. + * Contains \Drupal\Console\Command\Debug\CacheContextCommand. */ -namespace Drupal\Console\Command\Cache; +namespace Drupal\Console\Command\Debug; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\ContainerAwareCommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\ContainerAwareCommand; +use Drupal\Console\Core\Style\DrupalStyle; /** - * Class ContextDebugCommand. + * Class CacheContextCommand. * - * @package Drupal\Console\Command\Cache + * @package Drupal\Console\Command\Debug */ -class ContextDebugCommand extends Command +class CacheContextCommand extends ContainerAwareCommand { - use ContainerAwareCommandTrait; - /** * {@inheritdoc} */ protected function configure() { $this - ->setName('cache:context:debug') - ->setDescription($this->trans('commands.cache.context.debug.description')); + ->setName('debug:cache:context') + ->setDescription($this->trans('commands.debug.cache.context.description')) + ->setAliases(['dcc']); } /** @@ -41,9 +39,9 @@ protected function execute(InputInterface $input, OutputInterface $output) $contextManager = $this->get('cache_contexts_manager'); $tableHeader = [ - $this->trans('commands.cache.context.debug.messages.code'), - $this->trans('commands.cache.context.debug.messages.label'), - $this->trans('commands.cache.context.debug.messages.class'), + $this->trans('commands.debug.cache.context.messages.code'), + $this->trans('commands.debug.cache.context.messages.label'), + $this->trans('commands.debug.cache.context.messages.class'), ]; $tableRows = []; diff --git a/src/Command/Config/DebugCommand.php b/src/Command/Debug/ConfigCommand.php similarity index 77% rename from src/Command/Config/DebugCommand.php rename to src/Command/Debug/ConfigCommand.php index df057cf84..e73d5f286 100644 --- a/src/Command/Config/DebugCommand.php +++ b/src/Command/Debug/ConfigCommand.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\Console\Command\Config\DebugCommand. + * Contains \Drupal\Console\Command\Debug\ConfigCommand. */ -namespace Drupal\Console\Command\Config; +namespace Drupal\Console\Command\Debug; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -13,22 +13,24 @@ use Drupal\Component\Serialization\Yaml; use Drupal\Core\Config\CachedStorage; use Drupal\Core\Config\ConfigFactory; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; -class DebugCommand extends Command +class ConfigCommand extends Command { - use CommandTrait; - - /** @var ConfigFactory */ + /** + * @var ConfigFactory + */ protected $configFactory; - /** @var CachedStorage */ + /** + * @var CachedStorage + */ protected $configStorage; /** - * DebugCommand constructor. + * ConfigCommand constructor. + * * @param ConfigFactory $configFactory * @param CachedStorage $configStorage */ @@ -47,13 +49,14 @@ public function __construct( protected function configure() { $this - ->setName('config:debug') - ->setDescription($this->trans('commands.config.debug.description')) + ->setName('debug:config') + ->setDescription($this->trans('commands.debug.config.description')) ->addArgument( 'name', InputArgument::OPTIONAL, - $this->trans('commands.config.debug.arguments.name') - ); + $this->trans('commands.debug.config.arguments.name') + ) + ->setAliases(['dc']); } /** @@ -78,7 +81,7 @@ private function getAllConfigurations(DrupalStyle $io) { $names = $this->configFactory->listAll(); $tableHeader = [ - $this->trans('commands.config.debug.arguments.name'), + $this->trans('commands.debug.config.arguments.name'), ]; $tableRows = []; foreach ($names as $name) { @@ -111,7 +114,7 @@ private function getConfigurationByName(DrupalStyle $io, $config_name) $io->table($tableHeader, $tableRows, 'compact'); } else { $io->error( - sprintf($this->trans('commands.config.debug.errors.not-exists'), $config_name) + sprintf($this->trans('commands.debug.config.errors.not-exists'), $config_name) ); } } diff --git a/src/Command/Debug/ConfigSettingsCommand.php b/src/Command/Debug/ConfigSettingsCommand.php new file mode 100644 index 000000000..503d41719 --- /dev/null +++ b/src/Command/Debug/ConfigSettingsCommand.php @@ -0,0 +1,75 @@ +settings = $settings; + ; + parent::__construct(); + } + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('debug:config:settings') + ->setDescription($this->trans('commands.debug.config.settings.description')) + ->setHelp($this->trans('commands.debug.config.settings.help')) + ->setAliases(['dcs']); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + $settingKeys = array_keys($this->settings->getAll()); + + $io->newLine(); + $io->info($this->trans('commands.debug.config.settings.messages.current')); + $io->newLine(); + + foreach ($settingKeys as $settingKey) { + $settingValue = $this->settings->get($settingKey); + $io->comment($settingKey . ': ', is_array($settingValue)); + $io->write(Yaml::encode($settingValue)); + if (!is_array($settingValue)) { + $io->newLine(); + } + } + $io->newLine(); + } +} diff --git a/src/Command/Debug/ConfigValidateCommand.php b/src/Command/Debug/ConfigValidateCommand.php new file mode 100644 index 000000000..9c23f669c --- /dev/null +++ b/src/Command/Debug/ConfigValidateCommand.php @@ -0,0 +1,118 @@ +setName('debug:config:validate') + ->setDescription($this->trans('commands.debug.config.validate.description')) + ->addArgument( + 'filepath', + InputArgument::REQUIRED + ) + ->addArgument( + 'schema-filepath', + InputArgument::REQUIRED + ) + ->addOption( + 'schema-name', + 'sch', + InputOption::VALUE_REQUIRED + )->setAliases(['dcv']); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + + /** + * @var TypedConfigManagerInterface $typedConfigManager + */ + $typedConfigManager = $this->get('config.typed'); + + $io = new DrupalStyle($input, $output); + + //Validate config file path + $configFilePath = $input->getArgument('filepath'); + if (!file_exists($configFilePath)) { + $io->info($this->trans('commands.debug.config.validate.messages.noConfFile')); + return 1; + } + + //Validate schema path + $configSchemaFilePath = $input->getArgument('schema-filepath'); + if (!file_exists($configSchemaFilePath)) { + $io->info($this->trans('commands.debug.config.validate.messages.noConfSchema')); + return 1; + } + + $config = Yaml::decode(file_get_contents($configFilePath)); + $schema = Yaml::decode(file_get_contents($configSchemaFilePath)); + + //Get the schema name and check it exists in the schema array + $schemaName = $this->getSchemaName($input, $configFilePath); + if (!array_key_exists($schemaName, $schema)) { + $io->warning($this->trans('commands.debug.config.validate.messages.noSchemaName') . $schemaName); + return 1; + } + + return $this->printResults($this->manualCheckConfigSchema($typedConfigManager, $config, $schema[$schemaName]), $io); + } + + private function getSchemaName(InputInterface $input, $configFilePath) + { + $schemaName = $input->getOption('schema-name'); + if ($schemaName === null) { + $schema_name = end(explode('/', $configFilePath)); + $schemaName = substr($schema_name, 0, -4); + } + return $schemaName; + } + + private function manualCheckConfigSchema(TypedConfigManagerInterface $typed_config, $config_data, $config_schema) + { + $data_definition = $typed_config->buildDataDefinition($config_schema, $config_data); + $this->schema = $typed_config->create($data_definition, $config_data); + $errors = []; + foreach ($config_data as $key => $value) { + $errors = array_merge($errors, $this->checkValue($key, $value)); + } + if (empty($errors)) { + return true; + } + + return $errors; + } +} diff --git a/src/Command/Debug/ContainerCommand.php b/src/Command/Debug/ContainerCommand.php new file mode 100644 index 000000000..03255a54f --- /dev/null +++ b/src/Command/Debug/ContainerCommand.php @@ -0,0 +1,266 @@ +setName('debug:container') + ->setDescription($this->trans('commands.debug.container.description')) + ->addOption( + 'parameters', + null, + InputOption::VALUE_NONE, + $this->trans('commands.debug.container.arguments.service') + ) + ->addArgument( + 'service', + InputArgument::OPTIONAL, + $this->trans('commands.debug.container.arguments.service') + )->addArgument( + 'method', + InputArgument::OPTIONAL, + $this->trans('commands.debug.container.arguments.method') + )->addArgument( + 'arguments', + InputArgument::OPTIONAL, + $this->trans('commands.debug.container.arguments.arguments') + ) + ->setAliases(['dco']); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + $service = $input->getArgument('service'); + $parameters = $input->getOption('parameters'); + $method = $input->getArgument('method'); + $args = $input->getArgument('arguments'); + + if ($parameters) { + $parameterList = $this->getParameterList(); + ksort($parameterList); + $io->write(Yaml::dump(['parameters' => $parameterList], 4, 2)); + + return 0; + } + + if ($method) { + $tableHeader = []; + $callbackRow = $this->getCallbackReturnList($service, $method, $args); + $io->table($tableHeader, $callbackRow, 'compact'); + + return 0; + } else { + $tableHeader = []; + if ($service) { + $tableRows = $this->getServiceDetail($service); + $io->table($tableHeader, $tableRows, 'compact'); + + return 0; + } + + $tableHeader = [ + $this->trans('commands.debug.container.messages.service-id'), + $this->trans('commands.debug.container.messages.class-name') + ]; + + $tableRows = $this->getServiceList(); + $io->table($tableHeader, $tableRows, 'compact'); + } + + return 0; + } + + private function getCallbackReturnList($service, $method, $args) + { + if ($args != null) { + $parsedArgs = json_decode($args, true); + if (!is_array($parsedArgs)) { + $parsedArgs = explode(",", $args); + } + } else { + $parsedArgs = null; + } + $serviceInstance = \Drupal::service($service); + + if (!method_exists($serviceInstance, $method)) { + throw new \Symfony\Component\DependencyInjection\Exception\BadMethodCallException($this->trans('commands.debug.container.errors.method-not-exists')); + + return $serviceDetail; + } + $serviceDetail[] = [ + ''.$this->trans('commands.debug.container.messages.service').'', + ''.$service.'' + ]; + $serviceDetail[] = [ + ''.$this->trans('commands.debug.container.messages.class').'', + ''.get_class($serviceInstance).'' + ]; + $methods = [$method]; + $this->extendArgumentList($serviceInstance, $methods); + $serviceDetail[] = [ + ''.$this->trans('commands.debug.container.messages.method').'', + ''.$methods[0].'' + ]; + if ($parsedArgs) { + $serviceDetail[] = [ + ''.$this->trans('commands.debug.container.messages.arguments').'', + json_encode($parsedArgs, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) + ]; + } + $return = call_user_func_array([$serviceInstance,$method], $parsedArgs); + $serviceDetail[] = [ + ''.$this->trans('commands.debug.container.messages.return').'', + json_encode($return, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) + ]; + return $serviceDetail; + } + private function getServiceList() + { + $services = []; + $serviceDefinitions = $this->container + ->getParameter('console.service_definitions'); + + foreach ($serviceDefinitions as $serviceId => $serviceDefinition) { + $services[] = [$serviceId, $serviceDefinition->getClass()]; + } + usort($services, [$this, 'compareService']); + return $services; + } + private function compareService($a, $b) + { + return strcmp($a[0], $b[0]); + } + + private function getServiceDetail($service) + { + $serviceInstance = $this->get($service); + $serviceDetail = []; + + if ($serviceInstance) { + $serviceDetail[] = [ + ''.$this->trans('commands.debug.container.messages.service').'', + ''.$service.'' + ]; + $serviceDetail[] = [ + ''.$this->trans('commands.debug.container.messages.class').'', + ''.get_class($serviceInstance).'' + ]; + $interface = str_replace("{ }", "", Yaml::dump(class_implements($serviceInstance))); + if (!empty($interface)) { + $serviceDetail[] = [ + ''.$this->trans('commands.debug.container.messages.interface').'', + ''.$interface.'' + ]; + } + if ($parent = get_parent_class($serviceInstance)) { + $serviceDetail[] = [ + ''.$this->trans('commands.debug.container.messages.parent').'', + ''.$parent.'' + ]; + } + if ($vars = get_class_vars($serviceInstance)) { + $serviceDetail[] = [ + ''.$this->trans('commands.debug.container.messages.variables').'', + ''.Yaml::dump($vars).'' + ]; + } + if ($methods = get_class_methods($serviceInstance)) { + sort($methods); + $this->extendArgumentList($serviceInstance, $methods); + $serviceDetail[] = [ + ''.$this->trans('commands.debug.container.messages.methods').'', + ''.implode("\n", $methods).'' + ]; + } + } else { + throw new \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException($service); + + return $serviceDetail; + } + + return $serviceDetail; + } + private function extendArgumentList($serviceInstance, &$methods) + { + foreach ($methods as $k => $m) { + $reflection = new \ReflectionMethod($serviceInstance, $m); + $params = $reflection->getParameters(); + $p = []; + + for ($i = 0; $i < count($params); $i++) { + if ($params[$i]->isDefaultValueAvailable()) { + $defaultVar = $params[$i]->getDefaultValue(); + $defaultVar = " = ".str_replace(["\n","array ("], ["", "array("], var_export($def, true)).''; + } else { + $defaultVar = ''; + } + if (method_exists($params[$i], 'hasType') && method_exists($params[$i], 'getType')) { + if ($params[$i]->hasType()) { + $defaultType = ''.strval($params[$i]->getType()).' '; + } else { + $defaultType = ''; + } + } else { + $defaultType = ''; + } + if ($params[$i]->isPassedByReference()) { + $parameterReference = '&'; + } else { + $parameterReference = ''; + } + $p[] = $defaultType.$parameterReference.''.'$'.$params[$i]->getName().''.$defaultVar; + } + if ($reflection->isPublic()) { + $methods[$k] = ''.$methods[$k]."(".implode(', ', $p).") "; + } + } + } + + private function getParameterList() + { + $parameters = array_filter( + $this->container->getParameterBag()->all(), function ($name) { + if (preg_match('/^container\./', $name)) { + return false; + } + if (preg_match('/^drupal\./', $name)) { + return false; + } + if (preg_match('/^console\./', $name)) { + return false; + } + return true; + }, ARRAY_FILTER_USE_KEY + ); + + return $parameters; + } +} diff --git a/src/Command/Cron/DebugCommand.php b/src/Command/Debug/CronCommand.php similarity index 60% rename from src/Command/Cron/DebugCommand.php rename to src/Command/Debug/CronCommand.php index 6a6c48aae..9b7f7d649 100644 --- a/src/Command/Cron/DebugCommand.php +++ b/src/Command/Debug/CronCommand.php @@ -2,29 +2,27 @@ /** * @file - * Contains \Drupal\Console\Command\Cron\DebugCommand. + * Contains \Drupal\Console\Command\Debug\CronCommand. */ -namespace Drupal\Console\Command\Cron; +namespace Drupal\Console\Command\Debug; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; -class DebugCommand extends Command +class CronCommand extends Command { - use CommandTrait; - /** * @var ModuleHandlerInterface */ protected $moduleHandler; /** - * DebugCommand constructor. + * CronCommand constructor. + * * @param ModuleHandlerInterface $moduleHandler */ public function __construct(ModuleHandlerInterface $moduleHandler) @@ -39,8 +37,9 @@ public function __construct(ModuleHandlerInterface $moduleHandler) protected function configure() { $this - ->setName('cron:debug') - ->setDescription($this->trans('commands.cron.debug.description')); + ->setName('debug:cron') + ->setDescription($this->trans('commands.debug.cron.description')) + ->setAliases(['dcr']); } /** @@ -51,13 +50,11 @@ protected function execute(InputInterface $input, OutputInterface $output) $io = new DrupalStyle($input, $output); $io->section( - $this->trans('commands.cron.debug.messages.module-list') + $this->trans('commands.debug.cron.messages.module-list') ); $io->table( - [ - $this->trans('commands.cron.debug.messages.module') - ], + [ $this->trans('commands.debug.cron.messages.module') ], $this->moduleHandler->getImplementations('cron'), 'compact' ); diff --git a/src/Command/Debug/DatabaseLogCommand.php b/src/Command/Debug/DatabaseLogCommand.php new file mode 100644 index 000000000..6a112eebe --- /dev/null +++ b/src/Command/Debug/DatabaseLogCommand.php @@ -0,0 +1,174 @@ +setName('debug:database:log') + ->setDescription($this->trans('commands.debug.database.log.description')); + + $this->addDefaultLoggingOptions(); + + $this + ->addArgument( + 'event-id', + InputArgument::OPTIONAL, + $this->trans('commands.debug.database.log.arguments.event-id') + ) + ->addOption( + 'asc', + null, + InputOption::VALUE_NONE, + $this->trans('commands.debug.database.log.options.asc') + ) + ->addOption( + 'limit', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.debug.database.log.options.limit') + ) + ->addOption( + 'offset', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.debug.database.log.options.offset'), + 0 + ) + ->addOption( + 'yml', + null, + InputOption::VALUE_NONE, + $this->trans('commands.debug.database.log.options.yml'), + null + ) + ->setAliases(['dbb']); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + $this->getDefaultOptions($input); + $this->eventId = $input->getArgument('event-id'); + $this->asc = $input->getOption('asc'); + $this->limit = $input->getOption('limit'); + $this->offset = $input->getOption('offset'); + $this->ymlStyle = $input->getOption('yml'); + + + if ($this->eventId) { + return $this->getEventDetails($io); + } else { + return $this->getAllEvents($io); + } + } + + /** + * @param $io + * @param $eventId + * @return bool + */ + private function getEventDetails(DrupalStyle $io) + { + $dblog = $this->database + ->query( + 'SELECT w.*, u.uid FROM {watchdog} w LEFT JOIN {users} u ON u.uid = w.uid WHERE w.wid = :id', + [':id' => $this->eventId] + ) + ->fetchObject(); + + if (!$dblog) { + $io->error( + sprintf( + $this->trans('commands.debug.database.log.messages.not-found'), + $this->eventId + ) + ); + return 1; + } + + if ($this->ymlStyle) { + $io->writeln(Yaml::encode($this->formatSingle($dblog))); + } else { + $io->table( + $this->createTableHeader(), + [$this->createTableRow($dblog)] + ); + } + } + + /** + * @param \Drupal\Console\Core\Style\DrupalStyle $io + * @return bool + */ + private function getAllEvents(DrupalStyle $io) + { + $query = $this->makeQuery($io); + + $result = $query->execute(); + + $tableRows = []; + foreach ($result as $dblog) { + $tableRows[] = $this->createTableRow($dblog); + } + + $io->table( + $this->createTableHeader(), + $tableRows + ); + + return true; + } +} diff --git a/src/Command/Database/TableDebugCommand.php b/src/Command/Debug/DatabaseTableCommand.php similarity index 70% rename from src/Command/Database/TableDebugCommand.php rename to src/Command/Debug/DatabaseTableCommand.php index 440357026..88a77c2d2 100644 --- a/src/Command/Database/TableDebugCommand.php +++ b/src/Command/Debug/DatabaseTableCommand.php @@ -2,29 +2,28 @@ /** * @file - * Contains \Drupal\Console\Command\Database\TableDebugCommand. + * Contains \Drupal\Console\Command\Debug\DatabaseTableCommand. */ -namespace Drupal\Console\Command\Database; +namespace Drupal\Console\Command\Debug; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use RedBeanPHP\R; use Drupal\Core\Database\Connection; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Command\Shared\ConnectTrait; /** - * Class TableDebugCommand + * Class DatabaseTableCommand + * * @package Drupal\Console\Command\Database */ -class TableDebugCommand extends Command +class DatabaseTableCommand extends Command { - use CommandTrait; use ConnectTrait; /** @@ -38,8 +37,9 @@ class TableDebugCommand extends Command protected $redBean; /** - * TableDebugCommand constructor. - * @param R $redBean + * DatabaseTableCommand constructor. + * + * @param R $redBean * @param Connection $database */ public function __construct( @@ -57,22 +57,23 @@ public function __construct( protected function configure() { $this - ->setName('database:table:debug') - ->setDescription($this->trans('commands.database.table.debug.description')) + ->setName('debug:database:table') + ->setDescription($this->trans('commands.debug.database.table.description')) ->addOption( 'database', - '', + null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.database.table.debug.options.database'), + $this->trans('commands.debug.database.table.options.database'), 'default' ) ->addArgument( 'table', InputArgument::OPTIONAL, - $this->trans('commands.database.table.debug.arguments.table'), + $this->trans('commands.debug.database.table.arguments.table'), null ) - ->setHelp($this->trans('commands.database.table.debug.help')); + ->setHelp($this->trans('commands.debug.database.table.help')) + ->setAliases(['ddt']); } /** @@ -91,8 +92,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $tableInfo = $this->redBean->inspect($table); $tableHeader = [ - $this->trans('commands.database.table.debug.messages.column'), - $this->trans('commands.database.table.debug.messages.type') + $this->trans('commands.debug.database.table.messages.column'), + $this->trans('commands.debug.database.table.messages.type') ]; $tableRows = []; foreach ($tableInfo as $column => $type) { @@ -112,13 +113,13 @@ protected function execute(InputInterface $input, OutputInterface $output) $io->comment( sprintf( - $this->trans('commands.database.table.debug.messages.table-show'), + $this->trans('commands.debug.database.table.messages.table-show'), $databaseConnection['database'] ) ); $io->table( - [$this->trans('commands.database.table.debug.messages.table')], + [$this->trans('commands.debug.database.table.messages.table')], $tables ); diff --git a/src/Command/Debug/EntityCommand.php b/src/Command/Debug/EntityCommand.php new file mode 100644 index 000000000..ff1a74c07 --- /dev/null +++ b/src/Command/Debug/EntityCommand.php @@ -0,0 +1,93 @@ +entityTypeRepository = $entityTypeRepository; + $this->entityTypeManager = $entityTypeManager; + parent::__construct(); + } + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('debug:entity') + ->setDescription($this->trans('commands.debug.entity.description')) + ->addArgument( + 'entity-type', + InputArgument::OPTIONAL, + $this->trans('commands.debug.entity.arguments.entity-type') + )->setAliases(['de']); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + $entityType = $input->getArgument('entity-type'); + + $tableHeader = [ + $this->trans('commands.debug.entity.table-headers.entity-name'), + $this->trans('commands.debug.entity.table-headers.entity-type') + ]; + $tableRows = []; + + $entityTypesLabels = $this->entityTypeRepository->getEntityTypeLabels(true); + + if ($entityType) { + $entityTypes = [$entityType => $entityType]; + } else { + $entityTypes = array_keys($entityTypesLabels); + } + + foreach ($entityTypes as $entityTypeId) { + $entities = array_keys($entityTypesLabels[$entityTypeId]); + foreach ($entities as $entity) { + $tableRows[$entity] = [ + $entity, + $entityTypeId + ]; + } + } + + $io->table($tableHeader, array_values($tableRows)); + } +} diff --git a/src/Command/Debug/EventCommand.php b/src/Command/Debug/EventCommand.php new file mode 100644 index 000000000..126e9bc57 --- /dev/null +++ b/src/Command/Debug/EventCommand.php @@ -0,0 +1,142 @@ +eventDispatcher = $eventDispatcher; + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('debug:event') + ->setDescription($this->trans('commands.debug.event.description')) + ->addArgument( + 'event', + InputArgument::OPTIONAL, + $this->trans('commands.debug.event.arguments.event'), + null + ) + ->setHelp($this->trans('commands.debug.event.blerp')) + ->setAliases(['dev']); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + $events = array_keys($this->eventDispatcher->getListeners()); + $event = $input->getArgument('event'); + + if ($event) { + if (!in_array($event, $events)) { + throw new \Exception( + sprintf( + $this->trans('commands.debug.event.messages.no-events'), + $event + ) + ); + } + + $dispatcher = $this->eventDispatcher->getListeners($event); + $listeners = []; + + foreach ($dispatcher as $key => $value) { + $reflection = new \ReflectionClass(get_class($value[0])); + $className = $reflection->getName(); + + if (!$reflection->hasMethod('getSubscribedEvents')) { + $reflection = new \ReflectionClass($reflection->getParentClass()); + } + + $eventObject = $reflection->newInstanceWithoutConstructor(); + $reflectionMethod = new \ReflectionMethod( + $reflection->getName(), + 'getSubscribedEvents' + ); + + $subscribedEvents = $reflectionMethod->invoke( + $eventObject + ); + + if (!is_array($subscribedEvents[$event])) { + $subscribedEvents[$event] = [$subscribedEvents[$event]]; + } + + $subscribedEventData = []; + foreach ($subscribedEvents[$event] as $subscribedEvent) { + if (!is_array($subscribedEvent)) { + $subscribedEvent = [$subscribedEvent, 0]; + } + if ($subscribedEvent[0] == $value[1]) { + $subscribedEventData = [ + $subscribedEvent[0] => isset($subscribedEvent[1])?$subscribedEvent[1]:0 + ]; + } + } + + $listeners[] = [ + 'class' => $className, + 'method' => $value[1], + 'events' => Yaml::dump($subscribedEventData, 4, 2) + ]; + } + + $tableHeader = [ + $this->trans('commands.debug.event.messages.class'), + $this->trans('commands.debug.event.messages.method'), + ]; + + $tableRows = []; + foreach ($listeners as $key => $element) { + $tableRows[] = [ + 'class' => $element['class'], + 'events' => $element['events'] + ]; + } + + $io->table($tableHeader, $tableRows); + + return 0; + } + + $io->table( + [$this->trans('commands.debug.event.messages.event')], + $events + ); + } +} diff --git a/src/Command/Debug/FeaturesCommand.php b/src/Command/Debug/FeaturesCommand.php new file mode 100644 index 000000000..bcb3bc3f9 --- /dev/null +++ b/src/Command/Debug/FeaturesCommand.php @@ -0,0 +1,64 @@ +setName('debug:features') + ->setDescription($this->trans('commands.debug.features.description')) + ->addArgument( + 'bundle', + InputArgument::OPTIONAL, + $this->trans('commands.debug.features.arguments.bundle') + ); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + $bundle= $input->getArgument('bundle'); + + $tableHeader = [ + $this->trans('commands.debug.features.messages.bundle'), + $this->trans('commands.debug.features.messages.name'), + $this->trans('commands.debug.features.messages.machine-name'), + $this->trans('commands.debug.features.messages.status'), + $this->trans('commands.debug.features.messages.state'), + ]; + + $tableRows = []; + + $features = $this->getFeatureList($io, $bundle); + + foreach ($features as $feature) { + $tableRows[] = [$feature['bundle_name'],$feature['name'], $feature['machine_name'], $feature['status'],$feature['state']]; + } + + $io->table($tableHeader, $tableRows, 'compact'); + } +} diff --git a/src/Command/Image/StylesDebugCommand.php b/src/Command/Debug/ImageStylesCommand.php similarity index 67% rename from src/Command/Image/StylesDebugCommand.php rename to src/Command/Debug/ImageStylesCommand.php index 878717d03..1a6ecbda7 100644 --- a/src/Command/Image/StylesDebugCommand.php +++ b/src/Command/Debug/ImageStylesCommand.php @@ -2,33 +2,32 @@ /** * @file - * Contains \Drupal\Console\Command\Image\StylesDebugCommand. + * Contains \Drupal\Console\Command\Debug\ImageStylesCommand. */ -namespace Drupal\Console\Command\Image; +namespace Drupal\Console\Command\Debug; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class StylesDebugCommand - * @package Drupal\Console\Command\Image + * + * @package Drupal\Console\Command\Debug */ -class StylesDebugCommand extends Command +class ImageStylesCommand extends Command { - use CommandTrait; - /** * @var EntityTypeManagerInterface */ protected $entityTypeManager; /** - * StylesDebugCommand constructor. + * ImageStylesCommand constructor. + * * @param EntityTypeManagerInterface $entityTypeManager */ public function __construct(EntityTypeManagerInterface $entityTypeManager) @@ -43,8 +42,9 @@ public function __construct(EntityTypeManagerInterface $entityTypeManager) protected function configure() { $this - ->setName('image:styles:debug') - ->setDescription($this->trans('commands.image.styles.debug.description')); + ->setName('debug:image:styles') + ->setDescription($this->trans('commands.debug.image.styles.description')) + ->setAliases(['dis']); } /** @@ -58,7 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $io->newLine(); $io->comment( - $this->trans('commands.image.styles.debug.messages.styles-list') + $this->trans('commands.debug.image.styles.messages.styles-list') ); if ($imageStyle) { @@ -69,14 +69,14 @@ protected function execute(InputInterface $input, OutputInterface $output) } /** - * @param \Drupal\Console\Style\DrupalStyle $io + * @param \Drupal\Console\Core\Style\DrupalStyle $io * @param $imageStyle */ protected function imageStyleList(DrupalStyle $io, $imageStyle) { $tableHeader = [ - $this->trans('commands.image.styles.debug.messages.styles-name'), - $this->trans('commands.image.styles.debug.messages.styles-label') + $this->trans('commands.debug.image.styles.messages.styles-name'), + $this->trans('commands.debug.image.styles.messages.styles-label') ]; $tableRows = []; diff --git a/src/Command/Libraries/DebugCommand.php b/src/Command/Debug/LibrariesCommand.php similarity index 79% rename from src/Command/Libraries/DebugCommand.php rename to src/Command/Debug/LibrariesCommand.php index 5b734e27a..afd5b58a2 100644 --- a/src/Command/Libraries/DebugCommand.php +++ b/src/Command/Debug/LibrariesCommand.php @@ -2,40 +2,46 @@ /** * @file - * Contains \Drupal\Console\Command\Libraries\DebugCommand. + * Contains \Drupal\Console\Command\Debug\LibrariesCommand. */ -namespace Drupal\Console\Command\Libraries; +namespace Drupal\Console\Command\Debug; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\Core\Asset\LibraryDiscoveryInterface; use Drupal\Component\Serialization\Yaml; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; -class DebugCommand extends Command +class LibrariesCommand extends Command { - use CommandTrait; - - /** @var ModuleHandlerInterface */ + /** + * @var ModuleHandlerInterface +*/ protected $moduleHandler; - /** @var ThemeHandlerInterface; */ + /** + * @var ThemeHandlerInterface; +*/ protected $themeHandler; - /** @var LibraryDiscoveryInterface */ + /** + * @var LibraryDiscoveryInterface +*/ protected $libraryDiscovery; - /** @var string */ + /** + * @var string +*/ protected $appRoot; /** * DebugCommand constructor. + * * @param ModuleHandlerInterface $moduleHandler * @param ThemeHandlerInterface $themeHandler * @param LibraryDiscoveryInterface $libraryDiscovery @@ -60,13 +66,13 @@ public function __construct( protected function configure() { $this - ->setName('libraries:debug') - ->setDescription($this->trans('commands.libraries.debug.description')) + ->setName('debug:libraries') + ->setDescription($this->trans('commands.debug.libraries.description')) ->addArgument( 'group', InputArgument::OPTIONAL, - $this->trans('commands.libraries.debug.options.name') - ); + $this->trans('commands.debug.libraries.options.name') + )->setAliases(['dl']); } /** @@ -81,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $groups = $this->getAllLibraries(); $tableHeader = [ - $this->trans('commands.libraries.debug.messages.name'), + $this->trans('commands.debug.libraries.messages.name'), ]; $io->table($tableHeader, $groups, 'compact'); diff --git a/src/Command/Migrate/DebugCommand.php b/src/Command/Debug/MigrateCommand.php similarity index 65% rename from src/Command/Migrate/DebugCommand.php rename to src/Command/Debug/MigrateCommand.php index 761cc9b8e..ecaab1a85 100644 --- a/src/Command/Migrate/DebugCommand.php +++ b/src/Command/Debug/MigrateCommand.php @@ -2,19 +2,18 @@ /** * @file - * Contains \Drupal\Console\Command\Migrate\DebugCommand. + * Contains \Drupal\Console\Command\Debug\MigrateCommand. */ -namespace Drupal\Console\Command\Migrate; +namespace Drupal\Console\Command\Debug; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Drupal\Console\Command\Shared\MigrationTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Annotations\DrupalCommand; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\migrate\Plugin\MigrationPluginManagerInterface; /** @@ -23,11 +22,9 @@ * extensionType = "module" * ) */ - -class DebugCommand extends Command +class MigrateCommand extends Command { use MigrationTrait; - use CommandTrait; /** * @var MigrationPluginManagerInterface $pluginManagerMigration @@ -35,11 +32,13 @@ class DebugCommand extends Command protected $pluginManagerMigration; /** - * DebugCommand constructor. + * MigrateCommand constructor. + * * @param MigrationPluginManagerInterface $pluginManagerMigration */ - public function __construct(MigrationPluginManagerInterface $pluginManagerMigration) - { + public function __construct( + MigrationPluginManagerInterface $pluginManagerMigration + ) { $this->pluginManagerMigration = $pluginManagerMigration; parent::__construct(); } @@ -47,34 +46,35 @@ public function __construct(MigrationPluginManagerInterface $pluginManagerMigrat protected function configure() { $this - ->setName('migrate:debug') - ->setDescription($this->trans('commands.migrate.debug.description')) + ->setName('debug:migrate') + ->setDescription($this->trans('commands.debug.migrate.description')) ->addArgument( 'tag', InputArgument::OPTIONAL, - $this->trans('commands.migrate.debug.arguments.tag') - ); + $this->trans('commands.debug.migrate.arguments.tag') + ) + ->setAliases(['mid']); } protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $drupal_version = 'Drupal ' . $input->getArgument('tag'); - + $migrations = $this->getMigrations($drupal_version); - + $tableHeader = [ - $this->trans('commands.migrate.debug.messages.id'), - $this->trans('commands.migrate.debug.messages.description'), - $this->trans('commands.migrate.debug.messages.tags'), + $this->trans('commands.debug.migrate.messages.id'), + $this->trans('commands.debug.migrate.messages.description'), + $this->trans('commands.debug.migrate.messages.tags'), ]; $tableRows = []; if (empty($migrations)) { $io->error( sprintf( - $this->trans('commands.migrate.debug.messages.no-migrations'), + $this->trans('commands.debug.migrate.messages.no-migrations'), count($migrations) ) ); diff --git a/src/Command/Module/DebugCommand.php b/src/Command/Debug/ModuleCommand.php similarity index 74% rename from src/Command/Module/DebugCommand.php rename to src/Command/Debug/ModuleCommand.php index 6bed2f05c..21417aeb6 100644 --- a/src/Command/Module/DebugCommand.php +++ b/src/Command/Debug/ModuleCommand.php @@ -2,26 +2,23 @@ /** * @file - * Contains \Drupal\Console\Command\Module\DebugCommand. + * Contains \Drupal\Console\Command\Debug\ModuleCommand. */ -namespace Drupal\Console\Command\Module; +namespace Drupal\Console\Command\Debug; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Utils\Site; use GuzzleHttp\Client; -use Drupal\Console\Utils\ConfigurationManager; +use Drupal\Console\Core\Utils\ConfigurationManager; -class DebugCommand extends Command +class ModuleCommand extends Command { - use CommandTrait; - /** * @var ConfigurationManager */ @@ -34,6 +31,7 @@ class DebugCommand extends Command /** * DebugCommand constructor. + * * @param Client $httpClient */ @@ -41,8 +39,9 @@ class DebugCommand extends Command /** * ChainDebugCommand constructor. + * * @param ConfigurationManager $configurationManager - * @param Site $site + * @param Site $site */ public function __construct( ConfigurationManager $configurationManager, @@ -58,25 +57,26 @@ public function __construct( protected function configure() { $this - ->setName('module:debug') - ->setDescription($this->trans('commands.module.debug.description')) + ->setName('debug:module') + ->setDescription($this->trans('commands.debug.module.description')) ->addArgument( 'module', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, - $this->trans('commands.module.debug.module') + $this->trans('commands.debug.module.module') ) ->addOption( 'status', null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.module.debug.options.status') + $this->trans('commands.debug.module.options.status') ) ->addOption( 'type', null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.module.debug.options.type') - ); + $this->trans('commands.debug.module.options.type') + ) + ->setAliases(['dm']); } protected function execute(InputInterface $input, OutputInterface $output) @@ -105,7 +105,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } catch (\Exception $e) { $io->error( sprintf( - $this->trans('commands.module.debug.messages.no-results'), + $this->trans('commands.debug.module.messages.no-results'), $module ) ); @@ -124,17 +124,17 @@ protected function execute(InputInterface $input, OutputInterface $output) ]; $tableRows[] = [ - ''.$this->trans('commands.module.debug.messages.total-downloads').'', + ''.$this->trans('commands.debug.module.messages.total-downloads').'', $data->package->downloads->total ]; $tableRows[] = [ - ''.$this->trans('commands.module.debug.messages.total-monthly').'', + ''.$this->trans('commands.debug.module.messages.total-monthly').'', $data->package->downloads->monthly ]; $tableRows[] = [ - ''.$this->trans('commands.module.debug.messages.total-daily').'', + ''.$this->trans('commands.debug.module.messages.total-daily').'', $data->package->downloads->daily ]; @@ -160,13 +160,13 @@ protected function execute(InputInterface $input, OutputInterface $output) } $tableHeader = [ - $this->trans('commands.module.debug.messages.id'), - $this->trans('commands.module.debug.messages.name'), - $this->trans('commands.module.debug.messages.package'), - $this->trans('commands.module.debug.messages.version'), - $this->trans('commands.module.debug.messages.schema-version'), - $this->trans('commands.module.debug.messages.status'), - $this->trans('commands.module.debug.messages.origin'), + $this->trans('commands.debug.module.messages.id'), + $this->trans('commands.debug.module.messages.name'), + $this->trans('commands.debug.module.messages.package'), + $this->trans('commands.debug.module.messages.version'), + $this->trans('commands.debug.module.messages.schema-version'), + $this->trans('commands.debug.module.messages.status'), + $this->trans('commands.debug.module.messages.origin'), ]; $tableRows = []; @@ -180,7 +180,7 @@ protected function execute(InputInterface $input, OutputInterface $output) continue; } - $module_status = ($module->status) ? $this->trans('commands.module.debug.messages.installed') : $this->trans('commands.module.debug.messages.uninstalled'); + $module_status = ($module->status) ? $this->trans('commands.debug.module.messages.installed') : $this->trans('commands.debug.module.messages.uninstalled'); $module_origin = ($module->origin) ? $module->origin : 'no core'; $schema_version = (drupal_get_installed_schema_version($module_id)!= -1?drupal_get_installed_schema_version($module_id): ''); diff --git a/src/Command/Multisite/DebugCommand.php b/src/Command/Debug/MultisiteCommand.php similarity index 56% rename from src/Command/Multisite/DebugCommand.php rename to src/Command/Debug/MultisiteCommand.php index a096b7c4d..6dcf18064 100644 --- a/src/Command/Multisite/DebugCommand.php +++ b/src/Command/Debug/MultisiteCommand.php @@ -2,32 +2,32 @@ /** * @file - * Contains \Drupal\Console\Command\Site\DebugCommand. + * Contains \Drupal\Console\Command\Debug\MultisiteCommand. */ -namespace Drupal\Console\Command\Multisite; +namespace Drupal\Console\Command\Debug; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; /** - * Class SiteDebugCommand - * @package Drupal\Console\Command\Site + * Class MultisiteCommand + * + * @package Drupal\Console\Command\Debug */ -class DebugCommand extends Command +class MultisiteCommand extends Command { - use CommandTrait; - protected $appRoot; /** - * DebugCommand constructor. + * MultisiteCommand constructor. + * * @param $appRoot */ - public function __construct($appRoot) { + public function __construct($appRoot) + { $this->appRoot = $appRoot; parent::__construct(); } @@ -38,9 +38,10 @@ public function __construct($appRoot) { public function configure() { $this - ->setName('multisite:debug') - ->setDescription($this->trans('commands.multisite.debug.description')) - ->setHelp($this->trans('commands.multisite.debug.help')); + ->setName('debug:multisite') + ->setDescription($this->trans('commands.debug.multisite.description')) + ->setHelp($this->trans('commands.debug.multisite.help')) + ->setAliases(['dmu']); ; } @@ -64,26 +65,26 @@ protected function execute(InputInterface $input, OutputInterface $output) if (!$sites) { $io->error( - $this->trans('commands.multisite.debug.messages.no-multisites') + $this->trans('commands.debug.multisite.messages.no-multisites') ); return 1; } $io->info( - $this->trans('commands.multisite.debug.messages.site-format') + $this->trans('commands.debug.multisite.messages.site-format') ); $tableHeader = [ - $this->trans('commands.multisite.debug.messages.site'), - $this->trans('commands.multisite.debug.messages.directory'), + $this->trans('commands.debug.multisite.messages.site'), + $this->trans('commands.debug.multisite.messages.directory'), ]; $tableRows = []; foreach ($sites as $site => $directory) { $tableRows[] = [ $site, - $this->appRoot . '/' . $directory + $this->appRoot . '/sites/' . $directory ]; } diff --git a/src/Command/Debug/PermissionCommand.php b/src/Command/Debug/PermissionCommand.php new file mode 100644 index 000000000..759bd069c --- /dev/null +++ b/src/Command/Debug/PermissionCommand.php @@ -0,0 +1,115 @@ +setName('debug:permission') + ->setDescription($this->trans('commands.debug.permission.description')) + ->setHelp($this->trans('commands.debug.permission.help')) + ->addArgument( + 'role', + InputArgument::OPTIONAL, + $this->trans('commands.debug.permission.arguments.role') + )->setAliases(['dp']); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + $role = $input->getArgument('role'); + // No role specified, show a list of ALL permissions. + if (!$role) { + $tableHeader = [ + $this->trans('commands.debug.permission.table-headers.permission-name'), + $this->trans('commands.debug.permission.table-headers.permission-label'), + $this->trans('commands.debug.permission.table-headers.permission-role') + ]; + $tableRows = []; + $permissions = \Drupal::service('user.permissions')->getPermissions(); + foreach ($permissions as $permission_name => $permission) { + $tableRows[$permission_name] = [ + $permission_name, + strip_tags($permission['title']->__toString()), + implode(', ', $this->getRolesAssignedByPermission($permission_name)) + ]; + } + + ksort($tableRows); + $io->table($tableHeader, array_values($tableRows)); + + return true; + } else { + $tableHeader = [ + $this->trans('commands.debug.permission.table-headers.permission-name'), + $this->trans('commands.debug.permission.table-headers.permission-label') + ]; + $tableRows = []; + $permissions = \Drupal::service('user.permissions')->getPermissions(); + $roles = user_roles(); + if (empty($roles[$role])) { + $message = sprintf($this->trans('commands.debug.permission.messages.role-error'), $role); + $io->error($message); + return true; + } + $user_permission = $roles[$role]->getPermissions(); + foreach ($permissions as $permission_name => $permission) { + if (in_array($permission_name, $user_permission)) { + $tableRows[$permission_name] = [ + $permission_name, + strip_tags($permission['title']->__toString()) + ]; + } + } + ksort($tableRows); + $io->table($tableHeader, array_values($tableRows)); + return true; + } + } + + /** + * Get user roles Assigned by Permission. + * + * @param string $permission_name + * Permission Name. + * + * @return array + * User roles filtered by permission else empty array. + */ + public function getRolesAssignedByPermission($permission_name) + { + $roles = user_roles(); + $roles_found = []; + foreach ($roles as $role) { + if ($role->hasPermission($permission_name)) { + $roles_found[] = $role->getOriginalId(); + } + } + return $roles_found; + } +} diff --git a/src/Command/PluginDebugCommand.php b/src/Command/Debug/PluginCommand.php similarity index 76% rename from src/Command/PluginDebugCommand.php rename to src/Command/Debug/PluginCommand.php index 21d4c473a..bc6e9096b 100644 --- a/src/Command/PluginDebugCommand.php +++ b/src/Command/Debug/PluginCommand.php @@ -5,41 +5,40 @@ * Contains \Drupal\Console\Command\PluginDebugCommand. */ -namespace Drupal\Console\Command; +namespace Drupal\Console\Command\Debug; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\ContainerAwareCommand; use Symfony\Component\Yaml\Yaml; -use Drupal\Console\Command\Shared\ContainerAwareCommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class DebugCommand - * @package Drupal\Console\Command + * + * @package Drupal\Console\Command\Debug */ -class PluginDebugCommand extends Command +class PluginCommand extends ContainerAwareCommand { - use ContainerAwareCommandTrait; /** * {@inheritdoc} */ protected function configure() { - $this->setName('plugin:debug') - ->setDescription($this->trans('commands.plugin.debug.description')) - ->setHelp($this->trans('commands.plugin.debug.help')) + $this->setName('debug:plugin') + ->setDescription($this->trans('commands.debug.plugin.description')) + ->setHelp($this->trans('commands.debug.plugin.help')) ->addArgument( 'type', InputArgument::OPTIONAL, - $this->trans('commands.plugin.debug.arguments.type') + $this->trans('commands.debug.plugin.arguments.type') ) ->addArgument( 'id', InputArgument::OPTIONAL, - $this->trans('commands.plugin.debug.arguments.id') - ); + $this->trans('commands.debug.plugin.arguments.id') + )->setAliases(['dpl']); } /** @@ -55,8 +54,8 @@ protected function execute(InputInterface $input, OutputInterface $output) // No plugin type specified, show a list of plugin types. if (!$pluginType) { $tableHeader = [ - $this->trans('commands.plugin.debug.table-headers.plugin-type-name'), - $this->trans('commands.plugin.debug.table-headers.plugin-type-class') + $this->trans('commands.debug.plugin.table-headers.plugin-type-name'), + $this->trans('commands.debug.plugin.table-headers.plugin-type-class') ]; $tableRows = []; $serviceDefinitions = $this->container @@ -82,7 +81,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if (!$service) { $io->error( sprintf( - $this->trans('commands.plugin.debug.errors.plugin-type-not-found'), + $this->trans('commands.debug.plugin.errors.plugin-type-not-found'), $pluginType ) ); @@ -92,8 +91,8 @@ protected function execute(InputInterface $input, OutputInterface $output) // Valid plugin type specified, no ID specified, show list of instances. if (!$pluginId) { $tableHeader = [ - $this->trans('commands.plugin.debug.table-headers.plugin-id'), - $this->trans('commands.plugin.debug.table-headers.plugin-class') + $this->trans('commands.debug.plugin.table-headers.plugin-id'), + $this->trans('commands.debug.plugin.table-headers.plugin-class') ]; $tableRows = []; foreach ($service->getDefinitions() as $definition) { @@ -109,8 +108,8 @@ protected function execute(InputInterface $input, OutputInterface $output) // Valid plugin type specified, ID specified, show the definition. $definition = $service->getDefinition($pluginId); $tableHeader = [ - $this->trans('commands.plugin.debug.table-headers.definition-key'), - $this->trans('commands.plugin.debug.table-headers.definition-value') + $this->trans('commands.debug.plugin.table-headers.definition-key'), + $this->trans('commands.debug.plugin.table-headers.definition-value') ]; $tableRows = []; foreach ($definition as $key => $value) { diff --git a/src/Command/Queue/DebugCommand.php b/src/Command/Debug/QueueCommand.php similarity index 67% rename from src/Command/Queue/DebugCommand.php rename to src/Command/Debug/QueueCommand.php index e30269254..e4907a260 100644 --- a/src/Command/Queue/DebugCommand.php +++ b/src/Command/Debug/QueueCommand.php @@ -2,26 +2,24 @@ /** * @file - * Contains \Drupal\Console\Command\Queue\DebugCommand. + * Contains \Drupal\Console\Command\Debug\QueueCommand. */ -namespace Drupal\Console\Command\Queue; +namespace Drupal\Console\Command\Debug; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Drupal\Core\Queue\QueueWorkerManagerInterface; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class DebugCommand - * @package Drupal\Console\Command\Queue + * + * @package Drupal\Console\Command\Debug */ -class DebugCommand extends Command +class QueueCommand extends Command { - use CommandTrait; - /** * @var QueueWorkerManagerInterface */ @@ -29,9 +27,11 @@ class DebugCommand extends Command /** * DebugCommand constructor. + * * @param QueueWorkerManagerInterface $queueWorker */ - public function __construct( QueueWorkerManagerInterface $queueWorker) { + public function __construct(QueueWorkerManagerInterface $queueWorker) + { $this->queueWorker = $queueWorker; parent::__construct(); } @@ -42,8 +42,9 @@ public function __construct( QueueWorkerManagerInterface $queueWorker) { protected function configure() { $this - ->setName('queue:debug') - ->setDescription($this->trans('commands.queue.debug.description')); + ->setName('debug:queue') + ->setDescription($this->trans('commands.debug.queue.description')) + ->setAliases(['dq']); } /** @@ -54,9 +55,9 @@ protected function execute(InputInterface $input, OutputInterface $output) $io = new DrupalStyle($input, $output); $tableHeader = [ - $this->trans('commands.queue.debug.messages.queue'), - $this->trans('commands.queue.debug.messages.items'), - $this->trans('commands.queue.debug.messages.class') + $this->trans('commands.debug.queue.messages.queue'), + $this->trans('commands.debug.queue.messages.items'), + $this->trans('commands.debug.queue.messages.class') ]; $tableBody = $this->listQueues(); diff --git a/src/Command/Rest/DebugCommand.php b/src/Command/Debug/RestCommand.php similarity index 69% rename from src/Command/Rest/DebugCommand.php rename to src/Command/Debug/RestCommand.php index 2f4bb8343..1497365da 100644 --- a/src/Command/Rest/DebugCommand.php +++ b/src/Command/Debug/RestCommand.php @@ -2,19 +2,18 @@ /** * @file - * Contains \Drupal\Console\Command\Rest\DebugCommand. + * Contains \Drupal\Console\Command\Debug\RestCommand. */ -namespace Drupal\Console\Command\Rest; +namespace Drupal\Console\Command\Debug; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Annotations\DrupalCommand; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Command\Shared\RestTrait; use Drupal\rest\Plugin\Type\ResourcePluginManager; @@ -24,19 +23,18 @@ * extensionType = "module" * ) */ -class DebugCommand extends Command +class RestCommand extends Command { - use CommandTrait; use RestTrait; - /** * @var ResourcePluginManager $pluginManagerRest */ protected $pluginManagerRest; /** - * DebugCommand constructor. + * RestCommand constructor. + * * @param ResourcePluginManager $pluginManagerRest */ public function __construct(ResourcePluginManager $pluginManagerRest) @@ -48,19 +46,20 @@ public function __construct(ResourcePluginManager $pluginManagerRest) protected function configure() { $this - ->setName('rest:debug') - ->setDescription($this->trans('commands.rest.debug.description')) + ->setName('debug:rest') + ->setDescription($this->trans('commands.debug.rest.description')) ->addArgument( 'resource-id', InputArgument::OPTIONAL, - $this->trans('commands.rest.debug.arguments.resource-id') + $this->trans('commands.debug.rest.arguments.resource-id') ) ->addOption( 'authorization', - '', + null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.rest.debug.options.status') - ); + $this->trans('commands.debug.rest.options.status') + ) + ->setAliases(['rede']); } protected function execute(InputInterface $input, OutputInterface $output) @@ -88,7 +87,7 @@ private function restDetail(DrupalStyle $io, $resource_id) if (empty($plugin)) { $io->error( sprintf( - $this->trans('commands.rest.debug.messages.not-found'), + $this->trans('commands.debug.rest.messages.not-found'), $resource_id ) ); @@ -100,24 +99,24 @@ private function restDetail(DrupalStyle $io, $resource_id) $configuration = []; $configuration[] = [ - $this->trans('commands.rest.debug.messages.id'), + $this->trans('commands.debug.rest.messages.id'), $resource['id'] ]; $configuration[] = [ - $this->trans('commands.rest.debug.messages.label'), + $this->trans('commands.debug.rest.messages.label'), (string) $resource['label'] ]; $configuration[] = [ - $this->trans('commands.rest.debug.messages.canonical_url'), + $this->trans('commands.debug.rest.messages.canonical-url'), $resource['uri_paths']['canonical'] ]; $configuration[] = [ - $this->trans('commands.rest.debug.messages.status'), - (isset($config[$resource['id']])) ? $this->trans('commands.rest.debug.messages.enabled') : $this->trans('commands.rest.debug.messages.disabled')]; + $this->trans('commands.debug.rest.messages.status'), + (isset($config[$resource['id']])) ? $this->trans('commands.debug.rest.messages.enabled') : $this->trans('commands.debug.rest.messages.disabled')]; $configuration[] = [ $this->trans( sprintf( - 'commands.rest.debug.messages.provider', + 'commands.debug.rest.messages.provider', $resource['provider'] ) ) @@ -129,9 +128,9 @@ private function restDetail(DrupalStyle $io, $resource_id) $io->table([], $configuration, 'compact'); $tableHeader = [ - $this->trans('commands.rest.debug.messages.rest-state'), - $this->trans('commands.rest.debug.messages.supported-formats'), - $this->trans('commands.rest.debug.messages.supported_auth'), + $this->trans('commands.debug.rest.messages.rest-state'), + $this->trans('commands.debug.rest.messages.supported-formats'), + $this->trans('commands.debug.rest.messages.supported-auth'), ]; $tableRows = []; @@ -139,7 +138,7 @@ private function restDetail(DrupalStyle $io, $resource_id) $tableRows[] = [ $method, implode(', ', $settings['supported_formats']), - implode(', ', $settings['supported_auth']), + implode(', ', $settings['supported-auth']), ]; } @@ -151,11 +150,11 @@ protected function restList(DrupalStyle $io, $status) $rest_resources = $this->getRestResources($status); $tableHeader = [ - $this->trans('commands.rest.debug.messages.id'), - $this->trans('commands.rest.debug.messages.label'), - $this->trans('commands.rest.debug.messages.canonical_url'), - $this->trans('commands.rest.debug.messages.status'), - $this->trans('commands.rest.debug.messages.provider'), + $this->trans('commands.debug.rest.messages.id'), + $this->trans('commands.debug.rest.messages.label'), + $this->trans('commands.debug.rest.messages.canonical-url'), + $this->trans('commands.debug.rest.messages.status'), + $this->trans('commands.debug.rest.messages.provider'), ]; $tableRows = []; diff --git a/src/Command/Router/DebugCommand.php b/src/Command/Debug/RouterCommand.php similarity index 70% rename from src/Command/Router/DebugCommand.php rename to src/Command/Debug/RouterCommand.php index a620340c7..726f0bdc7 100644 --- a/src/Command/Router/DebugCommand.php +++ b/src/Command/Debug/RouterCommand.php @@ -2,24 +2,21 @@ /** * @file - * Contains \Drupal\Console\Command\RouterDebugCommand. + * Contains \Drupal\Console\Command\Debug\RouterCommand. */ -namespace Drupal\Console\Command\Router; +namespace Drupal\Console\Command\Debug; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Routing\RouteProviderInterface; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Component\Serialization\Yaml; -class DebugCommand extends Command +class RouterCommand extends Command { - use CommandTrait; - /** * @var RouteProviderInterface */ @@ -27,6 +24,7 @@ class DebugCommand extends Command /** * DebugCommand constructor. + * * @param RouteProviderInterface $routeProvider */ public function __construct(RouteProviderInterface $routeProvider) @@ -38,13 +36,14 @@ public function __construct(RouteProviderInterface $routeProvider) protected function configure() { $this - ->setName('router:debug') - ->setDescription($this->trans('commands.router.debug.description')) + ->setName('debug:router') + ->setDescription($this->trans('commands.debug.router.description')) ->addArgument( 'route-name', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, - $this->trans('commands.router.debug.arguments.route-name') - ); + $this->trans('commands.debug.router.arguments.route-name') + ) + ->setAliases(['dr']); } protected function execute(InputInterface $input, OutputInterface $output) @@ -65,8 +64,8 @@ protected function getAllRoutes(DrupalStyle $io) $routes = $this->routeProvider->getAllRoutes(); $tableHeader = [ - $this->trans('commands.router.debug.messages.name'), - $this->trans('commands.router.debug.messages.path'), + $this->trans('commands.debug.router.messages.name'), + $this->trans('commands.debug.router.messages.path'), ]; $tableRows = []; @@ -83,23 +82,29 @@ protected function getRouteByNames(DrupalStyle $io, $route_name) foreach ($routes as $name => $route) { $tableHeader = [ - $this->trans('commands.router.debug.messages.route'), + $this->trans('commands.debug.router.messages.route'), ''.$name.'' ]; $tableRows = []; $tableRows[] = [ - ''.$this->trans('commands.router.debug.messages.path').'', + ''.$this->trans('commands.debug.router.messages.path').'', $route->getPath(), ]; - $tableRows[] = [''.$this->trans('commands.router.debug.messages.defaults').'']; + $tableRows[] = [''.$this->trans('commands.debug.router.messages.defaults').'']; $attributes = $this->addRouteAttributes($route->getDefaults()); foreach ($attributes as $attribute) { $tableRows[] = $attribute; } - $tableRows[] = [''.$this->trans('commands.router.debug.messages.options').'']; + $tableRows[] = [''.$this->trans('commands.debug.router.messages.requirements').'']; + $requirements = $this->addRouteAttributes($route->getRequirements()); + foreach ($requirements as $requirement) { + $tableRows[] = $requirement; + } + + $tableRows[] = [''.$this->trans('commands.debug.router.messages.options').'']; $options = $this->addRouteAttributes($route->getOptions()); foreach ($options as $option) { $tableRows[] = $option; diff --git a/src/Command/State/DebugCommand.php b/src/Command/Debug/StateCommand.php similarity index 71% rename from src/Command/State/DebugCommand.php rename to src/Command/Debug/StateCommand.php index a3f639467..88fc5dacd 100644 --- a/src/Command/State/DebugCommand.php +++ b/src/Command/Debug/StateCommand.php @@ -2,29 +2,27 @@ /** * @file - * Contains \Drupal\Console\Command\State\DebugCommand. + * Contains \Drupal\Console\Command\Debug\DebugCommand. */ -namespace Drupal\Console\Command\State; +namespace Drupal\Console\Command\Debug; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\KeyValueStore\KeyValueFactoryInterface; use Drupal\Core\State\StateInterface; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Component\Serialization\Yaml; /** * Class DebugCommand - * @package Drupal\Console\Command\State + * + * @package Drupal\Console\Command\Debug */ -class DebugCommand extends Command +class StateCommand extends Command { - use CommandTrait; - /** * @var StateInterface */ @@ -37,6 +35,7 @@ class DebugCommand extends Command /** * DebugCommand constructor. + * * @param StateInterface $state * @param KeyValueFactoryInterface $keyValue */ @@ -55,14 +54,15 @@ public function __construct( protected function configure() { $this - ->setName('state:debug') - ->setDescription($this->trans('commands.state.debug.description')) - ->setHelp($this->trans('commands.state.debug.help')) + ->setName('debug:state') + ->setDescription($this->trans('commands.debug.state.description')) ->addArgument( 'key', InputArgument::OPTIONAL, - $this->trans('commands.state.debug.arguments.key') - ); + $this->trans('commands.debug.state.arguments.key') + ) + ->setHelp($this->trans('commands.debug.state.help')) + ->setAliases(['dst']); } /** @@ -80,7 +80,7 @@ protected function execute(InputInterface $input, OutputInterface $output) return 0; } - $tableHeader = [$this->trans('commands.state.debug.messages.key')]; + $tableHeader = [$this->trans('commands.debug.state.messages.key')]; $keyStoreStates = array_keys($this->keyValue->get('state')->getAll()); $io->table($tableHeader, $keyStoreStates); diff --git a/src/Command/Test/DebugCommand.php b/src/Command/Debug/TestCommand.php similarity index 80% rename from src/Command/Test/DebugCommand.php rename to src/Command/Debug/TestCommand.php index 24470bab0..1985b50e4 100644 --- a/src/Command/Test/DebugCommand.php +++ b/src/Command/Debug/TestCommand.php @@ -2,20 +2,19 @@ /** * @file - * Contains \Drupal\Console\Command\Test\DebugCommand. + * Contains \Drupal\Console\Command\Debug\TestCommand. */ -namespace Drupal\Console\Command\Test; +namespace Drupal\Console\Command\Debug; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Drupal\Component\Serialization\Yaml; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Annotations\DrupalCommand; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\simpletest\TestDiscovery; /** @@ -24,18 +23,17 @@ * extensionType = "module", * ) */ -class DebugCommand extends Command +class TestCommand extends Command { - use CommandTrait; - /** * @var TestDiscovery */ protected $test_discovery; /** - * DebugCommand constructor. - * @param TestDiscovery $test_discovery + * TestCommand constructor. + * + * @param TestDiscovery $test_discovery */ public function __construct( TestDiscovery $test_discovery @@ -48,20 +46,21 @@ public function __construct( protected function configure() { $this - ->setName('test:debug') - ->setDescription($this->trans('commands.test.debug.description')) + ->setName('debug:test') + ->setDescription($this->trans('commands.debug.test.description')) ->addArgument( 'group', InputArgument::OPTIONAL, - $this->trans('commands.test.debug.options.group'), + $this->trans('commands.debug.test.options.group'), null ) ->addOption( 'test-class', - '', + null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.test.debug.arguments.test-class') - ); + $this->trans('commands.debug.test.arguments.test-class') + ) + ->setAliases(['td']); } /** @@ -122,7 +121,7 @@ private function testDetail(DrupalStyle $io, $test_class) if ($class) { $methods = $class->getMethods(\ReflectionMethod::IS_PUBLIC); - $io->info($this->trans('commands.test.debug.messages.methods')); + $io->info($this->trans('commands.debug.test.messages.methods')); foreach ($methods as $method) { if ($method->class == $testDetails['name'] && strpos($method->name, 'test') === 0) { $io->simple($method->name); @@ -130,7 +129,7 @@ private function testDetail(DrupalStyle $io, $test_class) } } } else { - $io->error($this->trans('commands.test.debug.messages.not-found')); + $io->error($this->trans('commands.debug.test.messages.not-found')); } } @@ -140,17 +139,17 @@ protected function testList(DrupalStyle $io, $group) ->getTestClasses(null); if (empty($group)) { - $tableHeader = [$this->trans('commands.test.debug.messages.group')]; + $tableHeader = [$this->trans('commands.debug.test.messages.group')]; } else { $tableHeader = [ - $this->trans('commands.test.debug.messages.class'), - $this->trans('commands.test.debug.messages.type') + $this->trans('commands.debug.test.messages.class'), + $this->trans('commands.debug.test.messages.type') ]; $io->writeln( sprintf( '%s: %s', - $this->trans('commands.test.debug.messages.group'), + $this->trans('commands.debug.test.messages.group'), $group ) ); @@ -184,13 +183,13 @@ protected function testList(DrupalStyle $io, $group) if ($group) { $io->success( sprintf( - $this->trans('commands.test.debug.messages.success-group'), + $this->trans('commands.debug.test.messages.success-group'), $group ) ); } else { $io->success( - $this->trans('commands.test.debug.messages.success-groups') + $this->trans('commands.debug.test.messages.success-groups') ); } } diff --git a/src/Command/Theme/DebugCommand.php b/src/Command/Debug/ThemeCommand.php similarity index 74% rename from src/Command/Theme/DebugCommand.php rename to src/Command/Debug/ThemeCommand.php index 695956909..84a68ce23 100644 --- a/src/Command/Theme/DebugCommand.php +++ b/src/Command/Debug/ThemeCommand.php @@ -2,24 +2,21 @@ /** * @file - * Contains \Drupal\Console\Command\Theme\Debugommand. + * Contains \Drupal\Console\Command\Debug\ThemeCommand. */ -namespace Drupal\Console\Command\Theme; +namespace Drupal\Console\Command\Debug; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Extension\ThemeHandler; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; -class DebugCommand extends Command +class ThemeCommand extends Command { - use CommandTrait; - /** * @var ConfigFactory */ @@ -32,8 +29,9 @@ class DebugCommand extends Command /** * DebugCommand constructor. + * * @param ConfigFactory $configFactory - * @param ThemeHandler $themeHandler + * @param ThemeHandler $themeHandler */ public function __construct( ConfigFactory $configFactory, @@ -47,9 +45,14 @@ public function __construct( protected function configure() { $this - ->setName('theme:debug') - ->setDescription($this->trans('commands.theme.debug.description')) - ->addArgument('theme', InputArgument::OPTIONAL, $this->trans('commands.theme.debug.arguments.theme')); + ->setName('debug:theme') + ->setDescription($this->trans('commands.debug.theme.description')) + ->addArgument( + 'theme', + InputArgument::OPTIONAL, + $this->trans('commands.debug.theme.arguments.theme') + ) + ->setAliases(['dt']); } protected function execute(InputInterface $input, OutputInterface $output) @@ -67,10 +70,10 @@ protected function execute(InputInterface $input, OutputInterface $output) protected function themeList(DrupalStyle $io) { $tableHeader = [ - $this->trans('commands.theme.debug.messages.theme-id'), - $this->trans('commands.theme.debug.messages.theme-name'), - $this->trans('commands.theme.debug.messages.status'), - $this->trans('commands.theme.debug.messages.version'), + $this->trans('commands.debug.theme.messages.theme-id'), + $this->trans('commands.debug.theme.messages.theme-name'), + $this->trans('commands.debug.theme.messages.status'), + $this->trans('commands.debug.theme.messages.version'), ]; $themes = $this->themeHandler->rebuildThemeData(); @@ -112,7 +115,7 @@ protected function themeDetail(DrupalStyle $io, $themeId) $io->comment( sprintf( '%s : ', - $this->trans('commands.theme.debug.messages.status') + $this->trans('commands.debug.theme.messages.status') ), false ); @@ -120,18 +123,18 @@ protected function themeDetail(DrupalStyle $io, $themeId) $io->comment( sprintf( '%s : ', - $this->trans('commands.theme.debug.messages.version') + $this->trans('commands.debug.theme.messages.version') ), false ); $io->writeln($theme->info['version']); - $io->comment($this->trans('commands.theme.debug.messages.regions')); + $io->comment($this->trans('commands.debug.theme.messages.regions')); $tableRows = $this->addThemeAttributes($theme->info['regions'], $tableRows); $io->table([], $tableRows); } else { $io->error( sprintf( - $this->trans('commands.theme.debug.messages.invalid-theme'), + $this->trans('commands.debug.theme.messages.invalid-theme'), $themeId ) ); @@ -142,9 +145,9 @@ protected function getThemeStatus($theme) { $defaultTheme = $this->configFactory->get('system.theme')->get('default'); - $status = ($theme->status)?$this->trans('commands.theme.debug.messages.installed'):$this->trans('commands.theme.debug.messages.uninstalled'); + $status = ($theme->status)?$this->trans('commands.debug.theme.messages.installed'):$this->trans('commands.debug.theme.messages.uninstalled'); if ($defaultTheme == $theme) { - $status = $this->trans('commands.theme.debug.messages.default-theme'); + $status = $this->trans('commands.debug.theme.messages.default-theme'); } return $status; diff --git a/src/Command/Update/DebugCommand.php b/src/Command/Debug/UpdateCommand.php similarity index 72% rename from src/Command/Update/DebugCommand.php rename to src/Command/Debug/UpdateCommand.php index 6fbc2fd53..6aebfccaa 100644 --- a/src/Command/Update/DebugCommand.php +++ b/src/Command/Debug/UpdateCommand.php @@ -2,23 +2,20 @@ /** * @file - * Contains \Drupal\Console\Command\Update\DebugCommand. + * Contains \Drupal\Console\Command\Debug\UpdateCommand. */ -namespace Drupal\Console\Command\Update; +namespace Drupal\Console\Command\Debug; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Update\UpdateRegistry; -use Drupal\Console\Command\Shared\CommandTrait; use Drupal\Console\Utils\Site; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; -class DebugCommand extends Command +class UpdateCommand extends Command { - use CommandTrait; - /** * @var Site */ @@ -31,6 +28,7 @@ class DebugCommand extends Command /** * DebugCommand constructor. + * * @param Site $site * @param UpdateRegistry $postUpdateRegistry */ @@ -49,8 +47,9 @@ public function __construct( protected function configure() { $this - ->setName('update:debug') - ->setDescription($this->trans('commands.update.debug.description')); + ->setName('debug:update') + ->setDescription($this->trans('commands.debug.update.description')) + ->setAliases(['du']); } /** @@ -75,7 +74,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($severity == REQUIREMENT_ERROR || ($severity == REQUIREMENT_WARNING)) { $this->populateRequirements($io, $requirements); } elseif (empty($updates)) { - $io->info($this->trans('commands.update.debug.messages.no-updates')); + $io->info($this->trans('commands.debug.update.messages.no-updates')); } else { $this->populateUpdate($io, $updates); $this->populatePostUpdate($io); @@ -83,18 +82,18 @@ protected function execute(InputInterface $input, OutputInterface $output) } /** - * @param \Drupal\Console\Style\DrupalStyle $io + * @param \Drupal\Console\Core\Style\DrupalStyle $io * @param $requirements */ private function populateRequirements(DrupalStyle $io, $requirements) { - $io->info($this->trans('commands.update.debug.messages.requirements-error')); + $io->info($this->trans('commands.debug.update.messages.requirements-error')); $tableHeader = [ - $this->trans('commands.update.debug.messages.severity'), - $this->trans('commands.update.debug.messages.title'), - $this->trans('commands.update.debug.messages.value'), - $this->trans('commands.update.debug.messages.description'), + $this->trans('commands.debug.update.messages.severity'), + $this->trans('commands.debug.update.messages.title'), + $this->trans('commands.debug.update.messages.value'), + $this->trans('commands.debug.update.messages.description'), ]; $tableRows = []; @@ -117,16 +116,16 @@ private function populateRequirements(DrupalStyle $io, $requirements) } /** - * @param \Drupal\Console\Style\DrupalStyle $io + * @param \Drupal\Console\Core\Style\DrupalStyle $io * @param $updates */ private function populateUpdate(DrupalStyle $io, $updates) { - $io->info($this->trans('commands.update.debug.messages.module-list')); + $io->info($this->trans('commands.debug.update.messages.module-list')); $tableHeader = [ - $this->trans('commands.update.debug.messages.module'), - $this->trans('commands.update.debug.messages.update-n'), - $this->trans('commands.update.debug.messages.description') + $this->trans('commands.debug.update.messages.module'), + $this->trans('commands.debug.update.messages.update-n'), + $this->trans('commands.debug.update.messages.description') ]; $tableRows = []; foreach ($updates as $module => $module_updates) { @@ -143,17 +142,17 @@ private function populateUpdate(DrupalStyle $io, $updates) } /** - * @param \Drupal\Console\Style\DrupalStyle $io + * @param \Drupal\Console\Core\Style\DrupalStyle $io */ private function populatePostUpdate(DrupalStyle $io) { $io->info( - $this->trans('commands.update.debug.messages.module-list-post-update') + $this->trans('commands.debug.update.messages.module-list-post-update') ); $tableHeader = [ - $this->trans('commands.update.debug.messages.module'), - $this->trans('commands.update.debug.messages.post-update'), - $this->trans('commands.update.debug.messages.description') + $this->trans('commands.debug.update.messages.module'), + $this->trans('commands.debug.update.messages.post-update'), + $this->trans('commands.debug.update.messages.description') ]; $postUpdates = $this->postUpdateRegistry->getPendingUpdateInformation(); diff --git a/src/Command/User/DebugCommand.php b/src/Command/Debug/UserCommand.php similarity index 80% rename from src/Command/User/DebugCommand.php rename to src/Command/Debug/UserCommand.php index 450224bc0..48a73c59a 100644 --- a/src/Command/User/DebugCommand.php +++ b/src/Command/Debug/UserCommand.php @@ -5,26 +5,24 @@ * Contains \Drupal\Console\Command\User\DebugCommand. */ -namespace Drupal\Console\Command\User; +namespace Drupal\Console\Command\Debug; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\Query\QueryFactory; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Utils\DrupalApi; /** - * Class DebugCommand - * @package Drupal\Console\Command\User + * Class UserCommand + * + * @package Drupal\Console\Command\Debug */ -class DebugCommand extends Command +class UserCommand extends Command { - use CommandTrait; - /** * @var EntityTypeManagerInterface */ @@ -42,9 +40,10 @@ class DebugCommand extends Command /** * DebugCommand constructor. + * * @param EntityTypeManagerInterface $entityTypeManager - * @param QueryFactory $entityQuery - * @param DrupalApi $drupalApi + * @param QueryFactory $entityQuery + * @param DrupalApi $drupalApi */ public function __construct( EntityTypeManagerInterface $entityTypeManager, @@ -63,38 +62,38 @@ public function __construct( protected function configure() { $this - ->setName('user:debug') - ->setDescription($this->trans('commands.user.debug.description')) + ->setName('debug:user') + ->setDescription($this->trans('commands.debug.user.description')) ->addOption( 'uid', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, - $this->trans('commands.user.debug.options.uid') + $this->trans('commands.debug.user.options.uid') ) ->addOption( 'username', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, - $this->trans('commands.user.debug.options.username') + $this->trans('commands.debug.user.options.username') ) ->addOption( 'mail', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, - $this->trans('commands.user.debug.options.mail') + $this->trans('commands.debug.user.options.mail') ) ->addOption( 'roles', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_OPTIONAL, - $this->trans('commands.user.debug.options.roles') + $this->trans('commands.debug.user.options.roles') ) ->addOption( 'limit', null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.user.debug.options.limit') - ); + $this->trans('commands.debug.user.options.limit') + )->setAliases(['dus']); } /** @@ -151,10 +150,10 @@ protected function execute(InputInterface $input, OutputInterface $output) $users = $userStorage->loadMultiple($results); $tableHeader = [ - $this->trans('commands.user.debug.messages.user-id'), - $this->trans('commands.user.debug.messages.username'), - $this->trans('commands.user.debug.messages.roles'), - $this->trans('commands.user.debug.messages.status'), + $this->trans('commands.debug.user.messages.user-id'), + $this->trans('commands.debug.user.messages.username'), + $this->trans('commands.debug.user.messages.roles'), + $this->trans('commands.debug.user.messages.status'), ]; $tableRows = []; diff --git a/src/Command/Views/DebugCommand.php b/src/Command/Debug/ViewsCommand.php similarity index 74% rename from src/Command/Views/DebugCommand.php rename to src/Command/Debug/ViewsCommand.php index 8e60acc24..4f0a0016d 100644 --- a/src/Command/Views/DebugCommand.php +++ b/src/Command/Debug/ViewsCommand.php @@ -2,29 +2,27 @@ /** * @file - * Contains \Drupal\Console\Command\Views\DebugCommand. + * Contains \Drupal\Console\Command\Debug\ViewsCommand. */ -namespace Drupal\Console\Command\Views; +namespace Drupal\Console\Command\Debug; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\views\Entity\View; -use Drupal\Console\Command\Shared\CommandTrait; use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** - * Class DebugCommand - * @package Drupal\Console\Command\Views + * Class ViewsCommand + * + * @package Drupal\Console\Command\Debug */ -class DebugCommand extends Command +class ViewsCommand extends Command { - use CommandTrait; - /** * @var EntityTypeManagerInterface */ @@ -32,9 +30,11 @@ class DebugCommand extends Command /** * DebugCommand constructor. + * * @param EntityTypeManagerInterface $entityTypeManager */ - public function __construct(EntityTypeManagerInterface $entityTypeManager) { + public function __construct(EntityTypeManagerInterface $entityTypeManager) + { $this->entityTypeManager = $entityTypeManager; parent::__construct(); } @@ -45,24 +45,25 @@ public function __construct(EntityTypeManagerInterface $entityTypeManager) { protected function configure() { $this - ->setName('views:debug') - ->setDescription($this->trans('commands.views.debug.description')) + ->setName('debug:views') + ->setDescription($this->trans('commands.debug.views.description')) ->addArgument( 'view-id', InputArgument::OPTIONAL, - $this->trans('commands.views.debug.arguments.view-id') + $this->trans('commands.debug.views.arguments.view-id') ) ->addOption( 'tag', - '', + null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.views.debug.arguments.view-tag') + $this->trans('commands.debug.views.arguments.view-tag') )->addOption( 'status', - '', + null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.views.debug.arguments.view-status') - ); + $this->trans('commands.debug.views.arguments.view-status') + ) + ->setAliases(['vde']); } /** @@ -92,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output) /** - * @param \Drupal\Console\Style\DrupalStyle $io + * @param \Drupal\Console\Core\Style\DrupalStyle $io * @param $view_id * @return bool */ @@ -101,31 +102,31 @@ private function viewDetail(DrupalStyle $io, $view_id) $view = $this->entityTypeManager->getStorage('view')->load($view_id); if (empty($view)) { - $io->error(sprintf($this->trans('commands.views.debug.messages.not-found'), $view_id)); + $io->error(sprintf($this->trans('commands.debug.views.messages.not-found'), $view_id)); return false; } - $configuration = array(); - $configuration [] = [$this->trans('commands.views.debug.messages.view-id'), $view->get('id')]; - $configuration [] = [$this->trans('commands.views.debug.messages.view-name'), (string) $view->get('label')]; - $configuration [] = [$this->trans('commands.views.debug.messages.tag'), $view->get('tag')]; - $configuration [] = [$this->trans('commands.views.debug.messages.status'), $view->status() ? $this->trans('commands.common.status.enabled') : $this->trans('commands.common.status.disabled')]; - $configuration [] = [$this->trans('commands.views.debug.messages.description'), $view->get('description')]; + $configuration = []; + $configuration [] = [$this->trans('commands.debug.views.messages.view-id'), $view->get('id')]; + $configuration [] = [$this->trans('commands.debug.views.messages.view-name'), (string) $view->get('label')]; + $configuration [] = [$this->trans('commands.debug.views.messages.tag'), $view->get('tag')]; + $configuration [] = [$this->trans('commands.debug.views.messages.status'), $view->status() ? $this->trans('commands.common.status.enabled') : $this->trans('commands.common.status.disabled')]; + $configuration [] = [$this->trans('commands.debug.views.messages.description'), $view->get('description')]; $io->comment($view_id); $io->table([], $configuration); $tableHeader = [ - $this->trans('commands.views.debug.messages.display-id'), - $this->trans('commands.views.debug.messages.display-name'), - $this->trans('commands.views.debug.messages.display-description'), - $this->trans('commands.views.debug.messages.display-paths'), + $this->trans('commands.debug.views.messages.display-id'), + $this->trans('commands.debug.views.messages.display-name'), + $this->trans('commands.debug.views.messages.display-description'), + $this->trans('commands.debug.views.messages.display-paths'), ]; $displays = $this->viewDisplayList($view); - $io->info(sprintf($this->trans('commands.views.debug.messages.display-list'), $view_id)); + $io->info(sprintf($this->trans('commands.debug.views.messages.display-list'), $view_id)); $tableRows = []; foreach ($displays as $display_id => $display) { @@ -141,7 +142,7 @@ private function viewDetail(DrupalStyle $io, $view_id) } /** - * @param \Drupal\Console\Style\DrupalStyle $io + * @param \Drupal\Console\Core\Style\DrupalStyle $io * @param $tag * @param $status */ @@ -150,11 +151,11 @@ protected function viewList(DrupalStyle $io, $tag, $status) $views = $this->entityTypeManager->getStorage('view')->loadMultiple(); $tableHeader = [ - $this->trans('commands.views.debug.messages.view-id'), - $this->trans('commands.views.debug.messages.view-name'), - $this->trans('commands.views.debug.messages.tag'), - $this->trans('commands.views.debug.messages.status'), - $this->trans('commands.views.debug.messages.path') + $this->trans('commands.debug.views.messages.view-id'), + $this->trans('commands.debug.views.messages.view-name'), + $this->trans('commands.debug.views.messages.tag'), + $this->trans('commands.debug.views.messages.status'), + $this->trans('commands.debug.views.messages.path') ]; $tableRows = []; @@ -185,7 +186,7 @@ protected function viewList(DrupalStyle $io, $tag, $status) */ protected function viewDisplayPaths(View $view, $display_id = null) { - $all_paths = array(); + $all_paths = []; $executable = $view->getExecutable(); $executable->initDisplay(); foreach ($executable->displayHandlers as $display) { @@ -215,7 +216,7 @@ protected function viewDisplayPaths(View $view, $display_id = null) protected function viewDisplayList(View $view) { $displayManager = $this->getViewDisplayManager(); - $displays = array(); + $displays = []; foreach ($view->get('display') as $display) { $definition = $displayManager->getDefinition($display['display_plugin']); if (!empty($definition['admin'])) { diff --git a/src/Command/Views/PluginsDebugCommand.php b/src/Command/Debug/ViewsPluginsCommand.php similarity index 61% rename from src/Command/Views/PluginsDebugCommand.php rename to src/Command/Debug/ViewsPluginsCommand.php index 6939f801a..8a86774e5 100644 --- a/src/Command/Views/PluginsDebugCommand.php +++ b/src/Command/Debug/ViewsPluginsCommand.php @@ -2,39 +2,38 @@ /** * @file - * Contains \Drupal\Console\Command\Views\PluginsDebugCommand. + * Contains \Drupal\Console\Command\Debug\ViewsPluginsCommand. */ -namespace Drupal\Console\Command\Views; +namespace Drupal\Console\Command\Debug; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\ContainerAwareCommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\ContainerAwareCommand; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\views\Views; /** - * Class PluginsDebugCommand - * @package Drupal\Console\Command\Views + * Class ViewsPluginsCommand + * + * @package Drupal\Console\Command\Debug */ -class PluginsDebugCommand extends Command +class ViewsPluginsCommand extends ContainerAwareCommand { - use ContainerAwareCommandTrait; /** * {@inheritdoc} */ protected function configure() { $this - ->setName('views:plugins:debug') - ->setDescription($this->trans('commands.views.plugins.debug.description')) + ->setName('debug:views:plugins') + ->setDescription($this->trans('commands.debug.views.plugins.description')) ->addArgument( 'type', InputArgument::OPTIONAL, - $this->trans('commands.views.plugins.debug.arguments.type') - ); + $this->trans('commands.debug.views.plugins.arguments.type') + )->setAliases(['dvp']); } /** @@ -49,7 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } /** - * @param \Drupal\Console\Style\DrupalStyle $io + * @param \Drupal\Console\Core\Style\DrupalStyle $io * @param $type */ protected function pluginList(DrupalStyle $io, $type) @@ -75,10 +74,10 @@ protected function pluginList(DrupalStyle $io, $type) $tableHeader = [ - $this->trans('commands.views.plugins.debug.messages.type'), - $this->trans('commands.views.plugins.debug.messages.name'), - $this->trans('commands.views.plugins.debug.messages.provider'), - $this->trans('commands.views.plugins.debug.messages.views'), + $this->trans('commands.debug.views.plugins.messages.type'), + $this->trans('commands.debug.views.plugins.messages.name'), + $this->trans('commands.debug.views.plugins.messages.provider'), + $this->trans('commands.debug.views.plugins.messages.views'), ]; $io->table($tableHeader, $rows, 'compact'); diff --git a/src/Command/DumperCommand.php b/src/Command/DevelDumperCommand.php similarity index 67% rename from src/Command/DumperCommand.php rename to src/Command/DevelDumperCommand.php index 94d89425b..f19d0412e 100644 --- a/src/Command/DumperCommand.php +++ b/src/Command/DevelDumperCommand.php @@ -7,14 +7,13 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\ContainerAwareCommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\ContainerAwareCommand; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\devel\DevelDumperPluginManager; use Drupal\devel\DevelDumperManager; /** - * Class DumperCommand. + * Class DevelDumperCommand. * Command to quickly change between devel dumpers from the command line * * @package Drupal\Console\Command @@ -23,9 +22,23 @@ * @todo Move to namespace Devel * @todo Load devel.module legacy file */ -class DumperCommand extends Command +class DevelDumperCommand extends ContainerAwareCommand { - use ContainerAwareCommandTrait; + /** + * @var DevelDumperPluginManager + */ + protected $develDumperPluginManager; + + /** + * DevelDumperCommand constructor. + */ + public function __construct( + DevelDumperPluginManager $develDumperPluginManager = null + ) { + $this->develDumperPluginManager = $develDumperPluginManager; + + parent::__construct(); + } /** * {@inheritdoc} @@ -34,12 +47,12 @@ protected function configure() { $this ->setName('devel:dumper') - ->setDescription($this->trans('Change the devel dumper plugin')) + ->setDescription($this->trans('commands.devel.dumper.messages.change-devel-dumper-plugin')) ->addArgument( 'dumper', InputArgument::OPTIONAL, - $this->trans('Name of the devel dumper plugin') - ); + $this->trans('commands.devel.dumper.messages.name-devel-dumper-plugin') + )->setAliases(['dd']); } /** @@ -49,7 +62,7 @@ protected function interact(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); if (!\Drupal::moduleHandler()->moduleExists('devel')) { - $io->error($this->trans('Devel must be installed')); + $io->error($this->trans('commands.devel.dumper.messages.devel-must-be-installed')); return 1; } @@ -60,7 +73,7 @@ protected function interact(InputInterface $input, OutputInterface $output) $dumpKeys = $this->getDumperKeys(); $dumper = $io->choice( - $this->trans('Select a Debug Dumper'), + $this->trans('commands.devel.dumper.messages.select-debug-dumper'), $dumpKeys, 'kint', //Make kint the default for quick 'switchback' false @@ -81,7 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $dumper = $input->getArgument('dumper'); $dumpKeys = $this->getDumperKeys(); if (!in_array($dumper, $dumpKeys)) { - $io->error($this->trans('Dumper does not exist')); + $io->error($this->trans('commands.devel.dumper.messages.dumper-not-exist')); return 1; } @@ -92,7 +105,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $develSettings->set('devel_dumper', $dumper)->save(); $io->info( sprintf( - $this->trans('Devel Dumper set to: %s'), + $this->trans('commands.devel.dumper.messages.devel-dumper-set'), $configFactory->get('devel.settings')->get('devel_dumper') ) ); @@ -101,8 +114,7 @@ protected function execute(InputInterface $input, OutputInterface $output) protected function getDumperKeys() { /* @var DevelDumperPluginManager $manager */ - $manager = \Drupal::service('plugin.manager.devel_dumper'); - $plugins = $manager->getDefinitions(); + $plugins = $this->develDumperPluginManager->getDefinitions(); return array_keys($plugins); } } diff --git a/src/Command/Develop/ExampleCommand.php b/src/Command/Develop/ExampleCommand.php deleted file mode 100644 index 17ca3bc4c..000000000 --- a/src/Command/Develop/ExampleCommand.php +++ /dev/null @@ -1,83 +0,0 @@ -setName('develop:example'); - } - - /** - * {@inheritdoc} - */ - protected function interact(InputInterface $input, OutputInterface $output) - { - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - /* Register your command as a service - * - * Make sure you register your command class at - * config/services/namespace.yml file and add the `drupal.command` tag. - * - * develop_example: - * class: Drupal\Console\Command\Develop\ExampleCommand - * arguments: ['@service_id', '@console.service_id'] - * tags: - * - { name: drupal.command } - * - * NOTE: Make the proper changes on the namespace and class - * according your new command. - * - * DrupalConsole extends the SymfonyStyle class to provide - * an standardized Output Formatting Style. - * - * Drupal Console provides the DrupalStyle helper class: - */ - $io = new DrupalStyle($input, $output); - $io->simple('This text could be translatable by'); - $io->simple('adding a YAML file at "config/translations/LANGUAGE/command.name.yml"'); - - /** - * Reading user input argument - * $input->getArgument('ARGUMENT_NAME'); - * - * Reading user input option - * $input->getOption('OPTION_NAME'); - */ - } -} diff --git a/src/Command/Develop/ExampleContainerAwareCommand.php b/src/Command/Develop/ExampleContainerAwareCommand.php deleted file mode 100644 index 641ece2bd..000000000 --- a/src/Command/Develop/ExampleContainerAwareCommand.php +++ /dev/null @@ -1,91 +0,0 @@ -setName('develop:example:container:aware'); - } - - /** - * {@inheritdoc} - */ - protected function interact(InputInterface $input, OutputInterface $output) - { - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - /* Register your command as a service - * - * Make sure you register your command class at - * config/services/namespace.yml file and add the `drupal.command` tag. - * - * develop_example_container_aware: - * class: Drupal\Console\Command\Develop\ExampleContainerAwareCommand - * tags: - * - { name: drupal.command } - * - * NOTE: Make the proper changes on the namespace and class - * according your new command. - * - * DrupalConsole extends the SymfonyStyle class to provide - * an standardized Output Formatting Style. - * - * Drupal Console provides the DrupalStyle helper class: - */ - $io = new DrupalStyle($input, $output); - $io->simple('This text could be translatable by'); - $io->simple('adding a YAML file at "config/translations/LANGUAGE/command.name.yml"'); - - /** - * By using ContainerAwareCommandTrait on your class for the command - * (instead of the more basic CommandTrait), you have access to - * the service container. - * - * In other words, you can access to any configured Drupal service - * using the provided get method. - * - * $this->get('entity_type.manager'); - * - * Reading user input argument - * $input->getArgument('ARGUMENT_NAME'); - * - * Reading user input option - * $input->getOption('OPTION_NAME'); - */ - } -} diff --git a/src/Command/Develop/GenerateDocCheatsheetCommand.php b/src/Command/Develop/GenerateDocCheatsheetCommand.php deleted file mode 100644 index a29b840f5..000000000 --- a/src/Command/Develop/GenerateDocCheatsheetCommand.php +++ /dev/null @@ -1,266 +0,0 @@ -setName('generate:doc:cheatsheet') - ->setDescription($this->trans('commands.generate.doc.cheatsheet.description')) - ->addOption( - 'path', - null, - InputOption::VALUE_OPTIONAL, - $this->trans('commands.generate.doc.cheatsheet.options.path') - ) - ->addOption( - 'wkhtmltopdf', - null, - InputOption::VALUE_OPTIONAL, - $this->trans('commands.generate.doc.cheatsheet.options.wkhtmltopdf') - ); - ; - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $path = null; - - if ($input->hasOption('path')) { - $path = $input->getOption('path'); - } - - if (!$path) { - $io->error( - $this->trans('commands.generate.doc.gitbook.messages.missing_path') - ); - - return 1; - } - - // $wkhtmltopdfPath is overwritable by command option - - if ($input->getOption('wkhtmltopdf')) { - $this->wkhtmltopdfPath = $input->getOption('wkhtmltopdf'); - } - - $application = $this->getApplication(); - $command_list = []; - - foreach ($this->singleCommands as $single_command) { - $command = $application->find($single_command); - $command_list['none'][] = [ - 'name' => $command->getName(), - 'description' => $command->getDescription(), - ]; - } - - $namespaces = $application->getNamespaces(); - sort($namespaces); - - $namespaces = array_filter( - $namespaces, function ($item) { - return (strpos($item, ':')<=0); - } - ); - - foreach ($namespaces as $namespace) { - $commands = $application->all($namespace); - - usort( - $commands, function ($cmd1, $cmd2) { - return strcmp($cmd1->getName(), $cmd2->getName()); - } - ); - - foreach ($commands as $command) { - if ($command->getModule()=='Console') { - $command_list[$namespace][] = [ - 'name' => $command->getName(), - 'description' => $command->getDescription(), - ]; - } - } - } - - if (!empty($command_list)) { - $this->prepareHtml($command_list, $path, $io); - } - } - - - /** - * Generates (programatically, not with twig) the HTML to convert to PDF - * - * @param array $array_content - * @param string $path - */ - protected function prepareHtml($array_content, $path, $io) - { - $str = ''; - $str .= "
Drupal Console cheatsheet
"; - - // 1st page - foreach ($this->orderCommands as $command) { - $str .= $this->doTable($command, $array_content[$command]); - } - - // 2nd page - $str .= "

"; - - $str .= "

DrupalConsole Cheatsheet



"; - - $str .= $this->doTable("generate", $array_content["generate"]); - $str .= $this->doTable("miscelaneous", $array_content["none"]); - - $this->doPdf($str, $path, $io); - } - - - /** - * Generates the pdf with Snappy - * - * @param string $content - * @param string $path - * - * @return string - */ - protected function doPdf($content, $path, $io) - { - $snappy = new Pdf(); - //@TODO: catch exception if binary path doesn't exist! - $snappy->setBinary($this->wkhtmltopdfPath); - $snappy->setOption('orientation', "Landscape"); - $snappy->generateFromHtml($content, "/" .$path . 'dc-cheatsheet.pdf'); - $io->success("cheatsheet generated at /" .$path ."/dc-cheatsheet.pdf"); - - // command execution ends here - } - - /** - * Encloses text in tags - * - * @param string $str - * - * @return string - */ - public function td($str, $mode = null) - { - if ("header" == $mode) { - return "" . strtoupper($str) . ""; - } else { - if ("body" == $mode) { - return "". $str. ""; - } else { - return "" . $str . ""; - } - } - } - - /** - * Encloses text in tags - * - * @param string $str - * @param array $element - * - * @return string - */ - public function tr($str) - { - return "" . $str . ""; - } - - /** - * Encloses text in tag - * - * @param string $key_element - header - * @param array $element - command, description - * - * @return string - */ - public function doTable($key_element, $element) - { - $str = "
"; - $str .= $this->td($key_element, "header"); - - foreach ($element as $section) { - $str .= $this->tr($this->td($section["name"], "body") . $this->td($section["description"], "body")); - } - - return $str . "
\n\r"; - } -} diff --git a/src/Command/Develop/GenerateDocDashCommand.php b/src/Command/Develop/GenerateDocDashCommand.php deleted file mode 100644 index 07328a3d0..000000000 --- a/src/Command/Develop/GenerateDocDashCommand.php +++ /dev/null @@ -1,278 +0,0 @@ - - - - - CFBundleIdentifier - drupalconsole - CFBundleName - Drupal Console - DocSetPlatformFamily - drupalconsole - isDashDocset - - dashIndexFilePath - index.html - - -PLIST; - - private $single_commands = [ - 'about', - 'chain', - 'drush', - 'help', - 'init', - 'list', - 'self-update' - ]; - - /** - * @var SQLite3 Controller for the sqlite db required by the docset format. - */ - private $sqlite; - - /** - * @var ConfigurationManager $configurationManager - */ - protected $configurationManager; - - /** - * GenerateDocDashCommand constructor. - * @param $renderer - * @param $consoleRoot - */ - public function __construct(TwigRenderer $renderer, $consoleRoot) - { - $this->renderer = $renderer; - $this->consoleRoot = $consoleRoot; - parent::__construct(); - } - - - - /** - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('generate:doc:dash') - ->setDescription($this->trans('commands.generate.doc.dash.description')) - ->addOption( - 'path', - null, - InputOption::VALUE_OPTIONAL, - $this->trans('commands.generate.doc.dash.options.path') - ); - ; - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $path = null; - if ($input->hasOption('path')) { - $path = $input->getOption('path'); - } - - if (!$path) { - $io->error( - $this->trans('commands.generate.doc.dash.messages.missing_path') - ); - - return 1; - } - - // Setup the docset structure - $this->initDocset($path); - - $application = $this->getApplication(); - $command_list = []; - - foreach ($this->single_commands as $single_command) { - $command = $application->find($single_command); - $command_list['none'][] = [ - 'name' => $command->getName(), - 'description' => $command->getDescription(), - ]; - $this->renderCommand($command, $path, $this->renderer); - $this->registerCommand($command, $path); - } - - $namespaces = $application->getNamespaces(); - sort($namespaces); - - $namespaces = array_filter( - $namespaces, function ($item) { - return (strpos($item, ':') <= 0); - } - ); - - foreach ($namespaces as $namespace) { - $commands = $application->all($namespace); - - usort( - $commands, function ($cmd1, $cmd2) { - return strcmp($cmd1->getName(), $cmd2->getName()); - } - ); - - foreach ($commands as $command) { - if ($command->getModule() == 'Console') { - $command_list[$namespace][] = [ - 'name' => $command->getName(), - 'description' => $command->getDescription(), - ]; - $this->renderCommand($command, $path, $this->renderer); - $this->registerCommand($command, $path); - } - } - } - - $input = $application->getDefinition(); - $options = $input->getOptions(); - $arguments = $input->getArguments(); - $parameters = [ - 'command_list' => $command_list, - 'options' => $options, - 'arguments' => $arguments, - 'css_path' => 'style.css' - ]; - - // Set the index page - $this->renderFile( - 'dash/index.html.twig', - $path . '/DrupalConsole.docset/Contents/Resources/Documents/index.html', - $parameters, - null, - $this->renderer - ); - } - - private function renderCommand($command, $path, $renderer) - { - $input = $command->getDefinition(); - $options = $input->getOptions(); - $arguments = $input->getArguments(); - - $parameters = [ - 'options' => $options, - 'arguments' => $arguments, - 'command' => $command->getName(), - 'description' => $command->getDescription(), - 'aliases' => $command->getAliases(), - 'css_path' => '../style.css' - ]; - - $this->renderFile( - 'dash/generate-doc.html.twig', - $path . '/DrupalConsole.docset/Contents/Resources/Documents/commands/' - . str_replace(':', '-', $command->getName()) . '.html', - $parameters, - null, - $renderer - ); - } - - private function registerCommand($command) - { - try { - $statement = $this->sqlite->prepare('INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES (:name, :type, :path)'); - $statement->bindValue(':name', $command->getName(), SQLITE3_TEXT); - $statement->bindValue(':type', 'Command', SQLITE3_TEXT); - $statement->bindValue( - ':path', - 'commands/' - . str_replace(':', '-', $command->getName()) . '.html', - SQLITE3_TEXT - ); - $statement->execute(); - } catch (\Exception $e) { - throw $e; - } - } - - private function renderFile( - $template, - $target, - $parameters, - $renderer - ) { - $filesystem = new Filesystem(); - try { - $filesystem->dumpFile( - $target, - $renderer->render($template, $parameters) - ); - } catch (IOException $e) { - throw $e; - } - } - - private function initDocset($path) - { - try { - $filesystem = new Filesystem(); - $filesystem->mkdir( - $path . '/DrupalConsole.docset/Contents/Resources/Documents/', - 0777 - ); - $filesystem->dumpFile( - $path . '/DrupalConsole.docset/Contents/Info.plist', - self::PLIST - ); - - $filesystem->copy( - $this->consoleRoot . '/resources/drupal-console.png', - $path . '/DrupalConsole.docset/icon.png' - ); - $filesystem->copy( - $this->consoleRoot . '/resources/dash.css', - $path . '/DrupalConsole.docset/Contents/Resources/Documents/style.css' - ); - // create the required sqlite db - $this->sqlite = new \SQLite3($path . '/DrupalConsole.docset/Contents/Resources/docSet.dsidx'); - $this->sqlite->query("CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT)"); - $this->sqlite->query("CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path)"); - } catch (\Exception $e) { - throw $e; - } - } -} diff --git a/src/Command/Develop/GenerateDocDataCommand.php b/src/Command/Develop/GenerateDocDataCommand.php deleted file mode 100644 index f6ec7303c..000000000 --- a/src/Command/Develop/GenerateDocDataCommand.php +++ /dev/null @@ -1,61 +0,0 @@ -setName('generate:doc:data') - ->setDescription( - $this->trans('commands.generate.doc.data.description') - ) - ->addOption( - 'file', - null, - InputOption::VALUE_OPTIONAL, - $this->trans('commands.generate.doc.data.options.file') - ); - ; - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - $file = null; - if ($input->hasOption('file')) { - $file = $input->getOption('file'); - } - - $data = $this->getApplication()->getData(); - if ($file) { - file_put_contents($file, json_encode($data, JSON_PRETTY_PRINT)); - - return 0; - } - - $io->write(json_encode($data, JSON_PRETTY_PRINT)); - } -} diff --git a/src/Command/Develop/GenerateDocGitbookCommand.php b/src/Command/Develop/GenerateDocGitbookCommand.php deleted file mode 100644 index 04b515160..000000000 --- a/src/Command/Develop/GenerateDocGitbookCommand.php +++ /dev/null @@ -1,114 +0,0 @@ -renderer = $renderer; - parent::__construct(); - } - - - /** - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('generate:doc:gitbook') - ->setDescription($this->trans('commands.generate.doc.gitbook.description')) - ->addOption( - 'path', - null, - InputOption::VALUE_OPTIONAL, - $this->trans('commands.generate.doc.gitbook.options.path') - ); - ; - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $path = null; - if ($input->hasOption('path')) { - $path = $input->getOption('path'); - } - - if (!$path) { - $io->error( - $this->trans('commands.generate.doc.gitbook.messages.missing_path') - ); - - return 1; - } - - $application = $this->getApplication(); - $applicationData = $application->getData(); - $namespaces = $applicationData['application']['namespaces']; - foreach ($namespaces as $namespace) { - foreach ($applicationData['commands'][$namespace] as $command) { - $this->renderFile( - 'gitbook' . DIRECTORY_SEPARATOR . 'command.md.twig', - $path . DIRECTORY_SEPARATOR . 'commands' . DIRECTORY_SEPARATOR . $command['dashed'] . '.md', - $command, - null, - $this->renderer - ); - } - } - - $this->renderFile( - 'gitbook'.DIRECTORY_SEPARATOR.'available-commands.md.twig', - $path . DIRECTORY_SEPARATOR . 'commands'.DIRECTORY_SEPARATOR.'available-commands.md', - $applicationData, - null, - $this->renderer - ); - - $this->renderFile( - 'gitbook'.DIRECTORY_SEPARATOR.'available-commands-list.md.twig', - $path . DIRECTORY_SEPARATOR . 'commands'.DIRECTORY_SEPARATOR.'available-commands-list.md', - $applicationData, - null, - $this->renderer - ); - } - - private function renderFile($template, $target, $parameters, $flag = null, $renderer) - { - if (!is_dir(dirname($target))) { - mkdir(dirname($target), 0777, true); - } - - return file_put_contents($target, $renderer->render($template, $parameters), $flag); - } -} diff --git a/src/Command/Develop/TranslationCleanupCommand.php b/src/Command/Develop/TranslationCleanupCommand.php deleted file mode 100644 index 938af4bf2..000000000 --- a/src/Command/Develop/TranslationCleanupCommand.php +++ /dev/null @@ -1,123 +0,0 @@ -consoleRoot = $consoleRoot; - $this->configurationManager = $configurationManager; - parent::__construct(); - } - - /** - * {@inheritdoc} - */ - - protected function configure() - { - $this - ->setName('translation:cleanup') - ->setDescription($this->trans('commands.translation.cleanup.description')) - ->addArgument( - 'language', - InputArgument::OPTIONAL, - $this->trans('commands.translation.cleanup.arguments.language'), - null - ); - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $language = $input->getArgument('language'); - - $languages = $this->configurationManager->getConfiguration()->get('application.languages'); - unset($languages['en']); - - if ($language && !isset($languages[$language])) { - $io->error( - sprintf( - $this->trans('commands.translation.cleanup.messages.invalid-language'), - $language - ) - ); - return 1; - } - - if ($language) { - $languages = [$language => $languages[$language]]; - } - - $this->cleanupTranslations($io, $language, $languages); - - $io->success( - $this->trans('commands.translation.cleanup.messages.success') - ); - } - - protected function cleanupTranslations($io, $language = null, $languages) - { - $finder = new Finder(); - - foreach ($languages as $langCode => $languageName) { - if (file_exists($this->consoleRoot . sprintf( DRUPAL_CONSOLE_LANGUAGE, $langCode ))) { - foreach ($finder->files()->name('*.yml')->in($this->consoleRoot . sprintf( DRUPAL_CONSOLE_LANGUAGE, $langCode )) as $file) { - $filename = $file->getBasename('.yml'); - if (!file_exists($this->consoleRoot . sprintf( DRUPAL_CONSOLE_LANGUAGE, 'en') . $filename . '.yml')) { - $io->info( - sprintf( - $this->trans('commands.translation.cleanup.messages.file-deleted'), - $filename, - $languageName - ) - ); - unlink($this->consoleRoot . sprintf( DRUPAL_CONSOLE_LANGUAGE, $langCode ). '/' . $filename . '.yml'); - } - } - } - } - } -} diff --git a/src/Command/Develop/TranslationPendingCommand.php b/src/Command/Develop/TranslationPendingCommand.php deleted file mode 100644 index 559c7f079..000000000 --- a/src/Command/Develop/TranslationPendingCommand.php +++ /dev/null @@ -1,238 +0,0 @@ -consoleRoot = $consoleRoot; - $this->configurationManager = $configurationManager; - $this->nestedArray = $nestedArray; - parent::__construct(); - } - - - /** - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('translation:pending') - ->setDescription($this->trans('commands.translation.pending.description')) - ->addArgument( - 'language', - InputArgument::REQUIRED, - $this->trans('commands.translation.pending.arguments.language'), - null - ) - ->addOption( - 'file', - '', - InputOption::VALUE_OPTIONAL, - $this->trans('commands.translation.pending.options.file'), - null - ); - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $language = $input->getArgument('language'); - $file = $input->getOption('file'); - - $languages = $this->configurationManager->getConfiguration()->get('application.languages'); - unset($languages['en']); - - if ($language && !isset($languages[$language])) { - $io->error( - sprintf( - $this->trans('commands.translation.pending.messages.invalid-language'), - $language - ) - ); - return 1; - } - - if ($language) { - $languages = [$language => $languages[$language]]; - } - - $pendingTranslations = $this->determinePendingTranslation($io, $language, $languages, $file); - - if ($file) { - $io->success( - sprintf( - $this->trans('commands.translation.pending.messages.success-language-file'), - $pendingTranslations, - $languages[$language], - $file - ) - ); - } else { - $io->success( - sprintf( - $this->trans('commands.translation.pending.messages.success-language'), - $pendingTranslations, - $languages[$language] - ) - ); - } - } - - protected function determinePendingTranslation($io, $language = null, $languages, $fileFilter) - { - $englishFilesFinder = new Finder(); - $yaml = new Parser(); - $statistics = []; - - $englishDirectory = $this->consoleRoot . - sprintf( - DRUPAL_CONSOLE_LANGUAGE, - 'en' - ); - - $englishFiles = $englishFilesFinder->files()->name('*.yml')->in($englishDirectory); - - $pendingTranslations = 0; - foreach ($englishFiles as $file) { - $resource = $englishDirectory . '/' . $file->getBasename(); - $filename = $file->getBasename('.yml'); - - if ($fileFilter && $fileFilter != $file->getBasename()) { - continue; - } - - try { - $englishFileParsed = $yaml->parse(file_get_contents($resource)); - } catch (ParseException $e) { - $io->error($filename . '.yml: ' . $e->getMessage()); - continue; - } - - foreach ($languages as $langCode => $languageName) { - $languageDir = $this->consoleRoot . - sprintf( - DRUPAL_CONSOLE_LANGUAGE, - $langCode - ); - if (isset($language) && $langCode != $language) { - continue; - } - - $resourceTranslated = $languageDir . '/' . $file->getBasename(); - if (!file_exists($resourceTranslated)) { - $io->info( - sprintf( - $this->trans('commands.translation.pending.messages.missing-file'), - $languageName, - $file->getBasename() - ) - ); - continue; - } - - try { - $resourceTranslatedParsed = $yaml->parse(file_get_contents($resourceTranslated)); - } catch (ParseException $e) { - $io->error($resourceTranslated . ':' . $e->getMessage()); - } - - $diffStatistics = ['total' => 0, 'equal' => 0, 'diff' => 0]; - $diff = $this->nestedArray->arrayDiff($englishFileParsed, $resourceTranslatedParsed, true, $diffStatistics); - - if (!empty($diff)) { - $diffFlatten = array(); - $keyFlatten = ''; - $this->nestedArray->yamlFlattenArray($diff, $diffFlatten, $keyFlatten); - - $tableHeader = [ - $this->trans('commands.yaml.diff.messages.key'), - $this->trans('commands.yaml.diff.messages.value'), - ]; - - $tableRows = []; - foreach ($diffFlatten as $yamlKey => $yamlValue) { - if ($this->isYamlKey($yamlValue)) { - unset($diffFlatten[$yamlKey]); - } else { - $tableRows[] = [ - $yamlKey, - $yamlValue - ]; - } - } - - if (count($diffFlatten)) { - $io->writeln( - sprintf( - $this->trans('commands.translation.pending.messages.pending-translations'), - $languageName, - $file->getBasename() - ) - ); - - $io->table($tableHeader, $tableRows, 'compact'); - $pendingTranslations+= count($diffFlatten); - } - } - } - } - - return $pendingTranslations; - } -} diff --git a/src/Command/Develop/TranslationStatsCommand.php b/src/Command/Develop/TranslationStatsCommand.php deleted file mode 100644 index b26ed6f4c..000000000 --- a/src/Command/Develop/TranslationStatsCommand.php +++ /dev/null @@ -1,249 +0,0 @@ -consoleRoot = $consoleRoot; - $this->configurationManager = $configurationManager; - $this->renderer = $renderer; - $this->nestedArray = $nestedArray; - parent::__construct(); - } - - /** - * {@inheritdoc} - */ - - protected function configure() - { - $this - ->setName('translation:stats') - ->setDescription($this->trans('commands.translation.stats.description')) - ->addArgument( - 'language', - InputArgument::OPTIONAL, - $this->trans('commands.translation.stats.arguments.language'), - null - ) - ->addOption( - 'format', - '', - InputOption::VALUE_OPTIONAL, - $this->trans('commands.translation.stats.options.format'), - 'table' - ); - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $language = $input->getArgument('language'); - $format = $input->getOption('format'); - - $languages = $this->configurationManager->getConfiguration()->get('application.languages'); - unset($languages['en']); - - if ($language && !isset($languages[$language])) { - $io->error( - sprintf( - $this->trans('commands.translation.stats.messages.invalid-language'), - $language - ) - ); - return 1; - } - - if ($language) { - $languages = [$language => $languages[$language]]; - } - - $stats = $this->calculateStats($io, $language, $languages); - - if ($format == 'table') { - $tableHeaders = [ - $this->trans('commands.translation.stats.messages.language'), - $this->trans('commands.translation.stats.messages.percentage'), - $this->trans('commands.translation.stats.messages.iso') - ]; - - $io->table($tableHeaders, $stats); - return 0; - } - - if ($format == 'markdown') { - $arguments['language'] = $this->trans('commands.translation.stats.messages.language'); - $arguments['percentage'] = $this->trans('commands.translation.stats.messages.percentage'); - - $arguments['languages'] = $stats; - - $io->writeln( - $this->renderFile( - 'core/translation/stats.md.twig', - null, - $arguments - ) - ); - } - } - - protected function calculateStats($io, $language = null, $languages) - { - $englishFilesFinder = new Finder(); - $yaml = new Parser(); - $statistics = []; - - $englishDirectory = $this->consoleRoot . - sprintf( - DRUPAL_CONSOLE_LANGUAGE, - 'en' - ); - - $englishFiles = $englishFilesFinder->files()->name('*.yml')->in($englishDirectory); - - foreach ($englishFiles as $file) { - $resource = $englishDirectory . '/' . $file->getBasename(); - $filename = $file->getBasename('.yml'); - - try { - $englishFileParsed = $yaml->parse(file_get_contents($resource)); - } catch (ParseException $e) { - $io->error($filename . '.yml: ' . $e->getMessage()); - continue; - } - - foreach ($languages as $langCode => $languageName) { - $languageDir = $this->consoleRoot . - sprintf( - DRUPAL_CONSOLE_LANGUAGE, - $langCode - ); - //don't show that language if that repo isn't present - if (!file_exists($languageDir)) { - continue; - } - if (isset($language) && $langCode != $language) { - continue; - } - if (!isset($statistics[$langCode])) { - $statistics[$langCode] = ['total' => 0, 'equal'=> 0 , 'diff' => 0]; - } - - $resourceTranslated = $languageDir . '/' . $file->getBasename(); - if (!file_exists($resourceTranslated)) { - $englishFileEntries = count($englishFileParsed, COUNT_RECURSIVE); - $statistics[$langCode]['total'] += $englishFileEntries; - $statistics[$langCode]['equal'] += $englishFileEntries; - continue; - } - - try { - $resourceTranslatedParsed = $yaml->parse(file_get_contents($resourceTranslated)); - } catch (ParseException $e) { - $io->error($resourceTranslated . ':' . $e->getMessage()); - } - - $diffStatistics = ['total' => 0, 'equal' => 0, 'diff' => 0]; - $diff = $this->nestedArray->arrayDiff($englishFileParsed, $resourceTranslatedParsed, true, $diffStatistics); - - $yamlKeys = 0; - if (!empty($diff)) { - $diffFlatten = array(); - $keyFlatten = ''; - $this->nestedArray->yamlFlattenArray($diff, $diffFlatten, $keyFlatten); - - // Determine how many yaml keys were returned as values - foreach ($diffFlatten as $yamlKey => $yamlValue) { - if ($this->isYamlKey($yamlValue)) { - $yamlKeys++; - } - } - } - - $statistics[$langCode]['total'] += $diffStatistics['total']; - $statistics[$langCode]['equal'] += ($diffStatistics['equal'] - $yamlKeys); - $statistics[$langCode]['diff'] += $diffStatistics['diff'] + $yamlKeys; - } - } - - $stats = []; - foreach ($statistics as $langCode => $statistic) { - $index = isset($languages[$langCode])? $languages[$langCode]: $langCode; - $stats[] = [ - 'name' => $index, - 'percentage' => round($statistic['diff']/$statistic['total']*100, 2), - 'iso' => $langCode - ]; - } - - usort( - $stats, function ($a, $b) { - return $a["percentage"] < $b["percentage"]; - - } - ); - - return $stats; - } -} diff --git a/src/Command/Develop/TranslationSyncCommand.php b/src/Command/Develop/TranslationSyncCommand.php deleted file mode 100644 index 1a87e6cdd..000000000 --- a/src/Command/Develop/TranslationSyncCommand.php +++ /dev/null @@ -1,205 +0,0 @@ -consoleRoot = $consoleRoot; - $this->configurationManager = $configurationManager; - parent::__construct(); - } - - /** - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('translation:sync') - ->setDescription($this->trans('commands.translation.sync.description')) - ->addArgument( - 'language', - InputArgument::OPTIONAL, - $this->trans('commands.translation.sync.arguments.language'), - null - ) - ->addOption( - 'file', - '', - InputOption::VALUE_OPTIONAL, - $this->trans('commands.translation.stats.options.file'), - null - ); - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $language = $input->getArgument('language'); - $file = $input->getOption('file'); - $languages = $this->configurationManager->getConfiguration()->get('application.languages'); - unset($languages['en']); - - if ($language && !isset($languages[$language])) { - $io->error( - sprintf( - $this->trans('commands.translation.stats.messages.invalid-language'), - $language - ) - ); - return 1; - } - - if ($language) { - $languages = [$language => $languages[$language]]; - } - - $this->syncTranslations($io, $language, $languages, $file); - - $io->success($this->trans('commands.translation.sync.messages.sync-finished')); - } - - protected function syncTranslations($io, $language = null, $languages, $file) - { - $englishFilesFinder = new Finder(); - $yaml = new Parser(); - $dumper = new Dumper(); - - $englishDirectory = $this->consoleRoot . - sprintf( - DRUPAL_CONSOLE_LANGUAGE, - 'en' - ); - - if ($file) { - $englishFiles = $englishFilesFinder->files()->name($file)->in($englishDirectory); - } else { - $englishFiles = $englishFilesFinder->files()->name('*.yml')->in($englishDirectory); - } - - foreach ($englishFiles as $file) { - $resource = $englishDirectory . '/' . $file->getBasename(); - $filename = $file->getBasename('.yml'); - - try { - $englishFile = file_get_contents($resource); - $englishFileParsed = $yaml->parse($englishFile); - } catch (ParseException $e) { - $io->error($filename . '.yml: ' . $e->getMessage()); - continue; - } - - foreach ($languages as $langCode => $languageName) { - $languageDir = $this->consoleRoot . - sprintf( - DRUPAL_CONSOLE_LANGUAGE, - $langCode - ); - if (isset($language) && $langCode != $language) { - continue; - } - if (!isset($statistics[$langCode])) { - $statistics[$langCode] = ['total' => 0, 'equal'=> 0 , 'diff' => 0]; - } - - $resourceTranslated = $languageDir . '/' . $file->getBasename(); - if (!file_exists($resourceTranslated)) { - file_put_contents($resourceTranslated, $englishFile); - $io->info( - sprintf( - $this->trans('commands.translation.sync.messages.created-file'), - $file->getBasename(), - $languageName - ) - ); - continue; - } - - try { - //print $resourceTranslated . "\n"; - $resourceTranslatedParsed = $yaml->parse(file_get_contents($resourceTranslated)); - } catch (ParseException $e) { - $io->error($resourceTranslated . ':' . $e->getMessage()); - continue; - } - - $resourceTranslatedParsed = array_replace_recursive($englishFileParsed, $resourceTranslatedParsed); - - try { - $resourceTranslatedParsedYaml = $dumper->dump($resourceTranslatedParsed, 10); - } catch (\Exception $e) { - $io->error( - sprintf( - $this->trans('commands.translation.sync.messages.error-generating'), - $resourceTranslated, - $languageName, - $e->getMessage() - ) - ); - - continue; - } - - try { - file_put_contents($resourceTranslated, $resourceTranslatedParsedYaml); - } catch (\Exception $e) { - $io->error( - sprintf( - '%s: %s', - $this->trans('commands.translation.sync.messages.error-writing'), - $resourceTranslated, - $languageName, - $e->getMessage() - ) - ); - - return 1; - } - } - } - } -} diff --git a/src/Command/Entity/DeleteCommand.php b/src/Command/Entity/DeleteCommand.php index 0bf875695..f9b1ecbb4 100644 --- a/src/Command/Entity/DeleteCommand.php +++ b/src/Command/Entity/DeleteCommand.php @@ -9,16 +9,13 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Entity\EntityTypeRepository; use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; class DeleteCommand extends Command { - use CommandTrait; - /** * @var EntityTypeRepository */ @@ -31,8 +28,9 @@ class DeleteCommand extends Command /** * DeleteCommand constructor. - * @param EntityTypeRepository $entityTypeRepository - * @param EntityTypeManagerInterface $entityTypeManager + * + * @param EntityTypeRepository $entityTypeRepository + * @param EntityTypeManagerInterface $entityTypeManager */ public function __construct( EntityTypeRepository $entityTypeRepository, @@ -59,7 +57,7 @@ protected function configure() 'entity-id', InputArgument::REQUIRED, $this->trans('commands.entity.delete.arguments.entity-id') - ); + )->setAliases(['ed']); } /** diff --git a/src/Command/EventDebugCommand.php b/src/Command/EventDebugCommand.php deleted file mode 100644 index 2b5edadc7..000000000 --- a/src/Command/EventDebugCommand.php +++ /dev/null @@ -1,106 +0,0 @@ -eventDispatcher = $eventDispatcher; - parent::__construct(); - } - - /** - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('event:debug') - ->setDescription($this->trans('commands.event.debug.description')) - ->addArgument( - 'event', - InputArgument::OPTIONAL, - $this->trans('commands.event.debug.arguments.event'), - null - ) - ->setHelp($this->trans('commands.event.debug.help')); - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $events = array_keys($this->eventDispatcher->getListeners()); - $event = $input->getArgument('event'); - - if ($event) { - if (!in_array($event, $events)) { - throw new \Exception( - sprintf( - $this->trans('commands.event.debug.messages.no-events'), - $event - ) - ); - } - - $dispatcher = $this->eventDispatcher->getListeners($event); - $listeners = []; - - foreach ($dispatcher as $key => $value) { - $reflection = new \ReflectionClass(get_class($value[0])); - $listeners[] = [$reflection->getName(), $value[1]]; - } - - $tableHeader = [ - $this->trans('commands.event.debug.messages.class'), - $this->trans('commands.event.debug.messages.method'), - - ]; - - $tableRows = []; - foreach ($listeners as $key => $element) { - $tableRows[] = [ - 'class' => $element['0'], - 'method' => $element['1'] - ]; - } - - $io->table($tableHeader, $tableRows); - - return 0; - } - - $io->table( - [$this->trans('commands.event.debug.messages.event')], - $events - ); - } -} diff --git a/src/Command/Features/ImportCommand.php b/src/Command/Features/ImportCommand.php new file mode 100644 index 000000000..01ef819a7 --- /dev/null +++ b/src/Command/Features/ImportCommand.php @@ -0,0 +1,85 @@ +setName('features:import') + ->setDescription($this->trans('commands.features.import.description')) + ->addOption( + 'bundle', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.features.import.options.bundle') + ) + ->addArgument( + 'packages', + InputArgument::IS_ARRAY, + $this->trans('commands.features.import.arguments.packages') + )->setAliases(['fei']); + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + $packages = $input->getArgument('packages'); + $bundle = $input->getOption('bundle'); + + if ($bundle) { + $packages = $this->getPackagesByBundle($bundle); + } + + $this->getAssigner($bundle); + $this->importFeature($io, $packages); + } + + /** + * {@inheritdoc} + */ + protected function interact(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + $packages = $input->getArgument('packages'); + $bundle = $input->getOption('bundle'); + + if (!$packages && !$bundle) { + // @see Drupal\Console\Command\Shared\FeatureTrait::packageQuestion + $bundle = $this->packageQuestion($io); + $input->setArgument('packages', $bundle); + } + } +} diff --git a/src/Command/Field/InfoCommand.php b/src/Command/Field/InfoCommand.php index 904769dda..6c57302b0 100644 --- a/src/Command/Field/InfoCommand.php +++ b/src/Command/Field/InfoCommand.php @@ -10,20 +10,17 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\field\FieldConfigInterface; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class InfoCommand. */ class InfoCommand extends Command { - use CommandTrait; - /** * @var EntityTypeManagerInterface */ @@ -36,6 +33,7 @@ class InfoCommand extends Command /** * InfoCommand constructor. + * * @param EntityTypeManagerInterface $entityTypeManager * @param EntityFieldManagerInterface $entityFieldManager */ @@ -74,7 +72,7 @@ public function configure() null, InputOption::VALUE_OPTIONAL, $this->trans('commands.field.info.options.bundle') - ); + )->setAliases(['fii']); } /** diff --git a/src/Command/Generate/AuthenticationProviderCommand.php b/src/Command/Generate/AuthenticationProviderCommand.php index 35ff09aad..3e608fd05 100644 --- a/src/Command/Generate/AuthenticationProviderCommand.php +++ b/src/Command/Generate/AuthenticationProviderCommand.php @@ -7,42 +7,57 @@ namespace Drupal\Console\Command\Generate; -use Drupal\Console\Command\Generate\Questions\AuthenticationProviderQuestions; -use Drupal\Console\Command\Generate\Questions\ConfirmGeneration; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Command\Shared\ServicesTrait; +use Drupal\Console\Command\Shared\ModuleTrait; +use Drupal\Console\Command\Shared\FormTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Generator\AuthenticationProviderGenerator; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Command\Shared\ConfirmationTrait; +use Drupal\Console\Core\Style\DrupalStyle; +use Drupal\Console\Core\Utils\StringConverter; +use Drupal\Console\Extension\Manager; class AuthenticationProviderCommand extends Command { - use CommandTrait; + use ServicesTrait; + use ModuleTrait; + use FormTrait; + use ConfirmationTrait; - /** @var AuthenticationProviderGenerator */ + /** + * @var Manager +*/ + protected $extensionManager; + + /** + * @var AuthenticationProviderGenerator +*/ protected $generator; - /** @var AuthenticationProviderQuestions */ - private $questions; + /** + * @var StringConverter + */ + protected $stringConverter; - /** @var ConfirmGeneration */ - private $confirmation; /** * AuthenticationProviderCommand constructor. + * + * @param Manager $extensionManager * @param AuthenticationProviderGenerator $generator - * @param AuthenticationProviderQuestions $questions - * @param ConfirmGeneration $confirmation + * @param StringConverter $stringConverter */ public function __construct( + Manager $extensionManager, AuthenticationProviderGenerator $generator, - AuthenticationProviderQuestions $questions, - ConfirmGeneration $confirmation + StringConverter $stringConverter ) { + $this->extensionManager = $extensionManager; $this->generator = $generator; - $this->questions = $questions; - $this->confirmation = $confirmation; + $this->stringConverter = $stringConverter; parent::__construct(); } @@ -52,19 +67,20 @@ protected function configure() ->setName('generate:authentication:provider') ->setDescription($this->trans('commands.generate.authentication.provider.description')) ->setHelp($this->trans('commands.generate.authentication.provider.help')) - ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) ->addOption( 'class', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.authentication.provider.options.class') ) ->addOption( 'provider-id', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.authentication.provider.options.provider-id') - ); + ) + ->setAliases(['gap']); } /** @@ -72,32 +88,69 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { - if (!$this->confirmation->confirm()) { - return; + $io = new DrupalStyle($input, $output); + + // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration + if (!$this->confirmGeneration($io)) { + return 1; } - $this->generator->generate( - $input->getOption('module'), - $input->getOption('class'), - $input->getOption('provider-id') - ); + $module = $input->getOption('module'); + $class = $input->getOption('class'); + $provider_id = $input->getOption('provider-id'); + + $this->generator->generate($module, $class, $provider_id); + + return 0; } protected function interact(InputInterface $input, OutputInterface $output) { - if (!($input->getOption('module'))) { - $input->setOption('module', $this->questions->askForModule()); + $io = new DrupalStyle($input, $output); + + $stringUtils = $this->stringConverter; + + // --module option + $module = $input->getOption('module'); + if (!$module) { + // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion + $module = $this->moduleQuestion($io); + $input->setOption('module', $module); } - if (!($input->getOption('class'))) { - $input->setOption('class', $this->questions->askForClass()); + // --class option + $class = $input->getOption('class'); + if (!$class) { + $class = $io->ask( + $this->trans( + 'commands.generate.authentication.provider.options.class' + ), + 'DefaultAuthenticationProvider', + function ($value) use ($stringUtils) { + if (!strlen(trim($value))) { + throw new \Exception('The Class name can not be empty'); + } + + return $stringUtils->humanToCamelCase($value); + } + ); + $input->setOption('class', $class); } + // --provider-id option + $provider_id = $input->getOption('provider-id'); + if (!$provider_id) { + $provider_id = $io->ask( + $this->trans('commands.generate.authentication.provider.options.provider-id'), + $stringUtils->camelCaseToUnderscore($class), + function ($value) use ($stringUtils) { + if (!strlen(trim($value))) { + throw new \Exception('The Class name can not be empty'); + } - if (!($input->getOption('provider-id'))) { - $input->setOption( - 'provider-id', - $this->questions->askForProviderId($input) + return $stringUtils->camelCaseToUnderscore($value); + } ); + $input->setOption('provider-id', $provider_id); } } } diff --git a/src/Command/Generate/BreakPointCommand.php b/src/Command/Generate/BreakPointCommand.php index 3720c0b4b..d4582c55f 100644 --- a/src/Command/Generate/BreakPointCommand.php +++ b/src/Command/Generate/BreakPointCommand.php @@ -10,15 +10,14 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Extension\ThemeHandler; use Drupal\Console\Command\Shared\ThemeRegionTrait; use Drupal\Console\Command\Shared\ThemeBreakpointTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Utils\Validator; -use Drupal\Console\Utils\StringConverter; +use Drupal\Console\Core\Utils\StringConverter; use Drupal\Console\Generator\BreakPointGenerator; /** @@ -26,7 +25,6 @@ */ class BreakPointCommand extends Command { - use CommandTrait; use ConfirmationTrait; use ThemeRegionTrait; use ThemeBreakpointTrait; @@ -52,7 +50,9 @@ class BreakPointCommand extends Command protected $themeHandler; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; /** @@ -62,8 +62,9 @@ class BreakPointCommand extends Command /** * BreakPointCommand constructor. + * * @param BreakPointGenerator $generator - * @param $appRoot + * @param $appRoot * @param ThemeHandler $themeHandler * @param Validator $validator * @param StringConverter $stringConverter @@ -74,7 +75,7 @@ public function __construct( ThemeHandler $themeHandler, Validator $validator, StringConverter $stringConverter - ) { + ) { $this->generator = $generator; $this->appRoot = $appRoot; $this->themeHandler = $themeHandler; @@ -94,16 +95,16 @@ protected function configure() ->setHelp($this->trans('commands.generate.breakpoint.help')) ->addOption( 'theme', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.breakpoint.options.theme') ) ->addOption( 'breakpoints', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.breakpoint.options.breakpoints') - ); + )->setAliases(['gb']); } /** @@ -115,7 +116,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $validators = $this->validator; @@ -129,6 +130,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $breakpoints, $machine_name ); + + return 0; } /** diff --git a/src/Command/Generate/CacheContextCommand.php b/src/Command/Generate/CacheContextCommand.php new file mode 100644 index 000000000..f9445c5e7 --- /dev/null +++ b/src/Command/Generate/CacheContextCommand.php @@ -0,0 +1,172 @@ +generator = $generator; + $this->chainQueue = $chainQueue; + $this->extensionManager = $extensionManager; + $this->stringConverter = $stringConverter; + parent::__construct(); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('generate:cache:context') + ->setDescription($this->trans('commands.generate.cache.context.description')) + ->setHelp($this->trans('commands.generate.cache.context.description')) + ->addOption( + 'module', + null, + InputOption::VALUE_REQUIRED, + $this->trans('commands.common.options.module')) + ->addOption( + 'cache-context', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.cache.context.questions.name') + ) + ->addOption( + 'class', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.cache.context.questions.class') + ) + ->addOption( + 'services', + null, + InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, + $this->trans('commands.common.options.services') + )->setAliases(['gcc']); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration + if (!$this->confirmGeneration($io)) { + return 1; + } + + $module = $input->getOption('module'); + $cache_context = $input->getOption('cache-context'); + $class = $input->getOption('class'); + $services = $input->getOption('services'); + + // @see Drupal\Console\Command\Shared\ServicesTrait::buildServices + $buildServices = $this->buildServices($services); + + $this->generator->generate($module, $cache_context, $class, $buildServices); + + $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']); + } + + /** + * {@inheritdoc} + */ + protected function interact(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + // --module option + $module = $input->getOption('module'); + if (!$module) { + // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion + $module = $this->moduleQuestion($io); + $input->setOption('module', $module); + } + + // --cache_context option + $cache_context = $input->getOption('cache-context'); + if (!$cache_context) { + $cache_context = $io->ask( + $this->trans('commands.generate.cache.context.questions.name'), + sprintf('%s', $module) + ); + $input->setOption('cache-context', $cache_context); + } + + // --class option + $class = $input->getOption('class'); + if (!$class) { + $class = $io->ask( + $this->trans('commands.generate.cache.context.questions.class'), + 'DefaultCacheContext' + ); + $input->setOption('class', $class); + } + + // --services option + $services = $input->getOption('services'); + if (!$services) { + // @see Drupal\Console\Command\Shared\ServicesTrait::servicesQuestion + $services = $this->servicesQuestion($io); + $input->setOption('services', $services); + } + } +} diff --git a/src/Command/Generate/CommandCommand.php b/src/Command/Generate/CommandCommand.php index 860bb7f90..e0e15b128 100644 --- a/src/Command/Generate/CommandCommand.php +++ b/src/Command/Generate/CommandCommand.php @@ -7,26 +7,28 @@ namespace Drupal\Console\Command\Generate; +use Drupal\Console\Command\Shared\ExtensionTrait; use Drupal\Console\Command\Shared\ServicesTrait; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\ContainerAwareCommandTrait; +use Drupal\Console\Core\Command\ContainerAwareCommand; use Drupal\Console\Command\Shared\ConfirmationTrait; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Generator\CommandGenerator; -use Drupal\Console\Utils\StringConverter; +use Drupal\Console\Core\Utils\StringConverter; use Drupal\Console\Extension\Manager; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Utils\Validator; +use Drupal\Console\Utils\Site; + +class CommandCommand extends ContainerAwareCommand -class CommandCommand extends Command { - use ContainerAwareCommandTrait; use ConfirmationTrait; use ServicesTrait; use ModuleTrait; + use ExtensionTrait; /** * @var CommandGenerator @@ -48,23 +50,32 @@ class CommandCommand extends Command */ protected $stringConverter; + /** + * @var Site + */ + protected $site; + /** * CommandCommand constructor. + * * @param CommandGenerator $generator * @param Manager $extensionManager * @param Validator $validator * @param StringConverter $stringConverter + * @param Site $site */ public function __construct( CommandGenerator $generator, Manager $extensionManager, Validator $validator, - StringConverter $stringConverter + StringConverter $stringConverter, + Site $site ) { $this->generator = $generator; $this->extensionManager = $extensionManager; $this->validator = $validator; $this->stringConverter = $stringConverter; + $this->site = $site; parent::__construct(); } @@ -78,36 +89,42 @@ protected function configure() ->setDescription($this->trans('commands.generate.command.description')) ->setHelp($this->trans('commands.generate.command.help')) ->addOption( - 'module', - '', + 'extension', + null, InputOption::VALUE_REQUIRED, - $this->trans('commands.common.options.module') + $this->trans('commands.common.options.extension') + ) + ->addOption( + 'extension-type', + null, + InputOption::VALUE_REQUIRED, + $this->trans('commands.common.options.extension-type') ) ->addOption( 'class', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.command.options.class') ) ->addOption( 'name', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.command.options.name') ) ->addOption( 'container-aware', - '', + null, InputOption::VALUE_NONE, $this->trans('commands.generate.command.options.container-aware') ) ->addOption( 'services', - '', + null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $this->trans('commands.common.options.services') ) - ; + ->setAliases(['gco']); } /** @@ -117,7 +134,8 @@ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); - $module = $input->getOption('module'); + $extension = $input->getOption('extension'); + $extensionType = $input->getOption('extension-type'); $class = $input->getOption('class'); $name = $input->getOption('name'); $containerAware = $input->getOption('container-aware'); @@ -126,19 +144,24 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io, $yes)) { - return; + return 1; } // @see use Drupal\Console\Command\Shared\ServicesTrait::buildServices $build_services = $this->buildServices($services); $this->generator->generate( - $module, + $extension, + $extensionType, $name, $class, $containerAware, $build_services ); + + $this->site->removeCachedServicesFile(); + + return 0; } /** @@ -148,24 +171,28 @@ protected function interact(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); - // --module option - $module = $input->getOption('module'); - if (!$module) { - $module = $this->moduleQuestion($io); - $input->setOption('module', $module); + $extension = $input->getOption('extension'); + if (!$extension) { + $extension = $this->extensionQuestion($io, true, true); + $input->setOption('extension', $extension->getName()); + $input->setOption('extension-type', $extension->getType()); + } + + $extensionType = $input->getOption('extension-type'); + if (!$extensionType) { + $extensionType = $this->extensionTypeQuestion($io); + $input->setOption('extension-type', $extensionType); } - // --name $name = $input->getOption('name'); if (!$name) { $name = $io->ask( $this->trans('commands.generate.command.questions.name'), - sprintf('%s:default', $module) + sprintf('%s:default', $extension->getName()) ); $input->setOption('name', $name); } - // --class option $class = $input->getOption('class'); if (!$class) { $class = $io->ask( @@ -178,7 +205,6 @@ function ($class) { $input->setOption('class', $class); } - // --container-aware option $containerAware = $input->getOption('container-aware'); if (!$containerAware) { $containerAware = $io->confirm( @@ -189,7 +215,6 @@ function ($class) { } if (!$containerAware) { - // --services option // @see use Drupal\Console\Command\Shared\ServicesTrait::servicesQuestion $services = $this->servicesQuestion($io); $input->setOption('services', $services); diff --git a/src/Command/Generate/ConfigFormBaseCommand.php b/src/Command/Generate/ConfigFormBaseCommand.php index d166897ed..736180c1c 100644 --- a/src/Command/Generate/ConfigFormBaseCommand.php +++ b/src/Command/Generate/ConfigFormBaseCommand.php @@ -8,18 +8,84 @@ namespace Drupal\Console\Command\Generate; use Drupal\Console\Generator\FormGenerator; -use Drupal\Console\Utils\StringConverter; +use Drupal\Console\Core\Utils\StringConverter; use Drupal\Console\Extension\Manager; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\ChainQueue; use Drupal\Core\Routing\RouteProviderInterface; use Drupal\Core\Render\ElementInfoManager; class ConfigFormBaseCommand extends FormCommand { + /** + * @var Manager + */ + protected $extensionManager; + + /** + * @var FormGenerator + */ + protected $generator; + + /** + * @var StringConverter + */ + protected $stringConverter; + + /** + * @var RouteProviderInterface + */ + protected $routeProvider; + + /** + * @var ElementInfoManager + */ + protected $elementInfoManager; + + /** + * @var string + */ + protected $appRoot; + + /** + * @var ChainQueue + */ + protected $chainQueue; + + /** + * ConfigFormBaseCommand constructor. + * + * @param Manager $extensionManager + * @param FormGenerator $generator + * @param StringConverter $stringConverter + * @param RouteProviderInterface $routeProvider + * @param ElementInfoManager $elementInfoManager + * @param $appRoot + * @param ChainQueue $chainQueue + */ + public function __construct( + Manager $extensionManager, + FormGenerator $generator, + StringConverter $stringConverter, + RouteProviderInterface $routeProvider, + ElementInfoManager $elementInfoManager, + $appRoot, + ChainQueue $chainQueue + ) { + $this->extensionManager = $extensionManager; + $this->generator = $generator; + $this->stringConverter = $stringConverter; + $this->routeProvider = $routeProvider; + $this->elementInfoManager = $elementInfoManager; + $this->appRoot = $appRoot; + $this->chainQueue = $chainQueue; + parent::__construct($extensionManager, $generator, $chainQueue, $stringConverter, $elementInfoManager, $routeProvider); + } + protected function configure() { $this->setFormType('ConfigFormBase'); $this->setCommandName('generate:form:config'); + $this->setAliases(['gfc']); parent::configure(); } } diff --git a/src/Command/Generate/ControllerCommand.php b/src/Command/Generate/ControllerCommand.php index b3d4aafb2..730fd5ee6 100644 --- a/src/Command/Generate/ControllerCommand.php +++ b/src/Command/Generate/ControllerCommand.php @@ -7,7 +7,6 @@ namespace Drupal\Console\Command\Generate; -use Drupal\Console\Command\Shared\InputTrait; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -15,27 +14,30 @@ use Drupal\Console\Command\Shared\ConfirmationTrait; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Generator\ControllerGenerator; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; -use Drupal\Console\Utils\StringConverter; +use Drupal\Console\Core\Command\ContainerAwareCommand; +use Drupal\Core\Routing\RouteProviderInterface; +use Drupal\Console\Core\Style\DrupalStyle; +use Drupal\Console\Core\Utils\StringConverter; +use Drupal\Console\Core\Utils\ChainQueue; +use Drupal\Console\Core\Command\Shared\InputTrait; use Drupal\Console\Extension\Manager; -use Drupal\Console\Command\Shared\ContainerAwareCommandTrait; use Drupal\Console\Utils\Validator; -use Drupal\Core\Routing\RouteProviderInterface; -use Drupal\Console\Utils\ChainQueue; -class ControllerCommand extends Command +class ControllerCommand extends ContainerAwareCommand { use ModuleTrait; use ServicesTrait; use ConfirmationTrait; use InputTrait; - use ContainerAwareCommandTrait; - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; - /** @var ControllerGenerator */ + /** + * @var ControllerGenerator + */ protected $generator; /** @@ -43,10 +45,14 @@ class ControllerCommand extends Command */ protected $stringConverter; - /** @var Validator */ + /** + * @var Validator + */ protected $validator; - /** @var RouteProviderInterface */ + /** + * @var RouteProviderInterface + */ protected $routeProvider; /** @@ -56,6 +62,7 @@ class ControllerCommand extends Command /** * ControllerCommand constructor. + * * @param Manager $extensionManager * @param ControllerGenerator $generator * @param StringConverter $stringConverter @@ -88,34 +95,35 @@ protected function configure() ->setHelp($this->trans('commands.generate.controller.help')) ->addOption( 'module', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module') ) ->addOption( 'class', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.controller.options.class') ) ->addOption( 'routes', - '', + null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $this->trans('commands.generate.controller.options.routes') ) ->addOption( 'services', - '', + null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $this->trans('commands.common.options.services') ) ->addOption( 'test', - '', + null, InputOption::VALUE_NONE, $this->trans('commands.generate.controller.options.test') - ); + ) + ->setAliases(['gcon']); } /** @@ -128,10 +136,9 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io, $yes)) { - return; + return 1; } - $learning = $input->hasOption('learning')?$input->getOption('learning'):false; $module = $input->getOption('module'); $class = $input->getOption('class'); $routes = $input->getOption('routes'); @@ -155,6 +162,8 @@ protected function execute(InputInterface $input, OutputInterface $output) // Run cache rebuild to see changes in Web UI $this->chainQueue->addCommand('router:rebuild', []); + + return 0; } /** @@ -243,7 +252,10 @@ function ($method) use ($routes) { $path = $io->ask( $this->trans('commands.generate.controller.questions.path'), - sprintf('/%s/hello/{name}', $module), + sprintf( + '/%s/'.($method!='hello'?$method:'hello/{name}'), + $module + ), function ($path) use ($routes) { if (count($this->routeProvider->getRoutesByPattern($path)) > 0 || in_array($path, array_column($routes, 'path')) diff --git a/src/Command/Generate/EntityBundleCommand.php b/src/Command/Generate/EntityBundleCommand.php index bd766d28b..544f9441b 100644 --- a/src/Command/Generate/EntityBundleCommand.php +++ b/src/Command/Generate/EntityBundleCommand.php @@ -7,41 +7,42 @@ namespace Drupal\Console\Command\Generate; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Drupal\Console\Command\Shared\ConfirmationTrait; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\ServicesTrait; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Generator\ContentTypeGenerator; use Drupal\Console\Generator\EntityBundleGenerator; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; use Drupal\Console\Utils\Validator; class EntityBundleCommand extends Command { - use CommandTrait; use ModuleTrait; use ServicesTrait; use ConfirmationTrait; - /** * @var Validator */ protected $validator; - /** @var EntityBundleGenerator */ + /** + * @var EntityBundleGenerator +*/ protected $generator; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** * EntityBundleCommand constructor. + * * @param Validator $validator * @param EntityBundleGenerator $generator * @param Manager $extensionManager @@ -64,19 +65,20 @@ protected function configure() ->setName('generate:entity:bundle') ->setDescription($this->trans('commands.generate.entity.bundle.description')) ->setHelp($this->trans('commands.generate.entity.bundle.help')) - ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) ->addOption( 'bundle-name', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.entity.bundle.options.bundle-name') ) ->addOption( 'bundle-title', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.entity.bundle.options.bundle-title') - ); + ) + ->setAliases(['geb']); } /** @@ -88,18 +90,19 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $module = $input->getOption('module'); $bundleName = $input->getOption('bundle-name'); $bundleTitle = $input->getOption('bundle-title'); + $generator = $this->generator; //TODO: - //$generator->setLearning($learning); - //$learning = $input->hasOption('learning')?$input->getOption('learning'):false; + // $generator->setLearning($learning); + $generator->generate($module, $bundleName, $bundleTitle); - $this->generator->generate($module, $bundleName, $bundleTitle); + return 0; } /** diff --git a/src/Command/Generate/EntityCommand.php b/src/Command/Generate/EntityCommand.php index fe214a543..265872f00 100644 --- a/src/Command/Generate/EntityCommand.php +++ b/src/Command/Generate/EntityCommand.php @@ -10,14 +10,12 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Command\Shared\ModuleTrait; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; abstract class EntityCommand extends Command { - use CommandTrait; use ModuleTrait; private $entityType; private $commandName; diff --git a/src/Command/Generate/EntityConfigCommand.php b/src/Command/Generate/EntityConfigCommand.php index 7c4450b63..c6a2b2eed 100644 --- a/src/Command/Generate/EntityConfigCommand.php +++ b/src/Command/Generate/EntityConfigCommand.php @@ -13,17 +13,17 @@ use Drupal\Console\Generator\EntityConfigGenerator; use Drupal\Console\Extension\Manager; use Drupal\Console\Utils\Validator; -use Drupal\Console\Utils\StringConverter; +use Drupal\Console\Core\Utils\StringConverter; class EntityConfigCommand extends EntityCommand { /** - * @var Manager + * @var Manager */ protected $extensionManager; /** - * @var EntityConfigGenerator + * @var EntityConfigGenerator */ protected $generator; @@ -39,6 +39,7 @@ class EntityConfigCommand extends EntityCommand /** * EntityConfigCommand constructor. + * * @param Manager $extensionManager * @param EntityConfigGenerator $generator * @param Validator $validator @@ -69,7 +70,8 @@ protected function configure() null, InputOption::VALUE_NONE, $this->trans('commands.generate.entity.config.options.bundle-of') - ); + ) + ->setAliases(['gec']); } /** diff --git a/src/Command/Generate/EntityContentCommand.php b/src/Command/Generate/EntityContentCommand.php index 89ef1d956..9b5e65b79 100644 --- a/src/Command/Generate/EntityContentCommand.php +++ b/src/Command/Generate/EntityContentCommand.php @@ -12,10 +12,10 @@ use Symfony\Component\Console\Output\OutputInterface; use Drupal\Console\Generator\EntityContentGenerator; use Drupal\Console\Extension\Manager; -use Drupal\Console\Utils\StringConverter; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\StringConverter; +use Drupal\Console\Core\Utils\ChainQueue; use Drupal\Console\Utils\Validator; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; class EntityContentCommand extends EntityCommand { @@ -46,6 +46,7 @@ class EntityContentCommand extends EntityCommand /** * EntityContentCommand constructor. + * * @param ChainQueue $chainQueue * @param EntityContentGenerator $generator * @param StringConverter $stringConverter @@ -96,7 +97,8 @@ protected function configure() null, InputOption::VALUE_NONE, $this->trans('commands.generate.entity.content.options.revisionable') - ); + ) + ->setAliases(['geco']); } /** diff --git a/src/Command/Generate/EventSubscriberCommand.php b/src/Command/Generate/EventSubscriberCommand.php index 8ea3733f2..70d34617e 100644 --- a/src/Command/Generate/EventSubscriberCommand.php +++ b/src/Command/Generate/EventSubscriberCommand.php @@ -15,21 +15,19 @@ use Drupal\Console\Generator\EventSubscriberGenerator; use Drupal\Console\Command\Shared\ConfirmationTrait; use Drupal\Console\Command\Shared\EventsTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; -use Drupal\Console\Command\Shared\ContainerAwareCommandTrait; -use Drupal\Console\Utils\StringConverter; +use Drupal\Console\Core\Command\ContainerAwareCommand; +use Drupal\Console\Core\Style\DrupalStyle; +use Drupal\Console\Core\Utils\StringConverter; use Drupal\Console\Extension\Manager; use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\ChainQueue; -class EventSubscriberCommand extends Command +class EventSubscriberCommand extends ContainerAwareCommand { use EventsTrait; use ServicesTrait; use ModuleTrait; use ConfirmationTrait; - use ContainerAwareCommandTrait; /** * @var Manager @@ -58,6 +56,7 @@ class EventSubscriberCommand extends Command /** * EventSubscriberCommand constructor. + * * @param Manager $extensionManager * @param EventSubscriberGenerator $generator * @param StringConverter $stringConverter @@ -93,7 +92,7 @@ protected function configure() 'name', null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.generate.service.options.name') + $this->trans('commands.generate.service.options.service-name') ) ->addOption( 'class', @@ -112,7 +111,8 @@ protected function configure() null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $this->trans('commands.common.options.services') - ); + ) + ->setAliases(['ges']); } /** @@ -124,7 +124,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $module = $input->getOption('module'); diff --git a/src/Command/Generate/FormAlterCommand.php b/src/Command/Generate/FormAlterCommand.php index 9699e2108..e614a139c 100644 --- a/src/Command/Generate/FormAlterCommand.php +++ b/src/Command/Generate/FormAlterCommand.php @@ -16,16 +16,15 @@ use Drupal\Console\Command\Shared\MenuTrait; use Drupal\Console\Command\Shared\FormTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Utils\StringConverter; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; +use Drupal\Console\Core\Utils\StringConverter; use Drupal\Console\Extension\Manager; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Render\ElementInfoManager; use Drupal\Console\Utils\Validator; use Drupal\Core\Routing\RouteProviderInterface; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\ChainQueue; use Drupal\webprofiler\Profiler\Profiler; class FormAlterCommand extends Command @@ -35,12 +34,15 @@ class FormAlterCommand extends Command use FormTrait; use MenuTrait; use ConfirmationTrait; - use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var FormAlterGenerator */ + /** + * @var FormAlterGenerator +*/ protected $generator; /** @@ -58,10 +60,14 @@ class FormAlterCommand extends Command */ protected $elementInfoManager; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; - /** @var RouteProviderInterface */ + /** + * @var RouteProviderInterface +*/ protected $routeProvider; /** @@ -82,13 +88,14 @@ class FormAlterCommand extends Command /** * FormAlterCommand constructor. + * * @param Manager $extensionManager * @param FormAlterGenerator $generator * @param StringConverter $stringConverter * @param ModuleHandlerInterface $moduleHandler * @param ElementInfoManager $elementInfoManager * @param Profiler $profiler - * @param $appRoot + * @param $appRoot * @param ChainQueue $chainQueue */ public function __construct( @@ -129,22 +136,23 @@ protected function configure() ->setHelp($this->trans('commands.generate.form.alter.help')) ->addOption( 'module', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module') ) ->addOption( 'form-id', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.form.alter.options.form-id') ) ->addOption( 'inputs', - '', + null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $this->trans('commands.common.options.inputs') - ); + ) + ->setAliases(['gfa']); } /** @@ -156,7 +164,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $module = $input->getOption('module'); @@ -184,6 +192,8 @@ protected function execute(InputInterface $input, OutputInterface $output) ->generate($module, $formId, $inputs, $this->metadata); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']); + + return 0; } protected function interact(InputInterface $input, OutputInterface $output) @@ -248,7 +258,7 @@ protected function interact(InputInterface $input, OutputInterface $output) true ); - $this->metadata['unset'] = array_filter(array_map('trim', $formItemsToHide)); + $this->metadata['unset'] = array_filter(array_map('trim', $formItemsToHide)); } $input->setOption('form-id', $formId); @@ -295,7 +305,7 @@ protected function createGenerator() public function getWebprofilerForms() { $tokens = $this->profiler->find(null, null, 1000, null, '', ''); - $forms = array(); + $forms = []; foreach ($tokens as $token) { $token = [$token['token']]; $profile = $this->profiler->loadProfile($token); @@ -309,5 +319,4 @@ public function getWebprofilerForms() } return $forms; } - } diff --git a/src/Command/Generate/FormCommand.php b/src/Command/Generate/FormCommand.php index ae570471b..7ddc23dd2 100644 --- a/src/Command/Generate/FormCommand.php +++ b/src/Command/Generate/FormCommand.php @@ -14,19 +14,17 @@ use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\MenuTrait; use Drupal\Console\Command\Shared\FormTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; -use Drupal\Console\Command\Shared\ContainerAwareCommandTrait; +use Drupal\Console\Core\Command\ContainerAwareCommand; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Generator\FormGenerator; use Drupal\Console\Extension\Manager; -use Drupal\Console\Utils\ChainQueue; -use Drupal\Console\Utils\StringConverter; +use Drupal\Console\Core\Utils\ChainQueue; +use Drupal\Console\Core\Utils\StringConverter; use Drupal\Core\Render\ElementInfoManager; use Drupal\Core\Routing\RouteProviderInterface; -abstract class FormCommand extends Command +abstract class FormCommand extends ContainerAwareCommand { - use ContainerAwareCommandTrait; use ModuleTrait; use ServicesTrait; use FormTrait; @@ -35,13 +33,19 @@ abstract class FormCommand extends Command private $formType; private $commandName; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var FormGenerator */ + /** + * @var FormGenerator +*/ protected $generator; - /** @var ChainQueue */ + /** + * @var ChainQueue +*/ protected $chainQueue; /** @@ -62,6 +66,7 @@ abstract class FormCommand extends Command /** * FormCommand constructor. + * * @param Manager $extensionManager * @param FormGenerator $generator * @param ChainQueue $chainQueue @@ -115,64 +120,70 @@ protected function configure() ) ->addOption( 'module', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module') ) ->addOption( 'class', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.form.options.class') ) ->addOption( 'form-id', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.form.options.form-id') ) ->addOption( 'services', - '', + null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $this->trans('commands.common.options.services') ) + ->addOption( + 'config-file', + null, + InputOption::VALUE_NONE, + $this->trans('commands.generate.form.options.config-file') + ) ->addOption( 'inputs', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.common.options.inputs') ) ->addOption( 'path', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.form.options.path') ) ->addOption( - 'menu_link_gen', - '', + 'menu-link-gen', + null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.generate.form.options.menu_link_gen') + $this->trans('commands.generate.form.options.menu-link-gen') ) ->addOption( - 'menu_link_title', - '', + 'menu-link-title', + null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.generate.form.options.menu_link_title') + $this->trans('commands.generate.form.options.menu-link-title') ) ->addOption( - 'menu_parent', - '', + 'menu-parent', + null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.generate.form.options.menu_parent') + $this->trans('commands.generate.form.options.menu-parent') ) ->addOption( - 'menu_link_desc', - '', + 'menu-link-desc', + null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.generate.form.options.menu_link_desc') - ); + $this->trans('commands.generate.form.options.menu-link-desc') + )->setAliases(['gf']); } /** @@ -183,13 +194,14 @@ protected function execute(InputInterface $input, OutputInterface $output) $module = $input->getOption('module'); $services = $input->getOption('services'); $path = $input->getOption('path'); + $config_file = $input->getOption('config-file'); $class_name = $input->getOption('class'); $form_id = $input->getOption('form-id'); $form_type = $this->formType; - $menu_link_gen = $input->getOption('menu_link_gen'); - $menu_parent = $input->getOption('menu_parent'); - $menu_link_title = $input->getOption('menu_link_title'); - $menu_link_desc = $input->getOption('menu_link_desc'); + $menu_link_gen = $input->getOption('menu-link-gen'); + $menu_parent = $input->getOption('menu-parent'); + $menu_link_title = $input->getOption('menu-link-title'); + $menu_link_desc = $input->getOption('menu-link-desc'); // if exist form generate config file $inputs = $input->getOption('inputs'); @@ -197,7 +209,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this ->generator - ->generate($module, $class_name, $form_id, $form_type, $build_services, $inputs, $path, $menu_link_gen, $menu_link_title, $menu_parent, $menu_link_desc); + ->generate($module, $class_name, $form_id, $form_type, $build_services, $config_file, $inputs, $path, $menu_link_gen, $menu_link_title, $menu_parent, $menu_link_desc); $this->chainQueue->addCommand('router:rebuild', []); } @@ -241,6 +253,17 @@ protected function interact(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ServicesTrait::servicesQuestion $services = $this->servicesQuestion($io); $input->setOption('services', $services); + + // --config_file option + $config_file = $input->getOption('config-file'); + + if (!$config_file) { + $config_file = $io->confirm( + $this->trans('commands.generate.form.questions.config-file'), + true + ); + $input->setOption('config-file', $config_file); + } // --inputs option $inputs = $input->getOption('inputs'); @@ -290,15 +313,15 @@ function ($path) { // --link option for links.menu if ($this->formType == 'ConfigFormBase') { $menu_options = $this->menuQuestion($io, $className); - $menu_link_gen = $input->getOption('menu_link_gen'); - $menu_link_title = $input->getOption('menu_link_title'); - $menu_parent = $input->getOption('menu_parent'); - $menu_link_desc = $input->getOption('menu_link_desc'); + $menu_link_gen = $input->getOption('menu-link-gen'); + $menu_link_title = $input->getOption('menu-link-title'); + $menu_parent = $input->getOption('menu-parent'); + $menu_link_desc = $input->getOption('menu-link-desc'); if (!$menu_link_gen || !$menu_link_title || !$menu_parent || !$menu_link_desc) { - $input->setOption('menu_link_gen', $menu_options['menu_link_gen']); - $input->setOption('menu_link_title', $menu_options['menu_link_title']); - $input->setOption('menu_parent', $menu_options['menu_parent']); - $input->setOption('menu_link_desc', $menu_options['menu_link_desc']); + $input->setOption('menu-link-gen', $menu_options['menu_link_gen']); + $input->setOption('menu-link-title', $menu_options['menu_link_title']); + $input->setOption('menu-parent', $menu_options['menu_parent']); + $input->setOption('menu-link-desc', $menu_options['menu_link_desc']); } } } diff --git a/src/Command/Generate/HelpCommand.php b/src/Command/Generate/HelpCommand.php index ad3616164..8618ed620 100644 --- a/src/Command/Generate/HelpCommand.php +++ b/src/Command/Generate/HelpCommand.php @@ -10,24 +10,23 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Generator\HelpGenerator; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Drupal\Console\Command\Shared\CommandTrait; use Drupal\Console\Extension\Manager; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Utils\Site; -use Drupal\Console\Utils\ChainQueue; - +use Drupal\Console\Core\Utils\ChainQueue; class HelpCommand extends Command { - use CommandTrait; use ModuleTrait; use ConfirmationTrait; - /** @var HelpGenerator */ + /** + * @var HelpGenerator +*/ protected $generator; /** @@ -35,7 +34,9 @@ class HelpCommand extends Command */ protected $site; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** @@ -46,6 +47,7 @@ class HelpCommand extends Command /** * HelpCommand constructor. + * * @param HelpGenerator $generator * @param Site $site * @param Manager $extensionManager @@ -72,16 +74,16 @@ protected function configure() ->setHelp($this->trans('commands.generate.help.help')) ->addOption( 'module', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module') ) ->addOption( 'description', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.module.options.description') - ); + )->setAliases(['gh']); } /** @@ -93,7 +95,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $module = $input->getOption('module'); @@ -114,6 +116,8 @@ protected function execute(InputInterface $input, OutputInterface $output) ->generate($module, $description); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']); + + return 0; } protected function interact(InputInterface $input, OutputInterface $output) @@ -134,7 +138,7 @@ protected function interact(InputInterface $input, OutputInterface $output) if (!$description) { $description = $io->ask( $this->trans('commands.generate.module.questions.description'), - 'My Awesome Module' + $this->trans('commands.generate.module.suggestions.my-awesome-module') ); } $input->setOption('description', $description); diff --git a/src/Command/Generate/ModuleCommand.php b/src/Command/Generate/ModuleCommand.php index 584d88320..2956270f8 100644 --- a/src/Command/Generate/ModuleCommand.php +++ b/src/Command/Generate/ModuleCommand.php @@ -13,25 +13,24 @@ use Symfony\Component\Console\Output\OutputInterface; use Drupal\Console\Generator\ModuleGenerator; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Utils\Validator; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Utils\StringConverter; +use Drupal\Console\Core\Utils\StringConverter; use Drupal\Console\Utils\DrupalApi; -use GuzzleHttp\Client; -use Drupal\Console\Utils\Site; -use GuzzleHttp\Exception\ClientException; class ModuleCommand extends Command { use ConfirmationTrait; - use CommandTrait; - /** @var ModuleGenerator */ + /** + * @var ModuleGenerator + */ protected $generator; - /** @var Validator */ + /** + * @var Validator + */ protected $validator; /** @@ -50,25 +49,20 @@ class ModuleCommand extends Command protected $drupalApi; /** - * @var Client - */ - protected $httpClient; - - /** - * @var Site + * @var string */ - protected $site; + protected $twigtemplate; /** * ModuleCommand constructor. + * * @param ModuleGenerator $generator * @param Validator $validator - * @param $appRoot + * @param $appRoot * @param StringConverter $stringConverter * @param DrupalApi $drupalApi - * @param Client $httpClient - * @param Site $site + * @param $twigtemplate */ public function __construct( ModuleGenerator $generator, @@ -76,16 +70,14 @@ public function __construct( $appRoot, StringConverter $stringConverter, DrupalApi $drupalApi, - Client $httpClient, - Site $site + $twigtemplate = null ) { $this->generator = $generator; $this->validator = $validator; $this->appRoot = $appRoot; $this->stringConverter = $stringConverter; $this->drupalApi = $drupalApi; - $this->httpClient = $httpClient; - $this->site = $site; + $this->twigtemplate = $twigtemplate; parent::__construct(); } @@ -100,70 +92,78 @@ protected function configure() ->setHelp($this->trans('commands.generate.module.help')) ->addOption( 'module', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.module.options.module') ) ->addOption( 'machine-name', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.module.options.machine-name') ) ->addOption( 'module-path', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.module.options.module-path') ) ->addOption( 'description', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.module.options.description') ) ->addOption( 'core', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.module.options.core') ) ->addOption( 'package', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.module.options.package') ) ->addOption( 'module-file', - '', + null, InputOption::VALUE_NONE, $this->trans('commands.generate.module.options.module-file') ) ->addOption( 'features-bundle', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.module.options.features-bundle') ) ->addOption( 'composer', - '', + null, InputOption::VALUE_NONE, $this->trans('commands.generate.module.options.composer') ) ->addOption( 'dependencies', - '', + null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.generate.module.options.dependencies') + $this->trans('commands.generate.module.options.dependencies'), + '' ) ->addOption( - 'test', - '', - InputOption::VALUE_OPTIONAL, - $this->trans('commands.generate.module.options.test') - ); + 'test', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.module.options.test') + ) + ->addOption( + 'twigtemplate', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.module.options.twigtemplate') + ) + ->setAliases(['gm']); } /** @@ -176,7 +176,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io, $yes)) { - return; + return 1; } $module = $this->validator->validateModuleName($input->getOption('module')); @@ -191,23 +191,13 @@ protected function execute(InputInterface $input, OutputInterface $output) $moduleFile = $input->getOption('module-file'); $featuresBundle = $input->getOption('features-bundle'); $composer = $input->getOption('composer'); + $dependencies = $this->validator->validateExtensions( + $input->getOption('dependencies'), + 'module', + $io + ); $test = $input->getOption('test'); - - // Modules Dependencies, re-factor and share with other commands - $dependencies = $this->validator->validateModuleDependencies($input->getOption('dependencies')); - // Check if all module dependencies are available - if ($dependencies) { - $checked_dependencies = $this->checkDependencies($dependencies['success'], $io); - if (!empty($checked_dependencies['no_modules'])) { - $io->warning( - sprintf( - $this->trans('commands.generate.module.warnings.module-unavailable'), - implode(', ', $checked_dependencies['no_modules']) - ) - ); - } - $dependencies = $dependencies['success']; - } + $twigTemplate = $input->getOption('twigtemplate'); $this->generator->generate( $module, @@ -220,49 +210,11 @@ protected function execute(InputInterface $input, OutputInterface $output) $featuresBundle, $composer, $dependencies, - $test + $test, + $twigTemplate ); - } - - /** - * @param array $dependencies - * @return array - */ - private function checkDependencies(array $dependencies, DrupalStyle $io) - { - $this->site->loadLegacyFile('/core/modules/system/system.module'); - $localModules = array(); - $modules = system_rebuild_module_data(); - foreach ($modules as $module_id => $module) { - array_push($localModules, basename($module->subpath)); - } - - $checkDependencies = [ - 'local_modules' => [], - 'drupal_modules' => [], - 'no_modules' => [], - ]; - - foreach ($dependencies as $module) { - if (in_array($module, $localModules)) { - $checkDependencies['local_modules'][] = $module; - } else { - try { - $response = $this->httpClient->head('https://www.drupal.org/project/' . $module); - $header_link = explode(';', $response->getHeader('link')); - if (empty($header_link[0])) { - $checkDependencies['no_modules'][] = $module; - } else { - $checkDependencies['drupal_modules'][] = $module; - } - } catch (ClientException $e) { - $checkDependencies['no_modules'][] = $module; - } - } - } - - return $checkDependencies; + return 0; } /** @@ -282,7 +234,7 @@ protected function interact(InputInterface $input, OutputInterface $output) } catch (\Exception $error) { $io->error($error->getMessage()); - return; + return 1; } if (!$module) { @@ -298,7 +250,7 @@ function ($module) use ($validator) { try { $machineName = $input->getOption('machine-name') ? - $this->validate->validateModule( + $this->validator->validateModuleName( $input->getOption('machine-name') ) : null; } catch (\Exception $error) { @@ -344,7 +296,7 @@ function ($modulePath) use ($drupalRoot, $machineName) { if (!$description) { $description = $io->ask( $this->trans('commands.generate.module.questions.description'), - 'My Awesome Module' + $this->trans('commands.generate.module.suggestions.my-awesome-module') ); } $input->setOption('description', $description); @@ -434,6 +386,15 @@ function ($core) { ); $input->setOption('test', $test); } + + $twigtemplate = $input->getOption('twigtemplate'); + if (!$twigtemplate) { + $twigtemplate = $io->confirm( + $this->trans('commands.generate.module.questions.twigtemplate'), + true + ); + $input->setOption('twigtemplate', $twigtemplate); + } } /** diff --git a/src/Command/Generate/ModuleFileCommand.php b/src/Command/Generate/ModuleFileCommand.php index dc089a8f2..e4d3ed480 100644 --- a/src/Command/Generate/ModuleFileCommand.php +++ b/src/Command/Generate/ModuleFileCommand.php @@ -10,34 +10,37 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Generator\ModuleFileGenerator; use Drupal\Console\Command\Shared\ConfirmationTrait; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Extension\Manager; -use Drupal\Console\Style\DrupalStyle; - +use Drupal\Console\Core\Style\DrupalStyle; /** * Class ModuleFileCommand + * * @package Drupal\Console\Command\Generate */ class ModuleFileCommand extends Command { - use CommandTrait; use ConfirmationTrait; use ModuleTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var ModuleFileGenerator */ + /** + * @var ModuleFileGenerator +*/ protected $generator; /** * ModuleFileCommand constructor. + * * @param Manager $extensionManager * @param ModuleFileGenerator $generator */ @@ -59,7 +62,12 @@ protected function configure() ->setName('generate:module:file') ->setDescription($this->trans('commands.generate.module.file.description')) ->setHelp($this->trans('commands.generate.module.file.help')) - ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')); + ->addOption( + 'module', + null, + InputOption::VALUE_REQUIRED, + $this->trans('commands.common.options.module') + )->setAliases(['gmf']); } /** @@ -71,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io, $yes)) { - return; + return 1; } $machine_name = $input->getOption('module'); diff --git a/src/Command/Generate/PermissionCommand.php b/src/Command/Generate/PermissionCommand.php index 2a7b045cc..064473770 100644 --- a/src/Command/Generate/PermissionCommand.php +++ b/src/Command/Generate/PermissionCommand.php @@ -10,24 +10,24 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\PermissionTrait; use Drupal\Console\Generator\PermissionGenerator; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; -use Drupal\Console\Utils\StringConverter; +use Drupal\Console\Core\Utils\StringConverter; class PermissionCommand extends Command { - use CommandTrait; use ModuleTrait; use PermissionTrait; use ConfirmationTrait; - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** @@ -35,17 +35,25 @@ class PermissionCommand extends Command */ protected $stringConverter; + /** + * @var PermissionGenerator; + */ + protected $generator; + /** * PermissionCommand constructor. + * * @param Manager $extensionManager * @param StringConverter $stringConverter */ public function __construct( Manager $extensionManager, - StringConverter $stringConverter + StringConverter $stringConverter, + PermissionGenerator $permissionGenerator ) { $this->extensionManager = $extensionManager; $this->stringConverter = $stringConverter; + $this->generator = $permissionGenerator; parent::__construct(); } @@ -56,20 +64,21 @@ protected function configure() { $this ->setName('generate:permissions') - ->setDescription($this->trans('commands.generate.permission.description')) - ->setHelp($this->trans('commands.generate.permission.help')) + ->setDescription($this->trans('commands.generate.permissions.description')) + ->setHelp($this->trans('commands.generate.permissions.help')) ->addOption( 'module', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module') ) ->addOption( 'permissions', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.common.options.permissions') - ); + ) + ->setAliases(['gp']); } /** @@ -79,12 +88,10 @@ protected function execute(InputInterface $input, OutputInterface $output) { $module = $input->getOption('module'); $permissions = $input->getOption('permissions'); + $learning = $input->hasOption('learning'); - $learning = $input->hasOption('learning')?$input->getOption('learning'):false; - //@TODO: $this->generator - //$generator->setLearning($learning); - //$generator->generate($module, $permissions); + $this->generator->generate($module, $permissions, $learning); } /** diff --git a/src/Command/Generate/PluginBlockCommand.php b/src/Command/Generate/PluginBlockCommand.php index 3a4cf9021..eec339549 100644 --- a/src/Command/Generate/PluginBlockCommand.php +++ b/src/Command/Generate/PluginBlockCommand.php @@ -10,29 +10,27 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\ContainerAwareCommand; use Drupal\Console\Generator\PluginBlockGenerator; use Drupal\Console\Command\Shared\ServicesTrait; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\FormTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Drupal\Console\Command\Shared\ContainerAwareCommandTrait; use Drupal\Console\Extension\Manager; use Drupal\Console\Utils\Validator; -use Drupal\Console\Utils\StringConverter; -use Drupal\Console\Style\DrupalStyle; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\StringConverter; +use Drupal\Console\Core\Style\DrupalStyle; +use Drupal\Console\Core\Utils\ChainQueue; use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Render\ElementInfoManagerInterface; -class PluginBlockCommand extends Command +class PluginBlockCommand extends ContainerAwareCommand { use ServicesTrait; use ModuleTrait; use FormTrait; use ConfirmationTrait; - use ContainerAwareCommandTrait; /** * @var ConfigFactory @@ -76,6 +74,7 @@ class PluginBlockCommand extends Command /** * PluginBlockCommand constructor. + * * @param ConfigFactory $configFactory * @param ChainQueue $chainQueue * @param PluginBlockGenerator $generator @@ -112,43 +111,44 @@ protected function configure() ->setName('generate:plugin:block') ->setDescription($this->trans('commands.generate.plugin.block.description')) ->setHelp($this->trans('commands.generate.plugin.block.help')) - ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) ->addOption( 'class', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.block.options.class') ) ->addOption( 'label', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.block.options.label') ) ->addOption( 'plugin-id', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.block.options.plugin-id') ) ->addOption( 'theme-region', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.block.options.theme-region') ) ->addOption( 'inputs', - '', + null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $this->trans('commands.common.options.inputs') ) ->addOption( 'services', - '', + null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $this->trans('commands.common.options.services') - ); + ) + ->setAliases(['gpb']); } /** @@ -234,7 +234,7 @@ protected function interact(InputInterface $input, OutputInterface $output) $class = $input->getOption('class'); if (!$class) { $class = $io->ask( - $this->trans('commands.generate.plugin.block.options.class'), + $this->trans('commands.generate.plugin.block.questions.class'), 'DefaultBlock', function ($class) { return $this->validator->validateClassName($class); @@ -247,7 +247,7 @@ function ($class) { $label = $input->getOption('label'); if (!$label) { $label = $io->ask( - $this->trans('commands.generate.plugin.block.options.label'), + $this->trans('commands.generate.plugin.block.questions.label'), $this->stringConverter->camelCaseToHuman($class) ); $input->setOption('label', $label); @@ -257,7 +257,7 @@ function ($class) { $pluginId = $input->getOption('plugin-id'); if (!$pluginId) { $pluginId = $io->ask( - $this->trans('commands.generate.plugin.block.options.plugin-id'), + $this->trans('commands.generate.plugin.block.questions.plugin-id'), $this->stringConverter->camelCaseToUnderscore($class) ); $input->setOption('plugin-id', $pluginId); @@ -267,7 +267,7 @@ function ($class) { $themeRegion = $input->getOption('theme-region'); if (!$themeRegion) { $themeRegion = $io->choiceNoList( - $this->trans('commands.generate.plugin.block.options.theme-region'), + $this->trans('commands.generate.plugin.block.questions.theme-region'), array_values($themeRegions), null, true diff --git a/src/Command/Generate/PluginCKEditorButtonCommand.php b/src/Command/Generate/PluginCKEditorButtonCommand.php index b26f39aa3..d0bbd7aca 100644 --- a/src/Command/Generate/PluginCKEditorButtonCommand.php +++ b/src/Command/Generate/PluginCKEditorButtonCommand.php @@ -10,19 +10,17 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Generator\PluginCKEditorButtonGenerator; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Style\DrupalStyle; +use Drupal\Console\Core\Utils\ChainQueue; use Drupal\Console\Extension\Manager; -use Drupal\Console\Utils\StringConverter; +use Drupal\Console\Core\Utils\StringConverter; class PluginCKEditorButtonCommand extends Command { - use CommandTrait; use ModuleTrait; use ConfirmationTrait; @@ -33,10 +31,14 @@ class PluginCKEditorButtonCommand extends Command protected $chainQueue; - /** @var PluginCKEditorButtonGenerator */ + /** + * @var PluginCKEditorButtonGenerator +*/ protected $generator; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** @@ -47,6 +49,7 @@ class PluginCKEditorButtonCommand extends Command /** * PluginCKEditorButtonCommand constructor. + * * @param ChainQueue $chainQueue * @param PluginCKEditorButtonGenerator $generator * @param Manager $extensionManager @@ -73,40 +76,40 @@ protected function configure() ->setHelp($this->trans('commands.generate.plugin.ckeditorbutton.help')) ->addOption( 'module', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module') ) ->addOption( 'class', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.plugin.ckeditorbutton.options.class') ) ->addOption( 'label', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.plugin.ckeditorbutton.options.label') ) ->addOption( 'plugin-id', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.plugin.ckeditorbutton.options.plugin-id') ) ->addOption( 'button-name', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.plugin.ckeditorbutton.options.button-name') ) ->addOption( 'button-icon-path', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.plugin.ckeditorbutton.options.button-icon-path') - ); + )->setAliases(['gpc']); } /** @@ -118,7 +121,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $module = $input->getOption('module'); @@ -133,6 +136,8 @@ protected function execute(InputInterface $input, OutputInterface $output) ->generate($module, $class_name, $label, $plugin_id, $button_name, $button_icon_path); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery'], false); + + return 0; } protected function interact(InputInterface $input, OutputInterface $output) diff --git a/src/Command/Generate/PluginConditionCommand.php b/src/Command/Generate/PluginConditionCommand.php index f31e2e677..7b1cbbcfe 100644 --- a/src/Command/Generate/PluginConditionCommand.php +++ b/src/Command/Generate/PluginConditionCommand.php @@ -10,32 +10,34 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Entity\EntityTypeRepository; -use Drupal\Console\Command\Shared\CommandTrait; use Drupal\Console\Generator\PluginConditionGenerator; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; -use Drupal\Console\Utils\ChainQueue; -use Drupal\Console\Utils\StringConverter; - +use Drupal\Console\Core\Utils\ChainQueue; +use Drupal\Console\Core\Utils\StringConverter; /** * Class PluginConditionCommand + * * @package Drupal\Console\Command\Generate */ class PluginConditionCommand extends Command { - use CommandTrait; use ModuleTrait; use ConfirmationTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginConditionGenerator */ + /** + * @var PluginConditionGenerator +*/ protected $generator; /** @@ -51,11 +53,12 @@ class PluginConditionCommand extends Command /** * PluginConditionCommand constructor. - * @param Manager $extensionManager - * @param PluginConditionGenerator $generator - * @param ChainQueue $chainQueue - * @param EntityTypeRepository $entitytyperepository - * @param StringConverter $stringConverter + * + * @param Manager $extensionManager + * @param PluginConditionGenerator $generator + * @param ChainQueue $chainQueue + * @param EntityTypeRepository $entitytyperepository + * @param StringConverter $stringConverter */ public function __construct( Manager $extensionManager, @@ -78,43 +81,44 @@ protected function configure() ->setName('generate:plugin:condition') ->setDescription($this->trans('commands.generate.plugin.condition.description')) ->setHelp($this->trans('commands.generate.plugin.condition.help')) - ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) ->addOption( 'class', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.plugin.condition.options.class') ) ->addOption( 'label', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.plugin.condition.options.label') ) ->addOption( 'plugin-id', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.plugin.condition.options.plugin-id') ) ->addOption( 'context-definition-id', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.plugin.condition.options.context-definition-id') ) ->addOption( 'context-definition-label', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.plugin.condition.options.context-definition-label') ) ->addOption( 'context-definition-required', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.condition.options.context-definition-required') - ); + ) + ->setAliases(['gpco']); } /** @@ -126,7 +130,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $module = $input->getOption('module'); @@ -142,6 +146,8 @@ protected function execute(InputInterface $input, OutputInterface $output) ->generate($module, $class_name, $label, $plugin_id, $context_definition_id, $context_definition_label, $context_definition_required); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']); + + return 0; } protected function interact(InputInterface $input, OutputInterface $output) @@ -192,7 +198,7 @@ protected function interact(InputInterface $input, OutputInterface $output) $context_definition_id = $input->getOption('context-definition-id'); if (!$context_definition_id) { - $context_type = array('language' => 'Language', "entity" => "Entity"); + $context_type = ['language' => 'Language', "entity" => "Entity"]; $context_type_sel = $io->choice( $this->trans('commands.generate.plugin.condition.questions.context-type'), array_values($context_type) diff --git a/src/Command/Generate/PluginFieldCommand.php b/src/Command/Generate/PluginFieldCommand.php index 468bc39b1..f32aaa586 100644 --- a/src/Command/Generate/PluginFieldCommand.php +++ b/src/Command/Generate/PluginFieldCommand.php @@ -12,20 +12,20 @@ use Symfony\Component\Console\Output\OutputInterface; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Utils\StringConverter; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\StringConverter; +use Drupal\Console\Core\Utils\ChainQueue; class PluginFieldCommand extends Command { use ModuleTrait; use ConfirmationTrait; - use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** @@ -41,6 +41,7 @@ class PluginFieldCommand extends Command /** * PluginFieldCommand constructor. + * * @param Manager $extensionManager * @param StringConverter $stringConverter * @param ChainQueue $chainQueue @@ -62,85 +63,86 @@ protected function configure() ->setName('generate:plugin:field') ->setDescription($this->trans('commands.generate.plugin.field.description')) ->setHelp($this->trans('commands.generate.plugin.field.help')) - ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) ->addOption( 'type-class', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.plugin.field.options.type-class') ) ->addOption( 'type-label', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.field.options.type-label') ) ->addOption( 'type-plugin-id', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.field.options.type-plugin-id') ) ->addOption( 'type-description', - '', + null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.generate.plugin.field.options.type-type-description') + $this->trans('commands.generate.plugin.field.options.type-description') ) ->addOption( 'formatter-class', - '', + null, InputOption::VALUE_REQUIRED, - $this->trans('commands.generate.plugin.field.options.class') + $this->trans('commands.generate.plugin.field.options.formatter-class') ) ->addOption( 'formatter-label', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.field.options.formatter-label') ) ->addOption( 'formatter-plugin-id', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.field.options.formatter-plugin-id') ) ->addOption( 'widget-class', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.plugin.field.options.formatter-class') ) ->addOption( 'widget-label', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.field.options.widget-label') ) ->addOption( 'widget-plugin-id', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.field.options.widget-plugin-id') ) ->addOption( 'field-type', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.field.options.field-type') ) ->addOption( 'default-widget', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.field.options.default-widget') ) ->addOption( 'default-formatter', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.field.options.default-formatter') - ); + ) + ->setAliases(['gpf']); } /** @@ -152,7 +154,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $this->chainQueue @@ -193,6 +195,8 @@ protected function execute(InputInterface $input, OutputInterface $output) ); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery'], false); + + return 0; } protected function interact(InputInterface $input, OutputInterface $output) @@ -242,7 +246,7 @@ protected function interact(InputInterface $input, OutputInterface $output) if (!$description) { $description = $io->ask( $this->trans('commands.generate.plugin.field.questions.type-description'), - 'My Field Type' + $this->trans('commands.generate.plugin.field.suggestions.my-field-type') ); $input->setOption('type-description', $description); } diff --git a/src/Command/Generate/PluginFieldFormatterCommand.php b/src/Command/Generate/PluginFieldFormatterCommand.php index 3af94bee8..0befc9ffd 100644 --- a/src/Command/Generate/PluginFieldFormatterCommand.php +++ b/src/Command/Generate/PluginFieldFormatterCommand.php @@ -13,28 +13,31 @@ use Drupal\Console\Generator\PluginFieldFormatterGenerator; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Core\Field\FieldTypePluginManager; use Drupal\Console\Extension\Manager; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Utils\StringConverter; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\StringConverter; +use Drupal\Console\Core\Utils\ChainQueue; /** * Class PluginFieldFormatterCommand + * * @package Drupal\Console\Command\Generate */ class PluginFieldFormatterCommand extends Command { use ModuleTrait; use ConfirmationTrait; - use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginFieldFormatterGenerator */ + /** + * @var PluginFieldFormatterGenerator +*/ protected $generator; /** @@ -42,7 +45,9 @@ class PluginFieldFormatterCommand extends Command */ protected $stringConverter; - /** @var FieldTypePluginManager */ + /** + * @var FieldTypePluginManager +*/ protected $fieldTypePluginManager; /** @@ -53,11 +58,12 @@ class PluginFieldFormatterCommand extends Command /** * PluginImageFormatterCommand constructor. - * @param Manager $extensionManager + * + * @param Manager $extensionManager * @param PluginFieldFormatterGenerator $generator - * @param StringConverter $stringConverter - * @param FieldTypePluginManager $fieldTypePluginManager - * @param ChainQueue $chainQueue + * @param StringConverter $stringConverter + * @param FieldTypePluginManager $fieldTypePluginManager + * @param ChainQueue $chainQueue */ public function __construct( Manager $extensionManager, @@ -80,31 +86,32 @@ protected function configure() ->setName('generate:plugin:fieldformatter') ->setDescription($this->trans('commands.generate.plugin.fieldformatter.description')) ->setHelp($this->trans('commands.generate.plugin.fieldformatter.help')) - ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) ->addOption( 'class', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.plugin.fieldformatter.options.class') ) ->addOption( 'label', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.fieldformatter.options.label') ) ->addOption( 'plugin-id', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.fieldformatter.options.plugin-id') ) ->addOption( 'field-type', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.fieldformatter.options.field-type') - ); + ) + ->setAliases(['gpff']); } /** @@ -116,7 +123,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $module = $input->getOption('module'); @@ -128,6 +135,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->generator->generate($module, $class_name, $label, $plugin_id, $field_type); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']); + + return 0; } protected function interact(InputInterface $input, OutputInterface $output) diff --git a/src/Command/Generate/PluginFieldTypeCommand.php b/src/Command/Generate/PluginFieldTypeCommand.php index fb41ca55a..157a1e908 100644 --- a/src/Command/Generate/PluginFieldTypeCommand.php +++ b/src/Command/Generate/PluginFieldTypeCommand.php @@ -13,28 +13,31 @@ use Drupal\Console\Generator\PluginFieldTypeGenerator; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Utils\StringConverter; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\StringConverter; +use Drupal\Console\Core\Utils\ChainQueue; use Drupal\Core\Field\FieldTypePluginManager; /** * Class PluginFieldTypeCommand + * * @package Drupal\Console\Command\Generate */ class PluginFieldTypeCommand extends Command { use ModuleTrait; use ConfirmationTrait; - use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginFieldTypeGenerator */ + /** + * @var PluginFieldTypeGenerator +*/ protected $generator; /** @@ -50,6 +53,7 @@ class PluginFieldTypeCommand extends Command /** * PluginFieldTypeCommand constructor. + * * @param Manager $extensionManager * @param PluginFieldTypeGenerator $generator * @param StringConverter $stringConverter @@ -74,43 +78,44 @@ protected function configure() ->setName('generate:plugin:fieldtype') ->setDescription($this->trans('commands.generate.plugin.fieldtype.description')) ->setHelp($this->trans('commands.generate.plugin.fieldtype.help')) - ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) ->addOption( 'class', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.plugin.fieldtype.options.class') ) ->addOption( 'label', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.fieldtype.options.label') ) ->addOption( 'plugin-id', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.fieldtype.options.plugin-id') ) ->addOption( 'description', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.fieldtype.options.description') ) ->addOption( 'default-widget', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.fieldtype.options.default-widget') ) ->addOption( 'default-formatter', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.fieldtype.options.default-formatter') - ); + ) + ->setAliases(['gpft']); } /** @@ -122,7 +127,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $module = $input->getOption('module'); @@ -137,6 +142,8 @@ protected function execute(InputInterface $input, OutputInterface $output) ->generate($module, $class_name, $label, $plugin_id, $description, $default_widget, $default_formatter); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery'], false); + + return 0; } protected function interact(InputInterface $input, OutputInterface $output) @@ -186,7 +193,7 @@ protected function interact(InputInterface $input, OutputInterface $output) if (!$description) { $description = $io->ask( $this->trans('commands.generate.plugin.fieldtype.questions.description'), - 'My Field Type' + $this->trans('commands.generate.plugin.fieldtype.suggestions.my-field-type') ); $input->setOption('description', $description); } diff --git a/src/Command/Generate/PluginFieldWidgetCommand.php b/src/Command/Generate/PluginFieldWidgetCommand.php index f43cda77f..c61ea6cac 100644 --- a/src/Command/Generate/PluginFieldWidgetCommand.php +++ b/src/Command/Generate/PluginFieldWidgetCommand.php @@ -13,28 +13,31 @@ use Drupal\Console\Generator\PluginFieldWidgetGenerator; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Utils\StringConverter; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\StringConverter; +use Drupal\Console\Core\Utils\ChainQueue; use Drupal\Core\Field\FieldTypePluginManager; /** * Class PluginFieldWidgetCommand + * * @package Drupal\Console\Command\Generate */ class PluginFieldWidgetCommand extends Command { use ModuleTrait; use ConfirmationTrait; - use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginFieldWidgetGenerator */ + /** + * @var PluginFieldWidgetGenerator +*/ protected $generator; /** @@ -42,10 +45,14 @@ class PluginFieldWidgetCommand extends Command */ protected $stringConverter; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; - /** @var FieldTypePluginManager */ + /** + * @var FieldTypePluginManager +*/ protected $fieldTypePluginManager; /** @@ -56,6 +63,7 @@ class PluginFieldWidgetCommand extends Command /** * PluginFieldWidgetCommand constructor. + * * @param Manager $extensionManager * @param PluginFieldWidgetGenerator $generator * @param StringConverter $stringConverter @@ -83,31 +91,32 @@ protected function configure() ->setName('generate:plugin:fieldwidget') ->setDescription($this->trans('commands.generate.plugin.fieldwidget.description')) ->setHelp($this->trans('commands.generate.plugin.fieldwidget.help')) - ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) ->addOption( 'class', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.plugin.fieldwidget.options.class') ) ->addOption( 'label', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.fieldwidget.options.label') ) ->addOption( 'plugin-id', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.fieldwidget.options.plugin-id') ) ->addOption( 'field-type', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.fieldwidget.options.field-type') - ); + ) + ->setAliases(['gpfw']); } /** @@ -119,7 +128,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $module = $input->getOption('module'); @@ -131,6 +140,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->generator->generate($module, $class_name, $label, $plugin_id, $field_type); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']); + + return 0; } protected function interact(InputInterface $input, OutputInterface $output) @@ -179,7 +190,7 @@ protected function interact(InputInterface $input, OutputInterface $output) $field_type = $input->getOption('field-type'); if (!$field_type) { // Gather valid field types. - $field_type_options = array(); + $field_type_options = []; foreach ($this->fieldTypePluginManager->getGroupedDefinitions($this->fieldTypePluginManager->getUiDefinitions()) as $category => $field_types) { foreach ($field_types as $name => $field_type) { $field_type_options[] = $name; diff --git a/src/Command/Generate/PluginImageEffectCommand.php b/src/Command/Generate/PluginImageEffectCommand.php index 6d4309dcd..68ca5463c 100644 --- a/src/Command/Generate/PluginImageEffectCommand.php +++ b/src/Command/Generate/PluginImageEffectCommand.php @@ -13,27 +13,30 @@ use Drupal\Console\Generator\PluginImageEffectGenerator; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Utils\StringConverter; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\StringConverter; +use Drupal\Console\Core\Utils\ChainQueue; /** * Class PluginImageEffectCommand + * * @package Drupal\Console\Command\Generate */ class PluginImageEffectCommand extends Command { use ModuleTrait; use ConfirmationTrait; - use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginImageEffectGenerator */ + /** + * @var PluginImageEffectGenerator +*/ protected $generator; /** @@ -49,6 +52,7 @@ class PluginImageEffectCommand extends Command /** * PluginImageEffectCommand constructor. + * * @param Manager $extensionManager * @param PluginImageEffectGenerator $generator * @param StringConverter $stringConverter @@ -73,31 +77,32 @@ protected function configure() ->setName('generate:plugin:imageeffect') ->setDescription($this->trans('commands.generate.plugin.imageeffect.description')) ->setHelp($this->trans('commands.generate.plugin.imageeffect.help')) - ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) ->addOption( 'class', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.plugin.imageeffect.options.class') ) ->addOption( 'label', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.imageeffect.options.label') ) ->addOption( 'plugin-id', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.imageeffect.options.plugin-id') ) ->addOption( 'description', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.imageeffect.options.description') - ); + ) + ->setAliases(['gpie']); } /** @@ -109,7 +114,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $module = $input->getOption('module'); @@ -170,7 +175,7 @@ protected function interact(InputInterface $input, OutputInterface $output) if (!$description) { $description = $io->ask( $this->trans('commands.generate.plugin.imageeffect.questions.description'), - 'My Image Effect' + $this->trans('commands.generate.plugin.imageeffect.suggestions.my-image-effect') ); $input->setOption('description', $description); } diff --git a/src/Command/Generate/PluginImageFormatterCommand.php b/src/Command/Generate/PluginImageFormatterCommand.php index 1d56abbc5..07636c997 100644 --- a/src/Command/Generate/PluginImageFormatterCommand.php +++ b/src/Command/Generate/PluginImageFormatterCommand.php @@ -13,24 +13,26 @@ use Drupal\Console\Generator\PluginImageFormatterGenerator; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Utils\StringConverter; +use Drupal\Console\Core\Utils\StringConverter; use Drupal\Console\Utils\Validator; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\ChainQueue; class PluginImageFormatterCommand extends Command { use ModuleTrait; use ConfirmationTrait; - use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginImageFormatterGenerator */ + /** + * @var PluginImageFormatterGenerator +*/ protected $generator; /** @@ -38,7 +40,9 @@ class PluginImageFormatterCommand extends Command */ protected $stringConverter; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; /** @@ -49,11 +53,12 @@ class PluginImageFormatterCommand extends Command /** * PluginImageFormatterCommand constructor. - * @param Manager $extensionManager + * + * @param Manager $extensionManager * @param PluginImageFormatterGenerator $generator - * @param StringConverter $stringConverter - * @param Validator $validator - * @param ChainQueue $chainQueue + * @param StringConverter $stringConverter + * @param Validator $validator + * @param ChainQueue $chainQueue */ public function __construct( Manager $extensionManager, @@ -76,25 +81,26 @@ protected function configure() ->setName('generate:plugin:imageformatter') ->setDescription($this->trans('commands.generate.plugin.imageformatter.description')) ->setHelp($this->trans('commands.generate.plugin.imageformatter.help')) - ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) ->addOption( 'class', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.plugin.imageformatter.options.class') ) ->addOption( 'label', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.imageformatter.options.label') ) ->addOption( 'plugin-id', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.imageformatter.options.plugin-id') - ); + ) + ->setAliases(['gpif']); } /** @@ -106,7 +112,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $module = $input->getOption('module'); diff --git a/src/Command/Generate/PluginMailCommand.php b/src/Command/Generate/PluginMailCommand.php index 0eb67aa8d..cf983fb74 100644 --- a/src/Command/Generate/PluginMailCommand.php +++ b/src/Command/Generate/PluginMailCommand.php @@ -15,30 +15,33 @@ use Drupal\Console\Command\Shared\FormTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; use Drupal\Console\Generator\PluginMailGenerator; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\ContainerAwareCommand; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; -use Drupal\Console\Command\Shared\ContainerAwareCommandTrait; -use Drupal\Console\Utils\StringConverter; +use Drupal\Console\Core\Utils\StringConverter; use Drupal\Console\Utils\Validator; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\ChainQueue; /** * Class PluginMailCommand + * * @package Drupal\Console\Command\Generate */ -class PluginMailCommand extends Command +class PluginMailCommand extends ContainerAwareCommand { use ServicesTrait; use ModuleTrait; use FormTrait; use ConfirmationTrait; - use ContainerAwareCommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginMailGenerator */ + /** + * @var PluginMailGenerator +*/ protected $generator; /** @@ -46,7 +49,9 @@ class PluginMailCommand extends Command */ protected $stringConverter; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; /** @@ -57,6 +62,7 @@ class PluginMailCommand extends Command /** * PluginMailCommand constructor. + * * @param Manager $extensionManager * @param PluginMailGenerator $generator * @param StringConverter $stringConverter @@ -84,31 +90,31 @@ protected function configure() ->setName('generate:plugin:mail') ->setDescription($this->trans('commands.generate.plugin.mail.description')) ->setHelp($this->trans('commands.generate.plugin.mail.help')) - ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) ->addOption( 'class', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.mail.options.class') ) ->addOption( 'label', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.mail.options.label') ) ->addOption( 'plugin-id', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.mail.options.plugin-id') ) ->addOption( 'services', - '', + null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $this->trans('commands.common.options.services') - ); + )->setAliases(['gpm']); } /** diff --git a/src/Command/Generate/PluginMigrateProcessCommand.php b/src/Command/Generate/PluginMigrateProcessCommand.php new file mode 100644 index 000000000..14aaae194 --- /dev/null +++ b/src/Command/Generate/PluginMigrateProcessCommand.php @@ -0,0 +1,145 @@ +generator = $generator; + $this->chainQueue = $chainQueue; + $this->extensionManager = $extensionManager; + $this->stringConverter = $stringConverter; + parent::__construct(); + } + + protected function configure() + { + $this + ->setName('generate:plugin:migrate:process') + ->setDescription($this->trans('commands.generate.plugin.migrate.process.description')) + ->setHelp($this->trans('commands.generate.plugin.migrate.process.help')) + ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption( + 'class', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.plugin.migrate.process.options.class') + ) + ->addOption( + 'plugin-id', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.plugin.migrate.process.options.plugin-id') + )->setAliases(['gpmp']); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration + if (!$this->confirmGeneration($io)) { + return 1; + } + + $module = $input->getOption('module'); + $class_name = $input->getOption('class'); + $plugin_id = $input->getOption('plugin-id'); + + $this->generator->generate($module, $class_name, $plugin_id); + + $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']); + } + + /** + * {@inheritdoc} + */ + protected function interact(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + // 'module-name' option. + $module = $input->getOption('module'); + if (!$module) { + // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion + $module = $this->moduleQuestion($io); + $input->setOption('module', $module); + } + + // 'class-name' option + $class = $input->getOption('class'); + if (!$class) { + $class = $io->ask( + $this->trans('commands.generate.plugin.migrate.process.questions.class'), + ucfirst($this->stringConverter->underscoreToCamelCase($module)) + ); + $input->setOption('class', $class); + } + + // 'plugin-id' option. + $pluginId = $input->getOption('plugin-id'); + if (!$pluginId) { + $pluginId = $io->ask( + $this->trans('commands.generate.plugin.migrate.source.questions.plugin-id'), + $this->stringConverter->camelCaseToUnderscore($class) + ); + $input->setOption('plugin-id', $pluginId); + } + } +} diff --git a/src/Command/Generate/PluginMigrateSourceCommand.php b/src/Command/Generate/PluginMigrateSourceCommand.php new file mode 100644 index 000000000..5fd86db3b --- /dev/null +++ b/src/Command/Generate/PluginMigrateSourceCommand.php @@ -0,0 +1,265 @@ +configFactory = $configFactory; + $this->chainQueue = $chainQueue; + $this->generator = $generator; + $this->entityTypeManager = $entityTypeManager; + $this->extensionManager = $extensionManager; + $this->validator = $validator; + $this->stringConverter = $stringConverter; + $this->elementInfoManager = $elementInfoManager; + parent::__construct(); + } + + protected function configure() + { + $this + ->setName('generate:plugin:migrate:source') + ->setDescription($this->trans('commands.generate.plugin.migrate.source.description')) + ->setHelp($this->trans('commands.generate.plugin.migrate.source.help')) + ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption( + 'class', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.plugin.migrate.source.options.class') + ) + ->addOption( + 'plugin-id', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.plugin.migrate.source.options.plugin-id') + ) + ->addOption( + 'table', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.plugin.migrate.source.options.table') + ) + ->addOption( + 'alias', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.plugin.migrate.source.options.alias') + ) + ->addOption( + 'group-by', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.plugin.migrate.source.options.group-by') + ) + ->addOption( + 'fields', + null, + InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, + $this->trans('commands.generate.plugin.migrate.source.options.fields') + )->setAliases(['gpms']); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration + if (!$this->confirmGeneration($io)) { + return 1; + } + + $module = $input->getOption('module'); + $class_name = $input->getOption('class'); + $plugin_id = $input->getOption('plugin-id'); + $table = $input->getOption('table'); + $alias = $input->getOption('alias'); + $group_by = $input->getOption('group-by'); + $fields = $input->getOption('fields'); + + $this->generator + ->generate( + $module, + $class_name, + $plugin_id, + $table, + $alias, + $group_by, + $fields + ); + + $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']); + } + + protected function interact(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + $module = $input->getOption('module'); + if (!$module) { + // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion + $module = $this->moduleQuestion($io); + $input->setOption('module', $module); + } + + $class = $input->getOption('class'); + if (!$class) { + $class = $io->ask( + $this->trans('commands.generate.plugin.migrate.source.questions.class'), + ucfirst($this->stringConverter->underscoreToCamelCase($module)), + function ($class) { + return $this->validator->validateClassName($class); + } + ); + $input->setOption('class', $class); + } + + $pluginId = $input->getOption('plugin-id'); + if (!$pluginId) { + $pluginId = $io->ask( + $this->trans('commands.generate.plugin.migrate.source.questions.plugin-id'), + $this->stringConverter->camelCaseToUnderscore($class) + ); + $input->setOption('plugin-id', $pluginId); + } + + $table = $input->getOption('table'); + if (!$table) { + $table = $io->ask( + $this->trans('commands.generate.plugin.migrate.source.questions.table'), + '' + ); + $input->setOption('table', $table); + } + + $alias = $input->getOption('alias'); + if (!$alias) { + $alias = $io->ask( + $this->trans('commands.generate.plugin.migrate.source.questions.alias'), + substr($table, 0, 1) + ); + $input->setOption('alias', $alias); + } + + $groupBy = $input->getOption('group-by'); + if ($groupBy == '') { + $groupBy = $io->ask( + $this->trans('commands.generate.plugin.migrate.source.questions.group-by'), + false + ); + $input->setOption('group-by', $groupBy); + } + + $fields = $input->getOption('fields'); + if (!$fields) { + $fields = []; + while (true) { + $id = $io->ask( + $this->trans('commands.generate.plugin.migrate.source.questions.fields.id'), + false + ); + if (!$id) { + break; + } + $description = $io->ask( + $this->trans('commands.generate.plugin.migrate.source.questions.fields.description'), + $id + ); + $fields[] = [ + 'id' => $id, + 'description' => $description, + ]; + } + $input->setOption('fields', $fields); + } + } +} diff --git a/src/Command/Generate/PluginRestResourceCommand.php b/src/Command/Generate/PluginRestResourceCommand.php index 83327c3fa..9e3f04c87 100644 --- a/src/Command/Generate/PluginRestResourceCommand.php +++ b/src/Command/Generate/PluginRestResourceCommand.php @@ -15,15 +15,15 @@ use Drupal\Console\Command\Shared\FormTrait; use Drupal\Console\Generator\PluginRestResourceGenerator; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Utils\StringConverter; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\StringConverter; +use Drupal\Console\Core\Utils\ChainQueue; /** * Class PluginRestResourceCommand + * * @package Drupal\Console\Command\Generate */ class PluginRestResourceCommand extends Command @@ -32,12 +32,15 @@ class PluginRestResourceCommand extends Command use ModuleTrait; use FormTrait; use ConfirmationTrait; - use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginRestResourceGenerator */ + /** + * @var PluginRestResourceGenerator +*/ protected $generator; /** @@ -53,6 +56,7 @@ class PluginRestResourceCommand extends Command /** * PluginRestResourceCommand constructor. + * * @param Manager $extensionManager * @param PluginRestResourceGenerator $generator * @param StringConverter $stringConverter @@ -77,10 +81,10 @@ protected function configure() ->setName('generate:plugin:rest:resource') ->setDescription($this->trans('commands.generate.plugin.rest.resource.description')) ->setHelp($this->trans('commands.generate.plugin.rest.resource.help')) - ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) ->addOption( 'class', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.rest.resource.options.class') ) @@ -88,32 +92,33 @@ protected function configure() 'name', null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.generate.service.options.name') + $this->trans('commands.generate.service.options.service-name') ) ->addOption( 'plugin-id', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.rest.resource.options.plugin-id') ) ->addOption( 'plugin-label', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.rest.resource.options.plugin-label') ) ->addOption( 'plugin-url', - '', + null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $this->trans('commands.generate.plugin.rest.resource.options.plugin-url') ) ->addOption( 'plugin-states', - '', + null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $this->trans('commands.generate.plugin.rest.resource.options.plugin-states') - ); + ) + ->setAliases(['gprr']); } /** @@ -125,7 +130,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $module = $input->getOption('module'); @@ -138,6 +143,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->generator->generate($module, $class_name, $plugin_label, $plugin_id, $plugin_url, $plugin_states); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']); + + return 0; } protected function interact(InputInterface $input, OutputInterface $output) @@ -202,7 +209,7 @@ function ($class_name) use ($stringUtils) { // --plugin-states option $plugin_states = $input->getOption('plugin-states'); if (!$plugin_states) { - $states = array('GET', 'PUT', 'POST', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'); + $states = ['GET', 'PUT', 'POST', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS']; $plugin_states = $io->choice( $this->trans('commands.generate.plugin.rest.resource.questions.plugin-states'), $states, diff --git a/src/Command/Generate/PluginRulesActionCommand.php b/src/Command/Generate/PluginRulesActionCommand.php index c7ceb0ecc..fbdfe2575 100644 --- a/src/Command/Generate/PluginRulesActionCommand.php +++ b/src/Command/Generate/PluginRulesActionCommand.php @@ -15,15 +15,15 @@ use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\FormTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Utils\StringConverter; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\StringConverter; +use Drupal\Console\Core\Utils\ChainQueue; /** * Class PluginRulesActionCommand + * * @package Drupal\Console\Command\Generate */ class PluginRulesActionCommand extends Command @@ -32,12 +32,15 @@ class PluginRulesActionCommand extends Command use ModuleTrait; use FormTrait; use ConfirmationTrait; - use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginRulesActionGenerator */ + /** + * @var PluginRulesActionGenerator +*/ protected $generator; /** @@ -53,10 +56,11 @@ class PluginRulesActionCommand extends Command /** * PluginRulesActionCommand constructor. - * @param Manager $extensionManager - * @param PluginRulesActionGenerator $generator - * @param StringConverter $stringConverter - * @param ChainQueue $chainQueue + * + * @param Manager $extensionManager + * @param PluginRulesActionGenerator $generator + * @param StringConverter $stringConverter + * @param ChainQueue $chainQueue */ public function __construct( Manager $extensionManager, @@ -77,38 +81,39 @@ protected function configure() ->setName('generate:plugin:rulesaction') ->setDescription($this->trans('commands.generate.plugin.rulesaction.description')) ->setHelp($this->trans('commands.generate.plugin.rulesaction.help')) - ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) ->addOption( 'class', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.rulesaction.options.class') ) ->addOption( 'label', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.rulesaction.options.label') ) ->addOption( 'plugin-id', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.rulesaction.options.plugin-id') ) - ->addOption('type', '', InputOption::VALUE_REQUIRED, $this->trans('commands.generate.plugin.rulesaction.options.type')) + ->addOption('type', null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.plugin.rulesaction.options.type')) ->addOption( 'category', - '', + null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $this->trans('commands.generate.plugin.rulesaction.options.category') ) ->addOption( 'context', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.rulesaction.options.context') - ); + ) + ->setAliases(['gpra']); } /** @@ -120,7 +125,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $module = $input->getOption('module'); @@ -134,6 +139,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->generator->generate($module, $class_name, $label, $plugin_id, $category, $context, $type); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']); + + return 0; } protected function interact(InputInterface $input, OutputInterface $output) diff --git a/src/Command/Generate/PluginSkeletonCommand.php b/src/Command/Generate/PluginSkeletonCommand.php index b8a49a8b1..6792c0992 100644 --- a/src/Command/Generate/PluginSkeletonCommand.php +++ b/src/Command/Generate/PluginSkeletonCommand.php @@ -11,32 +11,35 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\ContainerAwareCommand; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; use Drupal\Console\Command\Shared\ServicesTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; -use Drupal\Console\Command\Shared\ContainerAwareCommandTrait; -use Drupal\Console\Utils\StringConverter; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\StringConverter; +use Drupal\Console\Core\Utils\ChainQueue; use Drupal\Console\Utils\Validator; /** * Class PluginSkeletonCommand + * * @package Drupal\Console\Command\Generate */ -class PluginSkeletonCommand extends Command +class PluginSkeletonCommand extends ContainerAwareCommand { use ModuleTrait; use ConfirmationTrait; use ServicesTrait; - use ContainerAwareCommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginSkeletonGenerator */ + /** + * @var PluginSkeletonGenerator +*/ protected $generator; /** @@ -44,7 +47,9 @@ class PluginSkeletonCommand extends Command */ protected $stringConverter; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; /** @@ -55,6 +60,7 @@ class PluginSkeletonCommand extends Command /** * PluginSkeletonCommand constructor. + * * @param Manager $extensionManager * @param PluginSkeletonGenerator $generator * @param StringConverter $stringConverter @@ -95,30 +101,29 @@ protected function configure() ->setHelp($this->trans('commands.generate.plugin.skeleton.help')) ->addOption( 'module', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module') ) ->addOption( 'plugin-id', - '', + null, InputOption::VALUE_REQUIRED, - $this->trans('commands.generate.plugin.options.plugin-id') + $this->trans('commands.generate.plugin.skeleton.options.plugin') ) ->addOption( 'class', - '', + null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.generate.plugin.block.options.class') + $this->trans('commands.generate.plugin.skeleton.options.class') ) ->addOption( 'services', - '', + null, InputOption::VALUE_OPTIONAL| InputOption::VALUE_IS_ARRAY, $this->trans('commands.common.options.services') - ); + )->setAliases(['gps']); } - /** * {@inheritdoc} */ @@ -129,7 +134,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $module = $input->getOption('module'); @@ -167,6 +172,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->generator->generate($module, $pluginId, $plugin, $className, $pluginMetaData, $buildServices); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']); + + return 0; } protected function interact(InputInterface $input, OutputInterface $output) @@ -252,7 +259,7 @@ protected function getPluginMetadata($pluginId) } if (empty($pluginMetaData['pluginInterface'])) { - $pluginMetaData['pluginInterfaceMethods'] = array(); + $pluginMetaData['pluginInterfaceMethods'] = []; } else { $pluginMetaData['pluginInterfaceMethods'] = $this->getClassMethods($pluginMetaData['pluginInterface']); } diff --git a/src/Command/Generate/PluginTypeAnnotationCommand.php b/src/Command/Generate/PluginTypeAnnotationCommand.php index 1dabc927f..9454cb877 100644 --- a/src/Command/Generate/PluginTypeAnnotationCommand.php +++ b/src/Command/Generate/PluginTypeAnnotationCommand.php @@ -15,15 +15,14 @@ use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\FormTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; -use Drupal\Console\Utils\StringConverter; - +use Drupal\Console\Core\Utils\StringConverter; /** * Class PluginTypeAnnotationCommand + * * @package Drupal\Console\Command\Generate */ class PluginTypeAnnotationCommand extends Command @@ -32,12 +31,15 @@ class PluginTypeAnnotationCommand extends Command use ModuleTrait; use FormTrait; use ConfirmationTrait; - use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginTypeAnnotationGenerator */ + /** + * @var PluginTypeAnnotationGenerator +*/ protected $generator; /** @@ -47,6 +49,7 @@ class PluginTypeAnnotationCommand extends Command /** * PluginTypeAnnotationCommand constructor. + * * @param Manager $extensionManager * @param PluginTypeAnnotationGenerator $generator * @param StringConverter $stringConverter @@ -68,25 +71,26 @@ protected function configure() ->setName('generate:plugin:type:annotation') ->setDescription($this->trans('commands.generate.plugin.type.annotation.description')) ->setHelp($this->trans('commands.generate.plugin.type.annotation.help')) - ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) ->addOption( 'class', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.type.annotation.options.class') ) ->addOption( 'machine-name', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.type.annotation.options.plugin-id') ) ->addOption( 'label', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.type.annotation.options.label') - ); + ) + ->setAliases(['gpta']); } /** diff --git a/src/Command/Generate/PluginTypeYamlCommand.php b/src/Command/Generate/PluginTypeYamlCommand.php index 0f366c314..d1987bebb 100644 --- a/src/Command/Generate/PluginTypeYamlCommand.php +++ b/src/Command/Generate/PluginTypeYamlCommand.php @@ -15,15 +15,15 @@ use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\FormTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Utils\StringConverter; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\StringConverter; +use Drupal\Console\Core\Utils\ChainQueue; /** * Class PluginTypeYamlCommand + * * @package Drupal\Console\Command\Generate */ class PluginTypeYamlCommand extends Command @@ -32,12 +32,15 @@ class PluginTypeYamlCommand extends Command use ModuleTrait; use FormTrait; use ConfirmationTrait; - use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginTypeYamlGenerator */ + /** + * @var PluginTypeYamlGenerator +*/ protected $generator; /** @@ -47,6 +50,7 @@ class PluginTypeYamlCommand extends Command /** * PluginTypeYamlCommand constructor. + * * @param Manager $extensionManager * @param PluginTypeYamlGenerator $generator * @param StringConverter $stringConverter @@ -68,25 +72,26 @@ protected function configure() ->setName('generate:plugin:type:yaml') ->setDescription($this->trans('commands.generate.plugin.type.yaml.description')) ->setHelp($this->trans('commands.generate.plugin.type.yaml.help')) - ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) ->addOption( 'class', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.type.yaml.options.class') ) ->addOption( 'plugin-name', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.type.yaml.options.plugin-name') ) ->addOption( 'plugin-file-name', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.type.yaml.options.plugin-file-name') - ); + ) + ->setAliases(['gpty']); } /** diff --git a/src/Command/Generate/PluginViewsFieldCommand.php b/src/Command/Generate/PluginViewsFieldCommand.php index d973725ee..f0e0f971c 100644 --- a/src/Command/Generate/PluginViewsFieldCommand.php +++ b/src/Command/Generate/PluginViewsFieldCommand.php @@ -13,29 +13,31 @@ use Drupal\Console\Generator\PluginViewsFieldGenerator; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; -use Drupal\Console\Utils\ChainQueue; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Utils\ChainQueue; use Drupal\Console\Utils\Site; -use Drupal\Console\Utils\StringConverter; +use Drupal\Console\Core\Utils\StringConverter; /** * Class PluginViewsFieldCommand + * * @package Drupal\Console\Command\Generate */ class PluginViewsFieldCommand extends Command { use ModuleTrait; use ConfirmationTrait; - use CommandTrait; - - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginViewsFieldGenerator */ + /** + * @var PluginViewsFieldGenerator +*/ protected $generator; /** @@ -55,6 +57,7 @@ class PluginViewsFieldCommand extends Command /** * PluginViewsFieldCommand constructor. + * * @param Manager $extensionManager * @param PluginViewsFieldGenerator $generator * @param Site $site @@ -82,25 +85,26 @@ protected function configure() ->setName('generate:plugin:views:field') ->setDescription($this->trans('commands.generate.plugin.views.field.description')) ->setHelp($this->trans('commands.generate.plugin.views.field.help')) - ->addOption('module', '', InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) + ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module')) ->addOption( 'class', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.plugin.views.field.options.class') ) ->addOption( 'title', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.views.field.options.title') ) ->addOption( 'description', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.plugin.views.field.options.description') - ); + ) + ->setAliases(['gpvf']); } /** @@ -112,7 +116,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $module = $input->getOption('module'); @@ -124,6 +128,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->generator->generate($module, $class_machine_name, $class_name, $title, $description); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']); + + return 0; } protected function interact(InputInterface $input, OutputInterface $output) diff --git a/src/Command/Generate/PostUpdateCommand.php b/src/Command/Generate/PostUpdateCommand.php index 853a61f73..648fc2e06 100644 --- a/src/Command/Generate/PostUpdateCommand.php +++ b/src/Command/Generate/PostUpdateCommand.php @@ -13,28 +13,31 @@ use Drupal\Console\Generator\PostUpdateGenerator; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; -use Drupal\Console\Utils\ChainQueue; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Utils\ChainQueue; use Drupal\Console\Utils\Site; use Drupal\Console\Utils\Validator; /** * Class PostUpdateCommand + * * @package Drupal\Console\Command\Generate */ class PostUpdateCommand extends Command { use ModuleTrait; use ConfirmationTrait; - use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PostUpdateGenerator */ + /** + * @var PostUpdateGenerator +*/ protected $generator; /** @@ -42,7 +45,9 @@ class PostUpdateCommand extends Command */ protected $site; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; /** @@ -52,6 +57,7 @@ class PostUpdateCommand extends Command /** * PostUpdateCommand constructor. + * * @param Manager $extensionManager * @param PostUpdateGenerator $generator * @param Site $site @@ -77,20 +83,20 @@ protected function configure() { $this ->setName('generate:post:update') - ->setDescription($this->trans('commands.generate.post:update.description')) + ->setDescription($this->trans('commands.generate.post.update.description')) ->setHelp($this->trans('commands.generate.post.update.help')) ->addOption( 'module', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module') ) ->addOption( 'post-update-name', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.post.update.options.post-update-name') - ); + )->setAliases(['gpu']); } /** @@ -102,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $module = $input->getOption('module'); @@ -113,6 +119,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->generator->generate($module, $postUpdateName); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']); + + return 0; } protected function interact(InputInterface $input, OutputInterface $output) diff --git a/src/Command/Generate/ProfileCommand.php b/src/Command/Generate/ProfileCommand.php index 4df53d6b9..60e93dd96 100644 --- a/src/Command/Generate/ProfileCommand.php +++ b/src/Command/Generate/ProfileCommand.php @@ -8,34 +8,34 @@ namespace Drupal\Console\Command\Generate; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Generator\ProfileGenerator; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Drupal\Console\Style\DrupalStyle; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; -use Drupal\Console\Utils\StringConverter; +use Drupal\Console\Core\Utils\StringConverter; use Drupal\Console\Utils\Validator; -use Drupal\Console\Utils\Site; -use GuzzleHttp\Client; - /** * Class ProfileCommand + * * @package Drupal\Console\Command\Generate */ class ProfileCommand extends Command { use ConfirmationTrait; - use CommandTrait; - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; - /** @var ProfileGenerator */ + /** + * @var ProfileGenerator + */ protected $generator; /** @@ -43,45 +43,32 @@ class ProfileCommand extends Command */ protected $stringConverter; - /** @var Validator */ - protected $validator; - - /** - * @var Site - */ - protected $site; - /** - * @var Client + * @var Validator */ - protected $httpClient; + protected $validator; /** * ProfileCommand constructor. + * * @param Manager $extensionManager * @param ProfileGenerator $generator * @param StringConverter $stringConverter * @param Validator $validator - * @param $appRoot - * @param Site $site - * @param Client $httpClient + * @param $appRoot */ public function __construct( Manager $extensionManager, ProfileGenerator $generator, StringConverter $stringConverter, Validator $validator, - $appRoot, - Site $site, - Client $httpClient + $appRoot ) { $this->extensionManager = $extensionManager; $this->generator = $generator; $this->stringConverter = $stringConverter; $this->validator = $validator; $this->appRoot = $appRoot; - $this->site = $site; - $this->httpClient = $httpClient; parent::__construct(); } @@ -96,40 +83,48 @@ protected function configure() ->setHelp($this->trans('commands.generate.profile.help')) ->addOption( 'profile', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.profile.options.profile') ) ->addOption( 'machine-name', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.profile.options.machine-name') ) ->addOption( 'description', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.profile.options.description') ) ->addOption( 'core', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.profile.options.core') ) ->addOption( 'dependencies', - false, + null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.generate.profile.options.dependencies') + $this->trans('commands.generate.profile.options.dependencies'), + '' + ) + ->addOption( + 'themes', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.profile.options.themes'), + '' ) ->addOption( 'distribution', - false, + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.profile.options.distribution') - ); + )->setAliases(['gpr']); } /** @@ -140,31 +135,18 @@ protected function execute(InputInterface $input, OutputInterface $output) $io = new DrupalStyle($input, $output); if (!$this->confirmGeneration($io)) { - return; + return 1; } $profile = $this->validator->validateModuleName($input->getOption('profile')); $machine_name = $this->validator->validateMachineName($input->getOption('machine-name')); $description = $input->getOption('description'); $core = $input->getOption('core'); + $dependencies = $this->validator->validateExtensions($input->getOption('dependencies'), 'module', $io); + $themes = $this->validator->validateExtensions($input->getOption('themes'), 'theme', $io); $distribution = $input->getOption('distribution'); $profile_path = $this->appRoot . '/profiles'; - // Check if all module dependencies are available. - $dependencies = $this->validator->validateModuleDependencies($input->getOption('dependencies')); - if ($dependencies) { - $checked_dependencies = $this->checkDependencies($dependencies['success']); - if (!empty($checked_dependencies['no_modules'])) { - $io->info( - sprintf( - $this->trans('commands.generate.profile.warnings.module-unavailable'), - implode(', ', $checked_dependencies['no_modules']) - ) - ); - } - $dependencies = $dependencies['success']; - } - $this->generator->generate( $profile, $machine_name, @@ -172,47 +154,11 @@ protected function execute(InputInterface $input, OutputInterface $output) $description, $core, $dependencies, + $themes, $distribution ); } - /** - * @param array $dependencies - * @return array - */ - private function checkDependencies(array $dependencies) - { - $this->site->loadLegacyFile('/core/modules/system/system.module'); - $local_modules = array(); - - $modules = system_rebuild_module_data(); - foreach ($modules as $module_id => $module) { - array_push($local_modules, basename($module->subpath)); - } - - $checked_dependencies = array( - 'local_modules' => array(), - 'drupal_modules' => array(), - 'no_modules' => array(), - ); - - foreach ($dependencies as $module) { - if (in_array($module, $local_modules)) { - $checked_dependencies['local_modules'][] = $module; - } else { - $response = $this->httpClient->head('https://www.drupal.org/project/' . $module); - $header_link = explode(';', $response->getHeader('link')); - if (empty($header_link[0])) { - $checked_dependencies['no_modules'][] = $module; - } else { - $checked_dependencies['drupal_modules'][] = $module; - } - } - } - - return $checked_dependencies; - } - /** * {@inheritdoc} */ @@ -226,11 +172,11 @@ protected function interact(InputInterface $input, OutputInterface $output) try { // A profile is technically also a module, so we can use the same // validator to check the name. - $profile = $input->getOption('profile') ? $this->validateModuleName($input->getOption('profile')) : null; + $profile = $input->getOption('profile') ? $validators->validateModuleName($input->getOption('profile')) : null; } catch (\Exception $error) { $io->error($error->getMessage()); - return; + return 1; } if (!$profile) { @@ -245,11 +191,11 @@ function ($profile) use ($validators) { } try { - $machine_name = $input->getOption('machine-name') ? $this->validateModule($input->getOption('machine-name')) : null; + $machine_name = $input->getOption('machine-name') ? $validators->validateModuleName($input->getOption('machine-name')) : null; } catch (\Exception $error) { $io->error($error->getMessage()); - return; + return 1; } if (!$machine_name) { @@ -267,7 +213,7 @@ function ($machine_name) use ($validators) { if (!$description) { $description = $io->ask( $this->trans('commands.generate.profile.questions.description'), - 'My Useful Profile' + $this->trans('commands.generate.profile.suggestions.my-useful-profile') ); $input->setOption('description', $description); } @@ -286,7 +232,8 @@ function ($machine_name) use ($validators) { if ($io->confirm( $this->trans('commands.generate.profile.questions.dependencies'), true - )) { + ) + ) { $dependencies = $io->ask( $this->trans('commands.generate.profile.options.dependencies'), '' @@ -300,10 +247,11 @@ function ($machine_name) use ($validators) { if ($io->confirm( $this->trans('commands.generate.profile.questions.distribution'), false - )) { + ) + ) { $distribution = $io->ask( $this->trans('commands.generate.profile.options.distribution'), - 'My Kick-ass Distribution' + $this->trans('commands.generate.profile.suggestions.my-kick-ass-distribution') ); $input->setOption('distribution', $distribution); } diff --git a/src/Command/Generate/RouteSubscriberCommand.php b/src/Command/Generate/RouteSubscriberCommand.php index d3cabdcd3..a6b11d5f1 100644 --- a/src/Command/Generate/RouteSubscriberCommand.php +++ b/src/Command/Generate/RouteSubscriberCommand.php @@ -13,27 +13,29 @@ use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Generator\RouteSubscriberGenerator; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; -use Drupal\Console\Utils\ChainQueue; -use Drupal\Console\Command\Shared\CommandTrait; - +use Drupal\Console\Core\Utils\ChainQueue; /** * Class RouteSubscriberCommand + * * @package Drupal\Console\Command\Generate */ class RouteSubscriberCommand extends Command { use ModuleTrait; use ConfirmationTrait; - use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var RouteSubscriberGenerator */ + /** + * @var RouteSubscriberGenerator +*/ protected $generator; /** @@ -43,6 +45,7 @@ class RouteSubscriberCommand extends Command /** * RouteSubscriberCommand constructor. + * * @param Manager $extensionManager * @param RouteSubscriberGenerator $generator * @param ChainQueue $chainQueue @@ -84,7 +87,7 @@ protected function configure() null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.routesubscriber.options.class') - ); + )->setAliases(['gr']); } /** @@ -96,7 +99,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($output)) { - return; + return 1; } $module = $input->getOption('module'); @@ -106,6 +109,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->generator->generate($module, $name, $class); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']); + + return 0; } /** diff --git a/src/Command/Generate/ServiceCommand.php b/src/Command/Generate/ServiceCommand.php index 0c331dfdb..8792b7e63 100644 --- a/src/Command/Generate/ServiceCommand.php +++ b/src/Command/Generate/ServiceCommand.php @@ -14,28 +14,31 @@ use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Generator\ServiceGenerator; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; -use Drupal\Console\Command\Shared\ContainerAwareCommandTrait; +use Drupal\Console\Core\Command\ContainerAwareCommand; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; -use Drupal\Console\Utils\ChainQueue; -use Drupal\Console\Utils\StringConverter; +use Drupal\Console\Core\Utils\ChainQueue; +use Drupal\Console\Core\Utils\StringConverter; /** * Class ServiceCommand + * * @package Drupal\Console\Command\Generate */ -class ServiceCommand extends Command +class ServiceCommand extends ContainerAwareCommand { use ServicesTrait; use ModuleTrait; use ConfirmationTrait; - use ContainerAwareCommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var ServiceGenerator */ + /** + * @var ServiceGenerator +*/ protected $generator; /** @@ -50,10 +53,11 @@ class ServiceCommand extends Command /** * ServiceCommand constructor. - * @param Manager $extensionManager - * @param ServiceGenerator $generator - * @param StringConverter $stringConverter - * @param ChainQueue $chainQueue + * + * @param Manager $extensionManager + * @param ServiceGenerator $generator + * @param StringConverter $stringConverter + * @param ChainQueue $chainQueue */ public function __construct( Manager $extensionManager, @@ -88,7 +92,7 @@ protected function configure() 'name', null, InputOption::VALUE_REQUIRED, - $this->trans('commands.generate.service.options.name') + $this->trans('commands.generate.service.options.service-name') ) ->addOption( 'class', @@ -98,15 +102,15 @@ protected function configure() ) ->addOption( 'interface', - false, + null, InputOption::VALUE_NONE, - $this->trans('commands.common.service.options.interface') + $this->trans('commands.generate.service.options.interface') ) ->addOption( - 'interface_name', - false, + 'interface-name', + null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.common.service.options.interface_name') + $this->trans('commands.generate.service.options.interface-name') ) ->addOption( 'services', @@ -115,11 +119,12 @@ protected function configure() $this->trans('commands.common.options.services') ) ->addOption( - 'path_service', + 'path-service', null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.service.options.path') - ); + ) + ->setAliases(['gs']); } /** @@ -131,16 +136,16 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $module = $input->getOption('module'); $name = $input->getOption('name'); $class = $input->getOption('class'); $interface = $input->getOption('interface'); - $interface_name = $input->getOption('interface_name'); + $interface_name = $input->getOption('interface-name'); $services = $input->getOption('services'); - $path_service = $input->getOption('path_service'); + $path_service = $input->getOption('path-service'); $available_services = $this->container->getServiceIds(); @@ -158,6 +163,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->generator->generate($module, $name, $class, $interface, $interface_name, $build_services, $path_service); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']); + + return 0; } /** @@ -206,12 +213,12 @@ protected function interact(InputInterface $input, OutputInterface $output) } // --interface_name option - $interface_name = $input->getOption('interface_name'); + $interface_name = $input->getOption('interface-name'); if ($interface && !$interface_name) { $interface_name = $io->askEmpty( - $this->trans('commands.generate.service.questions.interface_name') + $this->trans('commands.generate.service.questions.interface-name') ); - $input->setOption('interface_name', $interface_name); + $input->setOption('interface-name', $interface_name); } // --services option @@ -223,13 +230,13 @@ protected function interact(InputInterface $input, OutputInterface $output) } // --path_service option - $path_service = $input->getOption('path_service'); + $path_service = $input->getOption('path-service'); if (!$path_service) { $path_service = $io->ask( $this->trans('commands.generate.service.questions.path'), '/modules/custom/' . $module . '/src/' ); - $input->setOption('path_service', $path_service); + $input->setOption('path-service', $path_service); } } } diff --git a/src/Command/Generate/ThemeCommand.php b/src/Command/Generate/ThemeCommand.php index c77cb1677..a9da69656 100644 --- a/src/Command/Generate/ThemeCommand.php +++ b/src/Command/Generate/ThemeCommand.php @@ -14,17 +14,17 @@ use Drupal\Console\Command\Shared\ThemeBreakpointTrait; use Drupal\Console\Generator\ThemeGenerator; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; use Drupal\Console\Utils\Site; -use Drupal\Console\Utils\StringConverter; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Utils\StringConverter; use Drupal\Console\Utils\Validator; use Drupal\Core\Extension\ThemeHandler; /** * Class ThemeCommand + * * @package Drupal\Console\Command\Generate */ class ThemeCommand extends Command @@ -32,15 +32,20 @@ class ThemeCommand extends Command use ConfirmationTrait; use ThemeRegionTrait; use ThemeBreakpointTrait; - use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var ThemeGenerator */ + /** + * @var ThemeGenerator +*/ protected $generator; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; /** @@ -65,10 +70,11 @@ class ThemeCommand extends Command /** * ThemeCommand constructor. + * * @param Manager $extensionManager * @param ThemeGenerator $generator * @param Validator $validator - * @param $appRoot + * @param $appRoot * @param ThemeHandler $themeHandler * @param Site $site * @param StringConverter $stringConverter @@ -104,59 +110,66 @@ protected function configure() ->setHelp($this->trans('commands.generate.theme.help')) ->addOption( 'theme', - '', + null, InputOption::VALUE_REQUIRED, - $this->trans('commands.generate.theme.options.module') + $this->trans('commands.generate.theme.options.theme') ) ->addOption( 'machine-name', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.theme.options.machine-name') ) ->addOption( 'theme-path', - '', + null, InputOption::VALUE_REQUIRED, - $this->trans('commands.generate.theme.options.module-path') + $this->trans('commands.generate.theme.options.theme-path') ) ->addOption( 'description', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.theme.options.description') ) - ->addOption('core', '', InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.theme.options.core')) + ->addOption('core', null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.theme.options.core')) ->addOption( 'package', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.theme.options.package') ) ->addOption( 'global-library', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.theme.options.global-library') ) + ->addOption( + 'libraries', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.theme.options.libraries') + ) ->addOption( 'base-theme', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.theme.options.base-theme') ) ->addOption( 'regions', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.theme.options.regions') ) ->addOption( 'breakpoints', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.theme.options.breakpoints') - ); + ) + ->setAliases(['gt']); } /** @@ -168,7 +181,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $theme = $this->validator->validateModuleName($input->getOption('theme')); @@ -181,6 +194,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $package = $input->getOption('package'); $base_theme = $input->getOption('base-theme'); $global_library = $input->getOption('global-library'); + $libraries = $input->getOption('libraries'); $regions = $input->getOption('regions'); $breakpoints = $input->getOption('breakpoints'); @@ -193,9 +207,12 @@ protected function execute(InputInterface $input, OutputInterface $output) $package, $base_theme, $global_library, + $libraries, $regions, $breakpoints ); + + return 0; } /** @@ -210,7 +227,7 @@ protected function interact(InputInterface $input, OutputInterface $output) } catch (\Exception $error) { $io->error($error->getMessage()); - return; + return 1; } if (!$theme) { @@ -230,12 +247,12 @@ function ($theme) use ($validators) { } catch (\Exception $error) { $io->error($error->getMessage()); - return; + return 1; } if (!$machine_name) { $machine_name = $io->ask( - $this->trans('commands.generate.module.questions.machine-name'), + $this->trans('commands.generate.theme.questions.machine-name'), $this->stringConverter->createMachineName($theme), function ($machine_name) use ($validators) { return $validators->validateMachineName($machine_name); @@ -272,7 +289,7 @@ function ($theme_path) use ($drupalRoot, $machine_name) { if (!$description) { $description = $io->ask( $this->trans('commands.generate.theme.questions.description'), - 'My Awesome theme' + $this->trans('commands.generate.theme.suggestions.my-awesome-theme') ); $input->setOption('description', $description); } @@ -281,7 +298,7 @@ function ($theme_path) use ($drupalRoot, $machine_name) { if (!$package) { $package = $io->ask( $this->trans('commands.generate.theme.questions.package'), - 'Other' + $this->trans('commands.generate.theme.suggestions.other') ); $input->setOption('package', $package); } @@ -318,13 +335,29 @@ function ($theme_path) use ($drupalRoot, $machine_name) { $input->setOption('global-library', $global_library); } + + // --libraries option. + $libraries = $input->getOption('libraries'); + if (!$libraries) { + if ($io->confirm( + $this->trans('commands.generate.theme.questions.library-add'), + true + ) + ) { + // @see \Drupal\Console\Command\Shared\ThemeRegionTrait::libraryQuestion + $libraries = $this->libraryQuestion($io); + $input->setOption('libraries', $libraries); + } + } + // --regions option. $regions = $input->getOption('regions'); if (!$regions) { if ($io->confirm( $this->trans('commands.generate.theme.questions.regions'), true - )) { + ) + ) { // @see \Drupal\Console\Command\Shared\ThemeRegionTrait::regionQuestion $regions = $this->regionQuestion($io); $input->setOption('regions', $regions); @@ -337,7 +370,8 @@ function ($theme_path) use ($drupalRoot, $machine_name) { if ($io->confirm( $this->trans('commands.generate.theme.questions.breakpoints'), true - )) { + ) + ) { // @see \Drupal\Console\Command\Shared\ThemeRegionTrait::regionQuestion $breakpoints = $this->breakpointQuestion($io); $input->setOption('breakpoints', $breakpoints); diff --git a/src/Command/Generate/TwigExtensionCommand.php b/src/Command/Generate/TwigExtensionCommand.php index b2e397d87..d91cfe6c4 100644 --- a/src/Command/Generate/TwigExtensionCommand.php +++ b/src/Command/Generate/TwigExtensionCommand.php @@ -6,36 +6,39 @@ namespace Drupal\Console\Command\Generate; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\ContainerAwareCommand; use Drupal\Console\Command\Shared\ConfirmationTrait; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\ServicesTrait; use Drupal\Console\Generator\TwigExtensionGenerator; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Drupal\Console\Extension\Manager; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\ChainQueue; use Drupal\Console\Utils\Site; -use Drupal\Console\Utils\StringConverter; -use Drupal\Console\Command\Shared\ContainerAwareCommandTrait; +use Drupal\Console\Core\Utils\StringConverter; /** * Class TwigExtensionCommand + * * @package Drupal\Console\Command\Generate */ -class TwigExtensionCommand extends Command +class TwigExtensionCommand extends ContainerAwareCommand { use ModuleTrait; use ServicesTrait; use ConfirmationTrait; - use ContainerAwareCommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var TwigExtensionGenerator */ + /** + * @var TwigExtensionGenerator +*/ protected $generator; /** @@ -56,6 +59,7 @@ class TwigExtensionCommand extends Command /** * TwigExtensionCommand constructor. + * * @param Manager $extensionManager * @param TwigExtensionGenerator $generator * @param StringConverter $stringConverter @@ -108,7 +112,7 @@ protected function configure() null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $this->trans('commands.common.options.services') - ); + )->setAliases(['gte']); } /** @@ -120,7 +124,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $module = $input->getOption('module'); @@ -130,13 +134,14 @@ protected function execute(InputInterface $input, OutputInterface $output) // Add renderer service as first parameter. array_unshift($services, 'renderer'); - // @see Drupal\Console\Command\Shared\ServicesTrait::buildServices $build_services = $this->buildServices($services); $this->generator->generate($module, $name, $class, $build_services); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']); + + return 0; } /** diff --git a/src/Command/Generate/UpdateCommand.php b/src/Command/Generate/UpdateCommand.php index 0302b89ac..f3b41ad16 100644 --- a/src/Command/Generate/UpdateCommand.php +++ b/src/Command/Generate/UpdateCommand.php @@ -13,27 +13,30 @@ use Drupal\Console\Generator\UpdateGenerator; use Drupal\Console\Command\Shared\ModuleTrait; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\ChainQueue; use Drupal\Console\Utils\Site; /** * Class UpdateCommand + * * @package Drupal\Console\Command\Generate */ class UpdateCommand extends Command { use ModuleTrait; use ConfirmationTrait; - use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var UpdateGenerator */ + /** + * @var UpdateGenerator +*/ protected $generator; /** @@ -49,9 +52,10 @@ class UpdateCommand extends Command /** * UpdateCommand constructor. + * * @param Manager $extensionManager * @param UpdateGenerator $generator - * @param StringConverter $stringConverter + * @param Site $site * @param ChainQueue $chainQueue */ public function __construct( @@ -75,16 +79,16 @@ protected function configure() ->setHelp($this->trans('commands.generate.update.help')) ->addOption( 'module', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module') ) ->addOption( 'update-n', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.update.options.update-n') - ); + )->setAliases(['gu']); } /** @@ -96,7 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io)) { - return; + return 1; } $module = $input->getOption('module'); @@ -116,6 +120,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->generator->generate($module, $updateNumber); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']); + + return 0; } protected function interact(InputInterface $input, OutputInterface $output) diff --git a/src/Command/Image/StylesFlushCommand.php b/src/Command/Image/StylesFlushCommand.php index 06b0c394d..c9b267a6a 100644 --- a/src/Command/Image/StylesFlushCommand.php +++ b/src/Command/Image/StylesFlushCommand.php @@ -9,15 +9,12 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; class StylesFlushCommand extends Command { - use CommandTrait; - /** * @var EntityTypeManagerInterface */ @@ -25,6 +22,7 @@ class StylesFlushCommand extends Command /** * StylesDebugCommand constructor. + * * @param EntityTypeManagerInterface $entityTypeManager */ public function __construct(EntityTypeManagerInterface $entityTypeManager) @@ -42,7 +40,7 @@ protected function configure() 'styles', InputArgument::IS_ARRAY | InputArgument::REQUIRED, $this->trans('commands.image.styles.flush.options.image-style') - ); + )->setAliases(['isf']); } /** diff --git a/src/Command/Locale/LanguageAddCommand.php b/src/Command/Locale/LanguageAddCommand.php index ba43f027f..9ea8eb5dd 100644 --- a/src/Command/Locale/LanguageAddCommand.php +++ b/src/Command/Locale/LanguageAddCommand.php @@ -11,10 +11,9 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Drupal\language\Entity\ConfigurableLanguage; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Command\Shared\LocaleTrait; -use Drupal\Console\Command\Shared\CommandTrait; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Console\Utils\Site; use Drupal\Console\Annotations\DrupalCommand; @@ -27,7 +26,6 @@ */ class LanguageAddCommand extends Command { - use CommandTrait; use LocaleTrait; /** @@ -42,6 +40,7 @@ class LanguageAddCommand extends Command /** * LanguageAddCommand constructor. + * * @param Site $site * @param ModuleHandlerInterface $moduleHandler */ diff --git a/src/Command/Locale/LanguageDeleteCommand.php b/src/Command/Locale/LanguageDeleteCommand.php index 91a988a11..2a27accbc 100644 --- a/src/Command/Locale/LanguageDeleteCommand.php +++ b/src/Command/Locale/LanguageDeleteCommand.php @@ -7,13 +7,12 @@ namespace Drupal\Console\Command\Locale; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Command\Shared\LocaleTrait; -use Drupal\Console\Command\Shared\CommandTrait; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Console\Utils\Site; @@ -27,7 +26,6 @@ */ class LanguageDeleteCommand extends Command { - use CommandTrait; use LocaleTrait; /** @@ -47,9 +45,10 @@ class LanguageDeleteCommand extends Command /** * LoginUrlCommand constructor. - * @param Site $site - * @param EntityTypeManagerInterface $entityTypeManager - * @param ModuleHandlerInterface $moduleHandler + * + * @param Site $site + * @param EntityTypeManagerInterface $entityTypeManager + * @param ModuleHandlerInterface $moduleHandler */ public function __construct( Site $site, diff --git a/src/Command/Locale/TranslationStatusCommand.php b/src/Command/Locale/TranslationStatusCommand.php index 6c800291a..4c8f0304b 100644 --- a/src/Command/Locale/TranslationStatusCommand.php +++ b/src/Command/Locale/TranslationStatusCommand.php @@ -10,10 +10,9 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Command\Shared\LocaleTrait; -use Drupal\Console\Command\Shared\CommandTrait; use Drupal\Console\Utils\Site; use Drupal\Console\Extension\Manager; use Drupal\Console\Annotations\DrupalCommand; @@ -26,7 +25,6 @@ */ class TranslationStatusCommand extends Command { - use CommandTrait; use LocaleTrait; /** @@ -41,6 +39,7 @@ class TranslationStatusCommand extends Command /** * TranslationStatusCommand constructor. + * * @param Site $site * @param Manager $extensionManager */ @@ -85,11 +84,14 @@ protected function execute(InputInterface $input, OutputInterface $output) if (!$languages) { $io->info($this->trans('commands.locale.translation.status.messages.no-languages')); - return; - } elseif (empty($status)) { + return 1; + } + + if (empty($status)) { $io->info($this->trans('commands.locale.translation.status.messages.no-translations')); - return; + return 1; } + if ($languages) { $projectsStatus = $this->projectsStatus(); @@ -108,5 +110,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $io->table($tableHeader, $tableRows, 'compact'); } } + + return 0; } } diff --git a/src/Command/Migrate/ExecuteCommand.php b/src/Command/Migrate/ExecuteCommand.php index 4d327220c..1e92b1144 100644 --- a/src/Command/Migrate/ExecuteCommand.php +++ b/src/Command/Migrate/ExecuteCommand.php @@ -16,18 +16,23 @@ use Drupal\Console\Utils\MigrateExecuteMessageCapture; use Drupal\Console\Command\Shared\MigrationTrait; use Drupal\Console\Command\Shared\DatabaseTrait; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\State\StateInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\migrate\Plugin\MigrationPluginManagerInterface; +use Drupal\Console\Annotations\DrupalCommand; +/** + * @DrupalCommand( + * extension = "migrate", + * extensionType = "module" + * ) + */ class ExecuteCommand extends Command { use DatabaseTrait; use MigrationTrait; - use CommandTrait; protected $migrateConnection; @@ -38,21 +43,16 @@ class ExecuteCommand extends Command /** * DebugCommand constructor. + * * @param MigrationPluginManagerInterface $pluginManagerMigration */ - public function __construct(MigrationPluginManagerInterface $pluginManagerMigration) - { + public function __construct( + MigrationPluginManagerInterface $pluginManagerMigration + ) { $this->pluginManagerMigration = $pluginManagerMigration; parent::__construct(); } - /** - * @DrupalCommand( - * dependencies = { - * "migrate" - * } - * ) - */ protected function configure() { $this @@ -61,65 +61,67 @@ protected function configure() ->addArgument('migration-ids', InputArgument::IS_ARRAY, $this->trans('commands.migrate.execute.arguments.id')) ->addOption( 'site-url', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.migrate.execute.options.site-url') ) ->addOption( 'db-type', - '', + null, InputOption::VALUE_REQUIRED, - $this->trans('commands.migrate.setup.migrations.options.db-type') + $this->trans('commands.migrate.execute.migrations.options.db-type') ) ->addOption( 'db-host', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.migrate.execute.options.db-host') ) ->addOption( 'db-name', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.migrate.execute.options.db-name') ) ->addOption( 'db-user', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.migrate.execute.options.db-user') ) ->addOption( 'db-pass', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.migrate.execute.options.db-pass') ) ->addOption( 'db-prefix', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.migrate.execute.options.db-prefix') ) ->addOption( 'db-port', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.migrate.execute.options.db-port') ) ->addOption( 'exclude', - '', + null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $this->trans('commands.migrate.execute.options.exclude'), - array() + [] ) ->addOption( 'source-base_path', - '', + null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.migrate.execute.options.source-base_path') - );; + $this->trans('commands.migrate.execute.options.source-base-path') + ) + ->setAliases(['mie']); + ; } /** @@ -202,13 +204,13 @@ protected function interact(InputInterface $input, OutputInterface $output) if (!$drupal_version = $this->getLegacyDrupalVersion($this->migrateConnection)) { $io->error($this->trans('commands.migrate.setup.migrations.questions.not-drupal')); - return; + return 1; } $database = $this->getDBInfo(); $version_tag = 'Drupal ' . $drupal_version; - // Get migrations + // Get migrations $migrations_list = $this->getMigrations($version_tag); // --migration-id prefix @@ -270,7 +272,7 @@ protected function interact(InputInterface $input, OutputInterface $output) $sourceBasepath = $input->getOption('source-base_path'); if (!$sourceBasepath) { $sourceBasepath = $io->ask( - $this->trans('commands.migrate.setup.questions.source-base_path'), + $this->trans('commands.migrate.setup.questions.source-base-path'), '' ); $input->setOption('source-base_path', $sourceBasepath); @@ -292,17 +294,17 @@ protected function execute(InputInterface $input, OutputInterface $output) // If migrations weren't provided finish execution if (empty($migration_ids)) { - return; + return 1; } if (!$this->migrateConnection) { - $this->registerMigrateDB($input, $output); + $this->registerMigrateDB($input, $io); $this->migrateConnection = $this->getDBConnection($io, 'default', 'upgrade'); } if (!$drupal_version = $this->getLegacyDrupalVersion($this->migrateConnection)) { $io->error($this->trans('commands.migrate.setup.migrations.questions.not-drupal')); - return; + return 1; } $version_tag = 'Drupal ' . $drupal_version; @@ -320,7 +322,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if (count($migrations) == 0) { $io->error($this->trans('commands.migrate.execute.messages.no-migrations')); - return; + return 1; } foreach ($migrations as $migration_id) { @@ -384,7 +386,11 @@ protected function execute(InputInterface $input, OutputInterface $output) } } else { $io->error($this->trans('commands.migrate.execute.messages.fail-load')); + + return 1; } } + + return 0; } } diff --git a/src/Command/Migrate/RollBackCommand.php b/src/Command/Migrate/RollBackCommand.php new file mode 100644 index 000000000..d8ae107ed --- /dev/null +++ b/src/Command/Migrate/RollBackCommand.php @@ -0,0 +1,182 @@ +pluginManagerMigration = $pluginManagerMigration; + parent::__construct(); + } + + protected function configure() + { + $this + ->setName('migrate:rollback') + ->setDescription($this->trans('commands.migrate.rollback.description')) + ->addArgument('migration-ids', InputArgument::IS_ARRAY, $this->trans('commands.migrate.rollback.arguments.id')) + ->addOption( + 'source-base_path', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.migrate.setup.options.source-base-path') + )->setAliases(['mir']); + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + $sourceBasepath = $input->getOption('source-base_path'); + $configuration['source']['constants']['source_base_path'] = rtrim($sourceBasepath, '/') . '/'; + // --migration-id prefix + $migration_id = $input->getArgument('migration-ids'); + $migrations_list = array_keys($this->getMigrations($version_tag)); + // If migrations weren't provided finish execution + if (empty($migration_id)) { + return 1; + } + + + if (!in_array('all', $migration_id)) { + $migration_ids = $migration_id; + } else { + $migration_ids = $migrations_list; + } + + foreach ($migration_ids as $migration) { + if (!in_array($migration, $migrations_list)) { + $io->warning( + sprintf( + $this->trans('commands.migrate.rollback.messages.not-available'), + $migration + ) + ); + continue; + } + $migration_service = $this->pluginManagerMigration->createInstance($migration, $configuration); + if ($migration_service) { + $messages = new MigrateExecuteMessageCapture(); + $executable = new MigrateExecutable($migration_service, $messages); + + $migration_status = $executable->rollback(); + switch ($migration_status) { + case MigrationInterface::RESULT_COMPLETED: + $io->info( + sprintf( + $this->trans('commands.migrate.rollback.messages.processing'), + $migration + ) + ); + break; + case MigrationInterface::RESULT_INCOMPLETE: + $io->info( + sprintf( + $this->trans('commands.migrate.execute.messages.importing-incomplete'), + $migration + ) + ); + break; + case MigrationInterface::RESULT_STOPPED: + $io->error( + sprintf( + $this->trans('commands.migrate.execute.messages.import-stopped'), + $migration + ) + ); + break; + } + } + } + + return 0; + } + + /** + * {@inheritdoc} + */ + protected function interact(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + // Get migrations + $migrations_list = $this->getMigrations($version_tag); + + // --migration-id prefix + $migration_id = $input->getArgument('migration-ids'); + + + if (!$migration_id) { + $migrations_ids = []; + + while (true) { + $migration_id = $io->choiceNoList( + $this->trans('commands.migrate.execute.questions.id'), + array_keys($migrations_list), + 'all' + ); + + if (empty($migration_id) || $migration_id == 'all') { + // Only add all if it's the first option + if (empty($migrations_ids) && $migration_id == 'all') { + $migrations_ids[] = $migration_id; + } + break; + } else { + $migrations_ids[] = $migration_id; + } + } + + $input->setArgument('migration-ids', $migrations_ids); + } + + // --source-base_path + $sourceBasepath = $input->getOption('source-base_path'); + if (!$sourceBasepath) { + $sourceBasepath = $io->ask( + $this->trans('commands.migrate.setup.questions.source-base-path'), + '' + ); + $input->setOption('source-base_path', $sourceBasepath); + } + } +} diff --git a/src/Command/Migrate/SetupCommand.php b/src/Command/Migrate/SetupCommand.php index 35db40e83..ecd16286d 100644 --- a/src/Command/Migrate/SetupCommand.php +++ b/src/Command/Migrate/SetupCommand.php @@ -7,28 +7,33 @@ namespace Drupal\Console\Command\Migrate; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; +use Drupal\Core\State\StateInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\ContainerAwareCommandTrait; +use Drupal\Console\Core\Command\ContainerAwareCommand; use Drupal\Console\Command\Shared\DatabaseTrait; use Drupal\Console\Command\Shared\MigrationTrait; -use Drupal\Core\State\State; use Drupal\migrate\Plugin\MigrationPluginManagerInterface; use Drupal\migrate\Plugin\RequirementsInterface; use Drupal\migrate\Exception\RequirementsException; use Drupal\Component\Plugin\Exception\PluginNotFoundException; +use Drupal\Console\Annotations\DrupalCommand; -class SetupCommand extends Command +/** + * @DrupalCommand( + * extension = "migrate", + * extensionType = "module" + * ) + */ +class SetupCommand extends ContainerAwareCommand { - use ContainerAwareCommandTrait; use DatabaseTrait; use MigrationTrait; /** - * @var State $state + * @var StateInterface $state */ protected $state; @@ -39,10 +44,13 @@ class SetupCommand extends Command /** * SetupCommand constructor. - * @param State $pluginManagerMigration + * + * @param StateInterface $pluginManagerMigration */ - public function __construct(State $state, MigrationPluginManagerInterface $pluginManagerMigration) - { + public function __construct( + StateInterface $state, + MigrationPluginManagerInterface $pluginManagerMigration + ) { $this->state = $state; $this->pluginManagerMigration = $pluginManagerMigration; parent::__construct(); @@ -55,52 +63,53 @@ protected function configure() ->setDescription($this->trans('commands.migrate.setup.description')) ->addOption( 'db-type', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.migrate.setup.options.db-type') ) ->addOption( 'db-host', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.migrate.setup.options.db-host') ) ->addOption( 'db-name', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.migrate.setup.options.db-name') ) ->addOption( 'db-user', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.migrate.setup.options.db-user') ) ->addOption( 'db-pass', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.migrate.setup.options.db-pass') ) ->addOption( 'db-prefix', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.migrate.setup.options.db-prefix') ) ->addOption( 'db-port', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.migrate.setup.options.db-port') ) ->addOption( 'source-base_path', - '', + null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.migrate.setup.options.source-base_path') - ); + $this->trans('commands.migrate.setup.options.source-base-path') + )->setAliases(['mis']); + ; } /** @@ -163,7 +172,7 @@ protected function interact(InputInterface $input, OutputInterface $output) $sourceBasepath = $input->getOption('source-base_path'); if (!$sourceBasepath) { $sourceBasepath = $io->ask( - $this->trans('commands.migrate.setup.questions.source-base_path'), + $this->trans('commands.migrate.setup.questions.source-base-path'), '' ); $input->setOption('source-base_path', $sourceBasepath); @@ -182,7 +191,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if (!$drupal_version = $this->getLegacyDrupalVersion($this->migrateConnection)) { $io->error($this->trans('commands.migrate.setup.migrations.questions.not-drupal')); - return; + return 1; } $database = $this->getDBInfo(); @@ -201,5 +210,7 @@ protected function execute(InputInterface $input, OutputInterface $output) ) ); } + + return 0; } } diff --git a/src/Command/Module/DownloadCommand.php b/src/Command/Module/DownloadCommand.php index f214a0219..c4155dc56 100644 --- a/src/Command/Module/DownloadCommand.php +++ b/src/Command/Module/DownloadCommand.php @@ -7,31 +7,33 @@ namespace Drupal\Console\Command\Module; -use Drupal\Console\Command\Shared\CommandTrait; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Command\Shared\ProjectDownloadTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Utils\DrupalApi; use GuzzleHttp\Client; use Drupal\Console\Extension\Manager; use Drupal\Console\Utils\Validator; use Drupal\Console\Utils\Site; -use Drupal\Console\Utils\ConfigurationManager; -use Drupal\Console\Utils\ShellProcess; +use Drupal\Console\Core\Utils\ConfigurationManager; +use Drupal\Console\Core\Utils\ShellProcess; class DownloadCommand extends Command { - use CommandTrait; use ProjectDownloadTrait; - /** @var DrupalApi */ + /** + * @var DrupalApi +*/ protected $drupalApi; - /** @var Client */ + /** + * @var Client +*/ protected $httpClient; /** @@ -39,16 +41,24 @@ class DownloadCommand extends Command */ protected $appRoot; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; - /** @var ConfigurationManager */ + /** + * @var ConfigurationManager +*/ protected $configurationManager; - /** @var ShellProcess */ + /** + * @var ShellProcess +*/ protected $shellProcess; /** @@ -58,14 +68,15 @@ class DownloadCommand extends Command /** * DownloadCommand constructor. - * @param DrupalApi $drupalApi - * @param Client $httpClient + * + * @param DrupalApi $drupalApi + * @param Client $httpClient * @param $appRoot - * @param Manager $extensionManager - * @param Validator $validator - * @param Site $site + * @param Manager $extensionManager + * @param Validator $validator + * @param Site $site * @param ConfigurationManager $configurationManager - * @param ShellProcess $shellProcess + * @param ShellProcess $shellProcess * @param $root */ public function __construct( @@ -109,22 +120,23 @@ protected function configure() ) ->addOption( 'latest', - '', + null, InputOption::VALUE_NONE, $this->trans('commands.module.download.options.latest') ) ->addOption( 'composer', - '', + null, InputOption::VALUE_NONE, $this->trans('commands.module.install.options.composer') ) ->addOption( 'unstable', - '', + null, InputOption::VALUE_NONE, - $this->trans('commands.module.install.options.unstable') - ); + $this->trans('commands.module.download.options.unstable') + ) + ->setAliases(['mod']); } /** @@ -186,10 +198,11 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { $version = $io->choice( sprintf( - $this->trans( - 'commands.site.new.questions.composer-release'), - $module - ), + $this->trans( + 'commands.site.new.questions.composer-release' + ), + $module + ), $versions ); } diff --git a/src/Command/Module/InstallCommand.php b/src/Command/Module/InstallCommand.php index b625221a5..81a3c25b6 100644 --- a/src/Command/Module/InstallCommand.php +++ b/src/Command/Module/InstallCommand.php @@ -7,31 +7,29 @@ namespace Drupal\Console\Command\Module; -use Drupal\Console\Command\Shared\CommandTrait; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Process\ProcessBuilder; -use Symfony\Component\Process\Exception\ProcessFailedException; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Command\Shared\ProjectDownloadTrait; use Drupal\Console\Command\Shared\ModuleTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Utils\Site; use Drupal\Console\Utils\Validator; use Drupal\Core\ProxyClass\Extension\ModuleInstaller; use Drupal\Console\Utils\DrupalApi; use Drupal\Console\Extension\Manager; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\ChainQueue; /** * Class InstallCommand + * * @package Drupal\Console\Command\Module */ class InstallCommand extends Command { - use CommandTrait; use ProjectDownloadTrait; use ModuleTrait; @@ -40,16 +38,24 @@ class InstallCommand extends Command */ protected $site; - /** @var Validator */ + /** + * @var Validator + */ protected $validator; - /** @var ModuleInstaller */ + /** + * @var ModuleInstaller + */ protected $moduleInstaller; - /** @var DrupalApi */ + /** + * @var DrupalApi + */ protected $drupalApi; - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** @@ -64,13 +70,14 @@ class InstallCommand extends Command /** * InstallCommand constructor. - * @param Site $site - * @param Validator $validator + * + * @param Site $site + * @param Validator $validator * @param ModuleInstaller $moduleInstaller - * @param DrupalApi $drupalApi - * @param Manager $extensionManager + * @param DrupalApi $drupalApi + * @param Manager $extensionManager * @param $appRoot - * @param ChainQueue $chainQueue + * @param ChainQueue $chainQueue */ public function __construct( Site $site, @@ -106,16 +113,17 @@ protected function configure() ) ->addOption( 'latest', - '', + null, InputOption::VALUE_NONE, $this->trans('commands.module.install.options.latest') ) ->addOption( 'composer', - '', + null, InputOption::VALUE_NONE, $this->trans('commands.module.uninstall.options.composer') - ); + ) + ->setAliases(['moi']); } /** @@ -146,7 +154,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->site->loadLegacyFile('/core/includes/bootstrap.inc'); // check module's requirements - $this->moduleRequirement($module); + $this->moduleRequirement($module, $io); if ($composer) { foreach ($module as $moduleItem) { @@ -157,28 +165,26 @@ protected function execute(InputInterface $input, OutputInterface $output) $processBuilder = new ProcessBuilder([]); $processBuilder->setWorkingDirectory($this->appRoot); - $processBuilder->setArguments(explode(" ", $command)); - $process = $processBuilder->getProcess(); - $process->setTty('true'); - $process->run(); + $processBuilder->setArguments(explode(" ", $command)); + $process = $processBuilder->getProcess(); + $process->setTty('true'); + $process->run(); - if ($process->isSuccessful()) { + if ($process->isSuccessful()) { $io->info( sprintf( - 'Module %s was downloaded with Composer.', + $this->trans('commands.module.install.messages.download-with-composer'), $moduleItem ) ); } else { $io->error( sprintf( - 'Module %s seems not to be installed with Composer. Halting.', + $this->trans('commands.module.install.messages.not-installed-with-composer'), $moduleItem ) ); throw new \RuntimeException($process->getErrorOutput()); - - return 0; } } @@ -194,7 +200,7 @@ protected function execute(InputInterface $input, OutputInterface $output) unset($module[array_search($invalidModule, $module)]); $io->error( sprintf( - 'Invalid module name: %s', + $this->trans('commands.module.install.messages.invalid-name'), $invalidModule ) ); @@ -231,6 +237,7 @@ protected function execute(InputInterface $input, OutputInterface $output) return 1; } + $this->site->removeCachedServicesFile(); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']); } } diff --git a/src/Command/Module/InstallDependencyCommand.php b/src/Command/Module/InstallDependencyCommand.php index e5e38fb7d..392e6f05f 100644 --- a/src/Command/Module/InstallDependencyCommand.php +++ b/src/Command/Module/InstallDependencyCommand.php @@ -7,27 +7,26 @@ namespace Drupal\Console\Command\Module; -use Drupal\Console\Command\Shared\CommandTrait; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Command\Shared\ProjectDownloadTrait; use Drupal\Console\Command\Shared\ModuleTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Utils\Site; use Drupal\Console\Utils\Validator; -use Drupal\Core\ProxyClass\Extension\ModuleInstaller; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Core\Extension\ModuleInstallerInterface; +use Drupal\Console\Core\Utils\ChainQueue; /** * Class InstallDependencyCommand + * * @package Drupal\Console\Command\Module */ class InstallDependencyCommand extends Command { - use CommandTrait; use ProjectDownloadTrait; use ModuleTrait; @@ -36,10 +35,14 @@ class InstallDependencyCommand extends Command */ protected $site; - /** @var Validator */ + /** + * @var Validator + */ protected $validator; - /** @var ModuleInstaller */ + /** + * @var ModuleInstallerInterface + */ protected $moduleInstaller; /** @@ -49,14 +52,16 @@ class InstallDependencyCommand extends Command /** * InstallCommand constructor. - * @param Site $site - * @param Validator $validator - * @param ChainQueue $chainQueue + * + * @param Site $site + * @param Validator $validator + * @param ModuleInstallerInterface $moduleInstaller + * @param ChainQueue $chainQueue */ public function __construct( Site $site, Validator $validator, - ModuleInstaller $moduleInstaller, + ModuleInstallerInterface $moduleInstaller, ChainQueue $chainQueue ) { $this->site = $site; @@ -73,12 +78,12 @@ protected function configure() { $this ->setName('module:dependency:install') - ->setDescription($this->trans('commands.module.install.dependencies.description')) + ->setDescription($this->trans('commands.module.dependency.install.description')) ->addArgument( 'module', InputArgument::IS_ARRAY, - $this->trans('commands.module.install.dependencies.arguments.module') - ); + $this->trans('commands.module.dependency.install.arguments.module') + )->setAliases(['modi']); } /** @@ -107,14 +112,14 @@ protected function execute(InputInterface $input, OutputInterface $output) $unInstalledDependencies = $this->calculateDependencies((array)$module); if (!$unInstalledDependencies) { - $io->warning($this->trans('commands.module.install.dependencies.messages.no-depencies')); + $io->warning($this->trans('commands.module.dependency.install.messages.no-depencies')); return 0; } try { $io->comment( sprintf( - $this->trans('commands.module.install.dependencies.messages.installing'), + $this->trans('commands.module.dependency.install.messages.installing'), implode(', ', $unInstalledDependencies) ) ); @@ -124,7 +129,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->moduleInstaller->install($unInstalledDependencies, true); $io->success( sprintf( - $this->trans('commands.module.install.dependencies.messages.success'), + $this->trans('commands.module.dependency.install.messages.success'), implode(', ', $unInstalledDependencies) ) ); diff --git a/src/Command/Module/PathCommand.php b/src/Command/Module/PathCommand.php index 86cc2beda..0d8cfa697 100644 --- a/src/Command/Module/PathCommand.php +++ b/src/Command/Module/PathCommand.php @@ -11,15 +11,13 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Command\Shared\ModuleTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Extension\Manager; class PathCommand extends Command { - use CommandTrait; use ModuleTrait; /** @@ -29,6 +27,7 @@ class PathCommand extends Command /** * PathCommand constructor. + * * @param Manager $extensionManager */ public function __construct(Manager $extensionManager) @@ -49,10 +48,10 @@ protected function configure() ) ->addOption( 'absolute', - '', + null, InputOption::VALUE_NONE, $this->trans('commands.module.path.options.absolute') - ); + )->setAliases(['mop']); } protected function execute(InputInterface $input, OutputInterface $output) diff --git a/src/Command/Module/UninstallCommand.php b/src/Command/Module/UninstallCommand.php index 030043ec8..603f00d76 100755 --- a/src/Command/Module/UninstallCommand.php +++ b/src/Command/Module/UninstallCommand.php @@ -7,23 +7,21 @@ namespace Drupal\Console\Command\Module; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Extension\Manager; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Command\Shared\ProjectDownloadTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Utils\Site; -use Drupal\Console\Utils\Validator; use Drupal\Core\ProxyClass\Extension\ModuleInstaller; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\ChainQueue; use Drupal\Core\Config\ConfigFactory; class UninstallCommand extends Command { - use CommandTrait; use ProjectDownloadTrait; /** @@ -31,7 +29,9 @@ class UninstallCommand extends Command */ protected $site; - /** @var ModuleInstaller */ + /** + * @var ModuleInstaller + */ protected $moduleInstaller; /** @@ -39,28 +39,37 @@ class UninstallCommand extends Command */ protected $chainQueue; - /** @var ConfigFactory */ + /** + * @var ConfigFactory + */ protected $configFactory; + /** + * @var Manager + */ + protected $extensionManager; /** * InstallCommand constructor. - * @param Site $site - * @param Validator $validator - * @param ChainQueue $chainQueue - * @param ConfigFactory $configFactory + * + * @param Site $site + * @param ModuleInstaller $moduleInstaller + * @param ChainQueue $chainQueue + * @param ConfigFactory $configFactory + * @param Manager $extensionManager */ public function __construct( Site $site, ModuleInstaller $moduleInstaller, ChainQueue $chainQueue, - ConfigFactory $configFactory - + ConfigFactory $configFactory, + Manager $extensionManager ) { $this->site = $site; $this->moduleInstaller = $moduleInstaller; $this->chainQueue = $chainQueue; $this->configFactory = $configFactory; + $this->extensionManager = $extensionManager; parent::__construct(); } @@ -79,16 +88,17 @@ protected function configure() ) ->addOption( 'force', - '', + null, InputOption::VALUE_NONE, $this->trans('commands.module.uninstall.options.force') ) ->addOption( 'composer', - '', + null, InputOption::VALUE_NONE, $this->trans('commands.module.uninstall.options.composer') - ); + ) + ->setAliases(['mou']); } /** * {@inheritdoc} @@ -152,7 +162,7 @@ protected function execute(InputInterface $input, OutputInterface $output) return 1; } - $installedModules = $coreExtension->get('module') ?: array(); + $installedModules = $coreExtension->get('module') ?: []; if (!$moduleList = array_intersect_key($moduleList, $installedModules)) { $io->info($this->trans('commands.module.uninstall.messages.nothing')); @@ -160,6 +170,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } if (!$force = $input->getOption('force')) { + $profile = drupal_get_profile(); $dependencies = []; while (list($module) = each($moduleList)) { foreach (array_keys($moduleData[$module]->required_by) as $dependency) { @@ -199,13 +210,13 @@ protected function execute(InputInterface $input, OutputInterface $output) false ) ); - } catch (\Exception $e) { $io->error($e->getMessage()); return 1; } + $this->site->removeCachedServicesFile(); $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']); } } diff --git a/src/Command/Module/UpdateCommand.php b/src/Command/Module/UpdateCommand.php index e3f034dc1..511c100fe 100644 --- a/src/Command/Module/UpdateCommand.php +++ b/src/Command/Module/UpdateCommand.php @@ -7,23 +7,23 @@ namespace Drupal\Console\Command\Module; -use Drupal\Console\Command\Shared\CommandTrait; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Command\Shared\ProjectDownloadTrait; -use Drupal\Console\Utils\ShellProcess; +use Drupal\Console\Core\Utils\ShellProcess; class UpdateCommand extends Command { - use CommandTrait; use ProjectDownloadTrait; - /** @var ShellProcess */ + /** + * @var ShellProcess +*/ protected $shellProcess; /** @@ -33,6 +33,7 @@ class UpdateCommand extends Command /** * UpdateCommand constructor. + * * @param ShellProcess $shellProcess * @param $root */ @@ -56,16 +57,16 @@ protected function configure() ) ->addOption( 'composer', - '', + null, InputOption::VALUE_NONE, $this->trans('commands.module.update.options.composer') ) ->addOption( 'simulate', - '', + null, InputOption::VALUE_NONE, $this->trans('commands.module.update.options.simulate') - ); + )->setAliases(['moup']); } /** diff --git a/src/Command/Multisite/NewCommand.php b/src/Command/Multisite/NewCommand.php index fadcaafa1..8e8e1c3fc 100644 --- a/src/Command/Multisite/NewCommand.php +++ b/src/Command/Multisite/NewCommand.php @@ -7,9 +7,9 @@ namespace Drupal\Console\Command\Multisite; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -18,33 +18,34 @@ use Symfony\Component\Filesystem\Exception\FileNotFoundException; /** - * Class MultisiteNewCommand + * Class NewCommand + * * @package Drupal\Console\Command\Multisite */ class NewCommand extends Command { - use CommandTrait; - protected $appRoot; /** * DebugCommand constructor. + * * @param $appRoot */ - public function __construct($appRoot) { + public function __construct($appRoot) + { $this->appRoot = $appRoot; parent::__construct(); } /** - * @var \Symfony\Component\Filesystem\Filesystem; + * @var Filesystem; */ protected $fs; /** * @var string */ - protected $subdir = ''; + protected $directory = ''; /** * {@inheritdoc} @@ -55,22 +56,22 @@ public function configure() ->setDescription($this->trans('commands.multisite.new.description')) ->setHelp($this->trans('commands.multisite.new.help')) ->addArgument( - 'sites-subdir', - InputOption::VALUE_REQUIRED, - $this->trans('commands.multisite.new.arguments.sites-subdir') + 'directory', + InputArgument::REQUIRED, + $this->trans('commands.multisite.new.arguments.directory') ) - ->addOption( - 'site-uri', - '', - InputOption::VALUE_OPTIONAL, - $this->trans('commands.multisite.new.options.site-uri') + ->addArgument( + 'uri', + InputArgument::REQUIRED, + $this->trans('commands.multisite.new.arguments.uri') ) ->addOption( - 'copy-install', - '', + 'copy-default', + null, InputOption::VALUE_NONE, - $this->trans('commands.multisite.new.options.copy-install') - ); + $this->trans('commands.multisite.new.options.copy-default') + ) + ->setAliases(['mun']); } /** @@ -78,21 +79,21 @@ public function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { - $output = new DrupalStyle($input, $output); - $this->subdir = $input->getArgument('sites-subdir'); + $io = new DrupalStyle($input, $output); + $this->fs = new Filesystem(); + $this->directory = $input->getArgument('directory'); + + if (!$this->directory) { + $io->error($this->trans('commands.multisite.new.errors.subdir-empty')); - if (empty($this->subdir)) { - $output->error($this->trans('commands.multisite.new.errors.subdir-empty')); return 1; } - $this->fs = new Filesystem(); - - if ($this->fs->exists($this->appRoot . '/sites/' . $this->subdir)) { - $output->error( + if ($this->fs->exists($this->appRoot . '/sites/' . $this->directory)) { + $io->error( sprintf( $this->trans('commands.multisite.new.errors.subdir-exists'), - $this->subdir + $this->directory ) ); @@ -100,36 +101,34 @@ protected function execute(InputInterface $input, OutputInterface $output) } if (!$this->fs->exists($this->appRoot . '/sites/default')) { - $output->error($this->trans('commands.multisite.new.errors.default-missing')); + $io->error($this->trans('commands.multisite.new.errors.default-missing')); + return 1; } try { - $this->fs->mkdir($this->appRoot . '/sites/' . $this->subdir, 0755); + $this->fs->mkdir($this->appRoot . '/sites/' . $this->directory, 0755); } catch (IOExceptionInterface $e) { - $output->error( + $io->error( sprintf( $this->trans('commands.multisite.new.errors.mkdir-fail'), - $this->subdir + $this->directory ) ); + return 1; } - if ($uri = $input->getOption('site-uri')) { - try { - $this->addToSitesFile($output, $uri); - } catch (\Exception $e) { - $output->error($e->getMessage()); - return 1; - } - } + $uri = $input->getArgument('uri'); + try { + $this->addToSitesFile($io, $uri); + } catch (\Exception $e) { + $io->error($e->getMessage()); - if ($input->getOption('copy-install')) { - $this->copyExistingInstall($output); + return 1; } - $this->createFreshSite($output); + $this->createFreshSite($io); return 0; } @@ -151,14 +150,14 @@ protected function addToSitesFile(DrupalStyle $output, $uri) throw new FileNotFoundException($this->trans('commands.multisite.new.errors.sites-invalid')); } $sites_file_contents = file_get_contents($this->appRoot . '/sites/sites.php'); - } elseif ($this->fs->exists($this->root . '/sites/example.sites.php')) { + } elseif ($this->fs->exists($this->appRoot . '/sites/example.sites.php')) { $sites_file_contents = file_get_contents($this->appRoot . '/sites/example.sites.php'); $sites_file_contents .= "\n\$sites = [];"; } else { throw new FileNotFoundException($this->trans('commands.multisite.new.errors.sites-missing')); } - $sites_file_contents .= "\n\$sites['$uri'] = '$this->subdir';"; + $sites_file_contents .= "\n\$sites['$this->directory'] = '$this->directory';"; try { $this->fs->dumpFile($this->appRoot . '/sites/sites.php', $sites_file_contents); @@ -171,64 +170,64 @@ protected function addToSitesFile(DrupalStyle $output, $uri) /** * Copies detected default install alters settings.php to fit the new directory. * - * @param DrupalStyle $output + * @param DrupalStyle $io */ - protected function copyExistingInstall(DrupalStyle $output) + protected function copyExistingInstall(DrupalStyle $io) { if (!$this->fs->exists($this->appRoot . '/sites/default/settings.php')) { - $output->error( + $io->error( sprintf( $this->trans('commands.multisite.new.errors.file-missing'), 'sites/default/settings.php' ) ); - return; + return 1; } if ($this->fs->exists($this->appRoot . '/sites/default/files')) { try { $this->fs->mirror( $this->appRoot . '/sites/default/files', - $this->appRoot . '/sites/' . $this->subdir . '/files' + $this->appRoot . '/sites/' . $this->directory . '/files' ); } catch (IOExceptionInterface $e) { - $output->error( + $io->error( sprintf( $this->trans('commands.multisite.new.errors.copy-fail'), 'sites/default/files', - 'sites/' . $this->subdir . '/files' + 'sites/' . $this->directory . '/files' ) ); - return; + return 1; } } else { - $output->warning($this->trans('commands.multisite.new.warnings.missing-files')); + $io->warning($this->trans('commands.multisite.new.warnings.missing-files')); } $settings = file_get_contents($this->appRoot . '/sites/default/settings.php'); - $settings = str_replace('sites/default', 'sites/' . $this->subdir, $settings); + $settings = str_replace('sites/default', 'sites/' . $this->directory, $settings); try { $this->fs->dumpFile( - $this->appRoot . '/sites/' . $this->subdir . '/settings.php', + $this->appRoot . '/sites/' . $this->directory . '/settings.php', $settings ); } catch (IOExceptionInterface $e) { - $output->error( + $io->error( sprintf( $this->trans('commands.multisite.new.errors.write-fail'), - 'sites/' . $this->subdir . '/settings.php' + 'sites/' . $this->directory . '/settings.php' ) ); - return; + return 1; } - $this->chmodSettings($output); + $this->chmodSettings($io); - $output->success( + $io->success( sprintf( - $this->trans('commands.multisite.new.messages.copy-install'), - $this->subdir + $this->trans('commands.multisite.new.messages.copy-default'), + $this->directory ) ); } @@ -236,44 +235,46 @@ protected function copyExistingInstall(DrupalStyle $output) /** * Creates site folder with clean settings.php file. * - * @param DrupalStyle $output + * @param DrupalStyle $io */ - protected function createFreshSite(DrupalStyle $output) + protected function createFreshSite(DrupalStyle $io) { if ($this->fs->exists($this->appRoot . '/sites/default/default.settings.php')) { try { $this->fs->copy( $this->appRoot . '/sites/default/default.settings.php', - $this->appRoot . '/sites/' . $this->subdir . '/settings.php' + $this->appRoot . '/sites/' . $this->directory . '/settings.php' ); } catch (IOExceptionInterface $e) { - $output->error( + $io->error( sprintf( $this->trans('commands.multisite.new.errors.copy-fail'), $this->appRoot . '/sites/default/default.settings.php', - $this->appRoot . '/sites/' . $this->subdir . '/settings.php' + $this->appRoot . '/sites/' . $this->directory . '/settings.php' ) ); - return; + return 1; } } else { - $output->error( + $io->error( sprintf( $this->trans('commands.multisite.new.errors.file-missing'), 'sites/default/default.settings.php' ) ); - return; + return 1; } - $this->chmodSettings($output); + $this->chmodSettings($io); - $output->success( + $io->success( sprintf( $this->trans('commands.multisite.new.messages.fresh-site'), - $this->subdir + $this->directory ) ); + + return 0; } /** @@ -283,19 +284,21 @@ protected function createFreshSite(DrupalStyle $output) * anyone. Also, Drupal likes being able to write to it during, for example, * a fresh install. * - * @param DrupalStyle $output + * @param DrupalStyle $io */ - protected function chmodSettings(DrupalStyle $output) + protected function chmodSettings(DrupalStyle $io) { try { - $this->fs->chmod($this->appRoot . '/sites/' . $this->subdir . '/settings.php', 0640); + $this->fs->chmod($this->appRoot . '/sites/' . $this->directory . '/settings.php', 0640); } catch (IOExceptionInterface $e) { - $output->error( + $io->error( sprintf( $this->trans('commands.multisite.new.errors.chmod-fail'), - $this->appRoot . '/sites/' . $this->subdir . '/settings.php' + $this->appRoot . '/sites/' . $this->directory . '/settings.php' ) ); + + return 1; } } } diff --git a/src/Command/Node/AccessRebuildCommand.php b/src/Command/Node/AccessRebuildCommand.php index 3b71eef82..dabbb73b1 100644 --- a/src/Command/Node/AccessRebuildCommand.php +++ b/src/Command/Node/AccessRebuildCommand.php @@ -10,19 +10,17 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\State\StateInterface; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class AccessRebuildCommand + * * @package Drupal\Console\Command\Node */ class AccessRebuildCommand extends Command { - use CommandTrait; - /** * @var StateInterface */ @@ -30,9 +28,11 @@ class AccessRebuildCommand extends Command /** * AccessRebuildCommand constructor. + * * @param StateInterface $state */ - public function __construct(StateInterface $state) { + public function __construct(StateInterface $state) + { $this->state = $state; parent::__construct(); } @@ -50,7 +50,7 @@ protected function configure() null, InputOption::VALUE_NONE, $this->trans('commands.node.access.rebuild.options.batch') - ); + )->setAliases(['nar']); } /** diff --git a/src/Command/Queue/RunCommand.php b/src/Command/Queue/RunCommand.php index cc0052e8c..d45f4db75 100644 --- a/src/Command/Queue/RunCommand.php +++ b/src/Command/Queue/RunCommand.php @@ -7,23 +7,21 @@ namespace Drupal\Console\Command\Queue; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Drupal\Core\Queue\QueueWorkerManagerInterface; use Drupal\Core\Queue\QueueFactory; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class RunCommand + * * @package Drupal\Console\Command\Queue */ class RunCommand extends Command { - use CommandTrait; - /** * @var QueueWorkerManagerInterface */ @@ -37,8 +35,9 @@ class RunCommand extends Command /** * DebugCommand constructor. - * @param QueueWorkerManagerInterface $queueWorker - * @param QueueFactory $queue + * + * @param QueueWorkerManagerInterface $queueWorker + * @param QueueFactory $queue */ public function __construct( QueueWorkerManagerInterface $queueWorker, @@ -61,7 +60,7 @@ protected function configure() 'name', InputArgument::OPTIONAL, $this->trans('commands.queue.run.arguments.name') - ); + )->setAliases(['qr']); } /** diff --git a/src/Command/Rest/DisableCommand.php b/src/Command/Rest/DisableCommand.php index c1fa98901..b42bdc8b6 100644 --- a/src/Command/Rest/DisableCommand.php +++ b/src/Command/Rest/DisableCommand.php @@ -10,10 +10,9 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Annotations\DrupalCommand; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Command\Shared\RestTrait; use Drupal\Core\Config\ConfigFactory; use Drupal\rest\Plugin\Type\ResourcePluginManager; @@ -26,21 +25,21 @@ */ class DisableCommand extends Command { - use CommandTrait; use RestTrait; /** - * @var ConfigFactory -*/ + * @var ConfigFactory + */ protected $configFactory; /** - * @var ResourcePluginManager -*/ + * @var ResourcePluginManager + */ protected $pluginManagerRest; /** * DisableCommand constructor. + * * @param ConfigFactory $configFactory * @param ResourcePluginManager $pluginManagerRest */ @@ -53,14 +52,6 @@ public function __construct( parent::__construct(); } - - /** - * @DrupalCommand( - * dependencies = { - * “rest" - * } - * ) - */ protected function configure() { $this @@ -70,7 +61,8 @@ protected function configure() 'resource-id', InputArgument::OPTIONAL, $this->trans('commands.rest.debug.arguments.resource-id') - ); + ) + ->setAliases(['red']); } protected function execute(InputInterface $input, OutputInterface $output) @@ -96,23 +88,38 @@ protected function execute(InputInterface $input, OutputInterface $output) $rest_resources_ids, $this->translator ); - $input->setArgument('resource-id', $resource_id); - $rest_settings = $this->getRestDrupalConfig(); - - unset($rest_settings[$resource_id]); - - $config = $this->configFactory->getEditable('rest.settings'); - - $config->set('resources', $rest_settings); - $config->save(); - - $io->success( - sprintf( - $this->trans('commands.rest.disable.messages.success'), - $resource_id - ) - ); + $resources = \Drupal::service('entity_type.manager') + ->getStorage('rest_resource_config')->loadMultiple(); + if ($resources[$this->getResourceKey($resource_id)]) { + $routeBuilder = \Drupal::service('router.builder'); + $resources[$this->getResourceKey($resource_id)]->delete(); + // Rebuild routing cache. + $routeBuilder->rebuild(); + + $io->success( + sprintf( + $this->trans('commands.rest.disable.messages.success'), + $resource_id + ) + ); + return true; + } + $message = sprintf($this->trans('commands.rest.disable.messages.already-disabled'), $resource_id); + $io->info($message); + return true; + } - return 0; + /** + * The key used in the form. + * + * @param string $resource_id + * The resource ID. + * + * @return string + * The resource key in the form. + */ + protected function getResourceKey($resource_id) + { + return str_replace(':', '.', $resource_id); } } diff --git a/src/Command/Rest/EnableCommand.php b/src/Command/Rest/EnableCommand.php index 1f6e28901..1a7c6c0ec 100644 --- a/src/Command/Rest/EnableCommand.php +++ b/src/Command/Rest/EnableCommand.php @@ -10,14 +10,15 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Annotations\DrupalCommand; -use Drupal\Console\Style\DrupalStyle; +use Drupal\rest\RestResourceConfigInterface; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Command\Shared\RestTrait; use Drupal\rest\Plugin\Type\ResourcePluginManager; use Drupal\Core\Authentication\AuthenticationCollector; use Drupal\Core\Config\ConfigFactory; +use Drupal\Core\Entity\EntityManager; /** * @DrupalCommand( @@ -27,7 +28,6 @@ */ class EnableCommand extends Command { - use CommandTrait; use RestTrait; /** @@ -41,28 +41,50 @@ class EnableCommand extends Command protected $authenticationCollector; /** - * @var ConfigFactory -*/ + * @var ConfigFactory + */ protected $configFactory; + /** + * The available serialization formats. + * + * @var array + */ + protected $formats; + + /** + * The entity manager. + * + * @var \Drupal\Core\Entity\EntityManagerInterface + */ + protected $entityManager; + /** * EnableCommand constructor. - * @param ResourcePluginManager $pluginManagerRest - * @param AuthenticationCollector $authenticationCollector - * @param ConfigFactory $configFactory + * + * @param ResourcePluginManager $pluginManagerRest + * @param AuthenticationCollector $authenticationCollector + * @param ConfigFactory $configFactory + * @param array $formats + * The available serialization formats. + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * The entity manager. */ public function __construct( ResourcePluginManager $pluginManagerRest, AuthenticationCollector $authenticationCollector, - ConfigFactory $configFactory + ConfigFactory $configFactory, + array $formats, + EntityManager $entity_manager ) { $this->pluginManagerRest = $pluginManagerRest; $this->authenticationCollector = $authenticationCollector; $this->configFactory = $configFactory; + $this->formats = $formats; + $this->entityManager = $entity_manager; parent::__construct(); } - protected function configure() { $this @@ -72,7 +94,8 @@ protected function configure() 'resource-id', InputArgument::OPTIONAL, $this->trans('commands.rest.debug.arguments.resource-id') - ); + ) + ->setAliases(['ree']); } protected function execute(InputInterface $input, OutputInterface $output) @@ -81,12 +104,10 @@ protected function execute(InputInterface $input, OutputInterface $output) $resource_id = $input->getArgument('resource-id'); $rest_resources = $this->getRestResources(); - $rest_resources_ids = array_merge( array_keys($rest_resources['enabled']), array_keys($rest_resources['disabled']) ); - if (!$resource_id) { $resource_id = $io->choiceNoList( $this->trans('commands.rest.enable.arguments.resource-id'), @@ -101,17 +122,24 @@ protected function execute(InputInterface $input, OutputInterface $output) ); $input->setArgument('resource-id', $resource_id); - // Calculate states available by resource and generate the question + // Calculate states available by resource and generate the question. $plugin = $this->pluginManagerRest->getInstance(['id' => $resource_id]); - $states = $plugin->availableMethods(); + $methods = $plugin->availableMethods(); + $method = $io->choice( + $this->trans('commands.rest.enable.arguments.methods'), + $methods + ); + $io->writeln( + $this->trans('commands.rest.enable.messages.selected-method') . ' ' . $method + ); - $state = $io->choice( - $this->trans('commands.rest.enable.arguments.states'), - $states + $format = $io->choice( + $this->trans('commands.rest.enable.arguments.formats'), + $this->formats ); $io->writeln( - $this->trans('commands.rest.enable.messages.selected-state').' '.$state + $this->trans('commands.rest.enable.messages.selected-format') . ' ' . $format ); // Get Authentication Provider and generate the question @@ -125,21 +153,32 @@ protected function execute(InputInterface $input, OutputInterface $output) ); $io->writeln( - $this->trans('commands.rest.enable.messages.selected-authentication-providers').' '.implode( + $this->trans('commands.rest.enable.messages.selected-authentication-providers') . ' ' . implode( ', ', $authenticationProvidersSelected ) ); - $rest_settings = $this->getRestDrupalConfig(); - - $rest_settings[$resource_id][$state]['supported_formats'] = $formats; - $rest_settings[$resource_id][$state]['supported_auth'] = $authenticationProvidersSelected; - - $config = $this->configFactory->getEditable('rest.settings'); - $config->set('resources', $rest_settings); + $format_resource_id = str_replace(':', '.', $resource_id); + $config = $this->entityManager->getStorage('rest_resource_config')->load($format_resource_id); + if (!$config) { + $config = $this->entityManager->getStorage('rest_resource_config')->create( + [ + 'id' => $format_resource_id, + 'granularity' => RestResourceConfigInterface::METHOD_GRANULARITY, + 'configuration' => [] + ] + ); + } + $configuration = $config->get('configuration') ?: []; + $configuration[$method] = [ + 'supported_formats' => [$format], + 'supported_auth' => $authenticationProvidersSelected, + ]; + $config->set('configuration', $configuration); $config->save(); - - return 0; + $message = sprintf($this->trans('commands.rest.enable.messages.success'), $resource_id); + $io->info($message); + return true; } } diff --git a/src/Command/Router/RebuildCommand.php b/src/Command/Router/RebuildCommand.php index eaf788b30..7c5bc5bb8 100644 --- a/src/Command/Router/RebuildCommand.php +++ b/src/Command/Router/RebuildCommand.php @@ -9,15 +9,12 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Routing\RouteBuilderInterface; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; class RebuildCommand extends Command { - use CommandTrait; - /** * @var RouteBuilderInterface */ @@ -25,6 +22,7 @@ class RebuildCommand extends Command /** * RebuildCommand constructor. + * * @param RouteBuilderInterface $routerBuilder */ public function __construct(RouteBuilderInterface $routerBuilder) @@ -37,7 +35,8 @@ protected function configure() { $this ->setName('router:rebuild') - ->setDescription($this->trans('commands.router.rebuild.description')); + ->setDescription($this->trans('commands.router.rebuild.description')) + ->setAliases(['rr']); } protected function execute(InputInterface $input, OutputInterface $output) diff --git a/src/Command/ServerCommand.php b/src/Command/ServerCommand.php index c721b3428..16e1c7fcc 100644 --- a/src/Command/ServerCommand.php +++ b/src/Command/ServerCommand.php @@ -12,24 +12,30 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Process\ProcessBuilder; use Symfony\Component\Process\PhpExecutableFinder; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; +use \Drupal\Console\Core\Utils\ConfigurationManager; /** * Class ServerCommand + * * @package Drupal\Console\Command */ class ServerCommand extends Command { - use CommandTrait; - + /** + * @var string + */ protected $appRoot; + /** + * @var ConfigurationManager + */ protected $configurationManager; /** * ServerCommand constructor. + * * @param $appRoot * @param $configurationManager */ @@ -63,27 +69,19 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); - $learning = $input->hasOption('learning')?$input->getOption('learning'):false; $address = $this->validatePort($input->getArgument('address')); $finder = new PhpExecutableFinder(); if (false === $binary = $finder->find()) { $io->error($this->trans('commands.server.errors.binary')); - return; + return 1; } $router = $this->getRouterPath(); - $cli = sprintf( - '%s %s %s %s', - $binary, - '-S', - $address, - $router - ); - - if ($learning) { - $io->commentBlock($cli); - } + $processBuilder = new ProcessBuilder([$binary, '-S', $address, $router]); + $processBuilder->setTimeout(null); + $processBuilder->setWorkingDirectory($this->appRoot); + $process = $processBuilder->getProcess(); $io->success( sprintf( @@ -92,19 +90,22 @@ protected function execute(InputInterface $input, OutputInterface $output) ) ); - $processBuilder = new ProcessBuilder(explode(' ', $cli)); - $process = $processBuilder->getProcess(); - $process->setWorkingDirectory($this->appRoot); - if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) { - $process->setTty('true'); - } else { - $process->setTimeout(null); - } - $process->run(); + $io->commentBlock( + sprintf( + $this->trans('commands.server.messages.listening'), + 'http://'.$address + ) + ); + + // Use the process helper to copy process output to console output. + $this->getHelper('process')->run($output, $process, null, null); if (!$process->isSuccessful()) { $io->error($process->getErrorOutput()); + return 1; } + + return 0; } /** @@ -112,22 +113,26 @@ protected function execute(InputInterface $input, OutputInterface $output) */ private function getRouterPath() { - $router = sprintf( - '%s/.console/router.php', - $this->configurationManager->getHomeDirectory() - ); - - if (file_exists($router)) { - return $router; - } - - $router = sprintf( - '%s/config/dist/router.php', - $this->configurationManager->getApplicationDirectory() - ); + $routerPath = [ + sprintf( + '%s/.console/router.php', + $this->configurationManager->getHomeDirectory() + ), + sprintf( + '%s/console/router.php', + $this->configurationManager->getApplicationDirectory() + ), + sprintf( + '%s/%s/config/dist/router.php', + $this->configurationManager->getApplicationDirectory(), + DRUPAL_CONSOLE_CORE + ) + ]; - if (file_exists($router)) { - return $router; + foreach ($routerPath as $router) { + if (file_exists($router)) { + return $router; + } } return null; diff --git a/src/Command/Shared/ChainFilesTrait.php b/src/Command/Shared/ChainFilesTrait.php deleted file mode 100644 index 254223234..000000000 --- a/src/Command/Shared/ChainFilesTrait.php +++ /dev/null @@ -1,112 +0,0 @@ -configurationManager->getHomeDirectory() . DIRECTORY_SEPARATOR . '.console'. DIRECTORY_SEPARATOR .'chain', - $this->appRoot . DIRECTORY_SEPARATOR . 'console'. DIRECTORY_SEPARATOR .'chain', - $this->appRoot . DIRECTORY_SEPARATOR . '.console'. DIRECTORY_SEPARATOR .'chain', - ]; - - $modules = $this->extensionManager->discoverModules() - ->showInstalled() - ->showNoCore() - ->getList(true); - - $themes = $this->extensionManager->discoverThemes() - ->showInstalled() - ->getList(true); - - foreach ($modules as $module) { - $modulePath = sprintf( - '%s/%s/console/chain/', - $this->appRoot, - $module - ); - - if (is_dir($modulePath)) { - $directories[] = $modulePath; - } - } - foreach ($themes as $theme) { - $themePath = sprintf( - '%s/%s/console/chain', - $this->appRoot, - $theme - ); - if (is_dir($themePath)) { - $directories[] = $themePath; - } - } - - $chainFiles = []; - foreach ($directories as $directory) { - if (!is_dir($directory)) { - continue; - } - $finder = new Finder(); - $finder->files() - ->name('*.yml') - ->in($directory); - foreach ($finder as $file) { - $chainFiles[$file->getPath()][] = sprintf( - '%s/%s', - $directory, - $file->getBasename() - ); - } - } - - if ($onlyFiles) { - $files = []; - foreach ($chainFiles as $chainDirectory => $chainFileList) { - $files = array_merge($files, $chainFileList); - } - return $files; - } - - return $chainFiles; - } - - private function extractPlaceHolders($chainContent, $identifier) - { - $placeHolders = []; - $regex = '/\\'.$identifier.'{{(.*?)}}/'; - preg_match_all( - $regex, - $chainContent, - $placeHolders - ); - - if (!$placeHolders) { - return []; - } - - return array_unique($placeHolders[1]); - } - - private function extractInlinePlaceHolders($chainContent) - { - return $this->extractPlaceHolders($chainContent, '%'); - } - - private function extractEnvironmentPlaceHolders($chainContent) - { - return $this->extractPlaceHolders($chainContent, '$'); - } -} diff --git a/src/Command/Shared/ConfirmationTrait.php b/src/Command/Shared/ConfirmationTrait.php index 1f213a3a2..aaf1800e6 100644 --- a/src/Command/Shared/ConfirmationTrait.php +++ b/src/Command/Shared/ConfirmationTrait.php @@ -7,10 +7,11 @@ namespace Drupal\Console\Command\Shared; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class ConfirmationTrait + * * @package Drupal\Console\Command */ trait ConfirmationTrait diff --git a/src/Command/Shared/ConnectTrait.php b/src/Command/Shared/ConnectTrait.php index 4e57573fd..61d38b7fd 100644 --- a/src/Command/Shared/ConnectTrait.php +++ b/src/Command/Shared/ConnectTrait.php @@ -7,12 +7,12 @@ namespace Drupal\Console\Command\Shared; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Core\Database\Database; trait ConnectTrait { - protected $supportedDrivers = array('mysql','pgsql'); + protected $supportedDrivers = ['mysql','pgsql']; public function resolveConnection(DrupalStyle $io, $database = 'default') { diff --git a/src/Command/Shared/CreateTrait.php b/src/Command/Shared/CreateTrait.php index 758849dfe..4790177f6 100644 --- a/src/Command/Shared/CreateTrait.php +++ b/src/Command/Shared/CreateTrait.php @@ -9,6 +9,7 @@ /** * Class CreateTrait + * * @package Drupal\Console\Command */ trait CreateTrait diff --git a/src/Command/Shared/DatabaseTrait.php b/src/Command/Shared/DatabaseTrait.php index ebc5ef79d..85ac6456c 100644 --- a/src/Command/Shared/DatabaseTrait.php +++ b/src/Command/Shared/DatabaseTrait.php @@ -8,10 +8,11 @@ namespace Drupal\Console\Command\Shared; use Symfony\Component\Console\Input\InputInterface; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class DatabaseTrait + * * @package Drupal\Console\Command\Shared */ trait DatabaseTrait diff --git a/src/Command/Shared/EventsTrait.php b/src/Command/Shared/EventsTrait.php index 14322866a..83cb54b4a 100644 --- a/src/Command/Shared/EventsTrait.php +++ b/src/Command/Shared/EventsTrait.php @@ -7,10 +7,11 @@ namespace Drupal\Console\Command\Shared; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class EventsTrait + * * @package Drupal\Console\Command */ trait EventsTrait diff --git a/src/Command/Shared/ExportTrait.php b/src/Command/Shared/ExportTrait.php index a6bb18644..8c68f650e 100644 --- a/src/Command/Shared/ExportTrait.php +++ b/src/Command/Shared/ExportTrait.php @@ -7,12 +7,12 @@ namespace Drupal\Console\Command\Shared; -use Symfony\Component\Yaml\Dumper; -use \Symfony\Component\Yaml\Yaml; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Component\Serialization\Yaml; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class ConfigExportTrait + * * @package Drupal\Console\Command */ trait ExportTrait @@ -22,30 +22,34 @@ trait ExportTrait * @param bool|false $uuid * @return mixed */ - protected function getConfiguration($configName, $uuid = false) + protected function getConfiguration($configName, $uuid = false, $hash = false) { $config = $this->configStorage->read($configName); // Exclude uuid base in parameter, useful to share configurations. - if (!$uuid) { + if ($uuid) { unset($config['uuid']); } + // Exclude default_config_hash inside _core is site-specific. + if ($hash) { + unset($config['_core']['default_config_hash']); + } + return $config; } /** - * @param string $module + * @param string $directory * @param DrupalStyle $io */ protected function exportConfig($directory, DrupalStyle $io, $message) { - $dumper = new Dumper(); - + $directory = realpath($directory); $io->info($message); foreach ($this->configExport as $fileName => $config) { - $yamlConfig = $dumper->dump($config['data'], 10); + $yamlConfig = Yaml::encode($config['data']); $configFile = sprintf( '%s/%s.yml', @@ -53,7 +57,7 @@ protected function exportConfig($directory, DrupalStyle $io, $message) $fileName ); - $io->info('- ' . $configFile); + $io->writeln('- ' . $configFile); // Create directory if doesn't exist if (!file_exists($directory)) { @@ -73,14 +77,12 @@ protected function exportConfig($directory, DrupalStyle $io, $message) */ protected function exportConfigToModule($module, DrupalStyle $io, $message) { - $dumper = new Dumper(); - $io->info($message); $module = $this->extensionManager->getModule($module); foreach ($this->configExport as $fileName => $config) { - $yamlConfig = $dumper->dump($config['data'], 10); + $yamlConfig = Yaml::encode($config['data']); if ($config['optional']) { $configDirectory = $module->getConfigOptionalDirectory(false); @@ -121,7 +123,7 @@ protected function resolveDependencies($dependencies, $optional = false) { foreach ($dependencies as $dependency) { if (!array_key_exists($dependency, $this->configExport)) { - $this->configExport[$dependency] = array('data' => $this->getConfiguration($dependency), 'optional' => $optional); + $this->configExport[$dependency] = ['data' => $this->getConfiguration($dependency), 'optional' => $optional]; if ($dependencies = $this->fetchDependencies($this->configExport[$dependency], 'config')) { $this->resolveDependencies($dependencies, $optional); } @@ -131,8 +133,6 @@ protected function resolveDependencies($dependencies, $optional = false) protected function exportModuleDependencies($io, $module, $dependencies) { - $yaml = new Yaml(); - $module = $this->extensionManager->getModule($module); $info_yaml = $module->info; @@ -142,7 +142,7 @@ protected function exportModuleDependencies($io, $module, $dependencies) $info_yaml['dependencies'] = array_unique(array_merge($info_yaml['dependencies'], $dependencies)); } - if (file_put_contents($module->getPathname(), $yaml->dump($info_yaml))) { + if (file_put_contents($module->getPathname(), Yaml::encode($info_yaml))) { $io->info( '[+] ' . sprintf( diff --git a/src/Command/Shared/ExtensionTrait.php b/src/Command/Shared/ExtensionTrait.php new file mode 100644 index 000000000..2afec4963 --- /dev/null +++ b/src/Command/Shared/ExtensionTrait.php @@ -0,0 +1,94 @@ +extensionManager->discoverModules() + ->showInstalled() + ->showUninstalled() + ->showNoCore() + ->getList(false); + } + + if ($theme) { + $themes = $this->extensionManager->discoverThemes() + ->showInstalled() + ->showUninstalled() + ->showNoCore() + ->getList(false); + } + + if ($profile) { + $profiles = $this->extensionManager->discoverProfiles() + ->showInstalled() + ->showUninstalled() + ->showNoCore() + ->showCore() + ->getList(false); + } + + $extensions = array_merge( + $modules, + $themes, + $profiles + ); + + if (empty($extensions)) { + throw new \Exception('No extension available, execute the proper generator command to generate one.'); + } + + $extension = $io->choiceNoList( + $this->trans('commands.common.questions.extension'), + array_keys($extensions) + ); + + return $extensions[$extension]; + } + + /** + * @param DrupalStyle $io + * + * @return string + * + * @throws \Exception + */ + public function extensionTypeQuestion(DrupalStyle $io) + { + $extensionType = $io->choiceNoList( + $this->trans('commands.common.questions.extension-type'), + array_keys(['module', 'theme', 'profile']) + ); + + return $extensionType; + } +} diff --git a/src/Command/Shared/FeatureTrait.php b/src/Command/Shared/FeatureTrait.php new file mode 100644 index 000000000..32ab9a8e2 --- /dev/null +++ b/src/Command/Shared/FeatureTrait.php @@ -0,0 +1,217 @@ +getPackagesByBundle($bundle); + + if (empty($packages)) { + throw new \Exception( + $this->trans('commands.features.message.no-packages') + ); + } + + $package = $io->choiceNoList( + $this->trans('commands.features.import.questions.packages'), + $packages + ); + + return $package; + } + + + /** + * @param bool $bundle_name + * + * @return \Drupal\features\FeaturesAssignerInterface + */ + protected function getAssigner($bundle_name) + { + /** + * @var \Drupal\features\FeaturesAssignerInterface $assigner + */ + $assigner = \Drupal::service('features_assigner'); + if (!empty($bundle_name)) { + $bundle = $assigner->applyBundle($bundle_name); + + if ($bundle->getMachineName() != $bundle_name) { + } + } + // return configuration for default bundle + else { + $assigner->assignConfigPackages(); + } + return $assigner; + } + + /** + * Get a list of features. + * + * @param bundle + * + * @return array + */ + protected function getFeatureList($bundle) + { + $features = []; + $manager = $this->getFeatureManager(); + $modules = $this->getPackagesByBundle($bundle); + + foreach ($modules as $module_name) { + $feature = $manager->loadPackage($module_name, true); + $overrides = $manager->detectOverrides($feature); + + $state = $feature->getState(); + + if (!empty($overrides) && ($feature->getStatus() != FeaturesManagerInterface::STATUS_NO_EXPORT)) { + $state = FeaturesManagerInterface::STATE_OVERRIDDEN; + } + + if ($feature->getStatus() != FeaturesManagerInterface::STATUS_NO_EXPORT) { + $features[$feature->getMachineName()] = [ + 'name' => $feature->getName(), + 'machine_name' => $feature->getMachineName(), + 'bundle_name' => $feature->getBundle(), + 'status' => $manager->statusLabel($feature->getStatus()), + 'state' => ($state != FeaturesManagerInterface::STATE_DEFAULT) ? $manager->stateLabel($state) : '', + ]; + } + } + + return $features; + } + + + protected function importFeature(DrupalStyle $io, $packages) + { + $manager = $this->getFeatureManager(); + + $modules = (is_array($packages)) ? $packages : [$packages]; + $overridden = [] ; + foreach ($modules as $module_name) { + $package = $manager->loadPackage($module_name, true); + + if (empty($package)) { + $io->warning( + sprintf( + $this->trans('commands.features.import.messages.not-available'), + $module_name + ) + ); + continue; + } + + if ($package->getStatus() != FeaturesManagerInterface::STATUS_INSTALLED) { + $io->warning( + sprintf( + $this->trans('commands.features.import.messages.uninstall'), + $module_name + ) + ); + continue; + } + + $overrides = $manager->detectOverrides($package); + $missing = $manager->reorderMissing($manager->detectMissing($package)); + + if (!empty($overrides) || !empty($missing) && ($package->getStatus() == FeaturesManagerInterface::STATUS_INSTALLED)) { + $overridden[] = array_merge($missing, $overrides); + } + } + + // Process only missing or overridden features + $components = $overridden; + + if (empty($components)) { + $io->warning( + sprintf( + $this->trans('commands.features.import.messages.nothing') + ) + ); + + return ; + } else { + $this->import($io, $components); + } + } + + public function import($io, $components) + { + $manager = $this->getFeatureManager(); + /** + * @var \Drupal\config_update\ConfigRevertInterface $config_revert + */ + $config_revert = \Drupal::service('features.config_update'); + + $config = $manager->getConfigCollection(); + + foreach ($components as $component) { + foreach ($component as $feature) { + if (!isset($config[$feature])) { + //Import missing component. + $item = $manager->getConfigType($feature); + $type = ConfigurationItem::fromConfigStringToConfigType($item['type']); + $config_revert->import($type, $item['name_short']); + $io->info( + sprintf( + $this->trans('commands.features.import.messages.importing'), + $feature + ) + ); + } else { + // Revert existing component. + $item = $config[$feature]; + $type = ConfigurationItem::fromConfigStringToConfigType($item->getType()); + $config_revert->revert($type, $item->getShortName()); + $io->info( + sprintf( + $this->trans('commands.features.import.messages.reverting'), + $feature + ) + ); + } + } + } + } + + + public function getPackagesByBundle($bundle) + { + $manager = $this->getFeatureManager(); + $assigner = $this->getAssigner($bundle); + $current_bundle = $assigner->getBundle(); + + // List all packages availables + if ($current_bundle->getMachineName() == 'default') { + $current_bundle = null; + } + + $packages = array_keys($manager->getFeaturesModules($current_bundle)); + + return $packages; + } + + public function getFeatureManager() + { + return \Drupal::service('features.manager'); + } +} diff --git a/src/Command/Shared/FormTrait.php b/src/Command/Shared/FormTrait.php index f4030b297..8a72e0264 100644 --- a/src/Command/Shared/FormTrait.php +++ b/src/Command/Shared/FormTrait.php @@ -7,10 +7,11 @@ namespace Drupal\Console\Command\Shared; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class FormTrait + * * @package Drupal\Console\Command */ trait FormTrait @@ -25,7 +26,8 @@ public function formQuestion(DrupalStyle $io) if ($io->confirm( $this->trans('commands.common.questions.inputs.confirm'), true - )) { + ) + ) { $input_types = [ 'fieldset', 'text_format' @@ -67,7 +69,7 @@ public function formQuestion(DrupalStyle $io) $input_machine_name = $this->stringConverter->createMachineName($input_label); $input_name = $io->ask( - $this->trans('commands.common.questions.inputs.machine_name'), + $this->trans('commands.common.questions.inputs.machine-name'), $input_machine_name ); @@ -89,29 +91,29 @@ public function formQuestion(DrupalStyle $io) $maxlength = null; $size = null; - if (in_array($input_type, array('textfield', 'password', 'password_confirm'))) { + if (in_array($input_type, ['textfield', 'password', 'password_confirm'])) { $maxlength = $io->ask( - 'Maximum amount of characters', + $this->trans('commands.generate.form.questions.max-amount-characters'), '64' ); $size = $io->ask( - 'Width of the textfield (in characters)', + $this->trans('commands.generate.form.questions.textfield-width-in-chars'), '64' ); } if ($input_type == 'select') { $size = $io->ask( - 'Size of multiselect box (in lines)', + $this->trans('commands.generate.form.questions.multiselect-size-in-lines'), '5' ); } $input_options = ''; - if (in_array($input_type, array('checkboxes', 'radios', 'select'))) { + if (in_array($input_type, ['checkboxes', 'radios', 'select'])) { $input_options = $io->ask( - 'Input options separated by comma' + $this->trans('commands.generate.form.questions.input-options') ); } @@ -124,7 +126,7 @@ public function formQuestion(DrupalStyle $io) $input_options_output[$key] = "'$value' => \$this->t('".$value."')"; } - $input_options = 'array('.implode(', ', $input_options_output).')'; + $input_options = '['.implode(', ', $input_options_output).']'; } // Description for input diff --git a/src/Command/Shared/InputTrait.php b/src/Command/Shared/InputTrait.php deleted file mode 100644 index 82c716cd0..000000000 --- a/src/Command/Shared/InputTrait.php +++ /dev/null @@ -1,35 +0,0 @@ - $value) { - if (!is_array($value)) { - $inputValueItems = []; - foreach (explode(" ", $value) as $inputKeyValueItem) { - list($inputKeyItem, $inputValueItem) = explode(":", $inputKeyValueItem); - $inputValueItems[$inputKeyItem] = $inputValueItem; - } - $inputArrayValue[$key] = $inputValueItems; - } - } - - return $inputArrayValue?$inputArrayValue:$inputValue; - } -} diff --git a/src/Command/Shared/MenuTrait.php b/src/Command/Shared/MenuTrait.php index 5a3d54540..5d8bc55a4 100644 --- a/src/Command/Shared/MenuTrait.php +++ b/src/Command/Shared/MenuTrait.php @@ -7,34 +7,36 @@ namespace Drupal\Console\Command\Shared; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Symfony\Component\Yaml\Parser; /** * Class MenuTrait + * * @package Drupal\Console\Command */ trait MenuTrait { /** - * @param \Drupal\Console\Style\DrupalStyle $io - * @param string $className The form class name + * @param \Drupal\Console\Core\Style\DrupalStyle $io + * @param string $className The form class name * @return string * @throws \Exception */ public function menuQuestion(DrupalStyle $io, $className) { if ($io->confirm( - $this->trans('commands.generate.form.questions.menu_link_gen'), + $this->trans('commands.generate.form.options.menu-link-gen'), true - )) { + ) + ) { // now we need to ask them where to gen the form // get the route $menu_options = [ 'menu_link_gen' => true, ]; $menu_link_title = $io->ask( - $menu_link_title = $this->trans('commands.generate.form.questions.menu_link_title'), + $menu_link_title = $this->trans('commands.generate.form.options.menu-link-title'), $className ); $menuLinkFile = sprintf( @@ -47,14 +49,14 @@ public function menuQuestion(DrupalStyle $io, $className) $menu_parent = $io->choiceNoList( - $menu_parent = $this->trans('commands.generate.form.questions.menu_parent'), + $menu_parent = $this->trans('commands.generate.form.options.menu-parent'), array_keys($menuLinkContent), 'system.admin_config_system' ); $menu_link_desc = $io->ask( - $menu_link_desc = $this->trans('commands.generate.form.questions.menu_link_desc'), - 'A description for the menu entry' + $menu_link_desc = $this->trans('commands.generate.form.options.menu-link-desc'), + $menu_link_desc = $this->trans('commands.generate.form.suggestions.description-for-menu') ); $menu_options['menu_link_title'] = $menu_link_title; $menu_options['menu_parent'] = $menu_parent; diff --git a/src/Command/Shared/MigrationTrait.php b/src/Command/Shared/MigrationTrait.php index 82077c27d..202b5e52a 100644 --- a/src/Command/Shared/MigrationTrait.php +++ b/src/Command/Shared/MigrationTrait.php @@ -9,11 +9,12 @@ use Drupal\Core\Database\Connection; use Drupal\Core\Database\Database; -use Drupal\Console\Style\DrupalStyle; -use Symfony\Component\Console\Input\ArgvInput; +use Drupal\Console\Core\Style\DrupalStyle; +use Symfony\Component\Console\Input\InputInterface; /** * Class MigrationTrait + * * @package Drupal\Console\Command */ trait MigrationTrait @@ -29,9 +30,11 @@ trait MigrationTrait protected function getMigrations($version_tag = false, $flatList = false, $configuration = []) { //Get migration definitions by tag - $migrations = array_filter($this->pluginManagerMigration->getDefinitions(), function($migration) use ($version_tag) { - return !empty($migration['migration_tags']) && in_array($version_tag, $migration['migration_tags']); - }); + $migrations = array_filter( + $this->pluginManagerMigration->getDefinitions(), function ($migration) use ($version_tag) { + return !empty($migration['migration_tags']) && in_array($version_tag, $migration['migration_tags']); + } + ); // Create an array to configure all migration plugins with same configuration $keys = array_keys($migrations); @@ -40,7 +43,7 @@ protected function getMigrations($version_tag = false, $flatList = false, $confi //Create all migration instances $all_migrations = $this->pluginManagerMigration->createInstances(array_keys($migrations), $migration_plugin_configuration); - $migrations = array(); + $migrations = []; foreach ($all_migrations as $migration) { if ($flatList) { $migrations[$migration->id()] = ucwords($migration->label()); @@ -148,7 +151,7 @@ protected function getDBInfo() } /** - * @param \Drupal\Console\Style\DrupalStyle $io + * @param \Drupal\Console\Core\Style\DrupalStyle $io * @param $target * @param $key */ @@ -173,7 +176,7 @@ protected function getDBConnection(DrupalStyle $io, $target, $key) * @param InputInterface $input * @param DrupalStyle $io */ - protected function registerMigrateDB(ArgvInput $input, DrupalStyle $io) + protected function registerMigrateDB(InputInterface $input, DrupalStyle $io) { $dbType = $input->getOption('db-type'); $dbHost = $input->getOption('db-host'); diff --git a/src/Command/Shared/ModuleTrait.php b/src/Command/Shared/ModuleTrait.php index e16700a3d..88b52c1ab 100644 --- a/src/Command/Shared/ModuleTrait.php +++ b/src/Command/Shared/ModuleTrait.php @@ -1,25 +1,28 @@ choiceNoList( @@ -52,16 +55,35 @@ public function moduleQuestion(DrupalStyle $io, $showProfile = true) return $module; } - public function moduleRequirement($module) + /** + * Verify that install requirements for a list of modules are met. + * + * @param string[] $module + * List of modules to verify. + * @param DrupalStyle $io + * Console interface. + * + * @throws \Exception + * When one or more requirements are not met. + */ + public function moduleRequirement(array $module, DrupalStyle $io) { + // TODO: Module dependencies should also be checked + // for unmet requirements recursively. + $fail = false; foreach ($module as $module_name) { module_load_install($module_name); - - if ($requirements = \Drupal::moduleHandler()->invoke($module_name, 'requirements', array('install'))) { + if ($requirements = \Drupal::moduleHandler()->invoke($module_name, 'requirements', ['install'])) { foreach ($requirements as $requirement) { - throw new \Exception($module_name .' can not be installed: ' . $requirement['description']); + if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) { + $io->info("Module '{$module_name}' cannot be installed: " . $requirement['title'] . ' | ' . $requirement['value']); + $fail = true; + } } } } + if ($fail) { + throw new \Exception("Some module install requirements are not met."); + } } } diff --git a/src/Command/Shared/PermissionTrait.php b/src/Command/Shared/PermissionTrait.php index 59075ed72..de2047730 100644 --- a/src/Command/Shared/PermissionTrait.php +++ b/src/Command/Shared/PermissionTrait.php @@ -7,7 +7,7 @@ namespace Drupal\Console\Command\Shared; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; trait PermissionTrait { @@ -22,19 +22,19 @@ public function permissionQuestion(DrupalStyle $output) $boolOrNone = ['true','false','none']; while (true) { $permission = $output->ask( - $this->trans('commands.generate.permission.questions.permission'), - 'access content' + $this->trans('commands.generate.permissions.questions.permission'), + $this->trans('commands.generate.permissions.suggestions.access-content') ); $title = $output->ask( - $this->trans('commands.generate.permission.questions.title'), - 'Access content' + $this->trans('commands.generate.permissions.questions.title'), + $this->trans('commands.generate.permissions.suggestions.access-content') ); $description = $output->ask( - $this->trans('commands.generate.permission.questions.description'), - 'Allow access to my content' + $this->trans('commands.generate.permissions.questions.description'), + $this->trans('commands.generate.permissions.suggestions.allow-access-content') ); $restrictAccess = $output->choiceNoList( - $this->trans('commands.generate.permission.questions.restrict-access'), + $this->trans('commands.generate.permissions.questions.restrict-access'), $boolOrNone, 'none' ); @@ -53,9 +53,10 @@ public function permissionQuestion(DrupalStyle $output) ); if (!$output->confirm( - $this->trans('commands.generate.permission.questions.add'), + $this->trans('commands.generate.permissions.questions.add'), true - )) { + ) + ) { break; } } diff --git a/src/Command/Shared/ProjectDownloadTrait.php b/src/Command/Shared/ProjectDownloadTrait.php index ee3b28b9b..d2c70c661 100644 --- a/src/Command/Shared/ProjectDownloadTrait.php +++ b/src/Command/Shared/ProjectDownloadTrait.php @@ -7,7 +7,7 @@ namespace Drupal\Console\Command\Shared; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Zippy\Adapter\TarGzGNUTarForWindowsAdapter; use Drupal\Console\Zippy\FileStrategy\TarGzFileForWindowsStrategy; use Alchemy\Zippy\Zippy; @@ -16,6 +16,7 @@ /** * Class ProjectDownloadTrait + * * @package Drupal\Console\Command */ trait ProjectDownloadTrait @@ -153,7 +154,7 @@ protected function calculateDependencies($modules) } /** - * @param \Drupal\Console\Style\DrupalStyle $io + * @param \Drupal\Console\Core\Style\DrupalStyle $io * @param $project * @param $version * @param $type @@ -253,10 +254,10 @@ public function downloadProject(DrupalStyle $io, $project, $version, $type, $pat } /** - * @param \Drupal\Console\Style\DrupalStyle $io - * @param string $project - * @param bool $latest - * @param bool $stable + * @param \Drupal\Console\Core\Style\DrupalStyle $io + * @param string $project + * @param bool $latest + * @param bool $stable * @return string */ public function releasesQuestion(DrupalStyle $io, $project, $latest = false, $stable = false) @@ -266,7 +267,7 @@ public function releasesQuestion(DrupalStyle $io, $project, $latest = false, $st $io->comment( sprintf( $this->trans('commands.'.$commandKey.'.messages.getting-releases'), - implode(',', array($project)) + implode(',', [$project]) ) ); @@ -276,7 +277,7 @@ public function releasesQuestion(DrupalStyle $io, $project, $latest = false, $st $io->error( sprintf( $this->trans('commands.'.$commandKey.'.messages.no-releases'), - implode(',', array($project)) + implode(',', [$project]) ) ); diff --git a/src/Command/Shared/RestTrait.php b/src/Command/Shared/RestTrait.php index af7bd630c..0c5c3c70b 100644 --- a/src/Command/Shared/RestTrait.php +++ b/src/Command/Shared/RestTrait.php @@ -42,7 +42,7 @@ public function getRestResources($rest_status = false) } if (isset($available_resources[$rest_status])) { - return array($rest_status => $available_resources[$rest_status]); + return [$rest_status => $available_resources[$rest_status]]; } return $available_resources; diff --git a/src/Command/Shared/ServicesTrait.php b/src/Command/Shared/ServicesTrait.php index 17fb145f5..7f1b11888 100644 --- a/src/Command/Shared/ServicesTrait.php +++ b/src/Command/Shared/ServicesTrait.php @@ -7,7 +7,7 @@ namespace Drupal\Console\Command\Shared; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; trait ServicesTrait { @@ -21,7 +21,8 @@ public function servicesQuestion(DrupalStyle $io) if ($io->confirm( $this->trans('commands.common.questions.services.confirm'), false - )) { + ) + ) { $service_collection = []; $io->writeln($this->trans('commands.common.questions.services.message')); $services = $this->container->getServiceIds(); diff --git a/src/Command/Shared/ThemeBreakpointTrait.php b/src/Command/Shared/ThemeBreakpointTrait.php index 55e903b12..10759e4eb 100644 --- a/src/Command/Shared/ThemeBreakpointTrait.php +++ b/src/Command/Shared/ThemeBreakpointTrait.php @@ -7,7 +7,7 @@ namespace Drupal\Console\Command\Shared; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; trait ThemeBreakpointTrait { @@ -69,7 +69,8 @@ function ($breakPointLabel) use ($validators) { if (!$io->confirm( $this->trans('commands.generate.theme.questions.breakpoint-add'), true - )) { + ) + ) { break; } } diff --git a/src/Command/Shared/ThemeRegionTrait.php b/src/Command/Shared/ThemeRegionTrait.php index 5edaf8d90..c4bb8ac97 100644 --- a/src/Command/Shared/ThemeRegionTrait.php +++ b/src/Command/Shared/ThemeRegionTrait.php @@ -7,7 +7,7 @@ namespace Drupal\Console\Command\Shared; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; trait ThemeRegionTrait { @@ -46,11 +46,51 @@ function ($regionMachineName) use ($validators) { if (!$io->confirm( $this->trans('commands.generate.theme.questions.region-add'), true - )) { + ) + ) { break; } } return $regions; } + + /** + * @param DrupalStyle $io + * + * @return mixed + */ + public function libraryQuestion(DrupalStyle $io) + { + $validators = $this->validator; + $libraries = []; + while (true) { + $libraryName = $io->ask( + $this->trans('commands.generate.theme.questions.library-name') + ); + + $libraryVersion = $io->ask( + $this->trans('commands.generate.theme.questions.library-version'), + '1.0' + ); + + array_push( + $libraries, + [ + 'library_name' => $libraryName, + 'library_version'=> $libraryVersion, + ] + ); + + if (!$io->confirm( + $this->trans('commands.generate.theme.questions.library-add'), + true + ) + ) { + break; + } + } + + return $libraries; + } } diff --git a/src/Command/Shared/TranslationTrait.php b/src/Command/Shared/TranslationTrait.php index 39890fcbc..8648cf9d3 100644 --- a/src/Command/Shared/TranslationTrait.php +++ b/src/Command/Shared/TranslationTrait.php @@ -7,7 +7,7 @@ namespace Drupal\Console\Command\Shared; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; trait TranslationTrait { diff --git a/src/Command/ShellCommand.php b/src/Command/ShellCommand.php new file mode 100644 index 000000000..7db66821f --- /dev/null +++ b/src/Command/ShellCommand.php @@ -0,0 +1,38 @@ +setName('shell') + ->setDescription($this->trans('commands.shell.description')) + ->setHelp($this->trans('commands.shell.help')); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $config = new Configuration; + $shell = new Shell($config); + $shell->run(); + } +} diff --git a/src/Command/Site/DebugCommand.php b/src/Command/Site/DebugCommand.php deleted file mode 100644 index ef687bb17..000000000 --- a/src/Command/Site/DebugCommand.php +++ /dev/null @@ -1,154 +0,0 @@ -site = $site; - $this->configurationManager = $configurationManager; - parent::__construct(); - } - - /** - * @{@inheritdoc} - */ - public function configure() - { - $this - ->setName('site:debug') - ->setDescription($this->trans('commands.site.debug.description')) - ->addArgument( - 'target', - InputArgument::OPTIONAL, - $this->trans('commands.site.debug.options.target'), - null - ) - ->setHelp($this->trans('commands.site.debug.help')); - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $sitesDirectory = $this->configurationManager->getSitesDirectory(); - - if (!is_dir($sitesDirectory)) { - $io->error( - sprintf( - $this->trans('commands.site.debug.messages.directory-not-found'), - $sitesDirectory - ) - ); - - return 1; - } - - // --target argument - $target = $input->getArgument('target'); - if ($target) { - $io->write( - $this->siteDetail($target) - ); - - return 0; - } - - $tableHeader =[ - $this->trans('commands.site.debug.messages.site'), - $this->trans('commands.site.debug.messages.host'), - $this->trans('commands.site.debug.messages.root') - ]; - - $tableRows = $this->siteList($sitesDirectory); - - $io->table($tableHeader, $tableRows); - return 0; - } - - /** - * @param string $target - * - * @return string - */ - private function siteDetail($target) - { - if ($targetConfig = $this->configurationManager->readTarget($target)) { - $dumper = new Dumper(); - - return $dumper->dump($targetConfig, 2); - } - } - - /** - * @param DrupalStyle $io - * @param string $sitesDirectory - * @return array - */ - private function siteList($sitesDirectory) - { - $finder = new Finder(); - $finder->in($sitesDirectory); - $finder->name("*.yml"); - - $tableRows = []; - foreach ($finder as $site) { - $siteName = $site->getBasename('.yml'); - $environments = $this->configurationManager - ->readSite($site->getRealPath()); - - foreach ($environments as $env => $config) { - $tableRows[] = [ - $siteName . '.' . $env, - array_key_exists('host', $config) ? $config['host'] : 'local', - array_key_exists('root', $config) ? $config['root'] : '' - ]; - } - } - - return $tableRows; - } -} diff --git a/src/Command/Site/ImportLocalCommand.php b/src/Command/Site/ImportLocalCommand.php index 5f6c0ddb3..ef2750f2b 100644 --- a/src/Command/Site/ImportLocalCommand.php +++ b/src/Command/Site/ImportLocalCommand.php @@ -11,21 +11,19 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; -use Drupal\Console\Utils\ConfigurationManager; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; +use Drupal\Console\Core\Utils\ConfigurationManager; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Yaml\Yaml; /** * Class ImportLocalCommand + * * @package Drupal\Console\Command\Site */ class ImportLocalCommand extends Command { - use CommandTrait; - /** * @var string */ @@ -38,6 +36,7 @@ class ImportLocalCommand extends Command /** * ImportLocalCommand constructor. + * * @param $appRoot * @param ConfigurationManager $configurationManager */ @@ -74,7 +73,8 @@ protected function configure() InputOption::VALUE_OPTIONAL, $this->trans('commands.site.import.local.options.environment') ) - ->setHelp($this->trans('commands.site.import.local.help')); + ->setHelp($this->trans('commands.site.import.local.help')) + ->setAliases(['sil']); ; } diff --git a/src/Command/Site/InstallCommand.php b/src/Command/Site/InstallCommand.php index 86ab3d992..1e8a888e6 100644 --- a/src/Command/Site/InstallCommand.php +++ b/src/Command/Site/InstallCommand.php @@ -7,24 +7,25 @@ namespace Drupal\Console\Command\Site; +use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Config\Definition\Exception\Exception; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\ContainerAwareCommand; use Drupal\Core\Database\Database; use Drupal\Core\Installer\Exception\AlreadyInstalledException; use Drupal\Console\Command\Shared\DatabaseTrait; -use Drupal\Console\Utils\ConfigurationManager; +use Drupal\Console\Core\Utils\ConfigurationManager; use Drupal\Console\Extension\Manager; +use Drupal\Console\Core\Style\DrupalStyle; +use Drupal\Console\Bootstrap\Drupal; use Drupal\Console\Utils\Site; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Utils\DrupalFinder; -class InstallCommand extends Command +class InstallCommand extends ContainerAwareCommand { - use CommandTrait; use DatabaseTrait; /** @@ -49,6 +50,7 @@ class InstallCommand extends Command /** * InstallCommand constructor. + * * @param Manager $extensionManager * @param Site $site * @param ConfigurationManager $configurationManager @@ -67,98 +69,107 @@ public function __construct( parent::__construct(); } - // protected $connection; - protected function configure() { $this ->setName('site:install') ->setDescription($this->trans('commands.site.install.description')) - ->addArgument('profile', InputArgument::OPTIONAL, $this->trans('commands.site.install.arguments.profile')) + ->addArgument( + 'profile', + InputArgument::OPTIONAL, + $this->trans('commands.site.install.arguments.profile') + ) ->addOption( 'langcode', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.site.install.arguments.langcode') ) ->addOption( 'db-type', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.site.install.arguments.db-type') ) ->addOption( 'db-file', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.site.install.arguments.db-file') ) ->addOption( 'db-host', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.migrate.execute.options.db-host') ) ->addOption( 'db-name', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.migrate.execute.options.db-name') ) ->addOption( 'db-user', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.migrate.execute.options.db-user') ) ->addOption( 'db-pass', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.migrate.execute.options.db-pass') ) ->addOption( 'db-prefix', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.migrate.execute.options.db-prefix') ) ->addOption( 'db-port', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.migrate.execute.options.db-port') ) ->addOption( 'site-name', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.site.install.arguments.site-name') ) ->addOption( 'site-mail', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.site.install.arguments.site-mail') ) ->addOption( 'account-name', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.site.install.arguments.account-name') ) ->addOption( 'account-mail', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.site.install.arguments.account-mail') ) ->addOption( 'account-pass', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.site.install.arguments.account-pass') - ); + ) + ->addOption( + 'force', + null, + InputOption::VALUE_NONE, + $this->trans('commands.site.install.arguments.force') + ) + ->setAliases(['si']); } /** @@ -188,13 +199,13 @@ function ($profile) { $profile = $io->choice( $this->trans('commands.site.install.questions.profile'), - $profiles + array_values($profiles) ); $input->setArgument('profile', $profile); } - // // --langcode option + // --langcode option $langcode = $input->getOption('langcode'); if (!$langcode) { $languages = $this->site->getStandardLanguages(); @@ -214,7 +225,6 @@ function ($profile) { // Use default database setting if is available $database = Database::getConnectionInfo(); if (empty($database['default'])) { - // --db-type option $dbType = $input->getOption('db-type'); if (!$dbType) { @@ -309,7 +319,7 @@ function ($profile) { if (!$siteName) { $siteName = $io->ask( $this->trans('commands.site.install.questions.site-name'), - 'Drupal 8 Site Install' + $this->trans('commands.site.install.suggestions.site-name') ); $input->setOption('site-name', $siteName); } @@ -361,27 +371,48 @@ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); + $uri = parse_url($input->getParameterOption(['--uri', '-l'], 'default'), PHP_URL_HOST); + + if ($this->site->multisiteMode($uri)) { + if (!$this->site->validMultisite($uri)) { + $io->error( + sprintf($this->trans('commands.site.install.messages.invalid-multisite'), $uri, $uri) + ); + exit(1); + } + + // Modify $_SERVER environment information to enable + // the Drupal installer to use the multi-site configuration. + $_SERVER['HTTP_HOST'] = $uri; + } + // Database options - $dbType = $input->getOption('db-type'); + $dbType = $input->getOption('db-type')?:'mysql'; $dbFile = $input->getOption('db-file'); - $dbHost = $input->getOption('db-host'); - $dbName = $input->getOption('db-name'); - $dbUser = $input->getOption('db-user'); + $dbHost = $input->getOption('db-host')?:'127.0.0.1'; + $dbName = $input->getOption('db-name')?:'drupal_'.time(); + $dbUser = $input->getOption('db-user')?:'root'; $dbPass = $input->getOption('db-pass'); $dbPrefix = $input->getOption('db-prefix'); - $dbPort = $input->getOption('db-port'); + $dbPort = $input->getOption('db-port')?:'3306'; + $force = $input->getOption('force'); $databases = $this->site->getDatabaseTypes(); if ($dbType === 'sqlite') { - $database = array( + $database = [ 'database' => $dbFile, 'prefix' => $dbPrefix, 'namespace' => $databases[$dbType]['namespace'], 'driver' => $dbType, - ); + ]; + + if ($force) { + $fs = new Filesystem(); + $fs->remove($dbFile); + } } else { - $database = array( + $database = [ 'database' => $dbName, 'username' => $dbUser, 'password' => $dbPass, @@ -390,19 +421,34 @@ protected function execute(InputInterface $input, OutputInterface $output) 'host' => $dbHost, 'namespace' => $databases[$dbType]['namespace'], 'driver' => $dbType, - ); - } + ]; - $this->backupSitesFile($io); + if ($force && Database::isActiveConnection()) { + $schema = Database::getConnection()->schema(); + $tables = $schema->findTables('%'); + foreach ($tables as $table) { + $schema->dropTable($table); + } + } + } try { - $this->runInstaller($io, $input, $database); + $drupalFinder = new DrupalFinder(); + $drupalFinder->locateRoot(getcwd()); + $this->runInstaller($io, $input, $database, $uri); + + $autoload = $this->container->get('class_loader'); + $drupal = new Drupal($autoload, $drupalFinder); + $container = $drupal->boot(); + $this->getApplication()->setContainer($container); } catch (Exception $e) { - $output->error($e->getMessage()); - return; + $io->error($e->getMessage()); + return 1; } $this->restoreSitesFile($io); + + return 0; } /** @@ -413,46 +459,56 @@ protected function execute(InputInterface $input, OutputInterface $output) * appropriate subdir when run from a script and a sites.php file exists. * * @param DrupalStyle $output + * + * @return boolean */ protected function backupSitesFile(DrupalStyle $output) { if (!file_exists($this->appRoot . '/sites/sites.php')) { - return; + return true; } - rename($this->appRoot . '/sites/sites.php', $this->appRoot . '/sites/backup.sites.php'); + $renamed = rename($this->appRoot . '/sites/sites.php', $this->appRoot . '/sites/backup.sites.php'); $output->info($this->trans('commands.site.install.messages.sites-backup')); + + return $renamed; } /** * Restores backup.sites.php to sites.php (if needed). * * @param DrupalStyle $output + * + * @return boolean */ protected function restoreSitesFile(DrupalStyle $output) { if (!file_exists($this->appRoot . '/sites/backup.sites.php')) { - return; + return true; } - rename($this->appRoot . '/sites/backup.sites.php', $this->appRoot . '/sites/sites.php'); + $renamed = rename($this->appRoot . '/sites/backup.sites.php', $this->appRoot . '/sites/sites.php'); $output->info($this->trans('commands.site.install.messages.sites-restore')); + + return $renamed; } protected function runInstaller( - DrupalStyle $output, + DrupalStyle $io, InputInterface $input, - $database + $database, + $uri ) { $this->site->loadLegacyFile('/core/includes/install.core.inc'); - $driver = (string) $database['driver']; + $driver = (string)$database['driver']; + $settings = [ 'parameters' => [ - 'profile' => $input->getArgument('profile'), - 'langcode' => $input->getOption('langcode'), + 'profile' => $input->getArgument('profile') ?: 'standard', + 'langcode' => $input->getOption('langcode') ?: 'en', ], 'forms' => [ 'install_settings_form' => [ @@ -461,39 +517,50 @@ protected function runInstaller( 'op' => 'Save and continue', ], 'install_configure_form' => [ - 'site_name' => $input->getOption('site-name'), - 'site_mail' => $input->getOption('site-mail'), - 'account' => array( - 'name' => $input->getOption('account-name'), - 'mail' => $input->getOption('account-mail'), - 'pass' => array( - 'pass1' => $input->getOption('account-pass'), - 'pass2' => $input->getOption('account-pass') - ), - ), - 'update_status_module' => array( + 'site_name' => $input->getOption('site-name') ?: 'Drupal 8', + 'site_mail' => $input->getOption('site-mail') ?: 'admin@example.org', + 'account' => [ + 'name' => $input->getOption('account-name') ?: 'admin', + 'mail' => $input->getOption('account-mail') ?: 'admin@example.org', + 'pass' => [ + 'pass1' => $input->getOption('account-pass') ?: 'admin', + 'pass2' => $input->getOption('account-pass') ?: 'admin' + ], + ], + 'update_status_module' => [ 1 => true, 2 => true, - ), - 'clean_url' => true, + ], + 'clean_url' => true, 'op' => 'Save and continue', ], ] ]; - $output->info($this->trans('commands.site.install.messages.installing')); + if (!$this->site->multisiteMode($uri)) { + $this->backupSitesFile($io); + } + + $io->newLine(); + $io->info($this->trans('commands.site.install.messages.installing')); try { $autoload = $this->site->getAutoload(); install_drupal($autoload, $settings); } catch (AlreadyInstalledException $e) { - $output->error($this->trans('commands.site.install.messages.already-installed')); - return; + $io->error($this->trans('commands.site.install.messages.already-installed')); + return 1; } catch (\Exception $e) { - $output->error($e->getMessage()); - return; + $io->error($e->getMessage()); + return 1; + } + + if (!$this->site->multisiteMode($uri)) { + $this->restoreSitesFile($io); } - $output->success($this->trans('commands.site.install.messages.installed')); + $io->success($this->trans('commands.site.install.messages.installed')); + + return 0; } } diff --git a/src/Command/Site/MaintenanceCommand.php b/src/Command/Site/MaintenanceCommand.php index dfc49617a..edfde2a53 100644 --- a/src/Command/Site/MaintenanceCommand.php +++ b/src/Command/Site/MaintenanceCommand.php @@ -10,17 +10,13 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\ContainerAwareCommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\ContainerAwareCommand; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Core\State\StateInterface; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\ChainQueue; -class MaintenanceCommand extends Command +class MaintenanceCommand extends ContainerAwareCommand { - use ContainerAwareCommandTrait; - - /** * @var StateInterface */ @@ -34,8 +30,9 @@ class MaintenanceCommand extends Command /** * DebugCommand constructor. - * @param StateInterface $state - * @param ChainQueue $chainQueue + * + * @param StateInterface $state + * @param ChainQueue $chainQueue */ public function __construct( StateInterface $state, @@ -54,8 +51,9 @@ protected function configure() ->addArgument( 'mode', InputArgument::REQUIRED, - $this->trans('commands.site.maintenance.arguments.mode').'[on/off]' - ); + $this->trans('commands.site.maintenance.arguments.mode') + ) + ->setAliases(['sma']); } protected function execute(InputInterface $input, OutputInterface $output) diff --git a/src/Command/Site/ModeCommand.php b/src/Command/Site/ModeCommand.php index a8738d4c2..3767e1727 100644 --- a/src/Command/Site/ModeCommand.php +++ b/src/Command/Site/ModeCommand.php @@ -11,17 +11,14 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Yaml\Yaml; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\ContainerAwareCommandTrait; -use Drupal\Console\Style\DrupalStyle; -use Drupal\Console\Utils\ConfigurationManager; +use Drupal\Console\Core\Command\ContainerAwareCommand; +use Drupal\Console\Core\Style\DrupalStyle; +use Drupal\Console\Core\Utils\ConfigurationManager; use Drupal\Core\Config\ConfigFactory; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\ChainQueue; -class ModeCommand extends Command +class ModeCommand extends ContainerAwareCommand { - use ContainerAwareCommandTrait; - /** * @var ConfigFactory */ @@ -44,9 +41,11 @@ class ModeCommand extends Command /** * DebugCommand constructor. - * @param ConfigFactory $configFactory + * + * @param ConfigFactory $configFactory * @param ConfigurationManager $configurationManager - * @param ChainQueue $chainQueue, + * @param $appRoot, + * @param ChainQueue $chainQueue, */ public function __construct( ConfigFactory $configFactory, @@ -70,7 +69,8 @@ protected function configure() 'environment', InputArgument::REQUIRED, $this->trans('commands.site.mode.arguments.environment') - ); + ) + ->setAliases(['smo']); } protected function execute(InputInterface $input, OutputInterface $output) @@ -79,13 +79,13 @@ protected function execute(InputInterface $input, OutputInterface $output) $environment = $input->getArgument('environment'); - $loadedConfigurations = []; - if (in_array($environment, array('dev', 'prod'))) { - $loadedConfigurations = $this->loadConfigurations($environment); - } else { + if (!in_array($environment, ['dev', 'prod'])) { $io->error($this->trans('commands.site.mode.messages.invalid-env')); + return 1; } + $loadedConfigurations = $this->loadConfigurations($environment); + $configurationOverrideResult = $this->overrideConfigurations( $loadedConfigurations['configurations'] ); @@ -106,7 +106,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $io->table($tableHeader, $result); } - $servicesOverrideResult = $this->overrideServices( + $servicesOverrideResult = $this->processServicesFile( + $environment, $loadedConfigurations['services'], $io ); @@ -153,26 +154,10 @@ protected function overrideConfigurations($configurations) $config->save(); } - // $this->getDrupalService('settings');die(); - // - // $drupal = $this->getDrupalHelper(); - // $fs = $this->getApplication()->getContainerHelper()->get('filesystem'); - // - // $cache_render = '$settings = ["cache"]["bins"]["render"] = "cache.backend.null";'; - // $cache_dynamic = '$settings =["cache"]["bins"]["dynamic_page_cache"] = "cache.backend.null";'; - // - // $settings_file = $fs->exists($drupal->getRoot() . '/sites/default/local.settings.php')?:$drupal->getRoot() . '/sites/default/settings.php'; - // chmod($drupal->getRoot() . '/sites/default/', 0775); - // chmod($settings_file, 0775); - // $settings_file = $fs->dumpFile($settings_file, file_get_contents($settings_file) . $cache_render . $cache_dynamic); - // chmod($drupal->getRoot() . '/sites/default/', 0644); - // chmod($settings_file, 0644); - // @TODO: $io->commentBlock() - return $result; } - protected function overrideServices($servicesSettings, DrupalStyle $io) + protected function processServicesFile($environment, $servicesSettings, DrupalStyle $io) { $directory = sprintf( '%s/%s', @@ -181,6 +166,7 @@ protected function overrideServices($servicesSettings, DrupalStyle $io) ); $settingsServicesFile = $directory . '/services.yml'; + if (!file_exists($settingsServicesFile)) { // Copying default services $defaultServicesFile = $this->appRoot . '/sites/default/default.services.yml'; @@ -198,19 +184,31 @@ protected function overrideServices($servicesSettings, DrupalStyle $io) } $yaml = new Yaml(); + $services = $yaml->parse(file_get_contents($settingsServicesFile)); $result = []; foreach ($servicesSettings as $service => $parameters) { - foreach ($parameters as $parameter => $value) { - $services['parameters'][$service][$parameter] = $value; + if (is_array($parameters)) { + foreach ($parameters as $parameter => $value) { + $services['parameters'][$service][$parameter] = $value; + // Set values for output + $result[$parameter]['service'] = $service; + $result[$parameter]['parameter'] = $parameter; + if (is_bool($value)) { + $value = $value ? 'true' : 'false'; + } + $result[$parameter]['value'] = $value; + } + } else { + $services['parameters'][$service] = $parameters; // Set values for output - $result[$parameter]['service'] = $service; - $result[$parameter]['parameter'] = $parameter; - if (is_bool($value)) { - $value = $value? 'true' : 'false'; + $result[$service]['service'] = $service; + $result[$service]['parameter'] = ''; + if (is_bool($parameters)) { + $value = $parameters ? 'true' : 'false'; } - $result[$parameter]['value'] = $value; + $result[$service]['value'] = $value; } } @@ -247,19 +245,23 @@ protected function loadConfigurations($env) if (!file_exists($configFile)) { $configFile = sprintf( '%s/config/dist/site.mode.yml', - $this->appRoot + $this->configurationManager->getApplicationDirectory() . DRUPAL_CONSOLE_CORE ); } - $siteModeConfiguration = Yaml::dump(file_get_contents($configFile)); + $siteModeConfiguration = Yaml::parse(file_get_contents($configFile)); $configKeys = array_keys($siteModeConfiguration); $configurationSettings = []; foreach ($configKeys as $configKey) { $siteModeConfigurationItem = $siteModeConfiguration[$configKey]; foreach ($siteModeConfigurationItem as $setting => $parameters) { - foreach ($parameters as $parameter => $value) { - $configurationSettings[$configKey][$setting][$parameter] = $value[$env]; + if (array_key_exists($env, $parameters)) { + $configurationSettings[$configKey][$setting] = $parameters[$env]; + } else { + foreach ($parameters as $parameter => $value) { + $configurationSettings[$configKey][$setting][$parameter] = $value[$env]; + } } } } diff --git a/src/Command/Site/NewCommand.php b/src/Command/Site/NewCommand.php deleted file mode 100644 index 388bdcaad..000000000 --- a/src/Command/Site/NewCommand.php +++ /dev/null @@ -1,221 +0,0 @@ -setName('site:new') - ->setDescription($this->trans('commands.site.new.description')) - ->addArgument( - 'directory', - InputArgument::REQUIRED, - $this->trans('commands.site.new.arguments.directory') - ) - ->addArgument( - 'version', - InputArgument::OPTIONAL, - $this->trans('commands.site.new.arguments.version') - ) - ->addOption( - 'latest', - '', - InputOption::VALUE_NONE, - $this->trans('commands.site.new.options.latest') - ) - ->addOption( - 'composer', - '', - InputOption::VALUE_NONE, - $this->trans('commands.site.new.options.composer') - ) - ->addOption( - 'unstable', - '', - InputOption::VALUE_NONE, - $this->trans('commands.site.new.options.unstable') - ); - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $directory = $input->getArgument('directory'); - $version = $input->getArgument('version'); - $latest = $input->getOption('latest'); - $composer = $input->getOption('composer'); - - if (!$directory) { - $io->error( - $this->trans('commands.site.new.messages.missing-directory') - ); - - return 1; - } - - if ($composer) { - if (!$version) { - $version = '8.x-dev'; - } - - $io->newLine(); - $io->comment( - sprintf( - $this->trans('commands.site.new.messages.executing'), - 'drupal', - $version - ) - ); - - $command = sprintf( - 'composer create-project %s:%s %s --no-interaction', - 'drupal-composer/drupal-project', - $version, - $directory - ); - - $io->commentBlock($command); - - $shellProcess = $this->get('shell_process'); - if ($shellProcess->exec($command)) { - $io->success( - sprintf( - $this->trans('commands.site.new.messages.composer'), - $version, - $directory - ) - ); - - return 0; - } else { - return 1; - } - } - - if (!$version && $latest) { - $version = current( - $this->getApplication()->getDrupalApi()->getProjectReleases('drupal', 1, true) - ); - } - - if (!$version) { - $io->error('Missing version'); - - return 1; - } - - $projectPath = $this->downloadProject($io, 'drupal', $version, 'core'); - $downloadPath = sprintf('%sdrupal-%s', $projectPath, $version); - - if ($this->isAbsolutePath($directory)) { - $copyPath = $directory; - } else { - $copyPath = sprintf('%s%s', $projectPath, $directory); - } - - try { - $fileSystem = new Filesystem(); - $fileSystem->rename($downloadPath, $copyPath); - } catch (IOExceptionInterface $e) { - $io->commentBlock( - sprintf( - $this->trans('commands.site.new.messages.downloaded'), - $version, - $downloadPath - ) - ); - - $io->error( - sprintf( - $this->trans('commands.site.new.messages.error-copying'), - $e->getPath() - ) - ); - - return 1; - } - - $io->success( - sprintf( - $this->trans('commands.site.new.messages.downloaded'), - $version, - $copyPath - ) - ); - - return 0; - } - - /** - * {@inheritdoc} - */ - protected function interact(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $directory = $input->getArgument('directory'); - $version = $input->getArgument('version'); - $latest = $input->getOption('latest'); - $unstable = $input->getOption('unstable'); - $composer = $input->getOption('composer'); - - if (!$directory) { - $directory = $io->ask( - $this->trans('commands.site.new.questions.directory') - ); - $input->setArgument('directory', $directory); - } - - if ($composer) { - $input->setArgument('version', '8.x-dev'); - - return 0; - } - - if (!$version && $latest) { - $version = current( - $this->getApplication()->getDrupalApi()->getProjectReleases('drupal', 1, true) - ); - } - - if (!$version) { - $version = $this->releasesQuestion($io, 'drupal', false, !$unstable); - } - - $input->setArgument('version', $version); - - return 0; - } - - protected function isAbsolutePath($path) - { - return $path[0] === DIRECTORY_SEPARATOR || preg_match('~\A[A-Z]:(?![^/\\\\])~i', $path) > 0; - } -} diff --git a/src/Command/Site/StatisticsCommand.php b/src/Command/Site/StatisticsCommand.php index 6fe46d027..4d4fcfc62 100644 --- a/src/Command/Site/StatisticsCommand.php +++ b/src/Command/Site/StatisticsCommand.php @@ -9,9 +9,8 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\ContainerAwareCommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\ContainerAwareCommand; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Utils\DrupalApi; use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Console\Extension\Manager; @@ -19,12 +18,11 @@ /** * Class StatisticsCommand + * * @package Drupal\Console\Command\Site */ -class StatisticsCommand extends Command +class StatisticsCommand extends ContainerAwareCommand { - use ContainerAwareCommandTrait; - /** * @var DrupalApi */ @@ -47,10 +45,11 @@ class StatisticsCommand extends Command /** * StatisticsCommand constructor. - * @param DrupalApi $drupalApi - * @param QueryFactory $entityQuery; - * @param Manager $extensionManager - * @param ModuleHandlerInterface $moduleHandler + * + * @param DrupalApi $drupalApi + * @param QueryFactory $entityQuery; + * @param Manager $extensionManager + * @param ModuleHandlerInterface $moduleHandler */ public function __construct( DrupalApi $drupalApi, @@ -73,7 +72,8 @@ public function configure() $this ->setName('site:statistics') ->setDescription($this->trans('commands.site.statistics.description')) - ->setHelp($this->trans('commands.site.statistics.help')); + ->setHelp($this->trans('commands.site.statistics.help')) + ->setAliases(['sst']); ; } diff --git a/src/Command/Site/StatusCommand.php b/src/Command/Site/StatusCommand.php index 3898176f1..9773b0ee2 100644 --- a/src/Command/Site/StatusCommand.php +++ b/src/Command/Site/StatusCommand.php @@ -10,10 +10,9 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\ContainerAwareCommand; use Drupal\Core\Database\Database; -use Drupal\Console\Command\Shared\ContainerAwareCommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\system\SystemManager; use Drupal\Core\Site\Settings; use Drupal\Core\Config\ConfigFactory; @@ -24,10 +23,8 @@ * * @category site */ -class StatusCommand extends Command +class StatusCommand extends ContainerAwareCommand { - use ContainerAwareCommandTrait; - /* @var $connectionInfoKeys array */ protected $connectionInfoKeys = [ 'driver', @@ -72,8 +69,9 @@ class StatusCommand extends Command /** * DebugCommand constructor. - * @param SystemManager $systemManager - * @param Settings $settings + * + * @param SystemManager $systemManager + * @param Settings $settings * @param ConfigFactory $configFactory * @param ThemeHandler $themeHandler * @param $appRoot @@ -107,7 +105,8 @@ protected function configure() InputOption::VALUE_OPTIONAL, $this->trans('commands.site.status.options.format'), 'table' - ); + ) + ->setAliases(['ss']); } /** @@ -115,6 +114,9 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { + // Make sure all modules are loaded. + $this->container->get('module_handler')->loadAll(); + $io = new DrupalStyle($input, $output); $systemData = $this->getSystemData(); @@ -156,7 +158,7 @@ protected function getSystemData() $title = $requirement['title']; } - $systemData['system'][$title] = $requirement['value']; + $systemData['system'][$title] = strip_tags($requirement['value']); } if ($this->settings) { @@ -165,7 +167,7 @@ protected function getSystemData() } catch (\Exception $e) { $hashSalt = ''; } - $systemData['system'][$this->trans('commands.site.status.messages.hash_salt')] = $hashSalt; + $systemData['system'][$this->trans('commands.site.status.messages.hash-salt')] = $hashSalt; $systemData['system'][$this->trans('commands.site.status.messages.console')] = $this->getApplication()->getVersion(); } @@ -213,7 +215,6 @@ protected function getThemeData() protected function getDirectoryData() { - $systemTheme = $this->configFactory->get('system.theme'); $themeDefaultDirectory = ''; @@ -235,10 +236,10 @@ protected function getDirectoryData() return [ 'directory' => [ - $this->trans('commands.site.status.messages.directory_root') => $this->appRoot, - $this->trans('commands.site.status.messages.directory_temporary') => $systemFile->get('path.temporary'), - $this->trans('commands.site.status.messages.directory_theme_default') => $themeDefaultDirectory, - $this->trans('commands.site.status.messages.directory_theme_admin') => $themeAdminDirectory, + $this->trans('commands.site.status.messages.directory-root') => $this->appRoot, + $this->trans('commands.site.status.messages.directory-temporary') => $systemFile->get('path.temporary'), + $this->trans('commands.site.status.messages.directory-theme-default') => $themeDefaultDirectory, + $this->trans('commands.site.status.messages.directory-theme-admin') => $themeAdminDirectory, ], ]; } diff --git a/src/Command/State/DeleteCommand.php b/src/Command/State/DeleteCommand.php index 082b2e90a..0e30b5945 100644 --- a/src/Command/State/DeleteCommand.php +++ b/src/Command/State/DeleteCommand.php @@ -9,16 +9,13 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\KeyValueStore\KeyValueFactoryInterface; use Drupal\Core\State\StateInterface; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; class DeleteCommand extends Command { - use CommandTrait; - /** * @var StateInterface */ @@ -31,6 +28,7 @@ class DeleteCommand extends Command /** * DeleteCommand constructor. + * * @param StateInterface $state * @param KeyValueFactoryInterface $keyValue */ @@ -55,7 +53,7 @@ protected function configure() 'name', InputArgument::OPTIONAL, $this->trans('commands.state.delete.arguments.name') - ); + )->setAliases(['std']); } /** diff --git a/src/Command/State/OverrideCommand.php b/src/Command/State/OverrideCommand.php index 333854bde..6032d4bf8 100644 --- a/src/Command/State/OverrideCommand.php +++ b/src/Command/State/OverrideCommand.php @@ -10,21 +10,19 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\KeyValueStore\KeyValueFactoryInterface; use Drupal\Core\State\StateInterface; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Component\Serialization\Yaml; /** * Class DebugCommand + * * @package Drupal\Console\Command\State */ class OverrideCommand extends Command { - use CommandTrait; - /** * @var StateInterface */ @@ -37,6 +35,7 @@ class OverrideCommand extends Command /** * OverrideCommand constructor. + * * @param StateInterface $state * @param KeyValueFactoryInterface $keyValue */ @@ -67,7 +66,7 @@ protected function configure() 'value', InputArgument::OPTIONAL, $this->trans('commands.state.override.arguments.value') - ); + )->setAliases(['sto']); } /** * {@inheritdoc} diff --git a/src/Command/Taxonomy/DeleteTermCommand.php b/src/Command/Taxonomy/DeleteTermCommand.php index 5dfdb8fad..3200b092a 100644 --- a/src/Command/Taxonomy/DeleteTermCommand.php +++ b/src/Command/Taxonomy/DeleteTermCommand.php @@ -4,13 +4,12 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\taxonomy\Entity\Term; use Drupal\taxonomy\Entity\Vocabulary; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class DeleteTermCommand. @@ -19,8 +18,6 @@ */ class DeleteTermCommand extends Command { - use CommandTrait; - /** * The entity_type storage. * @@ -30,69 +27,123 @@ class DeleteTermCommand extends Command /** * InfoCommand constructor. + * * @param EntityTypeManagerInterface $entityTypeManager */ - public function __construct(EntityTypeManagerInterface $entityTypeManager) { + public function __construct(EntityTypeManagerInterface $entityTypeManager) + { $this->entityTypeManager = $entityTypeManager; parent::__construct(); } /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ protected function configure() { $this ->setName('taxonomy:term:delete') ->setDescription($this->trans('commands.taxonomy.term.delete.description')) - ->addArgument('vid', InputArgument::REQUIRED); + ->addArgument( + 'vid', + InputArgument::REQUIRED + )->setAliases(['ttd']); } /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ protected function execute(InputInterface $input, OutputInterface $output) { $vid = $input->getArgument('vid'); $io = new DrupalStyle($input, $output); + if ($vid === 'all') { + $vid = $vid; + } elseif (!in_array($vid, array_keys($this->getVocabularies()))) { + + $io->error( + sprintf( + $this->trans('commands.taxonomy.term.delete.messages.invalid-vocabulary'), + $vid + ) + ); + return; + + } $this->deleteExistingTerms($vid, $io); + } - return 0; + /** + * {@inheritdoc} + */ + protected function interact(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + // --vid argument + $vid = $input->getArgument('vid'); + if (!$vid) { + $vid = $io->choiceNoList( + $this->trans('commands.taxonomy.term.delete.vid'), + array_keys($this->getVocabularies()) + ); + $input->setArgument('vid', $vid); + } } /** - * Destroy all existing terms before import - * @param $vid - * @param $io - */ + * Destroy all existing terms + * @param $vid + * @param $io + */ private function deleteExistingTerms($vid = null, DrupalStyle $io) { - //Load the vid + $termStorage = $this->entityTypeManager->getStorage('taxonomy_term'); - $vocabularies = $this->entityTypeManager->getStorage('taxonomy_vocabulary') - ->loadMultiple(); + //Load all vocabularies + $vocabularies = $this->getVocabularies(); - if ($vid !== 'all') { - $vid = [$vid]; - } else { + if ($vid === 'all') { $vid = array_keys($vocabularies); + } else { + $vid = [$vid]; } foreach ($vid as $item) { - if (!isset($vocabularies[$item])) { - $io->error("Invalid vid: {$item}."); - } $vocabulary = $vocabularies[$item]; $terms = $termStorage->loadTree($vocabulary->id()); - foreach ($terms as $term) { - $treal = $termStorage->load($term->tid); - if ($treal !== null) { - $io->info("Deleting '{$term->name}' and all translations."); - $treal->delete(); + if (empty($terms)) { + $io->error( + sprintf( + $this->trans('commands.taxonomy.term.delete.messages.nothing'), + $item + ) + ); + + } else { + foreach ($terms as $term) { + $treal = $termStorage->load($term->tid); + + if ($treal !== null) { + $io->info( + sprintf( + $this->trans('commands.taxonomy.term.delete.messages.processing'), + $term->name + ) + ); + $treal->delete(); + } } + } } } + + private function getVocabularies() + { + return $this->entityTypeManager->getStorage('taxonomy_vocabulary') + ->loadMultiple(); + } } diff --git a/src/Command/Test/RunCommand.php b/src/Command/Test/RunCommand.php index ba882d005..74f3d06a7 100644 --- a/src/Command/Test/RunCommand.php +++ b/src/Command/Test/RunCommand.php @@ -12,10 +12,9 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Drupal\Component\Utility\Timer; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Annotations\DrupalCommand; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\simpletest\TestDiscovery; use Drupal\Core\Datetime\DateFormatter; @@ -28,8 +27,6 @@ */ class RunCommand extends Command { - use CommandTrait; - /** * @var string */ @@ -52,13 +49,12 @@ class RunCommand extends Command */ protected $dateFormatter; - - /** * RunCommand constructor. - * @param Site $site - * @param TestDiscovery $test_discovery - * @param ModuleHandlerInterface $moduleHandler + * + * @param Site $site + * @param TestDiscovery $test_discovery + * @param ModuleHandlerInterface $moduleHandler */ public function __construct( $appRoot, @@ -90,10 +86,11 @@ protected function configure() ) ->addOption( 'url', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.test.run.arguments.url') - ); + ) + ->setAliases(['ter']); } /* @@ -271,9 +268,9 @@ protected function simpletestScriptLoadMessagesByTestIds($test_ids) foreach ($test_ids as $test_id) { $result = \Drupal::database()->query( - "SELECT * FROM {simpletest} WHERE test_id = :test_id ORDER BY test_class, message_group, status", array( + "SELECT * FROM {simpletest} WHERE test_id = :test_id ORDER BY test_class, message_group, status", [ ':test_id' => $test_id, - ) + ] )->fetchAll(); if ($result) { $results = array_merge($results, $result); diff --git a/src/Command/Theme/DownloadCommand.php b/src/Command/Theme/DownloadCommand.php index c111e6d5e..3db6105dd 100644 --- a/src/Command/Theme/DownloadCommand.php +++ b/src/Command/Theme/DownloadCommand.php @@ -11,9 +11,8 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Command\Command; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Command\Shared\ProjectDownloadTrait; use Drupal\Console\Utils\DrupalApi; use GuzzleHttp\Client; @@ -21,8 +20,6 @@ class DownloadCommand extends Command { use ProjectDownloadTrait; - use CommandTrait; - /** * @var DrupalApi @@ -42,8 +39,9 @@ class DownloadCommand extends Command /** * DownloadCommand constructor. - * @param DrupalApi $drupalApi - * @param Client $httpClient + * + * @param DrupalApi $drupalApi + * @param Client $httpClient * @param $appRoot */ public function __construct( @@ -66,14 +64,22 @@ protected function configure() $this ->setName('theme:download') ->setDescription($this->trans('commands.theme.download.description')) - ->addArgument('theme', InputArgument::REQUIRED, $this->trans('commands.theme.download.arguments.theme')) - ->addArgument('version', InputArgument::OPTIONAL, $this->trans('commands.theme.download.arguments.version')) + ->addArgument( + 'theme', + InputArgument::REQUIRED, + $this->trans('commands.theme.download.arguments.theme') + ) + ->addArgument( + 'version', + InputArgument::OPTIONAL, + $this->trans('commands.theme.download.arguments.version') + ) ->addOption( 'composer', - '', + null, InputOption::VALUE_NONE, $this->trans('commands.theme.download.options.composer') - ); + )->setAliases(['thd']); } /** diff --git a/src/Command/Theme/InstallCommand.php b/src/Command/Theme/InstallCommand.php index 893cf0b04..7847598c7 100644 --- a/src/Command/Theme/InstallCommand.php +++ b/src/Command/Theme/InstallCommand.php @@ -11,18 +11,15 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Extension\ThemeHandler; use Drupal\Core\Config\UnmetDependenciesException; -use Drupal\Console\Style\DrupalStyle; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Style\DrupalStyle; +use Drupal\Console\Core\Utils\ChainQueue; class InstallCommand extends Command { - use CommandTrait; - /** * @var ConfigFactory */ @@ -40,9 +37,10 @@ class InstallCommand extends Command /** * DebugCommand constructor. + * * @param ConfigFactory $configFactory - * @param ThemeHandler $themeHandler - * @param ChainQueue $chainQueue + * @param ThemeHandler $themeHandler + * @param ChainQueue $chainQueue */ public function __construct( ConfigFactory $configFactory, @@ -60,13 +58,17 @@ protected function configure() $this ->setName('theme:install') ->setDescription($this->trans('commands.theme.install.description')) - ->addArgument('theme', InputArgument::IS_ARRAY, $this->trans('commands.theme.install.options.module')) + ->addArgument( + 'theme', + InputArgument::IS_ARRAY, + $this->trans('commands.theme.install.options.theme') + ) ->addOption( 'set-default', - '', + null, InputOption::VALUE_NONE, $this->trans('commands.theme.install.options.set-default') - ); + )->setAliases(['thi']); } /** @@ -100,7 +102,9 @@ protected function interact(InputInterface $input, OutputInterface $output) while (true) { $theme_name = $io->choiceNoList( $this->trans('commands.theme.install.questions.theme'), - array_keys($theme_list) + array_keys($theme_list), + null, + true ); if (empty($theme_name)) { @@ -131,7 +135,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if ($default && count($theme) > 1) { $io->error($this->trans('commands.theme.install.messages.invalid-theme-default')); - return; + return 1; } $themes = $this->themeHandler->rebuildThemeData(); @@ -187,6 +191,8 @@ protected function execute(InputInterface $input, OutputInterface $output) ) ); drupal_set_message($e->getTranslatedMessage($this->getStringTranslation(), $theme), 'error'); + + return 1; } } elseif (empty($themesAvailable) && count($themesInstalled) > 0) { if (count($themesInstalled) > 1) { @@ -224,5 +230,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // Run cache rebuild to see changes in Web UI $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']); + + return 0; } } diff --git a/src/Command/Theme/PathCommand.php b/src/Command/Theme/PathCommand.php index 3ba3cf432..77bd52693 100644 --- a/src/Command/Theme/PathCommand.php +++ b/src/Command/Theme/PathCommand.php @@ -11,29 +11,33 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Extension\Manager; -use Drupal\Console\Command\Shared\ModuleTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; +use Drupal\Core\Extension\ThemeHandler; class PathCommand extends Command { - use CommandTrait; - use ModuleTrait; - /** * @var Manager */ protected $extensionManager; + /** + * @var ThemeHandler + */ + protected $themeHandler; + /** * PathCommand constructor. - * @param Manager $extensionManager + * + * @param Manager $extensionManager + * @param ThemeHandler $themeHandler */ - public function __construct(Manager $extensionManager) + public function __construct(Manager $extensionManager, ThemeHandler $themeHandler) { $this->extensionManager = $extensionManager; + $this->themeHandler = $themeHandler; parent::__construct(); } @@ -45,24 +49,32 @@ protected function configure() ->addArgument( 'theme', InputArgument::REQUIRED, - $this->trans('commands.theme.path.arguments.module') + $this->trans('commands.theme.path.arguments.theme') ) ->addOption( 'absolute', - '', + null, InputOption::VALUE_NONE, $this->trans('commands.theme.path.options.absolute') - ); + )->setAliases(['thp']); } protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); - $theme = $input->getArgument('theme'); $fullPath = $input->getOption('absolute'); + if (!in_array($theme, $this->getThemeList())) { + $io->error( + sprintf( + $this->trans('commands.theme.path.messages.invalid-theme-name'), + $theme + ) + ); + return; + } $theme = $this->extensionManager->getTheme($theme); $io->info( @@ -77,12 +89,19 @@ protected function interact(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); - // --module argument + // --theme argument $theme = $input->getArgument('theme'); if (!$theme) { - // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion - $module = $this->moduleQuestion($io); - $input->setArgument('theme', $module); + $theme = $io->choiceNoList( + $this->trans('commands.theme.path.arguments.theme'), + $this->getThemeList() + ); + $input->setArgument('theme', $theme); } } + + protected function getThemeList() + { + return array_keys($this->themeHandler->rebuildThemeData()); + } } diff --git a/src/Command/Theme/UninstallCommand.php b/src/Command/Theme/UninstallCommand.php index 8d11fffa2..41604ec9d 100644 --- a/src/Command/Theme/UninstallCommand.php +++ b/src/Command/Theme/UninstallCommand.php @@ -10,18 +10,15 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Extension\ThemeHandler; use Drupal\Core\Config\UnmetDependenciesException; -use Drupal\Console\Style\DrupalStyle; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Style\DrupalStyle; +use Drupal\Console\Core\Utils\ChainQueue; class UninstallCommand extends Command { - use CommandTrait; - /** * @var ConfigFactory */ @@ -39,9 +36,10 @@ class UninstallCommand extends Command /** * DebugCommand constructor. + * * @param ConfigFactory $configFactory - * @param ThemeHandler $themeHandler - * @param ChainQueue $chainQueue + * @param ThemeHandler $themeHandler + * @param ChainQueue $chainQueue */ public function __construct( ConfigFactory $configFactory, @@ -59,7 +57,12 @@ protected function configure() $this ->setName('theme:uninstall') ->setDescription($this->trans('commands.theme.uninstall.description')) - ->addArgument('theme', InputArgument::IS_ARRAY, $this->trans('commands.theme.uninstall.options.module')); + ->addArgument( + 'theme', + InputArgument::IS_ARRAY, + $this->trans('commands.theme.uninstall.options.theme') + ) + ->setAliases(['thu']); } /** @@ -92,7 +95,9 @@ protected function interact(InputInterface $input, OutputInterface $output) while (true) { $theme_name = $io->choiceNoList( $this->trans('commands.theme.uninstall.questions.theme'), - array_keys($theme_list) + array_keys($theme_list), + null, + true ); if (empty($theme_name)) { @@ -145,7 +150,7 @@ protected function execute(InputInterface $input, OutputInterface $output) ) ); - return; + return 1; } if ($themeKey === $config->get('admin')) { @@ -155,7 +160,7 @@ protected function execute(InputInterface $input, OutputInterface $output) implode(',', $themesAvailable) ) ); - return; + return 1; } } @@ -184,6 +189,8 @@ protected function execute(InputInterface $input, OutputInterface $output) ) ); drupal_set_message($e->getTranslatedMessage($this->getStringTranslation(), $theme), 'error'); + + return 1; } } elseif (empty($themesAvailable) && count($themesUninstalled) > 0) { if (count($themesUninstalled) > 1) { @@ -221,5 +228,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // Run cache rebuild to see changes in Web UI $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']); + + return 0; } } diff --git a/src/Command/Update/EntitiesCommand.php b/src/Command/Update/EntitiesCommand.php index 43ea2aed0..c1f98eaf5 100644 --- a/src/Command/Update/EntitiesCommand.php +++ b/src/Command/Update/EntitiesCommand.php @@ -9,14 +9,13 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Utility\Error; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Core\State\StateInterface; use Drupal\Core\Entity\EntityDefinitionUpdateManager; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\ChainQueue; /** * Class EntitiesCommand. @@ -25,8 +24,6 @@ */ class EntitiesCommand extends Command { - use CommandTrait; - /** * @var StateInterface */ @@ -44,7 +41,8 @@ class EntitiesCommand extends Command /** * EntitiesCommand constructor. - * @param StateInterface $state + * + * @param StateInterface $state * @param EntityDefinitionUpdateManager $entityDefinitionUpdateManager * @param ChainQueue $chainQueue */ @@ -66,7 +64,9 @@ protected function configure() { $this ->setName('update:entities') - ->setDescription($this->trans('commands.update.entities.description')); + ->setDescription($this->trans('commands.update.entities.description')) + ->setAliases(['upe']); + ; } /** diff --git a/src/Command/Update/ExecuteCommand.php b/src/Command/Update/ExecuteCommand.php index 24abf462c..3eec5774a 100644 --- a/src/Command/Update/ExecuteCommand.php +++ b/src/Command/Update/ExecuteCommand.php @@ -10,20 +10,17 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\Command; use Drupal\Core\State\StateInterface; use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\Update\UpdateRegistry; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Utils\Site; use Drupal\Console\Extension\Manager; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\ChainQueue; class ExecuteCommand extends Command { - use CommandTrait; - /** * @var Site */ @@ -45,7 +42,9 @@ class ExecuteCommand extends Command protected $postUpdateRegistry; - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** @@ -65,11 +64,12 @@ class ExecuteCommand extends Command /** * EntitiesCommand constructor. + * * @param Site $site - * @param StateInterface $state + * @param StateInterface $state * @param ModuleHandler $moduleHandler * @param UpdateRegistry $postUpdateRegistry - * @param Manager $extensionManager + * @param Manager $extensionManager * @param ChainQueue $chainQueue */ public function __construct( @@ -99,14 +99,15 @@ protected function configure() ->setDescription($this->trans('commands.update.execute.description')) ->addArgument( 'module', - InputArgument::REQUIRED, + InputArgument::OPTIONAL, $this->trans('commands.common.options.module') ) ->addArgument( 'update-n', InputArgument::OPTIONAL, $this->trans('commands.update.execute.options.update-n') - ); + ) + ->setAliases(['upex']); } /** @@ -115,7 +116,7 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); - $this->module = $input->getArgument('module'); + $this->module = $input->getArgument('module') ?: 'all'; $this->update_n = $input->getArgument('update-n'); $this->site->loadLegacyFile('/core/includes/install.inc'); @@ -124,7 +125,10 @@ protected function execute(InputInterface $input, OutputInterface $output) drupal_load_updates(); update_fix_compatibility(); $updates = update_get_update_list(); - $this->checkUpdates($io); + if (!$this->checkUpdates($io, $updates)) { + return 1; + } + $maintenance_mode = $this->state->get('system.maintenance_mode', false); if (!$maintenance_mode) { @@ -132,8 +136,18 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->state->set('system.maintenance_mode', true); } - $this->runUpdates($io, $updates); - $this->runPostUpdates($io); + try { + $complete = $this->runUpdates($io, $updates); + + // Post Updates are only safe to run after all schemas have been updated. + if ($complete) { + $this->runPostUpdates($io); + } + } catch (\Exception $e) { + watchdog_exception('update', $e); + $io->error($e->getMessage()); + return 1; + } if (!$maintenance_mode) { $this->state->set('system.maintenance_mode', false); @@ -145,9 +159,12 @@ protected function execute(InputInterface $input, OutputInterface $output) } /** - * @param \Drupal\Console\Style\DrupalStyle $io + * @param \Drupal\Console\Core\Style\DrupalStyle $io + * @param array $updates + * + * @return bool true if the selected module/update number exists. */ - private function checkUpdates(DrupalStyle $io) + private function checkUpdates(DrupalStyle $io, array $updates) { if ($this->module != 'all') { if (!isset($updates[$this->module])) { @@ -157,106 +174,105 @@ private function checkUpdates(DrupalStyle $io) $this->module ) ); - return; + return false; } else { - // filter to execute only a specific module updates - $updates = [$this->module => $updates[$this->module]]; - if ($this->update_n && !isset($updates[$this->module]['pending'][$this->update_n])) { - $io->info( + $io->error( sprintf( $this->trans('commands.update.execute.messages.module-update-function-not-found'), $this->module, $this->update_n ) ); + return false; } } } + return true; } /** - * @param \Drupal\Console\Style\DrupalStyle $io - * @param $updates + * @param \Drupal\Console\Core\Style\DrupalStyle $io + * @param array $updates + * + * @return bool True if all available updates have been run. */ - private function runUpdates(DrupalStyle $io, $updates) + private function runUpdates(DrupalStyle $io, array $updates) { + if ($this->module != 'all') { + $complete = count($updates) == 1; + $updates = [$this->module => $updates[$this->module]]; + } else { + $complete = true; + } + foreach ($updates as $module_name => $module_updates) { - $this->site - ->loadLegacyFile($this->extensionManager->getModule($this->module)->getPath() . '/'. $this->module . '.install', false); + $extension = $this->extensionManager->getModule($module_name); + if (!$extension) { + $extension = $this->extensionManager->getProfile($module_name); + } + if ($extension) { + $this->site + ->loadLegacyFile($extension->getPath() . '/'. $module_name . '.install', false); + } + + if ($this->update_n > $module_updates['start']) { + $io->info( + $this->trans('commands.update.execute.messages.executing-required-previous-updates') + ); + } foreach ($module_updates['pending'] as $update_number => $update) { - if ($this->module != 'all' && $this->update_n !== null && $this->update_n != $update_number) { - continue; + if ($this->module != 'all' && $this->update_n !== null && $this->update_n < $update_number) { + return false; } - if ($this->update_n > $module_updates['start']) { - $io->info( - $this->trans('commands.update.execute.messages.executing-required-previous-updates') - ); - } + $io->comment( + sprintf( + $this->trans('commands.update.execute.messages.executing-update'), + $update_number, + $module_name + ) + ); - for ($update_index=$module_updates['start']; $update_index<=$update_number; $update_index++) { - $io->info( - sprintf( - $this->trans('commands.update.execute.messages.executing-update'), - $update_index, - $module_name - ) - ); + $updateExploded = explode(" - ", $update); + $updateExploded = count($updateExploded)>0?$updateExploded[1]:$updateExploded[0]; - try { - $this->moduleHandler->invoke($module_name, 'update_' . $update_index); - } catch (\Exception $e) { - watchdog_exception('update', $e); - $io->error($e->getMessage()); - } + $io->comment(trim($updateExploded)); + $io->newLine(); - drupal_set_installed_schema_version($module_name, $update_index); - } + $this->moduleHandler->invoke($module_name, 'update_' . $update_number); + drupal_set_installed_schema_version($module_name, $update_number); } } + + return $complete; } /** - * @param \Drupal\Console\Style\DrupalStyle $io + * @param \Drupal\Console\Core\Style\DrupalStyle $io */ private function runPostUpdates(DrupalStyle $io) { $postUpdates = $this->postUpdateRegistry->getPendingUpdateInformation(); foreach ($postUpdates as $module_name => $module_updates) { - foreach ($module_updates['pending'] as $update_number => $update) { - if ($this->module != 'all' && $this->update_n !== null && $this->update_n != $update_number) { - continue; - } - - if ($this->update_n > $module_updates['start']) { - $io->info( - $this->trans('commands.update.execute.messages.executing-required-previous-updates') - ); - } - for ($update_index=$module_updates['start']; $update_index<=$update_number; $update_index++) { - $io->info( - sprintf( - $this->trans('commands.update.execute.messages.executing-update'), - $update_index, - $module_name - ) - ); + foreach ($module_updates['pending'] as $update_name => $update) { + $io->info( + sprintf( + $this->trans('commands.update.execute.messages.executing-update'), + $update_name, + $module_name + ) + ); - try { - $function = sprintf( - '%s_post_update_%s', - $module_name, - $update_index - ); - drupal_flush_all_caches(); - update_invoke_post_update($function); - } catch (\Exception $e) { - watchdog_exception('update', $e); - $io->error($e->getMessage()); - } - } + $function = sprintf( + '%s_post_update_%s', + $module_name, + $update_name + ); + drupal_flush_all_caches(); + $context = []; + update_invoke_post_update($function, $context); } } } diff --git a/src/Command/User/CreateCommand.php b/src/Command/User/CreateCommand.php index c19639729..dffd2d163 100644 --- a/src/Command/User/CreateCommand.php +++ b/src/Command/User/CreateCommand.php @@ -10,20 +10,18 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Datetime\DateFormatterInterface; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\ChainQueue; use Drupal\Console\Utils\DrupalApi; use Drupal\Console\Command\Shared\ConfirmationTrait; use Drupal\user\Entity\User; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; class CreateCommand extends Command { - use CommandTrait; use ConfirmationTrait; /** @@ -48,10 +46,11 @@ class CreateCommand extends Command /** * CreateCommand constructor. - * @param Connection $database - * @param EntityTypeManagerInterface $entityTypeManager - * @param DateFormatterInterface $dateFormatter - * @param DrupalApi $drupalApi + * + * @param Connection $database + * @param EntityTypeManagerInterface $entityTypeManager + * @param DateFormatterInterface $dateFormatter + * @param DrupalApi $drupalApi */ public function __construct( Connection $database, @@ -75,11 +74,34 @@ protected function configure() ->setName('user:create') ->setDescription($this->trans('commands.user.create.description')) ->setHelp($this->trans('commands.user.create.help')) - ->addArgument('username', InputArgument::OPTIONAL, $this->trans('commands.user.create.options.username')) - ->addArgument('password', InputArgument::OPTIONAL, $this->trans('commands.user.create.options.password')) - ->addOption('roles', null, InputOption::VALUE_OPTIONAL, $this->trans('commands.user.create.options.roles')) - ->addOption('email', null, InputOption::VALUE_OPTIONAL, $this->trans('commands.user.create.options.email')) - ->addOption('status', null, InputOption::VALUE_OPTIONAL, $this->trans('commands.user.create.options.status')); + ->addArgument( + 'username', + InputArgument::OPTIONAL, + $this->trans('commands.user.create.options.username') + ) + ->addArgument( + 'password', + InputArgument::OPTIONAL, + $this->trans('commands.user.create.options.password') + ) + ->addOption( + 'roles', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.user.create.options.roles') + ) + ->addOption( + 'email', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.user.create.options.email') + ) + ->addOption( + 'status', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.user.create.options.status') + )->setAliases(['uc']); } /** diff --git a/src/Command/User/DeleteCommand.php b/src/Command/User/DeleteCommand.php index d01d327d4..db20543d8 100644 --- a/src/Command/User/DeleteCommand.php +++ b/src/Command/User/DeleteCommand.php @@ -10,21 +10,19 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\Query\QueryFactory; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Utils\DrupalApi; /** * Class DeleteCommand + * * @package Drupal\Console\Command\User */ class DeleteCommand extends Command { - use CommandTrait; - /** * @var EntityTypeManagerInterface */ @@ -42,9 +40,10 @@ class DeleteCommand extends Command /** * DeleteCommand constructor. + * * @param EntityTypeManagerInterface $entityTypeManager - * @param QueryFactory $entityQuery - * @param DrupalApi $drupalApi + * @param QueryFactory $entityQuery + * @param DrupalApi $drupalApi */ public function __construct( EntityTypeManagerInterface $entityTypeManager, @@ -76,7 +75,7 @@ protected function configure() null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, $this->trans('commands.user.delete.options.roles') - ); + )->setAliases(['ud']); } /** diff --git a/src/Command/User/LoginCleanAttemptsCommand.php b/src/Command/User/LoginCleanAttemptsCommand.php index 93ca05fc5..3bb1232b0 100644 --- a/src/Command/User/LoginCleanAttemptsCommand.php +++ b/src/Command/User/LoginCleanAttemptsCommand.php @@ -11,15 +11,13 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Database\Connection; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; use Drupal\user\Entity\User; class LoginCleanAttemptsCommand extends Command { - use CommandTrait; use ConfirmationTrait; /** @@ -29,9 +27,11 @@ class LoginCleanAttemptsCommand extends Command /** * LoginCleanAttemptsCommand constructor. + * * @param Connection $database */ - public function __construct(Connection $database) { + public function __construct(Connection $database) + { $this->database = $database; parent::__construct(); } @@ -45,7 +45,12 @@ protected function configure() setName('user:login:clear:attempts') ->setDescription($this->trans('commands.user.login.clear.attempts.description')) ->setHelp($this->trans('commands.user.login.clear.attempts.help')) - ->addArgument('uid', InputArgument::REQUIRED, $this->trans('commands.user.login.clear.attempts.options.user-id')); + ->addArgument( + 'uid', + InputArgument::REQUIRED, + $this->trans('commands.user.login.clear.attempts.options.user-id') + ) + ->setAliases(['ulca']); } /** diff --git a/src/Command/User/LoginUrlCommand.php b/src/Command/User/LoginUrlCommand.php index ac2550f23..6cd60cf86 100644 --- a/src/Command/User/LoginUrlCommand.php +++ b/src/Command/User/LoginUrlCommand.php @@ -10,10 +10,9 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class UserLoginCommand. @@ -22,8 +21,6 @@ */ class LoginUrlCommand extends Command { - use CommandTrait; - /** * @var EntityTypeManagerInterface */ @@ -31,9 +28,11 @@ class LoginUrlCommand extends Command /** * LoginUrlCommand constructor. - * @param EntityTypeManagerInterface $entityTypeManager + * + * @param EntityTypeManagerInterface $entityTypeManager */ - public function __construct(EntityTypeManagerInterface $entityTypeManager) { + public function __construct(EntityTypeManagerInterface $entityTypeManager) + { $this->entityTypeManager = $entityTypeManager; parent::__construct(); } @@ -51,7 +50,8 @@ protected function configure() InputArgument::REQUIRED, $this->trans('commands.user.login.url.options.user-id'), null - ); + ) + ->setAliases(['ulu']); } /** diff --git a/src/Command/User/PasswordHashCommand.php b/src/Command/User/PasswordHashCommand.php index 73a121574..53f5843d5 100644 --- a/src/Command/User/PasswordHashCommand.php +++ b/src/Command/User/PasswordHashCommand.php @@ -10,27 +10,27 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; -use Drupal\Core\Password\PhpassHashedPassword; +use Drupal\Console\Core\Command\Command; +use Drupal\Core\Password\PasswordInterface; use Drupal\Console\Command\Shared\ConfirmationTrait; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; class PasswordHashCommand extends Command { - use CommandTrait; use ConfirmationTrait; /** - * @var PhpassHashedPassword + * @var PasswordInterface */ protected $password; /** * PasswordHashCommand constructor. - * @param PhpassHashedPassword $password + * + * @param PasswordInterface $password */ - public function __construct(PhpassHashedPassword $password) { + public function __construct(PasswordInterface $password) + { $this->password = $password; parent::__construct(); } @@ -44,7 +44,12 @@ protected function configure() ->setName('user:password:hash') ->setDescription($this->trans('commands.user.password.hash.description')) ->setHelp($this->trans('commands.user.password.hash.help')) - ->addArgument('password', InputArgument::IS_ARRAY, $this->trans('commands.user.password.hash.options.password')); + ->addArgument( + 'password', + InputArgument::IS_ARRAY, + $this->trans('commands.user.password.hash.options.password') + ) + ->setAliases(['uph']); } /** @@ -65,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output) foreach ($passwords as $password) { $tableRows[] = [ $password, - $password->hash($password), + $this->password->hash($password), ]; } diff --git a/src/Command/User/PasswordResetCommand.php b/src/Command/User/PasswordResetCommand.php index 47a964f7a..67bc26457 100644 --- a/src/Command/User/PasswordResetCommand.php +++ b/src/Command/User/PasswordResetCommand.php @@ -9,17 +9,15 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Database\Connection; -use Drupal\Console\Utils\ChainQueue; +use Drupal\Console\Core\Utils\ChainQueue; use Drupal\Console\Command\Shared\ConfirmationTrait; use Drupal\user\Entity\User; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; class PasswordResetCommand extends Command { - use CommandTrait; use ConfirmationTrait; /** @@ -34,6 +32,7 @@ class PasswordResetCommand extends Command /** * PasswordHashCommand constructor. + * * @param Connection $database * @param ChainQueue $chainQueue */ @@ -55,8 +54,17 @@ protected function configure() ->setName('user:password:reset') ->setDescription($this->trans('commands.user.password.reset.description')) ->setHelp($this->trans('commands.user.password.reset.help')) - ->addArgument('user', InputArgument::REQUIRED, $this->trans('commands.user.password.reset.options.user-id')) - ->addArgument('password', InputArgument::REQUIRED, $this->trans('commands.user.password.reset.options.password')); + ->addArgument( + 'user', + InputArgument::REQUIRED, + $this->trans('commands.user.password.reset.options.user-id') + ) + ->addArgument( + 'password', + InputArgument::REQUIRED, + $this->trans('commands.user.password.reset.options.password') + ) + ->setAliases(['upr']); } /** @@ -173,7 +181,6 @@ function ($pass) use ($io) { return false; } } - } ); diff --git a/src/Command/User/RoleCommand.php b/src/Command/User/RoleCommand.php index a4f7c0b23..71f5ff0df 100644 --- a/src/Command/User/RoleCommand.php +++ b/src/Command/User/RoleCommand.php @@ -10,19 +10,17 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Console\Utils\DrupalApi; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class DebugCommand + * * @package Drupal\Console\Command\User */ class RoleCommand extends Command { - use CommandTrait; - /** * @var DrupalApi */ @@ -30,9 +28,11 @@ class RoleCommand extends Command /** * RoleCommand constructor. + * * @param DrupalApi $drupalApi */ - public function __construct(DrupalApi $drupalApi) { + public function __construct(DrupalApi $drupalApi) + { $this->drupalApi = $drupalApi; parent::__construct(); } @@ -48,18 +48,18 @@ protected function configure() ->addArgument( 'operation', InputOption::VALUE_REQUIRED, - $this->trans('commands.user.role.operation') + $this->trans('commands.user.role.arguments.operation') ) ->addArgument( 'user', InputOption::VALUE_REQUIRED, - $this->trans('commands.user.role.user') + $this->trans('commands.user.role.arguments.user') ) ->addArgument( 'role', InputOption::VALUE_REQUIRED, - $this->trans('commands.user.role.role') - ); + $this->trans('commands.user.role.arguments.roles') + )->setAliases(['ur']); } /** diff --git a/src/Command/Views/DisableCommand.php b/src/Command/Views/DisableCommand.php index 6f83f4d4d..2a2e1101b 100644 --- a/src/Command/Views/DisableCommand.php +++ b/src/Command/Views/DisableCommand.php @@ -10,20 +10,18 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\Query\QueryFactory; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class DisableCommand + * * @package Drupal\Console\Command\Views */ class DisableCommand extends Command { - use CommandTrait; - /** * @var EntityTypeManagerInterface */ @@ -36,8 +34,9 @@ class DisableCommand extends Command /** * DisableCommand constructor. + * * @param EntityTypeManagerInterface $entityTypeManager - * @param QueryFactory $entityQuery + * @param QueryFactory $entityQuery */ public function __construct( EntityTypeManagerInterface $entityTypeManager, @@ -59,8 +58,9 @@ protected function configure() ->addArgument( 'view-id', InputArgument::OPTIONAL, - $this->trans('commands.views.debug.arguments.view-id') - ); + $this->trans('commands.debug.views.arguments.view-id') + ) + ->setAliases(['vd']); } /** @@ -76,7 +76,7 @@ protected function interact(InputInterface $input, OutputInterface $output) ->condition('status', 1) ->execute(); $viewId = $io->choiceNoList( - $this->trans('commands.views.debug.arguments.view-id'), + $this->trans('commands.debug.views.arguments.view-id'), $views ); $input->setArgument('view-id', $viewId); @@ -95,8 +95,9 @@ protected function execute(InputInterface $input, OutputInterface $output) $view = $this->entityTypeManager->getStorage('view')->load($viewId); if (empty($view)) { - $io->error(sprintf($this->trans('commands.views.debug.messages.not-found'), $viewId)); - return; + $io->error(sprintf($this->trans('commands.debug.views.messages.not-found'), $viewId)); + + return 1; } try { @@ -105,6 +106,10 @@ protected function execute(InputInterface $input, OutputInterface $output) $io->success(sprintf($this->trans('commands.views.disable.messages.disabled-successfully'), $view->get('label'))); } catch (\Exception $e) { $io->error($e->getMessage()); + + return 1; } + + return 0; } } diff --git a/src/Command/Views/EnableCommand.php b/src/Command/Views/EnableCommand.php index b0133c31b..7bd74d773 100644 --- a/src/Command/Views/EnableCommand.php +++ b/src/Command/Views/EnableCommand.php @@ -11,20 +11,18 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Config\Definition\Exception\Exception; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Command\Shared\CommandTrait; +use Drupal\Console\Core\Command\Command; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\Query\QueryFactory; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Style\DrupalStyle; /** * Class EnableCommand + * * @package Drupal\Console\Command\Views */ class EnableCommand extends Command { - use CommandTrait; - /** * @var EntityTypeManagerInterface */ @@ -37,8 +35,9 @@ class EnableCommand extends Command /** * EnableCommand constructor. + * * @param EntityTypeManagerInterface $entityTypeManager - * @param QueryFactory $entityQuery + * @param QueryFactory $entityQuery */ public function __construct( EntityTypeManagerInterface $entityTypeManager, @@ -60,8 +59,9 @@ protected function configure() ->addArgument( 'view-id', InputArgument::OPTIONAL, - $this->trans('commands.views.debug.arguments.view-id') - ); + $this->trans('commands.debug.views.arguments.view-id') + ) + ->setAliases(['ve']); } /** @@ -77,7 +77,7 @@ protected function interact(InputInterface $input, OutputInterface $output) ->condition('status', 0) ->execute(); $viewId = $io->choiceNoList( - $this->trans('commands.views.debug.arguments.view-id'), + $this->trans('commands.debug.views.arguments.view-id'), $views ); $input->setArgument('view-id', $viewId); @@ -97,11 +97,11 @@ protected function execute(InputInterface $input, OutputInterface $output) if (empty($view)) { $io->error( sprintf( - $this->trans('commands.views.debug.messages.not-found'), + $this->trans('commands.debug.views.messages.not-found'), $viewId ) ); - return; + return 1; } try { @@ -114,6 +114,10 @@ protected function execute(InputInterface $input, OutputInterface $output) ); } catch (Exception $e) { $io->error($e->getMessage()); + + return 1; } + + return 0; } } diff --git a/src/Command/Yaml/DiffCommand.php b/src/Command/Yaml/DiffCommand.php deleted file mode 100644 index 41f043b54..000000000 --- a/src/Command/Yaml/DiffCommand.php +++ /dev/null @@ -1,242 +0,0 @@ -nestedArray = $nestedArray; - parent::__construct(); - } - - protected function configure() - { - $this - ->setName('yaml:diff') - ->setDescription($this->trans('commands.yaml.diff.description')) - ->addArgument( - 'yaml-left', - InputArgument::REQUIRED, - $this->trans('commands.yaml.diff.arguments.yaml-left') - ) - ->addArgument( - 'yaml-right', - InputArgument::REQUIRED, - $this->trans('commands.yaml.diff.arguments.yaml-right') - ) - ->addOption( - 'stats', - false, - InputOption::VALUE_NONE, - $this->trans('commands.yaml.diff.options.stats') - ) - ->addOption( - 'negate', - false, - InputOption::VALUE_NONE, - $this->trans('commands.yaml.diff.options.negate') - ) - ->addOption( - 'limit', - null, - InputOption::VALUE_OPTIONAL, - $this->trans('commands.yaml.diff.options.limit') - ) - ->addOption( - 'offset', - null, - InputOption::VALUE_OPTIONAL, - $this->trans('commands.yaml.diff.options.offset') - ); - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $yaml = new Parser(); - - $yaml_left = $input->getArgument('yaml-left'); - $yaml_right = $input->getArgument('yaml-right'); - - $stats = $input->getOption('stats'); - - $negate = $input->getOption('negate'); - - $limit = $input->getOption('limit'); - $offset = $input->getOption('offset'); - - if ($negate == 1 || $negate == 'TRUE') { - $negate = true; - } else { - $negate = false; - } - - try { - $yamlLeftParsed = $yaml->parse(file_get_contents($yaml_left)); - - if (empty($yamlLeftParsed)) { - $io->error( - sprintf( - $this->trans('commands.yaml.merge.messages.wrong-parse'), - $yaml_left - ) - ); - } - - $yamlRightParsed = $yaml->parse(file_get_contents($yaml_right)); - - if (empty($yamlRightParsed)) { - $io->error( - sprintf( - $this->trans('commands.yaml.merge.messages.wrong-parse'), - $yaml_right - ) - ); - } - } catch (\Exception $e) { - $io->error($this->trans('commands.yaml.merge.messages.error-parsing').': '.$e->getMessage()); - - return; - } - - $statistics = ['total' => 0, 'equal'=> 0 , 'diff' => 0]; -/* print_r($yamlLeftParsed); - print_r($yamlRightParsed);*/ - $diff = $this->nestedArray->arrayDiff($yamlLeftParsed, $yamlRightParsed, $negate, $statistics); - print_r($diff); - - if ($stats) { - $io->info( - sprintf( - $this->trans('commands.yaml.diff.messages.total'), - $statistics['total'] - ) - ); - - $io->info( - sprintf( - $this->trans('commands.yaml.diff.messages.diff'), - $statistics['diff'] - ) - ); - - $io->info( - sprintf( - $this->trans('commands.yaml.diff.messages.equal'), - $statistics['equal'] - ) - ); - - return; - } - // FLAT YAML file to display full yaml to be used with command yaml:update:key or yaml:update:value - $diffFlatten = array(); - $keyFlatten = ''; - $this->nestedArray->yamlFlattenArray($diff, $diffFlatten, $keyFlatten); - - if ($limit !== null) { - if (!$offset) { - $offset = 0; - } - $diffFlatten = array_slice($diffFlatten, $offset, $limit); - } - - $tableHeader = [ - $this->trans('commands.yaml.diff.messages.key'), - $this->trans('commands.yaml.diff.messages.value'), - ]; - - $tableRows = []; - foreach ($diffFlatten as $yamlKey => $yamlValue) { - $tableRows[] = [ - $yamlKey, - $yamlValue - ]; - print $yamlKey . "\n"; - print $yamlValue . "\n"; - } - - $io->table($tableHeader, $tableRows, 'compact'); - } - - /** - * {@inheritdoc} - */ - protected function interact(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $validator_filename = function ($value) use ($io) { - if (!strlen(trim($value)) || !is_file($value)) { - $io->error($this->trans('commands.common.errors.invalid-file-path')); - - return false; - } - - return $value; - }; - - // --yaml-left option - $yaml_left = $input->getArgument('yaml-left'); - if (!$yaml_left) { - while (true) { - $yaml_left = $output->ask( - $this->trans('commands.yaml.diff.questions.yaml-left'), - null, - $validator_filename - ); - - if ($yaml_left) { - break; - } - } - - $input->setArgument('yaml-left', $yaml_left); - } - - // --yaml-right option - $yaml_right = $input->getArgument('yaml-right'); - if (!$yaml_right) { - while (true) { - $yaml_right = $output->ask( - $this->trans('commands.yaml.diff.questions.yaml-right'), - null, - $validator_filename - ); - - if ($yaml_right) { - break; - } - } - - $input->setArgument('yaml-right', $yaml_right); - } - } -} diff --git a/src/Command/Yaml/GetValueCommand.php b/src/Command/Yaml/GetValueCommand.php deleted file mode 100644 index 2ecb8b3df..000000000 --- a/src/Command/Yaml/GetValueCommand.php +++ /dev/null @@ -1,95 +0,0 @@ -nestedArray = $nestedArray; - parent::__construct(); - } - - protected function configure() - { - $this - ->setName('yaml:get:value') - ->setDescription($this->trans('commands.yaml.get.value.description')) - ->addArgument( - 'yaml-file', - InputArgument::REQUIRED, - $this->trans('commands.yaml.get.value.arguments.yaml-file') - ) - ->addArgument( - 'yaml-key', - InputArgument::REQUIRED, - $this->trans('commands.yaml.get.value.arguments.yaml-key') - ); - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $yaml = new Parser(); - - $yaml_file = $input->getArgument('yaml-file'); - $yaml_key = $input->getArgument('yaml-key'); - - try { - $yaml_parsed = $yaml->parse(file_get_contents($yaml_file), true); - } catch (\Exception $e) { - $io->error($this->trans('commands.yaml.merge.messages.error-parsing').': '.$e->getMessage()); - return; - } - - if (empty($yaml_parsed)) { - $io->info( - sprintf( - $this->trans('commands.yaml.merge.messages.wrong-parse'), - $yaml_file - ) - ); - } else { - $key_exists = null; - $parents = explode(".", $yaml_key); - $yaml_value = $this->nestedArray->getValue($yaml_parsed, $parents, $key_exists); - - if (!$key_exists) { - $io->info( - sprintf( - $this->trans('commands.yaml.get.value.messages.invalid-key'), - $yaml_key, - $yaml_file - ) - ); - } - - $output->writeln($yaml_value); - } - } -} diff --git a/src/Command/Yaml/MergeCommand.php b/src/Command/Yaml/MergeCommand.php deleted file mode 100644 index 53e1fd60d..000000000 --- a/src/Command/Yaml/MergeCommand.php +++ /dev/null @@ -1,195 +0,0 @@ -setName('yaml:merge') - ->setDescription($this->trans('commands.yaml.merge.description')) - ->addArgument( - 'yaml-destination', - InputArgument::REQUIRED, - $this->trans('commands.yaml.merge.arguments.yaml-destination') - ) - ->addArgument( - 'yaml-files', - InputArgument::IS_ARRAY, - $this->trans('commands.yaml.merge.arguments.yaml-files') - ); - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $yaml = new Parser(); - $dumper = new Dumper(); - - $final_yaml = array(); - $yaml_destination = $input->getArgument('yaml-destination'); - $yaml_files = $input->getArgument('yaml-files'); - - if (count($yaml_files) < 2) { - $io->error($this->trans('commands.yaml.merge.messages.two-files-required')); - - return; - } - - foreach ($yaml_files as $yaml_file) { - try { - $yaml_parsed = $yaml->parse(file_get_contents($yaml_file)); - } catch (\Exception $e) { - $io->error( - sprintf( - '%s: %s', - $this->trans('commands.yaml.merge.messages.error-parsing'), - $e->getMessage() - ) - ); - - return; - } - - if (empty($yaml_parsed)) { - $io->error( - sprintf( - $this->trans('commands.yaml.merge.messages.wrong-parse'), - $yaml_file - ) - ); - } - - // Merge arrays - $final_yaml = array_replace_recursive($final_yaml, $yaml_parsed); - } - - try { - $yaml = $dumper->dump($final_yaml, 10); - } catch (\Exception $e) { - $io->error( - sprintf( - '%s: %s', - $this->trans('commands.yaml.merge.messages.error-generating'), - $e->getMessage() - ) - ); - - return; - } - - try { - file_put_contents($yaml_destination, $yaml); - } catch (\Exception $e) { - $io->error( - sprintf( - '%s: %s', - $this->trans('commands.yaml.merge.messages.error-writing'), - $e->getMessage() - ) - ); - - return; - } - - $io->success( - sprintf( - $this->trans('commands.yaml.merge.messages.merged'), - $yaml_destination - ) - ); - } - - /** - * {@inheritdoc} - */ - protected function interact(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $validator_filename = function ($value) use ($io) { - if (!strlen(trim($value)) || !is_file($value)) { - $io->error($this->trans('commands.common.errors.invalid-file-path')); - - return false; - } - - return $value; - }; - - // --yaml-destination option - $yaml_destination = $input->getArgument('yaml-destination'); - if (!$yaml_destination) { - while (true) { - $yaml_destination = $io->ask( - $this->trans('commands.yaml.merge.questions.yaml-destination'), - '', - $validator_filename - ); - - if ($yaml_destination) { - break; - } - } - - $input->setArgument('yaml-destination', $yaml_destination); - } - - $yaml_files = $input->getArgument('yaml-files'); - if (!$yaml_files) { - $yaml_files = array(); - - while (true) { - $yaml_file = $io->ask( - $this->trans('commands.yaml.merge.questions.file'), - '', - function ($file) use ($yaml_files, $io) { - if (count($yaml_files) < 2 && empty($file)) { - $io->error($this->trans('commands.yaml.merge.questions.invalid-file')); - - return false; - } elseif (in_array($file, $yaml_files)) { - $io->error( - sprintf($this->trans('commands.yaml.merge.questions.file-already-added'), $file) - ); - - return false; - } elseif ($file == '') { - return true; - } else { - return $file; - } - } - ); - - if ($yaml_file && !is_string($yaml_file)) { - break; - } - - if ($yaml_file) { - $yaml_files[] = $yaml_file; - } - } - - $input->setArgument('yaml-files', $yaml_files); - } - } -} diff --git a/src/Command/Yaml/SplitCommand.php b/src/Command/Yaml/SplitCommand.php deleted file mode 100644 index 56392892c..000000000 --- a/src/Command/Yaml/SplitCommand.php +++ /dev/null @@ -1,238 +0,0 @@ -nestedArray = $nestedArray; - parent::__construct(); - } - - protected function configure() - { - $this - ->setName('yaml:split') - ->setDescription($this->trans('commands.yaml.split.description')) - ->addArgument( - 'yaml-file', - InputArgument::REQUIRED, - $this->trans('commands.yaml.split.value.arguments.yaml-file') - ) - ->addOption( - 'indent-level', - false, - InputOption::VALUE_REQUIRED, - $this->trans('commands.yaml.split.options.indent-level') - ) - ->addOption( - 'file-output-prefix', - false, - InputOption::VALUE_REQUIRED, - $this->trans('commands.yaml.split.options.file-output-prefix') - ) - ->addOption( - 'file-output-suffix', - false, - InputOption::VALUE_REQUIRED, - $this->trans('commands.yaml.split.options.file-output-suffix') - ) - ->addOption( - 'starting-key', - false, - InputOption::VALUE_REQUIRED, - $this->trans('commands.yaml.split.options.starting-key') - ) - ->addOption( - 'exclude-parents-key', - false, - InputOption::VALUE_NONE, - $this->trans('commands.yaml.split.options.exclude-parents-key') - ); - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $yaml = new Parser(); - - $yaml_file = $input->getArgument('yaml-file'); - $indent_level = $input->getOption('indent-level'); - $exclude_parents_key = $input->getOption('exclude-parents-key'); - $starting_key = $input->getOption('starting-key'); - $file_output_prefix = $input->getOption('file-output-prefix'); - $file_output_suffix = $input->getOption('file-output-suffix'); - - if ($exclude_parents_key == 1 || $exclude_parents_key == 'TRUE') { - $exclude_parents_key = true; - } else { - $exclude_parents_key = false; - } - - try { - $yaml_file_parsed = $yaml->parse(file_get_contents($yaml_file)); - - if (empty($yaml_file_parsed)) { - $io->error( - sprintf( - $this->trans('commands.yaml.merge.messages.wrong-parse'), - $yaml_file - ) - ); - - return; - } - } catch (\Exception $e) { - $io->error( - sprintf( - '%s: %s', - $this->trans('commands.yaml.merge.messages.error-parsing'), - $e->getMessage() - ) - ); - - return; - } - - if ($starting_key) { - $parents = explode(".", $starting_key); - if ($this->nestedArray->keyExists($yaml_file_parsed, $parents)) { - $yaml_file_parsed = $this->nestedArray->getValue($yaml_file_parsed, $parents); - } else { - $io->error($this->trans('commands.yaml.merge.messages.invalid-key')); - } - - if ($indent_level == 0) { - $yaml_split[$starting_key] = $yaml_file_parsed; - } - } else { - // Set minimum level to split - $indent_level = empty($indent_level) ? 1 : $indent_level; - - $yaml_split = array(); - $key_flatten = ''; - $initial_level = 1; - - $this->nestedArray->yamlSplitArray($yaml_file_parsed, $yaml_split, $indent_level, $key_flatten, $initial_level, $exclude_parents_key); - } - - $this->writeSplittedFile($yaml_split, $file_output_prefix, $file_output_suffix, $io); - } - - protected function writeSplittedFile($yaml_splitted, $file_output_prefix = '', $file_output_suffix = '', DrupalStyle $io) - { - $dumper = new Dumper(); - - $io->info($this->trans('commands.yaml.split.messages.generating-split')); - - foreach ($yaml_splitted as $key => $value) { - if ($file_output_prefix) { - $key = $file_output_prefix . '.' . $key; - } - - if ($file_output_suffix) { - $key.= '.' . $file_output_suffix; - } - $filename = $key . '.yml'; - - try { - $yaml = $dumper->dump($value, 10); - } catch (\Exception $e) { - $io->error( - sprintf( - '%s: %s', - $this->trans('commands.yaml.merge.messages.error-generating'), - $e->getMessage() - ) - ); - - return; - } - - try { - file_put_contents($filename, $yaml); - } catch (\Exception $e) { - $io->error( - sprintf( - '%s: %s', - $this->trans('commands.yaml.merge.messages.error-writing'), - $e->getMessage() - ) - ); - - return; - } - - $io->success( - sprintf( - $this->trans('commands.yaml.split.messages.split-generated'), - $filename - ) - ); - } - } - - /** - * {@inheritdoc} - */ - protected function interact(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $validator_filename = function ($value) use ($io) { - if (!strlen(trim($value)) || !is_file($value)) { - $io->error($this->trans('commands.common.errors.invalid-file-path')); - - return false; - } - - return $value; - }; - - // --yaml-left option - $yaml_file = $input->getArgument('yaml-file'); - if (!$yaml_file) { - while (true) { - $yaml_file = $io->ask( - $this->trans('commands.yaml.diff.questions.yaml-left'), - '', - $validator_filename - ); - - if ($yaml_file) { - break; - } - } - - $input->setArgument('yaml-file', $yaml_file); - } - } -} diff --git a/src/Command/Yaml/UnsetKeyCommand.php b/src/Command/Yaml/UnsetKeyCommand.php deleted file mode 100644 index d744e6bbe..000000000 --- a/src/Command/Yaml/UnsetKeyCommand.php +++ /dev/null @@ -1,108 +0,0 @@ -nestedArray = $nestedArray; - parent::__construct(); - } - - protected function configure() - { - $this - ->setName('yaml:unset:key') - ->setDescription($this->trans('commands.yaml.unset.key.description')) - ->addArgument( - 'yaml-file', - InputArgument::REQUIRED, - $this->trans('commands.yaml.unset.value.arguments.yaml-file') - ) - ->addArgument( - 'yaml-key', - InputArgument::REQUIRED, - $this->trans('commands.yaml.unset.value.arguments.yaml-key') - ); - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $yaml = new Parser(); - $dumper = new Dumper(); - - $yaml_file = $input->getArgument('yaml-file'); - $yaml_key = $input->getArgument('yaml-key'); - - try { - $yaml_parsed = $yaml->parse(file_get_contents($yaml_file)); - } catch (\Exception $e) { - $io->error($this->trans('commands.yaml.merge.messages.error-parsing').': '.$e->getMessage()); - - return; - } - - if (empty($yaml_parsed)) { - $io->info( - sprintf( - $this->trans('commands.yaml.merge.messages.wrong-parse'), - $yaml_file - ) - ); - } - - $parents = explode(".", $yaml_key); - $this->nestedArray->unsetValue($yaml_parsed, $parents); - - try { - $yaml = $dumper->dump($yaml_parsed, 10); - } catch (\Exception $e) { - $io->error($this->trans('commands.yaml.merge.messages.error-generating').': '.$e->getMessage()); - - return; - } - - try { - file_put_contents($yaml_file, $yaml); - } catch (\Exception $e) { - $io->error($this->trans('commands.yaml.merge.messages.error-writing').': '.$e->getMessage()); - - return; - } - - $io->info( - sprintf( - $this->trans('commands.yaml.unset.value.messages.unset'), - $yaml_file - ) - ); - } -} diff --git a/src/Command/Yaml/UpdateKeyCommand.php b/src/Command/Yaml/UpdateKeyCommand.php deleted file mode 100644 index f194837fe..000000000 --- a/src/Command/Yaml/UpdateKeyCommand.php +++ /dev/null @@ -1,116 +0,0 @@ -nestedArray = $nestedArray; - parent::__construct(); - } - - - protected function configure() - { - $this - ->setName('yaml:update:key') - ->setDescription($this->trans('commands.yaml.update.key.description')) - ->addArgument( - 'yaml-file', - InputArgument::REQUIRED, - $this->trans('commands.yaml.update.value.arguments.yaml-file') - ) - ->addArgument( - 'yaml-key', - InputArgument::REQUIRED, - $this->trans('commands.yaml.update.value.arguments.yaml-key') - ) - ->addArgument( - 'yaml-new-key', - InputArgument::REQUIRED, - $this->trans('commands.yaml.update.value.arguments.yaml-new-key') - ); - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $yaml = new Parser(); - $dumper = new Dumper(); - - $yaml_file = $input->getArgument('yaml-file'); - $yaml_key = $input->getArgument('yaml-key'); - $yaml_new_key = $input->getArgument('yaml-new-key'); - - - try { - $yaml_parsed = $yaml->parse(file_get_contents($yaml_file)); - } catch (\Exception $e) { - $io->error($this->trans('commands.yaml.merge.messages.error-parsing').': '.$e->getMessage()); - - return; - } - - if (empty($yaml_parsed)) { - $io->info( - sprintf( - $this->trans('commands.yaml.merge.messages.wrong-parse'), - $yaml_file - ) - ); - } - - $parents = explode(".", $yaml_key); - $this->nestedArray->replaceKey($yaml_parsed, $parents, $yaml_new_key); - - try { - $yaml = $dumper->dump($yaml_parsed, 10); - } catch (\Exception $e) { - $io->error($this->trans('commands.yaml.merge.messages.error-generating').': '.$e->getMessage()); - - return; - } - - try { - file_put_contents($yaml_file, $yaml); - } catch (\Exception $e) { - $io->error($this->trans('commands.yaml.merge.messages.error-writing').': '.$e->getMessage()); - - return; - } - - $io->info( - sprintf( - $this->trans('commands.yaml.update.value.messages.updated'), - $yaml_file - ) - ); - } -} diff --git a/src/Command/Yaml/UpdateValueCommand.php b/src/Command/Yaml/UpdateValueCommand.php deleted file mode 100644 index 76dc11148..000000000 --- a/src/Command/Yaml/UpdateValueCommand.php +++ /dev/null @@ -1,115 +0,0 @@ -nestedArray = $nestedArray; - parent::__construct(); - } - - protected function configure() - { - $this - ->setName('yaml:update:value') - ->setDescription($this->trans('commands.yaml.update.value.description')) - ->addArgument( - 'yaml-file', - InputArgument::REQUIRED, - $this->trans('commands.yaml.update.value.arguments.yaml-file') - ) - ->addArgument( - 'yaml-key', - InputArgument::REQUIRED, - $this->trans('commands.yaml.update.value.arguments.yaml-key') - ) - ->addArgument( - 'yaml-value', - InputArgument::REQUIRED, - $this->trans('commands.yaml.update.value.arguments.yaml-value') - ); - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $yaml = new Parser(); - $dumper = new Dumper(); - - $yaml_file = $input->getArgument('yaml-file'); - $yaml_key = $input->getArgument('yaml-key'); - $yaml_value = $input->getArgument('yaml-value'); - - - try { - $yaml_parsed = $yaml->parse(file_get_contents($yaml_file)); - } catch (\Exception $e) { - $io->error($this->trans('commands.yaml.merge.messages.error-parsing').': '.$e->getMessage()); - return; - } - - if (empty($yaml_parsed)) { - $io->info( - sprintf( - $this->trans('commands.yaml.merge.messages.wrong-parse'), - $yaml_file - ) - ); - } - - $parents = explode(".", $yaml_key); - $this->nestedArray->setValue($yaml_parsed, $parents, $yaml_value, true); - - - try { - $yaml = $dumper->dump($yaml_parsed, 10); - } catch (\Exception $e) { - $io->error($this->trans('commands.yaml.merge.messages.error-generating').': '.$e->getMessage()); - - return; - } - - try { - file_put_contents($yaml_file, $yaml); - } catch (\Exception $e) { - $io->error($this->trans('commands.yaml.merge.messages.error-writing').': '.$e->getMessage()); - - return; - } - - $io->info( - sprintf( - $this->trans('commands.yaml.update.value.messages.updated'), - $yaml_file - ) - ); - } -} diff --git a/src/Extension/Discovery.php b/src/Extension/Discovery.php index 87e440b21..cc66a80c5 100644 --- a/src/Extension/Discovery.php +++ b/src/Extension/Discovery.php @@ -20,6 +20,6 @@ class Discovery extends ExtensionDiscovery */ public static function reset() { - static::$files = array(); + static::$files = []; } } diff --git a/src/Extension/Extension.php b/src/Extension/Extension.php index 4c01152af..6f6c71f11 100644 --- a/src/Extension/Extension.php +++ b/src/Extension/Extension.php @@ -6,6 +6,7 @@ /** * Class Extension + * * @package Drupal\Console\Extension */ class Extension extends BaseExtension @@ -27,9 +28,9 @@ public function getPath($fullPath = false) * @param bool $fullPath * @return string */ - public function getControllerDirectory($fullPath = false) + public function getControllerPath($fullPath = false) { - return $this->getSourcePath($fullPath) . '/Controller/'; + return $this->getSourcePath($fullPath) . '/Controller'; } /** @@ -111,6 +112,6 @@ public function getEntityPath($fullPath = false) */ public function getTemplatePath($fullPath = false) { - return $this->getSourcePath($fullPath) . '/templates'; + return $this->getPath($fullPath) . '/templates'; } } diff --git a/src/Extension/Manager.php b/src/Extension/Manager.php index d7e8171af..4c4a49cb2 100644 --- a/src/Extension/Manager.php +++ b/src/Extension/Manager.php @@ -3,9 +3,12 @@ namespace Drupal\Console\Extension; use Drupal\Console\Utils\Site; +use GuzzleHttp\Client; +use GuzzleHttp\Exception\ClientException; /** * Class ExtensionManager + * * @package Drupal\Console */ class Manager @@ -14,6 +17,12 @@ class Manager * @var Site */ protected $site; + + /** + * @var Client + */ + protected $httpClient; + /** * @var string */ @@ -36,14 +45,18 @@ class Manager /** * ExtensionManager constructor. + * * @param Site $site + * @param Client $httpClient * @param string $appRoot */ public function __construct( Site $site, + Client $httpClient, $appRoot ) { $this->site = $site; + $this->httpClient = $httpClient; $this->appRoot = $appRoot; $this->initialize(); } @@ -108,10 +121,10 @@ public function showNoCore() } /** - * @param string $nameOnly + * @param boolean $nameOnly * @return array */ - public function getList($nameOnly) + public function getList($nameOnly = false) { return $this->getExtensions($this->extension, $nameOnly); } @@ -156,6 +169,8 @@ private function discoverExtension($extension) { $this->extension = $extension; $this->extensions[$extension] = $this->discoverExtensions($extension); + + return $this; } /** @@ -234,6 +249,11 @@ private function discoverExtensions($type) system_rebuild_module_data(); } + if ($type === 'theme') { + $themeHandler = \Drupal::service('theme_handler'); + $themeHandler->rebuildThemeData(); + } + /* * @see Remove DrupalExtensionDiscovery subclass once * https://www.drupal.org/node/2503927 is fixed. @@ -257,6 +277,19 @@ public function getModule($name) return null; } + /** + * @param string $name + * @return \Drupal\Console\Extension\Extension + */ + public function getProfile($name) + { + if ($extension = $this->getExtension('profile', $name)) { + return $this->createExtension($extension); + } + + return null; + } + /** * @param string $name * @return \Drupal\Console\Extension\Extension @@ -307,11 +340,11 @@ private function createExtension($extension) } /** - * @param string $testType + * @param string $testType * @param $fullPath * @return string */ - public function getTestPath( $testType, $fullPath = false) + public function getTestPath($testType, $fullPath = false) { return $this->getPath($fullPath) . '/Tests/' . $testType; } @@ -344,4 +377,51 @@ public function getPluginPath($moduleName, $pluginType) return $module->getPath() . '/src/Plugin/'.$pluginType; } + + public function getDrupalExtension($type, $name) + { + $extension = $this->getExtension($type, $name); + return $this->createExtension($extension); + } + + /** + * @param array $extensions + * @param string $type + * @return array + */ + public function checkExtensions(array $extensions, $type = 'module') + { + $checkextensions = [ + 'local_extensions' => [], + 'drupal_extensions' => [], + 'no_extensions' => [], + ]; + + $local_extensions = $this->discoverExtension($type) + ->showInstalled() + ->showUninstalled() + ->showCore() + ->showNoCore() + ->getList(true); + + foreach ($extensions as $extension) { + if (in_array($extension, $local_extensions)) { + $checkextensions['local_extensions'][] = $extension; + } else { + try { + $response = $this->httpClient->head('https://www.drupal.org/project/' . $extension); + $header_link = explode(';', $response->getHeader('link')); + if (empty($header_link[0])) { + $checkextensions['no_extensions'][] = $extension; + } else { + $checkextensions['drupal_extensions'][] = $extension; + } + } catch (ClientException $e) { + $checkextensions['no_extensions'][] = $extension; + } + } + } + + return $checkextensions; + } } diff --git a/src/Generator/AuthenticationProviderGenerator.php b/src/Generator/AuthenticationProviderGenerator.php index ca7157e1c..4fd53df28 100644 --- a/src/Generator/AuthenticationProviderGenerator.php +++ b/src/Generator/AuthenticationProviderGenerator.php @@ -7,16 +7,19 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class AuthenticationProviderGenerator extends Generator { - - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** * AuthenticationProviderGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( diff --git a/src/Generator/BreakPointGenerator.php b/src/Generator/BreakPointGenerator.php index 693bf4949..7e91e0e35 100644 --- a/src/Generator/BreakPointGenerator.php +++ b/src/Generator/BreakPointGenerator.php @@ -7,20 +7,24 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; /** * Class BreakPointGenerator + * * @package Drupal\Console\Generator */ -class BreakPointGenerator extends Generator +class BreakPointGenerator extends Generator { - - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** * BreakPointGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( diff --git a/src/Generator/CacheContextGenerator.php b/src/Generator/CacheContextGenerator.php new file mode 100644 index 000000000..da87ee974 --- /dev/null +++ b/src/Generator/CacheContextGenerator.php @@ -0,0 +1,64 @@ +extensionManager = $extensionManager; + } + + /** + * Generator Service. + * + * @param string $module Module name + * @param string $cache_context Cache context name + * @param string $class Class name + * @param array $services List of services + */ + public function generate($module, $cache_context, $class, $services) + { + $parameters = [ + 'module' => $module, + 'name' => 'cache_context.' . $cache_context, + 'class' => $class, + 'services' => $services, + 'class_path' => sprintf('Drupal\%s\CacheContext\%s', $module, $class), + 'tags' => ['name' => 'cache.context'], + 'file_exists' => file_exists($this->extensionManager->getModule($module)->getPath() .'/'.$module.'.services.yml'), + ]; + + $this->renderFile( + 'module/src/cache-context.php.twig', + $this->extensionManager->getModule($module)->getSourcePath().'/CacheContext/'.$class.'.php', + $parameters + ); + + $this->renderFile( + 'module/services.yml.twig', + $this->extensionManager->getModule($module)->getPath() .'/'.$module.'.services.yml', + $parameters, + FILE_APPEND + ); + } +} diff --git a/src/Generator/CommandGenerator.php b/src/Generator/CommandGenerator.php index 4a175665a..ff01bd572 100644 --- a/src/Generator/CommandGenerator.php +++ b/src/Generator/CommandGenerator.php @@ -8,35 +8,35 @@ namespace Drupal\Console\Generator; use Drupal\Console\Extension\Manager; -use Drupal\Console\Utils\TranslatorManager; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\Yaml\Yaml; +use Drupal\Console\Core\Utils\TranslatorManagerInterface; +use Drupal\Console\Core\Generator\Generator; /** * Class CommandGenerator + * * @package Drupal\Console\Generator */ class CommandGenerator extends Generator { - /** * @var Manager */ protected $extensionManager; /** - * @var TranslatorManager + * @var TranslatorManagerInterface */ protected $translatorManager; /** * CommandGenerator constructor. - * @param Manager $extensionManager - * @param TranslatorManager $translatorManager + * + * @param Manager $extensionManager + * @param TranslatorManagerInterface $translatorManager */ public function __construct( Manager $extensionManager, - TranslatorManager $translatorManager + TranslatorManagerInterface $translatorManager ) { $this->extensionManager = $extensionManager; $this->translatorManager = $translatorManager; @@ -45,47 +45,50 @@ public function __construct( /** * Generate. * - * @param string $module Module name + * @param string $extension Extension name + * @param string $extensionType Extension type * @param string $name Command name * @param string $class Class name * @param boolean $containerAware Container Aware command * @param array $services Services array */ - public function generate($module, $name, $class, $containerAware, $services) + public function generate($extension, $extensionType, $name, $class, $containerAware, $services) { $command_key = str_replace(':', '.', $name); + $extensionObject = $this->extensionManager->getDrupalExtension($extensionType, $extension); + $parameters = [ - 'module' => $module, + 'extension' => $extension, + 'extensionType' => $extensionType, 'name' => $name, 'class_name' => $class, 'container_aware' => $containerAware, 'command_key' => $command_key, 'services' => $services, 'tags' => ['name' => 'drupal.command'], - 'class_path' => sprintf('Drupal\%s\Command\%s', $module, $class), - 'file_exists' => file_exists($this->extensionManager->getModule($module)->getPath() .'/'.$module.'.services.yml'), + 'class_path' => sprintf('Drupal\%s\Command\%s', $extension, $class), + 'file_exists' => file_exists($extensionObject->getPath().'/console.services.yml'), ]; $this->renderFile( 'module/src/Command/command.php.twig', - $this->extensionManager->getModule($module)->getCommandDirectory().'/'.$class.'.php', + $extensionObject->getCommandDirectory().$class.'.php', $parameters ); - $parameters['name'] = $module.'.'.str_replace(':', '_', $name); + $parameters['name'] = $extension.'.'.str_replace(':', '_', $name); $this->renderFile( 'module/services.yml.twig', - $this->extensionManager->getModule($module)->getPath() .'/'.$module.'.services.yml', + $extensionObject->getPath() .'/console.services.yml', $parameters, FILE_APPEND ); $this->renderFile( 'module/src/Command/console/translations/en/command.yml.twig', - $this->extensionManager->getModule($module)->getPath().'/console/translations/en/'.$command_key.'.yml' + $extensionObject->getPath().'/console/translations/en/'.$command_key.'.yml' ); - } } diff --git a/src/Generator/ControllerGenerator.php b/src/Generator/ControllerGenerator.php index 0736b0168..bb95974d8 100644 --- a/src/Generator/ControllerGenerator.php +++ b/src/Generator/ControllerGenerator.php @@ -7,16 +7,19 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class ControllerGenerator extends Generator { - - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** * AuthenticationProviderGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( @@ -37,7 +40,7 @@ public function generate($module, $class, $routes, $test, $services) $this->renderFile( 'module/src/Controller/controller.php.twig', - $this->extensionManager->getModule($module)->getControllerDirectory().'/'.$class.'.php', + $this->extensionManager->getModule($module)->getControllerPath().'/'.$class.'.php', $parameters ); diff --git a/src/Generator/DatabaseSettingsGenerator.php b/src/Generator/DatabaseSettingsGenerator.php new file mode 100644 index 000000000..9cda1031f --- /dev/null +++ b/src/Generator/DatabaseSettingsGenerator.php @@ -0,0 +1,50 @@ +kernel = $kernel; + } + + + /** + * Generator Plugin Block. + * + * @param $parameters + */ + public function generate($parameters) + { + $settingsFile = $this->kernel->getSitePath().'/settings.php'; + if (!is_writable($settingsFile)) { + return false; + } + return $this->renderFile( + 'database/add.php.twig', + $settingsFile, + $parameters, + FILE_APPEND + ); + } +} diff --git a/src/Generator/EntityBundleGenerator.php b/src/Generator/EntityBundleGenerator.php index 2056fc222..18e6ac6c5 100644 --- a/src/Generator/EntityBundleGenerator.php +++ b/src/Generator/EntityBundleGenerator.php @@ -7,16 +7,19 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class EntityBundleGenerator extends Generator { - - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** * PermissionGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( diff --git a/src/Generator/EntityConfigGenerator.php b/src/Generator/EntityConfigGenerator.php index d415d3a6b..3a4f752b2 100644 --- a/src/Generator/EntityConfigGenerator.php +++ b/src/Generator/EntityConfigGenerator.php @@ -6,17 +6,20 @@ */ namespace Drupal\Console\Generator; + +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class EntityConfigGenerator extends Generator { - - - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** * EntityConfigGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( diff --git a/src/Generator/EntityContentGenerator.php b/src/Generator/EntityContentGenerator.php index 61bc9de0b..3c9f98cce 100644 --- a/src/Generator/EntityContentGenerator.php +++ b/src/Generator/EntityContentGenerator.php @@ -7,15 +7,16 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; use Drupal\Console\Utils\Site; -use Drupal\Console\Utils\TwigRenderer; -use Drupal\Console\Style\DrupalStyle; +use Drupal\Console\Core\Utils\TwigRenderer; class EntityContentGenerator extends Generator { - - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** @@ -23,15 +24,18 @@ class EntityContentGenerator extends Generator */ protected $site; - /** @var TwigRenderer*/ + /** + * @var TwigRenderer +*/ protected $twigrenderer; protected $io; /** * EntityContentGenerator constructor. - * @param Manager $extensionManager - * @param Site $site + * + * @param Manager $extensionManager + * @param Site $site * @param TwigRenderer $twigrenderer */ public function __construct( @@ -60,7 +64,7 @@ public function setIo($io) * @param string $base_path Base path * @param string $is_translatable Translation configuration * @param string $bundle_entity_type (Config) entity type acting as bundle - * @param bool $revisionable Revision configuration + * @param bool $revisionable Revision configuration */ public function generate($module, $entity_name, $entity_class, $label, $base_path, $is_translatable, $bundle_entity_type = null, $revisionable = false) { @@ -178,36 +182,36 @@ public function generate($module, $entity_name, $entity_class, $label, $base_pat ); if ($revisionable) { - $this->renderFile( - 'module/src/Entity/Form/entity-content-revision-delete.php.twig', - $this->extensionManager->getModule($module)->getFormPath() .'/'.$entity_class.'RevisionDeleteForm.php', - $parameters - ); - $this->renderFile( - 'module/src/Entity/Form/entity-content-revision-revert-translation.php.twig', - $this->extensionManager->getModule($module)->getFormPath() .'/'.$entity_class.'RevisionRevertTranslationForm.php', - $parameters - ); - $this->renderFile( - 'module/src/Entity/Form/entity-content-revision-revert.php.twig', - $this->extensionManager->getModule($module)->getFormPath().'/'.$entity_class.'RevisionRevertForm.php', - $parameters - ); - $this->renderFile( - 'module/src/entity-storage.php.twig', - $this->extensionManager->getModule($module)->getSourcePath() .'/'.$entity_class.'Storage.php', - $parameters - ); - $this->renderFile( - 'module/src/interface-entity-storage.php.twig', - $this->extensionManager->getModule($module)->getSourcePath() .'/'.$entity_class.'StorageInterface.php', - $parameters - ); - $this->renderFile( - 'module/src/Controller/entity-controller.php.twig', - $this->extensionManager->getModule($module)->getControllerPath() .'/'.$entity_class.'Controller.php', - $parameters - ); + $this->renderFile( + 'module/src/Entity/Form/entity-content-revision-delete.php.twig', + $this->extensionManager->getModule($module)->getFormPath() .'/'.$entity_class.'RevisionDeleteForm.php', + $parameters + ); + $this->renderFile( + 'module/src/Entity/Form/entity-content-revision-revert-translation.php.twig', + $this->extensionManager->getModule($module)->getFormPath() .'/'.$entity_class.'RevisionRevertTranslationForm.php', + $parameters + ); + $this->renderFile( + 'module/src/Entity/Form/entity-content-revision-revert.php.twig', + $this->extensionManager->getModule($module)->getFormPath().'/'.$entity_class.'RevisionRevertForm.php', + $parameters + ); + $this->renderFile( + 'module/src/entity-storage.php.twig', + $this->extensionManager->getModule($module)->getSourcePath() .'/'.$entity_class.'Storage.php', + $parameters + ); + $this->renderFile( + 'module/src/interface-entity-storage.php.twig', + $this->extensionManager->getModule($module)->getSourcePath() .'/'.$entity_class.'StorageInterface.php', + $parameters + ); + $this->renderFile( + 'module/src/Controller/entity-controller.php.twig', + $this->extensionManager->getModule($module)->getControllerPath() .'/'.$entity_class.'Controller.php', + $parameters + ); } if ($bundle_entity_type) { diff --git a/src/Generator/EventSubscriberGenerator.php b/src/Generator/EventSubscriberGenerator.php index 5adb9f618..f53178be2 100644 --- a/src/Generator/EventSubscriberGenerator.php +++ b/src/Generator/EventSubscriberGenerator.php @@ -7,15 +7,19 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class EventSubscriberGenerator extends Generator { - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** * AuthenticationProviderGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( @@ -42,7 +46,7 @@ public function generate($module, $name, $class, $events, $services) 'class_path' => sprintf('Drupal\%s\EventSubscriber\%s', $module, $class), 'events' => $events, 'services' => $services, - 'tags' => array('name' => 'event_subscriber'), + 'tags' => ['name' => 'event_subscriber'], 'file_exists' => file_exists($this->extensionManager->getModule($module)->getPath() .'/'.$module.'.services.yml'), ]; diff --git a/src/Generator/FormAlterGenerator.php b/src/Generator/FormAlterGenerator.php index 32ff7fd2f..19fba6d82 100644 --- a/src/Generator/FormAlterGenerator.php +++ b/src/Generator/FormAlterGenerator.php @@ -7,16 +7,19 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class FormAlterGenerator extends Generator { - - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** * AuthenticationProviderGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( diff --git a/src/Generator/FormGenerator.php b/src/Generator/FormGenerator.php index 3d6077f8e..d19897480 100644 --- a/src/Generator/FormGenerator.php +++ b/src/Generator/FormGenerator.php @@ -7,12 +7,15 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; -use Drupal\Console\Utils\StringConverter; +use Drupal\Console\Core\Utils\StringConverter; class FormGenerator extends Generator { - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** @@ -22,7 +25,8 @@ class FormGenerator extends Generator /** * AuthenticationProviderGenerator constructor. - * @param Manager $extensionManager + * + * @param Manager $extensionManager * @param StringConverter $stringConverter */ public function __construct( @@ -37,6 +41,7 @@ public function __construct( * @param $module * @param $class_name * @param $services + * @param $config_file * @param $inputs * @param $form_id * @param $form_type @@ -46,15 +51,16 @@ public function __construct( * @param $menu_parent * @param $menu_link_desc */ - public function generate($module, $class_name, $form_id, $form_type, $services, $inputs, $path, $menu_link_gen, $menu_link_title, $menu_parent, $menu_link_desc) + public function generate($module, $class_name, $form_id, $form_type, $services, $config_file, $inputs, $path, $menu_link_gen, $menu_link_title, $menu_parent, $menu_link_desc) { $class_name_short = strtolower( $this->stringConverter->removeSuffix($class_name) ); - $parameters = array( + $parameters = [ 'class_name' => $class_name, 'services' => $services, + 'config_file' => $config_file, 'inputs' => $inputs, 'module_name' => $module, 'form_id' => $form_id, @@ -64,7 +70,7 @@ public function generate($module, $class_name, $form_id, $form_type, $services, 'menu_parent' => $menu_parent, 'menu_link_desc' => $menu_link_desc, 'class_name_short' => $class_name_short - ); + ]; if ($form_type == 'ConfigFormBase') { $template = 'module/src/Form/form-config.php.twig'; @@ -86,13 +92,15 @@ public function generate($module, $class_name, $form_id, $form_type, $services, $this->extensionManager->getModule($module)->getFormPath() .'/'.$class_name.'.php', $parameters ); - + // Render defaults YML file. - $this->renderFile( - 'module/config/install/field.default.yml.twig', - $this->extensionManager->getModule($module)->getPath() .'/config/install/'.$module.'.'.$class_name_short.'.yml', - $parameters - ); + if ($config_file == true) { + $this->renderFile( + 'module/config/install/field.default.yml.twig', + $this->extensionManager->getModule($module)->getPath() .'/config/install/'.$module.'.'.$class_name_short.'.yml', + $parameters + ); + } if ($menu_link_gen == true) { $this->renderFile( diff --git a/src/Generator/GeneratorInterface.php b/src/Generator/GeneratorInterface.php deleted file mode 100644 index 83a61a760..000000000 --- a/src/Generator/GeneratorInterface.php +++ /dev/null @@ -1,8 +0,0 @@ -renderFile( - 'module/src/help.php.twig', + 'module/help.php.twig', $module_path .'/'.$module.'.module', $parameters, FILE_APPEND diff --git a/src/Generator/ModuleFileGenerator.php b/src/Generator/ModuleFileGenerator.php index f74656135..8f8e84e47 100644 --- a/src/Generator/ModuleFileGenerator.php +++ b/src/Generator/ModuleFileGenerator.php @@ -7,8 +7,11 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; + /** * Class ModuleFileGenerator + * * @package Drupal\Console\Generator */ class ModuleFileGenerator extends Generator @@ -34,10 +37,10 @@ public function generate( } } - $parameters = array( + $parameters = [ 'machine_name' => $machine_name, 'file_path' => $file_path , - ); + ]; if ($machine_name) { $this->renderFile( diff --git a/src/Generator/ModuleGenerator.php b/src/Generator/ModuleGenerator.php index 4ddbad95d..f7c2ed0a7 100644 --- a/src/Generator/ModuleGenerator.php +++ b/src/Generator/ModuleGenerator.php @@ -7,8 +7,11 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; + /** * Class ModuleGenerator + * * @package Drupal\Console\Generator */ class ModuleGenerator extends Generator @@ -25,6 +28,7 @@ class ModuleGenerator extends Generator * @param $composer * @param $dependencies * @param $test + * @param $twigtemplate */ public function generate( $module, @@ -37,7 +41,8 @@ public function generate( $featuresBundle, $composer, $dependencies, - $test + $test, + $twigtemplate ) { $dir .= '/'.$machineName; if (file_exists($dir)) { @@ -50,7 +55,7 @@ public function generate( ); } $files = scandir($dir); - if ($files != array('.', '..')) { + if ($files != ['.', '..']) { throw new \RuntimeException( sprintf( 'Unable to generate the module as the target directory "%s" is not empty.', @@ -68,7 +73,7 @@ public function generate( } } - $parameters = array( + $parameters = [ 'module' => $module, 'machine_name' => $machineName, 'type' => 'module', @@ -77,7 +82,8 @@ public function generate( 'package' => $package, 'dependencies' => $dependencies, 'test' => $test, - ); + 'twigtemplate' => $twigtemplate, + ]; $this->renderFile( 'module/info.yml.twig', @@ -89,18 +95,15 @@ public function generate( $this->renderFile( 'module/features.yml.twig', $dir.'/'.$machineName.'.features.yml', - array( + [ 'bundle' => $featuresBundle, - ) + ] ); } if ($moduleFile) { - $this->renderFile( - 'module/module.twig', - $dir . '/' . $machineName . '.module', - $parameters - ); + // Generate '.module' file. + $this->createModuleFile($dir, $parameters); } if ($composer) { @@ -114,9 +117,72 @@ public function generate( if ($test) { $this->renderFile( 'module/src/Tests/load-test.php.twig', - $dir . '/src/Tests/' . 'LoadTest.php', + $dir . '/tests/src/Functional/' . 'LoadTest.php', + $parameters + ); + } + if ($twigtemplate) { + // If module file is not created earlier, create now. + if (!$moduleFile) { + // Generate '.module' file. + $this->createModuleFile($dir, $parameters); + } + $this->renderFile( + 'module/module-twig-template-append.twig', + $dir .'/' . $machineName . '.module', + $parameters, + FILE_APPEND + ); + $dir .= '/templates/'; + if (file_exists($dir)) { + if (!is_dir($dir)) { + throw new \RuntimeException( + sprintf( + 'Unable to generate the templates directory as the target directory "%s" exists but is a file.', + realpath($dir) + ) + ); + } + $files = scandir($dir); + if ($files != ['.', '..']) { + throw new \RuntimeException( + sprintf( + 'Unable to generate the templates directory as the target directory "%s" is not empty.', + realpath($dir) + ) + ); + } + if (!is_writable($dir)) { + throw new \RuntimeException( + sprintf( + 'Unable to generate the templates directory as the target directory "%s" is not writable.', + realpath($dir) + ) + ); + } + } + $this->renderFile( + 'module/twig-template-file.twig', + $dir . str_replace("_", "-", $machineName) . '.html.twig', $parameters ); } } + + /** + * Generate the '.module' file. + * + * @param string $dir + * The directory name. + * @param array $parameters + * The parameter array. + */ + protected function createModuleFile($dir, $parameters) + { + $this->renderFile( + 'module/module.twig', + $dir . '/' . $parameters['machine_name'] . '.module', + $parameters + ); + } } diff --git a/src/Generator/PermissionGenerator.php b/src/Generator/PermissionGenerator.php index 70a511f53..643b1f4ba 100644 --- a/src/Generator/PermissionGenerator.php +++ b/src/Generator/PermissionGenerator.php @@ -7,17 +7,19 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class PermissionGenerator extends Generator { - - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; - /** * PermissionGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( @@ -29,13 +31,14 @@ public function __construct( /** * @param $module * @param $permissions + * @param $learning */ - public function generate($module, $permissions) + public function generate($module, $permissions, $learning) { - $parameters = array( + $parameters = [ 'module_name' => $module, 'permissions' => $permissions, - ); + ]; $this->renderFile( 'module/permission.yml.twig', @@ -44,12 +47,12 @@ public function generate($module, $permissions) FILE_APPEND ); - $content = $this->getRenderHelper()->render( + $content = $this->renderer->render( 'module/permission-routing.yml.twig', $parameters ); - if ($this->isLearning()) { + if ($learning) { echo 'You can use this permission in the routing file like this:'.PHP_EOL; echo $content; } diff --git a/src/Generator/PluginBlockGenerator.php b/src/Generator/PluginBlockGenerator.php index ed92d2e11..3755ae193 100644 --- a/src/Generator/PluginBlockGenerator.php +++ b/src/Generator/PluginBlockGenerator.php @@ -7,6 +7,7 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class PluginBlockGenerator extends Generator @@ -18,6 +19,7 @@ class PluginBlockGenerator extends Generator /** * PermissionGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( @@ -40,37 +42,33 @@ public function generate($module, $class_name, $label, $plugin_id, $services, $i // Consider the type when determining a default value. Figure out what // the code looks like for the default value tht we need to generate. foreach ($inputs as &$input) { - $default_code = '$this->t(\'\')'; - if ($input['default_value'] == '') { - switch ($input['type']) { - case 'checkbox': - case 'number': - case 'weight': - case 'radio': - $default_code = 0; - break; + $default_code = '$this->t(\'\')'; + if ($input['default_value'] == '') { + switch ($input['type']) { + case 'checkbox': + case 'number': + case 'weight': + case 'radio': + $default_code = 0; + break; - case 'radios': - case 'checkboxes': - $default_code = 'array()'; - break; + case 'radios': + case 'checkboxes': + $default_code = 'array()'; + break; + } + } elseif (substr($input['default_value'], 0, 1) == '$') { + // If they want to put in code, let them, they're programmers. + $default_code = $input['default_value']; + } elseif (is_numeric($input['default_value'])) { + $default_code = $input['default_value']; + } elseif (preg_match('/^(true|false)$/i', $input['default_value'])) { + // Coding Standards + $default_code = strtoupper($input['default_value']); + } else { + $default_code = '$this->t(\'' . $input['default_value'] . '\')'; } - } - elseif (substr($input['default_value'], 0, 1) == '$') { - // If they want to put in code, let them, they're programmers. - $default_code = $input['default_value']; - } - elseif (is_numeric($input['default_value'])) { - $default_code = $input['default_value']; - } - elseif (preg_match('/^(true|false)$/i', $input['default_value'])) { - // Coding Standards - $default_code = strtoupper($input['default_value']); - } - else { - $default_code = '$this->t(\'' . $input['default_value'] . '\')'; - } - $input['default_code'] = $default_code; + $input['default_code'] = $default_code; } $parameters = [ diff --git a/src/Generator/PluginCKEditorButtonGenerator.php b/src/Generator/PluginCKEditorButtonGenerator.php index ab2b2604e..bcbef106b 100644 --- a/src/Generator/PluginCKEditorButtonGenerator.php +++ b/src/Generator/PluginCKEditorButtonGenerator.php @@ -7,18 +7,19 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class PluginCKEditorButtonGenerator extends Generator { - - - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; - /** * PermissionGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( @@ -27,7 +28,6 @@ public function __construct( $this->extensionManager = $extensionManager; } - /** * Generator Plugin CKEditor Button. * diff --git a/src/Generator/PluginConditionGenerator.php b/src/Generator/PluginConditionGenerator.php index 858b3d802..3b6fa9ad8 100644 --- a/src/Generator/PluginConditionGenerator.php +++ b/src/Generator/PluginConditionGenerator.php @@ -7,21 +7,24 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; /** * Class PluginConditionGenerator + * * @package Drupal\Console\Generator */ class PluginConditionGenerator extends Generator { - - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; - /** * PluginConditionGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( diff --git a/src/Generator/PluginFieldFormatterGenerator.php b/src/Generator/PluginFieldFormatterGenerator.php index 97c5dff33..b97fee7e3 100644 --- a/src/Generator/PluginFieldFormatterGenerator.php +++ b/src/Generator/PluginFieldFormatterGenerator.php @@ -7,12 +7,14 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class PluginFieldFormatterGenerator extends Generator { /** * PluginFieldFormatterGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( diff --git a/src/Generator/PluginFieldTypeGenerator.php b/src/Generator/PluginFieldTypeGenerator.php index b33129d21..75f832a9d 100644 --- a/src/Generator/PluginFieldTypeGenerator.php +++ b/src/Generator/PluginFieldTypeGenerator.php @@ -7,12 +7,14 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class PluginFieldTypeGenerator extends Generator { /** * PluginFieldTypeGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( @@ -21,7 +23,6 @@ public function __construct( $this->extensionManager = $extensionManager; } - /** * Generator Plugin Field Type. * diff --git a/src/Generator/PluginFieldWidgetGenerator.php b/src/Generator/PluginFieldWidgetGenerator.php index 1528eff48..3e252e296 100644 --- a/src/Generator/PluginFieldWidgetGenerator.php +++ b/src/Generator/PluginFieldWidgetGenerator.php @@ -7,12 +7,14 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class PluginFieldWidgetGenerator extends Generator { /** * PluginFieldWidgetGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( diff --git a/src/Generator/PluginImageEffectGenerator.php b/src/Generator/PluginImageEffectGenerator.php index c8c5994ce..fa56ef27b 100644 --- a/src/Generator/PluginImageEffectGenerator.php +++ b/src/Generator/PluginImageEffectGenerator.php @@ -7,12 +7,14 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class PluginImageEffectGenerator extends Generator { /** * PluginImageEffectGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( diff --git a/src/Generator/PluginImageFormatterGenerator.php b/src/Generator/PluginImageFormatterGenerator.php index b9d43dbfc..e71e739eb 100644 --- a/src/Generator/PluginImageFormatterGenerator.php +++ b/src/Generator/PluginImageFormatterGenerator.php @@ -7,12 +7,14 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class PluginImageFormatterGenerator extends Generator { /** * PluginImageFormatterGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( diff --git a/src/Generator/PluginMailGenerator.php b/src/Generator/PluginMailGenerator.php index edc247cd7..0c053b5d8 100644 --- a/src/Generator/PluginMailGenerator.php +++ b/src/Generator/PluginMailGenerator.php @@ -7,12 +7,14 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class PluginMailGenerator extends Generator { /** * PluginMailGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( diff --git a/src/Generator/PluginMigrateProcessGenerator.php b/src/Generator/PluginMigrateProcessGenerator.php new file mode 100644 index 000000000..227a5eda8 --- /dev/null +++ b/src/Generator/PluginMigrateProcessGenerator.php @@ -0,0 +1,52 @@ +extensionManager = $extensionManager; + } + + /** + * Generate Migrate Source plugin code. + * + * @param $module + * @param $class_name + * @param $plugin_id + */ + public function generate($module, $class_name, $plugin_id) + { + $parameters = [ + 'module' => $module, + 'class_name' => $class_name, + 'plugin_id' => $plugin_id, + ]; + + $this->renderFile( + 'module/src/Plugin/migrate/process/process.php.twig', + $this->extensionManager->getPluginPath($module, 'migrate').'/process/'.$class_name.'.php', + $parameters + ); + } +} diff --git a/src/Generator/PluginMigrateSourceGenerator.php b/src/Generator/PluginMigrateSourceGenerator.php new file mode 100644 index 000000000..123fab82c --- /dev/null +++ b/src/Generator/PluginMigrateSourceGenerator.php @@ -0,0 +1,60 @@ +extensionManager = $extensionManager; + } + + /** + * Generate Migrate Source plugin code. + * + * @param $module + * @param $class_name + * @param $plugin_id + * @param $table + * @param $alias + * @param $group_by + * @param fields + */ + public function generate($module, $class_name, $plugin_id, $table, $alias, $group_by, $fields) + { + $parameters = [ + 'module' => $module, + 'class_name' => $class_name, + 'plugin_id' => $plugin_id, + 'table' => $table, + 'alias' => $alias, + 'group_by' => $group_by, + 'fields' => $fields, + ]; + + $this->renderFile( + 'module/src/Plugin/migrate/source/source.php.twig', + $this->extensionManager->getPluginPath($module, 'migrate').'/source/'.$class_name.'.php', + $parameters + ); + } +} diff --git a/src/Generator/PluginRestResourceGenerator.php b/src/Generator/PluginRestResourceGenerator.php index 38734b4fe..05518ce81 100644 --- a/src/Generator/PluginRestResourceGenerator.php +++ b/src/Generator/PluginRestResourceGenerator.php @@ -7,12 +7,19 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class PluginRestResourceGenerator extends Generator { + /** + * @var Manager + */ + protected $extensionManager; + /** * PluginRestResourceGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( diff --git a/src/Generator/PluginRulesActionGenerator.php b/src/Generator/PluginRulesActionGenerator.php index 10455c2e3..a60ee380c 100644 --- a/src/Generator/PluginRulesActionGenerator.php +++ b/src/Generator/PluginRulesActionGenerator.php @@ -7,13 +7,19 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class PluginRulesActionGenerator extends Generator { + /** + * @var Manager + */ + protected $extensionManager; /** * PluginRulesActionGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( diff --git a/src/Generator/PluginSkeletonGenerator.php b/src/Generator/PluginSkeletonGenerator.php index 4b98165c0..1e80864f4 100644 --- a/src/Generator/PluginSkeletonGenerator.php +++ b/src/Generator/PluginSkeletonGenerator.php @@ -7,12 +7,19 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class PluginSkeletonGenerator extends Generator { + /** + * @var Manager + */ + protected $extensionManager; + /** * PluginSkeletonGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( @@ -26,7 +33,7 @@ public function __construct( * * @param $module * @param $pluginId - * * @param $plugin + * @param $plugin * @param $className * @param $pluginMetaData * @param $services @@ -35,7 +42,6 @@ public function generate($module, $pluginId, $plugin, $className, $pluginMetaDat { $module_path = $this->extensionManager->getModule($module)->getPath(); - $parameters = [ 'module' => $module, 'plugin_id' => $pluginId, diff --git a/src/Generator/PluginTypeAnnotationGenerator.php b/src/Generator/PluginTypeAnnotationGenerator.php index 8c3683fc8..2a5181f17 100644 --- a/src/Generator/PluginTypeAnnotationGenerator.php +++ b/src/Generator/PluginTypeAnnotationGenerator.php @@ -7,12 +7,19 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class PluginTypeAnnotationGenerator extends Generator { + /** + * @var Manager + */ + protected $extensionManager; + /** * PluginTypeAnnotationGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( diff --git a/src/Generator/PluginTypeYamlGenerator.php b/src/Generator/PluginTypeYamlGenerator.php index 04eff53e0..8dd2807fb 100644 --- a/src/Generator/PluginTypeYamlGenerator.php +++ b/src/Generator/PluginTypeYamlGenerator.php @@ -7,12 +7,19 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class PluginTypeYamlGenerator extends Generator { + /** + * @var Manager + */ + protected $extensionManager; + /** * PluginTypeYamlGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( diff --git a/src/Generator/PluginViewsFieldGenerator.php b/src/Generator/PluginViewsFieldGenerator.php index 924cb1513..3d0d03681 100644 --- a/src/Generator/PluginViewsFieldGenerator.php +++ b/src/Generator/PluginViewsFieldGenerator.php @@ -7,15 +7,19 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class PluginViewsFieldGenerator extends Generator { - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** * PluginViewsFieldGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( diff --git a/src/Generator/PostUpdateGenerator.php b/src/Generator/PostUpdateGenerator.php index 0f3c31acd..c3c10db7b 100644 --- a/src/Generator/PostUpdateGenerator.php +++ b/src/Generator/PostUpdateGenerator.php @@ -7,15 +7,19 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class PostUpdateGenerator extends Generator { - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** * PostUpdateGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( @@ -41,7 +45,7 @@ public function generate($module, $post_update_name) ]; $this->renderFile( - 'module/src/post-update.php.twig', + 'module/post-update.php.twig', $module_path .'/'.$module.'.post_update.php', $parameters, FILE_APPEND diff --git a/src/Generator/ProfileGenerator.php b/src/Generator/ProfileGenerator.php index fb6c5a28e..8d0857c1a 100644 --- a/src/Generator/ProfileGenerator.php +++ b/src/Generator/ProfileGenerator.php @@ -7,6 +7,8 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; + class ProfileGenerator extends Generator { public function generate( @@ -16,6 +18,7 @@ public function generate( $description, $core, $dependencies, + $themes, $distribution ) { $dir = $profile_path . '/' . $machine_name; @@ -30,7 +33,7 @@ public function generate( ); } $files = scandir($dir); - if ($files != array('.', '..')) { + if ($files != ['.', '..']) { throw new \RuntimeException( sprintf( 'Unable to generate the profile as the target directory "%s" is not empty.', @@ -48,15 +51,16 @@ public function generate( } } - $parameters = array( + $parameters = [ 'profile' => $profile, 'machine_name' => $machine_name, 'type' => 'profile', 'core' => $core, 'description' => $description, 'dependencies' => $dependencies, + 'themes' => $themes, 'distribution' => $distribution, - ); + ]; $this->renderFile( 'profile/info.yml.twig', diff --git a/src/Generator/RouteSubscriberGenerator.php b/src/Generator/RouteSubscriberGenerator.php index d7ced3cd7..388991f37 100644 --- a/src/Generator/RouteSubscriberGenerator.php +++ b/src/Generator/RouteSubscriberGenerator.php @@ -7,15 +7,19 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class RouteSubscriberGenerator extends Generator { - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** * AuthenticationProviderGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( @@ -38,7 +42,7 @@ public function generate($module, $name, $class) 'name' => $name, 'class' => $class, 'class_path' => sprintf('Drupal\%s\Routing\%s', $module, $class), - 'tags' => array('name' => 'event_subscriber'), + 'tags' => ['name' => 'event_subscriber'], 'file_exists' => file_exists($this->extensionManager->getModule($module)->getPath() .'/'.$module.'.services.yml'), ]; diff --git a/src/Generator/ServiceGenerator.php b/src/Generator/ServiceGenerator.php index bad04e973..855839f80 100644 --- a/src/Generator/ServiceGenerator.php +++ b/src/Generator/ServiceGenerator.php @@ -7,15 +7,19 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class ServiceGenerator extends Generator { - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** * AuthenticationProviderGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( diff --git a/src/Generator/ThemeGenerator.php b/src/Generator/ThemeGenerator.php index 8b1633b6a..78342bf98 100644 --- a/src/Generator/ThemeGenerator.php +++ b/src/Generator/ThemeGenerator.php @@ -7,6 +7,7 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; /** @@ -14,12 +15,14 @@ */ class ThemeGenerator extends Generator { - - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** * AuthenticationProviderGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( @@ -37,6 +40,7 @@ public function generate( $package, $base_theme, $global_library, + $libraries, $regions, $breakpoints ) { @@ -51,7 +55,7 @@ public function generate( ); } $files = scandir($dir); - if ($files != array('.', '..')) { + if ($files != ['.', '..']) { throw new \RuntimeException( sprintf( 'Unable to generate the bundle as the target directory "%s" is not empty.', @@ -69,7 +73,7 @@ public function generate( } } - $parameters = array( + $parameters = [ 'theme' => $theme, 'machine_name' => $machine_name, 'type' => 'theme', @@ -78,9 +82,10 @@ public function generate( 'package' => $package, 'base_theme' => $base_theme, 'global_library' => $global_library, + 'libraries' => $libraries, 'regions' => $regions, 'breakpoints' => $breakpoints, - ); + ]; $this->renderFile( 'theme/info.yml.twig', @@ -94,6 +99,14 @@ public function generate( $parameters ); + if ($libraries) { + $this->renderFile( + 'theme/libraries.yml.twig', + $dir . '/' . $machine_name . '.libraries.yml', + $parameters + ); + } + if ($breakpoints) { $this->renderFile( 'theme/breakpoints.yml.twig', diff --git a/src/Generator/TwigExtensionGenerator.php b/src/Generator/TwigExtensionGenerator.php index de5b95400..91c522023 100644 --- a/src/Generator/TwigExtensionGenerator.php +++ b/src/Generator/TwigExtensionGenerator.php @@ -7,19 +7,24 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; /** * Class TwigExtensionGenerator + * * @package Drupal\Console\Generator */ class TwigExtensionGenerator extends Generator { - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** * AuthenticationProviderGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( diff --git a/src/Generator/UpdateGenerator.php b/src/Generator/UpdateGenerator.php index 5d879caa4..55180668d 100644 --- a/src/Generator/UpdateGenerator.php +++ b/src/Generator/UpdateGenerator.php @@ -7,15 +7,19 @@ namespace Drupal\Console\Generator; +use Drupal\Console\Core\Generator\Generator; use Drupal\Console\Extension\Manager; class UpdateGenerator extends Generator { - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** * AuthenticationProviderGenerator constructor. + * * @param Manager $extensionManager */ public function __construct( @@ -32,16 +36,18 @@ public function __construct( */ public function generate($module, $update_number) { + $modulePath = $this->extensionManager->getModule($module)->getPath(); + $updateFile = $modulePath .'/'.$module.'.install'; + $parameters = [ 'module' => $module, 'update_number' => $update_number, + 'file_exists' => file_exists($updateFile) ]; - $module_path = $this->extensionManager->getModule($module)->getPath(); - $this->renderFile( - 'module/src/update.php.twig', - $module_path .'/'.$module.'.module', + 'module/update.php.twig', + $updateFile, $parameters, FILE_APPEND ); diff --git a/src/Plugin/ScriptHandler.php b/src/Plugin/ScriptHandler.php new file mode 100644 index 000000000..3c13f15ba --- /dev/null +++ b/src/Plugin/ScriptHandler.php @@ -0,0 +1,28 @@ +getComposer()->getPackage()->getRequires()); + if (!$packages) { + return; + } + } +} diff --git a/src/Utils/AnnotationValidator.php b/src/Utils/AnnotationValidator.php index 4154fc148..9e46c4c42 100644 --- a/src/Utils/AnnotationValidator.php +++ b/src/Utils/AnnotationValidator.php @@ -7,10 +7,11 @@ /** * Class AnnotationValidator + * * @package Drupal\Console\Utils */ -class AnnotationValidator { - +class AnnotationValidator +{ /** * @var DrupalCommandAnnotationReader */ @@ -26,6 +27,7 @@ class AnnotationValidator { /** * AnnotationValidator constructor. + * * @param DrupalCommandAnnotationReader $annotationCommandReader * @param Manager $extensionManager */ @@ -41,7 +43,8 @@ public function __construct( * @param $class * @return bool */ - public function isValidCommand($class) { + public function isValidCommand($class) + { $annotation = $this->annotationCommandReader->readAnnotation($class); if (!$annotation) { return true; @@ -66,25 +69,26 @@ public function isValidCommand($class) { * @param $extension * @return bool */ - protected function isExtensionInstalled($extension){ + protected function isExtensionInstalled($extension) + { if (!$this->extensions) { - $modules = $this->extensionManager->discoverModules() + $modules = $this->extensionManager->discoverModules() ->showCore() ->showNoCore() ->showInstalled() - ->getList(TRUE); + ->getList(true); $themes = $this->extensionManager->discoverThemes() ->showCore() ->showNoCore() ->showInstalled() - ->getList(TRUE); + ->getList(true); $profiles = $this->extensionManager->discoverProfiles() ->showCore() ->showNoCore() ->showInstalled() - ->getList(TRUE); + ->getList(true); $this->extensions = array_merge( $modules, @@ -100,9 +104,12 @@ protected function isExtensionInstalled($extension){ * @param $annotation * @return array */ - protected function extractDependencies($annotation) { + protected function extractDependencies($annotation) + { $dependencies = []; - if (array_key_exists('extension', $annotation)) { + $extension = array_key_exists('extension', $annotation) ? $annotation['extension'] : null; + $extensionType = array_key_exists('extensionType', $annotation) ? $annotation['extensionType'] : null; + if ($extension && $extensionType != 'library') { $dependencies[] = $annotation['extension']; } if (array_key_exists('dependencies', $annotation)) { @@ -111,4 +118,4 @@ protected function extractDependencies($annotation) { return $dependencies; } -} \ No newline at end of file +} diff --git a/src/Utils/Create/Base.php b/src/Utils/Create/Base.php index c73e74529..660c778c7 100644 --- a/src/Utils/Create/Base.php +++ b/src/Utils/Create/Base.php @@ -16,6 +16,7 @@ /** * Class ContentNode + * * @package Drupal\Console\Utils */ abstract class Base @@ -37,6 +38,7 @@ abstract class Base /** * ContentNode constructor. + * * @param EntityTypeManagerInterface $entityTypeManager * @param EntityFieldManagerInterface $entityFieldManager * @param DateFormatterInterface $dateFormatter diff --git a/src/Utils/Create/CommentData.php b/src/Utils/Create/CommentData.php index bca5b7072..1a6b9cca8 100644 --- a/src/Utils/Create/CommentData.php +++ b/src/Utils/Create/CommentData.php @@ -13,6 +13,7 @@ /** * Class Nodes + * * @package Drupal\Console\Utils\Create */ class CommentData extends Base diff --git a/src/Utils/Create/NodeData.php b/src/Utils/Create/NodeData.php index 27ba3fe04..da6405112 100644 --- a/src/Utils/Create/NodeData.php +++ b/src/Utils/Create/NodeData.php @@ -14,6 +14,7 @@ /** * Class Nodes + * * @package Drupal\Console\Utils */ class NodeData extends Base @@ -55,7 +56,8 @@ public function create( $contentTypes, $limit, $titleWords, - $timeRange + $timeRange, + $language = LanguageInterface::LANGCODE_NOT_SPECIFIED ) { $nodes = []; for ($i=0; $i<$limit; $i++) { @@ -71,7 +73,7 @@ public function create( 'revision' => mt_rand(0, 1), 'status' => true, 'promote' => mt_rand(0, 1), - 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED + 'langcode' => $language ] ); diff --git a/src/Utils/Create/TermData.php b/src/Utils/Create/TermData.php index 57ca1176d..51868ae25 100644 --- a/src/Utils/Create/TermData.php +++ b/src/Utils/Create/TermData.php @@ -14,6 +14,7 @@ /** * Class Terms + * * @package Drupal\Console\Utils */ class TermData extends Base @@ -64,10 +65,10 @@ public function create( [ 'vid' => $vocabulary, 'name' => $this->getRandom()->sentences(mt_rand(1, $nameWords), true), - 'description' => array( - 'value' => $this->getRandom()->sentences(), + 'description' => [ + 'value' => $this->getRandom()->sentences(mt_rand(1, $nameWords)), 'format' => 'full_html', - ), + ], 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, ] ); diff --git a/src/Utils/Create/UserData.php b/src/Utils/Create/UserData.php index 5e1671de5..e60907b31 100644 --- a/src/Utils/Create/UserData.php +++ b/src/Utils/Create/UserData.php @@ -13,6 +13,7 @@ /** * Class Users + * * @package Drupal\Console\Utils\Create */ class UserData extends Base diff --git a/src/Utils/Create/VocabularyData.php b/src/Utils/Create/VocabularyData.php index 337d06b0f..a0b853d55 100644 --- a/src/Utils/Create/VocabularyData.php +++ b/src/Utils/Create/VocabularyData.php @@ -15,6 +15,7 @@ /** * Class Vocabularies + * * @package Drupal\Console\Utils */ class VocabularyData extends Base @@ -57,7 +58,7 @@ public function create( $vocabulary = $this->entityTypeManager->getStorage('taxonomy_vocabulary')->create( [ 'name' => $this->getRandom()->sentences(mt_rand(1, $nameWords), true), - 'description' => $this->getRandom()->sentences(), + 'description' => $this->getRandom()->sentences(mt_rand(1, $nameWords)), 'vid' => Unicode::strtolower($this->getRandom()->name()), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'weight' => mt_rand(0, 10), diff --git a/src/Utils/DrupalApi.php b/src/Utils/DrupalApi.php index b0e660a33..c382e12eb 100644 --- a/src/Utils/DrupalApi.php +++ b/src/Utils/DrupalApi.php @@ -13,6 +13,7 @@ /** * Class DrupalHelper + * * @package Drupal\Console\Utils */ class DrupalApi @@ -27,6 +28,7 @@ class DrupalApi /** * DebugCommand constructor. + * * @param Client $httpClient */ @@ -34,6 +36,7 @@ class DrupalApi /** * ServerCommand constructor. + * * @param $appRoot * @param $entityTypeManager */ @@ -55,7 +58,7 @@ public function getDrupalVersion() /** * Auxiliary function to get all available drupal caches. * - * @return array The all available drupal caches + * @return \Drupal\Core\Cache\CacheBackendInterface[] The all available drupal caches */ public function getCaches() { @@ -224,7 +227,7 @@ public function downloadProjectRelease($project, $release, $destination = null) public function downloadFile($url, $destination) { - $this->httpClient->get($url, array('sink' => $destination)); + $this->httpClient->get($url, ['sink' => $destination]); return file_exists($destination); } @@ -314,14 +317,15 @@ private function getComposerReleases($url, $limit = 10, $unstable = false) * * Rebuilds all caches even when Drupal itself does not work. * - * @param \Composer\Autoload\ClassLoader $class_loader + * @param \Composer\Autoload\ClassLoader $class_loader * The class loader. * @param \Symfony\Component\HttpFoundation\Request $request * The current request. * * @see rebuild.php */ - public function drupal_rebuild($class_loader, \Symfony\Component\HttpFoundation\Request $request) { + public function drupal_rebuild($class_loader, \Symfony\Component\HttpFoundation\Request $request) + { // Remove Drupal's error and exception handlers; they rely on a working // service container and other subsystems and will only cause a fatal error // that hides the actual error. diff --git a/src/Utils/MigrateExecuteMessageCapture.php b/src/Utils/MigrateExecuteMessageCapture.php index 20dccc7e6..bc0565e30 100644 --- a/src/Utils/MigrateExecuteMessageCapture.php +++ b/src/Utils/MigrateExecuteMessageCapture.php @@ -19,7 +19,7 @@ class MigrateExecuteMessageCapture implements MigrateMessageInterface * * @var array */ - protected $messages = array(); + protected $messages = []; /** * {@inheritdoc} @@ -34,7 +34,7 @@ public function display($message, $type = 'status') */ public function clear() { - $this->messages = array(); + $this->messages = []; } /** diff --git a/src/Utils/Site.php b/src/Utils/Site.php index a3bc8da70..748acd079 100644 --- a/src/Utils/Site.php +++ b/src/Utils/Site.php @@ -9,18 +9,37 @@ use Drupal\Core\Language\LanguageManager; use Drupal\Core\Language\Language; use Drupal\Core\Site\Settings; +use Drupal\Console\Core\Utils\ConfigurationManager; class Site { + /** + * @var string + */ protected $appRoot; + /** + * @var ConfigurationManager + */ + protected $configurationManager; + + /** + * @var string + */ + protected $cacheServicesFile; + /** * Site constructor. - * @param $appRoot + * + * @param string $appRoot + * @param ConfigurationManager $configurationManager */ - public function __construct($appRoot) - { + public function __construct( + $appRoot, + ConfigurationManager $configurationManager + ) { $this->appRoot = $appRoot; + $this->configurationManager = $configurationManager; } public function loadLegacyFile($legacyFile, $relative = true) @@ -62,9 +81,21 @@ public function getDatabaseTypes() $this->loadLegacyFile('/core/includes/install.inc'); $this->setMinimalContainerPreKernel(); + $driverDirectories = [ + $this->appRoot . '/core/lib/Drupal/Core/Database/Driver', + $this->appRoot . '/drivers/lib/Drupal/Driver/Database' + ]; + + $driverDirectories = array_filter( + $driverDirectories, + function ($directory) { + return is_dir($directory); + } + ); + $finder = new Finder(); $finder->directories() - ->in($this->appRoot . '/core/lib/Drupal/Core/Database/Driver') + ->in($driverDirectories) ->depth('== 0'); $databases = []; @@ -103,7 +134,7 @@ protected function setMinimalContainerPreKernel() // Register the stream wrapper manager. $container ->register('stream_wrapper_manager', 'Drupal\Core\StreamWrapper\StreamWrapperManager') - ->addMethodCall('setContainer', array(new Reference('service_container'))); + ->addMethodCall('setContainer', [new Reference('service_container')]); $container ->register('file_system', 'Drupal\Core\File\FileSystem') ->addArgument(new Reference('stream_wrapper_manager')) @@ -135,4 +166,72 @@ public function getAutoload() return include $autoLoadFile; } + + /** + * @return boolean + */ + public function multisiteMode($uri) + { + if ($uri != 'default') { + return true; + } + + return false; + } + + /** + * @return boolean + */ + public function validMultisite($uri) + { + $multiSiteFile = sprintf( + '%s/sites/sites.php', + $this->appRoot + ); + + if (file_exists($multiSiteFile)) { + include $multiSiteFile; + } else { + return false; + } + + if (isset($sites[$uri]) && is_dir($this->appRoot . "/sites/" . $sites[$uri])) { + return true; + } + + return false; + } + + public function getCachedServicesFile() + { + if (!$this->cacheServicesFile) { + $configFactory = \Drupal::configFactory(); + $siteId = $configFactory->get('system.site')->get('uuid'); + + $this->cacheServicesFile = \Drupal::service('console.root') . + DRUPAL_CONSOLE . $siteId . '-console.services.yml'; + } + + return $this->cacheServicesFile; + } + + public function cachedServicesFileExists() + { + return file_exists($this->getCachedServicesFile()); + } + + public function removeCachedServicesFile() + { + if ($this->cachedServicesFileExists()) { + unlink($this->getCachedServicesFile()); + } + } + + /** + * @param string $root + */ + public function setRoot($root) + { + $this->root = $root; + } } diff --git a/src/Utils/TranslatorManager.php b/src/Utils/TranslatorManager.php new file mode 100644 index 000000000..a2eccaccd --- /dev/null +++ b/src/Utils/TranslatorManager.php @@ -0,0 +1,113 @@ +language + ); + + if (!is_dir($languageDirectory)) { + return; + } + $finder = new Finder(); + $finder->files() + ->name('*.yml') + ->in($languageDirectory); + foreach ($finder as $file) { + $resource = $languageDirectory . '/' . $file->getBasename(); + $filename = $file->getBasename('.yml'); + $key = 'commands.' . $filename; + try { + $this->loadTranslationByFile($resource, $key); + } catch (ParseException $e) { + echo $key . '.yml ' . $e->getMessage(); + } + } + } + + /** + * @param $module + */ + private function addResourceTranslationsByModule($module) + { + if (!\Drupal::moduleHandler()->moduleExists($module)) { + return; + } + $extensionPath = \Drupal::moduleHandler()->getModule($module)->getPath(); + $this->addResourceTranslationsByExtensionPath( + $extensionPath + ); + } + + /** + * @param $theme + */ + private function addResourceTranslationsByTheme($theme) + { + $extensionPath = \Drupal::service('theme_handler')->getTheme($theme)->getPath(); + $this->addResourceTranslationsByExtensionPath( + $extensionPath + ); + } + + /** + * @param $library + */ + private function addResourceTranslationsByLibrary($library) + { + $path = \Drupal::service('console.root') . '/vendor/' . $library; + $this->addResourceTranslationsByExtensionPath( + $path + ); + } + + /** + * @param $extension + * @param $type + */ + public function addResourceTranslationsByExtension($extension, $type) + { + if (array_search($extension, $this->extensions) !== false) { + return; + } + + $this->extensions[] = $extension; + if ($type == 'module') { + $this->addResourceTranslationsByModule($extension); + return; + } + if ($type == 'theme') { + $this->addResourceTranslationsByTheme($extension); + return; + } + if ($type == 'library') { + $this->addResourceTranslationsByLibrary($extension); + return; + } + } +} diff --git a/src/Utils/Validator.php b/src/Utils/Validator.php index 89670949c..b81c0ed65 100644 --- a/src/Utils/Validator.php +++ b/src/Utils/Validator.php @@ -8,6 +8,7 @@ namespace Drupal\Console\Utils; use Drupal\Console\Extension\Manager; +use Drupal\Console\Core\Style\DrupalStyle; class Validator { @@ -19,13 +20,23 @@ class Validator protected $appRoot; + /* + * TranslatorManager + */ + protected $translatorManager; + /** * Site constructor. - * @param Manager extensionManager + * + * @param Manager $extensionManager + * @param TranslatorManager $translatorManager */ - public function __construct(Manager $extensionManager) - { + public function __construct( + Manager $extensionManager, + TranslatorManager $translatorManager + ) { $this->extensionManager = $extensionManager; + $this->translatorManager = $translatorManager; } public function validateModuleName($module) @@ -113,29 +124,29 @@ public function validateModulePath($module_path, $create = false) return $module_path; } - public function validateModuleDependencies($dependencies) + public function validateMachineNameList($list) { - $dependencies_checked = array( - 'success' => array(), - 'fail' => array(), - ); + $list_checked = [ + 'success' => [], + 'fail' => [], + ]; - if (empty($dependencies)) { - return array(); + if (empty($list)) { + return []; } - $dependencies = explode(',', $this->removeSpaces($dependencies)); - foreach ($dependencies as $key => $module) { + $list = explode(',', $this->removeSpaces($list)); + foreach ($list as $key => $module) { if (!empty($module)) { if (preg_match(self::REGEX_MACHINE_NAME, $module)) { - $dependencies_checked['success'][] = $module; + $list_checked['success'][] = $module; } else { - $dependencies_checked['fail'][] = $module; + $list_checked['fail'][] = $module; } } } - return $dependencies_checked; + return $list_checked; } /** @@ -258,4 +269,31 @@ public function getUninstalledModules($moduleList) return array_diff($moduleList, $modules); } + + /** + * @param string $extensions_list + * @param string $type + * @param DrupalStyle $io + * + * @return array + */ + public function validateExtensions($extensions_list, $type, DrupalStyle $io) + { + $extensions = $this->validateMachineNameList($extensions_list); + // Check if all extensions are available + if ($extensions) { + $checked_extensions = $this->extensionManager->checkExtensions($extensions['success'], $type); + if (!empty($checked_extensions['no_extensions'])) { + $io->warning( + sprintf( + $this->translatorManager->trans('validator.warnings.extension-unavailable'), + implode(', ', $checked_extensions['no_extensions']) + ) + ); + } + $extensions = $extensions['success']; + } + + return $extensions; + } } diff --git a/src/Utils/YamlFileDumper.php b/src/Utils/YamlFileDumper.php deleted file mode 100644 index 0651dccf0..000000000 --- a/src/Utils/YamlFileDumper.php +++ /dev/null @@ -1,88 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Drupal\Console\Utils; - -use Symfony\Component\Translation\MessageCatalogue; -use Symfony\Component\Yaml\Yaml; -use Symfony\Component\Translation\Dumper\FileDumper; - -/** - * YamlFileDumper generates yaml files from a message catalogue. - * - * @author Michel Salib - */ -class YamlFileDumper extends FileDumper -{ - /** - * @var int Nesting depth. 0 means one line by message, 1 will - * indent at most one time, and so on. - */ - public $nestLevel = 0; - - /** - * {@inheritDoc} - */ - public function dump(MessageCatalogue $messages, $options = array()) - { - $this->nestLevel = array_key_exists('nest-level', $options) ? $options['nest-level'] : 0; - - parent::dump($messages, $options); - } - - /** - * {@inheritDoc} - */ - protected function format(MessageCatalogue $messages, $domain) - { - $m = $messages->all($domain); - - if ($this->nestLevel > 0) { - // build a message tree from the message list, with a max depth - // of $this->nestLevel - $tree = array(); - foreach ($m as $key => $message) { - // dots are ignored at the beginning and at the end of a key - $key = trim($key, "\t ."); - - if (strlen($key) > 0) { - $codes = explode('.', $key, $this->nestLevel + 1); - $node = &$tree; - - foreach ($codes as $code) { - if (strlen($code) > 0) { - if (!isset($node)) { - $node = array(); - } - $node = &$node[$code]; - } - } - $node = $message; - } - } - - return Yaml::dump( - $tree, - $this->nestLevel + 1 - ); // second parameter at 1 outputs normal line-by-line catalogue - } else { - return Yaml::dump($m, 1); - } - } - - /** - * {@inheritDoc} - */ - protected function getExtension() - { - return 'yml'; - } -} diff --git a/src/Zippy/Adapter/TarGzGNUTarForWindowsAdapter.php b/src/Zippy/Adapter/TarGzGNUTarForWindowsAdapter.php index 89b7a7c1f..143c8b94a 100644 --- a/src/Zippy/Adapter/TarGzGNUTarForWindowsAdapter.php +++ b/src/Zippy/Adapter/TarGzGNUTarForWindowsAdapter.php @@ -13,6 +13,7 @@ /** * Class TarGzGNUTarForWindowsAdapter + * * @package Drupal\Console\Zippy\Adapter */ class TarGzGNUTarForWindowsAdapter extends TarGzGNUTarAdapter @@ -30,6 +31,6 @@ protected function doAdd(ResourceInterface $resource, $files, $recursive) */ protected function getLocalOptions() { - return array_merge(parent::getLocalOptions(), array('--force-local')); + return array_merge(parent::getLocalOptions(), ['--force-local']); } } diff --git a/src/Zippy/FileStrategy/TarGzFileForWindowsStrategy.php b/src/Zippy/FileStrategy/TarGzFileForWindowsStrategy.php index 6c83aecca..c0f672ce4 100644 --- a/src/Zippy/FileStrategy/TarGzFileForWindowsStrategy.php +++ b/src/Zippy/FileStrategy/TarGzFileForWindowsStrategy.php @@ -11,6 +11,7 @@ /** * Class TarGzFileForWindowsStrategy + * * @package Drupal\Console\Zippy/Strategy */ class TarGzFileForWindowsStrategy extends AbstractFileStrategy @@ -20,9 +21,9 @@ class TarGzFileForWindowsStrategy extends AbstractFileStrategy */ protected function getServiceNames() { - return array( + return [ 'Drupal\\Console\\Zippy\\Adapter\\TarGzGNUTarForWindowsAdapter' - ); + ]; } /** diff --git a/templates/dash/generate-doc.html.twig b/templates/dash/generate-doc.html.twig deleted file mode 100644 index 196bbc715..000000000 --- a/templates/dash/generate-doc.html.twig +++ /dev/null @@ -1,56 +0,0 @@ - - - - - {% block title %}{{ command }}{% endblock %} - - - -

{{ command }}

-

The {{ command }} command: {{ description }}

-

Usage: -

-        $ drupal {{ command }} {% if arguments|length>0 %}[arguments] {% endif %}{% if options|length>0 %}[options] {% endif %}
-    
-

-{% if options|length>0 %} -

Available options

- - - - - - - - - {% for option in options %} - - - - - {% endfor %} - -
OptionDetails
{{ option.name }}{{ option.description }}
-{% endif %} - -{% if arguments|length>0 %} -

Available arguments

- - - - - - - - - {% for argument in arguments %} - - - - - {% endfor %} - -
ArgumentDetails
{{ argument.name }}{{ argument.description }}
-{% endif %} - - diff --git a/templates/dash/index.html.twig b/templates/dash/index.html.twig deleted file mode 100644 index 83428bd03..000000000 --- a/templates/dash/index.html.twig +++ /dev/null @@ -1,153 +0,0 @@ - - - - - Drupal Console - - - -

Drupal Console

- -

Getting the project

- -

There are different ways to get the project on your local machine. Our recommendation for getting the project on your - local machine is by using the installer.

- -

Using the Drupal Console Installer

- -

You can install the Drupal Console locally by running the installer in your project - directory, the installer will take care of downloading the necesary files to run drupal console on you computer. -

-

Using curl:

-
$ curl https://drupalconsole.com/installer -L -o drupal.phar
-    
-

Or if you don't have curl:

-
php -r "readfile('https://drupalconsole.com/installer');" > drupal.phar
-    
-

Example:

-
$ php console.phar generate:module
-    
-

You can place this file anywhere you wish. If you put it in your PATH, you can access it - globally. On unixy systems you can even make it executable and invoke it without php. -

-

Access console from anywhere on your system

-
$ mv console.phar /usr/local/bin/drupal
-    
-

Apply executable permissions on the downloaded file:

-
$ chmod +x /usr/local/bin/drupal
-    
-

You can now execute console using:

-
$ drupal
-    
-

NOTE: The name drupal is just an alias you can name it - anything you like. -

- -

Install Drupal Console Using Composer

- -

You can install this project using composer. - -

-
+
-
-

-

Install Drupal Console globally using composer:

-
$ composer global require drupal/console:@stable
-    
-

Add the binary directory to your class path:

-
$ echo "PATH=$PATH:~/.composer/vendor/bin" >> ~/.bash_profile
-    
-

You can now execute console using:

-
$ console generate:module
-    
-

Download phar file

- -

You can download the latest version of Console from the repository releases page at:

- -

https://github.com/hechoendrupal/DrupalConsole -

- -

Make sure you download the console.phar file from the most current release.

- -

Update project

- -

Drupal 8 is under heavy development, to keep in sync with the latest changes. The easiest and recommended way of - updating Drupal Console is using the self-update command. -

-

Depending on the installation method:

-
Installed globally (and renamed to "drupal"):
-
$ drupal self-update
-    
-
Installed globally (using composer):
-
$ composer global update drupal/console:@stable
-    
-
Installed locally (running - from directory where the console.phar has been downloaded):
-
$ php console.phar self-update
-    
-

Available Drupal Console Commands

-

Note: Drupal Console commands *must* be run from the root of a Drupal 8 installation.

- - - - - - - - - {% for namespace, commands in command_list %} - {% if namespace != 'none' %} - - - - - {% endif %} - {% for command in commands %} - - - - - {% endfor %} - {% endfor %} - -
Drupal Console CommandDetails
{{ namespace }}
{{ command.name }}{{ command.description }}
-{% if options|length>0 %} -

Available options

- - - - - - - - - {% for option in options %} - - - - - {% endfor %} - -
OptionDetails
{{ option.name }}{{ option.description }}
-{% endif %} -{% if arguments|length>0 %} -

Available arguments

- - - - - - - - - {% for argument in arguments %} - - - - - {% endfor %} - -
ArgumentDetails
{{ argument.name }}{{ argument.description }}
-{% endif %} - - diff --git a/templates/database/add.php.twig b/templates/database/add.php.twig new file mode 100644 index 000000000..c279c9fbd --- /dev/null +++ b/templates/database/add.php.twig @@ -0,0 +1,10 @@ + +$databases['{{ database }}']['default'] = [ + 'database' => '{{ database }}', + 'username' => '{{ username }}', + 'password' => '{{ password }}', + 'host' => '{{ host }}', + 'port' => '{{ port }}', + 'driver' => '{{ driver }}', + 'prefix' => '{{ prefix }}', +]; diff --git a/templates/gitbook/available-commands-list.md.twig b/templates/gitbook/available-commands-list.md.twig deleted file mode 100644 index 3343a19aa..000000000 --- a/templates/gitbook/available-commands-list.md.twig +++ /dev/null @@ -1,14 +0,0 @@ -{% for namespace in application.namespaces %} -{% if not loop.first %} -{% set last_namespace = namespace %} -{% endif %} -{% if last_namespace is defined %} - - {# Empty new line hack #} -{% endif %} -{% spaceless %} -{% for command in commands[namespace] %} - * [{{ command.name }}](commands/{{ command.name|replace(':','-') }}.md) -{% endfor %} -{% endspaceless %} -{% endfor %} diff --git a/templates/gitbook/available-commands.md.twig b/templates/gitbook/available-commands.md.twig deleted file mode 100644 index a9791ba6b..000000000 --- a/templates/gitbook/available-commands.md.twig +++ /dev/null @@ -1,32 +0,0 @@ -# {{ application.messages.title }} - -**{{ application.messages.note }}:** {{ application.messages.note_description }}. - -{{ application.messages.command }} | {{ application.messages.details }} ------------- | ------------- -{% for namespace in application.namespaces %} -{% if namespace != 'none' %} -**{{ namespace }}** | -{% endif %} -{% for command in commands[namespace] %} -[{{ command.name }}]({{ command.name|replace(':','-') }}.md) | {{ command.description }} -{% endfor %} -{% endfor %} -{% if application.options|length>0 %} - -## {{ application.messages.options }} -{{ application.messages.option }} | {{ application.messages.details }} --------|------------- -{% for option in application.options %} ---{{ option.name }} | {{ option.description }} -{% endfor %} -{% endif %} -{% if application.arguments|length>0 %} - -## {{ application.messages.arguments }} -{{ application.messages.argument }} | {{ application.messages.details }} ----------|------------- -{% for argument in application.arguments %} -{{ argument.name }} | {{ argument.description }} -{% endfor %} -{% endif %} diff --git a/templates/gitbook/command.md.twig b/templates/gitbook/command.md.twig deleted file mode 100644 index df02d0900..000000000 --- a/templates/gitbook/command.md.twig +++ /dev/null @@ -1,39 +0,0 @@ -# {{ name }} -{{ description }} - -**{{ messages.usage }}:** -``` -$ drupal {{ name }}{% if arguments|length>0 %} [arguments]{% endif %}{% if options|length>0 %} [options]{% endif %} - -{% for alias in aliases %} -$ {{ alias }} -{% endfor %} -``` -{% if options|length>0 %} - -## {{ messages.options }} -{{ messages.option }} | {{ messages.details }} --------|------------- -{% for option in options %} ---{{ option.name }} | {{ option.description }} -{% endfor %} -{% endif %} -{% if arguments|length>0 %} - -## {{ messages.arguments }} -{{ messages.argument }} | {{ messages.details }} ----------|------------- -{% for argument in arguments %} -{{ argument.name }} | {{ argument.description }} -{% endfor %} -{% endif %} -{% if examples|length>0 %} - -## {{ messages.examples }} -{% for example in examples %} -* {{ example.description }} -``` -$ {{ example.execution }} -``` -{% endfor %} -{% endif %} diff --git a/templates/module/Tests/Controller/controller.php.twig b/templates/module/Tests/Controller/controller.php.twig index a1748f9f5..d963c6652 100644 --- a/templates/module/Tests/Controller/controller.php.twig +++ b/templates/module/Tests/Controller/controller.php.twig @@ -23,11 +23,11 @@ class {{class_name}}Test extends WebTestBase {% endblock %} * {@inheritdoc} */ public static function getInfo() { - return array( + return [ 'name' => "{{module}} {{class_name}}'s controller functionality", 'description' => 'Test Unit for module {{module}} and controller {{class_name}}.', 'group' => 'Other', - ); + ]; } /** diff --git a/templates/module/entity-content-page.php.twig b/templates/module/entity-content-page.php.twig index 4279ebe0d..4b855e446 100644 --- a/templates/module/entity-content-page.php.twig +++ b/templates/module/entity-content-page.php.twig @@ -9,8 +9,6 @@ {% block use_class %} use Drupal\Core\Render\Element; -use Drupal\Core\Link; -use Drupal\Core\Url; {% endblock %} {% block file_methods %} diff --git a/templates/module/src/help.php.twig b/templates/module/help.php.twig similarity index 93% rename from templates/module/src/help.php.twig rename to templates/module/help.php.twig index d43f632e8..28248c1e5 100644 --- a/templates/module/src/help.php.twig +++ b/templates/module/help.php.twig @@ -1,6 +1,6 @@ {% block file_methods %} {% if not file_exists %} - [ + 'render element' => 'children', + ], + ]; +} diff --git a/templates/module/module.twig b/templates/module/module.twig index c6b55b356..53540372f 100644 --- a/templates/module/module.twig +++ b/templates/module/module.twig @@ -1,6 +1,6 @@ {% extends "base/file.php.twig" %} -{% block file_path %}{{machine_name}}.module.{% endblock %} +{% block file_path %}{{machine_name}}.module{% endblock %} {% block use_class %} use Drupal\Core\Routing\RouteMatchInterface; diff --git a/templates/module/module.views.inc.twig b/templates/module/module.views.inc.twig index daf921f23..98e755c13 100644 --- a/templates/module/module.views.inc.twig +++ b/templates/module/module.views.inc.twig @@ -21,19 +21,19 @@ use Drupal\system\ActionConfigEntityInterface; function {{module}}_views_data() { $data['views']['table']['group'] = t('Custom Global'); - $data['views']['table']['join'] = array( + $data['views']['table']['join'] = [ // #global is a special flag which allows a table to appear all the time. - '#global' => array(), - ); + '#global' => [], + ]; - $data['views']['{{ class_machine_name }}'] = array( + $data['views']['{{ class_machine_name }}'] = [ 'title' => t('{{ title }}'), 'help' => t('{{ description }}'), - 'field' => array( + 'field' => [ 'id' => '{{ class_machine_name }}', - ), - ); + ], + ]; return $data; } diff --git a/templates/module/php_tag.php.twig b/templates/module/php_tag.php.twig new file mode 100644 index 000000000..b3d9bbc7f --- /dev/null +++ b/templates/module/php_tag.php.twig @@ -0,0 +1 @@ +entityManager()->getStorage('{{ entity_name }}')->loadRevision(${{ entity_name }}_revision); - return $this->t('Revision of %title from %date', array('%title' => ${{ entity_name }}->label(), '%date' => format_date(${{ entity_name }}->getRevisionCreationTime()))); + return $this->t('Revision of %title from %date', ['%title' => ${{ entity_name }}->label(), '%date' => format_date(${{ entity_name }}->getRevisionCreationTime())]); } /** @@ -74,12 +72,12 @@ class {{ entity_class }}Controller extends ControllerBase implements ContainerIn ${{ entity_name }}_storage = $this->entityManager()->getStorage('{{ entity_name }}'); $build['#title'] = $has_translations ? $this->t('@langname revisions for %title', ['@langname' => $langname, '%title' => ${{ entity_name }}->label()]) : $this->t('Revisions for %title', ['%title' => ${{ entity_name }}->label()]); - $header = array($this->t('Revision'), $this->t('Operations')); + $header = [$this->t('Revision'), $this->t('Operations')]; $revert_permission = (($account->hasPermission("revert all {{ label|lower }} revisions") || $account->hasPermission('administer {{ label|lower }} entities'))); $delete_permission = (($account->hasPermission("delete all {{ label|lower }} revisions") || $account->hasPermission('administer {{ label|lower }} entities'))); - $rows = array(); + $rows = []; $vids = ${{ entity_name }}_storage->revisionIds(${{ entity_name }}); @@ -93,11 +91,11 @@ class {{ entity_class }}Controller extends ControllerBase implements ContainerIn if ($revision->hasTranslation($langcode) && $revision->getTranslation($langcode)->isRevisionTranslationAffected()) { $username = [ '#theme' => 'username', - '#account' => $revision->getRevisionAuthor(), + '#account' => $revision->getRevisionUser(), ]; // Use revision link to link to revisions that are not active. - $date = \Drupal::service('date.formatter')->format($revision->revision_timestamp->value, 'short'); + $date = \Drupal::service('date.formatter')->format($revision->getRevisionCreationTime(), 'short'); if ($vid != ${{ entity_name }}->getRevisionId()) { $link = $this->l($date, new Url('entity.{{ entity_name }}.revision', ['{{ entity_name }}' => ${{ entity_name }}->id(), '{{ entity_name }}_revision' => $vid])); } @@ -113,7 +111,7 @@ class {{ entity_class }}Controller extends ControllerBase implements ContainerIn '#context' => [ 'date' => $link, 'username' => \Drupal::service('renderer')->renderPlain($username), - 'message' => ['#markup' => $revision->revision_log_message->value, '#allowed_tags' => Xss::getHtmlTagList()], + 'message' => ['#markup' => $revision->getRevisionLogMessage(), '#allowed_tags' => Xss::getHtmlTagList()], ], ], ]; @@ -139,10 +137,10 @@ class {{ entity_class }}Controller extends ControllerBase implements ContainerIn 'title' => $this->t('Revert'), {% if is_translatable %} 'url' => $has_translations ? - Url::fromRoute('{{ entity_name }}.revision_revert_translation_confirm', ['{{ entity_name }}' => ${{ entity_name }}->id(), '{{ entity_name }}_revision' => $vid, 'langcode' => $langcode]) : - Url::fromRoute('{{ entity_name }}.revision_revert_confirm', ['{{ entity_name }}' => ${{ entity_name }}->id(), '{{ entity_name }}_revision' => $vid]), + Url::fromRoute('entity.{{ entity_name }}.translation_revert', ['{{ entity_name }}' => ${{ entity_name }}->id(), '{{ entity_name }}_revision' => $vid, 'langcode' => $langcode]) : + Url::fromRoute('entity.{{ entity_name }}.revision_revert', ['{{ entity_name }}' => ${{ entity_name }}->id(), '{{ entity_name }}_revision' => $vid]), {% else %} - 'url' => Url::fromRoute('{{ entity_name }}.revision_revert_confirm', ['{{ entity_name }}' => ${{ entity_name }}->id(), '{{ entity_name }}_revision' => $vid]), + 'url' => Url::fromRoute('entity.{{ entity_name }}.revision_revert', ['{{ entity_name }}' => ${{ entity_name }}->id(), '{{ entity_name }}_revision' => $vid]), {% endif %} ]; } @@ -150,7 +148,7 @@ class {{ entity_class }}Controller extends ControllerBase implements ContainerIn if ($delete_permission) { $links['delete'] = [ 'title' => $this->t('Delete'), - 'url' => Url::fromRoute('{{ entity_name }}.revision_delete_confirm', ['{{ entity_name }}' => ${{ entity_name }}->id(), '{{ entity_name }}_revision' => $vid]), + 'url' => Url::fromRoute('entity.{{ entity_name }}.revision_delete', ['{{ entity_name }}' => ${{ entity_name }}->id(), '{{ entity_name }}_revision' => $vid]), ]; } @@ -166,11 +164,11 @@ class {{ entity_class }}Controller extends ControllerBase implements ContainerIn } } - $build['{{ entity_name }}_revisions_table'] = array( + $build['{{ entity_name }}_revisions_table'] = [ '#theme' => 'table', '#rows' => $rows, '#header' => $header, - ); + ]; return $build; } diff --git a/templates/module/src/Entity/Form/entity-content-revision-delete.php.twig b/templates/module/src/Entity/Form/entity-content-revision-delete.php.twig index 4d5a13f2e..02674ac11 100644 --- a/templates/module/src/Entity/Form/entity-content-revision-delete.php.twig +++ b/templates/module/src/Entity/Form/entity-content-revision-delete.php.twig @@ -82,14 +82,14 @@ class {{ entity_class }}RevisionDeleteForm extends ConfirmFormBase {% endblock % * {@inheritdoc} */ public function getQuestion() { - return t('Are you sure you want to delete the revision from %revision-date?', array('%revision-date' => format_date($this->revision->getRevisionCreationTime()))); + return t('Are you sure you want to delete the revision from %revision-date?', ['%revision-date' => format_date($this->revision->getRevisionCreationTime())]); } /** * {@inheritdoc} */ public function getCancelUrl() { - return new Url('entity.{{ entity_name }}.version_history', array('{{ entity_name }}' => $this->revision->id())); + return new Url('entity.{{ entity_name }}.version_history', ['{{ entity_name }}' => $this->revision->id()]); } /** @@ -115,16 +115,16 @@ class {{ entity_class }}RevisionDeleteForm extends ConfirmFormBase {% endblock % public function submitForm(array &$form, FormStateInterface $form_state) { $this->{{ entity_class }}Storage->deleteRevision($this->revision->getRevisionId()); - $this->logger('content')->notice('{{ label }}: deleted %title revision %revision.', array('%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId())); - drupal_set_message(t('Revision from %revision-date of {{ label }} %title has been deleted.', array('%revision-date' => format_date($this->revision->getRevisionCreationTime()), '%title' => $this->revision->label()))); + $this->logger('content')->notice('{{ label }}: deleted %title revision %revision.', ['%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]); + drupal_set_message(t('Revision from %revision-date of {{ label }} %title has been deleted.', ['%revision-date' => format_date($this->revision->getRevisionCreationTime()), '%title' => $this->revision->label()])); $form_state->setRedirect( 'entity.{{ entity_name }}.canonical', - array('{{ entity_name }}' => $this->revision->id()) + ['{{ entity_name }}' => $this->revision->id()] ); - if ($this->connection->query('SELECT COUNT(DISTINCT vid) FROM {{ '{'~entity_name~'_field_revision}' }} WHERE id = :id', array(':id' => $this->revision->id()))->fetchField() > 1) { + if ($this->connection->query('SELECT COUNT(DISTINCT vid) FROM {{ '{'~entity_name~'_field_revision}' }} WHERE id = :id', [':id' => $this->revision->id()])->fetchField() > 1) { $form_state->setRedirect( 'entity.{{ entity_name }}.version_history', - array('{{ entity_name }}' => $this->revision->id()) + ['{{ entity_name }}' => $this->revision->id()] ); } } diff --git a/templates/module/src/Entity/Form/entity-content-revision-revert-translation.php.twig b/templates/module/src/Entity/Form/entity-content-revision-revert-translation.php.twig index 6d2f46c2a..0c38ba5b3 100644 --- a/templates/module/src/Entity/Form/entity-content-revision-revert-translation.php.twig +++ b/templates/module/src/Entity/Form/entity-content-revision-revert-translation.php.twig @@ -87,11 +87,11 @@ class {{ entity_class }}RevisionRevertTranslationForm extends {{ entity_class }} $this->langcode = $langcode; $form = parent::buildForm($form, $form_state, ${{ entity_name }}_revision); - $form['revert_untranslated_fields'] = array( + $form['revert_untranslated_fields'] = [ '#type' => 'checkbox', '#title' => $this->t('Revert content shared among translations'), '#default_value' => FALSE, - ); + ]; return $form; } diff --git a/templates/module/src/Entity/Form/entity-content-revision-revert.php.twig b/templates/module/src/Entity/Form/entity-content-revision-revert.php.twig index 42e65979f..4077d9417 100644 --- a/templates/module/src/Entity/Form/entity-content-revision-revert.php.twig +++ b/templates/module/src/Entity/Form/entity-content-revision-revert.php.twig @@ -89,7 +89,7 @@ class {{ entity_class }}RevisionRevertForm extends ConfirmFormBase {% endblock % * {@inheritdoc} */ public function getCancelUrl() { - return new Url('entity.{{ entity_name }}.version_history', array('{{ entity_name }}' => $this->revision->id())); + return new Url('entity.{{ entity_name }}.version_history', ['{{ entity_name }}' => $this->revision->id()]); } /** @@ -132,7 +132,7 @@ class {{ entity_class }}RevisionRevertForm extends ConfirmFormBase {% endblock % drupal_set_message(t('{{ label }} %title has been reverted to the revision from %revision-date.', ['%title' => $this->revision->label(), '%revision-date' => $this->dateFormatter->format($original_revision_timestamp)])); $form_state->setRedirect( 'entity.{{ entity_name }}.version_history', - array('{{ entity_name }}' => $this->revision->id()) + ['{{ entity_name }}' => $this->revision->id()] ); } diff --git a/templates/module/src/Entity/Form/entity-content.php.twig b/templates/module/src/Entity/Form/entity-content.php.twig index 1cc9a7cf2..63982a485 100644 --- a/templates/module/src/Entity/Form/entity-content.php.twig +++ b/templates/module/src/Entity/Form/entity-content.php.twig @@ -30,12 +30,12 @@ class {{ entity_class }}Form extends ContentEntityForm {% endblock %} {% if revisionable %} if (!$this->entity->isNew()) { - $form['new_revision'] = array( + $form['new_revision'] = [ '#type' => 'checkbox', '#title' => $this->t('Create new revision'), '#default_value' => FALSE, '#weight' => 10, - ); + ]; } {% endif %} @@ -57,7 +57,7 @@ class {{ entity_class }}Form extends ContentEntityForm {% endblock %} // If a new revision is created, save the current user as revision author. $entity->setRevisionCreationTime(REQUEST_TIME); - $entity->setRevisionAuthorId(\Drupal::currentUser()->id()); + $entity->setRevisionUserId(\Drupal::currentUser()->id()); } else { $entity->setNewRevision(FALSE); diff --git a/templates/module/src/Entity/Form/entity-settings.php.twig b/templates/module/src/Entity/Form/entity-settings.php.twig index df0a3aebe..aa71845e4 100644 --- a/templates/module/src/Entity/Form/entity-settings.php.twig +++ b/templates/module/src/Entity/Form/entity-settings.php.twig @@ -17,8 +17,6 @@ use Drupal\Core\Form\FormStateInterface; /** * Class {{ entity_class }}SettingsForm. * - * @package Drupal\{{module}}\Form - * * @ingroup {{module}} */ class {{ entity_class }}SettingsForm extends FormBase {% endblock %} @@ -30,7 +28,7 @@ class {{ entity_class }}SettingsForm extends FormBase {% endblock %} * The unique string identifying the form. */ public function getFormId() { - return '{{ entity_class }}_settings'; + return '{{ entity_class|lower }}_settings'; } /** @@ -57,7 +55,7 @@ class {{ entity_class }}SettingsForm extends FormBase {% endblock %} * Form definition array. */ public function buildForm(array $form, FormStateInterface $form_state) { - $form['{{ entity_class }}_settings']['#markup'] = 'Settings form for {{ label }} entities. Manage field settings here.'; + $form['{{ entity_class|lower }}_settings']['#markup'] = 'Settings form for {{ label }} entities. Manage field settings here.'; return $form; } {% endblock %} diff --git a/templates/module/src/Entity/entity-content-views-data.php.twig b/templates/module/src/Entity/entity-content-views-data.php.twig index ffaed8650..c8ee2645b 100644 --- a/templates/module/src/Entity/entity-content-views-data.php.twig +++ b/templates/module/src/Entity/entity-content-views-data.php.twig @@ -10,14 +10,13 @@ namespace Drupal\{{ module }}\Entity; {% block use_class %} use Drupal\views\EntityViewsData; -use Drupal\views\EntityViewsDataInterface; {% endblock %} {% block class_declaration %} /** * Provides Views data for {{ label }} entities. */ -class {{ entity_class }}ViewsData extends EntityViewsData implements EntityViewsDataInterface {% endblock %} +class {{ entity_class }}ViewsData extends EntityViewsData {% endblock %} {% block class_methods %} /** * {@inheritdoc} @@ -25,11 +24,8 @@ class {{ entity_class }}ViewsData extends EntityViewsData implements EntityViews public function getViewsData() { $data = parent::getViewsData(); - $data['{{ entity_name }}']['table']['base'] = array( - 'field' => 'id', - 'title' => $this->t('{{ label }}'), - 'help' => $this->t('The {{ label }} ID.'), - ); + // Additional information for Views integration, such as table joins, can be + // put here. return $data; } diff --git a/templates/module/src/Entity/entity-content-with-bundle.theme_hook_suggestions.php.twig b/templates/module/src/Entity/entity-content-with-bundle.theme_hook_suggestions.php.twig index c14788809..77ea4dfbb 100644 --- a/templates/module/src/Entity/entity-content-with-bundle.theme_hook_suggestions.php.twig +++ b/templates/module/src/Entity/entity-content-with-bundle.theme_hook_suggestions.php.twig @@ -4,7 +4,7 @@ * Implements hook_theme_suggestions_HOOK(). */ function {{ module }}_theme_suggestions_{{ entity_name }}(array $variables) { - $suggestions = array(); + $suggestions = []; $entity = $variables['elements']['#{{ entity_name }}']; $sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_'); diff --git a/templates/module/src/Entity/entity-content.php.twig b/templates/module/src/Entity/entity-content.php.twig index 640e1d97e..f1088f3f8 100644 --- a/templates/module/src/Entity/entity-content.php.twig +++ b/templates/module/src/Entity/entity-content.php.twig @@ -56,7 +56,9 @@ use Drupal\user\UserInterface; * }, * }, * base_table = "{{ entity_name }}", +{% if is_translatable %} * data_table = "{{ entity_name }}_field_data", +{% endif %} {% if revisionable %} * revision_table = "{{ entity_name }}_revision", * revision_data_table = "{{ entity_name }}_field_revision", @@ -92,11 +94,11 @@ use Drupal\user\UserInterface; {% if revisionable %} * "version-history" = "{{ base_path }}/{{ entity_name }}/{{ '{'~entity_name~'}' }}/revisions", * "revision" = "{{ base_path }}/{{ entity_name }}/{{ '{'~entity_name~'}' }}/revisions/{{ '{'~entity_name~'_revision}' }}/view", -{% if is_translatable %} * "revision_revert" = "{{ base_path }}/{{ entity_name }}/{{ '{'~entity_name~'}' }}/revisions/{{ '{'~entity_name~'_revision}' }}/revert", + * "revision_delete" = "{{ base_path }}/{{ entity_name }}/{{ '{'~entity_name~'}' }}/revisions/{{ '{'~entity_name~'_revision}' }}/delete", +{% if is_translatable %} * "translation_revert" = "{{ base_path }}/{{ entity_name }}/{{ '{'~entity_name~'}' }}/revisions/{{ '{'~entity_name~'_revision}' }}/revert/{langcode}", {% endif %} - * "revision_delete" = "{{ base_path }}/{{ entity_name }}/{{ '{'~entity_name~'}' }}/revisions/{{ '{'~entity_name~'_revision}' }}/delete", {% endif %} * "collection" = "{{ base_path }}/{{ entity_name }}", * }, @@ -121,9 +123,9 @@ class {{ entity_class }} extends {% if revisionable %}RevisionableContentEntityB */ public static function preCreate(EntityStorageInterface $storage_controller, array &$values) { parent::preCreate($storage_controller, $values); - $values += array( + $values += [ 'user_id' => \Drupal::currentUser()->id(), - ); + ]; } {% if revisionable %} @@ -144,21 +146,12 @@ class {{ entity_class }} extends {% if revisionable %}RevisionableContentEntityB // If no revision author has been set explicitly, make the {{ entity_name }} owner the // revision author. - if (!$this->getRevisionAuthor()) { - $this->setRevisionAuthorId($this->getOwnerId()); + if (!$this->getRevisionUser()) { + $this->setRevisionUserId($this->getOwnerId()); } } {% endif %} -{% if bundle_entity_type %} - /** - * {@inheritdoc} - */ - public function getType() { - return $this->bundle(); - } - -{% endif %} /** * {@inheritdoc} */ @@ -233,38 +226,6 @@ class {{ entity_class }} extends {% if revisionable %}RevisionableContentEntityB $this->set('status', $published ? TRUE : FALSE); return $this; } -{% if revisionable %} - - /** - * {@inheritdoc} - */ - public function getRevisionCreationTime() { - return $this->get('revision_timestamp')->value; - } - - /** - * {@inheritdoc} - */ - public function setRevisionCreationTime($timestamp) { - $this->set('revision_timestamp', $timestamp); - return $this; - } - - /** - * {@inheritdoc} - */ - public function getRevisionAuthor() { - return $this->get('revision_uid')->entity; - } - - /** - * {@inheritdoc} - */ - public function setRevisionAuthorId($uid) { - $this->set('revision_uid', $uid); - return $this; - } -{% endif %} /** * {@inheritdoc} @@ -279,21 +240,21 @@ class {{ entity_class }} extends {% if revisionable %}RevisionableContentEntityB ->setSetting('target_type', 'user') ->setSetting('handler', 'default') ->setTranslatable(TRUE) - ->setDisplayOptions('view', array( + ->setDisplayOptions('view', [ 'label' => 'hidden', 'type' => 'author', 'weight' => 0, - )) - ->setDisplayOptions('form', array( + ]) + ->setDisplayOptions('form', [ 'type' => 'entity_reference_autocomplete', 'weight' => 5, - 'settings' => array( + 'settings' => [ 'match_operator' => 'CONTAINS', 'size' => '60', 'autocomplete_type' => 'tags', 'placeholder' => '', - ), - )) + ], + ]) ->setDisplayConfigurable('form', TRUE) ->setDisplayConfigurable('view', TRUE); @@ -303,20 +264,20 @@ class {{ entity_class }} extends {% if revisionable %}RevisionableContentEntityB {% if revisionable %} ->setRevisionable(TRUE) {% endif %} - ->setSettings(array( + ->setSettings([ 'max_length' => 50, 'text_processing' => 0, - )) + ]) ->setDefaultValue('') - ->setDisplayOptions('view', array( + ->setDisplayOptions('view', [ 'label' => 'above', 'type' => 'string', 'weight' => -4, - )) - ->setDisplayOptions('form', array( + ]) + ->setDisplayOptions('form', [ 'type' => 'string_textfield', 'weight' => -4, - )) + ]) ->setDisplayConfigurable('form', TRUE) ->setDisplayConfigurable('view', TRUE); @@ -335,20 +296,7 @@ class {{ entity_class }} extends {% if revisionable %}RevisionableContentEntityB $fields['changed'] = BaseFieldDefinition::create('changed') ->setLabel(t('Changed')) ->setDescription(t('The time that the entity was last edited.')); -{% if revisionable %} - - $fields['revision_timestamp'] = BaseFieldDefinition::create('created') - ->setLabel(t('Revision timestamp')) - ->setDescription(t('The time that the current revision was created.')) - ->setQueryable(FALSE) - ->setRevisionable(TRUE); - - $fields['revision_uid'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('Revision user ID')) - ->setDescription(t('The user ID of the author of the current revision.')) - ->setSetting('target_type', 'user') - ->setQueryable(FALSE) - ->setRevisionable(TRUE); +{% if revisionable and is_translatable %} $fields['revision_translation_affected'] = BaseFieldDefinition::create('boolean') ->setLabel(t('Revision translation affected')) diff --git a/templates/module/src/Entity/entity-content.theme.php.twig b/templates/module/src/Entity/entity-content.theme.php.twig index 4aab3bdc7..afa9d750c 100644 --- a/templates/module/src/Entity/entity-content.theme.php.twig +++ b/templates/module/src/Entity/entity-content.theme.php.twig @@ -1,7 +1,7 @@ {% block hook_theme %} - $theme['{{ entity_name }}'] = array( + $theme['{{ entity_name }}'] = [ 'render element' => 'elements', 'file' => '{{ entity_name }}.page.inc', 'template' => '{{ entity_name }}', - ); + ]; {% endblock %} diff --git a/templates/module/src/Entity/entity.php.twig b/templates/module/src/Entity/entity.php.twig index 07d85f294..03efd8791 100644 --- a/templates/module/src/Entity/entity.php.twig +++ b/templates/module/src/Entity/entity.php.twig @@ -24,6 +24,7 @@ use Drupal\Core\Config\Entity\ConfigEntityBase; * id = "{{ entity_name }}", * label = @Translation("{{ label }}"), * handlers = { + * "view_builder" = "Drupal\Core\Entity\EntityViewBuilder", * "list_builder" = "Drupal\{{ module }}\{{ entity_class }}ListBuilder", * "form" = { * "add" = "Drupal\{{ module }}\Form\{{ entity_class }}Form", diff --git a/templates/module/src/Entity/interface-entity-content.php.twig b/templates/module/src/Entity/interface-entity-content.php.twig index 7831466e3..981b81bc2 100644 --- a/templates/module/src/Entity/interface-entity-content.php.twig +++ b/templates/module/src/Entity/interface-entity-content.php.twig @@ -10,9 +10,8 @@ namespace Drupal\{{module}}\Entity; {% block use_class %} {% if revisionable %} +use Drupal\Core\Entity\RevisionLogInterface; use Drupal\Core\Entity\RevisionableInterface; -use Drupal\Component\Utility\Xss; -use Drupal\Core\Url; {% else %} use Drupal\Core\Entity\ContentEntityInterface; {% endif %} @@ -26,20 +25,10 @@ use Drupal\user\EntityOwnerInterface; * * @ingroup {{module}} */ -interface {{ entity_class }}Interface extends {% if revisionable %}RevisionableInterface{% else %} ContentEntityInterface{% endif %}, EntityChangedInterface, EntityOwnerInterface {% endblock %} +interface {{ entity_class }}Interface extends {% if revisionable %}RevisionableInterface, RevisionLogInterface{% else %} ContentEntityInterface{% endif %}, EntityChangedInterface, EntityOwnerInterface {% endblock %} {% block class_methods %} // Add get/set methods for your configuration properties here. -{% if bundle_entity_type %} - /** - * Gets the {{ label }} type. - * - * @return string - * The {{ label }} type. - */ - public function getType(); - -{% endif %} /** * Gets the {{ label }} name. * @@ -125,7 +114,7 @@ interface {{ entity_class }}Interface extends {% if revisionable %}RevisionableI * @return \Drupal\user\UserInterface * The user entity for the revision author. */ - public function getRevisionAuthor(); + public function getRevisionUser(); /** * Sets the {{ label }} revision author. @@ -136,6 +125,6 @@ interface {{ entity_class }}Interface extends {% if revisionable %}RevisionableI * @return \Drupal\{{ module }}\Entity\{{ entity_class }}Interface * The called {{ label }} entity. */ - public function setRevisionAuthorId($uid); + public function setRevisionUserId($uid); {% endif %} {% endblock %} diff --git a/templates/module/src/Form/entity.php.twig b/templates/module/src/Form/entity.php.twig index 0b415c571..0ce40406a 100644 --- a/templates/module/src/Form/entity.php.twig +++ b/templates/module/src/Form/entity.php.twig @@ -16,8 +16,6 @@ use Drupal\Core\Form\FormStateInterface; {% block class_declaration %} /** * Class {{ entity_class }}Form. - * - * @package Drupal\{{ module }}\Form */ class {{ entity_class }}Form extends EntityForm {% endblock %} {% block class_methods %} @@ -70,6 +68,6 @@ class {{ entity_class }}Form extends EntityForm {% endblock %} '%label' => ${{ entity_name | machine_name }}->label(), ])); } - $form_state->setRedirectUrl(${{ entity_name | machine_name }}->urlInfo('collection')); + $form_state->setRedirectUrl(${{ entity_name | machine_name }}->toUrl('collection')); } {% endblock %} diff --git a/templates/module/src/Form/form-config.php.twig b/templates/module/src/Form/form-config.php.twig index 52ca88bfa..a4cc85a4f 100644 --- a/templates/module/src/Form/form-config.php.twig +++ b/templates/module/src/Form/form-config.php.twig @@ -20,12 +20,13 @@ use Symfony\Component\DependencyInjection\ContainerInterface; {% block class_declaration %} /** * Class {{ class_name }}. - * - * @package Drupal\{{module_name}}\Form */ class {{ class_name }} extends ConfigFormBase {% endblock %} {% block class_construct %} {% if services is not empty %} + /** + * Constructs a new {{ class_name }} object. + */ public function __construct( ConfigFactoryInterface $config_factory, {{ servicesAsParameters(services)|join(',\n ') }} diff --git a/templates/module/src/Form/form.php.twig b/templates/module/src/Form/form.php.twig index 1e307cef4..6548f0283 100644 --- a/templates/module/src/Form/form.php.twig +++ b/templates/module/src/Form/form.php.twig @@ -19,12 +19,13 @@ use Symfony\Component\DependencyInjection\ContainerInterface; {% block class_declaration %} /** * Class {{ class_name }}. - * - * @package Drupal\{{module_name}}\Form */ class {{ class_name }} extends FormBase {% endblock %} {% block class_construct %} {% if services is not empty %} + /** + * Constructs a new {{ class_name }} object. + */ public function __construct( {{ servicesAsParameters(services)|join(',\n ') }} ) { @@ -80,18 +81,17 @@ class {{ class_name }} extends FormBase {% endblock %} {% endif %} ]; {% endfor %} - $form['submit'] = [ - '#type' => 'submit', - '#value' => t('Submit'), + '#type' => 'submit', + '#value' => $this->t('Submit'), ]; return $form; } /** - * {@inheritdoc} - */ + * {@inheritdoc} + */ public function validateForm(array &$form, FormStateInterface $form_state) { parent::validateForm($form, $form_state); } @@ -102,7 +102,7 @@ class {{ class_name }} extends FormBase {% endblock %} public function submitForm(array &$form, FormStateInterface $form_state) { // Display result. foreach ($form_state->getValues() as $key => $value) { - drupal_set_message($key . ': ' . $value); + drupal_set_message($key . ': ' . $value); } } diff --git a/templates/module/src/Plugin/Block/block.php.twig b/templates/module/src/Plugin/Block/block.php.twig index e223b856f..c7d4cec4f 100644 --- a/templates/module/src/Plugin/Block/block.php.twig +++ b/templates/module/src/Plugin/Block/block.php.twig @@ -32,7 +32,7 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements {% block class_construct %} {% if services is not empty %} /** - * Construct. + * Constructs a new {{class_name}} object. * * @param array $configuration * A configuration array containing information about the plugin instance. diff --git a/templates/module/src/Plugin/Condition/condition.php.twig b/templates/module/src/Plugin/Condition/condition.php.twig index 569e56298..c782c90f5 100644 --- a/templates/module/src/Plugin/Condition/condition.php.twig +++ b/templates/module/src/Plugin/Condition/condition.php.twig @@ -42,7 +42,7 @@ public static function create(ContainerInterface $container, array $configuratio } /** - * Creates a new ExampleCondition instance. + * Creates a new {{ class_name }} object. * * @param array $configuration * The plugin configuration, i.e. an array with configuration values keyed diff --git a/templates/module/src/Plugin/Field/FieldFormatter/imageformatter.php.twig b/templates/module/src/Plugin/Field/FieldFormatter/imageformatter.php.twig index 34203bc4d..92059a4d4 100644 --- a/templates/module/src/Plugin/Field/FieldFormatter/imageformatter.php.twig +++ b/templates/module/src/Plugin/Field/FieldFormatter/imageformatter.php.twig @@ -58,7 +58,7 @@ class {{ class_name }} extends ImageFormatterBase implements ContainerFactoryPlu protected $imageStyleStorage; /** - * Constructs an ImageFormatter object. + * Constructs a new {{ class_name }} object. * * @param string $plugin_id * The plugin_id for the formatter. @@ -177,7 +177,7 @@ class {{ class_name }} extends ImageFormatterBase implements ContainerFactoryPlu if ($image_link_setting == 'content') { $entity = $items->getEntity(); if (!$entity->isNew()) { - $url = $entity->urlInfo(); + $url = $entity->toUrl(); } } elseif ($image_link_setting == 'file') { diff --git a/templates/module/src/Plugin/Mail/mail.php.twig b/templates/module/src/Plugin/Mail/mail.php.twig index d2e466e4c..878b3eea2 100644 --- a/templates/module/src/Plugin/Mail/mail.php.twig +++ b/templates/module/src/Plugin/Mail/mail.php.twig @@ -31,7 +31,7 @@ class {{class_name}} extends PhpMail {% if services is not empty %}implements Co {% block class_construct %} {% if services is not empty %} /** - * Construct. + * Constructs a new {{class_name}} object. * * @param array $configuration * A configuration array containing information about the plugin instance. diff --git a/templates/module/src/Plugin/Rest/Resource/rest.php.twig b/templates/module/src/Plugin/Rest/Resource/rest.php.twig index a5c3bbdce..9145f2e2a 100644 --- a/templates/module/src/Plugin/Rest/Resource/rest.php.twig +++ b/templates/module/src/Plugin/Rest/Resource/rest.php.twig @@ -43,7 +43,7 @@ class {{ class_name }} extends ResourceBase {% endblock %} {% block class_construct %} /** - * Constructs a Drupal\rest\Plugin\ResourceBase object. + * Constructs a new {{ class_name }} object. * * @param array $configuration * A configuration array containing information about the plugin instance. diff --git a/templates/module/src/Plugin/migrate/process/process.php.twig b/templates/module/src/Plugin/migrate/process/process.php.twig new file mode 100644 index 000000000..148d433f1 --- /dev/null +++ b/templates/module/src/Plugin/migrate/process/process.php.twig @@ -0,0 +1,33 @@ +{% extends "base/class.php.twig" %} + +{% block file_path %} +\Drupal\{{module}}\Plugin\migrate\process\{{class_name}}. +{% endblock %} + +{% block namespace_class %} +namespace Drupal\{{module}}\Plugin\migrate\process; +{% endblock %} + +{% block use_class %} +use Drupal\migrate\ProcessPluginBase; +use Drupal\migrate\MigrateExecutableInterface; +use Drupal\migrate\Row; +{% endblock %} + +{% block class_declaration %} +/** + * Provides a '{{class_name}}' migrate process plugin. + * + * @MigrateProcessPlugin( + * id = "{{plugin_id}}" + * ) + */ +class {{class_name}} extends ProcessPluginBase {% endblock %} +{% block class_methods %} + /** + * {@inheritdoc} + */ + public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { + // Plugin logic goes here. + } +{% endblock %} diff --git a/templates/module/src/Plugin/migrate/source/source.php.twig b/templates/module/src/Plugin/migrate/source/source.php.twig new file mode 100644 index 000000000..1f8ee6e23 --- /dev/null +++ b/templates/module/src/Plugin/migrate/source/source.php.twig @@ -0,0 +1,55 @@ +{% extends "base/class.php.twig" %} + +{% block file_path %} +\Drupal\{{module}}\Plugin\migrate\source\{{class_name}}. +{% endblock %} + +{% block namespace_class %} +namespace Drupal\{{module}}\Plugin\migrate\source; +{% endblock %} + +{% block use_class %} +use Drupal\migrate\Plugin\migrate\source\SqlBase; +{% endblock %} + +{% block class_declaration %} +/** + * Provides a '{{class_name}}' migrate source. + * + * @MigrateSource( + * id = "{{plugin_id}}" + * ) + */ +class {{class_name}} extends SqlBase {% endblock %} +{% block class_methods %} + /** + * {@inheritdoc} + */ + public function query() { + + return $this->select('{{table}}', '{{alias}}') + ->fields('{{alias}}'){% if group_by %} + ->groupBy('{{alias}}.{{group_by}}') + {% endif %}; + } + + /** + * {@inheritdoc} + */ + public function fields() { + $fields = [ + {% for field in fields %} + '{{field.id}}' => $this->t('{{field.description}}'), + {% endfor %} +]; + return $fields; + } + + /** + * {@inheritdoc} + */ + public function getIds() { + return [ + ]; + } +{% endblock %} diff --git a/templates/module/src/Plugin/skeleton.php.twig b/templates/module/src/Plugin/skeleton.php.twig index 4354a98f9..5bce614ab 100644 --- a/templates/module/src/Plugin/skeleton.php.twig +++ b/templates/module/src/Plugin/skeleton.php.twig @@ -39,7 +39,7 @@ class {{class_name}} implements {% if plugin_interface is not empty %} {{ plugin {% block class_construct %} {% if services is not empty %} /** - * Construct. + * Constructs a new {{class_name}} object. * * @param array $configuration * A configuration array containing information about the plugin instance. @@ -54,7 +54,7 @@ class {{class_name}} implements {% if plugin_interface is not empty %} {{ plugin $plugin_definition, {{ servicesAsParameters(services)|join(', \n\t') }} ) { - parent::__cons truct($configuration, $plugin_id, $plugin_definition); + parent::__construct($configuration, $plugin_id, $plugin_definition); {{ serviceClassInitialization(services) }} } {% endif %} diff --git a/templates/module/src/Routing/route-subscriber.php.twig b/templates/module/src/Routing/route-subscriber.php.twig index f7c52b53c..83cb44946 100644 --- a/templates/module/src/Routing/route-subscriber.php.twig +++ b/templates/module/src/Routing/route-subscriber.php.twig @@ -17,7 +17,6 @@ use Symfony\Component\Routing\RouteCollection; /** * Class {{ class }}. * - * @package Drupal\{{module}}\Routing * Listens to the dynamic route events. */ class {{ class }} extends RouteSubscriberBase {% endblock %} diff --git a/templates/module/src/Tests/load-test.php.twig b/templates/module/src/Tests/load-test.php.twig index df13935ca..69c2925a7 100644 --- a/templates/module/src/Tests/load-test.php.twig +++ b/templates/module/src/Tests/load-test.php.twig @@ -1,16 +1,16 @@ {% extends "base/class.php.twig" %} {% block file_path %} -\Drupal\{{ machine_name }}\Tests\LoadTest +\Drupal\Tests\{{ machine_name }}\Functional\LoadTest {% endblock %} {% block namespace_class %} -namespace Drupal\{{ machine_name }}\Tests; +namespace Drupal\Tests\{{ machine_name }}\Functional; {% endblock %} {% block use_class %} use Drupal\Core\Url; -use Drupal\simpletest\WebTestBase; +use Drupal\Tests\BrowserTestBase; {% endblock %} {% block class_declaration %} @@ -19,7 +19,7 @@ use Drupal\simpletest\WebTestBase; * * @group {{ machine_name }} */ -class LoadTest extends WebTestBase{% endblock %} +class LoadTest extends BrowserTestBase {% endblock %} {% block class_methods %} /** * Modules to enable. diff --git a/templates/module/src/TwigExtension/twig-extension.php.twig b/templates/module/src/TwigExtension/twig-extension.php.twig index 5b6f54758..362e65d5f 100644 --- a/templates/module/src/TwigExtension/twig-extension.php.twig +++ b/templates/module/src/TwigExtension/twig-extension.php.twig @@ -14,8 +14,6 @@ namespace Drupal\{{module}}\TwigExtension; {% block class_declaration %} /** * Class {{ class }}. - * - * @package Drupal\{{module}} */ class {{ class }} extends \Twig_Extension {% endblock %} @@ -36,7 +34,7 @@ class {{ class }} extends \Twig_Extension {% endblock %} {% if services|length > 1 %} /** - * Constructor. + * Constructs a new {{ class }} object. */ public function __construct({{ servicesAsParameters(services)|join(', ') }}) { parent::__construct($renderer); diff --git a/templates/module/src/cache-context.php.twig b/templates/module/src/cache-context.php.twig new file mode 100644 index 000000000..87a7b4c19 --- /dev/null +++ b/templates/module/src/cache-context.php.twig @@ -0,0 +1,54 @@ +{% extends "base/class.php.twig" %} + +{% block file_path %} +\Drupal\{{module}}\{{ class }}. +{% endblock %} + +{% block namespace_class %} +namespace Drupal\{{module}}\CacheContext; +{% endblock %} + +{% block use_class %} +use Drupal\Core\Cache\CacheableMetadata; +use Drupal\Core\Cache\Context\CacheContextInterface; +{% endblock %} + +{% block class_declaration %} +/** +* Class {{ class }}. +*/ +class {{ class }} implements CacheContextInterface {% endblock %} + +{% block class_construct %} + + /** + * Constructs a new {{ class }} object. + */ + public function __construct({{ servicesAsParameters(services)|join(', ') }}) { + {{ serviceClassInitialization(services) }} + } + +{% endblock %} + +{% block class_methods %} + /** + * {@inheritdoc} + */ + public static function getLabel() { + drupal_set_message('Lable of cache context'); + } + + /** + * {@inheritdoc} + */ + public function getContext() { + // Actual logic of context variation will lie here. + } + + /** + * {@inheritdoc} + */ + public function getCacheableMetadata() { + return new CacheableMetadata(); + } +{% endblock %} diff --git a/templates/module/src/entity-content-route-provider.php.twig b/templates/module/src/entity-content-route-provider.php.twig index 0a316ace6..afaa8908a 100644 --- a/templates/module/src/entity-content-route-provider.php.twig +++ b/templates/module/src/entity-content-route-provider.php.twig @@ -18,8 +18,8 @@ use Symfony\Component\Routing\Route; /** * Provides routes for {{ label }} entities. * - * @see Drupal\Core\Entity\Routing\AdminHtmlRouteProvider - * @see Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider + * @see \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider + * @see \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider */ class {{ entity_class }}HtmlRouteProvider extends AdminHtmlRouteProvider {% endblock %} {% block class_methods %} @@ -30,10 +30,6 @@ class {{ entity_class }}HtmlRouteProvider extends AdminHtmlRouteProvider {% endb $collection = parent::getRoutes($entity_type); $entity_type_id = $entity_type->id(); - - if ($collection_route = $this->getCollectionRoute($entity_type)) { - $collection->add("entity.{$entity_type_id}.collection", $collection_route); - } {% if revisionable %} if ($history_route = $this->getHistoryRoute($entity_type)) { @@ -45,16 +41,18 @@ class {{ entity_class }}HtmlRouteProvider extends AdminHtmlRouteProvider {% endb } if ($revert_route = $this->getRevisionRevertRoute($entity_type)) { - $collection->add("{$entity_type_id}.revision_revert_confirm", $revert_route); + $collection->add("entity.{$entity_type_id}.revision_revert", $revert_route); } if ($delete_route = $this->getRevisionDeleteRoute($entity_type)) { - $collection->add("{$entity_type_id}.revision_delete_confirm", $delete_route); + $collection->add("entity.{$entity_type_id}.revision_delete", $delete_route); } +{% if is_translatable %} if ($translation_route = $this->getRevisionTranslationRevertRoute($entity_type)) { $collection->add("{$entity_type_id}.revision_revert_translation_confirm", $translation_route); } +{% endif %} {% endif %} if ($settings_form_route = $this->getSettingsFormRoute($entity_type)) { @@ -63,31 +61,6 @@ class {{ entity_class }}HtmlRouteProvider extends AdminHtmlRouteProvider {% endb return $collection; } - - /** - * Gets the collection route. - * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type - * The entity type. - * - * @return \Symfony\Component\Routing\Route|null - * The generated route, if available. - */ - protected function getCollectionRoute(EntityTypeInterface $entity_type) { - if ($entity_type->hasLinkTemplate('collection') && $entity_type->hasListBuilderClass()) { - $entity_type_id = $entity_type->id(); - $route = new Route($entity_type->getLinkTemplate('collection')); - $route - ->setDefaults([ - '_entity_list' => $entity_type_id, - '_title' => "{$entity_type->getLabel()} list", - ]) - ->setRequirement('_permission', 'access {{ label|lower }} overview') - ->setOption('_admin_route', TRUE); - - return $route; - } - } {% if revisionable %} /** diff --git a/templates/module/src/entity-route-provider.php.twig b/templates/module/src/entity-route-provider.php.twig index b7ef81652..860d7b307 100644 --- a/templates/module/src/entity-route-provider.php.twig +++ b/templates/module/src/entity-route-provider.php.twig @@ -29,39 +29,8 @@ class {{ entity_class }}HtmlRouteProvider extends AdminHtmlRouteProvider {% endb public function getRoutes(EntityTypeInterface $entity_type) { $collection = parent::getRoutes($entity_type); - $entity_type_id = $entity_type->id(); - - if ($collection_route = $this->getCollectionRoute($entity_type)) { - $collection->add("entity.{$entity_type_id}.collection", $collection_route); - } + // Provide your custom entity routes here. return $collection; } - - /** - * Gets the collection route. - * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type - * The entity type. - * - * @return \Symfony\Component\Routing\Route|null - * The generated route, if available. - */ - protected function getCollectionRoute(EntityTypeInterface $entity_type) { - if ($entity_type->hasLinkTemplate('collection') && $entity_type->hasListBuilderClass()) { - $entity_type_id = $entity_type->id(); - $route = new Route($entity_type->getLinkTemplate('collection')); - $route - ->setDefaults([ - '_entity_list' => $entity_type_id, - // Make sure this is not a TranslatableMarkup object as the - // TitleResolver translates this string again. - '_title' => (string) $entity_type->getLabel(), - ]) - ->setRequirement('_permission', $entity_type->getAdminPermission()) - ->setOption('_admin_route', TRUE); - - return $route; - } - } {% endblock %} diff --git a/templates/module/src/entity-storage.php.twig b/templates/module/src/entity-storage.php.twig index 006f417e4..01aec1cc4 100644 --- a/templates/module/src/entity-storage.php.twig +++ b/templates/module/src/entity-storage.php.twig @@ -33,7 +33,7 @@ class {{ entity_class }}Storage extends SqlContentEntityStorage implements {{ en public function revisionIds({{ entity_class }}Interface $entity) { return $this->database->query( 'SELECT vid FROM {{ '{'~entity_name~'_revision}' }} WHERE id=:id ORDER BY vid', - array(':id' => $entity->id()) + [':id' => $entity->id()] )->fetchCol(); } @@ -43,7 +43,7 @@ class {{ entity_class }}Storage extends SqlContentEntityStorage implements {{ en public function userRevisionIds(AccountInterface $account) { return $this->database->query( 'SELECT vid FROM {{ '{'~entity_name~'_field_revision}' }} WHERE uid = :uid ORDER BY vid', - array(':uid' => $account->id()) + [':uid' => $account->id()] )->fetchCol(); } @@ -51,7 +51,7 @@ class {{ entity_class }}Storage extends SqlContentEntityStorage implements {{ en * {@inheritdoc} */ public function countDefaultLanguageRevisions({{ entity_class }}Interface $entity) { - return $this->database->query('SELECT COUNT(*) FROM {{ '{'~entity_name~'_field_revision}' }} WHERE id = :id AND default_langcode = 1', array(':id' => $entity->id())) + return $this->database->query('SELECT COUNT(*) FROM {{ '{'~entity_name~'_field_revision}' }} WHERE id = :id AND default_langcode = 1', [':id' => $entity->id()]) ->fetchField(); } @@ -60,7 +60,7 @@ class {{ entity_class }}Storage extends SqlContentEntityStorage implements {{ en */ public function clearRevisionsLanguage(LanguageInterface $language) { return $this->database->update('{{ entity_name }}_revision') - ->fields(array('langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED)) + ->fields(['langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED]) ->condition('langcode', $language->getId()) ->execute(); } diff --git a/templates/module/src/event-subscriber.php.twig b/templates/module/src/event-subscriber.php.twig index a8fded0f3..e79389234 100644 --- a/templates/module/src/event-subscriber.php.twig +++ b/templates/module/src/event-subscriber.php.twig @@ -16,15 +16,13 @@ use Symfony\Component\EventDispatcher\Event; {% block class_declaration %} /** * Class {{ class }}. - * - * @package Drupal\{{module}} */ class {{ class }} implements EventSubscriberInterface {% endblock %} {% block class_construct %} /** - * Constructor. + * Constructs a new {{ class }} object. */ public function __construct({{ servicesAsParameters(services)|join(', ') }}) { {{ serviceClassInitialization(services) }} diff --git a/templates/module/src/listbuilder-entity-content.php.twig b/templates/module/src/listbuilder-entity-content.php.twig index 1615da806..46af6648c 100644 --- a/templates/module/src/listbuilder-entity-content.php.twig +++ b/templates/module/src/listbuilder-entity-content.php.twig @@ -11,8 +11,7 @@ namespace Drupal\{{module}}; {% block use_class %} use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityListBuilder; -use Drupal\Core\Routing\LinkGeneratorTrait; -use Drupal\Core\Url; +use Drupal\Core\Link; {% endblock %} {% block class_declaration %} @@ -22,9 +21,6 @@ use Drupal\Core\Url; * @ingroup {{ module }} */ class {{ entity_class }}ListBuilder extends EntityListBuilder {% endblock %} -{% block use_trait %} - use LinkGeneratorTrait; -{% endblock %} {% block class_methods %} /** @@ -42,13 +38,10 @@ class {{ entity_class }}ListBuilder extends EntityListBuilder {% endblock %} public function buildRow(EntityInterface $entity) { /* @var $entity \Drupal\{{module}}\Entity\{{ entity_class }} */ $row['id'] = $entity->id(); - $row['name'] = $this->l( + $row['name'] = Link::createFromRoute( $entity->label(), - new Url( - 'entity.{{ entity_name }}.edit_form', array( - '{{ entity_name }}' => $entity->id(), - ) - ) + 'entity.{{ entity_name }}.edit_form', + ['{{ entity_name }}' => $entity->id()] ); return $row + parent::buildRow($entity); } diff --git a/templates/module/src/plugin-type-annotation-manager.php.twig b/templates/module/src/plugin-type-annotation-manager.php.twig index f8645554b..2ed39b5df 100644 --- a/templates/module/src/plugin-type-annotation-manager.php.twig +++ b/templates/module/src/plugin-type-annotation-manager.php.twig @@ -22,7 +22,7 @@ class {{ class_name }}Manager extends DefaultPluginManager {% endblock %} {% block class_methods %} /** - * Constructor for {{ class_name }}Manager objects. + * Constructs a new {{ class_name }}Manager object. * * @param \Traversable $namespaces * An object that implements \Traversable which contains the root paths diff --git a/templates/module/src/service-interface.php.twig b/templates/module/src/service-interface.php.twig index 6177ec8da..9989f83e4 100644 --- a/templates/module/src/service-interface.php.twig +++ b/templates/module/src/service-interface.php.twig @@ -11,7 +11,5 @@ namespace Drupal\{{module}}; {% block interface_declaration %} /** * Interface {{ interface }}. - * - * @package Drupal\{{module}} */ interface {{ interface }} {% endblock %} diff --git a/templates/module/src/service.php.twig b/templates/module/src/service.php.twig index 2deb9d3eb..1347bfa56 100644 --- a/templates/module/src/service.php.twig +++ b/templates/module/src/service.php.twig @@ -10,13 +10,11 @@ namespace Drupal\{{module}};{% endblock %} {% block class_declaration %} /** * Class {{ class }}. - * - * @package Drupal\{{module}} */ class {{ class }}{% if(interface is defined and interface) %} implements {{ interface }}{% endif %} {% endblock %} {% block class_construct %} /** - * Constructor. + * Constructs a new {{ class }} object. */ public function __construct({{ servicesAsParameters(services)|join(', ') }}) { {{ serviceClassInitialization(services) }} diff --git a/templates/module/src/yaml-plugin-manager.php.twig b/templates/module/src/yaml-plugin-manager.php.twig index 81e6442b7..16d486bc5 100644 --- a/templates/module/src/yaml-plugin-manager.php.twig +++ b/templates/module/src/yaml-plugin-manager.php.twig @@ -28,14 +28,14 @@ class {{ plugin_class }}Manager extends DefaultPluginManager implements {{ plugi * * @var array */ - protected $defaults = array( + protected $defaults = [ // Add required and optional plugin properties. 'id' => '', 'label' => '', - ); + ]; /** - * Constructs a {{ plugin_class }}Manager object. + * Constructs a new {{ plugin_class }}Manager object. * * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. @@ -45,7 +45,7 @@ class {{ plugin_class }}Manager extends DefaultPluginManager implements {{ plugi public function __construct(ModuleHandlerInterface $module_handler, CacheBackendInterface $cache_backend) { // Add more services as required. $this->moduleHandler = $module_handler; - $this->setCacheBackend($cache_backend, '{{ plugin_name }}', array('{{ plugin_name }}')); + $this->setCacheBackend($cache_backend, '{{ plugin_name }}', ['{{ plugin_name }}']); } /** diff --git a/templates/module/twig-template-file.twig b/templates/module/twig-template-file.twig new file mode 100644 index 000000000..91e43c8f8 --- /dev/null +++ b/templates/module/twig-template-file.twig @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/templates/module/src/update.php.twig b/templates/module/update.php.twig similarity index 79% rename from templates/module/src/update.php.twig rename to templates/module/update.php.twig index 431304d43..2f8d005f1 100644 --- a/templates/module/src/update.php.twig +++ b/templates/module/update.php.twig @@ -1,10 +1,12 @@ {% block file_methods %} +{% if not file_exists %} +{% include 'module/php_tag.php.twig' %} +{% endif %} /** * Implements hook_update_N() on Module {{ module }} Update # {{ update_number }}. */ function {{ module }}_update_{{ update_number }}(&$sandbox) { drupal_set_message('Module {{ module }} Update # {{ update_number }} () was executed successfully.'); } -{% endblock %} - +{% endblock %} diff --git a/templates/profile/info.yml.twig b/templates/profile/info.yml.twig index 31d0472e2..385baa630 100644 --- a/templates/profile/info.yml.twig +++ b/templates/profile/info.yml.twig @@ -14,3 +14,10 @@ dependencies: - {{ dependency }} {% endfor %} {% endif %} +{% if themes %} + +themes: +{% for theme in themes %} + - {{ theme }} +{% endfor %} +{% endif %} diff --git a/templates/theme/info.yml.twig b/templates/theme/info.yml.twig index e711e06cf..f68e9fb7e 100644 --- a/templates/theme/info.yml.twig +++ b/templates/theme/info.yml.twig @@ -5,7 +5,11 @@ package: {{ package }} core: {{ core }} libraries: - {{ machine_name }}/{{ global_library }} - +{% if libraries %} +{% for library in libraries %} + - {{ machine_name }}/{{ library.library_name }} +{% endfor %} +{% endif %} base theme: {{ base_theme }} {% if base_theme == 'classy' %} #Using Classy as a base theme https://www.drupal.org/theme-guide/8/classy diff --git a/templates/theme/libraries.yml.twig b/templates/theme/libraries.yml.twig new file mode 100644 index 000000000..8d2379ea6 --- /dev/null +++ b/templates/theme/libraries.yml.twig @@ -0,0 +1,16 @@ +{{ global_library }}: + version: 1.0 + css: + theme: + #css/your_style_sheet.css : {} + js: + #js/your_js.js : {} +{% for library in libraries %} +{{ library.library_name }}: + version: {{ library.library_version }} + css: + theme: + #js/your_js.js : {} + js: + #js/your_js.js : {} +{% endfor %} \ No newline at end of file diff --git a/services-drupal-install.yml b/uninstall.services.yml similarity index 66% rename from services-drupal-install.yml rename to uninstall.services.yml index 50ece8702..c1835417a 100644 --- a/services-drupal-install.yml +++ b/uninstall.services.yml @@ -1,13 +1,10 @@ services: - # Installer services - console.root: - class: SplString console.site: class: Drupal\Console\Utils\Site - arguments: ['@app.root'] + arguments: ['@app.root', '@console.configuration_manager'] console.extension_manager: class: Drupal\Console\Extension\Manager - arguments: ['@console.site', '@app.root'] + arguments: ['@console.site', '@http_client', '@app.root'] console.server: class: Drupal\Console\Command\ServerCommand arguments: ['@app.root', '@console.configuration_manager'] @@ -18,3 +15,10 @@ services: arguments: ['@console.extension_manager', '@console.site', '@console.configuration_manager', '@app.root'] tags: - { name: drupal.command } + console.multisite_new: + class: Drupal\Console\Command\Multisite\NewCommand + arguments: ['@app.root'] + tags: + - { name: drupal.command } + http_client: + class: GuzzleHttp\Client