<?php

namespace Zend\Console;

use Zend\Stdlib\Message;
use Zend\Stdlib\ResponseInterface;

class Response extends Message implements ResponseInterface
{
}

<?php

namespace Zend\Console;

use Zend\Stdlib\Message;
use Zend\Stdlib\ResponseInterface;

class Response extends Message implements ResponseInterface
{
    protected $contentSent = false;

    public function contentSent()
    {
        return $this->contentSent;
    }

    /**
     * Set the error level that will be returned to shell.
     *
     * @param integer   $errorLevel
     * @return Response
     */
    public function setErrorLevel($errorLevel){
        $this->setMetadata('errorLevel', $errorLevel);
        return $this;
    }

    /**
     * Get response error level that will be returned to shell.
     *
     * @return integer|0
     */
    public function getErrorLevel(){
        return $this->getMetadata('errorLevel', 0);
    }

    public function sendContent()
    {
        if ($this->contentSent()) {
            return $this;
        }
        echo $this->getContent();
        $this->contentSent = true;
        return $this;
    }

    public function send()
    {
        $this->sendContent();
        $errorLevel = (int)$this->getMetadata('errorLevel',0);
        exit($errorLevel);
    }
}

Introduce Console rendering strategies and more incremental changes.
[WIP] Introduce Console rendering strategies and more incremental changes.

- Console\Response now supports setting and getting errorLevel (stored as metadata).
- Console\Response now properly supports send()ing, including exiting the application with an error level.
- Add Mvc\View\Console\DefaultRenderingStrategy for building console response from plain-text action controller
responses.
- Currently, the default console rendering strategy does NOT use Zend\View nor Rendering to produce responses (it
just concatenates plain-text responses from controllers and puts them into console response object)
- Remove View\Strategy\ConsoleStrategy because of its bad design.
