SlideShare uma empresa Scribd logo
1 de 24
Baixar para ler offline
Drupal 7 vs 8
Andy Postnikov
Freelancer

&

Alexey Gaydabura
Lead Developer at @SkillD

Lviv, 2013

http://www.skilld.fr
Installer makeup
Drupal 7 - install.php
if (version_compare(PHP_VERSION, '5.2.4') < 0) {
exit;
}

Drupal 8 - install.php
chdir('..');
require_once __DIR__ . '/vendor/autoload.php';
if (version_compare(PHP_VERSION, '5.3.10') < 0) {
exit;
}
if (ini_get('safe_mode')) {
print 'Your PHP installation has safe_mode enabled.
...';
exit;
}
Drupal 7 - index.php
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
menu_execute_active_handler();

Drupal 8 - index.php
require_once __DIR__ . '/core/vendor/autoload.php';
require_once __DIR__ . '/core/includes/bootstrap.inc';
try {
drupal_handle_request();
}
catch (Exception $e) {
print 'If you have ... read http://drupal.org/documentation/rebuild';

throw $e;
}
Drupal 7 - Bootstrap
1. DRUPAL_BOOTSTRAP_CONFIGURATION
2. DRUPAL_BOOTSTRAP_PAGE_CACHE
3. DRUPAL_BOOTSTRAP_DATABASE
4. DRUPAL_BOOTSTRAP_VARIABLES
5. DRUPAL_BOOTSTRAP_SESSION
6. DRUPAL_BOOTSTRAP_PAGE_HEADER
7. DRUPAL_BOOTSTRAP_LANGUAGE
8. DRUPAL_BOOTSTRAP_FULL
Drupal 8 - Bootstrap
1. DRUPAL_BOOTSTRAP_CONFIGURATION
+ DRUPAL_BOOTSTRAP_KERNEL
2. DRUPAL_BOOTSTRAP_PAGE_CACHE
3. DRUPAL_BOOTSTRAP_DATABASE
DRUPAL_BOOTSTRAP_VARIABLES
- DRUPAL_BOOTSTRAP_SESSION
- DRUPAL_BOOTSTRAP_PAGE_HEADER
- DRUPAL_BOOTSTRAP_LANGUAGE

+ DRUPAL_BOOTSTRAP_CODE
DRUPAL_BOOTSTRAP_FULL (language + theme)

Should be 3 steps - https://drupal.org/node/2023495
Drupal 7: Menu page callback
$result = _menu_site_is_offline()

? MENU_SITE_OFFLINE :

MENU_SITE_ONLINE;

drupal_alter('menu_site_status', $result, ...);
$result = call_user_func_array( $router['page_callback'],
$router['page_arguments']);
drupal_alter('page_delivery_callback',
$delivery_callback);
drupal_deliver_html_page()
drupal_render_page() - hook_page_build() + hook_page()
drupal_page_footer()
Drupal 8: Symfony drupal_handle_request()
// Initialize the environment, load settings.php, and activate a PSR-0 class
// autoloader with required namespaces registered.

drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
$kernel = new DrupalKernel('prod', drupal_classloader(),
!$test_only);
// @todo Remove this once everything in the bootstrap has been
//

converted to services in the DIC.

$kernel->boot();
drupal_bootstrap(DRUPAL_BOOTSTRAP_CODE);
// Create a request object from the HttpFoundation.

$request = Request::createFromGlobals();
$response = $kernel->handle($request)
->prepare($request)->send();
$kernel->terminate($request, $response);
D7: Hook, alter, preprocess!
●
●
●
●
●

Core hooks
Custom hooks
Alter everything
Preprocess anything
Theme suggestions

You are the King!
D8: Hook, alter, preprocess!
+ Subscribe
●
●
●
●
●
●

Kernel & Routing events
Core hooks
Custom hooks
Alter everything
Preprocess anything
Theme suggestions ++

You are the King!
D8: Subscribe kernel
namespace SymfonyComponentHttpKernel;
final class KernelEvents

●
●
●
●
●
●

