You are here

public function VarietyItems::get in Migrate Plus 8

Same name and namespace in other branches
  1. 8.5 migrate_example_advanced/migrate_example_advanced_setup/src/Plugin/rest/resource/VarietyItems.php \Drupal\migrate_example_advanced_setup\Plugin\rest\resource\VarietyItems::get()
  2. 8.2 migrate_example_advanced/migrate_example_advanced_setup/src/Plugin/rest/resource/VarietyItems.php \Drupal\migrate_example_advanced_setup\Plugin\rest\resource\VarietyItems::get()
  3. 8.3 migrate_example_advanced/migrate_example_advanced_setup/src/Plugin/rest/resource/VarietyItems.php \Drupal\migrate_example_advanced_setup\Plugin\rest\resource\VarietyItems::get()
  4. 8.4 migrate_example_advanced/migrate_example_advanced_setup/src/Plugin/rest/resource/VarietyItems.php \Drupal\migrate_example_advanced_setup\Plugin\rest\resource\VarietyItems::get()

Responds to GET requests.

Parameters

string $variety: Machine name of the variety to retrieve.

Return value

\Drupal\rest\ResourceResponse The response containing the requested variety data.

File

migrate_example_advanced/migrate_example_advanced_setup/src/Plugin/rest/resource/VarietyItems.php, line 35
Contains \Drupal\migrate_example_advanced_setup\Plugin\rest\resource\VarietyItems.

Class

VarietyItems
Provides varieties as two endpoints, one for reds and one for whites.

Namespace

Drupal\migrate_example_advanced_setup\Plugin\rest\resource

Code

public function get($variety = NULL) {
  $varieties = [
    'retsina' => [
      'name' => 'Retsina',
      'parent' => 1,
      // categoryid for 'white'.
      'details' => 'Greek',
    ],
    'trebbiano' => [
      'name' => 'Trebbiano',
      'parent' => 1,
      // categoryid for 'white'.
      'details' => 'Italian',
    ],
    'valpolicella' => [
      'name' => 'Valpolicella',
      'parent' => 3,
      // categoryid for 'red'.
      'details' => 'Italian Venoto region',
    ],
    'bardolino' => [
      'name' => 'Bardolino',
      'parent' => 3,
      // categoryid for 'red'.
      'details' => 'Italian Venoto region',
    ],
  ];
  if (isset($varieties[$variety])) {
    $data = [
      'variety' => $varieties[$variety],
    ];
  }
  else {
    $data = [];
  }
  $response = new ResourceResponse($data, 200);
  return $response;
}