protected function _prepareResponse(Context $c, $result, $buffer = null)
  {
    if($result instanceof ContextAware)
    {
      $result->setContext($c);
    }

    if($this->_callStartTime && $result instanceof CubexResponse)
    {
      return $result->setCallStartTime($this->_callStartTime);
    }

    if($result instanceof Response)
    {
      return $result;
    }

    if($result instanceof Renderable)
    {
      return $this->_makeCubexResponse($result->render());
    }

    if($result instanceof ISafeHtmlProducer)
    {
      return $this->_makeCubexResponse($result->produceSafeHTML()->getContent());
    }

    $result = parent::_prepareResponse($c, $result, $buffer);

    try
    {
      Strings::stringable($result);
      return $this->_makeCubexResponse($result);
    }
    catch(\InvalidArgumentException $e)
    {
      //Non stringable $result, return as is
    }

    return $result;
  }
protected function _prepareResponse(Context $c, $result, $buffer = null)
  {
    if($result instanceof ContextAware)
    {
      $result->setContext($c);
    }

    if($this->_callStartTime && $result instanceof CubexResponse)
    {
      return $result->setCallStartTime($this->_callStartTime);
    }

    if($result instanceof Response)
    {
      return $result;
    }

    if($result instanceof Renderable)
    {
      return $this->_makeCubexResponse($result->render());
    }

    if($result instanceof ISafeHtmlProducer)
    {
      return $this->_makeCubexResponse($result->produceSafeHTML()->getContent());
    }

    $result = parent::_prepareResponse($c, $result, $buffer);

    try
    {
      Strings::stringable($result);
      return $this->_makeCubexResponse($result);
    }
    catch(\InvalidArgumentException $e)
    {
      //Non stringable $result, return as is
    }

    return $result;
  }
protected function _prepareResponse ( Context $ c , $ result , $ buffer = null ) { if ( $ result instanceof ContextAware ) { $ result -> setContext ( $ c ) ; } if ( $ this -> _callStartTime && $ result instanceof CubexResponse ) { return $ result -> setCallStartTime ( $ this -> _callStartTime ) ; } if ( $ result instanceof Response ) { return $ result ; } if ( $ result instanceof Renderable ) { return $ this -> _makeCubexResponse ( $ result -> render ( ) ) ; } if ( $ result instanceof ISafeHtmlProducer ) { return $ this -> _makeCubexResponse ( $ result -> produceSafeHTML ( ) -> getContent ( ) ) ; } $ result = parent :: _prepareResponse ( $ c , $ result , $ buffer ) ; try { Strings :: stringable ( $ result ) ; return $ this -> _makeCubexResponse ( $ result ) ; } catch ( \ InvalidArgumentException $ e ) { //Non stringable $result, return as is } return $ result ; }
Convert a route response into a valid Response

@param Context     $c
@param mixed       $result
@param null|string $buffer

@return mixed|CubexResponse
Convert a route response into a valid Response