Symfony2 Meets Drupal 8

by Larry Garfield

@Crell

What we do

Druplicon

Drupal is awesome!

No REALLY!

Drupal is awesome!

Drupal is awesome if you are an end user!

Powerful admin interface

Drupal is awesome if you are a sales guy!

Well known brand

Drupal sucks if you are a developer!

                                                         

Drupal sucks if you want a framework.

Drupal is CMS 1st, development framework 2nd

That is a natural result of Drupal's history


Drupal has evolved into a CMS/framework hybrid:
A "framlication"

Undesirable results of that legacy..

Kitten will fix it

Web Services and Context Core Initiative (WSCCI)

WSCCI

The original plan...

The Web Services and Context Core Initiative (WSCCI) aims to transform Drupal from a first-class CMS to a first-class REST server with a first-class CMS on top of it. To do that, we must give Drupal a unified, powerful context system that will support smarter, context- sensitive, easily cacheable block-centric layouts and non-page responses using a robust unified plugin mechanism.

Huh?

Page layout in Drupal 7

Blocks in Drupal 7

Page layout in Drupal 8 (planned)

Blocks in Drupal 8

Drupal 7 page flow

Page request flow in Drupal 7

"As long as we're fixing that we may as well bake REST support in."

Symfony + Drupal

Why Symfony?

Drupal 7

Drupal 7 block diagram

Not very well separated

Symfony2

Symfony block diagram

Very separated

Symfony2 Applications

Silex block diagram

One approach...

Drupal 8

Drupal 8 block diagram

(That's the plan, anyway)

So what are we using?

So far...

This is all a work in progress...

The kernel

Routing

I'd show a diagram here, but you've seen it already.

That's the whole point :-)

Dependency Injection

Transitional state

    function drupal_container(ContainerBuilder $reset = NULL) {
      static $container = NULL;
      if (isset($reset)) {
        $container = $reset;
      }
      elseif (!isset($container)) {
        $container = new ContainerBuilder();
      }
      return $container;
    }
    
      $langcode = drupal_container()->get('language_interface')->langcode;
    

Now we can inject the language as we move other things into the container.

Eventually remove the wrapper function and inject all the things!

EventDispatcher

EventDispatcher

Hooks

Hooks

Benefits

Limitations

Hooks

    function mymodule_node_access($node, $op, $account) {
      if ($op == 'edit'
          && $node->uid == $account->uid
          && $node->created > (REQUEST_TIME - 3600)) {
        return NODE_ACCESS_ALLOW;
      }
      return NODE_ACCESS_IGNORE;
    }
    

        $return = module_invoke_all('node_access', $node, 'update', $account);
      

Hooks in Drupal 8

Prediction (warning, I know better than to gamble):

Twig

Twig Logo

Templating in Drupal 7

Templating in Drupal 7

Benefits

Drawbacks

DrupalCon Denver - March 2012

We must get rid of these Arrays of Doom.

--Karoly Negyesi

Twig in Drupal 8

Maybe!

Benefits

Drawbacks

We could use a hand!

Also under consideration...

Google image search for "Symfony Newbie"

Boston WSCCI Sprint Symfony noob

We need help

We need help

Contact people

Larry Garfield Larry "Crell" Garfield Kernel, Routing, Web services
Kris Vanderwater Kris "EclipseGc" Vanderwater ESI-based page layout
Rob Loach Rob Loach Dependency Injection
Jen Lampton Jen Lampton Twig
Greg Dunlap Greg "heyrocker" Dunlap YAML, Configuration

Where to find us

Collaboration

We're in UR pull requests, improvin' ur Framework

We're coming upstream

File Streaming

Odds and ends

Excited yet?

I hope so, because we are...

Group hug!
DrupalCon Munich

Questions?

http://groups.drupal.org/wscci

Be nice to me on Joind.in!
https://joind.in/talk/view/6600
Stalk me on Twitter!
@Crell