Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 2f89d82

Browse files
authored
Merge pull request #260 from symfony-cmf/backport-bugfixes
Backport bugfixes
2 parents a936899 + c130376 commit 2f89d82

File tree

5 files changed

+38
-5
lines changed

5 files changed

+38
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
unreleased
5+
----------
6+
7+
* **2016-05-25** Use "auto" for publish workflow enabled flag. If auto and
8+
CmfCoreBundle is not instantiated, publish workflow integration is not enabled.
9+
410
2.0.0
511
-----
612

DependencyInjection/CmfMenuExtension.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ public function load(array $configs, ContainerBuilder $container)
4444
$this->loadExtensions($config, $loader, $container);
4545
}
4646

47-
if ($config['publish_workflow']['enabled']) {
47+
if (true === $config['publish_workflow']['enabled']
48+
|| 'auto' === $config['publish_workflow']['enabled'] && isset($bundles['CmfCoreBundle'])
49+
) {
4850
$loader->load('publish-workflow.xml');
4951
}
5052
}

DependencyInjection/Configuration.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@ public function getConfigTreeBuilder()
8181

8282
->arrayNode('publish_workflow')
8383
->addDefaultsIfNotSet()
84-
->canBeDisabled()
84+
->children()
85+
->enumNode('enabled')
86+
->values(array(true, false, 'auto'))
87+
->defaultValue('auto')
88+
->end()
89+
->end()
8590
->end()
8691
->end()
8792
;

QuietFactory.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
namespace Symfony\Cmf\Bundle\MenuBundle;
1313

14+
use Knp\Menu\Factory\ExtensionInterface;
1415
use Knp\Menu\FactoryInterface;
16+
use LogicException;
1517
use Psr\Log\LoggerInterface;
1618
use Symfony\Component\Routing\Exception\RouteNotFoundException;
1719

@@ -69,10 +71,28 @@ public function createItem($name, array $options = array())
6971
}
7072

7173
// remove route and content options
72-
unset($options['route']);
73-
unset($options['content']);
74+
unset($options['route'], $options['content']);
7475

7576
return $this->innerFactory->createItem($name, $options);
7677
}
7778
}
79+
80+
/**
81+
* Forward adding extensions to the wrapped factory.
82+
*
83+
* @param ExtensionInterface $extension
84+
* @param int $priority
85+
*
86+
* @throws \Exception if the inner factory does not implement the addExtension method.
87+
*/
88+
public function addExtension(ExtensionInterface $extension, $priority = 0)
89+
{
90+
if (!method_exists($this->innerFactory, 'addExtension')) {
91+
throw new LogicException(sprintf(
92+
'Wrapped factory "%s" does not have the method "addExtension".',
93+
get_class($this->innerFactory)
94+
));
95+
}
96+
$this->innerFactory->addExtension($extension, $priority);
97+
}
7898
}

Resources/config/schema/menu-1.0.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
</xsd:complexType>
5252

5353
<xsd:complexType name="publish-workflow">
54-
<xsd:attribute name="enabled" type="xsd:boolean" />
54+
<xsd:attribute name="enabled" type="enable_auto" />
5555
</xsd:complexType>
5656

5757
<xsd:simpleType name="enable_auto">

0 commit comments

Comments
 (0)