Well you can guess it, it is with services :) so statically calling it would be
Well you can guess it, it is with services :) so statically calling it would be
When submitting a form you might want to redirect users to some page, there are few ways you can do that, they are listed below. You will put this into your submit handler function
Putting some form in a block is matter of creating a new block and assigning a form to it through form_builder that is called through dependency injection(DI) and then using method getForm that will get rendered array of this form, which is exactly what build method for block expects to output
Some throwback to Drupal 7 and commerce or just entities. You need to duplicate(clone) some entity, well you can do it easily with this helper function
To get drupal 8 config object that is mutable (changeable) you need to use config factory to get it and set it. For example
In drupal 8 we have cool new thing, instead of hooks we can use event subscribers and create event listeners. They do similar things as hooks, we can do something on certain "events" in system, get data and change it or somehow act upon it.
So to subscribe to some event we need to do a service with tags in it, like
To get list of methods you can run on certain types of entities you can get the list by loading this entity and then running get_class_methods on it so for example
If you need to get entity object in form alter, you can get it with this method
$entity = $form_state->getFormObject()->getEntity();
and form then you can get info you need, use methods on it etc
There is one gotcha when using loadByProperties with entityTypeManager. When normally loading entities like
Some explanation why it is better to use
$node = \Drupal::entityManager()->getStorage('node')->load($nid);
than
$node = Node::load($nid);