PluginShell.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  11. * @link https://cakephp.org CakePHP(tm) Project
  12. * @since 3.0.0
  13. * @license https://opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Shell;
  16. use Cake\Console\Shell;
  17. use Cake\Core\Plugin;
  18. /**
  19. * Shell for tasks related to plugins.
  20. *
  21. * @property \Cake\Shell\Task\AssetsTask $Assets
  22. * @property \Cake\Shell\Task\LoadTask $Load
  23. * @property \Cake\Shell\Task\UnloadTask $Unload
  24. */
  25. class PluginShell extends Shell
  26. {
  27. /**
  28. * Tasks to load
  29. *
  30. * @var array
  31. */
  32. public $tasks = [
  33. 'Assets',
  34. 'Load',
  35. 'Unload',
  36. ];
  37. /**
  38. * Displays all currently loaded plugins.
  39. *
  40. * @return void
  41. */
  42. public function loaded()
  43. {
  44. $loaded = Plugin::loaded();
  45. $this->out($loaded);
  46. }
  47. /**
  48. * Gets the option parser instance and configures it.
  49. *
  50. * @return \Cake\Console\ConsoleOptionParser
  51. */
  52. public function getOptionParser()
  53. {
  54. $parser = parent::getOptionParser();
  55. $parser->setDescription('Plugin Shell perform various tasks related to plugin.')
  56. ->addSubcommand('assets', [
  57. 'help' => 'Symlink / copy plugin assets to app\'s webroot',
  58. 'parser' => $this->Assets->getOptionParser()
  59. ])
  60. ->addSubcommand('loaded', [
  61. 'help' => 'Lists all loaded plugins',
  62. 'parser' => $parser,
  63. ])
  64. ->addSubcommand('load', [
  65. 'help' => 'Loads a plugin',
  66. 'parser' => $this->Load->getOptionParser(),
  67. ])
  68. ->addSubcommand('unload', [
  69. 'help' => 'Unloads a plugin',
  70. 'parser' => $this->Unload->getOptionParser(),
  71. ]);
  72. return $parser;
  73. }
  74. }