SlideShare uma empresa Scribd logo
1 de 35
Drupal 8 Every Day
An Intro to Developing With Drupal 8
Erin Marchak
● Acquia Certified Front End Specialist, and Developer
● dgo.to/@emarchak
Geoff Appleby
● Acquia Certified Developer
● dgo.to/@gapple
● Persistent Login & drupalreleasedate.com
1. Unboxing
2. Installation
3. Configuration Management
a. Development Workflow
b. Export
c. Import
4. Development
a. Module Generation
b. Page Controllers
c. Entity Bundles
d. Forms
5. Theming
a. Theme Generation
b. Twig Syntax
c. Debugging
d. Including Assets
Unboxing
Unboxing Drupal 8
New Features
Configuration Management
Twig replaces PHPTemplate
PHPUnit supplements SimpleTest
Responsive base theme & admin
Fast by Default
New modules in core
Requirements
Minimum
PHP 5.5.9
MySQL 5.5.3
Recommended
PHP 5.6.5
APCu
New file structure
Core is now in ./core
Modules are now in ./modules
Profiles are now in ./profiles
Themes are now in ./themes
Drupal Console
Interactive console
Scaffolding
Site Management
What about Drush?
curl -LSs http://drupalconsole.com/installer | php
Installation
Site Install - site:new
Site Install - site:install
Configuration Management
ProductionDevelopment
Active
Storage
Active
Storage
Code Repository
Sync Storage
ImportExport
Configuration Management
Move database settings to settings.local.php
Uncomment include() statement
Set config sync directory in settings.php
$config_directories[CONFIG_SYNC_DIRECTORY] = __DIR__ . '/config';
cp example.gitignore .gitignore
git add -f sites/default/settings.php
mkdir sites/default/config
Configuration Management - Export
Console creates an archive of YML files
drupal config:export
Drush outputs YML files directly to the sync directory
drush config-export
Configuration Management - Import
Console imports an archive of YML files
drupal config:import [file name]
Drush imports YML files directly from the sync directory
drush config-import
Development
Development - Generate a Custom Module
Development - Generate a Page Controller
Development - ./photography.routing.yml
photography.gallery_controller_gallery:
path: '/photography'
defaults:
_controller: 'DrupalphotographyControllerGalleryController::gallery'
_title: 'Photography Gallery'
requirements:
_permission: 'access content'
photography.order_form:
path: '/photography/order'
defaults:
_form: 'DrupalphotographyFormOrderForm'
_title: 'Photo Order Form'
requirements:
_permission: 'access content'
Development - ./src/Controller/GalleryController.php
/**
* @file
* Contains DrupalphotographyControllerGalleryController.
*/
namespace DrupalphotographyController;
use DrupalCoreControllerControllerBase;
/**
* Class GalleryController.
*
* @package DrupalphotographyController
*/
class GalleryController extends ControllerBase {
/**
* Helper function to load all published photographs.
*/
public function loadAllPhotos($bundle_type = 'photograph') {...}
/**
* Gallery display.
*/
public function gallery() {...}
}
Development - Generate an Entity Bundle
Development - GalleryController->loadAllPhotos()
/**
* Helper function to load all published photographs.
*
* @param string $bundle_type
* @return DrupalCoreEntityEntityInterface[]
* Array of node objects keyed by nid.
*/
public function loadAllPhotos($bundle_type = 'photograph') {
// Return the entity manager service and load the the storage instance for nodes.
// That way we have access to the enity api while keeping our controller lean.
$storage = $this->entityManager()->getStorage('node');
// loadByProperties() allows us to query and load entities in one line!
return $storage->loadByProperties(array(
'type' => $bundle_type,
'status' => 1,
));
}
Development - GalleryController->gallery()
/**
* Gallery display.
*/
public function gallery() {
$langcode = $this->languageManager()->getCurrentLanguage('language');
$photographs = $this->loadAllPhotos();
$view_mode = 'teaser';
$gallery = array();
// Loop through the loaded photograph node objects and output their rendered result into a list.
$viewBuilder = $this->entityManager->getViewBuilder('node');
foreach ($photographs as $photograph) {
$gallery[] = $viewBuilder->view($photograph, $view_mode);
}
// If the gallery is empty, we should apologise.
if (empty($gallery)) {...}
// Return an item list of photographs for our gallery.
return [
'#theme' => 'item_list',
'#items' => $gallery,
];
}
Development - ./src/Form/OrderForm.php
/**
* @file
* Contains DrupalphotographyFormOrderForm.
*/
namespace DrupalphotographyForm;
use DrupalCoreFormFormBase;
use DrupalCoreFormFormStateInterface;
/**
* Class OrderForm.
*
* @package DrupalphotographyForm
*/
class OrderForm extends FormBase {
public function getFormId() {...}
public function buildForm(array $form, FormStateInterface $form_state) {...}
protected function validPostalCode(string $postal_code) {...}
public function validateForm(array &$form, FormStateInterface $form_state) {...}
public function submitForm(array &$form, FormStateInterface $form_state) {...}
}
Development - ./Tests/src/OrderFormTests.php
/**
* @file
* Contains DrupalphotographyTestsOrderFormTest.
*/
namespace DrupalphotographyTests;
use DrupalTestsUnitTestCase;
use DrupalphotographyFormOrderForm;
/**
* Tests validation of postal codes.
*
* @group photography
*/
class OrderFormTest extends UnitTestCase {
...
/**
* Test valid postal codes.
*/
public function testPostalCodeValid() {...}
/**
* Test invalid postal codes.
*/
public function testPostalCodeInvalid() {...}
Theming
Theming with Twig - generate:theme
Twig Syntax
PHPTemplate Twig
<?php print $variable ?> {{ variable }}
<?php if (condition): ?> {% if condition %}
<?php foreach ($users as $user):
?>
{% for user in users %}
<?php print t(“string”) ?> {{ “string”|t }}
{%
set classes = [
'node',
'node--type-' ~ node.bundle|clean_class,
node.isPromoted() ? 'node--promoted',
node.isSticky() ? 'node--sticky',
not node.isPublished() ? 'node--unpublished',
view_mode ? 'node--view-mode-' ~ view_mode|clean_class,
]
%}
{{ attach_library('classy/node') }}
<article{{ attributes.addClass(classes) }}>
{{ title_prefix }}
{% if not page %}
<h2{{ title_attributes }}>
<a href="{{ url }}" rel="bookmark">{{ label }}</a>
</h2>
{% endif %}
{{ title_suffix }}
<div{{ content_attributes.addClass('node__content') }}>
{{ content }}
</div>
</article>
Twig Debug
sites/default/services.yml
parameters:
twig.config:
debug: true
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'block' -->
<!-- FILE NAME SUGGESTIONS:
* block--bartik-main-menu.html.twig
* block--system-menu-block--main.html.twig
x block--system-menu-block.html.twig
* block--system.html.twig
* block.html.twig
-->
<!-- BEGIN OUTPUT from 'core/themes/bartik/templates/block--system-menu-block.html.twig' -->
<nav role="navigation"
aria-labelledby="block-bartik-main-menu-menu"
id="block-bartik-main-menu"
class="contextual-region block block-menu navigation menu--main">
Adding CSS
portfolio.libraries.yml
global-styling:
version: 1.x
css:
theme:
css/portfolio-global.css: {}
portfolio.info.yml
libraries:
- portfolio/global-styling
Questions or Comments? We’d love to hear from you!
twitter.com/emarchak
twitter.com/gappleca
twitter.com/myplanetHQ
We can also help with your Drupal projects.
We know how to nudge the big wigs to give D8 a chance.
Extra pair of hands to plug in and help out.
That’s all, folks!
Thank you
Resources
Github Repository https://github.com/gapple/drupal-8-every-day
Database Dump https://drive.google.com/file/d/0B-PTT5Vfuw18RTdId2poQUFNR1E/view
Drupal Console https://www.drupal.org/project/console
Theming Guide https://www.drupal.org/theme-guide/8
CMI Documentation https://www.drupal.org/documentation/administer/config

Mais conteúdo relacionado

Mais procurados

Laravel for Web Artisans
Laravel for Web ArtisansLaravel for Web Artisans
Laravel for Web ArtisansRaf Kewl
 
10 Laravel packages everyone should know
10 Laravel packages everyone should know10 Laravel packages everyone should know
10 Laravel packages everyone should knowPovilas Korop
 
Always up to date, testable and maintainable documentation with OpenAPI
Always up to date, testable and maintainable documentation with OpenAPIAlways up to date, testable and maintainable documentation with OpenAPI
Always up to date, testable and maintainable documentation with OpenAPIGOG.com dev team
 
Laravel 5 In Depth
Laravel 5 In DepthLaravel 5 In Depth
Laravel 5 In DepthKirk Bushell
 
Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)Viral Solani
 
