public function VarietyMultiFiles::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/VarietyMultiFiles.php \Drupal\migrate_example_advanced_setup\Plugin\rest\resource\VarietyMultiFiles::get()
- 8.2 migrate_example_advanced/migrate_example_advanced_setup/src/Plugin/rest/resource/VarietyMultiFiles.php \Drupal\migrate_example_advanced_setup\Plugin\rest\resource\VarietyMultiFiles::get()
- 8.3 migrate_example_advanced/migrate_example_advanced_setup/src/Plugin/rest/resource/VarietyMultiFiles.php \Drupal\migrate_example_advanced_setup\Plugin\rest\resource\VarietyMultiFiles::get()
- 8.4 migrate_example_advanced/migrate_example_advanced_setup/src/Plugin/rest/resource/VarietyMultiFiles.php \Drupal\migrate_example_advanced_setup\Plugin\rest\resource\VarietyMultiFiles::get()
Responds to GET requests.
Parameters
string $type: 'red', 'white', or NULL to return all varieties.
Return value
\Drupal\rest\ResourceResponse The response containing the requested variety data.
File
- migrate_example_advanced/
migrate_example_advanced_setup/ src/ Plugin/ rest/ resource/ VarietyMultiFiles.php, line 35 - Contains \Drupal\migrate_example_advanced_setup\Plugin\rest\resource\VarietyMultiFiles.
Class
- VarietyMultiFiles
- Provides varieties as two endpoints, one for reds and one for whites.
Namespace
Drupal\migrate_example_advanced_setup\Plugin\rest\resourceCode
public function get($type = NULL) {
$data = [];
if (strtolower($type) != 'white') {
$data['variety'][] = [
'name' => 'Amarone',
'parent' => 3,
// categoryid for 'red'.
'details' => 'Italian Venoto region',
];
$data['variety'][] = [
'name' => 'Barbaresco',
'parent' => 3,
// categoryid for 'red'.
'details' => 'Italian Piedmont region',
];
}
if (strtolower($type) != 'red') {
$data['variety'][] = [
'name' => 'Kir',
'parent' => 1,
// categoryid for 'white'.
'details' => 'French Burgundy region',
];
$data['variety'][] = [
'name' => 'Pinot Grigio',
'parent' => 1,
// categoryid for 'white'.
'details' => 'From the northeast of Italy',
];
}
$response = new ResourceResponse($data, 200);
return $response;
}