Drupal as a framework

471 views

Published on

Diapositivas de la charla Drupal como framework, dada en el grupo phpMAD, en Abril de 2014.
Hablamos del patrón de diseño que usa Drupal7, el que usa Drupal8, sus diferencias y como afecta eso a la hora de desarrollar módulos utilizando Drupal.
Podéis ver el vídeo aquí: https://www.youtube.com/watch?v=-aI18i506MM

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
471
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Drupal as a framework

  1. 1. DRUPAL as a framework Samuel Solís @estoyausente linkedin.com/in/samuelsolisfuentes
  2. 2. Drupal as a framework Samuel Solís | @estoyausente What is DRUPAL?
  3. 3. Drupal as framework Samuel Solís | @estoyausente CMSs Frameworks Drupal as a framework Samuel Solís | @estoyausente
  4. 4. Drupal as framework Samuel Solís | @estoyausente CMSs Frameworks ¿CMF? Drupal as a framework Samuel Solís | @estoyausente
  5. 5. Drupal as framework Samuel Solís | @estoyausente Drupal inside Drupal as a framework Samuel Solís | @estoyausente
  6. 6. Drupal as framework Samuel Solís | @estoyausente diff drupal7 drupal8 - PAC (presentation-abstraction-control)! + MVC! + Orient-Object code! + PHP standards! + Symfony2 component! + Twig! + Build-in web services! Drupal as a framework Samuel Solís | @estoyausente
  7. 7. Drupal as framework Samuel Solís | @estoyausente PAC Drupal as a framework Samuel Solís | @estoyausente
  8. 8. Drupal as framework Samuel Solís | @estoyausente Drupal7’s PAC http://dsheiko.com/ Drupal as a framework Samuel Solís | @estoyausente
  9. 9. Drupal as framework Samuel Solís | @estoyausente http://dsheiko.com/ Drupal as a framework Samuel Solís | @estoyausente
  10. 10. Drupal for devs Samuel Solís | @estoyausente ! block_example/! ├── block_example.info ├── block_example.install ├── block_example.module └── block_example.test tree block_example Drupal as a framework Samuel Solís | @estoyausente
  11. 11. Drupal for devs Samuel Solís | @estoyausente function block_example_block_info() {! $blocks['example_configurable_text'] = !! array(! 'info' => t('Example),! 'cache' => DRUPAL_CACHE_PER_ROLE,! );! return $blocks;! } ! vi block_example.module Drupal as a framework Samuel Solís | @estoyausente
  12. 12. Drupal for devs Samuel Solís | @estoyausente function block_example_block_configure($delta = '') {! $form = array();! if ($delta == ‘example_configurable_text’){! $form['block_example_string'] = array(! '#type' => ‘textfield',! '#title' => t('Block contents’),! '#size' => 60,! '#description' => t('This text example'),! '#default_value' => variable_get('block_example_string', t('Some example content.’)),! ); ! } return $form;! } Drupal as a framework Samuel Solís | @estoyausente
  13. 13. Drupal for devs Samuel Solís | @estoyausente function block_example_block_save($delta = '', $edit = array()) {! if ($delta == ‘example_configurable_text’){! ! variable_set(‘block_example_string’,! ! $edit[‘block_example_string’]);! }! }! Drupal as a framework Samuel Solís | @estoyausente
  14. 14. Drupal for devs Samuel Solís | @estoyausente function block_example_block_view($delta = '') { switch ($delta) {! case ‘example_configurable_text':! $block['subject'] = t('Title'); $block['content'] = block_example_contents();! break; ! }! return $block;! }! Drupal as a framework Samuel Solís | @estoyausente
  15. 15. Drupal for devs Samuel Solís | @estoyausente function block_example_contents() { return variable_get(‘block_example_string’);! }! Drupal as a framework Samuel Solís | @estoyausente
  16. 16. Drupal as framework Samuel Solís | @estoyausente Drupal8’s MVC Drupal as a framework Samuel Solís | @estoyausente
  17. 17. Drupal for devs Samuel Solís | @estoyausente block_example/ ├── block_example.info.yml ├── block_example.module ├── block_example.routing.yml └── lib └── Drupal └── block_example ├── Controller │   └── BlockExampleController.php ├── Plugin │   └── Block │   ├── ExampleConfigurableTextBlock.php │   ├── ExampleEmptyBlock.php │   └── ExampleUppercaseBlock.php └── Tests ├── BlockExampleMenuTest.php └── BlockExampleTest.php tree block_example Drupal as a framework Samuel Solís | @estoyausente
  18. 18. Drupal for devs Samuel Solís | @estoyausente block_example/ ├── block_example.info.yml ├── block_example.module ├── block_example.routing.yml └── lib └── Drupal └── block_example ├── Controller │   └── BlockExampleController.php ├── Plugin │   └── Block │   ├── ExampleConfigurableTextBlock.php │   ├── ExampleEmptyBlock.php │   └── ExampleUppercaseBlock.php └── Tests ├── BlockExampleMenuTest.php └── BlockExampleTest.php tree block_example Drupal as a framework Samuel Solís | @estoyausente PSR 0
  19. 19. Drupal for devs Samuel Solís | @estoyausente function block_example_menu_link_defaults() { $links['block_example'] = array( 'link_title' => 'Block Example’, 'route_name' => ‘block_example.description', ); return $links; } vi block_example.module Drupal as a framework Samuel Solís | @estoyausente
  20. 20. Drupal for devs Samuel Solís | @estoyausente block_example.description: path: ‘examples/block_example’ defaults: _content: 'Drupalblock_exampleController BlockExampleController::description' requirements: _access: 'TRUE' vi block_example.routing.yml Drupal as a framework Samuel Solís | @estoyausente
  21. 21. Drupal for devs Samuel Solís | @estoyausente namespace Drupalblock_exampleController; class BlockExampleController { public function description() { $build = array( '#markup' => t(‘Descripion'), ); return $build; } } vi BlockExampleController.php Drupal as a framework Samuel Solís | @estoyausente
  22. 22. Drupal for devs Samuel Solís | @estoyausente namespace Drupalblock_examplePluginBlock; use DrupalblockAnnotationBlock; use DrupalblockBlockBase; use DrupalCoreAnnotationTranslation; vi BlockExampleConfigurableText.php Drupal as a framework Samuel Solís | @estoyausente
  23. 23. Drupal for devs Samuel Solís | @estoyausente class ExampleConfigurableTextBlock extends BlockBase { ! public function defaultConfiguration() { return array( 'block_example_string' => t(‘Default'), ); } ! Drupal as a framework Samuel Solís | @estoyausente
  24. 24. Drupal for devs Samuel Solís | @estoyausente public function blockForm($form, &$form_state) { $form['block_example_string_text'] = array( '#type' => ‘textfield', '#title' => t('Block contents’), '#size' => 60, '#description' => t(‘Description'), '#default_value' => $this->configuration[‘block_example_string'], ); return $form; } ! ! Drupal as a framework Samuel Solís | @estoyausente
  25. 25. Drupal for devs Samuel Solís | @estoyausente public function blockSubmit($form, & $form_state) { $this->configuration['block_example_string'] = $form_state[‘values'] ['block_example_string_text']; } Drupal as a framework Samuel Solís | @estoyausente
  26. 26. Drupal for devs Samuel Solís | @estoyausente public function build() { return array( '#type' => ‘markup', '#markup' => $this->configuration[‘block_example_string'], ); } ! }//end class Drupal as a framework Samuel Solís | @estoyausente
  27. 27. Drupal as framework Samuel Solís | @estoyausente Drush Drupal as a framework Samuel Solís | @estoyausente
  28. 28. Samuel Solís @estoyausente

×