eZ Documentation Center

This is outdated documentation made for eZ Publish Platform 5.2. It is being moved into the eZ Publish 5.x documentation, so please go there for most up-to-date documentation.

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Fixed wrong class reference


For convenience, we will consider that our input parser returns an instance of our ValueValues\Hello class.

Code Block
namespace My\Bundle\RestBundle\Rest\InputParser;
use eZ\Publish\Core\REST\Server\Input\Parser\Base as BaseParser;
use eZ\Publish\Core\REST\Common\Input\ParsingDispatcher;
use My\Bundle\RestBundle\Rest\Value\Hello;
use eZ\Publish\Core\REST\Common\Exceptions;

class Greetings extends BaseParser
     * @return My\Bundle\RestBundle\Rest\Value\Hello
    public function parse( array $data, ParsingDispatcher $parsingDispatcher )
        // re-using the REST exceptions will make sure that those already have a ValueObjectVisitor
        if ( !isset( $data['name'] ) )
            throw new Exceptions\Parser( "Missing or invalid 'name' element for Greetings." );

        return new Hello( $data['name'] );