REQUEST - hook_boot()
CONTROLLER - menu “page callback”
VIEW - hook_page_build()
RESPONSE - hook_page_alter()
TERMINATE - hook_exit()
EXCEPTION
D8: Subscribe routing
namespace DrupalCoreRouting;
final class RoutingEvents {
const ALTER = 'routing.route_alter';
const DYNAMIC = 'routing.route_dynamic';
}
D8: Subscribe and alter
namespace DrupalCoreEventSubscriber;
class AccessSubscriber implements EventSubscriberInterface {

static function getSubscribedEvents() {
$events[KernelEvents::REQUEST][] = array
('onKernelRequestAccessCheck', 30);
// Setting very low priority to ensure access checks are run after alters.

$events[RoutingEvents::ALTER][] = array
('onRoutingRouteAlterSetAccessCheck', -50);
return $events;
}
}
D8: Subscribe
D8: Hook, alter, preprocess
function telephone_field_info_alter(&$info) {
if (Drupal::moduleHandler()->moduleExists('text')) {
$info['telephone']['default_formatter'] = 'text_plain';
}
}
function telephone_field_formatter_info_alter(&$info) {
if (isset($info['text_plain'])) {
$info['text_plain']['field_types'][] = 'telephone';
}
}
D7: My.module vs altering
●

hook_menu()

