Pathologic was missing because of a .git folder inside.
[yaffs-website] / web / modules / contrib / migrate_plus / migrate_example_advanced / migrate_example_advanced_setup / src / Plugin / rest / resource / VarietyItems.php
1 <?php
2
3 namespace Drupal\migrate_example_advanced_setup\Plugin\rest\resource;
4
5 use Drupal\rest\Plugin\ResourceBase;
6 use Drupal\rest\ResourceResponse;
7
8 /**
9  * Provides varieties as two endpoints, one for reds and one for whites.
10  *
11  * @RestResource(
12  *   id = "migrate_example_advanced_variety_items",
13  *   label = @Translation("Advanced migration example - Variety data"),
14  *   uri_paths = {
15  *     "canonical" = "/migrate_example_advanced_variety_list/{variety}"
16  *   }
17  * )
18  */
19 class VarietyItems extends ResourceBase {
20
21   /**
22    * Responds to GET requests.
23    *
24    * @param string $variety
25    *   Machine name of the variety to retrieve.
26    *
27    * @return \Drupal\rest\ResourceResponse
28    *   The response containing the requested variety data.
29    */
30   public function get($variety = NULL) {
31     $varieties = [
32       'retsina' => [
33         'name' => 'Retsina',
34         'parent' => 1,  // categoryid for 'white'.
35         'details' => 'Greek',
36       ],
37       'trebbiano' => [
38         'name' => 'Trebbiano',
39         'parent' => 1,  // categoryid for 'white'.
40         'details' => 'Italian',
41       ],
42       'valpolicella' => [
43         'name' => 'Valpolicella',
44         'parent' => 3,  // categoryid for 'red'.
45         'details' => 'Italian Venoto region',
46       ],
47       'bardolino' => [
48         'name' => 'Bardolino',
49         'parent' => 3,  // categoryid for 'red'.
50         'details' => 'Italian Venoto region',
51       ],
52     ];
53     if (isset($varieties[$variety])) {
54       $data = ['variety' => $varieties[$variety]];
55     }
56     else {
57       $data = [];
58     }
59
60     $response = new ResourceResponse($data, 200);
61     return $response;
62   }
63
64   /**
65    * {@inheritdoc}
66    */
67   public function permissions() {
68     // Remove permissions so the resource is available to all.
69     return [];
70   }
71
72 }