8 - Unit 1: Services and the Services Container in Drupal

Описание к видео 8 - Unit 1: Services and the Services Container in Drupal

Services are used to perform consistent operations, like accessing the database or sending an e-mail. So for example, rather than use PHP's native MySQL functions to write or read data, we instead use the Drupal core-provided database service to perform the operations. In this way, our code can simply access the database without having to concern ourselves about whether the database is MySQL or S.Q.L.ite, or other. In fact that database server could in theory be totally swapped with a different database provider, and as long as our code uses the database service, we wouldn’t have to change our code at all.

Comparably, when sending an email, the mechanism for sending email could be SMTP or it could be some other method such as an API call to external mail service, but our code just needs to simply tell Drupal’s email service to send an email.

This service abstraction is also very beneficial for testing code. By leveraging PHPUnit tests, it is easier to test the actual business logic of the code separate from the service implementation.

Resources:
https://www.drupal.org/node/2133171
https://symfony.com/doc/3.4/service_c...
https://api.drupal.org/api/drupal/cor...
https://api.drupal.org/api/drupal/cor...
https://api.drupal.org/api/drupal/ser...

This training video is part of Acquia Academy’s Drupal Training Course, which is available with additional study guides, practice exams, and Drupal certification at community.acquiaacademy.com. Training videos are broken out into three modules: 1. Site Building, 2. Layout and Theming, and 3. Module Development. These three modules are grouped into playlists on Acquia’s YouTube channel. 

Subscribe: http://www.youtube.com/subscription_c...

Follow Acquia on social media:
Facebook:   / acquia  
Twitter:   / acquia  
LinkedIn:   / acquia  
Instagram:   / acquia  
Slideshare: https://www.slideshare.net/AcquiaInc

Комментарии

Информация по комментариям в разработке