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

Commit

Permalink
Merge pull request #289 from symfony-cmf/cleanups
Browse files Browse the repository at this point in the history
code cleanups
  • Loading branch information
dbu authored Feb 21, 2017
2 parents 9432cb2 + 3bca10c commit eb754e9
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/CmfMenuBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function build(ContainerBuilder $container)
$container->addCompilerPass(new DecorateMenuFactoryPass());
$container->addCompilerPass(new ValidationPass());

if (class_exists('Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\DoctrinePhpcrMappingsPass')) {
if (class_exists(DoctrinePhpcrMappingsPass::class)) {
$container->addCompilerPass(
DoctrinePhpcrMappingsPass::createXmlMappingDriver(
[
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/CmfMenuExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function load(array $configs, ContainerBuilder $container)
}

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

if (isset($config['voters']['content_identity'])) {
if (empty($config['voters']['content_identity']['content_key'])) {
if (!class_exists('Symfony\\Cmf\\Bundle\\RoutingBundle\\Routing\\DynamicRouter')) {
if (!class_exists(DynamicRouter::class)) {
throw new \RuntimeException('You need to set the content_key when not using the CmfRoutingBundle DynamicRouter');
}
$contentKey = DynamicRouter::CONTENT_KEY;
Expand Down
6 changes: 4 additions & 2 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Cmf\Bundle\MenuBundle\DependencyInjection;

use Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\Menu;
use Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

Expand All @@ -34,8 +36,8 @@ public function getConfigTreeBuilder()
->scalarNode('content_basepath')->defaultValue('/cms/content')->end()
->integerNode('prefetch')->defaultValue(10)->end()
->scalarNode('manager_name')->defaultNull()->end()
->scalarNode('menu_document_class')->defaultValue('Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\Menu')->end()
->scalarNode('node_document_class')->defaultValue('Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode')->end()
->scalarNode('menu_document_class')->defaultValue(Menu::class)->end()
->scalarNode('node_document_class')->defaultValue(MenuNode::class)->end()
->end()
->end()
->end()
Expand Down
11 changes: 7 additions & 4 deletions src/Extension/ContentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,13 @@ public function buildItem(ItemInterface $item, array $options)
}

/**
* If linkType not specified, we can determine it from
* existing options.
* If linkType not specified, we can determine it from existing options.
*
* @param array $options Menu node options
*
* @return string The type of link to use
*/
protected function determineLinkType($options)
private function determineLinkType(array $options)
{
if (!empty($options['uri'])) {
return 'uri';
Expand All @@ -119,7 +122,7 @@ protected function determineLinkType($options)
* @throws \InvalidArgumentException if $linkType is not one of the known
* link types
*/
protected function validateLinkType($linkType)
private function validateLinkType($linkType)
{
$linkTypes = ['uri', 'route', 'content'];
if (!in_array($linkType, $linkTypes)) {
Expand Down
12 changes: 6 additions & 6 deletions src/Model/MenuOptionsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getAttributes();
*
* @param $attributes array
*
* @return Page The current Page instance
* @return MenuOptionsInterface The item to provide a fluent interface
*/
public function setAttributes(array $attributes);

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

Expand All @@ -100,7 +100,7 @@ public function getLinkAttributes();
*
* @param array $linkAttributes
*
* @return Page The current Page instance
* @return MenuOptionsInterface The item to provide a fluent interface
*/
public function setLinkAttributes($linkAttributes);

Expand All @@ -114,9 +114,9 @@ public function getChildrenAttributes();
/**
* Set the children attributes.
*
* @param array $attributes
* @param array $childrenAttributes
*
* @return Page The current Page instance
* @return MenuOptionsInterface The item to provide a fluent interface
*/
public function setChildrenAttributes(array $childrenAttributes);

Expand All @@ -132,7 +132,7 @@ public function getLabelAttributes();
*
* @param array $labelAttributes
*
* @return Page The current Page instance
* @return MenuOptionsInterface The item to provide a fluent interface
*/
public function setLabelAttributes($labelAttributes);
}
2 changes: 1 addition & 1 deletion src/PublishWorkflow/CreateMenuItemFromNodeListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class CreateMenuItemFromNodeListener
{
/**
* @var SecurityContextInterface
* @var AuthorizationCheckerInterface
*/
private $publishWorkflowChecker;

Expand Down
5 changes: 3 additions & 2 deletions src/PublishWorkflow/Voter/MenuContentVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Cmf\Bundle\MenuBundle\PublishWorkflow\Voter;

use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishWorkflowChecker;
use Symfony\Cmf\Bundle\MenuBundle\Model\MenuNode;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
Expand Down Expand Up @@ -49,7 +50,7 @@ public function supportsAttribute($attribute)
*/
public function supportsClass($class)
{
return is_subclass_of($class, 'Symfony\Cmf\Bundle\MenuBundle\Model\MenuNode');
return is_subclass_of($class, MenuNode::class);
}

/**
Expand All @@ -62,9 +63,9 @@ public function vote(TokenInterface $token, $object, array $attributes)
if (!$this->supportsClass(get_class($object))) {
return self::ACCESS_ABSTAIN;
}

/** @var PublishWorkflowChecker $publishWorkflowChecker */
$publishWorkflowChecker = $this->container->get('cmf_core.publish_workflow.checker');
/** @var MenuNode $object */
$content = $object->getContent();
$decision = self::ACCESS_GRANTED;
foreach ($attributes as $attribute) {
Expand Down
2 changes: 0 additions & 2 deletions src/Voter/RequestContentIdentityVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,5 @@ public function matchItem(ItemInterface $item = null)
) {
return true;
}

return;
}
}
2 changes: 0 additions & 2 deletions src/Voter/RequestParentContentIdentityVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,5 @@ public function matchItem(ItemInterface $item = null)
) {
return true;
}

return;
}
}
2 changes: 0 additions & 2 deletions src/Voter/UriPrefixVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,5 @@ public function matchItem(ItemInterface $item)
return true;
}
}

return;
}
}

0 comments on commit eb754e9

Please sign in to comment.