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

Commit eb8346b

Browse files
authored
Merge pull request #805 from symfony-cmf/bp-seo
[seo] change doc to best practices
2 parents 1c72d5b + a13aac0 commit eb8346b

File tree

8 files changed

+155
-136
lines changed

8 files changed

+155
-136
lines changed

bundles/seo/alternate_locale.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ Enable alternate locale support:
4646
4747
.. code-block:: php
4848
49-
$container->loadFromExtension('cmf_seo', array(
49+
// app/config/config.php
50+
$container->loadFromExtension('cmf_seo', [
5051
'alternate_locale' => true,
51-
));
52+
]);
5253
5354
If you are using PHPCR-ODM, enabling ``phpcr: ~`` in the seo bundle
5455
configuration will activate a listener that extracts the alternate locales
@@ -96,11 +97,12 @@ use your custom alternate locale provider instead of the default one. Set the
9697
9798
.. code-block:: php
9899
99-
$container->loadFromExtension('cmf_seo', array(
100-
'alternate_locale' => array (
100+
// app/config/config.php
101+
$container->loadFromExtension('cmf_seo', [
102+
'alternate_locale' => [
101103
'provider_id' => 'alternate_locale.provider',
102-
),
103-
));
104+
],
105+
]);
104106
105107
.. versionadded:: 1.2
106108
When :doc:`Sitemaps <sitemap>` are enabled, alternate locales are also

bundles/seo/configuration.rst

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,15 @@ Configuration
4242
4343
.. code-block:: php
4444
45-
$container->loadFromExtension('cmf_seo', array(
46-
'persistence' => array(
47-
'phpcr' => array(
45+
// app/config/config.php
46+
$container->loadFromExtension('cmf_seo', [
47+
'persistence' => [
48+
'phpcr' => [
4849
'enabled' => false,
4950
'manager_name' => null,
50-
),
51-
),
52-
));
51+
],
52+
],
53+
]);
5354
5455
``enabled``
5556
***********
@@ -139,8 +140,8 @@ manually or disable the content listener.
139140
defaults:
140141
default_change_frequency: always
141142
templates:
142-
html: CmfSeoBundle:Sitemap:index.html.twig
143-
xml: CmfSeoBundle:Sitemap:index.xml.twig
143+
html: :sitemap/index.html.twig
144+
xml: ::sitemap:index.xml.twig
144145
configurations:
145146
sitemap: ~
146147
@@ -164,20 +165,20 @@ manually or disable the content listener.
164165
.. code-block:: php
165166
166167
// app/config/config.php
167-
$container->loadFromExtension('cmf_seo', array(
168-
'sitemap' => array(
168+
$container->loadFromExtension('cmf_seo', [
169+
'sitemap' => [
169170
'enabled' => true,
170-
'defaults' => array(
171-
'templates' => array(
171+
'defaults' => [
172+
'templates' => [
172173
'html' => 'CmfSeoBundle:Sitemap:index.html.twig',
173174
'xml' => 'CmfSeoBundle:Sitemap:index.xml.twig',
174-
),
175-
),
176-
'configurations' => array(
175+
],
176+
],
177+
'configurations' => [
177178
'sitemap' => null,
178-
),
179-
),
180-
));
179+
],
180+
],
181+
]);
181182
182183
``enabled``
183184
"""""""""""
@@ -246,7 +247,7 @@ Extension.
246247
~~~~~~~~
247248

248249
``data_class``
249-
"""""""""""""""
250+
""""""""""""""
250251

251252
``seo_metadata``
252253
****************
@@ -259,8 +260,8 @@ Extension.
259260
Configures the class to use when creating new ``SeoMetadata`` objects using the
260261
:ref:`SeoMetadata form type <bundles-seo-metadata-form-type>`.
261262

262-
When the `phpcr`_ persistence layer is enabled, this defaults to
263-
``Symfony\Cmf\Bundle\SeoBundle\Doctrine\Phpcr\SeoMetadata``.
263+
When the :doc:`PHPCR-ODM <../phpcr_odm/introduction>` persistence layer is enabled,
264+
this defaults to ``Symfony\Cmf\Bundle\SeoBundle\Doctrine\Phpcr\SeoMetadata``.
264265

265266
.. _bundles-seo-config-error:
266267

