Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Custom entities in d8

408 views

Published on

Cómo crear un tipo de entidad en Drupal 8 desde el principio. Definición de la nueva entidad, especificación de campos y formulario, handlers, validaciones y renderización.

Sesión impartida en el DrupalDay 2017 en Santiago de Compostela.

Vídeo quí. No se me ve a mi, pero se ven las slides y se escucha perfectamente:
https://vimeo.com/192773521

Published in: Software
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download Full doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download PDF EBOOK here { https://urlzs.com/UABbn } ......................................................................................................................... Download EPUB Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... Download doc Ebook here { https://urlzs.com/UABbn } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://shorturl.at/mzUV6 } ......................................................................................................................... Download Full EPUB Ebook here { http://shorturl.at/mzUV6 } ......................................................................................................................... Download Full doc Ebook here { http://shorturl.at/mzUV6 } ......................................................................................................................... Download PDF EBOOK here { http://shorturl.at/mzUV6 } ......................................................................................................................... Download EPUB Ebook here { http://shorturl.at/mzUV6 } ......................................................................................................................... Download doc Ebook here { http://shorturl.at/mzUV6 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Custom entities in d8

  1. 1. Custom entities in D8
  2. 2. Custom entities in D8 DrupalDay Santiago de compostela 2016 Samuel Solís (@estoyausente)
  3. 3. @estoyausente Samuel Solís
  4. 4. Drupalday Santiago 2017 @estoyausente
  5. 5. Drupalday Santiago 2017 @estoyausente ¿Qué vamos a ver? ¿Qué es un tipo de entidad? De contenido vs de configuración Algo de terminología Definición del tipo de entidad en bd Formularios Validaciones Renderizar entidades
  6. 6. Drupalday Santiago 2017 @estoyausente ¿Qué es un tipo de entidad? Un tipo de entidad es una clase que tiene métodos y manejadores definidos para almacenar, listar, cargar y mostrar una estructura de datos de forma unificada. “
  7. 7. Drupalday Santiago 2017 @estoyausente ¿Qué es un tipo de entidad? Un tipo de entidad es una clase que tiene métodos y manejadores definidos para almacenar, listar, cargar y mostrar una estructura de datos de forma unificada. “ WTF????
  8. 8. Drupalday Santiago 2017 @estoyausente Config Content Entities Content types Views Contact forms Image styles Nodes Comments Profiles Terms .yml files CMI
  9. 9. Drupalday Santiago 2017 @estoyausente Config Content Entities Content types Views Contact forms Image styles Nodes Comments Profiles Terms .yml files CMI
  10. 10. Drupalday Santiago 2017 @estoyausente Algo de terminología Bundle Field PropertyEntity type node author Page Imagen
  11. 11. Drupalday Santiago 2017 @estoyausente
  12. 12. Drupalday Santiago 2017 @estoyausente Definición del Tipo de Entidad Anotación Definición de la clase método baseFieldDefinitions
  13. 13. MiDrupal$ /** * @ContentEntityType( * id = "galician", * label = @Translation(“Galician"), * handlers = { * }, * }, * base_table = “galicians", * admin_permission = "administer galician people", * fieldable = FALSE, * entity_keys = { * "id" = "id", * }, * admin_permission = “administer galicians” * ) */ vim src/Entity/Galician.php
  14. 14. MiDrupal$ vim src/Entity/MyEntity.php namespace DrupalgalicianEntity; use DrupalCoreFieldBaseFieldDefinition; use DrupalCoreEntityContentEntityBase; . . . class Galician extends ContentEntityBase { use StringTranslationTrait; } vim src/Entity/Galician.php
  15. 15. MiDrupal$ vim src/Entity/MyEntity.php public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['id'] = BaseFieldDefinition::create('integer') ->setLabel(t('ID')) ->setDescription(t('The ID of the galician person.')) ->setReadOnly(TRUE); $fields['clothing'] = BaseFieldDefinition::create('string') ->setLabel(t('From')) ->setDescription(t(‘Galician clothing.’) ->setSettings(array( 'default_value' => 'Raincoat', )) ->setRequired(true); $fields['created'] = BaseFieldDefinition::create('created') ->setLabel(t('Created')) ->setDescription(t('The time that the entity was created.')); } vim src/Entity/Galician.php
  16. 16. MiDrupal$ $fields['province'] = BaseFieldDefinition::create('entity_reference') ->setLabel(t('Province id.')) ->setDescription(t('The Pid of the associated province.')) ->setSetting('target_type', 'province') ->setSetting('handler', 'default'); vim src/Entity/Galician.php
  17. 17. MiDrupal$ public function getClothing() {} public function setClothing() {} public function getOwner() {} public function preSave() {} public function postSave() {} public function preCreate() {} . . . vim src/Entity/Galician.php
  18. 18. MiDrupal$ public function eatPrawns($num) { //eat a boat of prawns. return true; } vim src/Entity/Galician.php
  19. 19. drush en miModulo drush entity-updates
  20. 20. MiDrupal$ vim any/other/Place.php $galicianIds = Drupal::entityQuery('galician') ->condition(‘clothing’,’raincoat' , '<>') ->sort('date', 'DESC') ->execute(); } //Dirty and easy way $galicians = Drupal::entityTypeManager() ->getStorage(‘galician')->loadMultiple($galicianIds); //Dependency Injection way $galicians = $this->GalicianStorageController —>loadMultiple($orderIds); foreach($galicians as $galician) { $galician->eatPrawns(100000); } $galician->save();
  21. 21. Drupalday Santiago 2017 @estoyausente Formularios
  22. 22. Drupalday Santiago 2017 @estoyausente Formularios
  23. 23. MiDrupal$ /** * @ContentEntityType( * id = "galician", * … some stuff * handlers = { * "form" = { * "add" = "DrupalgaliciaFormGalicianForm", * "edit" = "DrupalgaliciaFormGalicianForm", * "delete" = “DrupalCoreEntityContentEntityDeleteForm", * }, * }, * }, * some stuff … * ) */ vim src/Entity/Galician.php
  24. 24. MiDrupal$ vim src/Entity/MyEntity.php public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['clothing'] = BaseFieldDefinition::create('string') ->setLabel(t('From')) ->setDescription(t(‘Galician clothing.’) ->setSettings([( 'default_value' => 'Raincoat', ]) ->setDisplayConfigurable('Form', true) ->setDisplayOptions('Form', [ 'weigth' => 2, ]) ->setRequired(true); } vim src/Entity/Galician.php
  25. 25. MiDrupal$ namespace DrupalgalicianForm; use DrupalCoreEntityContentEntityForm; use DrupalCoreFormFormStateInterface; class GalicianForm extends ContentEntityForm { public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); if(isSunny()) { // <— if(false) $form[‘clothing']['widget'][0]['default_value'] = ‘heat'; } return $form; } public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); } } vim src/Form/GalicianForm.php
  26. 26. MiDrupal$ entity.galician.galician_add:
 path: '/galician/add'
 defaults:
 _entity_form: galician.add
 _title: ‘Create a new Galician person'
 requirements:
 _entity_create_access: 'galician'
 
 entity.galician.galician_add:
 path: '/galician/{galician}/edit'
 defaults:
 _entity_form: galician.edit
 _title: 'Edit Galician'
 requirements:
 _permission: 'administer galician entity'
 vim galician.routing.yml
  27. 27. Tia na naaaaa …
  28. 28. Algunos gallegos creados …
  29. 29. Algunos gallegos creados … Mario Casas
  30. 30. Rouco Varela Algunos gallegos creados … Mario Casas
  31. 31. Rouco Varela Algunos gallegos creados … Mario Casas Mariano Rajoy
  32. 32. Rouco Varela Mario Conde Algunos gallegos creados … Mario Casas Mariano Rajoy
  33. 33. Drupalday Santiago 2017 @estoyausente Validaciones Campos Entidad
  34. 34. MiDrupal$ vim src/Entity/MyEntity.php public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['clothing'] = BaseFieldDefinition::create('string') ->setLabel(t('From')) ->setDescription($this->t('Galician clothing.') ->setSettings(array( 'default_value' => 'Raincoat', )) ->addConstrain('Length', ['mas' => 20]) ->setRequired(true); } vim src/Entity/Galician.php Campos
  35. 35. MiDrupal$ * @ContentEntityType( * id = "galician", * constraints = { * "Galician" = {} * } * ) vim src/Entity/Galician.php Entidad
  36. 36. MiDrupal$ namespace DrupalgalicianPluginValidationConstraint; use SymfonyComponentValidatorConstraint; /** * Supports validating comment author names. * * @Constraint( * id = "Galician", * label = @Translation("Galician validation", context = "Validation"), * type = "entity:galician" * ) */ class GalicianConstraint extends Constraint { public $messageDate = ‘Date must be 12-11-2016’; public $messageClothing = ‘You aren’t a real Galician!!’; } vim src/Plugin/Validation/Contraint/GalicianConstraint.php
  37. 37. MiDrupal$ vim src/Plugin/Validation/Contraint/GalicianConstraintValidator.php namespace DrupalgalicianPluginValidationConstraint; use SymfonyComponentValidatorConstraint; use SymfonyComponentValidatorConstraintValidator; class GalicianConstraintValidator extends ConstraintValidator { public function validate($entity, Constraint $constraint) { if($entity->date != ’12-11-2016’) { $this->context->buildViolation($constraint->messageDate) ->addViolation(); } if($entity->clothing != ‘raincoat’) { $this->context->buildViolation($constraint->messageClothing) ->addViolation(); } } }
  38. 38. Drupalday Santiago 2017 @estoyausente Renderizar entidades Completas Listados
  39. 39. MiDrupal$ $fields['clothing'] = BaseFieldDefinition::create('string') ->setLabel(t('From')) ->setDescription($this->t('Galician clothing.') ->addConstrain('Length', ['mas' => 20]) ->setRequired(true); ->setDisplayConfigurable('view', TRUE) ->setDisplayOptions('view', [ 'label' => 'above', 'type' => 'string', 'weight' => 1, ]); vim src/Entity/Galician.php Completas
  40. 40. MiDrupal$ /** * @ContentEntityType( * id = "galician", * … some stuff * handlers = { * "list_builder” = “DrupalgalicianController GalicianListBuilder”, * “view_builder” = “DrupalCoreEntityEntityViewBuilder” * }, * }, * some stuff … * ) */ vim src/Entity/Galician.php Listados
  41. 41. MiDrupal$ vim src/GalicianListBuilder.php namespace DrupalgalicianEntityController; use DrupalCoreEntityEntityInterface; use DrupalCoreEntityEntityListBuilder; class GalicianListBuilder extends EntityListBuilder { public function render() { $build['description'] = array( '#markup' => $this->t('Galician list.'), ); $build['table'] = parent::render(); return $build; } public function buildHeader() { $header['id'] = $this->t('Order id'); $header['clothing'] = $this->t('Clothing'); return $header + parent::buildHeader(); } public function buildRow(EntityInterface $entity) { $row['id'] = $entity->id(); $row['clothing'] = $entity->clothing->value; return $row + parent::buildRow($entity); } } Listados
  42. 42. drush entity-updates drush cr
  43. 43. Tia na naaaaa …
  44. 44. Algunos gallegos creados …
  45. 45. Michel Salgado Algunos gallegos creados …
  46. 46. Rosalía de Castro Michel Salgado Algunos gallegos creados …
  47. 47. Rosalía de Castro Michel Salgado Camilo José Cela Algunos gallegos creados …
  48. 48. Rosalía de Castro Michel Salgado Camilo José Cela Agustín Jimenez Algunos gallegos creados …
  49. 49. Rosalía de Castro Michel Salgado Camilo José Cela Algunos gallegos creados …
  50. 50. Rosalía de Castro Michel Salgado Camilo José Cela Adolfo Dominguez Algunos gallegos creados …
  51. 51. Drupalday Santiago 2017 @estoyausente Para otro día Otros maneadores disponibles (storage, access, …) Bundles y fields Traducciones Revisiones Extensión de entidades existentes …
  52. 52. Drupalday Santiago 2017 @estoyausente Referencias Core La documentación de drupal.org Módulo Examples Drupal console (Aunque suele generar bastante más de lo que necesitamos)Utilidad
  53. 53. Drupalday Santiago 2017 @estoyausente
  54. 54. Coffee break! @estoyausenteSamuel Solís Nos vemos en IRC #drupal-es

×