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

Commit 454893b

Browse files
committed
Merge pull request #270 from symfony-cmf/core-bundle
restructured CoreBundle docs
2 parents f6a5919 + 61a535d commit 454893b

15 files changed

+981
-612
lines changed

bundles/core.rst

Lines changed: 0 additions & 596 deletions
This file was deleted.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
.. index::
2+
single: Dependency Injection Tags; CoreBundle
3+
4+
Dependency Injection Tags
5+
-------------------------
6+
7+
cmf_request_aware
8+
~~~~~~~~~~~~~~~~~
9+
10+
If you have services that need the request (e.g. for the publishing workflow
11+
or current menu item voters), you can tag them with ``cmf_request_aware`` to
12+
have a kernel listener inject the request. Any class used in such a tagged
13+
service must have the ``setRequest`` method or you will get a fatal error::
14+
15+
use Symfony\Component\HttpFoundation\Request;
16+
17+
class MyClass
18+
{
19+
private $request;
20+
21+
public function setRequest(Request $request)
22+
{
23+
$this->request = $request;
24+
}
25+
}
26+
27+
.. caution::
28+
29+
You should only use this tag on services that will be needed on every
30+
request. If you use this tag excessively you will run into performance
31+
issues. For seldom used services, you can inject the container in the
32+
service definition and call ``$this->container->get('request')`` in your
33+
code when you actually need the request.
34+
35+
For Symfony 2.3, this tag is automatically translated to a
36+
`synchronized service`_ but Symfony 2.2 does not have that feature, so you can
37+
use this tag for bundles that you want to be able to work with Symfony 2.2. In
38+
custom applications that run with Symfony 2.3, there is no need for this tag,
39+
just use the synchronized service feature.
40+
41+
cmf_published_voter
42+
~~~~~~~~~~~~~~~~~~~
43+
44+
Used to activate :ref:`custom voters <bundle-core-workflow_custom_voters>` for the
45+
:ref:`publish workflow <bundle-core-publish_workflow>`. Tagging a service with
46+
``cmf_published_voter`` integrates it into the access decision of the publish
47+
workflow.
48+
49+
This tag has the attribute ``priority``. The lower the priority number, the
50+
earlier the voter gets to vote.
51+
52+
.. _`synchronized service`: http://symfony.com/doc/current/cookbook/service_container/scopes.html#using-a-synchronized-service

bundles/core/index.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CoreBundle
2+
==========
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
7+
introduction
8+
publish_workflow
9+
dependency_injection_tags
10+
templating
11+
multilang

bundles/core/introduction.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.. index::
2+
single: Core; Bundles
3+
4+
CoreBundle
5+
==========
6+
7+
This bundle provides common functionality, helpers and utilities for the
8+
other CMF bundles.
9+
10+
One of the provided features is an interface and implementation of a publish
11+
workflow checker with an accompanying interface that models can implement if
12+
they want to support this checker.
13+
14+
Furthermore, it provides a twig helper exposing several useful functions for
15+
twig templates to interact with PHPCR-ODM documents.
16+
17+
Finally, most of its configuration settings are automatically applied as
18+
defaults for most of the other CMF Bundles.
19+
20+
Installation
21+
------------
22+
23+
You can install the bundle in 2 different ways:
24+
25+
* Use the official Git repository (https://github.com/symfony-cmf/CoreBundle);
26+
* Install it via Composer (``symfony-cmf/core-bundle`` on `Packagist`_).
27+
28+
Sections
29+
--------
30+
31+
* :doc:`publish_workflow`
32+
* :doc:`dependency_injection_tags`
33+
* :doc:`templating`
34+
* :doc:`multilang`
35+
36+
.. _`Packagist`: https://packagist.org/packages/symfony-cmf/core-bundle

bundles/core/multilang.rst

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
.. index::
2+
single: Multi-Language; CoreBundle
3+
4+
Multi-language support
5+
----------------------
6+
7+
Editing Locale Information: Translatable Sonata Admin Extension
8+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9+
10+
Several bundles provide translatable model classes that implement
11+
``TranslatableInterface``. This extension adds a locale field
12+
to the given SonataAdminBundle forms.
13+
14+
To enable the extensions in your admin classes, simply define the extension
15+
configuration in the ``sonata_admin`` section of your project configuration:
16+
17+
.. configuration-block::
18+
19+
.. code-block:: yaml
20+
21+
# app/config/config.yml
22+
sonata_admin:
23+
# ...
24+
extensions:
25+
cmf_core.admin_extension.translatable:
26+
implements:
27+
- Symfony\Cmf\Bundle\CoreBundle\Translatable\TranslatableInterface
28+
29+
.. code-block:: xml
30+
31+
<!-- app/config/config.xml -->
32+
<?xml version="1.0" charset="UTF-8" ?>
33+
<container xmlns="http://symfony.com/schema/dic/services">
34+
35+
<config xmlns="http://sonata-project.org/schema/dic/admin">
36+
<!-- ... -->
37+
<extension id="cmf_core.admin_extension.translatable">
38+
<implement>
39+
Symfony\Cmf\Bundle\CoreBundle\Translatable\TranslatableInterface
40+
</implement>
41+
</extension>
42+
</config>
43+
44+
</container>
45+
46+
.. code-block:: php
47+
48+
// app/config/config.php
49+
$container->loadFromExtension('sonata_admin', array(
50+
// ...
51+
'extensions' => array(
52+
'cmf_core.admin_extension.translatable' => array(
53+
'implements' => array(
54+
'Symfony\Cmf\Bundle\CoreBundle\Translatable\TranslatableInterface',
55+
),
56+
),
57+
),
58+
));
59+
60+
See the `Sonata Admin extension documentation`_ for more information.
61+
62+
.. _`Sonata Admin extension documentation`: http://sonata-project.org/bundles/admin/master/doc/reference/extensions.html

0 commit comments

Comments
 (0)