Laravel presentation
Laravel presentationLaravel presentation
Laravel presentationToufiq Mahmud
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterHaehnchen
 
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 TutorialAdventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 TutorialJoe Ferguson
 
Becoming A Drupal Master Builder
Becoming A Drupal Master BuilderBecoming A Drupal Master Builder
Becoming A Drupal Master BuilderPhilip Norton
 
Laravel Design Patterns
Laravel Design PatternsLaravel Design Patterns
Laravel Design PatternsBobby Bouwmann
 
Top laravel packages to install handpicked list from expert
Top laravel packages to install handpicked list from expertTop laravel packages to install handpicked list from expert
Top laravel packages to install handpicked list from expertKaty Slemon
 
Getting to know Laravel 5
Getting to know Laravel 5Getting to know Laravel 5
Getting to know Laravel 5Bukhori Aqid
 
Drupal 8 Services And Dependency Injection
Drupal 8 Services And Dependency InjectionDrupal 8 Services And Dependency Injection
Drupal 8 Services And Dependency InjectionPhilip Norton
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5Darren Craig
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Elena Kolevska
 
Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8Michelangelo van Dam
 

Mais procurados (20)

Laravel 5
Laravel 5Laravel 5
Laravel 5
 
Workshop Laravel 5.2
Workshop Laravel 5.2Workshop Laravel 5.2
Workshop Laravel 5.2
 
