Services Drupal 8Yuriy GerasimovSenior Drupal ArchitectPropeople@ygerasimov
Routing
Drupal 7 routing● based on path only (menu_get_item($path))● tied up with menu links (tables menu_router,menu_links)
menu_rebuild()● This function will clear and populate the{menu_router} table, add entries to {menu_links}for new router it...
Drupal 7 routing● hook_menu()
Drupal 7 routing● hook_menu_alter()
Drupal 8 routing
Drupal 8 routing● mymodule.routing.yml●●●{router} database table, route_set =<modulename>
Dynamic routes● Subscriber reacting onRoutingEvents::DYNAMIC event●●●●●●{router} table, route_set = dynamic_routes
Drupal 8 meets Symfony routing● RouterListener subscriber (core.services.yml)● RouterListener::onKernelRequest() setsattri...
Routing● RouterListener::onKernelRequest()
Routing ChainRouter
router.dynamic internals● RouteProvider – fetch all records from {router}table filtering by pattern_outline,● NestedMatche...
legacy_router internals● NullGenerator● LegacyUrlMatcher– menu_get_item($path)– Convert it to Route● _controller is callba...
Routing RecapDrupal7● Path only● Tied with menu linksDrupal 8● Heavily usedSymfony● Path● Mime type● Http method● (and more)
REST in core● New Entity API with field metadata● REST API support can be enabled for anyentity known to the system● Acces...
Modules● Serialization● REST● HAL
Retrieve a node (decoded)
Resource plugin● DrupalmodulenamePluginrestresource● Annotation with id and description● Each http method as class method ...
Resource plugin
Serialization
Normalizers● ImageItemNormalizer● EntityReferenceNormalizer● FieldItemNormalizer● FieldNormalizer● EntityNormalizer
Serialization
CSRF protection● Each non-safe REST call (not GET, HEAD,OPTIONS, TRACE methods) should be donewith X-CSRF-Token header wit...
Services in Drupal 8 (plans)● Own plugin (extends Resource from REST)● Each method as own route (not tied with httpmethod ...
Services example
Authentication (in progress)● https://drupal.org/node/1890878● No more dependent on Cookie Session● Authentication Provide...
Welcome to Contribute!
Guzzle. Service Description
Guzzle. Client● Descriptions make life easier
Services Guzzle module● Module for Drupal 7● Includes client for testing (similar to whatservices 6.x-2.x had)
Thanks● Larry Garfield @Crell● Lin Clark @linclark● Klaus Purer @_klausi_● WSCCI team
Links● https://groups.drupal.org/wscci● https://portland2013.drupal.org/session/rest-and-serialization-drupal-8● http://gu...
Services Drupal 8Yuriy GerasimovSenior Drupal ArchitectPropeople@ygerasimov
Upcoming SlideShare
Loading in...5
×

Drupal 8 Routing

5,724

Published on

Presentation about comparing routing system in Drupal 7 and Drupal 8. What is implemented in REST module of Drupal 8? What is going to be in Services module for Drupal 8.

Published in: Technology
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,724
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide

Drupal 8 Routing

  1. 1. Services Drupal 8Yuriy GerasimovSenior Drupal ArchitectPropeople@ygerasimov
  2. 2. Routing
  3. 3. Drupal 7 routing● based on path only (menu_get_item($path))● tied up with menu links (tables menu_router,menu_links)
  4. 4. menu_rebuild()● This function will clear and populate the{menu_router} table, add entries to {menu_links}for new router items, and then remove staleitems from {menu_links}. If called fromupdate.php or install.php, it will also schedule acall to itself on the first real page load frommenu_execute_active_handler(), because themaintenance page environment is different andleaves stale data in the menu tables.
  5. 5. Drupal 7 routing● hook_menu()
  6. 6. Drupal 7 routing● hook_menu_alter()
  7. 7. Drupal 8 routing
  8. 8. Drupal 8 routing● mymodule.routing.yml●●●{router} database table, route_set =<modulename>
  9. 9. Dynamic routes● Subscriber reacting onRoutingEvents::DYNAMIC event●●●●●●{router} table, route_set = dynamic_routes
  10. 10. Drupal 8 meets Symfony routing● RouterListener subscriber (core.services.yml)● RouterListener::onKernelRequest() setsattributes to request object using matcher
  11. 11. Routing● RouterListener::onKernelRequest()
  12. 12. Routing ChainRouter
  13. 13. router.dynamic internals● RouteProvider – fetch all records from {router}table filtering by pattern_outline,● NestedMatcher:– MimeTypeMatcher– UrlMatcher:● prefix● regex (example #^/node$#s)● host regex● http method● http scheme (http or https)
  14. 14. legacy_router internals● NullGenerator● LegacyUrlMatcher– menu_get_item($path)– Convert it to Route● _controller is callback function name● hook_menu file got included
  15. 15. Routing RecapDrupal7● Path only● Tied with menu linksDrupal 8● Heavily usedSymfony● Path● Mime type● Http method● (and more)
  16. 16. REST in core● New Entity API with field metadata● REST API support can be enabled for anyentity known to the system● Access control on the entity level● Access control on the field level
  17. 17. Modules● Serialization● REST● HAL
  18. 18. Retrieve a node (decoded)
  19. 19. Resource plugin● DrupalmodulenamePluginrestresource● Annotation with id and description● Each http method as class method (get, post,delete, patch ...)
  20. 20. Resource plugin
  21. 21. Serialization
  22. 22. Normalizers● ImageItemNormalizer● EntityReferenceNormalizer● FieldItemNormalizer● FieldNormalizer● EntityNormalizer
  23. 23. Serialization
  24. 24. CSRF protection● Each non-safe REST call (not GET, HEAD,OPTIONS, TRACE methods) should be donewith X-CSRF-Token header with token.● Drupal 7 Services got SA on 6 June 13.
  25. 25. Services in Drupal 8 (plans)● Own plugin (extends Resource from REST)● Each method as own route (not tied with httpmethod names)● Use annotations to describe your routes● Validation of arguments
  26. 26. Services example
  27. 27. Authentication (in progress)● https://drupal.org/node/1890878● No more dependent on Cookie Session● Authentication Providers● Multiple authentication providers – 400 BadRequest● Access check if authenticaion provider allowed
  28. 28. Welcome to Contribute!
  29. 29. Guzzle. Service Description
  30. 30. Guzzle. Client● Descriptions make life easier
  31. 31. Services Guzzle module● Module for Drupal 7● Includes client for testing (similar to whatservices 6.x-2.x had)
  32. 32. Thanks● Larry Garfield @Crell● Lin Clark @linclark● Klaus Purer @_klausi_● WSCCI team
  33. 33. Links● https://groups.drupal.org/wscci● https://portland2013.drupal.org/session/rest-and-serialization-drupal-8● http://guzzlephp.org/
  34. 34. Services Drupal 8Yuriy GerasimovSenior Drupal ArchitectPropeople@ygerasimov

×