In Drupal 8 Core class user entity provide the user related information to us. Using the Role Class function loadMultiple(), will returns all Roles available in our Drupal 8 site as Object. Similarly load() function return particular Role information as Object.
In Drupal 7 there function called module_exist(). This function returns true if module exist else return false. For Drupal 8 module_exist() function is Deprecated. In Drupal there is Core function moduleHandler() will more information about modules in Drupal system. The moduleHandler() returns a object, using this object we can call moduleExists() function with module name as parameter to the function.
If we planned to restrict some pages from user we put 404 error message to that page that is called Access Denied. To achieve this in Drupal 8 we need to use Symfony components class. This AccessDenied is handle as Exception in Drupal 8. By using HttpKernel’s AccessDeniedHttpException class constructor Drupal 8 throwing 404 error.
In Drupal 8 fully works on OOPs concept. To create page redirection we need to use Symfony components class. The page redirection is done by RedirectResponse Class from Symfony HttpFoundation. This class object used inside function as a return parameter. While creating object we need to send valid site path to the constructor of RedirectResponse class. In Drupal 7 we using drupal_goto() function for redirect.
In Drupal 8 by extending the Core class “BlockBase”. For each block we need to specify the ID and Display name for the block at annotation place. In BlockBase class there is function build(), we need to implement this function to render our content.
To make view contextual filter textfiled into autocomplete, in our module need to alter the text field into autocomplete by assigning autocomplete path to it. This autocomplete path already defined in module. Below is the steps,
To detect the event when text change inside the any HTML element like div, span, table or etc., using DOMNodeInserted, DOMContentLoaded, DOMSubtreeModified and DOMNodeRemoved events. These events are known as Mutation events. Below is the sample code of handling Mutation events on different browsers.
In Pass by value the argument values are affected only locally with in the function where as in Pass by reference the argument values affected globally (i.e outside the function).