function ExampleHamSandwich::order

Same name and namespace in other branches
  1. 4.0.x modules/plugin_type_example/src/Plugin/Sandwich/ExampleHamSandwich.php \Drupal\plugin_type_example\Plugin\Sandwich\ExampleHamSandwich::order()

Place an order for a sandwich.

This is just an example method on our plugin that we can call to get something back.

Parameters

array $extras: Array of extras to include with this order.

Return value

string A description of the sandwich ordered.

Overrides SandwichBase::order

File

modules/plugin_type_example/src/Plugin/Sandwich/ExampleHamSandwich.php, line 45

Class

ExampleHamSandwich
Provides a ham sandwich.

Namespace

Drupal\plugin_type_example\Plugin\Sandwich

Code

public function order(array $extras) {
  $ingredients = [
    'ham, mustard',
    'rocket',
    'sun-dried tomatoes',
  ];
  $sandwich = array_merge($ingredients, $extras);
  return 'You ordered an ' . implode(', ', $sandwich) . ' sandwich. Enjoy!';
}