diff --git a/src/app/autoload.php b/src/app/autoload.php
index 2fc72e419e..34133fae28 100644
--- a/src/app/autoload.php
+++ b/src/app/autoload.php
@@ -1,5 +1,6 @@
addCompilerPass(new DoctrinePass(), PassConfig::TYPE_OPTIMIZE);
+
$container->addCompilerPass(new RegisterCoreListenersPass(), PassConfig::TYPE_AFTER_REMOVING);
// todo - see if we can do this only on module install/upgrade - drak
diff --git a/src/lib/Zikula/Bundle/CoreBundle/DependencyInjection/Compiler/DoctrinePass.php b/src/lib/Zikula/Bundle/CoreBundle/DependencyInjection/Compiler/DoctrinePass.php
new file mode 100644
index 0000000000..1f15147524
--- /dev/null
+++ b/src/lib/Zikula/Bundle/CoreBundle/DependencyInjection/Compiler/DoctrinePass.php
@@ -0,0 +1,15 @@
+setAlias('doctrine.entitymanager', 'doctrine.orm.default_entity_manager');
+ }
+}
diff --git a/src/lib/Zikula/Bundle/CoreBundle/EventListener/DoctrineListener.php b/src/lib/Zikula/Bundle/CoreBundle/EventListener/DoctrineListener.php
index 17601e8c79..6064611cdc 100644
--- a/src/lib/Zikula/Bundle/CoreBundle/EventListener/DoctrineListener.php
+++ b/src/lib/Zikula/Bundle/CoreBundle/EventListener/DoctrineListener.php
@@ -41,7 +41,7 @@ public function __construct(ContainerBuilder $container)
public function initDoctrine(GenericEvent $event)
{
- if ($this->container->has('doctrine.entitymanager')) {
+ if ($this->container->has('doctrine.event_manager')) {
return;
}
@@ -74,7 +74,6 @@ public function initDoctrine(GenericEvent $event)
$mysqlStorageEvent = new MySqlGenerateSchemaListener($eventManager);
}
- $this->container->setAlias('doctrine.entitymanager', 'doctrine.orm.default_entity_manager');
$this->container->setAlias('doctrine.eventmanager', 'doctrine.event_manager');
}
diff --git a/src/lib/util/ServiceUtil.php b/src/lib/util/ServiceUtil.php
index 5f20a194e9..36ddc61a6b 100644
--- a/src/lib/util/ServiceUtil.php
+++ b/src/lib/util/ServiceUtil.php
@@ -11,6 +11,7 @@
* Please see the NOTICE file distributed with this source code for further
* information regarding copyright and licensing.
*/
+use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* ServiceUtil
@@ -57,6 +58,16 @@ public static function getManager(Zikula_Core $core = null)
return self::$serviceManager;
}
+ public static function hasContainer()
+ {
+ return self::$serviceManager !== null;
+ }
+
+ public static function setContainer(ContainerInterface $container)
+ {
+ self::$serviceManager = $container;
+ }
+
/**
* Convenience shortcut to get a service.
*
@@ -138,7 +149,7 @@ public static function loadPersistentServices()
}
foreach ($handlers as $id => $handler) {
- self::$serviceManager->registerService(new Zikula_ServiceManager_Service($id, $handler['definition'], $handler['shared']));
+ self::$serviceManager->registerService($id, $handler['definition'], $handler['shared']);
}
}
}
diff --git a/src/system/ZikulaRoutesModule/Entity/RouteEntity.php b/src/system/ZikulaRoutesModule/Entity/RouteEntity.php
index d8a5158e2b..d4aec91f03 100644
--- a/src/system/ZikulaRoutesModule/Entity/RouteEntity.php
+++ b/src/system/ZikulaRoutesModule/Entity/RouteEntity.php
@@ -71,10 +71,22 @@ public function prepareItemActions()
}
}
- public function getPathWithBundlePrefix()
+ /**
+ * Returns the route's path prepended with the bundle prefix.
+ *
+ * @param null $container Can be used to set the container for \ServiceUtil in case it is not already set.
+ *
+ * @return string
+ */
+ public function getPathWithBundlePrefix($container = null)
{
if (!isset($this->options['zkNoBundlePrefix']) || !$this->options['zkNoBundlePrefix']) {
$bundle = $this->getBundle();
+
+ if (!\ServiceUtil::hasContainer()) {
+ \ServiceUtil::setContainer($container);
+ }
+
$modinfo = \ModUtil::getInfoFromName($bundle);
return "/" . $modinfo["url"] . $this->path;
diff --git a/src/system/ZikulaRoutesModule/Resources/config/custom_services.xml b/src/system/ZikulaRoutesModule/Resources/config/custom_services.xml
index a6956eb176..b47cb4ccea 100644
--- a/src/system/ZikulaRoutesModule/Resources/config/custom_services.xml
+++ b/src/system/ZikulaRoutesModule/Resources/config/custom_services.xml
@@ -4,6 +4,8 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
Zikula\RoutesModule\Routing\InstallerListener
+ Zikula\RoutesModule\Translation\ConsoleCommandListener
+ Zikula\RoutesModule\Translation\DefaultRouteExclusionStrategy
@@ -19,9 +21,14 @@
+
+
+
+
- em
+
+
diff --git a/src/system/ZikulaRoutesModule/Routing/RouteLoader.php b/src/system/ZikulaRoutesModule/Routing/RouteLoader.php
index 3d21022d47..71fe440325 100644
--- a/src/system/ZikulaRoutesModule/Routing/RouteLoader.php
+++ b/src/system/ZikulaRoutesModule/Routing/RouteLoader.php
@@ -6,6 +6,7 @@
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Loader\LoaderResolverInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use Zikula\RoutesModule\Routing\Util as RoutingUtil;
@@ -21,9 +22,12 @@ class RouteLoader implements LoaderInterface
private $em;
- public function __construct(EntityManagerInterface $em)
+ private $container;
+
+ public function __construct(EntityManagerInterface $em, ContainerInterface $container)
{
$this->em = $em;
+ $this->container = $container;
}
public function load($resource, $type = null)
@@ -34,6 +38,7 @@ public function load($resource, $type = null)
unset($type);
$routeCollection = new RouteCollection();
+
try {
$routes = $this->em->getRepository('ZikulaRoutesModule:RouteEntity')->findBy(array('workflowState' => 'approved'), array('group' => 'ASC', 'sort' => 'ASC'));
} catch (DBALException $e) {
@@ -56,7 +61,7 @@ public function load($resource, $type = null)
$defaults['_zkFunc'] = $func;
$route = new Route(
- $dbRoute->getPathWithBundlePrefix(),
+ !isset($GLOBALS['translation_extract_routes']) ? $dbRoute->getPathWithBundlePrefix($this->container) : $dbRoute->getPath(),
$defaults,
$dbRoute->getRequirements(),
$dbRoute->getOptions(),
diff --git a/src/system/ZikulaRoutesModule/Translation/ConsoleCommandListener.php b/src/system/ZikulaRoutesModule/Translation/ConsoleCommandListener.php
new file mode 100644
index 0000000000..97050a615e
--- /dev/null
+++ b/src/system/ZikulaRoutesModule/Translation/ConsoleCommandListener.php
@@ -0,0 +1,57 @@
+ array('checkBundleForTranslatingRoutes')
+ );
+ }
+
+ /**
+ * This function saves the bundle whose routes shall be translated in a global variable to be used in
+ * Zikula\RoutesModule\Translation\DefaultRouteExclusionStrategy later on.
+ *
+ * @param ConsoleCommandEvent $event
+ */
+ public function checkBundleForTranslatingRoutes(ConsoleCommandEvent $event)
+ {
+ if ($event->getCommand()->getName() !== 'translation:extract') {
+ return;
+ }
+
+ $GLOBALS['translation_extract_routes'] = true;
+
+ if ($event->getInput()->hasParameterOption('--bundle')) {
+ $bundle = $event->getInput()->getParameterOption('--bundle');
+ if ('@' === $bundle[0]) {
+ $bundle = substr($bundle, 1);
+ }
+
+ $GLOBALS['translation_extract_routes_bundle'] = $bundle;
+ }
+ }
+}
diff --git a/src/system/ZikulaRoutesModule/Translation/DefaultRouteExclusionStrategy.php b/src/system/ZikulaRoutesModule/Translation/DefaultRouteExclusionStrategy.php
new file mode 100644
index 0000000000..0481c5819f
--- /dev/null
+++ b/src/system/ZikulaRoutesModule/Translation/DefaultRouteExclusionStrategy.php
@@ -0,0 +1,36 @@
+getDefault('_zkModule') !== $GLOBALS['translation_extract_routes_bundle'];
+ }
+
+ return $exclude;
+ }
+}