BakeTask.php 1.8 KB

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