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