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 #805

Merged
merged 1 commit into from
Feb 4, 2017
Merged
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
14 changes: 8 additions & 6 deletions bundles/seo/alternate_locale.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ Enable alternate locale support:

.. code-block:: php

$container->loadFromExtension('cmf_seo', array(
// app/config/config.php
$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 +97,12 @@ use your custom alternate locale provider instead of the default one. Set the

.. code-block:: php

$container->loadFromExtension('cmf_seo', array(
'alternate_locale' => array (
// app/config/config.php
$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
66 changes: 34 additions & 32 deletions bundles/seo/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ Configuration

.. code-block:: php

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

``enabled``
***********
Expand Down Expand Up @@ -139,8 +140,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 +165,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 +247,7 @@ Extension.
~~~~~~~~

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

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

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

.. _bundles-seo-config-error:

Expand Down Expand Up @@ -346,13 +347,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 +383,13 @@ routes, use:

.. code-block:: php

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

``enabled``
"""""""""""
Expand Down
23 changes: 12 additions & 11 deletions bundles/seo/error_pages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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,7 +150,7 @@ Now, register this new class as a service and tag it as

# app/config/services.yml
services:
app.suggestions.hompage:
app.hompage_suggestions:
class: AppBundle\Seo\HomepageSuggestionProvider
tags:
- { name: cmf_seo.suggestion_provider }
Expand All @@ -165,7 +165,7 @@ Now, register this new class as a service and tag it as
>

<services>
<service id="app.suggestions.homepage"
<service id="app.hompage_suggestions"
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.hompage_suggestions', $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 @@ -97,6 +98,7 @@ create a class which implements the ``SeoExtractorInterface`` and tag it with

.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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