Laravel for Web Artisans
Laravel for Web ArtisansLaravel for Web Artisans
Laravel for Web Artisans
 
10 Laravel packages everyone should know
10 Laravel packages everyone should know10 Laravel packages everyone should know
10 Laravel packages everyone should know
 
Always up to date, testable and maintainable documentation with OpenAPI
Always up to date, testable and maintainable documentation with OpenAPIAlways up to date, testable and maintainable documentation with OpenAPI
Always up to date, testable and maintainable documentation with OpenAPI
 
CakePHP
CakePHPCakePHP
CakePHP
 
Laravel 5 In Depth
Laravel 5 In DepthLaravel 5 In Depth
Laravel 5 In Depth
 
Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)
 
Laravel presentation
Laravel presentationLaravel presentation
Laravel presentation
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 
Why Laravel?
Why Laravel?Why Laravel?
Why Laravel?
 
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 TutorialAdventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
 
Becoming A Drupal Master Builder
Becoming A Drupal Master BuilderBecoming A Drupal Master Builder
Becoming A Drupal Master Builder
 
Laravel Design Patterns
Laravel Design PatternsLaravel Design Patterns
Laravel Design Patterns
 
Top laravel packages to install handpicked list from expert
Top laravel packages to install handpicked list from expertTop laravel packages to install handpicked list from expert
Top laravel packages to install handpicked list from expert
 
Getting to know Laravel 5
Getting to know Laravel 5Getting to know Laravel 5
Getting to know Laravel 5
 
Drupal 8 Services And Dependency Injection
Drupal 8 Services And Dependency InjectionDrupal 8 Services And Dependency Injection
Drupal 8 Services And Dependency Injection
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
 
Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8
 

Semelhante a Drupal 8 Every Day: An Intro to Developing With Drupal 8

Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practicesmanugoel2003
 
Voiture tech talk
Voiture tech talkVoiture tech talk
Voiture tech talkHoppinger
 
Drupal 8 simple page: Mi primer proyecto en Drupal 8.
Drupal 8 simple page: Mi primer proyecto en Drupal 8.Drupal 8 simple page: Mi primer proyecto en Drupal 8.
Drupal 8 simple page: Mi primer proyecto en Drupal 8.Samuel Solís Fuentes
 
Convert modules from 6.x to 7.x
Convert modules from 6.x to 7.xConvert modules from 6.x to 7.x
Convert modules from 6.x to 7.xJoão Ventura
 
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and BeyondDrupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and BeyondDrupalDay
 
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 Configuration Management with Features
Drupal 8 Configuration Management with FeaturesDrupal 8 Configuration Management with Features
Drupal 8 Configuration Management with FeaturesNuvole
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolGordon Forsythe
 
Andy Postnikov - Drupal 7 vs Drupal 8: от бутстрапа до рендера
Andy Postnikov - Drupal 7 vs Drupal 8: от бутстрапа до рендераAndy Postnikov - Drupal 7 vs Drupal 8: от бутстрапа до рендера
Andy Postnikov - Drupal 7 vs Drupal 8: от бутстрапа до рендераLEDC 2016
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Phpfunkatron
 
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
 
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and SimpleDrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and SimpleAlexander Varwijk
 
把鐵路開進視窗裡
把鐵路開進視窗裡把鐵路開進視窗裡
把鐵路開進視窗裡Wei Jen Lu
 
Laying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentLaying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentTammy Hart
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to javaciklum_ods
 
Customizing the Presentation Model and Physical Renderer in Siebel Open UI
Customizing the Presentation Model and Physical Renderer in Siebel Open UICustomizing the Presentation Model and Physical Renderer in Siebel Open UI
Customizing the Presentation Model and Physical Renderer in Siebel Open UITech OneStop
 
Drupal 8, Where Did the Code Go? From Info Hook to Plugin
Drupal 8, Where Did the Code Go? From Info Hook to PluginDrupal 8, Where Did the Code Go? From Info Hook to Plugin
Drupal 8, Where Did the Code Go? From Info Hook to PluginAcquia
 
Михаил Крайнюк - Form API + Drupal 8: Form and AJAX
Михаил Крайнюк - Form API + Drupal 8: Form and AJAXМихаил Крайнюк - Form API + Drupal 8: Form and AJAX
Михаил Крайнюк - Form API + Drupal 8: Form and AJAXDrupalSib
 

Semelhante a Drupal 8 Every Day: An Intro to Developing With Drupal 8 (20)

Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
Voiture tech talk
Voiture tech talkVoiture tech talk
Voiture tech talk
 
Drupal 8 simple page: Mi primer proyecto en Drupal 8.
Drupal 8 simple page: Mi primer proyecto en Drupal 8.Drupal 8 simple page: Mi primer proyecto en Drupal 8.
Drupal 8 simple page: Mi primer proyecto en Drupal 8.
 
Convert modules from 6.x to 7.x
Convert modules from 6.x to 7.xConvert modules from 6.x to 7.x
Convert modules from 6.x to 7.x
 
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and BeyondDrupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
 
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 Configuration Management with Features
Drupal 8 Configuration Management with FeaturesDrupal 8 Configuration Management with Features
Drupal 8 Configuration Management with Features
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_Tool
 
Test your modules
Test your modulesTest your modules
Test your modules
 
Andy Postnikov - Drupal 7 vs Drupal 8: от бутстрапа до рендера
Andy Postnikov - Drupal 7 vs Drupal 8: от бутстрапа до рендераAndy Postnikov - Drupal 7 vs Drupal 8: от бутстрапа до рендера
Andy Postnikov - Drupal 7 vs Drupal 8: от бутстрапа до рендера
 
Lviv 2013 d7 vs d8
Lviv 2013   d7 vs d8Lviv 2013   d7 vs d8
Lviv 2013 d7 vs d8
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
 
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)
 
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and SimpleDrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
DrupalJam 2018 - Maintaining a Drupal Module: Keep It Small and Simple
 
把鐵路開進視窗裡
把鐵路開進視窗裡把鐵路開進視窗裡
把鐵路開進視窗裡
 
Laying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentLaying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme development
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
Customizing the Presentation Model and Physical Renderer in Siebel Open UI
Customizing the Presentation Model and Physical Renderer in Siebel Open UICustomizing the Presentation Model and Physical Renderer in Siebel Open UI
Customizing the Presentation Model and Physical Renderer in Siebel Open UI
 
Drupal 8, Where Did the Code Go? From Info Hook to Plugin
Drupal 8, Where Did the Code Go? From Info Hook to PluginDrupal 8, Where Did the Code Go? From Info Hook to Plugin
Drupal 8, Where Did the Code Go? From Info Hook to Plugin
 
Михаил Крайнюк - Form API + Drupal 8: Form and AJAX
Михаил Крайнюк - Form API + Drupal 8: Form and AJAXМихаил Крайнюк - Form API + Drupal 8: Form and AJAX
Михаил Крайнюк - Form API + Drupal 8: Form and AJAX
 

Mais de Acquia

Acquia_Adcetera Webinar_Marketing Automation.pdf
Acquia_Adcetera Webinar_Marketing Automation.pdfAcquia_Adcetera Webinar_Marketing Automation.pdf
Acquia_Adcetera Webinar_Marketing Automation.pdfAcquia
 
Acquia Webinar Deck - 9_13 .pdf
Acquia Webinar Deck - 9_13 .pdfAcquia Webinar Deck - 9_13 .pdf
Acquia Webinar Deck - 9_13 .pdfAcquia
 
Taking Your Multi-Site Management at Scale to the Next Level
Taking Your Multi-Site Management at Scale to the Next LevelTaking Your Multi-Site Management at Scale to the Next Level
Taking Your Multi-Site Management at Scale to the Next LevelAcquia
 
CDP for Retail Webinar with Appnovation - Q2 2022.pdf
CDP for Retail Webinar with Appnovation - Q2 2022.pdfCDP for Retail Webinar with Appnovation - Q2 2022.pdf
CDP for Retail Webinar with Appnovation - Q2 2022.pdfAcquia
 
May Partner Bootcamp 2022
May Partner Bootcamp 2022May Partner Bootcamp 2022
May Partner Bootcamp 2022Acquia
 
April Partner Bootcamp 2022
April Partner Bootcamp 2022April Partner Bootcamp 2022
April Partner Bootcamp 2022Acquia
 
How to Unify Brand Experience: A Hootsuite Story
How to Unify Brand Experience: A Hootsuite Story How to Unify Brand Experience: A Hootsuite Story
How to Unify Brand Experience: A Hootsuite Story Acquia
 
Using Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CX
Using Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CXUsing Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CX
Using Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CXAcquia
 
Improve Code Quality and Time to Market: 100% Cloud-Based Development Workflow
Improve Code Quality and Time to Market: 100% Cloud-Based Development WorkflowImprove Code Quality and Time to Market: 100% Cloud-Based Development Workflow
Improve Code Quality and Time to Market: 100% Cloud-Based Development WorkflowAcquia
 
