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

Commit eb754e9

Browse files
authored
Merge pull request #289 from symfony-cmf/cleanups
code cleanups
2 parents 9432cb2 + 3bca10c commit eb754e9

10 files changed

+24
-24
lines changed

src/CmfMenuBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function build(ContainerBuilder $container)
2626
$container->addCompilerPass(new DecorateMenuFactoryPass());
2727
$container->addCompilerPass(new ValidationPass());
2828

29-
if (class_exists('Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\DoctrinePhpcrMappingsPass')) {
29+
if (class_exists(DoctrinePhpcrMappingsPass::class)) {
3030
$container->addCompilerPass(
3131
DoctrinePhpcrMappingsPass::createXmlMappingDriver(
3232
[

src/DependencyInjection/CmfMenuExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function load(array $configs, ContainerBuilder $container)
4040
}
4141

4242
if (true === $config['publish_workflow']['enabled']
43-
|| 'auto' === $config['publish_workflow']['enabled'] && isset($bundles['CmfCoreBundle'])
43+
|| ('auto' === $config['publish_workflow']['enabled'] && isset($bundles['CmfCoreBundle']))
4444
) {
4545
$loader->load('publish-workflow.xml');
4646
}
@@ -52,7 +52,7 @@ public function loadVoters($config, XmlFileLoader $loader, ContainerBuilder $con
5252

5353
if (isset($config['voters']['content_identity'])) {
5454
if (empty($config['voters']['content_identity']['content_key'])) {
55-
if (!class_exists('Symfony\\Cmf\\Bundle\\RoutingBundle\\Routing\\DynamicRouter')) {
55+
if (!class_exists(DynamicRouter::class)) {
5656
throw new \RuntimeException('You need to set the content_key when not using the CmfRoutingBundle DynamicRouter');
5757
}
5858
$contentKey = DynamicRouter::CONTENT_KEY;

src/DependencyInjection/Configuration.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Cmf\Bundle\MenuBundle\DependencyInjection;
1313

14+
use Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\Menu;
15+
use Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode;
1416
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
1517
use Symfony\Component\Config\Definition\ConfigurationInterface;
1618

@@ -34,8 +36,8 @@ public function getConfigTreeBuilder()
3436
->scalarNode('content_basepath')->defaultValue('/cms/content')->end()
3537
->integerNode('prefetch')->defaultValue(10)->end()
3638
->scalarNode('manager_name')->defaultNull()->end()
37-
->scalarNode('menu_document_class')->defaultValue('Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\Menu')->end()
38-
->scalarNode('node_document_class')->defaultValue('Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode')->end()
39+
->scalarNode('menu_document_class')->defaultValue(Menu::class)->end()
40+
->scalarNode('node_document_class')->defaultValue(MenuNode::class)->end()
3941
->end()
4042
->end()
4143
->end()

src/Extension/ContentExtension.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,13 @@ public function buildItem(ItemInterface $item, array $options)
9191
}
9292

9393
/**
94-
* If linkType not specified, we can determine it from
95-
* existing options.
94+
* If linkType not specified, we can determine it from existing options.
95+
*
96+
* @param array $options Menu node options
97+
*
98+
* @return string The type of link to use
9699
*/
97-
protected function determineLinkType($options)
100+
private function determineLinkType(array $options)
98101
{
99102
if (!empty($options['uri'])) {
100103
return 'uri';
@@ -119,7 +122,7 @@ protected function determineLinkType($options)
119122
* @throws \InvalidArgumentException if $linkType is not one of the known
120123
* link types
121124
*/
122-
protected function validateLinkType($linkType)
125+
private function validateLinkType($linkType)
123126
{
124127
$linkTypes = ['uri', 'route', 'content'];
125128
if (!in_array($linkType, $linkTypes)) {

src/Model/MenuOptionsInterface.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function getAttributes();
6464
*
6565
* @param $attributes array
6666
*
67-
* @return Page The current Page instance
67+
* @return MenuOptionsInterface The item to provide a fluent interface
6868
*/
6969
public function setAttributes(array $attributes);
7070

@@ -84,7 +84,7 @@ public function getAttribute($name, $default = null);
8484
* @param string $name attribute name
8585
* @param string $value attribute value
8686
*
87-
* @return Page The current Page instance
87+
* @return MenuOptionsInterface The item to provide a fluent interface
8888
*/
8989
public function setAttribute($name, $value);
9090

@@ -100,7 +100,7 @@ public function getLinkAttributes();
100100
*
101101
* @param array $linkAttributes
102102
*
103-
* @return Page The current Page instance
103+
* @return MenuOptionsInterface The item to provide a fluent interface
104104
*/
105105
public function setLinkAttributes($linkAttributes);
106106

@@ -114,9 +114,9 @@ public function getChildrenAttributes();
114114
/**
115115
* Set the children attributes.
116116
*
117-
* @param array $attributes
117+
* @param array $childrenAttributes
118118
*
119-
* @return Page The current Page instance
119+
* @return MenuOptionsInterface The item to provide a fluent interface
120120
*/
121121
public function setChildrenAttributes(array $childrenAttributes);
122122

@@ -132,7 +132,7 @@ public function getLabelAttributes();
132132
*
133133
* @param array $labelAttributes
134134
*
135-
* @return Page The current Page instance
135+
* @return MenuOptionsInterface The item to provide a fluent interface
136136
*/
137137
public function setLabelAttributes($labelAttributes);
138138
}

src/PublishWorkflow/CreateMenuItemFromNodeListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
class CreateMenuItemFromNodeListener
2525
{
2626
/**
27-
* @var SecurityContextInterface
27+
* @var AuthorizationCheckerInterface
2828
*/
2929
private $publishWorkflowChecker;
3030

src/PublishWorkflow/Voter/MenuContentVoter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Cmf\Bundle\MenuBundle\PublishWorkflow\Voter;
1313

1414
use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishWorkflowChecker;
15+
use Symfony\Cmf\Bundle\MenuBundle\Model\MenuNode;
1516
use Symfony\Component\DependencyInjection\ContainerInterface;
1617
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1718
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
@@ -49,7 +50,7 @@ public function supportsAttribute($attribute)
4950
*/
5051
public function supportsClass($class)
5152
{
52-
return is_subclass_of($class, 'Symfony\Cmf\Bundle\MenuBundle\Model\MenuNode');
53+
return is_subclass_of($class, MenuNode::class);
5354
}
5455

5556
/**
@@ -62,9 +63,9 @@ public function vote(TokenInterface $token, $object, array $attributes)
6263
if (!$this->supportsClass(get_class($object))) {
6364
return self::ACCESS_ABSTAIN;
6465
}
65-
6666
/** @var PublishWorkflowChecker $publishWorkflowChecker */
6767
$publishWorkflowChecker = $this->container->get('cmf_core.publish_workflow.checker');
68+
/** @var MenuNode $object */
6869
$content = $object->getContent();
6970
$decision = self::ACCESS_GRANTED;
7071
foreach ($attributes as $attribute) {

src/Voter/RequestContentIdentityVoter.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,5 @@ public function matchItem(ItemInterface $item = null)
6767
) {
6868
return true;
6969
}
70-
71-
return;
7270
}
7371
}

src/Voter/RequestParentContentIdentityVoter.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,5 @@ public function matchItem(ItemInterface $item = null)
7878
) {
7979
return true;
8080
}
81-
82-
return;
8381
}
8482
}

src/Voter/UriPrefixVoter.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,5 @@ public function matchItem(ItemInterface $item)
5858
return true;
5959
}
6060
}
61-
62-
return;
6361
}
6462
}

0 commit comments

Comments
 (0)