$items['mypath'] = array(
'page callback' => 'mypath_page_view'
'theme callback' => 'theme_mypath_page_view'
'delivery callback' => 'deliver_mypath_page_view'
●
●

hook_theme()
mypath_page_view($arg);

VS
●
●
●
●

hook_menu_alter()
hook_theme_registry_alter()
mycore_page_view()
mycore_page_theme()
D7: My.module hook_menu()
1.
2.
3.
4.
5.
6.

Routing
Menu links
Local actions
Local tasks
Breadcrumbs
Contextual links
D8: My.module NO hook_menu()
1.

my.routing.yml

2.

my_default_menu_links()

3.

my.local_actions.yml

4.

my.local_tasks.yml

5.

class MyBreadcrumbBuilder

6.

my.contextual_links.yml

7.

my.services.yml
D8: My.module vs altering
hook_”world”_alter() - THE SAME!
class MyEventSubscriber implements

EventSubscriberInterface
{ public static function getSubscribedEvents(); }

class MyServiceProvider implements

ServiceProviderInterface, ServiceModifierInterface
{
public function register(ContainerBuilder $container) {}
public function alter(ContainerBuilder $container) {}

}
D8: Services & Managers
D7 vs D8: render
Render array (‘#theme’ => ‘item_list’,‘#items’ => array())

https://drupal.org/node/2068471
+

$events[KernelEvents::VIEW][] = array('onHtmlFragment', 100);

+

$events[KernelEvents::VIEW][] = array('onHtmlPage', 50);

class Link extends HeadElement
class Metatag extends HeadElement
class HeadElement
class HtmlPage extends HtmlFragment
class HtmlFragment
When it’s ready™?
https://drupal.org/node/2107085
http://xjm.drupalgardens.com/blog/when-its-ready
no more hook_menu()
no more variable_get()
complete language negotiation
complete entity field api
Questions?
Drupal 7 vs 8
Anderey Postnikov

Alexey Gaydabura

Freelance Developer
Skype: andypost
E-mail: apostnikov@gmail.com

Lead Developer at @SkillD
Skype: alexey.gaydabura
E-mail: gaydabura@gmail.com

http://www.skilld.fr

Mais conteúdo relacionado

Mais procurados

Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Ontico
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleStein Inge Morisbak
 
Docker SQL Continuous Integration Flow
Docker SQL Continuous Integration FlowDocker SQL Continuous Integration Flow
Docker SQL Continuous Integration FlowAndrii Podanenko
 
Building scala with bazel
Building scala with bazelBuilding scala with bazel
Building scala with bazelNatan Silnitsky
 
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境謝 宗穎
 
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...ZeroTurnaround
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleStein Inge Morisbak
 
Jenkins and Groovy
Jenkins and GroovyJenkins and Groovy
Jenkins and GroovyKiyotaka Oku
 
How to integrate front end tool via gruntjs
How to integrate front end tool via gruntjsHow to integrate front end tool via gruntjs
How to integrate front end tool via gruntjsBo-Yi Wu
 
Automating your workflow with Gulp.js
Automating your workflow with Gulp.jsAutomating your workflow with Gulp.js
Automating your workflow with Gulp.jsBo-Yi Wu
 
Gearman work queue in php
Gearman work queue in phpGearman work queue in php
Gearman work queue in phpBo-Yi Wu
 
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Advanced Git Techniques: Subtrees, Grafting, and Other Fun StuffAdvanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Advanced Git Techniques: Subtrees, Grafting, and Other Fun StuffAtlassian
 
Zero to Continuous Delivery on Google Cloud
Zero to Continuous Delivery on Google CloudZero to Continuous Delivery on Google Cloud
Zero to Continuous Delivery on Google CloudJames Heggs
 
Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Bo-Yi Wu
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Puppet
 
Jenkins 2.0 最新事情 〜Make Jenkins Great Again〜
Jenkins 2.0 最新事情 〜Make Jenkins Great Again〜Jenkins 2.0 最新事情 〜Make Jenkins Great Again〜
Jenkins 2.0 最新事情 〜Make Jenkins Great Again〜Jumpei Miyata
 
Vagrant introduction for Developers
Vagrant introduction for DevelopersVagrant introduction for Developers
Vagrant introduction for DevelopersAntons Kranga
 
"Wix Serverless from inside", Mykola Borozdin
"Wix Serverless from inside", Mykola Borozdin"Wix Serverless from inside", Mykola Borozdin
"Wix Serverless from inside", Mykola BorozdinFwdays
 
PHP & JavaScript & CSS Coding style
PHP & JavaScript & CSS Coding stylePHP & JavaScript & CSS Coding style
PHP & JavaScript & CSS Coding styleBo-Yi Wu
 

Mais procurados (20)

Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with Ansible
 
Docker SQL Continuous Integration Flow
Docker SQL Continuous Integration FlowDocker SQL Continuous Integration Flow
Docker SQL Continuous Integration Flow
 
Building scala with bazel
Building scala with bazelBuilding scala with bazel
Building scala with bazel
 
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
 
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with Ansible
 
Jenkins and Groovy
Jenkins and GroovyJenkins and Groovy
Jenkins and Groovy
 
How to integrate front end tool via gruntjs
How to integrate front end tool via gruntjsHow to integrate front end tool via gruntjs
How to integrate front end tool via gruntjs
 
Automating your workflow with Gulp.js
Automating your workflow with Gulp.jsAutomating your workflow with Gulp.js
Automating your workflow with Gulp.js
 
Gearman work queue in php
Gearman work queue in phpGearman work queue in php
Gearman work queue in php
 
ESIGate dev meeting #4 21-11-2013
ESIGate dev meeting #4 21-11-2013ESIGate dev meeting #4 21-11-2013
ESIGate dev meeting #4 21-11-2013
 
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Advanced Git Techniques: Subtrees, Grafting, and Other Fun StuffAdvanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
Advanced Git Techniques: Subtrees, Grafting, and Other Fun Stuff
 
Zero to Continuous Delivery on Google Cloud
Zero to Continuous Delivery on Google CloudZero to Continuous Delivery on Google Cloud
Zero to Continuous Delivery on Google Cloud
 
Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
 
Jenkins 2.0 最新事情 〜Make Jenkins Great Again〜
Jenkins 2.0 最新事情 〜Make Jenkins Great Again〜Jenkins 2.0 最新事情 〜Make Jenkins Great Again〜
Jenkins 2.0 最新事情 〜Make Jenkins Great Again〜
 
Vagrant introduction for Developers
Vagrant introduction for DevelopersVagrant introduction for Developers
Vagrant introduction for Developers
 
"Wix Serverless from inside", Mykola Borozdin
"Wix Serverless from inside", Mykola Borozdin"Wix Serverless from inside", Mykola Borozdin
"Wix Serverless from inside", Mykola Borozdin
 
PHP & JavaScript & CSS Coding style
PHP & JavaScript & CSS Coding stylePHP & JavaScript & CSS Coding style
PHP & JavaScript & CSS Coding style
 

Destaque

Многоязычие сайта на Drupal
Многоязычие сайта на DrupalМногоязычие сайта на Drupal
Многоязычие сайта на DrupalDrupal Camp Kyiv
 
DrupalCamp Kyiv 2009 Official Report
DrupalCamp Kyiv 2009 Official ReportDrupalCamp Kyiv 2009 Official Report
DrupalCamp Kyiv 2009 Official ReportDrupal Camp Kyiv
 
Работа с Views в Drupal 7
Работа с Views в Drupal 7Работа с Views в Drupal 7
Работа с Views в Drupal 7Eugene Fidelin
 
Работа с полями (fields) в Drupal 7
Работа с полями (fields) в Drupal 7Работа с полями (fields) в Drupal 7
Работа с полями (fields) в Drupal 7Eugene Fidelin
 
Работа с материалами (nodes) в Drupal 7
Работа с материалами (nodes) в Drupal 7Работа с материалами (nodes) в Drupal 7
Работа с материалами (nodes) в Drupal 7Eugene Fidelin
 
Do + ldo for developers(full)
Do + ldo for developers(full)Do + ldo for developers(full)
Do + ldo for developers(full)Andrii Podanenko
 
Who is here? DrupalCamp Kyiv 2009 opening
Who is here? DrupalCamp Kyiv 2009 openingWho is here? DrupalCamp Kyiv 2009 opening
Who is here? DrupalCamp Kyiv 2009 openingDrupal Camp Kyiv
 
Happy ever afters with ci workflow
Happy ever afters with ci workflowHappy ever afters with ci workflow
Happy ever afters with ci workflowAlbina Tiupa
 
Drupal code sprint для новичков
Drupal code sprint для новичковDrupal code sprint для новичков
Drupal code sprint для новичковOvadiah Myrgorod
 
Drupal на 20-ти мегабайтах или издевательства над Shared Hosting
Drupal на 20-ти мегабайтах или издевательства над Shared HostingDrupal на 20-ти мегабайтах или издевательства над Shared Hosting
Drupal на 20-ти мегабайтах или издевательства над Shared HostingAndrii Podanenko
 
Порівняння Drupal та Typo3
Порівняння Drupal та Typo3Порівняння Drupal та Typo3
Порівняння Drupal та Typo3Drupal Camp Kyiv
 
Історія, теорія та використання CMS Drupal
Історія, теорія та використання CMS DrupalІсторія, теорія та використання CMS Drupal
Історія, теорія та використання CMS DrupalIgor Bronovskyy
 
Drupal Continuous Integration Workflow
Drupal Continuous Integration WorkflowDrupal Continuous Integration Workflow
Drupal Continuous Integration WorkflowAndrii Podanenko
 
природна і економна дорожня карта для переходу команди розробки на тест центр...
природна і економна дорожня карта для переходу команди розробки на тест центр...природна і економна дорожня карта для переходу команди розробки на тест центр...
природна і економна дорожня карта для переходу команди розробки на тест центр...Andrii Podanenko
 
Головні Принципи Автоматизації
Головні Принципи АвтоматизаціїГоловні Принципи Автоматизації
Головні Принципи АвтоматизаціїAndrii Podanenko
 

Destaque (18)

Drupal Paranoia
Drupal ParanoiaDrupal Paranoia
Drupal Paranoia
 
Многоязычие сайта на Drupal
Многоязычие сайта на DrupalМногоязычие сайта на Drupal
Многоязычие сайта на Drupal
 
DrupalCamp Kyiv 2009 Official Report
DrupalCamp Kyiv 2009 Official ReportDrupalCamp Kyiv 2009 Official Report
DrupalCamp Kyiv 2009 Official Report
 
Работа с Views в Drupal 7
Работа с Views в Drupal 7Работа с Views в Drupal 7
Работа с Views в Drupal 7
 
AngularJS in practice
AngularJS in practiceAngularJS in practice
AngularJS in practice
 
Работа с полями (fields) в Drupal 7
Работа с полями (fields) в Drupal 7Работа с полями (fields) в Drupal 7
Работа с полями (fields) в Drupal 7
 
Работа с материалами (nodes) в Drupal 7
Работа с материалами (nodes) в Drupal 7Работа с материалами (nodes) в Drupal 7
Работа с материалами (nodes) в Drupal 7
 
Do + ldo for developers(full)
Do + ldo for developers(full)Do + ldo for developers(full)
Do + ldo for developers(full)
 
Who is here? DrupalCamp Kyiv 2009 opening
Who is here? DrupalCamp Kyiv 2009 openingWho is here? DrupalCamp Kyiv 2009 opening
Who is here? DrupalCamp Kyiv 2009 opening
 
Happy ever afters with ci workflow
Happy ever afters with ci workflowHappy ever afters with ci workflow
Happy ever afters with ci workflow
 
Drupal code sprint для новичков
Drupal code sprint для новичковDrupal code sprint для новичков
Drupal code sprint для новичков
 
Drupal на 20-ти мегабайтах или издевательства над Shared Hosting
Drupal на 20-ти мегабайтах или издевательства над Shared HostingDrupal на 20-ти мегабайтах или издевательства над Shared Hosting
Drupal на 20-ти мегабайтах или издевательства над Shared Hosting
 
Порівняння Drupal та Typo3
Порівняння Drupal та Typo3Порівняння Drupal та Typo3
Порівняння Drupal та Typo3
 
Start using vagrant now!
Start using vagrant now!Start using vagrant now!
Start using vagrant now!
 
Історія, теорія та використання CMS Drupal
Історія, теорія та використання CMS DrupalІсторія, теорія та використання CMS Drupal
Історія, теорія та використання CMS Drupal
 
Drupal Continuous Integration Workflow
Drupal Continuous Integration WorkflowDrupal Continuous Integration Workflow
Drupal Continuous Integration Workflow
 
природна і економна дорожня карта для переходу команди розробки на тест центр...
природна і економна дорожня карта для переходу команди розробки на тест центр...природна і економна дорожня карта для переходу команди розробки на тест центр...
природна і економна дорожня карта для переходу команди розробки на тест центр...
 
Головні Принципи Автоматизації
Головні Принципи АвтоматизаціїГоловні Принципи Автоматизації
Головні Принципи Автоматизації
 

Semelhante a Lviv 2013 d7 vs d8

Lviv 2013 d7 vs d8
Lviv 2013 d7 vs d8Lviv 2013 d7 vs d8
Lviv 2013 d7 vs d8Skilld
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenchesLukas Smith
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5Darren Craig
 
Zend Framework 2 - Basic Components
Zend Framework 2  - Basic ComponentsZend Framework 2  - Basic Components
Zend Framework 2 - Basic ComponentsMateusz Tymek
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207patter
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐいHisateru Tanaka
 
Drupalcon 2023 - How Drupal builds your pages.pdf
Drupalcon 2023 - How Drupal builds your pages.pdfDrupalcon 2023 - How Drupal builds your pages.pdf
Drupalcon 2023 - How Drupal builds your pages.pdfLuca Lusso
 
2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pages2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pagessparkfabrik
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)arcware
 
Laravel5 Introduction and essentials
Laravel5 Introduction and essentialsLaravel5 Introduction and essentials
Laravel5 Introduction and essentialsPramod Kadam
 
Patterns Are Good For Managers
Patterns Are Good For ManagersPatterns Are Good For Managers
Patterns Are Good For ManagersAgileThought
 
Magento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request FlowMagento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request FlowVrann Tulika
 
Drupal 8 Every Day: An Intro to Developing With Drupal 8
Drupal 8 Every Day: An Intro to Developing With Drupal 8Drupal 8 Every Day: An Intro to Developing With Drupal 8
Drupal 8 Every Day: An Intro to Developing With Drupal 8Acquia
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the TrenchesJonathan Wage
 
Debugging in drupal 8
Debugging in drupal 8Debugging in drupal 8
Debugging in drupal 8Allie Jones
 
Debugging: Rules & Tools
Debugging: Rules & ToolsDebugging: Rules & Tools
Debugging: Rules & ToolsIan Barber
 
Drupal 8 Services And Dependency Injection
Drupal 8 Services And Dependency InjectionDrupal 8 Services And Dependency Injection
Drupal 8 Services And Dependency InjectionPhilip Norton
 

Semelhante a Lviv 2013 d7 vs d8 (20)

Lviv 2013 d7 vs d8
Lviv 2013 d7 vs d8Lviv 2013 d7 vs d8
Lviv 2013 d7 vs d8
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5
 
Zend Framework 2 - Basic Components
Zend Framework 2  - Basic ComponentsZend Framework 2  - Basic Components
Zend Framework 2 - Basic Components
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
Drupalcon 2023 - How Drupal builds your pages.pdf
Drupalcon 2023 - How Drupal builds your pages.pdfDrupalcon 2023 - How Drupal builds your pages.pdf
Drupalcon 2023 - How Drupal builds your pages.pdf
 
2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pages2023 - Drupalcon - How Drupal builds your pages
2023 - Drupalcon - How Drupal builds your pages
 
Intro to Laravel 4
Intro to Laravel 4Intro to Laravel 4
Intro to Laravel 4
 
Drupal 8 migrate!
Drupal 8 migrate!Drupal 8 migrate!
Drupal 8 migrate!
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
 
Laravel5 Introduction and essentials
Laravel5 Introduction and essentialsLaravel5 Introduction and essentials
Laravel5 Introduction and essentials
 
Patterns Are Good For Managers
Patterns Are Good For ManagersPatterns Are Good For Managers
Patterns Are Good For Managers
 
Magento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request FlowMagento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request Flow
 
Drupal 8 Every Day: An Intro to Developing With Drupal 8
Drupal 8 Every Day: An Intro to Developing With Drupal 8Drupal 8 Every Day: An Intro to Developing With Drupal 8
Drupal 8 Every Day: An Intro to Developing With Drupal 8
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the Trenches
 
Debugging in drupal 8
Debugging in drupal 8Debugging in drupal 8
Debugging in drupal 8
 
Debugging: Rules & Tools
Debugging: Rules & ToolsDebugging: Rules & Tools
Debugging: Rules & Tools
 
Fatc
FatcFatc
Fatc
 
Drupal 8 Services And Dependency Injection
Drupal 8 Services And Dependency InjectionDrupal 8 Services And Dependency Injection
Drupal 8 Services And Dependency Injection
 

Último

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 

Último (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

Lviv 2013 d7 vs d8

  • 1. Drupal 7 vs 8 Andy Postnikov Freelancer & Alexey Gaydabura Lead Developer at @SkillD Lviv, 2013 http://www.skilld.fr
  • 3. Drupal 7 - install.php if (version_compare(PHP_VERSION, '5.2.4') < 0) { exit; } Drupal 8 - install.php chdir('..'); require_once __DIR__ . '/vendor/autoload.php'; if (version_compare(PHP_VERSION, '5.3.10') < 0) { exit; } if (ini_get('safe_mode')) { print 'Your PHP installation has safe_mode enabled. ...'; exit; }
  • 4. Drupal 7 - index.php define('DRUPAL_ROOT', getcwd()); require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); menu_execute_active_handler(); Drupal 8 - index.php require_once __DIR__ . '/core/vendor/autoload.php'; require_once __DIR__ . '/core/includes/bootstrap.inc'; try { drupal_handle_request(); } catch (Exception $e) { print 'If you have ... read http://drupal.org/documentation/rebuild'; throw $e; }
  • 5. Drupal 7 - Bootstrap 1. DRUPAL_BOOTSTRAP_CONFIGURATION 2. DRUPAL_BOOTSTRAP_PAGE_CACHE 3. DRUPAL_BOOTSTRAP_DATABASE 4. DRUPAL_BOOTSTRAP_VARIABLES 5. DRUPAL_BOOTSTRAP_SESSION 6. DRUPAL_BOOTSTRAP_PAGE_HEADER 7. DRUPAL_BOOTSTRAP_LANGUAGE 8. DRUPAL_BOOTSTRAP_FULL
  • 6. Drupal 8 - Bootstrap 1. DRUPAL_BOOTSTRAP_CONFIGURATION + DRUPAL_BOOTSTRAP_KERNEL 2. DRUPAL_BOOTSTRAP_PAGE_CACHE 3. DRUPAL_BOOTSTRAP_DATABASE DRUPAL_BOOTSTRAP_VARIABLES - DRUPAL_BOOTSTRAP_SESSION - DRUPAL_BOOTSTRAP_PAGE_HEADER - DRUPAL_BOOTSTRAP_LANGUAGE + DRUPAL_BOOTSTRAP_CODE DRUPAL_BOOTSTRAP_FULL (language + theme) Should be 3 steps - https://drupal.org/node/2023495
  • 7. Drupal 7: Menu page callback $result = _menu_site_is_offline() ? MENU_SITE_OFFLINE : MENU_SITE_ONLINE; drupal_alter('menu_site_status', $result, ...); $result = call_user_func_array( $router['page_callback'], $router['page_arguments']); drupal_alter('page_delivery_callback', $delivery_callback); drupal_deliver_html_page() drupal_render_page() - hook_page_build() + hook_page() drupal_page_footer()
  • 8. Drupal 8: Symfony drupal_handle_request() // Initialize the environment, load settings.php, and activate a PSR-0 class // autoloader with required namespaces registered. drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION); $kernel = new DrupalKernel('prod', drupal_classloader(), !$test_only); // @todo Remove this once everything in the bootstrap has been // converted to services in the DIC. $kernel->boot(); drupal_bootstrap(DRUPAL_BOOTSTRAP_CODE); // Create a request object from the HttpFoundation. $request = Request::createFromGlobals(); $response = $kernel->handle($request) ->prepare($request)->send(); $kernel->terminate($request, $response);
  • 9. D7: Hook, alter, preprocess! ● ● ● ● ● Core hooks Custom hooks Alter everything Preprocess anything Theme suggestions You are the King!
  • 10. D8: Hook, alter, preprocess! + Subscribe ● ● ● ● ● ● Kernel & Routing events Core hooks Custom hooks Alter everything Preprocess anything Theme suggestions ++ You are the King!
  • 11. D8: Subscribe kernel namespace SymfonyComponentHttpKernel; final class KernelEvents ● ● ● ● ● ● REQUEST - hook_boot() CONTROLLER - menu “page callback” VIEW - hook_page_build() RESPONSE - hook_page_alter() TERMINATE - hook_exit() EXCEPTION
  • 12. D8: Subscribe routing namespace DrupalCoreRouting; final class RoutingEvents { const ALTER = 'routing.route_alter'; const DYNAMIC = 'routing.route_dynamic'; }
  • 13. D8: Subscribe and alter namespace DrupalCoreEventSubscriber; class AccessSubscriber implements EventSubscriberInterface { static function getSubscribedEvents() { $events[KernelEvents::REQUEST][] = array ('onKernelRequestAccessCheck', 30); // Setting very low priority to ensure access checks are run after alters. $events[RoutingEvents::ALTER][] = array ('onRoutingRouteAlterSetAccessCheck', -50); return $events; } }
  • 15. D8: Hook, alter, preprocess function telephone_field_info_alter(&$info) { if (Drupal::moduleHandler()->moduleExists('text')) { $info['telephone']['default_formatter'] = 'text_plain'; } } function telephone_field_formatter_info_alter(&$info) { if (isset($info['text_plain'])) { $info['text_plain']['field_types'][] = 'telephone'; } }
  • 16. D7: My.module vs altering ● hook_menu() $items['mypath'] = array( 'page callback' => 'mypath_page_view' 'theme callback' => 'theme_mypath_page_view' 'delivery callback' => 'deliver_mypath_page_view' ● ● hook_theme() mypath_page_view($arg); VS ● ● ● ● hook_menu_alter() hook_theme_registry_alter() mycore_page_view() mycore_page_theme()
  • 17. D7: My.module hook_menu() 1. 2. 3. 4. 5. 6. Routing Menu links Local actions Local tasks Breadcrumbs Contextual links
  • 18. D8: My.module NO hook_menu() 1. my.routing.yml 2. my_default_menu_links() 3. my.local_actions.yml 4. my.local_tasks.yml 5. class MyBreadcrumbBuilder 6. my.contextual_links.yml 7. my.services.yml
  • 19. D8: My.module vs altering hook_”world”_alter() - THE SAME! class MyEventSubscriber implements EventSubscriberInterface { public static function getSubscribedEvents(); } class MyServiceProvider implements ServiceProviderInterface, ServiceModifierInterface { public function register(ContainerBuilder $container) {} public function alter(ContainerBuilder $container) {} }
  • 20. D8: Services & Managers
  • 21. D7 vs D8: render Render array (‘#theme’ => ‘item_list’,‘#items’ => array()) https://drupal.org/node/2068471 + $events[KernelEvents::VIEW][] = array('onHtmlFragment', 100); + $events[KernelEvents::VIEW][] = array('onHtmlPage', 50); class Link extends HeadElement class Metatag extends HeadElement class HeadElement class HtmlPage extends HtmlFragment class HtmlFragment
  • 22. When it’s ready™? https://drupal.org/node/2107085 http://xjm.drupalgardens.com/blog/when-its-ready no more hook_menu() no more variable_get() complete language negotiation complete entity field api
  • 24. Drupal 7 vs 8 Anderey Postnikov Alexey Gaydabura Freelance Developer Skype: andypost E-mail: apostnikov@gmail.com Lead Developer at @SkillD Skype: alexey.gaydabura E-mail: gaydabura@gmail.com http://www.skilld.fr