September Partner Bootcamp
September Partner BootcampSeptember Partner Bootcamp
September Partner BootcampAcquia
 
August partner bootcamp
August partner bootcampAugust partner bootcamp
August partner bootcampAcquia
 
July 2021 Partner Bootcamp
July  2021 Partner BootcampJuly  2021 Partner Bootcamp
July 2021 Partner BootcampAcquia
 
May Partner Bootcamp
May Partner BootcampMay Partner Bootcamp
May Partner BootcampAcquia
 
DRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASY
DRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASYDRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASY
DRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASYAcquia
 
Work While You Sleep: The CMO’s Guide to a 24/7/365 Lead Machine
Work While You Sleep: The CMO’s Guide to a 24/7/365 Lead MachineWork While You Sleep: The CMO’s Guide to a 24/7/365 Lead Machine
Work While You Sleep: The CMO’s Guide to a 24/7/365 Lead MachineAcquia
 
Acquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B Leads
Acquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B LeadsAcquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B Leads
Acquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B LeadsAcquia
 
April partner bootcamp deck cookieless future
April partner bootcamp deck  cookieless futureApril partner bootcamp deck  cookieless future
April partner bootcamp deck cookieless futureAcquia
 
How to enhance cx through personalised, automated solutions
How to enhance cx through personalised, automated solutionsHow to enhance cx through personalised, automated solutions
How to enhance cx through personalised, automated solutionsAcquia
 
DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...
DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...
DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...Acquia
 
Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021
Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021
Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021Acquia
 

Mais de Acquia (20)

Acquia_Adcetera Webinar_Marketing Automation.pdf
Acquia_Adcetera Webinar_Marketing Automation.pdfAcquia_Adcetera Webinar_Marketing Automation.pdf
Acquia_Adcetera Webinar_Marketing Automation.pdf
 
Acquia Webinar Deck - 9_13 .pdf
Acquia Webinar Deck - 9_13 .pdfAcquia Webinar Deck - 9_13 .pdf
Acquia Webinar Deck - 9_13 .pdf
 
Taking Your Multi-Site Management at Scale to the Next Level
Taking Your Multi-Site Management at Scale to the Next LevelTaking Your Multi-Site Management at Scale to the Next Level
Taking Your Multi-Site Management at Scale to the Next Level
 
CDP for Retail Webinar with Appnovation - Q2 2022.pdf
CDP for Retail Webinar with Appnovation - Q2 2022.pdfCDP for Retail Webinar with Appnovation - Q2 2022.pdf
CDP for Retail Webinar with Appnovation - Q2 2022.pdf
 
May Partner Bootcamp 2022
May Partner Bootcamp 2022May Partner Bootcamp 2022
May Partner Bootcamp 2022
 
April Partner Bootcamp 2022
April Partner Bootcamp 2022April Partner Bootcamp 2022
April Partner Bootcamp 2022
 
How to Unify Brand Experience: A Hootsuite Story
How to Unify Brand Experience: A Hootsuite Story How to Unify Brand Experience: A Hootsuite Story
How to Unify Brand Experience: A Hootsuite Story
 
Using Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CX
Using Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CXUsing Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CX
Using Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CX
 
Improve Code Quality and Time to Market: 100% Cloud-Based Development Workflow
Improve Code Quality and Time to Market: 100% Cloud-Based Development WorkflowImprove Code Quality and Time to Market: 100% Cloud-Based Development Workflow
Improve Code Quality and Time to Market: 100% Cloud-Based Development Workflow
 
September Partner Bootcamp
September Partner BootcampSeptember Partner Bootcamp
September Partner Bootcamp
 
August partner bootcamp
August partner bootcampAugust partner bootcamp
August partner bootcamp
 
July 2021 Partner Bootcamp
July  2021 Partner BootcampJuly  2021 Partner Bootcamp
July 2021 Partner Bootcamp
 
May Partner Bootcamp
May Partner BootcampMay Partner Bootcamp
May Partner Bootcamp
 
DRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASY
DRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASYDRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASY
DRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASY
 
Work While You Sleep: The CMO’s Guide to a 24/7/365 Lead Machine
Work While You Sleep: The CMO’s Guide to a 24/7/365 Lead MachineWork While You Sleep: The CMO’s Guide to a 24/7/365 Lead Machine
Work While You Sleep: The CMO’s Guide to a 24/7/365 Lead Machine
 
Acquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B Leads
Acquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B LeadsAcquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B Leads
Acquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B Leads
 
April partner bootcamp deck cookieless future
April partner bootcamp deck  cookieless futureApril partner bootcamp deck  cookieless future
April partner bootcamp deck cookieless future
 
How to enhance cx through personalised, automated solutions
How to enhance cx through personalised, automated solutionsHow to enhance cx through personalised, automated solutions
How to enhance cx through personalised, automated solutions
 
DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...
DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...
DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...
 
Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021
Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021
Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021
 

Último

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
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
 
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
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
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
 

Último (20)

Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
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
 

Drupal 8 Every Day: An Intro to Developing With Drupal 8

  • 1.
  • 2. Drupal 8 Every Day An Intro to Developing With Drupal 8
  • 3. Erin Marchak ● Acquia Certified Front End Specialist, and Developer ● dgo.to/@emarchak Geoff Appleby ● Acquia Certified Developer ● dgo.to/@gapple ● Persistent Login & drupalreleasedate.com
  • 4. 1. Unboxing 2. Installation 3. Configuration Management a. Development Workflow b. Export c. Import 4. Development a. Module Generation b. Page Controllers c. Entity Bundles d. Forms 5. Theming a. Theme Generation b. Twig Syntax c. Debugging d. Including Assets
  • 6. Unboxing Drupal 8 New Features Configuration Management Twig replaces PHPTemplate PHPUnit supplements SimpleTest Responsive base theme & admin Fast by Default New modules in core Requirements Minimum PHP 5.5.9 MySQL 5.5.3 Recommended PHP 5.6.5 APCu New file structure Core is now in ./core Modules are now in ./modules Profiles are now in ./profiles Themes are now in ./themes
  • 7. Drupal Console Interactive console Scaffolding Site Management What about Drush? curl -LSs http://drupalconsole.com/installer | php
  • 9. Site Install - site:new
  • 10. Site Install - site:install
  • 13. Configuration Management Move database settings to settings.local.php Uncomment include() statement Set config sync directory in settings.php $config_directories[CONFIG_SYNC_DIRECTORY] = __DIR__ . '/config'; cp example.gitignore .gitignore git add -f sites/default/settings.php mkdir sites/default/config
  • 14. Configuration Management - Export Console creates an archive of YML files drupal config:export Drush outputs YML files directly to the sync directory drush config-export
  • 15.
  • 16. Configuration Management - Import Console imports an archive of YML files drupal config:import [file name] Drush imports YML files directly from the sync directory drush config-import
  • 18. Development - Generate a Custom Module
  • 19. Development - Generate a Page Controller
  • 20. Development - ./photography.routing.yml photography.gallery_controller_gallery: path: '/photography' defaults: _controller: 'DrupalphotographyControllerGalleryController::gallery' _title: 'Photography Gallery' requirements: _permission: 'access content' photography.order_form: path: '/photography/order' defaults: _form: 'DrupalphotographyFormOrderForm' _title: 'Photo Order Form' requirements: _permission: 'access content'
  • 21. Development - ./src/Controller/GalleryController.php /** * @file * Contains DrupalphotographyControllerGalleryController. */ namespace DrupalphotographyController; use DrupalCoreControllerControllerBase; /** * Class GalleryController. * * @package DrupalphotographyController */ class GalleryController extends ControllerBase { /** * Helper function to load all published photographs. */ public function loadAllPhotos($bundle_type = 'photograph') {...} /** * Gallery display. */ public function gallery() {...} }
  • 22. Development - Generate an Entity Bundle
  • 23. Development - GalleryController->loadAllPhotos() /** * Helper function to load all published photographs. * * @param string $bundle_type * @return DrupalCoreEntityEntityInterface[] * Array of node objects keyed by nid. */ public function loadAllPhotos($bundle_type = 'photograph') { // Return the entity manager service and load the the storage instance for nodes. // That way we have access to the enity api while keeping our controller lean. $storage = $this->entityManager()->getStorage('node'); // loadByProperties() allows us to query and load entities in one line! return $storage->loadByProperties(array( 'type' => $bundle_type, 'status' => 1, )); }
  • 24. Development - GalleryController->gallery() /** * Gallery display. */ public function gallery() { $langcode = $this->languageManager()->getCurrentLanguage('language'); $photographs = $this->loadAllPhotos(); $view_mode = 'teaser'; $gallery = array(); // Loop through the loaded photograph node objects and output their rendered result into a list. $viewBuilder = $this->entityManager->getViewBuilder('node'); foreach ($photographs as $photograph) { $gallery[] = $viewBuilder->view($photograph, $view_mode); } // If the gallery is empty, we should apologise. if (empty($gallery)) {...} // Return an item list of photographs for our gallery. return [ '#theme' => 'item_list', '#items' => $gallery, ]; }
  • 25. Development - ./src/Form/OrderForm.php /** * @file * Contains DrupalphotographyFormOrderForm. */ namespace DrupalphotographyForm; use DrupalCoreFormFormBase; use DrupalCoreFormFormStateInterface; /** * Class OrderForm. * * @package DrupalphotographyForm */ class OrderForm extends FormBase { public function getFormId() {...} public function buildForm(array $form, FormStateInterface $form_state) {...} protected function validPostalCode(string $postal_code) {...} public function validateForm(array &$form, FormStateInterface $form_state) {...} public function submitForm(array &$form, FormStateInterface $form_state) {...} }
  • 26. Development - ./Tests/src/OrderFormTests.php /** * @file * Contains DrupalphotographyTestsOrderFormTest. */ namespace DrupalphotographyTests; use DrupalTestsUnitTestCase; use DrupalphotographyFormOrderForm; /** * Tests validation of postal codes. * * @group photography */ class OrderFormTest extends UnitTestCase { ... /** * Test valid postal codes. */ public function testPostalCodeValid() {...} /** * Test invalid postal codes. */ public function testPostalCodeInvalid() {...}
  • 28. Theming with Twig - generate:theme
  • 29. Twig Syntax PHPTemplate Twig <?php print $variable ?> {{ variable }} <?php if (condition): ?> {% if condition %} <?php foreach ($users as $user): ?> {% for user in users %} <?php print t(“string”) ?> {{ “string”|t }}
  • 30. {% set classes = [ 'node', 'node--type-' ~ node.bundle|clean_class, node.isPromoted() ? 'node--promoted', node.isSticky() ? 'node--sticky', not node.isPublished() ? 'node--unpublished', view_mode ? 'node--view-mode-' ~ view_mode|clean_class, ] %} {{ attach_library('classy/node') }} <article{{ attributes.addClass(classes) }}> {{ title_prefix }} {% if not page %} <h2{{ title_attributes }}> <a href="{{ url }}" rel="bookmark">{{ label }}</a> </h2> {% endif %} {{ title_suffix }} <div{{ content_attributes.addClass('node__content') }}> {{ content }} </div> </article>
  • 31. Twig Debug sites/default/services.yml parameters: twig.config: debug: true <!-- THEME DEBUG --> <!-- THEME HOOK: 'block' --> <!-- FILE NAME SUGGESTIONS: * block--bartik-main-menu.html.twig * block--system-menu-block--main.html.twig x block--system-menu-block.html.twig * block--system.html.twig * block.html.twig --> <!-- BEGIN OUTPUT from 'core/themes/bartik/templates/block--system-menu-block.html.twig' --> <nav role="navigation" aria-labelledby="block-bartik-main-menu-menu" id="block-bartik-main-menu" class="contextual-region block block-menu navigation menu--main">
  • 33. Questions or Comments? We’d love to hear from you! twitter.com/emarchak twitter.com/gappleca twitter.com/myplanetHQ We can also help with your Drupal projects. We know how to nudge the big wigs to give D8 a chance. Extra pair of hands to plug in and help out. That’s all, folks!
  • 35. Resources Github Repository https://github.com/gapple/drupal-8-every-day Database Dump https://drive.google.com/file/d/0B-PTT5Vfuw18RTdId2poQUFNR1E/view Drupal Console https://www.drupal.org/project/console Theming Guide https://www.drupal.org/theme-guide/8 CMI Documentation https://www.drupal.org/documentation/administer/config

Notas do Editor

  1. Mention Geoff’s modules! persistent login!
  2. Before we jump into it, we’re going to take a quick poll. At your company, are you guys planning on hopping on to D8? a) Yup, we’re planning on or are currently developing a D8 site b) Yes, we’re planning on or are currently migrating an existing site to D8 c) Nope not yet d) Enter your own response (Blank field)
  3. Twig: no php in templates, autoescape output Fast by Default: Improved caching (cache tags), Page Caching on by default, uses APCu when available (ChainedFastCache) New Modules: Views, field types, breakpoint + picture This new file structure adds simplicity for new developers. We’re no longer pointing people into a rabbit hole of files to get started developing. (/sites/all/modules and /sites/default/modules still work, and override /modules) PHP 5.5 still receives security fixes, but is the oldest supported version (7 will be out soon, with big performance improvements) APCu is automatically used for some caching when available A note to MAMP developers: versions prior to MAMP 3 don’t come with the minimum PHP version. Either expect to spend the time to roll your own, or upgrade.
  4. Drupal Console’s main functionality is assisting in development by generating snippets. Built on Symfony Console components, only supports D8 Compared to drush: No remote management (yet) Module / extension support may be better for drush Collaborating with drush to improve both projects
  5. Most of the console of the prompts have autocompletes and defaults, so it’s quite quick to get through the progress.
  6. Before we jump into it, we’re going to take a quick poll. Which CMS(s) is your company currently on? a) Drupal b) Other open-souce (Wordpress, Joomla etc.) c) A proprietary or in-house platform d) Enter your own response (Blank field)
  7. Active storage is in the database Changes made in UI are applied to active store By default the sync directory is within the site’s files directory; should be set to a version-controlled location Previously called “Staging”; may still be used in some older documentation Import/Export are all or nothing operations, replacing config in target location Merge tools are being improved Admin page allows comparing differences before import to active storage Sites can’t yet be setup directly from config files; database has to be synced between environments initially.
  8. Keep site specific or security conscious code out of settings.php (e.g. database config) site install creates a config directory with random name in files; want to replace with folder tracked in version control yml files are protected from public visibility by the web server
  9. Drush offers simplest workflow for now, by storing YML to sync directory
  10. drupal generate:module drupal console can generate module scaffolding quickly and efficiently. stuff that was previously done through the GUI can be performed entirely in the command line. it even allows you to include a composer.json file if you’re dependant on external libraries in your module. YAML: info, menu
  11. Create page controller If you wanted to load services (language manager, entity manager, entity query, etc.) you could pre-load them during the generation. I found, however that ControllerBase already had everything. drupalize.me’s Amber Matz said, “check your pantry to see if [you] already have it” before you start adding dependencies. A good IDE really helps inspecting your available methods and properties. console only generates simpletests right now, so unit tests will have to be included by hand (we’ll get into that later.)
  12. If your route needs a menu item, that needs to be defined separately in module_name.links.menu.yml defaults for routes can be: controller, form, entity view (finds entity in path and renders it), entity list (returns a list of entities) and entity form (edit for for entites) If you have a parameter in your path that you identity as the entity type (e.g. {node}), you can pre-load it in the controller. Route access can be permission or role defined, you can control the method (get/post) you can also control if the output is in json, html or both just from the routing.
  13. This is the contents of the controller. All of the structure was pre-generated except for loadAllPhotos() Namespace reflects the file location within the src directory. No dependency injection, no services, no complex construction. Since we’ll be loading the photos, we’ll need to create a content type.
  14. drupal config:export:content:type [content] --module=[module] generate basic bundles through drupal console, field configuration through the UI (it may change!)
  15. entity manager is available in the base Controller class already. Updated entity api allows us to quickly query and load entites. No need for multiple loops in custom code. Check the pantry before you shop!
  16. this is the action method that we defined in our router. language manager is available in the base Controller class already. getViewBuilder() creates an entity handler instance for your specific entity type. consistent entity handlers mean that entities will behave consistently, no need to know multiple process just to render two types of entities More things are entities in d8 (blocks, comments, nodes, users, taxonomies, etc.) render array stays the same.
  17. While the form is still a FAPI array, the form state is stored in a FormStateInterface object reading, creating and manipulating form data has become much easier. Type hinting is encouraged and expected in your methods. New HTML5 field widgets (url, tel, email, color, etc.), HTML5 input types (date, email, range, color, etc.), and HTML5 input attributes (placeholder, min, max, autocomplete, etc.). HTML5 form elements (progressbar) are en route No private methods because of the desire to keep things visible. Keeping something protected means that no one else can change up the values on the object arbitrarily. Given how extensible drupal is, they've chosen to keep all functions public or protected to allow developers to edit their code/output. This is not in the coding standard, but comes from discussions with core developers. The use of public properties is strongly discouraged, as it allows for unwanted side effects. It also exposes implementation-specific details, which in turn makes swapping out a class for another implementation (one of the key reasons to use objects) much harder. Properties should be considered internal to a class. Protected properties and methods should not use an underscore prefix.
  18. Running tests on my custom postal code validation function, since submit and validation unit tests already are covered. You must run PHPUnit from the /core directory PHPUnit can only find tests in ./Tests/src/Unit/*, whose class ends with “Test” and methods start with “test”. Examples of this test can be found in our code repository.
  19. Before we jump into it, we’re going to take a quick poll. 3. What is your biggest challenge to working with or adopting Drupal 8? a) Unported modules b) Switching to object orientated c) Bureaucracy from the big wigs d) Enter your own response (Blank field)
  20. like modules, the *.info now changed to *.info.yml *.theme instead of template.php Base Themes: Stable & Classy Stable provides basic HTML markup for complete control in a sub-theme Classy (the default) provides classic drupal wrapper classes (though much improved)
  21. Common components of a template are easily converted. Can output any object that can be converted to a string understands render arrays as well, so no need to call render() on children
  22. More control over output given to template files: templates are the norm, functions discouraged (Theme functions only used in performance sensitive areas) classes defined in templates instead of preprocess functions Arbitrary PHP is not allowed, but still many tools available Setting and manipulating variables Attributes is an object; methods are available
  23. Adds comments to show possible template file names, marks template in use, and provides full path to template file (helps differentiate between parent / child theme files) {{ dump() }} available to see all variables accessible within template
  24. {} allows defining a media property for each file Adding to *.info.yml will apply site-wide Can also be added within a twig template with {{ attach_library('theme/library') }}, or during preprocess phase using #attached property of render array element jQuery is not included by default, so must declare dependency in library definition. drupalSettings is also only included when necessary Inline Javascript no longer available through #attached / libraries Themes can place in template files Modules should convert to JS file; dynamic components should use drupalSettings