/** * main */ public function main() { $this->_header(); $this->out("When a mommy and daddy class get together... ", 0); list($one, $two) = $this->args; $oneClass = substr($one, strrpos($one, '/') + 1); $onePath = substr($one, 0, strrpos($one, '/')); $twoClass = substr($two, strrpos($two, '/') + 1); $twoPath = substr($two, 0, strrpos($two, '/')); $PhpBaker = new PhpBaker(); $PhpBaker->merge(array($oneClass, $onePath), array($twoClass, $twoPath)); $this->out("<good>;)</good>"); }
/** * testArrayToCode */ public function testArrayToCode() { $PhpBaker = new PhpBaker('Comment', 'Model'); $in = array('name' => 'Test', 'actsAs' => array('Translate' => array('name', 'body'))); $result = $PhpBaker->arrayToCode($in); $expected = "array(\n\t'name' => 'Test',\n\t'actsAs' => array(\n\t\t'Translate' => array(\n\t\t\t'name',\n\t\t\t'body',\n\t\t),\n\t),\n)"; $this->assertEquals($expected, $result); }
/** * Turn config into bake array for Controllers * * @param array $config * @return boolean */ public function bakeControllers($config = array()) { $config = Set::merge($this->_defaultConfig, $config); if (empty($config['recipe'])) { return false; } foreach ($config['recipe'] as $name => $node) { $className = Inflector::camelize($name); $class = $className . 'Controller'; $props = array(); if (!empty($node['controller'])) { foreach ($node['controller'] as $key => $val) { $props[$key] = array('value' => $val); } } if (empty($config['config']['code_header']['doc'])) { $config['config']['code_header']['doc'] = $className . ' Controller'; } $bake = array('class' => array('class' => 'class ' . $class . ' extends BasesController', 'doc' => $this->_buildDocHeader($config), 'uses' => array("App::uses('BasesController', 'Oven.Controller');")), 'properties' => $props, 'methods' => array()); $PhpBaker = new PhpBaker($class, 'Controller'); $PhpBaker->write($bake); } $this->_getControllers(); return true; }