X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Ftemplates%2Fmodule%2Fsrc%2FPlugin%2FRest%2FResource%2Frest.php.twig;fp=vendor%2Fdrupal%2Fconsole%2Ftemplates%2Fmodule%2Fsrc%2FPlugin%2FRest%2FResource%2Frest.php.twig;h=e2a620d958cb0d1a6ef12e02b60bcde38ae9c191;hp=9145f2e2a51e8eefcfdaabb32e75cf1de57a7ac9;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/vendor/drupal/console/templates/module/src/Plugin/Rest/Resource/rest.php.twig b/vendor/drupal/console/templates/module/src/Plugin/Rest/Resource/rest.php.twig index 9145f2e2a..e2a620d95 100644 --- a/vendor/drupal/console/templates/module/src/Plugin/Rest/Resource/rest.php.twig +++ b/vendor/drupal/console/templates/module/src/Plugin/Rest/Resource/rest.php.twig @@ -10,11 +10,12 @@ namespace Drupal\{{module_name}}\Plugin\rest\resource; {% block use_class %} use Drupal\Core\Session\AccountProxyInterface; +use Drupal\rest\ModifiedResourceResponse; use Drupal\rest\Plugin\ResourceBase; use Drupal\rest\ResourceResponse; +use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -use Psr\Log\LoggerInterface; {% endblock %} {% block class_declaration %} @@ -87,18 +88,23 @@ class {{ class_name }} extends ResourceBase {% endblock %} ); } {% endblock %} + {% block class_methods %} -{% for state in plugin_states %} +{% for state, state_settings in plugin_states %} /** * Responds to {{ state }} requests. * - * Returns a list of bundles for specified entity. + * @param \Drupal\Core\Entity\EntityInterface $entity + * The entity object. + * + * @return \Drupal\rest\{{ state_settings.response_class }} + * The HTTP response object. * * @throws \Symfony\Component\HttpKernel\Exception\HttpException * Throws exception expected. */ - public function {{ state|lower }}() { + public function {{ state|lower }}(EntityInterface $entity) { // You must to implement the logic of your REST Resource here. // Use current user after pass authentication to validate access. @@ -106,7 +112,7 @@ class {{ class_name }} extends ResourceBase {% endblock %} throw new AccessDeniedHttpException(); } - return new ResourceResponse("Implement REST State {{ state }}!"); + return new {{ state_settings.response_class }}({{ (state == 'DELETE') ? 'NULL' : '$entity' }}, {{ state_settings.http_code }}); } {% endfor %} {% endblock %}