14 november - 010PHP
@willemjanz
github.com/wjzijderveld
blog.willem-jan.net
Interface any PHP content management application with any content repository
Write applications once, switch storage backends when needed
<jcr:root>
<cms>
<pages>
<home title="Homepage">
<block
title="News"
content="Today: Symfony CMF presentation"/>
</home>
<contact
title="Contact"
content="symfony-cmf-devs@googlegroups.com"/>
</pages>
</cms>
</jcr:root>
Implement your publication workflow
Uses Symfony Security Component with Access Voters
<?php
class Article implements PublishableInterface, PublishTimePeriodInterface
{
/** @var \DateTime */
private $isPublishable;
public function isPublishable() {
return $this->isPublishable;
}
}
MyController.php
<?php
// check if current user is allowed to see this document
$pwc = $container->get('cmf_core.publish_workflow.checker');
if (!$pwc->isGranted(
PublishWorkflowChecker::VIEW_ATTRIBUTE,
$document
)) { // f.e. redirect to 404 }
Most of the time, this is handled by the RequestListener
Provides some basic helpers
{% for newsItem in cmf_children(page)|reverse %}
<li>
<a href="{{ path(newsItem) }}">{{ newsItem.title }}</a>
({{ newsItem.publishStartDate | date('Y-m-d') }})
</li>
{% endfor %}
When the found route is an instance of RouteObjectInterface
<?php class Route implements RouteObjectInterface {}
Set's the contentDocument in the route
<?php $route->getContent(); ?>
Sets a value in the route, based on a hashmap
<?php
use Symfony\Cmf\Component\Routing\Enhancer\FieldMapEnhancer;
$hashMap = array('foo' => '010PHP');
$enhancer = new FieldMapEnhancer('bar', 'title', $hashMap);
Imagine a Route, that has a property bar with value foo
After the enhancer is applied, the route will also have a property title with value 010PHP
Looks like FieldMap enhancer
Checks with instanceOf instead of comparing value
Used to set a controller based on Document
Simply set's a value when a field is present
Can also be used to set a default value
Is used to set the default Controller
Create and use blocks of content in your website.
Makes perfect sense as childnodes in your Content Repository
{{ sonata_block_render({
'name': 'presentationBlock'
}) }}
{% createphp page as="rdf" noautotag %}
<div {{ createphp_attributes(rdf) }}>
<h1 class="my-title" {{ createphp_attributes( rdf.title ) }}>
{{ createphp_content( rdf.title ) }}
</h1>
<div {{ createphp_attributes( rdf.body ) }}>
{{ createphp_content( rdf.body ) }}
</div>
</div>
{% endcreatephp %}
{{ knp_menu_render('main-menu') }}
Simple isn't it?
So somewhere in December