@@ -346,13 +347,13 @@ routes, use:
346347
.. code-block:: php
347348
348349
// app/config/config.php
349-
$container->loadFromExtension('cmf_seo', array(
350-
'error' => array(
351-
'exclusion_rules' => array(
352-
array('path' => '^/admin'),
353-
),
354-
),
355-
));
350+
$container->loadFromExtension('cmf_seo', [
351+
'error' => [
352+
'exclusion_rules' => [
353+
['path' => '^/admin'],
354+
],
355+
],
356+
]);
356357
357358
``alternate_locale``
358359
~~~~~~~~~~~~~~~~~~~~
@@ -382,12 +383,13 @@ routes, use:
382383
383384
.. code-block:: php
384385
385-
$container->loadFromExtension('cmf_seo', array(
386-
'alternate_locale' => array (
386+
// app/config/config.php
387+
$container->loadFromExtension('cmf_seo', [
388+
'alternate_locale' => [
387389
'enabled' => true,
388390
'provider_id' => app.alternate_locale.provider,
389-
),
390-
));
391+
],
392+
]);
391393
392394
``enabled``
393395
"""""""""""

bundles/seo/error_pages.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ controller:
4646
.. code-block:: php
4747
4848
// app/config/config.php
49-
$container->loadFromExtension('twig', array(
49+
$container->loadFromExtension('twig', [
5050
'exception_controller' => 'cmf_seo.error.suggestion_provider.controller:showAction',
51-
));
51+
]);
5252
5353
.. seealso::
5454

@@ -99,12 +99,12 @@ You can enable these in your config:
9999
.. code-block:: php
100100
101101
// app/config/config.php
102-
$container->loadFromExtension('cmf_seo', array(
103-
'error' => array(
102+
$container->loadFromExtension('cmf_seo', [
103+
'error' => [
104104
'enable_parent_provider' => true,
105105
'enable_sibling_provider' => true,
106-
),
107-
));
106+
],
107+
]);
108108
109109
.. tip::
110110

@@ -137,7 +137,7 @@ assume you always want to suggest the homepage, the provider looks like::
137137
// somehow get the Route instance of the homepage route (e.g. by quering the database)
138138
$homepageRoute = ...;
139139

140-
return array($homepageRoute);
140+
return [$homepageRoute];
141141
}
142142
}
143143

@@ -150,7 +150,7 @@ Now, register this new class as a service and tag it as
150150
151151
# app/config/services.yml
152152
services:
153-
app.suggestions.hompage:
153+
app.hompage_suggestions:
154154
class: AppBundle\Seo\HomepageSuggestionProvider
155155
tags:
156156
- { name: cmf_seo.suggestion_provider }
@@ -165,7 +165,7 @@ Now, register this new class as a service and tag it as
165165
>
166166
167167
<services>
168-
<service id="app.suggestions.homepage"
168+
<service id="app.hompage_suggestions"
169169
class="AppBundle\Seo\HomepageSuggestionProvider"
170170
>
171171
<tag name="cmf_seo.suggestion_provider"/>
@@ -177,11 +177,12 @@ Now, register this new class as a service and tag it as
177177
.. code-block:: php
178178
179179
// app/config/services.php
180+
use AppBundle\Seo\HomepageSuggestionProvider;
180181
use Symfony\Component\DependencyInjection\Definition;
181182
182-
$definition = new Definition('AppBundle\Seo\HomepageSuggestionProvider');
183+
$definition = new Definition(HomepageSuggestionProvider::class);
183184
$definition->addTag('cmf_seo.suggestion_provider');
184-
$container->setDefinition('app.suggestions.homepage', $definition);
185+
$container->setDefinition('app.hompage_suggestions', $definition);
185186
186187
The tag allows a ``group`` attribute, in order to group suggested links.
187188

bundles/seo/extractors.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ description, you can implement both interfaces and your result will be::
6969

7070
public function getSeoExtras()
7171
{
72-
return array(
73-
'property' => array(
72+
return [
73+
'property' => [
7474
'og:title' => $this->title,
7575
'og:description' => $this->description,
76-
),
77-
);
76+
],
77+
];
7878
}
7979
}
8080

@@ -89,6 +89,7 @@ create a class which implements the ``SeoExtractorInterface`` and tag it with
8989

9090
.. code-block:: yaml
9191
92+
# app/config/config.yml
9293
services:
9394
extractor.custom:
9495
class: "AppBundle\Extractor\MyCustomExtractor"
@@ -97,6 +98,7 @@ create a class which implements the ``SeoExtractorInterface`` and tag it with
9798
9899
.. code-block:: xml
99100
101+
<!-- app/config/config.xml -->
100102
<?xml version="1.0" ?>
101103
<container xmlns="http://symfony.com/schema/dic/services"
102104
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -110,6 +112,9 @@ create a class which implements the ``SeoExtractorInterface`` and tag it with
110112
111113
.. code-block:: php
112114
113-
$container->register('extractor.custom', 'AppBundle\Extractor\MyCustomExtractor')
115+
// app/config/config.php
116+
use AppBundle\Extractor\MyCustomExtractor;
117+
118+
$container->register('extractor.custom', MyCustomExtractor::class)
114119
->addTag('cmf_seo.extractor')
115120
;

0 commit comments

Comments
 (0)