1<?php 2/** 3 * Zend Framework (http://framework.zend.com/) 4 * 5 * @link http://github.com/zendframework/zf2 for the canonical source repository 6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 7 * @license http://framework.zend.com/license/new-bsd New BSD License 8 */ 9 10namespace Zend\Console; 11 12use Zend\Stdlib\Message; 13use Zend\Stdlib\ResponseInterface; 14 15class Response extends Message implements ResponseInterface 16{ 17 /** 18 * @var bool 19 */ 20 protected $contentSent = false; 21 22 /** 23 * Check if content was sent 24 * 25 * @return bool 26 * @deprecated 27 */ 28 public function contentSent() 29 { 30 return $this->contentSent; 31 } 32 33 /** 34 * Set the error level that will be returned to shell. 35 * 36 * @param int $errorLevel 37 * @return Response 38 */ 39 public function setErrorLevel($errorLevel) 40 { 41 if (is_string($errorLevel) && !ctype_digit($errorLevel)) { 42 return $this; 43 } 44 45 $this->setMetadata('errorLevel', $errorLevel); 46 return $this; 47 } 48 49 /** 50 * Get response error level that will be returned to shell. 51 * 52 * @return int|0 53 */ 54 public function getErrorLevel() 55 { 56 return $this->getMetadata('errorLevel', 0); 57 } 58 59 /** 60 * Send content 61 * 62 * @return Response 63 * @deprecated 64 */ 65 public function sendContent() 66 { 67 if ($this->contentSent()) { 68 return $this; 69 } 70 echo $this->getContent(); 71 $this->contentSent = true; 72 return $this; 73 } 74 75 /** 76 * @deprecated 77 */ 78 public function send() 79 { 80 $this->sendContent(); 81 $errorLevel = (int) $this->getMetadata('errorLevel', 0); 82 exit($errorLevel); 83 } 84} 85