Skip to main content

Posts

Showing posts from October, 2020

Logical Interview Question

 1. How to Swap two variables, With or without the third variable & inbuild function. This method will work for any variable type: $a = 5 ; $b = 6 ; list ($a, $b) = array ($b, $a); print $a . ',' . $b; // 6,5 Another simple way (which only works for numbers, not strings/arrays/etc) is $a = $a + $b; // 5 + 6 = 11 $b = $a - $b; // 11 - 6 = 5 $a = $a - $b; // 11 - 5 = 6 print $a . ',' . $b; // 6,5

How to Enable/Disable module Manually

Execute this code Anyhow on the server to uninstall module  // Read the configuration. $module_data = \Drupal::config('core.extension')->get('module'); // Unset the modules you do not need. unset($module_data['MODULE_NAME']); // Write the configuration. \Drupal::configFactory()->getEditable('core.extension')->set('module', $module_data)->save(); Another Way: <?php   \Drupal::service('module_installer')->install(['admin_toolbar']); ?> <?php   \Drupal::service('module_installer')->uninstall(['admin_toolbar']); ?> Delete config: \Drupal::configFactory()->getEditable('contact.form.personal')->delete();

Deign Pattern in Drupal

 What are Design Patterns in General: Description of communicating objects and classes that are customized to solve a general problem in a particular way. Why design pattern required: 1 - Design pattern help to speed up the development, 2 - The templates are proven and from the developer's position, the Only implementation is required 3- Encapsulate big ideas in a simpler way 4 -  Each pattern describes a problem which occurs over & over again, Design Pattern Inforces SOLID Principles: SOLID is an acronym that stands for the following: S ingle responsibility principle O pen/closed principle L iskov substitution principle I nterface segregation principle D ependency inversion principle Categorization of GOF(Gang of Four Design Patterns) - Creation - Used to construct objects such that they can be decoupled from their implementation system. i.e in one class, we put business logic & in another class create the instance of it. - Structural - Used to form large object str...