Showing 14 posts by,

Deji Akala

Drupal implements the Front Controller design pattern. All HTTP requests are directed to the index.php file, and a response is generated and returned. With the architectural decision to use Object-Oriented Programming and Symfony Components, the file has remained very short and concise. However, the request and response aspects of the process are given prominence. This is the index.php without comments: <?php use Drupal\Core\DrupalKernel; u [...]

The introduction of the EventDispatcher Component has brought an interesting approach to how components of an application talk to each other in a clean and organized manner. Interestingly, this is what the hook system, which is as old as the Drupal project, was designed to do. From the documentation of Drupal 1.0: The idea is to be able to run random code at given places in the engine. This random code should then be able to do whatever needed [...]

The module and hook systems are as old as Drupal. From the documentation in Drupal 1.0: In places where hooks are made available, the engine calls each module's exported functions. This is done by iterating through the modules directory where all modules must reside. Say your module is named foo (i.e. modules/foo.module) and if there was a hook called bar, the engine will call foo_bar() if this was exported by your module. Although the Conte [...]

Earlier Drupal versions have a hook system, a way of letting other developers write code that interacts with core code in a clean and organized manner. System events are defined, and when they occur, the entire application is notified, and all the code associated with the event is run. The hook system is based on the naming and definition of functions. When certain events occur, e.g. a form has been built, a node is being inserted into the datab [...]

The heart of Drupal 8 is the DrupalKernel, an extension of the HttpKernel component from Symfony. The documentation beautifully summarizes its purpose: The HttpKernel component provides a structured process for converting a Request into a Response by making use of the EventDispatcher component. The HttpKernelInterface only provides a single method, handle(), which is where the seemingly magical process of converting a Request to Response takes [...]

Introduction Management of site settings has been a challenge ever since the early days of the Drupal project. What is managed as configuration is often difficult to differentiate from the content. General site information is not the same as taxonomy vocabularies, terms, menus, or blocks. Earlier versions of Drupal store a variety of settings as variables which are managed with variable_get(), variable_set() and variable_del() functions. Drupa [...]

Definition A Drupal 8 application has several objects, some of which specialize in the performance of specific tasks across the system, e.g. logging, mailing, authentication, etc. There might even be a simple object with a couple of methods to be shared by other classes. These objects are called services. Then, there is a service container which is a special object that holds or contains all the services in the application. The Symfony Dependency [...]

Usually, web applications do one thing. A browser makes a request for a resource and the server replies with a response. It is Request in, Response out. With a centralized request-handling mechanism, all requests pass through a single handler which kicks off a workflow doing things like authentication, authorization, or logging, until the resource is located and returned to the request agent, usually a web browser. This is the front controller [...]

Drupal 8 is about Object-Oriented Programming (OOP) and a firm positioning of Drupal in the enterprise. The introduction of key Symfony components was meant to herald new beginnings and enforce a more professional programming paradigm. The hook system which is as old as the project allows Drupal core to call certain functions defined in modules at specific places. In other words, Drupal allows developers to interact with core code when some thin [...]

Drupal, like other web applications, receives an HTTP request for a resource and returns a response. This is a multi-step process that involves decoding the request and mapping it to a predefined callback. When the callback function is executed, the requested resource is prepared and returned to the caller. Let us take a closer look at the way a simple page is built and displayed in both Drupal 7 and 8. Drupal 7 In a module, for example simple_ [...]