diff --git a/bundles/menu/configuration.rst b/bundles/menu/configuration.rst index f191f52f..72fbf1bc 100644 --- a/bundles/menu/configuration.rst +++ b/bundles/menu/configuration.rst @@ -64,9 +64,9 @@ persistence configuration has the following configuration: .. code-block:: php // app/config/config.php - $container->loadFromExtension('cmf_menu', array( - 'persistence' => array( - 'phpcr' => array( + $container->loadFromExtension('cmf_menu', [ + 'persistence' => [ + 'phpcr' => [ 'enabled' => false, 'menu_basepath' => '/cms/menu', 'content_basepath' => null, @@ -78,9 +78,9 @@ persistence configuration has the following configuration: 'menu_admin_class' => null, 'node_admin_class' => null, 'admin_recursive_breadcrumbs' => true, - ), - ), - )); + ], + ], + ]); ``enabled`` """"""""""" @@ -244,15 +244,14 @@ You can configure the menu options extension in this sections. .. code-block:: php // app/config/config.php - $container->loadFromExtension('cmf_menu', array( - 'admin_extensions' => array( - 'menu_options' => array( - 'enabled' => 'auto', - 'advanced' => false, - ), - ), - ), - )); + $container->loadFromExtension('cmf_menu', [ + 'admin_extensions' => [ + 'menu_options' => [ + 'enabled' => 'auto', + 'advanced' => false, + ], + ], + ]); ``enabled`` """"""""""" @@ -303,16 +302,16 @@ The ``voters`` section enables you to enable and configure *pre-defined* .. code-block:: php // app/config/config.php - $container->loadFromExtension('cmf_menu', array( - 'persistence' => array( - 'voters' => array( - 'content_identity' => array( + $container->loadFromExtension('cmf_menu', [ + 'persistence' => [ + 'voters' => [ + 'content_identity' => [ 'content_key' => null, - ), + ], 'uri_prefix' => false, - ), - ), - )); + ], + ], + ]); ``content_identity`` ~~~~~~~~~~~~~~~~~~~~ @@ -382,8 +381,8 @@ To disable the menu content voter, use: .. code-block:: php // app/config/config.php - $container->loadFromExtension('cmf_core', array( - 'publish_workflow' => array( + $container->loadFromExtension('cmf_core', [ + 'publish_workflow' => [ 'enabled' => false, - ), - )); + ], + ]); diff --git a/bundles/menu/introduction.rst b/bundles/menu/introduction.rst index 33d635a8..691b550d 100644 --- a/bundles/menu/introduction.rst +++ b/bundles/menu/introduction.rst @@ -36,11 +36,11 @@ bundles in addition to the CmfMenuBundle:: { public function registerBundles() { - $bundles = array( + $bundles = [ // ... new Knp\Bundle\MenuBundle\KnpMenuBundle(), new Symfony\Cmf\Bundle\MenuBundle\CmfMenuBundle(), - ); + ]; // ... } diff --git a/bundles/menu/menu_documents.rst b/bundles/menu/menu_documents.rst index 2c17fafb..8ae067f2 100644 --- a/bundles/menu/menu_documents.rst +++ b/bundles/menu/menu_documents.rst @@ -31,26 +31,26 @@ the KnpMenu component documentation for more information. // Attributes are the HTML attributes of the DOM element representing the // menu node (e.g.
  • ) $node->setAttribute('attr_name', 'attr_value'); - $node->setAttributes(array('attr_name', 'attr_value')); - $node->setChildrenAttributes(array('attr_name', 'attr_value')); + $node->setAttributes(['attr_name', 'attr_value']); + $node->setChildrenAttributes(['attr_name', 'attr_value']); // Display the node or not $node->setDisplay(true); $node->setDisplayChildren(true); // Any extra attributes you wish to associate with the menu node - $node->setExtras(array('extra_param_1' => 'value')); + $node->setExtras(['extra_param_1' => 'value']); // The label and the HTML attributes of the label $node->setLabel('Menu Node'); - $node->setLabelAttributes(array('style' => 'color: red;')); + $node->setLabelAttributes(['style' => 'color: red;']); // The HTML attributes of the link (i.e. - $node->setLinkAttributes(array('style' => 'color: yellow;')); + $node->setLinkAttributes(['style' => 'color: yellow;']); // Specify a route name to use and the parameters to use with it $node->setRoute('my_hard_coded_route_name'); - $node->setRouteParameters(array()); + $node->setRouteParameters([]); // Specify if the route should be rendered absolute (otherwise relative) $node->setRouteAbsolute(true); diff --git a/bundles/menu/menu_factory.rst b/bundles/menu/menu_factory.rst index 019fa45e..64e31e78 100644 --- a/bundles/menu/menu_factory.rst +++ b/bundles/menu/menu_factory.rst @@ -183,7 +183,7 @@ The service needs to be tagged as event listener: - @@ -199,15 +199,16 @@ The service needs to be tagged as event listener: .. code-block:: php // app/config/services.php + use AppBundle\EventListener\CreateMenuItemFromMenuListener; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; - $definition = new Definition('AppBundle\EventListener\CreateMenuItemFromMenuListener', array( + $definition = new Definition(CreateMenuItemFromMenuListener::class, [ new Reference('knp_menu.menu_provider'), - )); - $definition->addTag('kernel.event_listener', array( + ]); + $definition->addTag('kernel.event_listener', [ 'event' => 'cmf_menu.create_menu_item_from_node', 'method' => 'onCreateMenuItemFromNode', - )); + ]); - $container->setDefinition('acme_demo.listener.menu_referrer_listener', $definition); + $container->setDefinition('app.listener.menu_referrer_listener', $definition); diff --git a/bundles/menu/sonata_admin.rst b/bundles/menu/sonata_admin.rst index 25a08cd9..fe43a646 100644 --- a/bundles/menu/sonata_admin.rst +++ b/bundles/menu/sonata_admin.rst @@ -54,17 +54,17 @@ select the menu node target. .. code-block:: php // app/config/config.php - $container->loadFromExtension('cmf_menu', array( - 'persistence' => array( - 'phpcr' => array( + $container->loadFromExtension('cmf_menu', [ + 'persistence' => [ + 'phpcr' => [ // use true/false to force using / not using sonata admin 'use_sonata_admin' => 'auto', // used with Sonata Admin to manage content; defaults to %cmf_core.basepath%/content 'content_basepath' => null, - ), - ), - )); + ], + ], + ]); MenuNodeReferrersInterface Sonata Admin Extension @@ -107,15 +107,17 @@ configuration in the ``sonata_admin`` section of your project configuration: .. code-block:: php // app/config/config.php - $container->loadFromExtension('sonata_admin', array( - 'extensions' => array( - 'cmf_menu.admin_extension.menu_node_referrers' => array( - 'implements' => array( - 'Symfony\Cmf\Bundle\MenuBundle\Model\MenuNodeReferrersInterface', - ), - ), - ), - )); + use Symfony\Cmf\Bundle\MenuBundle\Model\MenuNodeReferrersInterface; + + $container->loadFromExtension('sonata_admin', [ + 'extensions' => [ + 'cmf_menu.admin_extension.menu_node_referrers' => [ + 'implements' => [ + MenuNodeReferrersInterface::class, + ], + ], + ], + ]); See the `Sonata Admin extension documentation`_ for more information. @@ -159,15 +161,17 @@ configuration in the ``sonata_admin`` section of your project configuration: .. code-block:: php // app/config/config.php - $container->loadFromExtension('sonata_admin', array( - 'extensions' => array( - 'cmf_menu.admin_extension.menu_options' => array( - 'implements' => array( - 'Symfony\Cmf\Bundle\MenuBundle\Model\MenuOptionsInterface', - ), - ), - ), - )); + use Symfony\Cmf\Bundle\MenuBundle\Model\MenuOptionsInterface; + + $container->loadFromExtension('sonata_admin', [ + 'extensions' => [ + 'cmf_menu.admin_extension.menu_options' => [ + 'implements' => [ + MenuOptionsInterface::class, + ], + ], + ], + ]); See the `Sonata Admin extension documentation`_ for more information. @@ -231,13 +235,13 @@ configuration: .. code-block:: php // app/config/config.php - $container->loadFromExtension('cmf_menu', array( - 'admin_extensions' => array( - 'menu_options' => array( + $container->loadFromExtension('cmf_menu', [ + 'admin_extensions' => [ + 'menu_options' => [ 'advanced' => true, - ), - ), - )); + ], + ], + ]); .. _`Sonata Admin extension documentation`: https://sonata-project.org/bundles/admin/master/doc/reference/extensions.html .. _SonataDoctrinePHPCRAdminBundle: https://sonata-project.org/bundles/doctrine-phpcr-admin/master/doc/index.html diff --git a/bundles/menu/voters.rst b/bundles/menu/voters.rst index b059e359..07347768 100644 --- a/bundles/menu/voters.rst +++ b/bundles/menu/voters.rst @@ -50,6 +50,7 @@ setting to your configuration. Example config: .. code-block:: yaml + # app/config/config.yml cmf_menu: voters: content_identity: @@ -58,6 +59,7 @@ setting to your configuration. Example config: .. code-block:: xml + @@ -69,14 +71,15 @@ setting to your configuration. Example config: .. code-block:: php - $container->loadFromExtension('cmf_menu', array( - 'voters' => array( - 'content_identity' => array( + // app/config/config.php + $container->loadFromExtension('cmf_menu', [ + 'voters' => [ + 'content_identity' => [ 'enabled' => true, 'content_key' => 'myKey', - ), - ), - )); + ], + ], + ]); .. note:: @@ -107,7 +110,7 @@ article which can be reached at ``/articles/computers/laptops/acme/A200``:: use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route; use Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuItem; - use Acme\FooBundle\Document\Article; + use AppBundle\Document\Article; $dm = ...; // get an instance of the document manager @@ -162,11 +165,11 @@ configuration. .. code-block:: php // app/config/config.php - $container->loadFromExtension('cmf_menu', array( - 'voters' => array( + $container->loadFromExtension('cmf_menu', [ + 'voters' => [ 'uri_prefix' => true, - ), - )); + ], + ]); RequestParentContentIdentityVoter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -206,11 +209,11 @@ voters (see below), except you do not need to write your own PHP code: # app/config/services.yml services: - my_bundle.menu_voter.parent: + app.menu_voter_parent: class: Symfony\Cmf\Bundle\MenuBundle\Voter\RequestParentContentIdentityVoter arguments: - contentDocument - - '%my_bundle.my_model_class%' + - AppBundle\Document\Article tags: - { name: "knp_menu.voter", request: true } @@ -223,10 +226,10 @@ voters (see below), except you do not need to write your own PHP code: xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - contentDocument - %my_bundle.my_model_class% + AppBundle\Document\Article @@ -236,22 +239,24 @@ voters (see below), except you do not need to write your own PHP code: .. code-block:: php // app/config/services.php + use AppBundle\Document\Article; + use Symfony\Cmf\Bundle\MenuBundle\Voter\RequestParentContentIdentityVoter; use Symfony\Component\DependencyInjection\Definition; $definition = new Definition( - 'Symfony\Cmf\Bundle\MenuBundle\Voter\RequestParentContentIdentityVoter', - array('contentDocument', '%my_bundle.my_model_class%') + RequestParentContentIdentityVoter, + ['contentDocument', Article::class] )); - $definition->addMethodCall('setRequest', array( + $definition->addMethodCall('setRequest', [ new Reference( 'request', ContainerInterface::NULL_ON_INVALID_REFERENCE, false ) - )); - $definition->addTag('knp_menu.voter', array('request' => true)); + ]); + $definition->addTag('knp_menu.voter', ['request' => true]); - $container->setDefinition('my_bundle.menu_voter.parent', $definition); + $container->setDefinition('app.menu_voter_parent', $definition); .. _bundles_menu_voters_custom_voter: