Skip to content

adjust to phpcr-odm mapping bc break, use phpcr-odm compiler pass #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 27, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions CmfRoutingBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

namespace Symfony\Cmf\Bundle\RoutingBundle;

use Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\DoctrinePhpcrMappingsPass;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Cmf\Bundle\RoutingBundle\DependencyInjection\Compiler\ChainRouterPass;
use Symfony\Cmf\Bundle\RoutingBundle\DependencyInjection\Compiler\RouteEnhancerPass;
use Symfony\Cmf\Bundle\RoutingBundle\DependencyInjection\Compiler\SetRouterPass;
use Symfony\Cmf\Bundle\RoutingBundle\DependencyInjection\Compiler\RoutePass;

/**
* Bundle class
Expand All @@ -23,6 +24,27 @@ public function build(ContainerBuilder $container)
$container->addCompilerPass(new ChainRouterPass());
$container->addCompilerPass(new RouteEnhancerPass());
$container->addCompilerPass(new SetRouterPass());
$container->addCompilerPass(new RoutePass());
$container->addCompilerPass($this->buildBasePhpcrCompilerPass());
}

/**
* Build the compiler pass for the symfony core routing component. The
* factory method uses the SymfonyFileLocator which will look at the
* namespace and thus not work here.
*
* @return DoctrinePhpcrMappingsPass
*/
private function buildBasePhpcrCompilerPass()
{
$arguments = array(array(realpath(__DIR__ . '/Resources/config/doctrine')), '.phpcr.xml');
$locator = new Definition('Doctrine\Common\Persistence\Mapping\Driver\DefaultFileLocator', $arguments);
$driver = new Definition('Doctrine\ODM\PHPCR\Mapping\Driver\XmlDriver', array($locator));

return new DoctrinePhpcrMappingsPass(
$driver,
array('Symfony\Component\Routing'),
array('cmf_routing.manager_name'),
false // TODO: once we have config for orm or phpcr-odm, configure the enabled parameter
);
}
}
5 changes: 0 additions & 5 deletions DependencyInjection/CmfRoutingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ private function setupDynamicRouter(array $config, ContainerBuilder $container,
$contentRepository->replaceArgument(0, new Reference($config['manager_registry']));
$container->setParameter($this->getAlias() . '.manager_name', $config['manager_name']);

// @todo - remove these lines when Compiler/RoutePass no longer depends on the manager_registry factory.
$managerRegistry = $container->getDefinition($this->getAlias() . '.manager_registry');
$managerRegistry->setFactoryService(new Reference($config['manager_registry']));
$managerRegistry->replaceArgument(0, $config['manager_name']);

$dynamic = $container->getDefinition($this->getAlias().'.dynamic_router');

// if any mappings are defined, set the respective route enhancer
Expand Down
41 changes: 0 additions & 41 deletions DependencyInjection/Compiler/RoutePass.php

This file was deleted.

8 changes: 0 additions & 8 deletions Resources/config/cmf_routing.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@
<call method="setContentRepository"><argument type="service" id="cmf_routing.content_repository"/></call>
</service>

<!-- @todo - remove this when Compiler/RoutePass no longer depends on the manager_registry factory.-->
<service id="cmf_routing.manager_registry"
factory-service=""
factory-method="getManager"
class="Symfony\Bridge\Doctrine\ManagerRegistry">
<argument />
</service>

<service id="cmf_routing.default_route_provider" class="%cmf_routing.route_provider_class%">
<argument/>
<argument>%cmf_routing.route_entity_class%</argument>
Expand Down
18 changes: 11 additions & 7 deletions Resources/config/doctrine/RedirectRoute.phpcr.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/phpcr/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<doctrine-mapping
xmlns="http://doctrine-project.org/schemas/phpcr-odm/phpcr-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/phpcr-odm/phpcr-mapping
https://github.com/doctrine/phpcr-odm/raw/master/doctrine-phpcr-odm-mapping.xsd"
>

<document name="Symfony\Cmf\Bundle\RoutingBundle\Document\RedirectRoute">

<field fieldName="uri" type="uri"/>
<field fieldName="routeName" type="string"/>
<reference-one fieldName="routeTarget"/>
<field fieldName="permanent" type="boolean"/>
<field fieldName="parameters" type="string" assoc=""/>
<field name="uri" type="uri"/>
<field name="routeName" type="string"/>
<field name="permanent" type="boolean"/>
<field name="parameters" type="string" assoc=""/>
<reference-one name="routeTarget"/>

</document>

Expand Down
25 changes: 15 additions & 10 deletions Resources/config/doctrine/Route.phpcr.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/phpcr/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping
xmlns="http://doctrine-project.org/schemas/phpcr-odm/phpcr-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/phpcr-odm/phpcr-mapping
https://github.com/doctrine/phpcr-odm/raw/master/doctrine-phpcr-odm-mapping.xsd"
>

<document name="Symfony\Cmf\Bundle\RoutingBundle\Document\Route" referenceable="true">
<parentdocument name="parent"/>
<nodename name="name"/>
<id name="id">
<generator strategy="parent"/>
<generator strategy="PARENT"/>
</id>
<reference-one fieldName="routeContent"/>
<children fieldName="children"/>
<field fieldName="variablePattern" type="string"/>
<field fieldName="addFormatPattern" type="boolean"/>
<field fieldName="addTrailingSlash" type="boolean"/>
<field name="variablePattern" type="string"/>
<field name="addFormatPattern" type="boolean"/>
<field name="addTrailingSlash" type="boolean"/>
<nodename name="name"/>
<parent-document name="parent"/>
<children name="children"/>
<reference-one name="routeContent"/>
</document>

</doctrine-mapping>
11 changes: 0 additions & 11 deletions Resources/config/doctrine/Symfony.Component.Routing.Route.dcm.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping
xmlns="http://doctrine-project.org/schemas/phpcr-odm/phpcr-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/phpcr-odm/phpcr-mapping
https://github.com/doctrine/phpcr-odm/raw/master/doctrine-phpcr-odm-mapping.xsd"
>

<mapped-superclass name="Symfony\Component\Routing\Route">
<field name="host" type="string"/>
<field name="defaults" type="string" assoc=""/>
<field name="requirements" type="string" assoc=""/>
<field name="options" type="string" assoc=""/>
</mapped-superclass>

</doctrine-mapping>