BakeTask.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * Base class for Bake Tasks.
  4. *
  5. * PHP 5
  6. *
  7. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  8. * Copyright 2005-2011, Cake Software Foundation, Inc.
  9. *
  10. * Licensed under The MIT License
  11. * Redistributions of files must retain the above copyright notice.
  12. *
  13. * @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. * @link http://cakephp.org CakePHP(tm) Project
  15. * @since CakePHP(tm) v 1.3
  16. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  17. */
  18. /**
  19. * Base class for Bake Tasks.
  20. *
  21. * @package Cake.Console.Command.Task
  22. */
  23. class BakeTask extends Shell {
  24. /**
  25. * Name of plugin
  26. *
  27. * @var string
  28. * @access public
  29. */
  30. public $plugin = null;
  31. /**
  32. * The db connection being used for baking
  33. *
  34. * @var string
  35. * @access public
  36. */
  37. public $connection = null;
  38. /**
  39. * Flag for interactive mode
  40. *
  41. * @var boolean
  42. */
  43. public $interactive = false;
  44. /**
  45. * Gets the path for output. Checks the plugin property
  46. * and returns the correct path.
  47. *
  48. * @return string Path to output.
  49. */
  50. public function getPath() {
  51. $path = $this->path;
  52. if (isset($this->plugin)) {
  53. $path = $this->_pluginPath($this->plugin) . $this->name . DS;
  54. }
  55. return $path;
  56. }
  57. /**
  58. * Base execute method parses some parameters and sets some properties on the bake tasks.
  59. * call when overriding execute()
  60. *
  61. * @return void
  62. */
  63. public function execute() {
  64. foreach($this->args as $i => $arg) {
  65. if (strpos($arg, '.')) {
  66. list($this->params['plugin'], $this->args[$i]) = pluginSplit($arg);
  67. break;
  68. }
  69. }
  70. if (isset($this->params['plugin'])) {
  71. $this->plugin = $this->params['plugin'];
  72. }
  73. }
  74. }