This document provides an overview of Drupal for developers familiar with Symfony. It describes Drupal as a PHP content management framework that is highly customizable. It highlights key Drupal features like security, performance, and multilingual support. The document reviews Drupal versions, the installation and content structure, and the user interface. It provides examples of Drupal code like routing, services, events and the use of Symfony components. Finally, it discusses the Drupal community and support resources available.
Optimizing AI for immediate response in Smart CCTV
Drupal intro for Symfony developers
1. Drupal for Symfony Developers Samuel Solís - @estoyausenteSamuel Solís - @estoyausente
Drupal for Symfony
Developers
By Samuel Solís
2. Drupal for Symfony Developers Samuel Solís - @estoyausente
A PHP CMS
Samuel Solís - @estoyausente
¿What is Drupal?
Open
Source
Highly
customizable
Usually called
as CMF
3. Drupal for Symfony Developers Samuel Solís - @estoyausente
Main features
Security Performance
& Scaling
Multilingual Marketing
automation
Content
management Personalization
Content as a
Service
4. Drupal for Symfony Developers Samuel Solís - @estoyausente
A lot of contrib modules
5. Drupal for Symfony Developers Samuel Solís - @estoyausente
Note about Drupal versions
<D7 D7 D8
Old like a
mountain, now
unpredictable
Mature, important in
the Drupal story
Young, different, the
real hero
6. Drupal for Symfony Developers Samuel Solís - @estoyausente
Drupal install
Usually LAMP environment but many variations possible.
1. Download the project https://github.com/drupal/recommended-project
2. Composer install
3. Install the database and configuration
a. Go to the site and follow the install wizard
b. Using drush with the command drush site-install
31. Drupal for Symfony Developers Samuel Solís - @estoyausente
Drupal theme structure
config/
templates/
images/
css/
js/
images/
theme_name.info.yml
theme_name.libraries.yml
theme_name.theme
A theme is an special module,
but a module. The structure is
the same.
32. Drupal for Symfony Developers Samuel Solís - @estoyausente
Some random code snippets
34. Drupal for Symfony Developers Samuel Solís - @estoyausente
bb_data_layer.services.yml
services:
bb_data_layer.marketplace_wines:
class: Drupalbb_data_layerMarketplaceWines
bb_data_layer.product_sales:
class: Drupalbb_data_layerProductSales
...
35. Drupal for Symfony Developers Samuel Solís - @estoyausente
AutocompleteController.php
<?php
namespace Drupalbb_data_layerController;
use DrupalCoreControllerControllerBase;
...
class AutocompleteController extends ControllerBase {
public function providerAutocomplete(Request $request, $search_field_name,
$return_field_name) {
$return = []; // some stuff
return new JsonResponse($return);
}
}
36. Drupal for Symfony Developers Samuel Solís - @estoyausente
HazteSocio.php
/**
* Provides an example block.
* @Block(
* id = "bb_blocks_haztesocio",
* admin_label = @Translation("Register now"),
* )
*/
class HazteSocio extends BlockBase {
public function build() {
return [
'forms' => [
'facebook' => $this->facebook,
'#type' => 'container',
'#attributes' => [
'class' => ['user-register-input-wrapper'],
],
]
}
}
}
37. Drupal for Symfony Developers Samuel Solís - @estoyausente
Symfony Components in D8
● ClassLoader
● CssSelector
● DependencyInjection
● EventDispatcher
● HttpFoundation
● HttpKernel
● Process
● Routing
● Serializer
● Translation
● Validator
● Yaml
38. Drupal for Symfony Developers Samuel Solís - @estoyausente
DependencyInjection & Services
$logger = $container->get('logger');
$entityManager = $container->get(entity.orm.entity_manager');
39. Drupal for Symfony Developers Samuel Solís - @estoyausente
Event & Event dispatcher
class UserLoginEvent extends Event {
const EVENT_NAME = 'bb_auth_user_login';
public $account;
public function __construct(UserInterface $account) {
$this->account = $account;
}
}
40. Drupal for Symfony Developers Samuel Solís - @estoyausente
Event & Event dispatcher
$event = new UserLoginEvent($account);
// Get the event_dispatcher service and dispatch the event.
$event_dispatcher = Drupal::service('event_dispatcher');
$event_dispatcher->dispatch(UserLoginEvent::EVENT_NAME, $event);
41. Drupal for Symfony Developers Samuel Solís - @estoyausente
Event & Event dispatcher
class BbAuthApiRequest implements EventSubscriberInterface {
public function onAPIRequest(BbRestRequest $event) {}
public static function getSubscribedEvents() {
$events[BbRestRequest::BB_REST_REQUEST][] = ['onAPIRequest'];
return $events;
}
}
42. Drupal for Symfony Developers Samuel Solís - @estoyausente
Ya casi acabamos
43. Drupal for Symfony Developers Samuel Solís - @estoyausente
Drupal community & support
● Drupalchat.eu (Rocket chat) -
Spanish channel #drupal-es
● Groups.drupal.org
● Drupal.slack.com
● drupal.stackexchange.com
Day to day Events
44. Drupal for Symfony Developers Samuel Solís - @estoyausente
Thank for coming!