2015-12-01 12:02:51 +00:00
|
|
|
<?php
|
2015-12-01 14:26:22 +00:00
|
|
|
/**
|
2017-06-10 21:33:55 +00:00
|
|
|
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
2017-06-10 22:10:52 +00:00
|
|
|
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
2015-12-01 14:26:22 +00:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* For full copyright and license information, please see the LICENSE.txt
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2017-06-10 22:10:52 +00:00
|
|
|
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
2017-06-10 21:33:55 +00:00
|
|
|
* @link https://cakephp.org CakePHP(tm) Project
|
2015-12-01 14:26:22 +00:00
|
|
|
* @since 2.8
|
2017-06-10 22:23:14 +00:00
|
|
|
* @license https://opensource.org/licenses/mit-license.php MIT License
|
2015-12-01 14:26:22 +00:00
|
|
|
*/
|
2015-12-01 12:02:51 +00:00
|
|
|
|
2015-12-14 09:47:22 +00:00
|
|
|
abstract class BaseShellHelper {
|
2015-12-01 12:02:51 +00:00
|
|
|
|
2015-12-01 14:26:22 +00:00
|
|
|
/**
|
|
|
|
* Default config for this helper.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2015-12-01 15:37:06 +00:00
|
|
|
protected $_defaultConfig = array();
|
2015-12-01 12:02:51 +00:00
|
|
|
|
2015-12-01 14:26:22 +00:00
|
|
|
/**
|
|
|
|
* ConsoleOutput instance.
|
|
|
|
*
|
|
|
|
* @var ConsoleOutput
|
|
|
|
*/
|
|
|
|
protected $_consoleOutput;
|
2015-12-01 13:29:08 +00:00
|
|
|
|
2015-12-01 14:26:22 +00:00
|
|
|
/**
|
|
|
|
* Runtime config
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2015-12-01 15:37:06 +00:00
|
|
|
protected $_config = array();
|
2015-12-01 13:29:08 +00:00
|
|
|
|
2015-12-01 14:26:22 +00:00
|
|
|
/**
|
|
|
|
* Whether the config property has already been configured with defaults
|
|
|
|
*
|
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
protected $_configInitialized = false;
|
2015-12-01 12:02:51 +00:00
|
|
|
|
2015-12-01 14:26:22 +00:00
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*
|
|
|
|
* @param ConsoleOutput $consoleOutput The ConsoleOutput instance to use.
|
|
|
|
* @param array $config The settings for this helper.
|
|
|
|
*/
|
|
|
|
public function __construct(ConsoleOutput $consoleOutput, array $config = array()) {
|
|
|
|
$this->_consoleOutput = $consoleOutput;
|
|
|
|
$this->config($config);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize config & store config values
|
|
|
|
*
|
|
|
|
* @param null $config Config values to set
|
|
|
|
* @return array|void
|
|
|
|
*/
|
|
|
|
public function config($config = null) {
|
|
|
|
if ($config === null) {
|
|
|
|
return $this->_config;
|
|
|
|
}
|
|
|
|
if (!$this->_configInitialized) {
|
|
|
|
$this->_config = array_merge($this->_defaultConfig, $config);
|
|
|
|
$this->_configInitialized = true;
|
|
|
|
} else {
|
|
|
|
$this->_config = array_merge($this->_config, $config);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This method should output content using `$this->_consoleOutput`.
|
|
|
|
*
|
|
|
|
* @param array $args The arguments for the helper.
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
abstract public function output($args);
|
2015-12-01 12:02:51 +00:00
|
|
|
}
|