By toswebdev, 14 May, 2022

Plugins are small pieces of functionality that are swappable. Plugins that perform similar functionality are of the same plugin type.

Drupal contains many different plugins, of different types. For example, 'Field widget' is a plugin type, and each different field widget type is a plugin. The admin user may select from the list of field widget plugins to set the widget that a field uses.

By toswebdev, 14 May, 2022

Some modules are enabled by developers on the local instance of their drupal site but are not meant to be enabled on the production site.

Solution 1st:-

The manual solution to this is to uninstall the module before doing a configuration export and to manually install it again locally after a configuration import.

Solution 2nd:-

Enable the module and activate the filter by declaring $settings['config_exclude_modules'] in your settings.php file, eg:

By toswebdev, 27 January, 2022

use Drupal\Core\Access\AccessResult;
 * Implements hook_entity_access().
function drupalbook_examples_entity_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account) {
  if ($entity->getEntityTypeId() == 'node' && $entity->getType() == 'article' && $operation == 'view' && in_array('administrator', $account->getRoles())) {


There Main Three types AccessResult as Below 

By toswebdev, 27 January, 2022
 * Implements hook_entity_presave().
function drupalbook_examples_entity_presave(Drupal\Core\Entity\EntityInterface $entity) {
  if ($entity->getEntityTypeId() == 'node' && $entity->getType() == 'article') {
    $entity->title->value = $entity->title->value . 'by ' . date('d-m-Y');

Hook_entity_presave () is fired every time an entity is saved.

By toswebdev, 20 December, 2021

You can add to bookmarks this page to always have a cheat sheet on hand on how to execute MySQL queries select in Drupal 8 or 9.

Get single value:

$query = \Drupal::database()->select('node_field_data', 'n');
$query->addField('n', 'nid');
$query->condition('n.title', 'About Us');
$query->range(0, 1);
$nid = $query->execute()->fetchField();

Get an entry in the array: