public function VarietyItems::get in Migrate Plus 8
Same name and namespace in other branches
- 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()
- 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()
- 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()
- 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\resourceCode
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;
}