Esta presentación está bajo una Licencia Creative Commons Atribución 3.0 Unported.
Para ver una copia de la licencia, visite http://creativecommons.org/licenses/by/3.0/deed.es
Julio 2014
Drupal 8.x está aún en desarrollo. Todo lo incluído en esta presentación podría cambiar/eliminarse antes de la versión estable. (8.0-alpha13-344-g9b274e1) |
Introducción (1/4)
D7 | D8 | |
---|---|---|
total |
320,236 |
1’175,492 |
core |
320,236 |
807,409 (~68%) |
vendor |
- |
368,083 (~32%) |
D7 en 7.29-17-g3310afe. |
Introducción (2/4)
D7 | D8 | |
---|---|---|
total |
652 |
6,127 |
core tests |
562 (~86%) |
1,376 (~22%) |
vendor |
- |
2,465 (~40%) |
otras |
90 (~14%) |
2,286 (~37%) |
Introducción (3/4)
D7 | D8 | |
---|---|---|
total |
18 |
628 |
vendor |
0 |
269 (~43%) |
otras |
18 |
359 (~57%) |
Introducción (3/4)
-
Not-invented here™
-
PSR-4 (php-fig)
-
Symfony
-
Composer
-
ej. autocomplete via jquery ui autocomplete
-
-
Orientación a objetos
-
PHP 5.4.2 (de 5.2.4)
-
Agrupando
-
Iniciativas
-
Cambios en módulos/temas
-
Cambios generales
Iniciativas
-
Configuration Management
-
HTML5
-
Layouts
-
Mobile
-
Multilingual
-
Views in Core
-
Web Services
Iniciativas: Configuration Management (CMI)
-
Entidades de configuración
-
Como archivos
-
+Settings API
-
+States API
-
-variables API
-
uuids
Iniciativas: HTML5
-
textarea.js, CSS3-resize++
-
htmlshiv lib.
Iniciativas: Layouts
-
Bloques son instancias de plugins
Iniciativas: Mobile
-
todo tema en core es adaptable(responsive)
Iniciativas: Multilingual
-
Módulo language
-
Ver CHANGELOG.txt
Iniciativas: Views in Core
\o/
Iniciativas: Web Services
-
Autenticación modular (is not only about cookies)
-
Sistema de routing basado en symfony
Cambios en módulos
-
reubicación
-
nueva funcionalidad
-
nuevos campos
-
eliminados
Cambios en módulos: reubicación
-
action
-
ban
-
block/block_content
-
entity
-
field_sql_storage (field types)
-
history
-
language
-
menu_link/menu_link_content/menu_ui (menu)
-
number
-
options
-
text
-
xmlrpc
Cambios en módulos: nueva funcionalidad
-
+basic_auth
-
+breakpoint
-
+ckeditor
-
+config
-
+config_translation
-
+content_translation(era translation)
-
+quickedit (in-place)
-
+editor (wysiwyg)
-
+hal
-
+migrate
-
+migrate_drupal
-
+responsive_image
-
+rest
-
+serialization
-
+tour
-
transliteration
-
+views
-
+views_ui
Cambios en módulos: nuevos campos
-
+datetime
-
+email
-
+entity_reference
-
+link
-
+telephone
Cambios en módulos: eliminados
-
-blog
-
-dashboard
-
-openid
-
-overlay
-
-php
-
-poll
-
-profile
-
-trigger
Cambios en temas
-
-Garland
Generales
-
Orientación a objetos
-
Términos
-
Estructura de archivos
-
Nuevas librerías
-
Symfony components
-
APIs
Generales: Orientación a objetos
-
Namespaces
-
Clases
-
Interfaces
Generales: Términos
-
Servicios
-
Contenedor
-
Inyección de dependencias
-
Pedido/Respuesta (Request/Response)
-
Route
-
Controller
-
Plugins (y Discovery)
hooks vs event listeners |
Generales: Estructura de ficheros
ver estructura ej. syslog, telephone
PSR-4 vs PSR-0 /modules/my_module/lib/Drupal/my_module/Entity/MyEntity.php vs/modules/my_module/src/Entity/MyEntity.php |
Generales: Nuevas librerías php (1/2)
Generales: Nuevas librerías php (2/2)
-
composer
-
doctrine
-
easyrdf
-
guzzle
-
assetic
-
vfsStream
-
phpunit
-
gliph
-
symfony
-
symfony-cmf
-
twig
-
zendframework
Generales: Nuevas librerías assets
Javascript
|
|
CSS
|
|
Generales: Symfony components
-
class-loader
-
css-selector
-
debug
-
dependency-injection
hint: buscar "what is dependency injection" fabien -
event-dispatcher
-
http-foundation
-
http-kernel
-
process
-
property-access
-
routing
-
serializer
-
translation
-
validator
-
yaml
Generales: APIs, anotaciones
<?php /** * Defines the file entity class. * * @ContentEntityType( * id = "file", * label = @Translation("File"), * controllers = { * "storage" = "Drupal\file\FileStorage", * "access" = "Drupal\file\FileAccessController", * "view_builder" = "Drupal\Core\Entity\EntityViewBuilder" * }, * base_table = "file_managed", * entity_keys = { * "id" = "fid", * "label" = "filename", * "uuid" = "uuid" * } * ) */
Generales: APIs, EntityNG
-
objetos de entidades basadas en clases
-
todo en una entidad es un campo (no más propiedades)
-
EntityInterface
-
CRUD completo
-
node_{load,load_multiple,save,delete,delete_multiple}() vs
entity_{load,load_multiple,create+save,delete_multiple}()
-
-
todo es una entidad (contenido vs configuración)
-
ContentEntityInterface (ContentEntityBase)
-
nodos*, usuarios*, comentarios*, términos*, ficheros, links de menú, shortcut, feed, item, BlockContent
-
-
ConfigEntityInterface
-
i.e. vocabularios*, vistas (incomplete)
-
-
-
EntityFieldQuery vs \Drupal::entityQuery()
-
validación desacoplada de lógica de formularios
Generales: APIS, EntityNG D7 node
<?php /** * Implements hook_entity_info(). */ function user_entity_info() { $return = array( 'user' => array( 'label' => t('User'), 'controller class' => 'UserController', 'base table' => 'users', 'uri callback' => 'user_uri', 'label callback' => 'format_username', 'fieldable' => TRUE, // $user->language is only the preferred user language for the user // interface textual elements. As it is not necessarily related to the // language assigned to fields, we do not define it as the entity language // key. 'entity keys' => array( 'id' => 'uid', ), 'bundles' => array( 'user' => array( 'label' => t('User'), 'admin' => array( 'path' => 'admin/config/people/accounts', 'access arguments' => array('administer users'), ), ), ), 'view modes' => array( 'full' => array( 'label' => t('User account'), 'custom settings' => FALSE, ), ), ), ); return $return; }
Generales: APIS, EntityNG D8 node
<?php /** * Defines the user entity class. * * The base table name here is plural, despite Drupal table naming standards, * because "user" is a reserved word in many databases. * * @ContentEntityType( * id = "user", * label = @Translation("User"), * controllers = { * "storage" = "Drupal\user\UserStorage", * "access" = "Drupal\user\UserAccessController", * "list_builder" = "Drupal\user\UserListBuilder", * "view_builder" = "Drupal\Core\Entity\EntityViewBuilder", * "form" = { * "default" = "Drupal\user\ProfileForm", * "cancel" = "Drupal\user\Form\UserCancelForm", * "register" = "Drupal\user\RegisterForm" * }, * "translation" = "Drupal\user\ProfileTranslationHandler" * }, * admin_permission = "administer user", * base_table = "users", * label_callback = "user_format_name", * fieldable = TRUE, * translatable = TRUE, * entity_keys = { * "id" = "uid", * "uuid" = "uuid" * }, * links = { * "canonical" = "user.view", * "edit-form" = "user.edit", * "admin-form" = "user.account_settings", * "cancel-form" = "user.cancel" * } * ) */ class User extends ContentEntityBase implements UserInterface {
Generales: APIs, campos
-
tipos
-
base fields (antes propiedades): node title, node id, roles de usuario
-
bundle fields (configurables): ej. cuerpo de nodo, etiquetas de nodo.+ provistos por field.module
-
-
nombres
-
configuración de instancia de campo (field instace config) vs definición de campo(field definition)
-
configuración de campo (field config) vs definición del almacenamiento del campo (field storage definition)
-
-
field storage está ahora a nivel de entidades
-
definir una propia
-
dinámicos (computed fields)
-
hook_entity_base_field_info{,_alter}(); hook_entity_bundle_field_info{,_alter}(); hook_entity_field_storage_info{,_alter}();
Generales: APIs, campos, number d7
/** * Implements hook_field_schema(). */ function number_field_schema($field) { switch ($field['type']) { case 'number_integer' : $columns = array( 'value' => array( 'type' => 'int', 'not null' => FALSE ), ); break; case 'number_float' : $columns = array( 'value' => array( 'type' => 'float', 'not null' => FALSE ), ); break; case 'number_decimal' : $columns = array( 'value' => array( 'type' => 'numeric', 'precision' => $field['settings']['precision'], 'scale' => $field['settings']['scale'], 'not null' => FALSE ), ); break; } return array( 'columns' => $columns, ); } /** * Implements hook_field_info(). */ function number_field_info() { return array( 'number_integer' => array( 'label' => t('Integer'), 'description' => t('This field stores a number in the database as an integer.'), 'instance_settings' => array('min' => '', 'max' => '', 'prefix' => '', 'suffix' => ''), 'default_widget' => 'number', 'default_formatter' => 'number_integer', ), 'number_decimal' => array( 'label' => t('Decimal'), 'description' => t('This field stores a number in the database in a fixed decimal format.'), 'settings' => array('precision' => 10, 'scale' => 2, 'decimal_separator' => '.'), 'instance_settings' => array('min' => '', 'max' => '', 'prefix' => '', 'suffix' => ''), 'default_widget' => 'number', 'default_formatter' => 'number_decimal', ), 'number_float' => array( 'label' => t('Float'), 'description' => t('This field stores a number in the database in a floating point format.'), 'settings' => array('decimal_separator' => '.'), 'instance_settings' => array('min' => '', 'max' => '', 'prefix' => '', 'suffix' => ''), 'default_widget' => 'number', 'default_formatter' => 'number_decimal', ), ); }
Generales: APIs, campos, number d8
<?php /** * The integer data type. * * The plain value of an integer is a regular PHP integer. For setting the value * any PHP variable that casts to an integer may be passed. * * @DataType( * id = "integer", * label = @Translation("Integer") * ) */ class Integer extends PrimitiveBase implements IntegerInterface { /** * {@inheritdoc} */ public function getCastedValue() { return (int) $this->value; } }
<?php /** * Defines the 'integer' field type. * * @FieldType( * id = "integer", * label = @Translation("Number (integer)"), * description = @Translation("This field stores a number in the database as an integer."), * default_widget = "number", * default_formatter = "number_integer" * ) */ class IntegerItem extends NumericItemBase { /** * {@inheritdoc} */ public static function defaultSettings() { return array( 'unsigned' => FALSE, ) + parent::defaultSettings(); } /** * {@inheritdoc} */ public static function defaultInstanceSettings() { return array( 'min' => '', 'max' => '', 'prefix' => '', 'suffix' => '', // Valid size property values include: 'tiny', 'small', 'medium', 'normal' // and 'big'. 'size' => 'normal', ) + parent::defaultInstanceSettings(); } /** * {@inheritdoc} */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('integer') ->setLabel(t('Integer value')); return $properties; } /** * {@inheritdoc} */ public function getConstraints() { $constraints = parent::getConstraints(); // If this is an unsigned integer, add a validation constraint for the // integer to be positive. if ($this->getSetting('unsigned')) { $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager(); $constraints[] = $constraint_manager->create('ComplexData', array( 'value' => array( 'Range' => array( 'min' => 0, 'minMessage' => t('%name: The integer must be larger or equal to %min.', array( '%name' => $this->getFieldDefinition()->getLabel(), '%min' => 0, )), ), ), )); } return $constraints; } /** * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { return array( 'columns' => array( 'value' => array( 'type' => 'int', 'not null' => FALSE, // Expose the 'unsigned' setting in the field item schema. 'unsigned' => $field_definition->getSetting('unsigned'), // Expose the 'size' setting in the field item schema. For instance, // supply 'big' as a value to produce a 'bigint' type. 'size' => $field_definition->getSetting('size'), ), ), ); } }
Plugins
-
campos
-
bloques
-
efectos de imagen
Twig
-
Temas ahora usan motor twig
-
drupal_render() reemplaza a theme()
-
Migrate
-
Migrate vs. hook_update_N()
Assets: agregar css
<?php drupal_add_css(drupal_get_path('module', 'example') . '/css/example.css');
<?php $example = array( '#attached' => array( 'css' => array( drupal_get_path('module', 'example') . '/css/example.css' => array(), ), ), );
Assets: agregar js
<?php drupal_add_js(drupal_get_path('module', 'example') . '/example.js');
<?php $example = array( '#attached' => array( 'js' => array( drupal_get_path('module', 'example') . '/js/example.js' => array(), ), ), );
Assets: declarar js
<?php // jQuery Form Plugin. $libraries['jquery.form'] = array( 'title' => 'jQuery Form Plugin', 'website' => 'http://malsup.com/jquery/form/', 'version' => '3.39', 'js' => array( 'core/assets/vendor/jquery-form/jquery.form.js' => array(), ), 'dependencies' => array( array('system', 'jquery'), array('system', 'jquery.cookie'), ), );
jquery.form: remote: https://github.com/malsup/form version: 3.39 js: assets/vendor/jquery-form/jquery.form.js: {} dependencies: - core/jquery - core/jquery.cookie
<?php drupal_add_library('example', 'drag-and-drop');
<?php $example = array( '#attached' => array( 'library' => array( 'example/drag-and-drop', ), ), );
Otros
-
YAML(no más hook_info)
-
No más variables globales, i.e. $user
-
Funciones globales reagrupadas(ver core/lib/Drupal/Component), ej.:
-
drupal_strlen() → Unicode::strlen()
-
module_exists() → \Drupal::moduleHandler()->moduleExists()
-
-
Llamadas a hooks en Drupal\Core\Extension\ModuleHandler
-
module_implements() → \Drupal::moduleHandler()->getImplementations()
-
module_invoke() → \Drupal::moduleHandler()->invoke()
-
module_invoke_all() → \Drupal::moduleHandler()->invokeAll()
-
drupal_alter() → \Drupal::moduleHandler()->alter()
-
-
cache tags
-
ver CacheBackendInterface
-
Generales: UI
-
Edición en vivo
-
WYSIWYG: ckeditor
Referencias
From Not-Invented-Here to Proudly-Found-Elsewhere: A Drupal 8 Story, por Alex Pott, alexpott.
DrupalCon Prague 2013
https://prague2013.drupal.org/session/not-invented-here-proudly-found-elsewhere-drupal-8-story
Upgrading your modules to Drupal 8, por Alex Bronstein, effulgentsia.
DrupalCon Portland 2013
https://portland2013.drupal.org/session/upgrading-your-modules-drupal-8
Upgrading your modules to Drupal 8, por Angie Byron, webchick.
DrupalCon Sydney 2013
http://sydney2013.drupal.org/program/core-conversations
Drupal 8 Entity API, por Wolfgang Ziegler, fago.
DrupalCon Austin 2014
https://austin2014.drupal.org/session/drupal-8-entity-api
30 Drupal 8 API Functions You Should Already Know, por Fredric Mitchell, fmitchell.
DrupalCon Austin 2014
https://austin2014.drupal.org/session/30-drupal-8-api-functions-you-should-already-know
Lista de cambios en drupal core
https://drupal.org/list-changes/drupal