Enviar pesquisa
Carregar
Drupal 8 Sample Module
•
0 gostou
•
940 visualizações
drubb
Seguir
Introducing Block Plugins & Configuration Forms Drupal Meetup Stuttgart 03/05/2015
Leia menos
Leia mais
Internet
Denunciar
Compartilhar
Denunciar
Compartilhar
1 de 21
Baixar agora
Baixar para ler offline
Recomendados
Drupal 8: Routing & More
Drupal 8: Routing & More
drubb
Drupal 8: Forms
Drupal 8: Forms
drubb
Drupal 8: Entities
Drupal 8: Entities
drubb
jQuery secrets
jQuery secrets
Bastian Feder
Your Entity, Your Code
Your Entity, Your Code
Marco Vito Moscaritolo
Entities in drupal 7
Entities in drupal 7
Zsolt Tasnadi
Top Ten Reasons to Use EntityFieldQuery in Drupal
Top Ten Reasons to Use EntityFieldQuery in Drupal
Fredric Mitchell
What's New in Drupal 8: Entity Field API
What's New in Drupal 8: Entity Field API
Drupalize.Me
Recomendados
Drupal 8: Routing & More
Drupal 8: Routing & More
drubb
Drupal 8: Forms
Drupal 8: Forms
drubb
Drupal 8: Entities
Drupal 8: Entities
drubb
jQuery secrets
jQuery secrets
Bastian Feder
Your Entity, Your Code
Your Entity, Your Code
Marco Vito Moscaritolo
Entities in drupal 7
Entities in drupal 7
Zsolt Tasnadi
Top Ten Reasons to Use EntityFieldQuery in Drupal
Top Ten Reasons to Use EntityFieldQuery in Drupal
Fredric Mitchell
What's New in Drupal 8: Entity Field API
What's New in Drupal 8: Entity Field API
Drupalize.Me
Dependency injection in PHP 5.3/5.4
Dependency injection in PHP 5.3/5.4
Fabien Potencier
The Origin of Lithium
The Origin of Lithium
Nate Abele
Drupal 8: Theming
Drupal 8: Theming
drubb
Dependency injection-zendcon-2010
Dependency injection-zendcon-2010
Fabien Potencier
Unit and Functional Testing with Symfony2
Unit and Functional Testing with Symfony2
Fabien Potencier
Drupal Entities - Emerging Patterns of Usage
Drupal Entities - Emerging Patterns of Usage
Ronald Ashri
Entity Query API
Entity Query API
marcingy
Drupal 8 Hooks
Drupal 8 Hooks
Sathya Sheela Sankaralingam
The State of Lithium
The State of Lithium
Nate Abele
Drupal 7 entities & TextbookMadness.com
Drupal 7 entities & TextbookMadness.com
JD Leonard
Build your own entity with Drupal
Build your own entity with Drupal
Marco Vito Moscaritolo
Building Lithium Apps
Building Lithium Apps
Nate Abele
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Fabien Potencier
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate Frameworks
Nate Abele
Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3
Fabien Potencier
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Nate Abele
Field api.From d7 to d8
Field api.From d7 to d8
Pavel Makhrinsky
The Zen of Lithium
The Zen of Lithium
Nate Abele
Design Patterns in PHP5
Design Patterns in PHP5
Wildan Maulana
Doctrine 2
Doctrine 2
zfconfua
Михаил Крайнюк - Form API + Drupal 8: Form and AJAX
Михаил Крайнюк - Form API + Drupal 8: Form and AJAX
DrupalSib
Debugging in drupal 8
Debugging in drupal 8
Allie Jones
Mais conteúdo relacionado
Mais procurados
Dependency injection in PHP 5.3/5.4
Dependency injection in PHP 5.3/5.4
Fabien Potencier
The Origin of Lithium
The Origin of Lithium
Nate Abele
Drupal 8: Theming
Drupal 8: Theming
drubb
Dependency injection-zendcon-2010
Dependency injection-zendcon-2010
Fabien Potencier
Unit and Functional Testing with Symfony2
Unit and Functional Testing with Symfony2
Fabien Potencier
Drupal Entities - Emerging Patterns of Usage
Drupal Entities - Emerging Patterns of Usage
Ronald Ashri
Entity Query API
Entity Query API
marcingy
Drupal 8 Hooks
Drupal 8 Hooks
Sathya Sheela Sankaralingam
The State of Lithium
The State of Lithium
Nate Abele
Drupal 7 entities & TextbookMadness.com
Drupal 7 entities & TextbookMadness.com
JD Leonard
Build your own entity with Drupal
Build your own entity with Drupal
Marco Vito Moscaritolo
Building Lithium Apps
Building Lithium Apps
Nate Abele
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Fabien Potencier
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate Frameworks
Nate Abele
Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3
Fabien Potencier
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Nate Abele
Field api.From d7 to d8
Field api.From d7 to d8
Pavel Makhrinsky
The Zen of Lithium
The Zen of Lithium
Nate Abele
Design Patterns in PHP5
Design Patterns in PHP5
Wildan Maulana
Doctrine 2
Doctrine 2
zfconfua
Mais procurados
(20)
Dependency injection in PHP 5.3/5.4
Dependency injection in PHP 5.3/5.4
The Origin of Lithium
The Origin of Lithium
Drupal 8: Theming
Drupal 8: Theming
Dependency injection-zendcon-2010
Dependency injection-zendcon-2010
Unit and Functional Testing with Symfony2
Unit and Functional Testing with Symfony2
Drupal Entities - Emerging Patterns of Usage
Drupal Entities - Emerging Patterns of Usage
Entity Query API
Entity Query API
Drupal 8 Hooks
Drupal 8 Hooks
The State of Lithium
The State of Lithium
Drupal 7 entities & TextbookMadness.com
Drupal 7 entities & TextbookMadness.com
Build your own entity with Drupal
Build your own entity with Drupal
Building Lithium Apps
Building Lithium Apps
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate Frameworks
Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Field api.From d7 to d8
Field api.From d7 to d8
The Zen of Lithium
The Zen of Lithium
Design Patterns in PHP5
Design Patterns in PHP5
Doctrine 2
Doctrine 2
Semelhante a Drupal 8 Sample Module
Михаил Крайнюк - Form API + Drupal 8: Form and AJAX
Михаил Крайнюк - Form API + Drupal 8: Form and AJAX
DrupalSib
Debugging in drupal 8
Debugging in drupal 8
Allie Jones
Your Entity, Your Code
Your Entity, Your Code
DrupalDay
First Steps in Drupal Code Driven Development
First Steps in Drupal Code Driven Development
Nuvole
laravel tricks in 50minutes
laravel tricks in 50minutes
Barang CK
50 Laravel Tricks in 50 Minutes
50 Laravel Tricks in 50 Minutes
Azim Kurt
Codeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept Implementation
Abdul Malik Ikhsan
How Kris Writes Symfony Apps
How Kris Writes Symfony Apps
Kris Wallsmith
Rapid Prototyping with PEAR
Rapid Prototyping with PEAR
Markus Wolff
¿Cómo de sexy puede hacer Backbone mi código?
¿Cómo de sexy puede hacer Backbone mi código?
jaespinmora
Symfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technology
Daniel Knell
Drupal 8 Theme System: The Backend of Frontend
Drupal 8 Theme System: The Backend of Frontend
Acquia
Ordering System IP2buildclasses.netbeans_automatic_buildO.docx
Ordering System IP2buildclasses.netbeans_automatic_buildO.docx
hopeaustin33688
Extbase and Beyond
Extbase and Beyond
Jochen Rau
Unittests für Dummies
Unittests für Dummies
Lars Jankowfsky
Android and the Seven Dwarfs from Devox'15
Android and the Seven Dwarfs from Devox'15
Murat Yener
Drupal 8 Every Day: An Intro to Developing With Drupal 8
Drupal 8 Every Day: An Intro to Developing With Drupal 8
Acquia
Porting adsense module to Drupal 8
Porting adsense module to Drupal 8
João Ventura
Drupal 9 training ajax
Drupal 9 training ajax
NeelAndrew
Magento 2 | Declarative schema
Magento 2 | Declarative schema
Kiel Pykett
Semelhante a Drupal 8 Sample Module
(20)
Михаил Крайнюк - Form API + Drupal 8: Form and AJAX
Михаил Крайнюк - Form API + Drupal 8: Form and AJAX
Debugging in drupal 8
Debugging in drupal 8
Your Entity, Your Code
Your Entity, Your Code
First Steps in Drupal Code Driven Development
First Steps in Drupal Code Driven Development
laravel tricks in 50minutes
laravel tricks in 50minutes
50 Laravel Tricks in 50 Minutes
50 Laravel Tricks in 50 Minutes
Codeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept Implementation
How Kris Writes Symfony Apps
How Kris Writes Symfony Apps
Rapid Prototyping with PEAR
Rapid Prototyping with PEAR
¿Cómo de sexy puede hacer Backbone mi código?
¿Cómo de sexy puede hacer Backbone mi código?
Symfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technology
Drupal 8 Theme System: The Backend of Frontend
Drupal 8 Theme System: The Backend of Frontend
Ordering System IP2buildclasses.netbeans_automatic_buildO.docx
Ordering System IP2buildclasses.netbeans_automatic_buildO.docx
Extbase and Beyond
Extbase and Beyond
Unittests für Dummies
Unittests für Dummies
Android and the Seven Dwarfs from Devox'15
Android and the Seven Dwarfs from Devox'15
Drupal 8 Every Day: An Intro to Developing With Drupal 8
Drupal 8 Every Day: An Intro to Developing With Drupal 8
Porting adsense module to Drupal 8
Porting adsense module to Drupal 8
Drupal 9 training ajax
Drupal 9 training ajax
Magento 2 | Declarative schema
Magento 2 | Declarative schema
Mais de drubb
Barrierefreie Webseiten
Barrierefreie Webseiten
drubb
Drupal 9 Entity Bundle Classes
Drupal 9 Entity Bundle Classes
drubb
Drupal 8 Dependency Injection Using Traits
Drupal 8 Dependency Injection Using Traits
drubb
Closing the Drupal Hosting Gap - A Review of Wodby
Closing the Drupal Hosting Gap - A Review of Wodby
drubb
Composer & Drupal
Composer & Drupal
drubb
Headless Drupal
Headless Drupal
drubb
Spamschutzverfahren für Drupal
Spamschutzverfahren für Drupal
drubb
Drupal 8: TWIG Template Engine
Drupal 8: TWIG Template Engine
drubb
Drupal 8: Neuerungen im Überblick
Drupal 8: Neuerungen im Überblick
drubb
Drupal Entities
Drupal Entities
drubb
Mais de drubb
(10)
Barrierefreie Webseiten
Barrierefreie Webseiten
Drupal 9 Entity Bundle Classes
Drupal 9 Entity Bundle Classes
Drupal 8 Dependency Injection Using Traits
Drupal 8 Dependency Injection Using Traits
Closing the Drupal Hosting Gap - A Review of Wodby
Closing the Drupal Hosting Gap - A Review of Wodby
Composer & Drupal
Composer & Drupal
Headless Drupal
Headless Drupal
Spamschutzverfahren für Drupal
Spamschutzverfahren für Drupal
Drupal 8: TWIG Template Engine
Drupal 8: TWIG Template Engine
Drupal 8: Neuerungen im Überblick
Drupal 8: Neuerungen im Überblick
Drupal Entities
Drupal Entities
Último
NSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentation
Marko4394
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptx
editsforyah
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
494f574xmv
Git and Github workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
gdsc13
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
eusebiomeyer
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
z xss
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
Christopher H Felton
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhi
miss dipika
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
zdzoqco
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
Fs
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 Documentation
LinaWolf1
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
Dyna Gilbert
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24
Paul Calvano
Magic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptx
MartaLoveguard
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
rnrncn29
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Sonam Pathan
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
ys8omjxb
Elevate Your Business with Our IT Expertise in New Orleans
Elevate Your Business with Our IT Expertise in New Orleans
corenetworkseo
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
Fs
Último
(20)
NSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentation
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptx
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
Git and Github workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhi
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 Documentation
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24
Magic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptx
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Elevate Your Business with Our IT Expertise in New Orleans
Elevate Your Business with Our IT Expertise in New Orleans
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
Drupal 8 Sample Module
1.
Drupal 8: Sample
ModuleDrupal 8: Sample Module Introducing Block Plugins & Configuration FormsIntroducing Block Plugins & Configuration Forms Drupal Meetup StuttgartDrupal Meetup Stuttgart 03/05/2015
2.
1. Tell Drupal
about the1. Tell Drupal about the modulemodule
3.
name: Temperature type: module description:
'Creates a configurable block showing the local temperature' package: Meetup version: '1.0.0' core: '8.x' modules/custom/temperature/temperature.info.yml
4.
5.
2. Create a
simple block2. Create a simple block pluginplugin
6.
<?php /** * @file * Contains
DrupaltemperaturePluginBlockTemperatureBlock. */ namespace DrupaltemperaturePluginBlock; use DrupalCoreBlockBlockBase; /** * Provides a 'Temperature' block. * * @Block( * id = "temperature", * admin_label = @Translation("Local temperature"), * category = @Translation("Meetup") * ) */ class TemperatureBlock extends BlockBase { public function build() { return [ '#markup' => 'Seems cold outside!', ]; } } modules/custom/temperature/src/Plugin/Block/TemperatureBlock.php
7.
use GuzzleHttpClient; class TemperatureBlock
extends BlockBase { public function build() { $city = 'Stuttgart, DE' $client = new Client(); $response = $client->get("http://api.openweathermap.org/data/2.5/weather?q=$city"); if ($response->getStatusCode() == '200') { $result = json_decode($response->getBody()); $markup = "Current temperature in<br>$city:<br>"; $markup .= round($result->main->temp - 273.15) . '° C'; } else { $markup = 'Sorry, something went wrong!'; } return [ '#markup' => $markup, ]; } } Adding the "real" content
8.
9.
3. Make block
instances3. Make block instances configurableconfigurable
10.
block.settings.temperature: type: block_settings label: 'Temperature
block' mapping: city: type: string label: 'City for temperature display' modules/custom/temperature/config/schema/temperature.schema.yml
11.
use DrupalCoreBlockBlockBase; use DrupalCoreFormFormStateInterface; class
TemperatureBlock extends BlockBase { public function build() { $city = $this->configuration['city']; ... } public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['city'] = array( '#title' => 'Location', '#type' => 'textfield', '#default_value' => $this->configuration['city'], ); return $form; } public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['city'] = $form_state->getValue('city'); $this->blockSubmit($form, $form_state); } } modules/custom/temperature/src/Plugin/Block/TemperatureBlock.php
12.
13.
4. Provide a
default4. Provide a default configurationconfiguration
14.
temperature.settings: type: mapping label: 'Temperature
settings' mapping: city: type: string label: 'Default city for temperature display' block.settings.temperature: type: block_settings label: 'Temperature block' mapping: city: type: string label: 'City for temperature display' modules/custom/temperature/config/schema/temperature.schema.yml modules/custom/temperature/config/install/temperature.settings.yml city: 'Stuttgart,DE'
15.
... class TemperatureBlock extends
BlockBase { public function defaultConfiguration() { $config = Drupal::config('temperature.settings')->get(); return $config; } public function build() { ... } public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['city'] = array( '#title' => 'Location', '#type' => 'textfield', '#default_value' => $this->configuration['city'], ); return $form; } public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { $this->configuration['city'] = $form_state->getValue('city'); $this->blockSubmit($form, $form_state); } } modules/custom/temperature/src/Plugin/Block/TemperatureBlock.php
16.
17.
5. Make default5.
Make default configuration editableconfiguration editable
18.
temperature.settings: path: '/admin/config/system/temperature' defaults: _form: 'DrupaltemperatureFormSettingsForm' _title:
'Temperature settings' requirements: _permission: 'administer site configuration' modules/custom/temperature/temperature.routing.yml
19.
<?php /** * @file * Contains
DrupaltemperatureFormSettingsForm */ namespace DrupaltemperatureForm; use DrupalCoreFormConfigFormBase; use DrupalCoreFormFormStateInterface; class SettingsForm extends ConfigFormBase { public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); $form['city'] = [ '#title' => 'Default Location', '#type' => 'textfield', '#default_value' => $this->config('temperature.settings')->get('city'), ]; return $form; } public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('temperature.settings') ->set('city', $form_state->getValue('city')) ->save(); parent::submitForm($form, $form_state); } protected function getEditableConfigNames() { return ['temperature.settings']; } public function getFormId() { return 'temperature_settings'; } } modules/custom/temperature/src/Form/SettingsForm.php
20.
21.
Thank You!Thank You! http://slides.com/drubb http://slideshare.net/drubb
Baixar agora