diff --git a/Admin/PageAdmin.php b/Admin/PageAdmin.php
index 11dd287..1c9bb20 100644
--- a/Admin/PageAdmin.php
+++ b/Admin/PageAdmin.php
@@ -9,17 +9,17 @@
* file that was distributed with this source code.
*/
-
namespace Symfony\Cmf\Bundle\SimpleCmsBundle\Admin;
-use Sonata\DoctrinePHPCRAdminBundle\Admin\Admin;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
+use Sonata\DoctrinePHPCRAdminBundle\Admin\Admin;
+use Symfony\Cmf\Bundle\RoutingBundle\Admin\RouteAdmin;
use Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page;
-use Symfony\Cmf\Bundle\SimpleCmsBundle\Model\Page as ModelPage;
+use Symfony\Component\Form\FormBuilder;
-class PageAdmin extends Admin
+class PageAdmin extends RouteAdmin
{
protected $translationDomain = 'CmfSimpleCmsBundle';
@@ -37,32 +37,41 @@ protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('path', 'text')
- ->add('title', 'text')
+ ->addIdentifier('title', 'text')
->add('label', 'text')
->add('name', 'text')
->add('createDate', 'date')
- ->add('publishStartDate', 'date')
- ->add('publishEndDate', 'date')
;
}
protected function configureFormFields(FormMapper $formMapper)
{
+ parent::configureFormFields($formMapper);
+
+ $formMapper->remove('content');
+
+ // remap to routeOptions
+ $formMapper->remove('options');
+
$formMapper
- ->with('form.group_general')
- ->add(
- 'parent',
- 'doctrine_phpcr_odm_tree',
- array('choice_list' => array(), 'select_root_node' => true, 'root_node' => $this->getRootPath())
- )
- ->add('name', 'text')
- ->add('label', null, array('required' => false))
- ->add('title')
- ->add('createDate')
- ->add('addFormatPattern', null, array('required' => false, 'help' => 'form.help_add_format_pattern'))
- ->add('addTrailingSlash', null, array('required' => false, 'help' => 'form.help_add_trailing_slash'))
- ->add('addLocalePattern', null, array('required' => false, 'help' => 'form.help_add_locale_pattern'))
- ->add('body', 'textarea')
+ ->with('form.group_general', array(
+ 'translation_domain' => 'CmfSimpleCmsBundle',
+ ))
+ ->add('label', null, array('required' => false))
+ ->add('title')
+ ->add('body', 'textarea')
+ ->add('createDate')
+ ->end()
+ ->with('form.group_advanced', array(
+ 'translation_domain' => 'CmfRoutingBundle',
+ ))
+ ->add(
+ 'routeOptions',
+ 'sonata_type_immutable_array',
+ array('keys' => $this->configureFieldsForOptions($this->getSubject()->getRouteOptions()), 'label' => 'form.label_options'),
+ array('help' => 'form.help_options')
+ )
+ ->end()
;
}
@@ -98,7 +107,7 @@ public function preUpdate($object)
*/
protected function ensureOrderByDate($page)
{
- $items = $page->getParent()->getChildren();
+ $items = $page->getParentDocument()->getChildren();
$itemsByDate = array();
/** @var $item Page */
@@ -135,7 +144,7 @@ protected function ensureOrderByDate($page)
public function toString($object)
{
- return $object instanceof ModelPage && $object->getTitle()
+ return $object instanceof Page && $object->getTitle()
? $object->getTitle()
: $this->trans('link_add', array(), 'SonataAdminBundle')
;
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d71cb53..c047699 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,20 @@
Changelog
=========
+* **2014-04-01**: Refactored the RoutingBundle to provide all routing
+ features needed by SimpleCmsBundle.
+ * If you where only using the SimpleCmsBundle you now need to activate
+ the dynamic router. SimpleCmsBundle automatically does this for you.
+ * The configuration for document to route/template now all happens under
+ cmf_routing.dynamic and the route enhancers also apply to simplecms Pages.
+ You can configure additional base paths where to look for routes in the
+ cmf_routing.persistence.phpcr.base_routepaths field.
+ * The configuration for locales is not needed anymore. Configuring it on the
+ cmf_routing is enough.
+ * The options for the format pattern, trailing slash and locale pattern are
+ now moved into the route "options" and the Page Document now takes an
+ array of options in the constructor instead of boolean flags.
+
* **2013-11-14**: The Page now supports the menu options that make sense for a
page: display, displayChildren, attributes, children|link|labelAttributes.
Note that those only affect the menu rendering, not anything else.
diff --git a/CmfSimpleCmsBundle.php b/CmfSimpleCmsBundle.php
index c64515b..0844af9 100644
--- a/CmfSimpleCmsBundle.php
+++ b/CmfSimpleCmsBundle.php
@@ -30,7 +30,6 @@ public function build(ContainerBuilder $container)
$container->addCompilerPass(
DoctrinePhpcrMappingsPass::createXmlMappingDriver(
array(
- realpath(__DIR__ . '/Resources/config/doctrine-model') => 'Symfony\Cmf\Bundle\SimpleCmsBundle\Model',
realpath(__DIR__ . '/Resources/config/doctrine-phpcr') => 'Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr',
),
array('cmf_simple_cms.persistence.phpcr.manager_name')
diff --git a/DependencyInjection/CmfSimpleCmsExtension.php b/DependencyInjection/CmfSimpleCmsExtension.php
index 5f4e7ae..7957a2d 100644
--- a/DependencyInjection/CmfSimpleCmsExtension.php
+++ b/DependencyInjection/CmfSimpleCmsExtension.php
@@ -32,9 +32,32 @@ class CmfSimpleCmsExtension extends Extension implements PrependExtensionInterfa
*/
public function prepend(ContainerBuilder $container)
{
- $prependConfig = array('persistence' => array('phpcr' => (array('enabled' => true))));
- $container->prependExtensionConfig('cmf_menu', $prependConfig);
- $prependConfig = array('dynamic' => $prependConfig);
+ // process the configuration of CmfCoreExtension
+ $configs = $container->getExtensionConfig($this->getAlias());
+ $parameterBag = $container->getParameterBag();
+ $configs = $parameterBag->resolveValue($configs);
+ $config = $this->processConfiguration(new Configuration(), $configs);
+
+ if (empty($config['persistence']['phpcr']['enabled'])) {
+ return;
+ }
+
+ $prependConfig = array(
+ 'chain' => array(
+ 'routers_by_id' => array(
+ 'router.default' => 0,
+ 'cmf_routing.dynamic_router' => -100,
+ )
+ ),
+ 'dynamic' => array(
+ 'enabled' => true,
+ )
+ );
+ if (isset($config['persistence']['phpcr']['basepath'])
+ && '/cms/simple' != $config['persistence']['phpcr']['basepath']
+ ) {
+ $prependConfig['dynamic']['persistence']['phpcr']['route_basepaths'] = array($config['persistence']['phpcr']['basepath']);
+ }
$container->prependExtensionConfig('cmf_routing', $prependConfig);
}
@@ -43,12 +66,8 @@ public function load(array $configs, ContainerBuilder $container)
$config = $this->processConfiguration(new Configuration(), $configs);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
- $this->loadRouting($config['routing'], $loader, $container);
-
if ($config['persistence']['phpcr']) {
$this->loadPhpcr($config['persistence']['phpcr'], $loader, $container);
- $locales = isset($config['multilang']['locales']) ? $config['multilang']['locales'] : false;
- $this->loadPhpcrRouting($config, $loader, $container, $locales);
if ($config['use_menu']) {
$this->loadPhpcrMenu($config, $loader, $container);
@@ -56,88 +75,11 @@ public function load(array $configs, ContainerBuilder $container)
}
}
- protected function loadRouting($config, XmlFileLoader $loader, ContainerBuilder $container)
- {
- $container->setParameter($this->getAlias() . '.uri_filter_regexp', $config['uri_filter_regexp']);
-
- $loader->load('routing.xml');
-
- $dynamic = $container->getDefinition($this->getAlias().'.dynamic_router');
-
- if (!empty($config['generic_controller'])) {
- $definition = new DefinitionDecorator('cmf_routing.enhancer.explicit_template');
- $definition->replaceArgument(2, $config['generic_controller']);
- $container->setDefinition(
- $this->getAlias() . '.enhancer.explicit_template',
- $definition
- );
- $dynamic->addMethodCall('addRouteEnhancer', array(
- new Reference($this->getAlias() . '.enhancer.explicit_template')
- ));
- }
-
- if (!empty($config['controllers_by_type'])) {
- $definition = new DefinitionDecorator('cmf_routing.enhancer.controllers_by_type');
- $definition->replaceArgument(2, $config['controllers_by_type']);
- $container->setDefinition(
- $this->getAlias() . '.enhancer.controllers_by_type',
- $definition
- );
- $dynamic->addMethodCall('addRouteEnhancer', array(
- new Reference($this->getAlias() . '.enhancer.controllers_by_type')
- ));
- }
-
- if (!empty($config['controllers_by_class'])) {
- $definition = new DefinitionDecorator('cmf_routing.enhancer.controllers_by_class');
- $definition->replaceArgument(2, $config['controllers_by_class']);
- $container->setDefinition(
- $this->getAlias() . '.enhancer.controllers_by_class',
- $definition
- );
- $dynamic->addMethodCall('addRouteEnhancer', array(
- new Reference($this->getAlias() . '.enhancer.controllers_by_class')
- ));
- }
-
- if (!empty($config['generic_controller']) && !empty($config['templates_by_class'])) {
- $controllerForTemplates = array();
- foreach ($config['templates_by_class'] as $key => $value) {
- $controllerForTemplates[$key] = $config['generic_controller'];
- }
-
- $definition = new DefinitionDecorator('cmf_routing.enhancer.controller_for_templates_by_class');
- $definition->replaceArgument(2, $controllerForTemplates);
-
- $container->setDefinition(
- $this->getAlias() . '.enhancer.controller_for_templates_by_class',
- $definition
- );
-
- $definition = new DefinitionDecorator('cmf_routing.enhancer.templates_by_class');
- $definition->replaceArgument(2, $config['templates_by_class']);
-
- $container->setDefinition(
- $this->getAlias() . '.enhancer.templates_by_class',
- $definition
- );
-
- $dynamic->addMethodCall('addRouteEnhancer', array(
- new Reference($this->getAlias() . '.enhancer.controller_for_templates_by_class')
- ));
- $dynamic->addMethodCall('addRouteEnhancer', array(
- new Reference($this->getAlias() . '.enhancer.templates_by_class')
- ));
- }
- }
-
protected function loadPhpcr($config, XmlFileLoader $loader, ContainerBuilder $container)
{
$loader->load('services-phpcr.xml');
- // migrator is only for PHPCR
$loader->load('migrator-phpcr.xml');
- // save some characters
$prefix = $this->getAlias() . '.persistence.phpcr';
$container->setParameter($prefix . '.basepath', $config['basepath']);
@@ -155,24 +97,6 @@ protected function loadPhpcr($config, XmlFileLoader $loader, ContainerBuilder $c
$container->setParameter($prefix . '.document.class', $config['document_class']);
}
- protected function loadPhpcrRouting($config, XmlFileLoader $loader, ContainerBuilder $container, $locales)
- {
- $loader->load('routing-phpcr.xml');
- $prefix = $this->getAlias() . '.persistence.phpcr';
-
- $routeProvider = $container->getDefinition($prefix.'.route_provider');
- $routeProvider->replaceArgument(0, new Reference($config['persistence']['phpcr']['manager_registry']));
- if (!empty($locales)) {
- $routeProvider->addMethodCall('setLocales', array($locales));
- }
- $container->setAlias($this->getAlias() . '.route_provider', $prefix.'.route_provider');
-
- $generator = $container->getDefinition($this->getAlias().'.generator');
- $generator->addMethodCall('setContentRepository', array(
- new Reference($config['routing']['content_repository_id'])
- ));
- }
-
protected function loadPhpcrMenu($config, XmlFileLoader $loader, ContainerBuilder $container)
{
$bundles = $container->getParameter('kernel.bundles');
diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php
index b029707..6df5d05 100644
--- a/DependencyInjection/Configuration.php
+++ b/DependencyInjection/Configuration.php
@@ -58,37 +58,17 @@ public function getConfigTreeBuilder()
->end()
->arrayNode('routing')
- ->fixXmlConfig('controller_by_type', 'controllers_by_type')
- ->fixXmlConfig('controller_by_class', 'controllers_by_class')
- ->fixXmlConfig('template_by_class', 'templates_by_class')
- ->addDefaultsIfNotSet()
- ->children()
- ->scalarNode('generic_controller')->defaultValue('cmf_content.controller:indexAction')->end()
- ->scalarNode('content_repository_id')->defaultValue('cmf_routing.content_repository')->end()
- ->scalarNode('uri_filter_regexp')->defaultValue('')->end()
- ->arrayNode('controllers_by_type')
- ->useAttributeAsKey('type')
- ->prototype('scalar')->end()
- ->end()
- ->arrayNode('controllers_by_class')
- ->useAttributeAsKey('alias')
- ->prototype('scalar')->end()
- ->end()
- ->arrayNode('templates_by_class')
- ->useAttributeAsKey('alias')
- ->prototype('scalar')->end()
- ->end()
+ ->info('removed')
+ ->beforeNormalization()
+ ->ifArray()
+ ->thenInvalid('The SimpleCmsBundle routing configuration has moved to cmf_routing.dynamic')
->end()
->end()
-
->arrayNode('multilang')
- ->fixXmlConfig('locale')
- ->children()
- ->arrayNode('locales')
- ->isRequired()
- ->requiresAtLeastOneElement()
- ->prototype('scalar')->end()
- ->end()
+ ->info('removed')
+ ->beforeNormalization()
+ ->ifArray()
+ ->thenInvalid('The SimpleCmsBundle locale configuration is not needed anymore')
->end()
->end()
->end()
diff --git a/Doctrine/Phpcr/MultilangRedirectRoute.php b/Doctrine/Phpcr/MultilangRedirectRoute.php
deleted file mode 100644
index c8a5065..0000000
--- a/Doctrine/Phpcr/MultilangRedirectRoute.php
+++ /dev/null
@@ -1,37 +0,0 @@
-getPrefix();
- $path = substr($this->getId(), strlen($prefix));
- $path = $prefix.'/{_locale}'.$path;
-
- return $this->generateStaticPrefix($path, $this->idPrefix);
- }
-}
diff --git a/Doctrine/Phpcr/MultilangRoute.php b/Doctrine/Phpcr/MultilangRoute.php
deleted file mode 100644
index e75a392..0000000
--- a/Doctrine/Phpcr/MultilangRoute.php
+++ /dev/null
@@ -1,37 +0,0 @@
-getPrefix();
- $path = substr($this->getId(), strlen($prefix));
- $path = $prefix.'/{_locale}'.$path;
-
- return $this->generateStaticPrefix($path, $this->idPrefix);
- }
-}
diff --git a/Doctrine/Phpcr/Page.php b/Doctrine/Phpcr/Page.php
index 0879f79..792391f 100644
--- a/Doctrine/Phpcr/Page.php
+++ b/Doctrine/Phpcr/Page.php
@@ -9,15 +9,658 @@
* file that was distributed with this source code.
*/
-
namespace Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr;
-use Symfony\Cmf\Bundle\SimpleCmsBundle\Model\Page as ModelPage;
+use Doctrine\Common\Collections\Collection;
+use LogicException;
+use Knp\Menu\NodeInterface;
+use Doctrine\Common\Collections\ArrayCollection;
+use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishTimePeriodInterface;
+use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishableInterface;
+use Symfony\Cmf\Bundle\CoreBundle\Translatable\TranslatableInterface;
+use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route;
+use Symfony\Cmf\Component\Routing\RouteReferrersReadInterface;
+
+use Symfony\Component\Validator\Constraints as Assert;
/**
- * {@inheritDoc}
+ * This is the standard Simple CMS Page document.
+ *
+ * It supports:
+ *
+ * - Multilang
+ * - Publish Workflow
+ *
+ * Additionally you can store "extra" string values in it for application
+ * specific purposes.
*/
-class Page extends ModelPage
+class Page extends Route implements
+ NodeInterface,
+ RouteReferrersReadInterface, // this must not be the write interface, it would make no sense
+ PublishTimePeriodInterface,
+ PublishableInterface,
+ TranslatableInterface
{
- public $node;
+ /**
+ * @var NodeInterface
+ */
+ protected $node;
+
+ /**
+ * @Assert\NotBlank
+ */
+ protected $title;
+
+ /**
+ * Menu label.
+ *
+ * @var string
+ */
+ protected $label = '';
+
+ /**
+ * HTML attributes to add to the individual menu element.
+ *
+ * e.g. array('class' => 'foobar', 'style' => 'bar: foo')
+ *
+ * @var array
+ */
+ protected $attributes = array();
+
+ /**
+ * HTML attributes to add to the children list element.
+ *
+ * e.g. array('class' => 'foobar', 'style' => 'bar: foo')
+ *
+ * @var array
+ */
+ protected $childrenAttributes = array();
+
+ /**
+ * HTML attributes to add to items link.
+ *
+ * e.g. array('class' => 'foobar', 'style' => 'bar: foo')
+ *
+ * @var array
+ */
+ protected $linkAttributes = array();
+
+ /**
+ * HTML attributes to add to the items label.
+ *
+ * e.g. array('class' => 'foobar', 'style' => 'bar: foo')
+ *
+ * @var array
+ */
+ protected $labelAttributes = array();
+
+ /**
+ * Set to false to not render a menu item for this.
+ *
+ * @var boolean
+ */
+ protected $display = true;
+
+ /**
+ * Set to false to not render the child menu items of this page.
+ *
+ * @var boolean
+ */
+ protected $displayChildren = true;
+
+ /**
+ * @var string
+ */
+ protected $body;
+
+ /**
+ * @var \DateTime
+ */
+ protected $createDate;
+
+ /**
+ * @var \DateTime
+ */
+ protected $publishStartDate;
+
+ /**
+ * @var \DateTime
+ */
+ protected $publishEndDate;
+
+ /**
+ * @var boolean
+ */
+ protected $publishable = true;
+
+ /**
+ * @var string
+ */
+ protected $locale;
+
+ /**
+ * Extra values an application can store along with a page
+ * @var array
+ */
+ protected $extras = array();
+
+ public function __construct(array $options = array())
+ {
+ parent::__construct($options);
+
+ $this->createDate = new \DateTime();
+ }
+
+ /**
+ * @deprecated use getOption('add_locale_pattern') instead
+ */
+ public function getAddLocalePattern()
+ {
+ return $this->getOption('add_locale_pattern');
+ }
+
+ /**
+ * @deprecated use setOption('add_locale_pattern', $bool) instead
+ */
+ public function setAddLocalePattern($addLocalePattern)
+ {
+ $this->setOption('add_locale_pattern', $addLocalePattern);
+ }
+
+ /**
+ * @return NodeInterface
+ */
+ public function getNode()
+ {
+ return $this->node;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getLocale()
+ {
+ return $this->locale;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function setLocale($locale)
+ {
+ $this->locale = $locale;
+ }
+
+ /**
+ * Get the "date" of this page, which is the publishStartDate if set,
+ * otherwise the createDate.
+ */
+ public function getDate()
+ {
+ return $this->publishStartDate ? $this->publishStartDate : $this->createDate;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getPublishStartDate()
+ {
+ return $this->publishStartDate;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function setPublishStartDate(\DateTime $publishStartDate = null)
+ {
+ $this->publishStartDate = $publishStartDate;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getPublishEndDate()
+ {
+ return $this->publishEndDate;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function setPublishEndDate(\DateTime $publishEndDate = null)
+ {
+ $this->publishEndDate = $publishEndDate;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function isPublishable()
+ {
+ return $this->publishable;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function setPublishable($publishable)
+ {
+ $this->publishable = $publishable;
+ }
+
+ /**
+ * Get extras - a flat key-value hashmap
+ *
+ * @return array with only string values
+ */
+ public function getExtras()
+ {
+ return $this->extras;
+ }
+
+ /**
+ * Set extras - applications can store additional information on a page
+ * without needing to extend the document class.
+ *
+ * @param array $extras a flat key-value hashmap. The values are cast to
+ * string as PHPCR stores multivalue data with only one data type for
+ * all values.
+ */
+ public function setExtras($extras)
+ {
+ foreach ($extras as $key => $value) {
+ $extras[$key] = (string) $value;
+ }
+
+ $this->extras = $extras;
+ }
+
+ /**
+ * Add a single key - value pair to extras
+ *
+ * @param string $key
+ * @param string $value - if this is not a string it is cast to one
+ */
+ public function addExtra($key, $value)
+ {
+ $this->extras[$key] = (string) $value;
+ }
+
+ /**
+ * Remove a single key - value pair from extras, if it was set.
+ *
+ * @param string $key
+ */
+ public function removeExtra($key)
+ {
+ if (array_key_exists($key, $this->extras)) {
+ unset($this->extras[$key]);
+ }
+ }
+
+ /**
+ * Return a single extras value for the provided key or the $default if
+ * the key is not defined.
+ *
+ * @param string $key
+ * @param string|null $default
+ *
+ * @return string|null The value at $key or if not existing $default
+ */
+ public function getExtra($key, $default = null)
+ {
+ return array_key_exists($key, $this->extras) ? $this->extras[$key] : $default;
+ }
+
+ /**
+ * Content method: Get the routes that point to this content
+ *
+ * {@inheritDoc}
+ */
+ public function getRoutes()
+ {
+ return array($this);
+ }
+
+ /**
+ * Menu method: Get child menu nodes.
+ *
+ * @return ArrayCollection the child nodes
+ */
+ public function getChildren()
+ {
+ return $this->children;
+ }
+
+ /**
+ * Menu method: List of child menu nodes
+ *
+ * @param object[] $children
+ */
+ public function setChildren($children)
+ {
+ $this->children = $children;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Route method: The content of this route is the object itself.
+ *
+ * {@inheritDoc}
+ */
+ public function getContent()
+ {
+ return $this;
+ }
+
+ /**
+ * Never call this, it makes no sense. The SimpleCms Page is its own
+ * content.
+ *
+ * @param $document
+ *
+ * @throws LogicException
+ */
+ public function setContent($document)
+ {
+ throw new LogicException('Do not set a content object for the SimpleCMS page. It is its own content.');
+ }
+
+ /**
+ * Menu method: set the menu label
+ *
+ * @param string $label
+ */
+ public function setLabel($label)
+ {
+ $this->label = $label;
+ }
+
+ /**
+ * Menu method: get the label for the menu
+ *
+ * @return string
+ */
+ public function getLabel()
+ {
+ return $this->label;
+ }
+
+ /**
+ * Content method: set the page title
+ *
+ * @param string $title
+ */
+ public function setTitle($title)
+ {
+ $this->title = $title;
+ }
+
+ /**
+ * Content method: get the page title
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ /**
+ * Content method: set the page body
+ *
+ * @param string $body
+ */
+ public function setBody($body)
+ {
+ $this->body = $body;
+ }
+
+ /**
+ * Content method: get the page body
+ *
+ * @return string
+ */
+ public function getBody()
+ {
+ return $this->body;
+ }
+
+ /**
+ * Get the creation date
+ *
+ * @return \DateTime
+ */
+ public function getCreateDate()
+ {
+ return $this->createDate;
+ }
+
+ /**
+ * Overwrite the creation date manually
+ *
+ * On creation of a Page, the createDate is automatically set to the
+ * current time.
+ *
+ * @param \DateTime $createDate
+ */
+ public function setCreateDate(\DateTime $createDate = null)
+ {
+ $this->createDate = $createDate;
+ }
+
+ /**
+ * Return the attributes associated with this menu node
+ *
+ * @return array
+ */
+ public function getAttributes()
+ {
+ return $this->attributes;
+ }
+
+ /**
+ * Set the attributes associated with this menu node
+ *
+ * @param $attributes array
+ *
+ * @return Page The current Page instance
+ */
+ public function setAttributes(array $attributes)
+ {
+ $this->attributes = $attributes;
+
+ return $this;
+ }
+
+ /**
+ * Return the given attribute, optionally specifying a default value
+ *
+ * @param string $name The name of the attribute to return
+ * @param string $default The value to return if the attribute doesn't exist
+ *
+ * @return string
+ */
+ public function getAttribute($name, $default = null)
+ {
+ if (isset($this->attributes[$name])) {
+ return $this->attributes[$name];
+ }
+
+ return $default;
+ }
+
+ /**
+ * Set the named attribute
+ *
+ * @param string $name attribute name
+ * @param string $value attribute value
+ *
+ * @return Page The current Page instance
+ */
+ public function setAttribute($name, $value)
+ {
+ $this->attributes[$name] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Return the children attributes
+ *
+ * @return array
+ */
+ public function getChildrenAttributes()
+ {
+ return $this->childrenAttributes;
+ }
+
+ /**
+ * Set the children attributes
+ *
+ * @param array $attributes
+ *
+ * @return Page The current Page instance
+ */
+ public function setChildrenAttributes(array $attributes)
+ {
+ $this->childrenAttributes = $attributes;
+
+ return $this;
+ }
+
+ /**
+ * Get the link HTML attributes.
+ *
+ * @return array
+ */
+ public function getLinkAttributes()
+ {
+ return $this->linkAttributes;
+ }
+
+ /**
+ * Set the link HTML attributes as associative array.
+ *
+ * @param array $linkAttributes
+ *
+ * @return Page The current Page instance
+ */
+ public function setLinkAttributes($linkAttributes)
+ {
+ $this->linkAttributes = $linkAttributes;
+
+ return $this;
+ }
+
+ /**
+ * Get the label HTML attributes.
+ *
+ * @return array
+ */
+ public function getLabelAttributes()
+ {
+ return $this->labelAttributes;
+ }
+
+ /**
+ * Set the label HTML attributes as associative array.
+ *
+ * @param array $labelAttributes
+ *
+ * @return Page The current Page instance
+ */
+ public function setLabelAttributes($labelAttributes)
+ {
+ $this->labelAttributes = $labelAttributes;
+
+ return $this;
+ }
+
+ /**
+ * Whether to display the menu item for this.
+ *
+ * @return boolean
+ */
+ public function getDisplay()
+ {
+ return $this->display;
+ }
+
+ /**
+ * Set whether to display the menu item for this.
+ *
+ * @param boolean $display
+ *
+ * @return Page The current Page instance
+ */
+ public function setDisplay($display)
+ {
+ $this->display = $display;
+
+ return $this;
+ }
+
+ /**
+ * Whether to display the child menu items of this page.
+ *
+ * @return boolean
+ */
+ public function getDisplayChildren()
+ {
+ return $this->displayChildren;
+ }
+
+ /**
+ * Set whether to display the child menu items of this page.
+ *
+ * @param boolean $displayChildren
+ *
+ * @return Page The current Page instance
+ */
+ public function setDisplayChildren($displayChildren)
+ {
+ $this->displayChildren = $displayChildren;
+
+ return $this;
+ }
+
+ /**
+ * Route method and Menu method - provides menu options merged with the
+ * route options
+ *
+ * {@inheritDoc}
+ */
+ public function getOptions()
+ {
+ return parent::getOptions() + array(
+ 'label' => $this->getLabel(),
+ 'attributes' => $this->getAttributes(),
+ 'childrenAttributes' => $this->getChildrenAttributes(),
+ 'display' => $this->display,
+ 'displayChildren' => $this->displayChildren,
+ 'routeParameters' => array(),
+ 'routeAbsolute' => false,
+ 'linkAttributes' => $this->linkAttributes,
+ 'labelAttributes' => $this->labelAttributes,
+ 'content' => $this,
+ );
+ }
+
+ public function getRouteOptions()
+ {
+ return parent::getOptions();
+ }
+
+ public function setRouteOptions(array $options)
+ {
+ parent::setOptions($options);
+ }
}
diff --git a/Doctrine/Phpcr/PageRouteProvider.php b/Doctrine/Phpcr/PageRouteProvider.php
deleted file mode 100644
index a8ea8e6..0000000
--- a/Doctrine/Phpcr/PageRouteProvider.php
+++ /dev/null
@@ -1,91 +0,0 @@
-locales = $locales;
- }
-
- protected function getCandidates($url)
- {
- $dirs = explode('/', ltrim($url, '/'));
- if (isset($dirs[0]) && in_array($dirs[0], $this->locales)) {
- $this->locale = $dirs[0];
- array_shift($dirs);
- $url = '/'.implode('/', $dirs);
-
- // the normal listener "waits" until the routing completes
- // as the locale could be defined inside the route
- $this->getObjectManager()->getLocaleChooserStrategy()->setLocale($this->locale);
- }
-
- return parent::getCandidates($url);
- }
-
- protected function configureLocale($route)
- {
- if ($this->getObjectManager()->isDocumentTranslatable($route)) {
- // add locale requirement
- if (!$route->getRequirement('_locale')) {
- $locales = $this->getObjectManager()->getLocalesFor($route, true);
- $route->setRequirement('_locale', implode('|', $locales));
- }
- }
- }
-
- public function getRouteCollectionForRequest(Request $request)
- {
- $collection = parent::getRouteCollectionForRequest($request);
- foreach ($collection as $route) {
- $this->configureLocale($route);
- }
-
- return $collection;
- }
-
- /**
- * {@inheritDoc}
- */
- public function getRouteByName($name, $parameters = array())
- {
- $route = parent::getRouteByName($name, $parameters);
- $this->configureLocale($route);
-
- return $route;
- }
-}
diff --git a/Migrator/Phpcr/Page.php b/Migrator/Phpcr/Page.php
index 27efb55..6acd45d 100644
--- a/Migrator/Phpcr/Page.php
+++ b/Migrator/Phpcr/Page.php
@@ -31,17 +31,17 @@
class Page implements MigratorInterface
{
/**
- * @var PHPCR\SessionInterface
+ * @var SessionInterface
*/
protected $session;
/*
- * @var Symfony\Component\Console\Output\OutputInterface
+ * @var OutputInterface
*/
protected $output;
/**
- * @var \Doctrine\ODM\PHPCR\DocumentManager
+ * @var DocumentManager
*/
protected $dm;
@@ -65,7 +65,7 @@ public function init(SessionInterface $session, OutputInterface $output)
protected function createPageInstance($className)
{
- return new $className(true);
+ return new $className(array('add_format_pattern' => true));
}
public function migrate($path = '/', $depth = -1)
diff --git a/Model/Page.php b/Model/Page.php
deleted file mode 100644
index e5583c0..0000000
--- a/Model/Page.php
+++ /dev/null
@@ -1,670 +0,0 @@
- 'foobar', 'style' => 'bar: foo')
- *
- * @var array
- */
- protected $attributes = array();
-
- /**
- * HTML attributes to add to the children list element.
- *
- * e.g. array('class' => 'foobar', 'style' => 'bar: foo')
- *
- * @var array
- */
- protected $childrenAttributes = array();
-
- /**
- * HTML attributes to add to items link.
- *
- * e.g. array('class' => 'foobar', 'style' => 'bar: foo')
- *
- * @var array
- */
- protected $linkAttributes = array();
-
- /**
- * HTML attributes to add to the items label.
- *
- * e.g. array('class' => 'foobar', 'style' => 'bar: foo')
- *
- * @var array
- */
- protected $labelAttributes = array();
-
- /**
- * Set to false to not render a menu item for this.
- *
- * @var boolean
- */
- protected $display = true;
-
- /**
- * Set to false to not render the child menu items of this page.
- *
- * @var boolean
- */
- protected $displayChildren = true;
-
- /**
- * @var string
- */
- protected $body;
-
- /**
- * @var \DateTime
- */
- protected $createDate;
-
- /**
- * @var \DateTime
- */
- protected $publishStartDate;
-
- /**
- * @var \DateTime
- */
- protected $publishEndDate;
-
- /**
- * @var boolean
- */
- protected $publishable = true;
-
- /**
- * @var boolean
- */
- protected $addLocalePattern;
-
- /**
- * @var string
- */
- protected $locale;
-
- /**
- * Extra values an application can store along with a page
- * @var array
- */
- protected $extras = array();
-
- /**
- * Overwrite to be able to create route without pattern
- *
- * @param Boolean $addFormatPattern whether to add ".{_format}" to the route pattern
- * also implicitly sets a default/require on "_format" to "html"
- * @param Boolean $addTrailingSlash whether to add a trailing slash to the route, defaults to not add one
- * @param Boolean $addLocalePattern whether to add "/{_locale}" to the route pattern
- */
- public function __construct($addFormatPattern = false, $addTrailingSlash = false, $addLocalePattern = false)
- {
- parent::__construct($addFormatPattern, $addTrailingSlash);
- $this->addLocalePattern = $addLocalePattern;
- $this->createDate = new \DateTime();
- }
-
- public function getAddLocalePattern()
- {
- return $this->addLocalePattern;
- }
-
- public function setAddLocalePattern($addLocalePattern)
- {
- $this->addLocalePattern = $addLocalePattern;
- }
-
- /**
- * {@inheritDoc}
- */
- public function getLocale()
- {
- return $this->locale;
- }
-
- /**
- * {@inheritDoc}
- */
- public function setLocale($locale)
- {
- $this->locale = $locale;
- }
-
- /**
- * {@inheritDoc}
- *
- * automatically prepend the _locale to the pattern
- *
- * @see PageRouteProvider::getCandidates()
- */
- public function getStaticPrefix()
- {
- if (!$this->addLocalePattern) {
- return parent::getStaticPrefix();
- }
-
- $prefix = $this->getPrefix();
- $path = substr(parent::getId(), strlen($prefix));
- $path = $prefix.'/{_locale}'.$path;
-
- return $this->generateStaticPrefix($path, $this->idPrefix);
- }
-
- /**
- * Get the "date" of this page, which is the publishStartDate if set,
- * otherwise the createDate.
- */
- public function getDate()
- {
- return $this->publishStartDate ? $this->publishStartDate : $this->createDate;
- }
-
- /**
- * {@inheritDoc}
- */
- public function getPublishStartDate()
- {
- return $this->publishStartDate;
- }
-
- /**
- * {@inheritDoc}
- */
- public function setPublishStartDate(\DateTime $publishStartDate = null)
- {
- $this->publishStartDate = $publishStartDate;
- }
-
- /**
- * {@inheritDoc}
- */
- public function getPublishEndDate()
- {
- return $this->publishEndDate;
- }
-
- /**
- * {@inheritDoc}
- */
- public function setPublishEndDate(\DateTime $publishEndDate = null)
- {
- $this->publishEndDate = $publishEndDate;
- }
-
- /**
- * {@inheritDoc}
- */
- public function isPublishable()
- {
- return $this->publishable;
- }
-
- /**
- * {@inheritDoc}
- */
- public function setPublishable($publishable)
- {
- $this->publishable = $publishable;
- }
-
- /**
- * Get extras - a flat key-value hashmap
- *
- * @return array with only string values
- */
- public function getExtras()
- {
- return $this->extras;
- }
-
- /**
- * Set extras - applications can store additional information on a page
- * without needing to extend the document class.
- *
- * @param array $extras a flat key-value hashmap. The values are cast to
- * string as PHPCR stores multivalue data with only one data type for
- * all values.
- */
- public function setExtras($extras)
- {
- foreach ($extras as $key => $value) {
- $extras[$key] = (string) $value;
- }
-
- $this->extras = $extras;
- }
-
- /**
- * Add a single key - value pair to extras
- *
- * @param string $key
- * @param string $value - if this is not a string it is cast to one
- */
- public function addExtra($key, $value)
- {
- $this->extras[$key] = (string) $value;
- }
-
- /**
- * Remove a single key - value pair from extras, if it was set.
- *
- * @param string $key
- */
- public function removeExtra($key)
- {
- if (array_key_exists($key, $this->extras)) {
- unset($this->extras[$key]);
- }
- }
-
- /**
- * Return a single extras value for the provided key or the $default if
- * the key is not defined.
- *
- * @param string $key
- * @param string|null $default
- *
- * @return string|null The value at $key or if not existing $default
- */
- public function getExtra($key, $default = null)
- {
- return array_key_exists($key, $this->extras) ? $this->extras[$key] : $default;
- }
-
- /**
- * Content method: Get the routes that point to this content
- *
- * {@inheritDoc}
- */
- public function getRoutes()
- {
- return array($this);
- }
-
- /**
- * Menu method: Get child menu nodes.
- *
- * @return ArrayCollection the child nodes
- */
- public function getChildren()
- {
- return $this->children;
- }
-
- /**
- * Menu method: List of child menu nodes
- *
- * @param object[] $children
- */
- public function setChildren($children)
- {
- $this->children = $children;
- }
-
- /**
- * {@inheritDoc}
- */
- public function getName()
- {
- return $this->name;
- }
-
- /**
- * Route method: The content of this route is the object itself.
- *
- * {@inheritDoc}
- */
- public function getContent()
- {
- return $this;
- }
-
- /**
- * Never call this, it makes no sense. The SimpleCms Page is its own
- * content.
- *
- * @param $document
- *
- * @throws LogicException
- */
- public function setContent($document)
- {
- throw new LogicException('Do not set a content for the redirect route. It is its own content.');
- }
-
- /**
- * Menu method: set the menu label
- *
- * @param string $label
- */
- public function setLabel($label)
- {
- $this->label = $label;
- }
-
- /**
- * Menu method: get the label for the menu
- *
- * @return string
- */
- public function getLabel()
- {
- return $this->label;
- }
-
- /**
- * Content method: set the page title
- *
- * @param string $title
- */
- public function setTitle($title)
- {
- $this->title = $title;
- }
-
- /**
- * Content method: get the page title
- *
- * @return string
- */
- public function getTitle()
- {
- return $this->title;
- }
-
- /**
- * Content method: set the page body
- *
- * @param string $body
- */
- public function setBody($body)
- {
- $this->body = $body;
- }
-
- /**
- * Content method: get the page body
- *
- * @return string
- */
- public function getBody()
- {
- return $this->body;
- }
-
- /**
- * Get the creation date
- *
- * @return \DateTime
- */
- public function getCreateDate()
- {
- return $this->createDate;
- }
-
- /**
- * Overwrite the creation date manually
- *
- * On creation of a Page, the createDate is automatically set to the
- * current time.
- *
- * @param \DateTime $createDate
- */
- public function setCreateDate(\DateTime $createDate = null)
- {
- $this->createDate = $createDate;
- }
-
- /**
- * Return the attributes associated with this menu node
- *
- * @return array
- */
- public function getAttributes()
- {
- return $this->attributes;
- }
-
- /**
- * Set the attributes associated with this menu node
- *
- * @param $attributes array
- *
- * @return Page The current Page instance
- */
- public function setAttributes(array $attributes)
- {
- $this->attributes = $attributes;
-
- return $this;
- }
-
- /**
- * Return the given attribute, optionally specifying a default value
- *
- * @param string $name The name of the attribute to return
- * @param string $default The value to return if the attribute doesn't exist
- *
- * @return string
- */
- public function getAttribute($name, $default = null)
- {
- if (isset($this->attributes[$name])) {
- return $this->attributes[$name];
- }
-
- return $default;
- }
-
- /**
- * Set the named attribute
- *
- * @param string $name attribute name
- * @param string $value attribute value
- *
- * @return Page The current Page instance
- */
- public function setAttribute($name, $value)
- {
- $this->attributes[$name] = $value;
-
- return $this;
- }
-
- /**
- * Return the children attributes
- *
- * @return array
- */
- public function getChildrenAttributes()
- {
- return $this->childrenAttributes;
- }
-
- /**
- * Set the children attributes
- *
- * @param array $attributes
- *
- * @return Page The current Page instance
- */
- public function setChildrenAttributes(array $attributes)
- {
- $this->childrenAttributes = $attributes;
-
- return $this;
- }
-
- /**
- * Get the link HTML attributes.
- *
- * @return array
- */
- public function getLinkAttributes()
- {
- return $this->linkAttributes;
- }
-
- /**
- * Set the link HTML attributes as associative array.
- *
- * @param array $linkAttributes
- *
- * @return Page The current Page instance
- */
- public function setLinkAttributes($linkAttributes)
- {
- $this->linkAttributes = $linkAttributes;
-
- return $this;
- }
-
- /**
- * Get the label HTML attributes.
- *
- * @return array
- */
- public function getLabelAttributes()
- {
- return $this->labelAttributes;
- }
-
- /**
- * Set the label HTML attributes as associative array.
- *
- * @param array $labelAttributes
- *
- * @return Page The current Page instance
- */
- public function setLabelAttributes($labelAttributes)
- {
- $this->labelAttributes = $labelAttributes;
-
- return $this;
- }
-
- /**
- * Whether to display the menu item for this.
- *
- * @return boolean
- */
- public function getDisplay()
- {
- return $this->display;
- }
-
- /**
- * Set whether to display the menu item for this.
- *
- * @param boolean $display
- *
- * @return Page The current Page instance
- */
- public function setDisplay($display)
- {
- $this->display = $display;
-
- return $this;
- }
-
- /**
- * Whether to display the child menu items of this page.
- *
- * @return boolean
- */
- public function getDisplayChildren()
- {
- return $this->displayChildren;
- }
-
- /**
- * Set whether to display the child menu items of this page.
- *
- * @param boolean $displayChildren
- *
- * @return Page The current Page instance
- */
- public function setDisplayChildren($displayChildren)
- {
- $this->displayChildren = $displayChildren;
-
- return $this;
- }
-
- /**
- * Route method and Menu method - provides menu options merged with the
- * route options
- *
- * {@inheritDoc}
- */
- public function getOptions()
- {
- return parent::getOptions() + array(
- 'label' => $this->getLabel(),
- 'attributes' => $this->getAttributes(),
- 'childrenAttributes' => $this->getChildrenAttributes(),
- 'display' => $this->display,
- 'displayChildren' => $this->displayChildren,
- 'routeParameters' => array(),
- 'routeAbsolute' => false,
- 'linkAttributes' => $this->linkAttributes,
- 'labelAttributes' => $this->labelAttributes,
- 'content' => $this,
- );
- }
-}
diff --git a/Resources/config/admin-phpcr.xml b/Resources/config/admin-phpcr.xml
index 2cd6a85..352c590 100644
--- a/Resources/config/admin-phpcr.xml
+++ b/Resources/config/admin-phpcr.xml
@@ -27,12 +27,15 @@
-
+
%cmf_simple_cms.persistence.phpcr.basepath%
%cmf_simple_cms.persistence.phpcr.admin.sort%
+
+
+
diff --git a/Resources/config/doctrine-model/Page.phpcr.xml b/Resources/config/doctrine-model/Page.phpcr.xml
deleted file mode 100644
index 443d990..0000000
--- a/Resources/config/doctrine-model/Page.phpcr.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Resources/config/doctrine-phpcr/MultilangRedirectRoute.phpcr.xml b/Resources/config/doctrine-phpcr/MultilangRedirectRoute.phpcr.xml
deleted file mode 100644
index 1836995..0000000
--- a/Resources/config/doctrine-phpcr/MultilangRedirectRoute.phpcr.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
diff --git a/Resources/config/doctrine-phpcr/MultilangRoute.phpcr.xml b/Resources/config/doctrine-phpcr/MultilangRoute.phpcr.xml
deleted file mode 100644
index db4d8b4..0000000
--- a/Resources/config/doctrine-phpcr/MultilangRoute.phpcr.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
diff --git a/Resources/config/doctrine-phpcr/Page.phpcr.xml b/Resources/config/doctrine-phpcr/Page.phpcr.xml
index db8f209..fb36ef9 100644
--- a/Resources/config/doctrine-phpcr/Page.phpcr.xml
+++ b/Resources/config/doctrine-phpcr/Page.phpcr.xml
@@ -7,8 +7,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Resources/config/routing-phpcr.xml b/Resources/config/routing-phpcr.xml
deleted file mode 100644
index b3dd976..0000000
--- a/Resources/config/routing-phpcr.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
- Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\PageRouteProvider
- Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\IdPrefixListener
-
-
-
-
-
-
-
-
-
-
-
- null
- %cmf_simple_cms.persistence.phpcr.manager_name%
- %cmf_simple_cms.persistence.phpcr.basepath%
-
-
-
- %cmf_simple_cms.persistence.phpcr.basepath%
-
-
-
-
-
-
diff --git a/Resources/config/routing.xml b/Resources/config/routing.xml
deleted file mode 100644
index d0db559..0000000
--- a/Resources/config/routing.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
- Symfony\Cmf\Bundle\RoutingBundle\Routing\DynamicRouter
- Symfony\Cmf\Component\Routing\NestedMatcher\NestedMatcher
- Symfony\Cmf\Bundle\RoutingBundle\Routing\ContentAwareGenerator
-
-
-
-
-
-
-
-
- %cmf_simple_cms.uri_filter_regexp%
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Resources/config/schema/simplecms-1.1.xsd b/Resources/config/schema/simplecms-1.1.xsd
new file mode 100644
index 0000000..558830b
--- /dev/null
+++ b/Resources/config/schema/simplecms-1.1.xsd
@@ -0,0 +1,56 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Resources/translations/CmfSimpleCmsBundle.de.xliff b/Resources/translations/CmfSimpleCmsBundle.de.xliff
index ca637cd..e90bba5 100644
--- a/Resources/translations/CmfSimpleCmsBundle.de.xliff
+++ b/Resources/translations/CmfSimpleCmsBundle.de.xliff
@@ -82,18 +82,6 @@
form.label_create_date
Erstellungsdatum
-
- form.label_add_format_pattern
- Formatmuster hinzufügen
-
-
- form.label_add_trailing_slash
- Abschließenden Schrägstrich hinzufügen
-
-
- form.label_add_locale_pattern
- Sprache hinzufügen
-
form.label_locale
Sprache
@@ -102,18 +90,6 @@
form.label_body
Inhalt
-
- form.help_add_format_pattern
- Format zu URL hinzufügen: /eine/url.{format}. Wenn nichts angegeben wird ist das Format html.
-
-
- form.help_add_trailing_slash
- Die URL hört in diesem Fall mit einem Schrägstrich auf, zum Beispiel /eine/url/.
-
-
- form.help_add_locale_pattern
- Die URL enthält in diesem Fall die Sprache: /{locale}/eine/url
-