- ./index.php pretends to build and return a sample renderable.
- ./fake-drupal is just a dummy Drupal skeleton to give some conceptual basis.
In fake-drupal.php, explore un-commenting the lines in:
getAlterCallbacks()
,getModuleDecoratorClasses()
, andgetThemeDecoratorClass()
to explore how extensibility via Builder and Decorator methods.
- Logical template-based markup that can be extended and overridden.
hook_theme()
, PHPTemplate (Twig),template_preprocess()
, hook suggestions, theme registry
- Abstracted, alterable structure.
- Render arrays,
hook_node_view()
,hook_page_alter()
- Render arrays,
- Sensible, accessible, API.
theme()
,drupal_render()
,render()
/hide()
/show()
- Define renderable.
$build = new RenderableBuilder('ThemeFoo', array('foo' => $foo));
- Alter renderable.
$build->set('param', $myParam); $build->setThemeClass('ThemeBar');
- Render renderable.
$renderable = $build->create(); $renderable instanceOf ThemeBar;
A. Prepare/alter vars.$renderable = new BazThemeBarDecorator($renderable);
B. Invoke theme engine & template.print (string) $renderable;
"Make it faster. Don't break caching." -- Moshe
Big thanks to Mark Sonnabaum for OO reality checks and the the Drupal 8 Twig team.