45. /**
* Event
*
* @HydraExpose(iri="http://schema.org/Event")
* @HydraId("event_retrieve")
* @HydraOperations( {
* "event_replace",
* "event_delete"
* } )
*/
class Event
{
/**
* The event's name
*
* @HydraExpose(iri="http://schema.org/name", required=true)
*/
private $name;
// ... other members and methods ...
}
46. $ php app/console hydra:generate:crud
--entity=MLEventApiBundle:Event
--route-prefix=/events/
--with-write
--no-interaction
CRUD generation
Generating the CRUD code: OK
You can now start using the generated code!
47. /**
* Event controller
*
* @Route("/events")
*/
class EventController extends HydraController
{
/**
* Creates a new Event entity
*
* @Route("/", name="event_create")
* @Method("POST")
*
* @HydraOperation(
* type = "http://schema.org/AddAction",
* expect = "MLEventApiBundleEntityEvent"
* })
*
* @return MLEventApiBundleEntityEvent
*/
public function collectionPostAction(Request $request)
{
...