import v1.1.0_RC2 | 2009-09-20
This commit is contained in:
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: Abstract.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -60,6 +60,23 @@ abstract class Zend_Tool_Framework_Client_Abstract implements Zend_Tool_Framewor
|
||||
*/
|
||||
protected $_debugLogger = null;
|
||||
|
||||
public function __construct($options = array())
|
||||
{
|
||||
if ($options) {
|
||||
$this->setOptions($options);
|
||||
}
|
||||
}
|
||||
|
||||
public function setOptions(Array $options)
|
||||
{
|
||||
foreach ($options as $optionName => $optionValue) {
|
||||
$setMethodName = 'set' . $optionName;
|
||||
if (method_exists($this, $setMethodName)) {
|
||||
$this->{$setMethodName}($optionValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getName() - Return the client name which can be used to
|
||||
* query the manifest if need be.
|
||||
|
105
libs/Zend/Tool/Framework/Client/Config.php
Normal file
105
libs/Zend/Tool/Framework/Client/Config.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Config.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Framework_Client_Config
|
||||
{
|
||||
|
||||
protected $_configFilepath = null;
|
||||
|
||||
/**
|
||||
* @var Zend_Config
|
||||
*/
|
||||
protected $_config = null;
|
||||
|
||||
public function __config($options = array())
|
||||
{
|
||||
if ($options) {
|
||||
$this->setOptions($options);
|
||||
}
|
||||
}
|
||||
|
||||
public function setOptions(Array $options)
|
||||
{
|
||||
foreach ($options as $optionName => $optionValue) {
|
||||
$setMethodName = 'set' . $optionName;
|
||||
if (method_exists($this, $setMethodName)) {
|
||||
$this->{$setMethodName}($optionValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setConfigFilepath($configFilepath)
|
||||
{
|
||||
if (!file_exists($configFilepath)) {
|
||||
require_once 'Zend/Tool/Framework/Client/Exception.php';
|
||||
throw new Zend_Tool_Framework_Client_Exception('Provided path to config ' . $configFilepath . ' does not exist');
|
||||
}
|
||||
|
||||
$this->_configFilepath = $configFilepath;
|
||||
|
||||
$suffix = substr($configFilepath, -4);
|
||||
|
||||
switch ($suffix) {
|
||||
case '.ini':
|
||||
require_once 'Zend/Config/Ini.php';
|
||||
$this->_config = new Zend_Config_Ini($configFilepath);
|
||||
break;
|
||||
case '.xml':
|
||||
require_once 'Zend/Config/Xml.php';
|
||||
$this->_config = new Zend_Config_Xml($configFilepath);
|
||||
break;
|
||||
case '.php':
|
||||
require_once 'Zend/Config.php';
|
||||
$this->_config = new Zend_Config(include $configFilepath);
|
||||
break;
|
||||
default:
|
||||
require_once 'Zend/Tool/Framework/Client/Exception.php';
|
||||
throw new Zend_Tool_Framework_Client_Exception('Unknown config file type '
|
||||
. $suffix . ' at location ' . $configFilepath
|
||||
);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getConfigFilepath()
|
||||
{
|
||||
return $this->_configFilepath;
|
||||
}
|
||||
|
||||
public function get($name, $defaultValue)
|
||||
{
|
||||
return $this->_config->get($name, $defaultValue);
|
||||
}
|
||||
|
||||
public function __get($name)
|
||||
{
|
||||
return $this->_config->{$name};
|
||||
}
|
||||
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: Console.php 16972 2009-07-22 18:44:24Z ralph $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -64,6 +64,16 @@ class Zend_Tool_Framework_Client_Console
|
||||
Zend_Tool_Framework_Client_Interactive_OutputInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_configOptions = null;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_storageOptions = null;
|
||||
|
||||
/**
|
||||
* @var Zend_Filter_Word_CamelCaseToDash
|
||||
*/
|
||||
@ -79,13 +89,25 @@ class Zend_Tool_Framework_Client_Console
|
||||
* self contained main() function.
|
||||
*
|
||||
*/
|
||||
public static function main()
|
||||
public static function main($options = array())
|
||||
{
|
||||
ini_set('display_errors', true);
|
||||
$cliClient = new self();
|
||||
$cliClient = new self($options);
|
||||
$cliClient->dispatch();
|
||||
}
|
||||
|
||||
public function setConfigOptions($configOptions)
|
||||
{
|
||||
$this->_configOptions = $configOptions;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setStorageOptions($storageOptions)
|
||||
{
|
||||
$this->_storageOptions = $storageOptions;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* getName() - return the name of the client, in this case 'console'
|
||||
*
|
||||
@ -102,6 +124,21 @@ class Zend_Tool_Framework_Client_Console
|
||||
*/
|
||||
protected function _preInit()
|
||||
{
|
||||
$config = $this->_registry->getConfig();
|
||||
|
||||
if ($this->_configOptions != null) {
|
||||
$config->setOptions($this->_configOptions);
|
||||
}
|
||||
|
||||
$storage = $this->_registry->getStorage();
|
||||
|
||||
if ($this->_storageOptions != null && isset($this->_storageOptions['directory'])) {
|
||||
require_once 'Zend/Tool/Framework/Client/Storage/Directory.php';
|
||||
$storage->setAdapter(
|
||||
new Zend_Tool_Framework_Client_Storage_Directory($this->_storageOptions['directory'])
|
||||
);
|
||||
}
|
||||
|
||||
// support the changing of the current working directory, necessary for some providers
|
||||
if (isset($_ENV['ZEND_TOOL_CURRENT_WORKING_DIRECTORY'])) {
|
||||
chdir($_ENV['ZEND_TOOL_CURRENT_WORKING_DIRECTORY']);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: ArgumentParser.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: HelpSystem.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: Manifest.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,9 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Colorizer.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
class Zend_Tool_Framework_Client_Console_ResponseDecorator_Colorizer
|
||||
implements Zend_Tool_Framework_Client_Response_ContentDecorator_Interface
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Framework_Client_Console_ResponseDecorator_Colorizer
|
||||
implements Zend_Tool_Framework_Client_Response_ContentDecorator_Interface
|
||||
{
|
||||
|
||||
|
||||
protected $_colorOptions = array(
|
||||
// blacks
|
||||
'black' => '30m',
|
||||
@ -11,7 +36,7 @@ class Zend_Tool_Framework_Client_Console_ResponseDecorator_Colorizer
|
||||
'bgBlack' => '40m',
|
||||
// reds
|
||||
'red' => '31m',
|
||||
'hiRed' => '1:31m',
|
||||
'hiRed' => '1;31m',
|
||||
'bgRed' => '41m',
|
||||
// greens
|
||||
'green' => '32m',
|
||||
@ -38,30 +63,30 @@ class Zend_Tool_Framework_Client_Console_ResponseDecorator_Colorizer
|
||||
'hiWhite' => '1;37m',
|
||||
'bgWhite' => '47m'
|
||||
);
|
||||
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'color';
|
||||
}
|
||||
|
||||
|
||||
public function decorate($content, $color)
|
||||
{
|
||||
if (is_string($color)) {
|
||||
$color = array($color);
|
||||
}
|
||||
|
||||
|
||||
$newContent = '';
|
||||
|
||||
|
||||
foreach ($color as $c) {
|
||||
if (array_key_exists($c, $this->_colorOptions)) {
|
||||
$newContent .= "\033[" . $this->_colorOptions[$c];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$newContent .= $content . "\033[m";
|
||||
|
||||
|
||||
return $newContent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: Exception.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: InputHandler.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Framework_Client_Interactive_InputHandler
|
||||
{
|
||||
|
||||
@ -46,4 +71,4 @@ class Zend_Tool_Framework_Client_Interactive_InputHandler
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: InputInterface.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
interface Zend_Tool_Framework_Client_Interactive_InputInterface
|
||||
{
|
||||
|
||||
@ -13,4 +38,4 @@ interface Zend_Tool_Framework_Client_Interactive_InputInterface
|
||||
|
||||
public function getMissingParameterPromptString(Zend_Tool_Framework_Provider_Interface $provider, Zend_Tool_Framework_Action_Interface $actionInterface, $missingParameterName);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: InputRequest.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Framework_Client_Interactive_InputRequest
|
||||
{
|
||||
protected $_content = null;
|
||||
@ -26,4 +51,4 @@ class Zend_Tool_Framework_Client_Interactive_InputRequest
|
||||
{
|
||||
return $this->_content;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: InputResponse.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Framework_Client_Interactive_InputResponse
|
||||
{
|
||||
|
||||
|
@ -1,8 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: OutputInterface.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
interface Zend_Tool_Framework_Client_Interactive_OutputInterface
|
||||
{
|
||||
|
||||
public function handleInteractiveOutput($string);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: Request.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: Response.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Interface.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
interface Zend_Tool_Framework_Client_Response_ContentDecorator_Interface
|
||||
{
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
* @version $Id: Separator.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
117
libs/Zend/Tool/Framework/Client/Storage.php
Normal file
117
libs/Zend/Tool/Framework/Client/Storage.php
Normal file
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Storage.php 16972 2009-07-22 18:44:24Z ralph $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Framework_Client_Storage_AdapterInterface
|
||||
*/
|
||||
require_once 'Zend/Tool/Framework/Client/Storage/AdapterInterface.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Framework_Client_Storage
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Zend_Tool_Framework_Client_Storage_AdapterInterface
|
||||
*/
|
||||
protected $_adapter = null;
|
||||
|
||||
public function __construct($options = array())
|
||||
{
|
||||
if (isset($options['adapter'])) {
|
||||
$this->setAdapter($options['adapter']);
|
||||
}
|
||||
}
|
||||
|
||||
public function setAdapter($adapter)
|
||||
{
|
||||
if (is_string($adapter)) {
|
||||
$storageAdapterClass = 'Zend_Tool_Framework_Client_Storage_' . ucfirst($adapter);
|
||||
Zend_Loader::loadClass($storageAdapterClass);
|
||||
$adapter = new $storageAdapterClass();
|
||||
}
|
||||
$this->_adapter = $adapter;
|
||||
}
|
||||
|
||||
public function isEnabled()
|
||||
{
|
||||
return ($this->_adapter instanceof Zend_Tool_Framework_Client_Storage_AdapterInterface);
|
||||
}
|
||||
|
||||
public function put($name, $value)
|
||||
{
|
||||
if (!$this->_adapter) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_adapter->put($name, $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get($name, $defaultValue = false)
|
||||
{
|
||||
if (!$this->_adapter) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->_adapter->has($name)) {
|
||||
return $this->_adapter->get($name);
|
||||
} else {
|
||||
return $defaultValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function has($name)
|
||||
{
|
||||
if (!$this->_adapter) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->_adapter->has($name);
|
||||
}
|
||||
|
||||
public function remove($name)
|
||||
{
|
||||
if (!$this->_adapter) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_adapter->remove($name);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStreamUri($name)
|
||||
{
|
||||
if (!$this->_adapter) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->_adapter->getStreamUri($name);
|
||||
}
|
||||
}
|
42
libs/Zend/Tool/Framework/Client/Storage/AdapterInterface.php
Normal file
42
libs/Zend/Tool/Framework/Client/Storage/AdapterInterface.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: AdapterInterface.php 16972 2009-07-22 18:44:24Z ralph $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
interface Zend_Tool_Framework_Client_Storage_AdapterInterface
|
||||
{
|
||||
|
||||
public function put($name, $value);
|
||||
|
||||
public function get($name);
|
||||
|
||||
public function has($name);
|
||||
|
||||
public function remove($name);
|
||||
|
||||
public function getStreamUri($name);
|
||||
|
||||
}
|
73
libs/Zend/Tool/Framework/Client/Storage/Directory.php
Normal file
73
libs/Zend/Tool/Framework/Client/Storage/Directory.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Directory.php 16972 2009-07-22 18:44:24Z ralph $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Tool_Framework_Client_Storage_AdapterInterface
|
||||
*/
|
||||
require_once 'Zend/Tool/Framework/Client/Storage/AdapterInterface.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Tool
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Framework_Client_Storage_Directory
|
||||
implements Zend_Tool_Framework_Client_Storage_AdapterInterface
|
||||
{
|
||||
|
||||
protected $_directoryPath = null;
|
||||
|
||||
public function __construct($directoryPath)
|
||||
{
|
||||
if (!file_exists($directoryPath)) {
|
||||
throw new Zend_Tool_Framework_Client_Exception(__CLASS__ . ': the supplied directory does not exist');
|
||||
}
|
||||
$this->_directoryPath = $directoryPath;
|
||||
}
|
||||
|
||||
public function put($name, $value)
|
||||
{
|
||||
return file_put_contents($this->_directoryPath . DIRECTORY_SEPARATOR . $name, $value);
|
||||
}
|
||||
|
||||
public function get($name)
|
||||
{
|
||||
return file_get_contents($this->_directoryPath . DIRECTORY_SEPARATOR . $name);
|
||||
}
|
||||
|
||||
public function has($name)
|
||||
{
|
||||
return file_exists($this->_directoryPath . DIRECTORY_SEPARATOR . $name);
|
||||
}
|
||||
|
||||
public function remove($name)
|
||||
{
|
||||
return unlink($this->_directoryPath . DIRECTORY_SEPARATOR . $name);
|
||||
}
|
||||
|
||||
public function getStreamUri($name)
|
||||
{
|
||||
return $this->_directoryPath . DIRECTORY_SEPARATOR . $name;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user