Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (5)

View Page History
$duration = Zend_Commons::factory('exec')
->setPattern('{ps} | {grep}')
->setCommand('ps') ->useCommand('ps')
->addArg('ax', false) // don't quote this argument
->setCommand('grep') ->useCommand('grep')
->addArg('some text') // this arg will be escaped/quoted
->setStdoutFile($fileName)
{code}
{card}
{card:label=UC-04: Custom plugins}
{code}
// We create a new class with a custom strategy, which is
// going to be used in many places inside our application:
class Model_Commons_Special extends Zend_Commons_Abstract {
public function execute() {
// do something special
}
}
// Somewhere inside bootstrap:
Zend_Commons::getPluginLoader()->addPrefixPath(
'Model_Commons',
APPLICATION_PATH . '/Model/Commons'
);
// Somewhere later in the code of the application:
Zend_Commons::factory('special')->execute();
{code}
{card}
{deck}
{zone-data}
*/
public static function mock($cls, $id);

/**
* Return an instance of plugin loader used here.
* @return Zend_Loader_PluginLoader
*/
public static function getPluginLoader();
}

{code}
{card}
{card:label=Zend_Commons_Exec}
{code}
/**
* Execute shell command.
*/
class Zend_Commons_Exec extends Zend_Commons_Abstract
{
/**
* Set shell command pattern.
* @param string The name
* @return $this
*/
public function setPattern($pattern);

/**
* Use this particular command for further instructions.
* @param string The name of the command
* @return $this
*/
public function useCommand($command);

/**
* Add argument to the current active command.
* @param string The argument
* @param boolean Shall we quote it?
* @return $this
*/
public function addArg($arg, $quote = true);

/**
* Save stdout to the file provided.
* @param string The name of the file
* @return $this
*/
public function setStdoutFile($file);

/**
* Save stdout to the variable provided.
* @param mixed The variable
* @return $this
*/
public function setStdoutVariable(&$var);

/**
* Save stderr to the file provided.
* @param string The name of the file
* @return $this
*/
public function setStderrFile($file);

/**
* Save stderr to the variable provided.
* @param mixed The variable
* @return $this
*/
public function setStderrVariable(&$var);

/**
* What to return as a result of execute()?
* @param integer What shall we return
* @return $this
*/
public function setReturnSubject($subj);

/**
* Shall we fail if return code is NON zero?
* @param boolean Shall we?
* @return $this
*/
public function setFailOnNonZero($fail);

/**
* Execute the command.
* @return mixed
*/
public function execute();
}
{code}
{card}
{deck}
{zone-data}