BakeTask.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. App::uses('Shell', 'Console');
  19. /**
  20. * Base class for Bake Tasks.
  21. *
  22. * @package Cake.Console.Command.Task
  23. */
  24. class BakeTask extends Shell {
  25. /**
  26. * Name of plugin
  27. *
  28. * @var string
  29. */
  30. public $plugin = null;
  31. /**
  32. * The db connection being used for baking
  33. *
  34. * @var string
  35. */
  36. public $connection = null;
  37. /**
  38. * Flag for interactive mode
  39. *
  40. * @var boolean
  41. */
  42. public $interactive = false;
  43. /**
  44. * Disable caching for baking.
  45. * This forces the most current database schema to be used.
  46. *
  47. * @return void
  48. */
  49. function startup() {
  50. Configure::write('Cache.disable', 1);
  51. parent::startup();
  52. }
  53. /**
  54. * Gets the path for output. Checks the plugin property
  55. * and returns the correct path.
  56. *
  57. * @return string Path to output.
  58. */
  59. public function getPath() {
  60. $path = $this->path;
  61. if (isset($this->plugin)) {
  62. $path = $this->_pluginPath($this->plugin) . $this->name . DS;
  63. }
  64. return $path;
  65. }
  66. /**
  67. * Base execute method parses some parameters and sets some properties on the bake tasks.
  68. * call when overriding execute()
  69. *
  70. * @return void
  71. */
  72. public function execute() {
  73. foreach($this->args as $i => $arg) {
  74. if (strpos($arg, '.')) {
  75. list($this->params['plugin'], $this->args[$i]) = pluginSplit($arg);
  76. break;
  77. }
  78. }
  79. if (isset($this->params['plugin'])) {
  80. $this->plugin = $this->params['plugin'];
  81. }
  82. }
  83. }