Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

что нового в мире Services


Published on

Published in: Technology
  • Be the first to comment

что нового в мире Services

  1. 1. Drupal 7 routing● based on path only (menu_get_item($path))● tied up with menu links (tables menu_router,menu_links)
  2. 2. 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.
  3. 3. Drupal 7 routing● hook_menu()
  4. 4. Drupal 7 routing● hook_menu_alter()
  5. 5. Drupal 8 routing● mymodule.routing.yml●●●{router} database table, route_set =<modulename>
  6. 6. Dynamic routes● Subscriber reacting onRoutingEvents::DYNAMIC event●●●●●●{router} table, route_set = dynamic_routes
  7. 7. Drupal 8 meets Symfony routing● RouterListener subscriber (● RouterListener::onKernelRequest() setsattributes to request object using matcher
  8. 8. Routing● RouterListener::onKernelRequest()
  9. 9. Routing ChainRouter
  10. 10. 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)
  11. 11. legacy_router internals● NullGenerator● LegacyUrlMatcher– menu_get_item($path)– Convert it to Route● _controller is callback function name● hook_menu file got included
  12. 12. 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
  13. 13. Modules● Serialization● REST● HAL
  14. 14. Retrieve a node (decoded)
  15. 15. Resource plugin● DrupalmodulenamePluginrestresource● Annotation with id and description● Each http method as class method (get, post,delete, patch ...)
  16. 16. Resource plugin
  17. 17. Serialization
  18. 18. Normalizers● ImageItemNormalizer● EntityReferenceNormalizer● FieldItemNormalizer● FieldNormalizer● EntityNormalizer
  19. 19. Serialization
  20. 20. CSRF protection● Each non-safe REST call (not GET, HEAD,OPTIONS, TRACE methods) should be donewith X-CSRF-Token header with token.
  21. 21. Services in Drupal 8● Own plugin (extends Resource from REST)● Each method as own route (not tied with httpmethod names)● Use annotations to describe your routes
  22. 22. Services example
  23. 23. Authentication (in progress)●● No more dependent on Cookie Session● Authentication Providers● Multiple authentication providers – 400 BadRequest● Access check if authenticaion provider allowed
  24. 24. Thanks● Larry Garfield @Crell● Lin Clark @linclark● Klaus Purer @_klausi_● WSCCI team
  25. 25. Links●●