Skip to content

Instantly share code, notes, and snippets.

@vijaycs85
Created February 20, 2013 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijaycs85/4996975 to your computer and use it in GitHub Desktop.
Save vijaycs85/4996975 to your computer and use it in GitHub Desktop.
+++ b/core/lib/Drupal/Core/ParamConverter/EntityConverter.phpundefined
@@ -0,0 +1,106 @@
+ /**
+ * Tries to upcast every variable to an entity type.
+ *
+ * If there is a type denoted in the route options it will try to upcast to
+ * it, if there is no definition in the options it will try to upcast to an
+ * entity type of that name. If the chosen enity type does not exists it will
+ * leave the variable untouched.
+ * If the entity type exist, but there is no entity with the given id it will
+ * convert the variable to NULL.
+ *
+ * Example:
+ *
+ * pattern: '/a/{user}/some/{foo}/and/{bar}/'
+ * options:
+ * converters:
+ * foo: 'node'
+ *
+ * The value for {user} will be converted to a user entity and the value
+ * for {foo} to a node entity, but it will not touch the value for {bar}.
+ *
+ * It will not process variables which are marked as converted. It will mark
+ * any variable it processes as converted.
+ *
+ * @param array &$variables
+ * Array of values to convert to their corresponding objects, if applicable.
+ * @param \Symfony\Component\Routing\Route $route
+ * The route object.
+ * @param array &$converted
+ * Array collecting the names of all variables which have been
+ * altered by a converter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment