We’re rewarding the question askers & reputations are being recalculated! Read more.

New answers tagged

0

Drupal introduced the Drupal\Core\Cache\MemoryCache\MemoryCache class to, as Added memory cache says, allow classes that would previously maintain state on a protected property (as a static cache to avoid persistent cache or database lookups) to inject a service to hold that state instead. Drupal core implements two services that use that class, one of them ...


0

A small addition I would make would be to do a check for UID = 1 like the rest of D7. A little late but hope it might helps some one. function MODULE_user_has_role() { global $user; if ($user->uid == 1) { return TRUE; } $roles = func_get_args(); foreach ($roles as $role) { if (in_array($role, $user->roles)) { return TRUE; } ...


0

I need to create a form for all nodes of a type. This form route has to be like this, the base /booking + the node alias. The node alias could be: /accommodation-test /rooms/accommodation-test /rooms/address-test/accommodation-test Final form route: /booking/accommodation-test /booking/rooms/accommodation-test /booking/rooms/address-test/accommodation-...


1

Use more placeholders in your route, like path: 'booking/{url_alias}/{anyother}' Then add a default for the last one, like defaults: anyother: "" Now your Path applies for two and three uri components. Check this page for default parameters in form - routes: https://www.drupal.org/docs/8/api/routing-system/parameters-in-routes/using-parameters-in-...


1

Is this possible? path: 'booking/{url_alias}' or path: '{url_alias}/booking' path: '{url_alias}/booking' paths can never start with a slug/placeholder. You'll have to use path: 'booking/{url_alias}' In your form: /** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state, $url_alias = NULL) { // Some DB ...


0

It's the expected behavior, and it's described in the documentation for hook_menu(), even it could not be clear, at a quick read. Callback Functions The definition for each path may include a page callback function, which is invoked when the registered path is requested. If there is no other registered path that fits the requested path better, ...


0

In a clean Drupal 8 way, you could alter tasks by using modulename_local_tasks_alter(), as described in the documentation /** * Implements hook_local_tasks_alter(). */ function modulename_local_tasks_alter(&$local_tasks) { // Remove unwanted tabs // Here, we'll remove the "Payment method" tasks from the user edit tasks unset($local_tasks['entity....


Top 50 recent answers are included