Permalink
Browse files

Type operations using schema.org actions

The PUT method in the CRUD controller is currently being mapped to http://schema.org/UpdateAction as it doesn't really completely replace the entity.
  • Loading branch information...
lanthaler committed Jul 20, 2014
1 parent c23a974 commit d7701bf66c6e29d80e23d66d4e8b1359f415c5da
@@ -305,6 +305,7 @@ private function documentOperations($operations)
$result[] = array(
'@id' => '_:' . $operation->getName(),
'@type' => $operation->getType() ?: 'hydra:Operation',
'method' => $operation->getMethod(),
'label' => ($operation->getTitle())
?
@@ -329,6 +329,7 @@ protected function getRouteMetadata($routeName)
$operation = new OperationDefinition($routeName);
$operation->setIri($annotation->getIri());
$operation->setType($annotation->type);
$operation->setRoute($route);
@@ -26,6 +26,11 @@ class OperationDefinition
*/
private $iri;
/**
* @var string The IRI identifying the type of this operation
*/
private $type;
/**
* @var string The title of the description of this operation
*/
@@ -116,6 +121,30 @@ public function isExternalReference()
return strpos($this->iri, ':') !== false;
}
/**
* Sets the IRI identifying the type of this operation
*
* @return string The IRI identifying the type of this operation.
*
* @return OperationDefinition $this
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* Gets the IRI identifying the type of this operation
*
* @return string The IRI identifying the type of this operation.
*/
public function getType()
{
return $this->type;
}
/**
* Sets the title of the description of this operation
*
@@ -8,6 +8,7 @@
{% endif %}
*
* @Hydra\Operation(
* type = "http://schema.org/AddAction",
* expect = "{{ namespace }}\Entity\{{ entity }}",
* status_codes = {
* "201" = "If the {{ entity }} entity was created successfully."
@@ -7,7 +7,9 @@
* @Method("DELETE")
{% endif %}
*
* @Hydra\Operation()
* @Hydra\Operation(
* type = "http://schema.org/DeleteAction"
* )
*
* @return void
*/
@@ -8,6 +8,7 @@
{% endif %}
*
* @Hydra\Operation(
* type = "http://schema.org/UpdateAction"
* expect = "{{ namespace }}\Entity\{{ entity }}",
* status_codes = {
* "404" = "If the {{ entity }} entity wasn't found."

0 comments on commit d7701bf

Please sign in to comment.