2023-03-11 12:04:29 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Zend Framework (http://framework.zend.com/)
|
|
|
|
*
|
|
|
|
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
2023-04-01 09:03:34 +03:00
|
|
|
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
2023-03-11 12:04:29 +03:00
|
|
|
* @license http://framework.zend.com/license/new-bsd New BSD License
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Zend\Console;
|
|
|
|
|
|
|
|
use Zend\Stdlib\Message;
|
|
|
|
use Zend\Stdlib\ResponseInterface;
|
|
|
|
|
|
|
|
class Response extends Message implements ResponseInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
protected $contentSent = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if content was sent
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
* @deprecated
|
|
|
|
*/
|
|
|
|
public function contentSent()
|
|
|
|
{
|
|
|
|
return $this->contentSent;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the error level that will be returned to shell.
|
|
|
|
*
|
|
|
|
* @param int $errorLevel
|
|
|
|
* @return Response
|
|
|
|
*/
|
|
|
|
public function setErrorLevel($errorLevel)
|
|
|
|
{
|
2023-04-01 09:03:34 +03:00
|
|
|
if (is_string($errorLevel) && !ctype_digit($errorLevel)) {
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2023-03-11 12:04:29 +03:00
|
|
|
$this->setMetadata('errorLevel', $errorLevel);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get response error level that will be returned to shell.
|
|
|
|
*
|
|
|
|
* @return int|0
|
|
|
|
*/
|
|
|
|
public function getErrorLevel()
|
|
|
|
{
|
|
|
|
return $this->getMetadata('errorLevel', 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send content
|
|
|
|
*
|
|
|
|
* @return Response
|
|
|
|
* @deprecated
|
|
|
|
*/
|
|
|
|
public function sendContent()
|
|
|
|
{
|
|
|
|
if ($this->contentSent()) {
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
echo $this->getContent();
|
|
|
|
$this->contentSent = true;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
*/
|
|
|
|
public function send()
|
|
|
|
{
|
|
|
|
$this->sendContent();
|
|
|
|
$errorLevel = (int) $this->getMetadata('errorLevel', 0);
|
|
|
|
exit($errorLevel);
|
|
|
|
}
|
|
|
|
}
|