11. / CoreConcepts / ServiceContainers.php
@are Auto-instantiate service-oriented
actionable classes with all
registered dependencies
12. / CoreConcepts / Plugins.php
“Plugin - A discreet class that executes an
operation within the context of a given
scope, as a means to extend Drupal’s
functionality”
14. / CoreConcepts / Plugins.php
- Lazy loaded
- Unified code (using interfaces)
- extensible
- reusable across a projects
- each plugin type should have own
plugin manager, wasted?
PROFIT
NOTICE
21. New Cache API
Request cache_default bin:
$cache = Drupal::cache();
Request a particular bin(cache_custom):
$custom_cache = Drupal::cache('custom');
Retrieve a cached data:
$data = Drupal::cache()->get('my_value');
Save data to the cache:
$data = Drupal::cache()->set('my_value', ['some_data']);
23. New Cache API
Invalidate a cache items with a particular tag(s):
DrupalCoreCacheCache::invalidateTags(array('node:5', 'my_tag'));
Retrieve an existent entity’s cache tags:
● DrupalCoreEntityEntityInterface::getCacheTags()
● DrupalCoreEntityEntityTypeInterface::getListCacheTags()
Cache tags allow us to invalidate caches more smartly.
25. New Cache API
Cache contexts are analogous to HTTP's Vary header.
It helps Drupal to decide whether the cached response can be
used rather than requesting a fresh one.
Contexts examples:
theme (vary by negotiated theme)
user.roles (vary by the combination of roles)
languages (vary by all language types: interface, content …)
33. Form API
DrupalCoreFormFormInterface
- everything what you usually need!
- getFormId() - specify Form ID
- buildForm() - build form array
- validateForm() - form validation handler
- submitForm() - form submit handler
34. Form API
New HTML 5 elements:
● '#type' => 'tel'
● '#type' => 'email'
● '#type' => 'number'
● '#type' => 'date'
● '#type' => 'url'
● '#type' => 'search'
● '#type' => 'range'
● etc.
36. Form API
Integrate the form in a request:
mymodule.test_form:
path: 'mymodule/test_form'
defaults:
_form: 'DrupalmymoduleFormsExampleForm'
_title: 'Test form'
requirements:
_permission: 'access content'
37. Form API
Retrieving the form outside of routes:
$form = Drupal::formBuilder()
->getForm('DrupalexampleFormExampleForm');
39. Form API
Rendering forms programmatically:
// Retrieve a form array.
$form = Drupal::formBuilder()
->getForm('DrupalexampleFormExampleForm');
// Render it.
$rendered_form = Drupal::service('renderer')
->render($form);
48. Migrate yourself!: src / Module / Multilingual / ConfigVariables.php
STEP #1 add variables with text, string type to the
root of config_object var inside a
my_module.schema.yml
WARNING: works only with first level depth text-based elements
in the config_object