Global navigation

   Documentation Center
   eZ Studio & eZ Platform
     User Manual
     Technical Manual
   eZ Publish 4.x / legacy

eZ Publish (5.x)

eZ Publish 5.x | For eZ Platform & eZ Studio topics see Technical manual and User manual, for eZ Publish 4.x and Legacy topics see eZ Publish legacy

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Code Block
namespace My\Bundle\RestBundle\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 ( !array_key_exists( 'name', $data ) )
            throw new Exceptions\Parser( "Missing or invalid 'name' element for Greetings." );

        // the root level of the parsed structure is ignored
        $name = $data['name']
        return new Hello( $name );