annotate core/lib/Drupal/Core/ParamConverter/ParamConverterInterface.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 4c8ae668cc8c
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\Core\ParamConverter;
Chris@0 4
Chris@0 5 use Symfony\Component\Routing\Route;
Chris@0 6
Chris@0 7 /**
Chris@0 8 * Interface for parameter converters.
Chris@0 9 *
Chris@0 10 * Classes implementing this interface are responsible for converting a path
Chris@0 11 * parameter to the object it represents.
Chris@0 12 *
Chris@0 13 * Here is an example path: /admin/structure/block/manage/{block}
Chris@0 14 *
Chris@0 15 * In this case, '{block}' would be the path parameter which should be turned
Chris@0 16 * into a block object representing the block in question.
Chris@0 17 *
Chris@0 18 * ParamConverters are defined as services tagged with 'paramconverter', and are
Chris@0 19 * managed by the 'paramconverter_manager' service.
Chris@0 20 *
Chris@0 21 * @see menu
Chris@0 22 * @see \Drupal\Core\ParamConverter\ParamConverterManagerInterface
Chris@0 23 * @see \Drupal\Core\ParamConverter\EntityConverter
Chris@0 24 */
Chris@0 25 interface ParamConverterInterface {
Chris@0 26
Chris@0 27 /**
Chris@0 28 * Converts path variables to their corresponding objects.
Chris@0 29 *
Chris@0 30 * @param mixed $value
Chris@0 31 * The raw value.
Chris@0 32 * @param mixed $definition
Chris@0 33 * The parameter definition provided in the route options.
Chris@0 34 * @param string $name
Chris@0 35 * The name of the parameter.
Chris@0 36 * @param array $defaults
Chris@0 37 * The route defaults array.
Chris@0 38 *
Chris@0 39 * @return mixed|null
Chris@0 40 * The converted parameter value.
Chris@0 41 */
Chris@0 42 public function convert($value, $definition, $name, array $defaults);
Chris@0 43
Chris@0 44 /**
Chris@0 45 * Determines if the converter applies to a specific route and variable.
Chris@0 46 *
Chris@0 47 * @param mixed $definition
Chris@0 48 * The parameter definition provided in the route options.
Chris@0 49 * @param string $name
Chris@0 50 * The name of the parameter.
Chris@0 51 * @param \Symfony\Component\Routing\Route $route
Chris@0 52 * The route to consider attaching to.
Chris@0 53 *
Chris@0 54 * @return bool
Chris@0 55 * TRUE if the converter applies to the passed route and parameter, FALSE
Chris@0 56 * otherwise.
Chris@0 57 */
Chris@0 58 public function applies($definition, $name, Route $route);
Chris@0 59
Chris@0 60 }