BakeTask.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. * @link http://cakephp.org CakePHP(tm) Project
  15. * @package cake.console.shells.tasks
  16. * @since CakePHP(tm) v 1.3
  17. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  18. */
  19. class BakeTask extends Shell {
  20. /**
  21. * Name of plugin
  22. *
  23. * @var string
  24. * @access public
  25. */
  26. public $plugin = null;
  27. /**
  28. * The db connection being used for baking
  29. *
  30. * @var string
  31. * @access public
  32. */
  33. public $connection = null;
  34. /**
  35. * Flag for interactive mode
  36. *
  37. * @var boolean
  38. */
  39. public $interactive = false;
  40. /**
  41. * Gets the path for output. Checks the plugin property
  42. * and returns the correct path.
  43. *
  44. * @return string Path to output.
  45. */
  46. public function getPath() {
  47. $path = $this->path;
  48. if (isset($this->plugin)) {
  49. $path = $this->_pluginPath($this->plugin) . $this->name . DS;
  50. }
  51. return $path;
  52. }
  53. /**
  54. * Base execute method parses some parameters and sets some properties on the bake tasks.
  55. * call when overriding execute()
  56. *
  57. * @return void
  58. */
  59. public function execute() {
  60. foreach($this->args as $i => $arg) {
  61. if (strpos($arg, '.')) {
  62. list($this->params['plugin'], $this->args[$i]) = pluginSplit($arg);
  63. break;
  64. }
  65. }
  66. if (isset($this->params['plugin'])) {
  67. $this->plugin = $this->params['plugin'];
  68. }
  69. }
  70. }