2. Claudiu Cristea
Webikon.com
Drupal Romania Association
Member of Drupal Association
www www.claudiucristea.ro
@claudiu_cristea
www.facebook.com/claudiu.cristea
28. New directory structure
Drupal 7
modules node
themes bartik
modules contrib_module
sites all themes custom_theme
29. New directory structure
Drupal 8
modules contrib_module
So... the exact
opposite of what
you’re used to. ;)
themes custom_theme
The drop is always
moving!
core modules node
themes bartik
39. What problems are
we trying to solve?
• Inconsistency; some Logo
Site Title
PageTitle
Primary Links
Secondary Links
stuff on page is blocks,
others special theme Block Block
variables, and then Block Block
“content” area.
Block
•
Content Area
Only one layout. Block
region
Block
region
• Layout built “inside
out”; blocks lack
context of overall page
Block region
• Blocks can’t be re-used Block region
in multiple instances
40. What’s the plan for
Drupal 8? HTTP Display
Request Pass to Kernel Select
Req. controller
•
s
me n t
Layout built “outside Argu
in”; necessary context
provided to blocks Menu
block
Content block
• Everything on page is a Field
Advert
block
block (or a layout, or a
block
nested layout) Field
block View Field block
block Who's
online
•
block
Blocks rendered View
block
Custom block Custom
independently,
block
Advert
supporting ESI caching block
Custom Custom text block
block
46. What problems are
we trying to solve?
Drupal 7 released Surpasses Drupal 6
January 2011 February 2012
13 months!
...
July 2011
People start using it
61. New Class Autoloader
modules example example.test modules example example.info
<?php name = Example
description = An example.
/**
* @file core = 7.x
* Tests for example.module. files[] = example.test
*/
/**
* Test the example_bar() function.
*/
class ExampleFooTest extends DrupalWebTestCase {
“Drupalism”
public static function getInfo() {
...
}
}
/**
* Test the example_bar() function.
*/
class ExampleBarTest extends DrupalWebTestCase {
public static function getInfo() {
}
...
Drupal 7
62. New Class Autoloader
(PSR-0)
modules example lib Drupal example Tests ExampleFooTest.php
<?php
/** ExampleBarTest.php
* @file
* Definition of DrupalexampleTestsExampleFooTest.
*/
namespace DrupalexampleTests;
use DrupalCoreDatabaseDatabase;
/** “Proudly found elsewhere”
* Test the example_foo() function.
*/
class ExampleFooTest extends DrupalWebTestCase {
public static function getInfo() {
...
}
}
Drupal 8
69. REST module
$ curl -i -H "Accept: application/ld+json" --cookie SESSxxx http://example.com/entity/node/1
HTTP/1.0 200 OK
<snip>
Content-Type: application/ld+json
{"nid":"1","vid":"1","isDefaultRevision":"1","uuid":"bc37d058-8c45-484c-8e00-
eae8da8f4d67","type":"article","langcode":"en","title":"Hello","uid":"1","status":"1","crea
ted":"1353018305","changed":"1353018458","comment":"2","promote":"1","sticky":"0","tnid":"0
","translate":"0","revision_timestamp":"1353018305","revision_uid":"1","u0000*
u0000entityType":"node","u0000*u0000enforceIsNew":null,"u0000*
u0000newRevision":false,"log":"","body":{"en":[{"value":"This is in English. I live in
Vancouver, BC.","summary":"","format":"filtered_html","safe_value":"<p>This is in English.
I live in Vancouver, BC.</p>n","safe_summary":""}],"fr":[{"value":"Cette est en fran
u00e7ais. J'habite u00e1 Montru00e9al,
PQ.","summary":"","format":"filtered_html","safe_value":"<p>Cette est en franu00e7ais.
J'habite u00e1 Montru00e9al, PQ.</p>n","safe_summary":""}]},"field_tags":{"en":
[{"tid":"2"},{"tid":"1"}],"fr":[{"tid":"3"},{"tid":"4"}]},"field_image":{"und":
[{"fid":"2","alt":"","title":"","width":"500","height":"400"}]},"rdf_mapping":
{"field_image":{"predicates":["og:image","rdfs:seeAlso"],"type":"rel"},"field_tags":
{"predicates":["dc:subject"],"type":"rel"},"rdftype":["sioc:Item","foaf:Document"],"title":
{"predicates":["dc:title"]},"created":{"predicates":
["dc:date","dc:created"],"datatype":"xsd:dateTime","callback":"date_iso8601"},"changed":
The REST module provides a framework for exposing
{"predicates":["dc:modified"],"datatype":"xsd:dateTime","callback":"date_iso8601"},"body":
Drupal's data structures as RESTful web services.
{"predicates":["content:encoded"]},"uid":{"predicates":
70. Configuration
Management
node ID 4
node ID 4
It’s like Features module in core, only better.
71. What problems are
we trying to solve?
Dev Live
admin/config/foo node/4 admin/config/foo node/4
TEST Welcome
Setting 1 text test test test test Setting 1 old text This is real
test test test test content on the
Setting 2 label test test test test Setting 2 label live site that end
test test users are viewing
Save Save
Database Database
72. What problems are
we trying to solve?
Dev Live
admin/config/foo node/4 admin/config/foo node/4
TEST Welcome
Setting 1 text test test test test Setting 1 old text This is real
test test test test content on the
Setting 2 label test test test test Setting 2 label live site that end
test test users are viewing
Save Save
Database Database
Danger!
Want to bring over configuration
changes from dev, but not
overwrite live content!
73. What problems are
we trying to solve?
variable_set()/variable_get()
db_select()/db_update()/
db_delete()
hook_update_N()
$conf[...];
drush fu
ctools_export_object()/
ctools_export_load_object()
74. What’s the plan for
Drupal 8?
Dev Live
node/4
node/4 node/4
node/4
admin/config/foo admin/config/foo
TEST
ALERT! Welcome
ALERT!
Setting 1 text test test test test
Important Setting 1 old text This is real
Important
test test test test
announcement content on the
announcement
Setting 2 label test test test test Setting 2 label live site that end
about something. about something.
test test users are viewing
Save Save
Cache
Active store Cache
Active store
(e.g. (e.g.
Database) Database)
StagingFile Active File StagingFile Active File
File Store
storage Store File Store
storage Store
http://heyrocker.com/how-use-drupal-8-configuration-system
75. What’s the plan for
Drupal 8?
Dev Live
node/4
node/4 node/4
node/4
admin/config/foo $node->uuid = '0a8f293...'; admin/config/foo $node->uuid = '98a7bd...';
TEST
ALERT! Welcome
ALERT!
Setting 1 text test test test test
Important Setting 1 old text This is real
Important
test test test test
announcement content on the
announcement
Setting 2 label test test test test Setting 2 label live site that end
about something. about something.
test test users are viewing
Save Save
1 Cache
Active store Cache
Active store
(e.g. (e.g.
Database) Database)
2 5
3
File
Staging File
Active Active File StagingFile Active File
File Store
Store
storage Store File Store
storage Store
4
http://heyrocker.com/how-use-drupal-8-configuration-system
77. Configuration API
Want to deploy it? Use config().
$config = config(‘contact.settings’);
$config->set(‘user_default_enabled’, 1);
$config->save();
files/config_XXX/active/contact.settings.yml
default_category: feedback
flood:
limit: '5'
interval: '3600'
user_default_enabled: '1'
78. State API
Only useful for this environment? Use state().
state()->set('update.last_check', $now);
...
$last_check = state()->get('update.last_check') ?: 0;
MySQL [8x]> SELECT * FROM key_value WHERE collection = 'state' AND
name = 'update.last_check';
+------------+-------------------+---------------+
| collection | name | value |
+------------+-------------------+---------------+
| state | update.last_check | i:1353017727; |
+------------+-------------------+---------------+
1 row in set (0.00 sec)
79. Other stuff
• Getting OOPy with it!
• Entity API++
• More fasterer testbot!
• File/Media API improvements
• ...and more!