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

[seo] change doc to best practices #800

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions bundles/seo/alternate_locale.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ Enable alternate locale support:

.. code-block:: php

$container->loadFromExtension('cmf_seo', array(
$container->loadFromExtension('cmf_seo', [
'alternate_locale' => true,
));
]);

If you are using PHPCR-ODM, enabling ``phpcr: ~`` in the seo bundle
configuration will activate a listener that extracts the alternate locales
Expand Down Expand Up @@ -96,11 +96,11 @@ use your custom alternate locale provider instead of the default one. Set the

.. code-block:: php

$container->loadFromExtension('cmf_seo', array(
'alternate_locale' => array (
$container->loadFromExtension('cmf_seo', [
'alternate_locale' => [
'provider_id' => 'alternate_locale.provider',
),
));
],
]);

.. versionadded:: 1.2
When :doc:`Sitemaps <sitemap>` are enabled, alternate locales are also
Expand Down
62 changes: 32 additions & 30 deletions bundles/seo/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ Configuration

.. code-block:: php

$container->loadFromExtension('cmf_seo', array(
'persistence' => array(
'phpcr' => array(
$container->loadFromExtension('cmf_seo', [
'persistence' => [
'phpcr' => [
'enabled' => false,
'manager_name' => null,
),
),
));
],
],
]);

``enabled``
***********
Expand Down Expand Up @@ -139,8 +139,8 @@ manually or disable the content listener.
defaults:
default_change_frequency: always
templates:
html: CmfSeoBundle:Sitemap:index.html.twig
xml: CmfSeoBundle:Sitemap:index.xml.twig
html: :sitemap/index.html.twig
xml: ::sitemap:index.xml.twig
configurations:
sitemap: ~

Expand All @@ -164,20 +164,20 @@ manually or disable the content listener.
.. code-block:: php

// app/config/config.php
$container->loadFromExtension('cmf_seo', array(
'sitemap' => array(
$container->loadFromExtension('cmf_seo', [
'sitemap' => [
'enabled' => true,
'defaults' => array(
'templates' => array(
'defaults' => [
'templates' => [
'html' => 'CmfSeoBundle:Sitemap:index.html.twig',
'xml' => 'CmfSeoBundle:Sitemap:index.xml.twig',
),
),
'configurations' => array(
],
],
'configurations' => [
'sitemap' => null,
),
),
));
],
],
]);

``enabled``
"""""""""""
Expand Down Expand Up @@ -246,7 +246,7 @@ Extension.
~~~~~~~~

``data_class``
"""""""""""""""
""""""""""""""

``seo_metadata``
****************
Expand Down Expand Up @@ -346,13 +346,13 @@ routes, use:
.. code-block:: php

// app/config/config.php
$container->loadFromExtension('cmf_seo', array(
'error' => array(
'exclusion_rules' => array(
array('path' => '^/admin'),
),
),
));
$container->loadFromExtension('cmf_seo', [
'error' => [
'exclusion_rules' => [
['path' => '^/admin'],
],
],
]);

``alternate_locale``
~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -382,12 +382,12 @@ routes, use:

.. code-block:: php

$container->loadFromExtension('cmf_seo', array(
'alternate_locale' => array (
$container->loadFromExtension('cmf_seo', [
'alternate_locale' => [
'enabled' => true,
'provider_id' => app.alternate_locale.provider,
),
));
],
]);

``enabled``
"""""""""""
Expand All @@ -402,3 +402,5 @@ Whether or not the the :ref:`bundles-seo-alternate-locale` should be loaded
**type**: ``string`` **default**: ``null``

Specify the service id of a custom :doc:`AlternateLocaleProvider <../seo/alternate_locale>`.

.. _phpcr: ../phpcrodm-admin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you add this? This should be transformed into a :doc:`../phpcrodm-admin` link

27 changes: 14 additions & 13 deletions bundles/seo/error_pages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ controller:

.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<!-- app/config/config.xml -->
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
Expand All @@ -46,9 +46,9 @@ controller:
.. code-block:: php

// app/config/config.php
$container->loadFromExtension('twig', array(
$container->loadFromExtension('twig', [
'exception_controller' => 'cmf_seo.error.suggestion_provider.controller:showAction',
));
]);

.. seealso::

Expand Down Expand Up @@ -99,12 +99,12 @@ You can enable these in your config:
.. code-block:: php

// app/config/config.php
$container->loadFromExtension('cmf_seo', array(
'error' => array(
$container->loadFromExtension('cmf_seo', [
'error' => [
'enable_parent_provider' => true,
'enable_sibling_provider' => true,
),
));
],
]);

.. tip::

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

return array($homepageRoute);
return [$homepageRoute];
}
}

Expand All @@ -150,22 +150,22 @@ Now, register this new class as a service and tag it as

# app/config/services.yml
services:
app.suggestions.hompage:
app.suggestions_hompage:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

homepage_suggestions ?

class: AppBundle\Seo\HomepageSuggestionProvider
tags:
- { name: cmf_seo.suggestion_provider }

.. code-block:: xml

<!-- app/config/services.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<!-- app/config/services.xml -->
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"
>

<services>
<service id="app.suggestions.homepage"
<service id="app.suggestions_homepage"
class="AppBundle\Seo\HomepageSuggestionProvider"
>
<tag name="cmf_seo.suggestion_provider"/>
Expand All @@ -177,11 +177,12 @@ Now, register this new class as a service and tag it as
.. code-block:: php

// app/config/services.php
use AppBundle\Seo\HomepageSuggestionProvider;
use Symfony\Component\DependencyInjection\Definition;

$definition = new Definition('AppBundle\Seo\HomepageSuggestionProvider');
$definition = new Definition(HomepageSuggestionProvider::class);
$definition->addTag('cmf_seo.suggestion_provider');
$container->setDefinition('app.suggestions.homepage', $definition);
$container->setDefinition('app.suggestions_homepage', $definition);

The tag allows a ``group`` attribute, in order to group suggested links.

Expand Down
15 changes: 10 additions & 5 deletions bundles/seo/extractors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ description, you can implement both interfaces and your result will be::

public function getSeoExtras()
{
return array(
'property' => array(
return [
'property' => [
'og:title' => $this->title,
'og:description' => $this->description,
),
);
],
];
}
}

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

.. code-block:: yaml

# app/config/config.yml
services:
extractor.custom:
class: "AppBundle\Extractor\MyCustomExtractor"
Expand All @@ -98,6 +99,7 @@ create a class which implements the ``SeoExtractorInterface`` and tag it with
.. code-block:: xml

<?xml version="1.0" ?>
<!-- app/config/config.xml -->
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
Expand All @@ -110,6 +112,9 @@ create a class which implements the ``SeoExtractorInterface`` and tag it with

.. code-block:: php

$container->register('extractor.custom', 'AppBundle\Extractor\MyCustomExtractor')
// app/config/config.php
use AppBundle\Extractor\MyCustomExtractor;

$container->register('extractor.custom', MyCustomExtractor::class)
->addTag('cmf_seo.extractor')
;
Loading