mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Updating visibility in the various bake tasks.
This commit is contained in:
parent
854583f0d7
commit
02c56ba8c1
7 changed files with 49 additions and 54 deletions
|
@ -57,7 +57,7 @@ class ControllerTask extends BakeTask {
|
|||
*/
|
||||
public function execute() {
|
||||
if (empty($this->args)) {
|
||||
$this->__interactive();
|
||||
$this->_interactive();
|
||||
}
|
||||
|
||||
if (isset($this->args[0])) {
|
||||
|
@ -101,10 +101,9 @@ class ControllerTask extends BakeTask {
|
|||
/**
|
||||
* Bake All the controllers at once. Will only bake controllers for models that exist.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function all() {
|
||||
public function all() {
|
||||
$this->interactive = false;
|
||||
$this->listAll($this->connection, false);
|
||||
ClassRegistry::config('Model', array('ds' => $this->connection));
|
||||
|
@ -124,9 +123,9 @@ class ControllerTask extends BakeTask {
|
|||
/**
|
||||
* Interactive
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function __interactive() {
|
||||
protected function _interactive() {
|
||||
$this->interactive = true;
|
||||
$this->hr();
|
||||
$this->out(sprintf(__("Bake Controller\nPath: %s"), $this->path));
|
||||
|
@ -210,7 +209,7 @@ class ControllerTask extends BakeTask {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function confirmController($controllerName, $useDynamicScaffold, $helpers, $components) {
|
||||
public function confirmController($controllerName, $useDynamicScaffold, $helpers, $components) {
|
||||
$this->out();
|
||||
$this->hr();
|
||||
$this->out(__('The following controller will be created:'));
|
||||
|
@ -248,7 +247,7 @@ class ControllerTask extends BakeTask {
|
|||
*
|
||||
* @return array Array containing (bakeRegular, bakeAdmin) answers
|
||||
*/
|
||||
function _askAboutMethods() {
|
||||
protected function _askAboutMethods() {
|
||||
$wannaBakeCrud = $this->in(
|
||||
__("Would you like to create some basic class methods \n(index(), add(), view(), edit())?"),
|
||||
array('y','n'), 'n'
|
||||
|
@ -269,7 +268,7 @@ class ControllerTask extends BakeTask {
|
|||
* @return string Baked actions
|
||||
* @access private
|
||||
*/
|
||||
function bakeActions($controllerName, $admin = null, $wannaUseSession = true) {
|
||||
public function bakeActions($controllerName, $admin = null, $wannaUseSession = true) {
|
||||
$currentModelName = $modelImport = $this->_modelName($controllerName);
|
||||
if ($this->plugin) {
|
||||
$modelImport = $this->plugin . '.' . $modelImport;
|
||||
|
@ -301,9 +300,8 @@ class ControllerTask extends BakeTask {
|
|||
* @param array $components Components to use in controller
|
||||
* @param array $uses Models to use in controller
|
||||
* @return string Baked controller
|
||||
* @access private
|
||||
*/
|
||||
function bake($controllerName, $actions = '', $helpers = null, $components = null) {
|
||||
public function bake($controllerName, $actions = '', $helpers = null, $components = null) {
|
||||
$isScaffold = ($actions === 'scaffold') ? true : false;
|
||||
|
||||
$this->Template->set('plugin', Inflector::camelize($this->plugin));
|
||||
|
@ -323,9 +321,8 @@ class ControllerTask extends BakeTask {
|
|||
*
|
||||
* @param string $className Controller class name
|
||||
* @return string Baked test
|
||||
* @access private
|
||||
*/
|
||||
function bakeTest($className) {
|
||||
public function bakeTest($className) {
|
||||
$this->Test->plugin = $this->plugin;
|
||||
$this->Test->connection = $this->connection;
|
||||
$this->Test->interactive = $this->interactive;
|
||||
|
@ -337,7 +334,7 @@ class ControllerTask extends BakeTask {
|
|||
*
|
||||
* @return array Helpers that the user wants to use.
|
||||
*/
|
||||
function doHelpers() {
|
||||
public function doHelpers() {
|
||||
return $this->_doPropertyChoices(
|
||||
__("Would you like this controller to use other helpers\nbesides HtmlHelper and FormHelper?"),
|
||||
__("Please provide a comma separated list of the other\nhelper names you'd like to use.\nExample: 'Ajax, Javascript, Time'")
|
||||
|
@ -349,7 +346,7 @@ class ControllerTask extends BakeTask {
|
|||
*
|
||||
* @return array Components the user wants to use.
|
||||
*/
|
||||
function doComponents() {
|
||||
public function doComponents() {
|
||||
return $this->_doPropertyChoices(
|
||||
__("Would you like this controller to use any components?"),
|
||||
__("Please provide a comma separated list of the component names you'd like to use.\nExample: 'Acl, Security, RequestHandler'")
|
||||
|
@ -363,7 +360,7 @@ class ControllerTask extends BakeTask {
|
|||
* @param sting $example A question for a comma separated list, with examples.
|
||||
* @return array Array of values for property.
|
||||
*/
|
||||
function _doPropertyChoices($prompt, $example) {
|
||||
protected function _doPropertyChoices($prompt, $example) {
|
||||
$proceed = $this->in($prompt, array('y','n'), 'n');
|
||||
$property = array();
|
||||
if (strtolower($proceed) == 'y') {
|
||||
|
|
|
@ -69,7 +69,7 @@ class DbConfigTask extends Shell {
|
|||
*/
|
||||
public function execute() {
|
||||
if (empty($this->args)) {
|
||||
$this->__interactive();
|
||||
$this->_interactive();
|
||||
$this->_stop();
|
||||
}
|
||||
}
|
||||
|
@ -77,9 +77,9 @@ class DbConfigTask extends Shell {
|
|||
/**
|
||||
* Interactive interface
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function __interactive() {
|
||||
protected function _interactive() {
|
||||
$this->hr();
|
||||
$this->out('Database Configuration:');
|
||||
$this->hr();
|
||||
|
@ -175,7 +175,7 @@ class DbConfigTask extends Shell {
|
|||
$config = compact('name', 'driver', 'persistent', 'host', 'login', 'password', 'database', 'prefix', 'encoding', 'port', 'schema');
|
||||
|
||||
while ($this->__verify($config) == false) {
|
||||
$this->__interactive();
|
||||
$this->_interactive();
|
||||
}
|
||||
$dbConfigs[] = $config;
|
||||
$doneYet = $this->in('Do you wish to add another database configuration?', null, 'n');
|
||||
|
@ -194,9 +194,8 @@ class DbConfigTask extends Shell {
|
|||
* Output verification message and bake if it looks good
|
||||
*
|
||||
* @return boolean True if user says it looks good, false otherwise
|
||||
* @access private
|
||||
*/
|
||||
function __verify($config) {
|
||||
private function __verify($config) {
|
||||
$config = array_merge($this->__defaultConfig, $config);
|
||||
extract($config);
|
||||
$this->out();
|
||||
|
@ -347,7 +346,7 @@ class DbConfigTask extends Shell {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function getConfig() {
|
||||
public function getConfig() {
|
||||
App::import('Model', 'ConnectionManager', false);
|
||||
|
||||
$useDbConfig = 'default';
|
||||
|
|
|
@ -63,10 +63,11 @@ class FixtureTask extends BakeTask {
|
|||
* Execution method always used for tasks
|
||||
* Handles dispatching to interactive, named, or all processess.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute() {
|
||||
if (empty($this->args)) {
|
||||
$this->__interactive();
|
||||
$this->_interactive();
|
||||
}
|
||||
|
||||
if (isset($this->args[0])) {
|
||||
|
@ -85,10 +86,9 @@ class FixtureTask extends BakeTask {
|
|||
/**
|
||||
* Bake All the Fixtures at once. Will only bake fixtures for models that exist.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function all() {
|
||||
public function all() {
|
||||
$this->interactive = false;
|
||||
$this->Model->interactive = false;
|
||||
$tables = $this->Model->listAll($this->connection, false);
|
||||
|
@ -101,9 +101,9 @@ class FixtureTask extends BakeTask {
|
|||
/**
|
||||
* Interactive baking function
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function __interactive() {
|
||||
protected function _interactive() {
|
||||
$this->DbConfig->interactive = $this->Model->interactive = $this->interactive = true;
|
||||
$this->hr();
|
||||
$this->out(sprintf("Bake Fixture\nPath: %s", $this->path));
|
||||
|
@ -232,9 +232,9 @@ class FixtureTask extends BakeTask {
|
|||
/**
|
||||
* Get the path to the fixtures.
|
||||
*
|
||||
* @return void
|
||||
* @return string Path for the fixtures
|
||||
*/
|
||||
function getPath() {
|
||||
public function getPath() {
|
||||
$path = $this->path;
|
||||
if (isset($this->plugin)) {
|
||||
$path = $this->_pluginPath($this->plugin) . 'tests' . DS . 'fixtures' . DS;
|
||||
|
|
|
@ -54,7 +54,7 @@ class PluginTask extends Shell {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function execute() {
|
||||
public function execute() {
|
||||
if (empty($this->params['skel'])) {
|
||||
$this->params['skel'] = '';
|
||||
if (is_dir(CAKE_CORE_INCLUDE_PATH . DS . CAKE . 'console' . DS . 'templates' . DS . 'skel') === true) {
|
||||
|
@ -74,10 +74,10 @@ class PluginTask extends Shell {
|
|||
$this->err(sprintf(__('%s in path %s not found.'), $plugin, $pluginPath));
|
||||
$this->_stop();
|
||||
} else {
|
||||
$this->__interactive($plugin);
|
||||
$this->_interactive($plugin);
|
||||
}
|
||||
} else {
|
||||
return $this->__interactive();
|
||||
return $this->_interactive();
|
||||
}
|
||||
|
||||
if (isset($this->args[0])) {
|
||||
|
@ -102,7 +102,7 @@ class PluginTask extends Shell {
|
|||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function __interactive($plugin = null) {
|
||||
protected function _interactive($plugin = null) {
|
||||
while ($plugin === null) {
|
||||
$plugin = $this->in(__('Enter the name of the plugin in CamelCase format'));
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ class PluginTask extends Shell {
|
|||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function bake($plugin) {
|
||||
public function bake($plugin) {
|
||||
$pluginPath = Inflector::underscore($plugin);
|
||||
|
||||
$pathOptions = App::path('plugins');
|
||||
|
@ -200,9 +200,9 @@ class PluginTask extends Shell {
|
|||
/**
|
||||
* find and change $this->path to the user selection
|
||||
*
|
||||
* @return void
|
||||
* @return string plugin path
|
||||
*/
|
||||
function findPath($pathOptions) {
|
||||
public function findPath($pathOptions) {
|
||||
$valid = false;
|
||||
$max = count($pathOptions);
|
||||
while (!$valid) {
|
||||
|
|
|
@ -40,7 +40,7 @@ class TemplateTask extends Shell {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function initialize() {
|
||||
public function initialize() {
|
||||
$this->templatePaths = $this->_findThemes();
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ class TemplateTask extends Shell {
|
|||
*
|
||||
* @return array Array of bake themes that are installed.
|
||||
*/
|
||||
function _findThemes() {
|
||||
protected function _findThemes() {
|
||||
$paths = App::path('shells');
|
||||
$core = array_pop($paths);
|
||||
$core = str_replace('libs' . DS, '', $core);
|
||||
|
@ -99,7 +99,7 @@ class TemplateTask extends Shell {
|
|||
* Unused if $one is an associative array, otherwise serves as the values to $one's keys.
|
||||
* @return void
|
||||
*/
|
||||
function set($one, $two = null) {
|
||||
public function set($one, $two = null) {
|
||||
$data = null;
|
||||
if (is_array($one)) {
|
||||
if (is_array($two)) {
|
||||
|
@ -129,7 +129,7 @@ class TemplateTask extends Shell {
|
|||
* @access public
|
||||
* @return contents of generated code template
|
||||
*/
|
||||
function generate($directory, $filename, $vars = null) {
|
||||
public function generate($directory, $filename, $vars = null) {
|
||||
if ($vars !== null) {
|
||||
$this->set($vars);
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ class TemplateTask extends Shell {
|
|||
*
|
||||
* @return string returns the path to the selected theme.
|
||||
*/
|
||||
function getThemePath() {
|
||||
public function getThemePath() {
|
||||
if (count($this->templatePaths) == 1) {
|
||||
$paths = array_values($this->templatePaths);
|
||||
return $paths[0];
|
||||
|
@ -194,7 +194,7 @@ class TemplateTask extends Shell {
|
|||
* @access public
|
||||
* @return string filename will exit program if template is not found.
|
||||
*/
|
||||
function _findTemplate($path, $directory, $filename) {
|
||||
public function _findTemplate($path, $directory, $filename) {
|
||||
$themeFile = $path . $directory . DS . $filename . '.ctp';
|
||||
if (file_exists($themeFile)) {
|
||||
return $themeFile;
|
||||
|
|
|
@ -67,11 +67,11 @@ class TestTask extends BakeTask {
|
|||
*/
|
||||
public function execute() {
|
||||
if (empty($this->args)) {
|
||||
$this->__interactive();
|
||||
$this->_interactive();
|
||||
}
|
||||
|
||||
if (count($this->args) == 1) {
|
||||
$this->__interactive($this->args[0]);
|
||||
$this->_interactive($this->args[0]);
|
||||
}
|
||||
|
||||
if (count($this->args) > 1) {
|
||||
|
@ -87,7 +87,7 @@ class TestTask extends BakeTask {
|
|||
*
|
||||
* @access private
|
||||
*/
|
||||
function __interactive($type = null) {
|
||||
protected function _interactive($type = null) {
|
||||
$this->interactive = true;
|
||||
$this->hr();
|
||||
$this->out(__('Bake Tests'));
|
||||
|
|
|
@ -98,7 +98,7 @@ class ViewTask extends BakeTask {
|
|||
*/
|
||||
public function execute() {
|
||||
if (empty($this->args)) {
|
||||
$this->__interactive();
|
||||
$this->_interactive();
|
||||
}
|
||||
if (empty($this->args[0])) {
|
||||
return;
|
||||
|
@ -144,7 +144,7 @@ class ViewTask extends BakeTask {
|
|||
*
|
||||
* @return array Array of action names that should be baked
|
||||
*/
|
||||
function _methodsToBake() {
|
||||
protected function _methodsToBake() {
|
||||
$methods = array_diff(
|
||||
array_map('strtolower', get_class_methods($this->controllerName . 'Controller')),
|
||||
array_map('strtolower', get_class_methods('appcontroller'))
|
||||
|
@ -176,7 +176,7 @@ class ViewTask extends BakeTask {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function all() {
|
||||
public function all() {
|
||||
$this->Controller->interactive = false;
|
||||
$tables = $this->Controller->listAll($this->connection, false);
|
||||
|
||||
|
@ -202,9 +202,8 @@ class ViewTask extends BakeTask {
|
|||
/**
|
||||
* Handles interactive baking
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function __interactive() {
|
||||
protected function _interactive() {
|
||||
$this->hr();
|
||||
$this->out(sprintf("Bake View\nPath: %s", $this->path));
|
||||
$this->hr();
|
||||
|
@ -265,7 +264,7 @@ class ViewTask extends BakeTask {
|
|||
* @return array Returns an variables to be made available to a view template
|
||||
* @access private
|
||||
*/
|
||||
function __loadController() {
|
||||
private function __loadController() {
|
||||
if (!$this->controllerName) {
|
||||
$this->err(__('Controller not found'));
|
||||
}
|
||||
|
@ -314,7 +313,7 @@ class ViewTask extends BakeTask {
|
|||
* @param array $actions Array of actions to make files for.
|
||||
* @return void
|
||||
*/
|
||||
function bakeActions($actions, $vars) {
|
||||
public function bakeActions($actions, $vars) {
|
||||
foreach ($actions as $action) {
|
||||
$content = $this->getContent($action, $vars);
|
||||
$this->bake($action, $content);
|
||||
|
@ -326,7 +325,7 @@ class ViewTask extends BakeTask {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
function customAction() {
|
||||
public function customAction() {
|
||||
$action = '';
|
||||
while ($action == '') {
|
||||
$action = $this->in(__('Action Name? (use lowercase_underscored function name)'));
|
||||
|
@ -463,7 +462,7 @@ class ViewTask extends BakeTask {
|
|||
* @return array $associations
|
||||
* @access private
|
||||
*/
|
||||
function __associations(&$model) {
|
||||
private function __associations(&$model) {
|
||||
$keys = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
|
||||
$associations = array();
|
||||
|
||||
|
|
Loading…
Reference in a new issue