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

Commit d82a76d

Browse files
authored
sonata admin integration (#790)
started on documenting the sonata admin integration bundle
1 parent 9c4c615 commit d82a76d

File tree

11 files changed

+213
-134
lines changed

11 files changed

+213
-134
lines changed

bundles/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Bundles
1616
search/index
1717
seo/index
1818
simple_cms/index
19+
sonata_phpcr_admin_integration/index
1920
tree_browser/index
2021

2122
.. include:: map.rst.inc

bundles/map.rst.inc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ library or they introduce a complete new concept.
8181
* :doc:`tree_browser/introduction`
8282
* :doc:`tree_browser/configuration`
8383

84+
Admin Integrations
85+
~~~~~~~~~~~~~~~~~~
86+
87+
Since version 2 of the CMF, we provide a separate bundle with admin implementations for the
88+
SonataDoctrinePHPCRAdminBundle_.
89+
90+
* :doc:`sonata_phpcr_admin_integration/index`
91+
8492
Showcase Bundles
8593
~~~~~~~~~~~~~~~~
8694

@@ -120,6 +128,4 @@ help with integrating PHPCR concepts into the Symfony Framework.
120128
* :doc:`phpcr_odm/multiple_sessions`
121129
* :doc:`phpcr_odm/configuration`
122130

123-
* SonataDoctrinePHPCRAdminBundle_
124-
125131
.. _SonataDoctrinePHPCRAdminBundle: https://sonata-project.org/bundles/doctrine-phpcr-admin/master/doc/index.html
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
ContentBundle
2+
=============
3+
4+
This integration becomes available once the :doc:`CmfContentBundle
5+
<../content/introduction>` is installed.
6+
7+
Content bundle support consists in an admin interface for the ``StaticContent``
8+
document. Enable this admin using:
9+
10+
.. configuration-block::
11+
12+
.. code-block:: yaml
13+
14+
# app/config/config.yml
15+
cmf_sonata_phpcr_admin_integration:
16+
bundles:
17+
content: ~
18+
19+
.. code-block:: xml
20+
21+
<!-- app/config/config.xml -->
22+
<?xml version="2.0" encoding="UTF-8" ?>
23+
<container xmlns="http://symfony.com/schema/dic/services"
24+
xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance"
25+
xsd:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
26+
http://cmf.symfony.com/schema/dic/sonata_admin_integration http://cmf.symfony.com/schema/dic/sonata_admin_integration/sonata_admin_integration.xsd"
27+
>
28+
29+
<config xmlns="http://cmf.symfony.com/schema/dic/sonata_admin_integration">
30+
<bundles>
31+
<content/>
32+
</bundles>
33+
</config>
34+
</container>
35+
36+
.. code-block:: php
37+
38+
// app/config/config.php
39+
$container->loadFromExtension('cmf_sonata_phpcr_admin_integration', [
40+
'bundles' => [
41+
'content' => true,
42+
],
43+
]);
44+
45+
.. tip::
46+
47+
Install the IvoryCKEditorBundle_ to enable a CKEditor to edit the content
48+
body:
49+
50+
.. code-block:: bash
51+
52+
$ composer require egeloen/ckeditor-bundle
53+
54+
.. _IvoryCKEditorBundle: https://github.com/egeloen/IvoryCKEditorBundle
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CoreBundle
2+
==========
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
SonataPhpcrAdminIntegrationBundle
2+
=================================
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
7+
introduction
8+
core
9+
content
10+
menu
11+
routing
12+
routing_auto
13+
seo
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
.. index::
2+
single: Sonata; Bundles
3+
single: SonataPhpcrAdminIntegrationBundle
4+
5+
SonataPhpcrAdminIntegrationBundle
6+
=================================
7+
8+
The SonataPhpcrAdminIntegrationBundle provides admin services for the Sonata
9+
Admin tool. Additionally, it provides admin extensions to improve your
10+
custom admin services.
11+
12+
Installation
13+
------------
14+
15+
You can install this bundle `with composer`_ using the
16+
``symfony-cmf/sonata-phpcr-admin-integration-bundle`` package on Packagist_.
17+
18+
As this bundle integrates the SonataDoctrinePhpcrAdminBundle_, please follow
19+
`its official installation guide`_ to install the bundle.
20+
21+
After this, enable both the CmfSonataPhpcrAdminIntegrationBundle as well as the
22+
SonataDoctrinePhpcrAdminBundle related bundles::
23+
24+
// app/appKernel.php
25+
26+
// ...
27+
public function registerBundles()
28+
{
29+
$bundles = array(
30+
// ...
31+
32+
// SonataAdminBundle related
33+
new Sonata\CoreBundle\SonataCoreBundle(),
34+
new Sonata\BlockBundle\SonataBlockBundle(),
35+
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
36+
new Sonata\AdminBundle\SonataAdminBundle(),
37+
38+
// SonataDoctrinePhpcrAdminBundle related
39+
new Symfony\Cmf\Bundle\TreeBrowserBundle\CmfTreeBrowserBundle(),
40+
new Sonata\DoctrinePHPCRAdminBundle\SonataDoctrinePHPCRAdminBundle(),
41+
42+
// CmfSonataPhpcrAdminIntegrationBundle
43+
new Symfony\Cmf\Bundle\SonataPhpcrAdminIntegrationBundle\CmfSonataPhpcrAdminIntegrationBundle(),
44+
);
45+
46+
// ...
47+
48+
return $bundles;
49+
}
50+
51+
Usage
52+
-----
53+
54+
The integration bundle provides admins for the CMF bundles. The related
55+
configuration section of a bundle becomes available whenever a CMF bundle is
56+
registered in the ``AppKernel``. For instance, to enable the admin integration
57+
for the :doc:`CmfContentBundle <../content/introduction>`, use the following
58+
config:
59+
60+
.. configuration-block::
61+
62+
.. code-block:: yaml
63+
64+
# app/config/config.yml
65+
cmf_sonata_phpcr_admin_integration:
66+
bundles:
67+
content: ~
68+
69+
.. code-block:: xml
70+
71+
<!-- app/config/config.xml -->
72+
<?xml version="2.0" encoding="UTF-8" ?>
73+
<container xmlns="http://symfony.com/schema/dic/services"
74+
xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance"
75+
xsd:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
76+
http://cmf.symfony.com/schema/dic/sonata_admin_integration http://cmf.symfony.com/schema/dic/sonata_admin_integration/sonata_admin_integration.xsd"
77+
>
78+
79+
<config xmlns="http://cmf.symfony.com/schema/dic/sonata_admin_integration">
80+
<bundles>
81+
<content/>
82+
</bundles>
83+
</config>
84+
</container>
85+
86+
.. code-block:: php
87+
88+
// app/config/config.php
89+
$container->loadFromExtension('cmf_sonata_phpcr_admin_integration', [
90+
'bundles' => [
91+
'content' => true,
92+
],
93+
]);
94+
95+
Configuration
96+
-------------
97+
98+
The configuration is split into a section for each supported CMF bundle.
99+
Each part is only available if the corresponding bundle is installed and
100+
registered with the kernel.
101+
102+
.. toctree::
103+
104+
core
105+
content
106+
menu
107+
routing
108+
routing_auto
109+
seo
110+
111+
Learn More
112+
----------
113+
114+
* SonataAdminBundle_
115+
* SonataDoctrinePhpcrAdminBundle_
116+
* :doc:`The Sonata Admin chapter of the tutorial <../../tutorial/sonata-admin>`
117+
118+
.. _`with composer`: https://getcomposer.org
119+
.. _`Packagist`: https://packagist.org/packages/symfony-cmf/sonata-admin-integration-bundle
120+
.. _SonataDoctrinePhpcrAdminBundle: https://sonata-project.org/bundles/doctrine-phpcr-admin/1-x/doc/index.html
121+
.. _its official installation guide: https://sonata-project.org/bundles/doctrine-phpcr-admin/1-x/doc/reference/installation.html
122+
.. _SonataAdminBundle: https://sonata-project.org/bundles/admin/3-x/doc/index.html
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
MenuBundle
2+
==========
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
RoutingBundle
2+
=============
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
RoutingAutoBundle
2+
=================
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SeoBundle
2+
=========

tutorial/sonata-admin.rst

Lines changed: 5 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -4,139 +4,11 @@ The Backend - Sonata Admin
44
In this chapter you will build an administration interface with the help
55
of the SonataDoctrinePHPCRAdminBundle_.
66

7-
Installation
8-
------------
7+
First, follow the `Sonata installation guide`_, and then the
8+
:doc:`instructions to set up the SonataPhpcrAdminIntegrationBundle <../bundles/sonata_phpcr_admin_integration/introduction>`.
99

10-
Ensure that you installed the ``sonata-project/doctrine-phpcr-admin-bundle``
11-
package as detailed in the :ref:`gettingstarted_installadditionbundles`
12-
section.
13-
14-
Enable the Sonata related bundles to your kernel::
15-
16-
// app/AppKernel.php
17-
class AppKernel extends Kernel
18-
{
19-
public function registerBundles()
20-
{
21-
$bundles = array(
22-
// ...
23-
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
24-
new Sonata\CoreBundle\SonataCoreBundle(),
25-
new Sonata\jQueryBundle\SonatajQueryBundle(),
26-
new Sonata\BlockBundle\SonataBlockBundle(),
27-
new Sonata\AdminBundle\SonataAdminBundle(),
28-
new Sonata\DoctrinePHPCRAdminBundle\SonataDoctrinePHPCRAdminBundle(),
29-
);
30-
31-
// ...
32-
}
33-
}
34-
35-
Sonata requires the ``sonata_block`` bundle to be configured in your main
36-
configuration:
37-
38-
.. configuration-block::
39-
40-
.. code-block:: yaml
41-
42-
# app/config/config.yml
43-
44-
# ...
45-
sonata_block:
46-
default_contexts: [cms]
47-
blocks:
48-
# Enable the SonataAdminBundle block
49-
sonata.admin.block.admin_list:
50-
contexts: [admin]
51-
52-
.. code-block:: xml
53-
54-
<!-- app/config/config.xml -->
55-
<?xml version="1.0" encoding="UTF-8" ?>
56-
<container xmlns="htp://symfony.com/schema/dic/services">
57-
<config xmlns="http://sonata-project.org/schema/dic/block">
58-
<default-context>cms</default-context>
59-
60-
<block id="sonata.admin.block.admin_list">
61-
<context>admin</context>
62-
</block>
63-
</config>
64-
</container>
65-
66-
.. code-block:: php
67-
68-
// app/config/config.php
69-
$container->loadFromExtension('sonata_block', array(
70-
'default_contexts' => array('cms'),
71-
'blocks' => array(
72-
'sonata.admin.block.admin_list' => array(
73-
'contexts' => array('admin'),
74-
),
75-
),
76-
));
77-
78-
and it requires the following entries in your routing file:
79-
80-
.. configuration-block::
81-
82-
.. code-block:: yaml
83-
84-
# app/config/routing.yml
85-
86-
admin:
87-
resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
88-
prefix: /admin
89-
90-
_sonata_admin:
91-
resource: .
92-
type: sonata_admin
93-
prefix: /admin
94-
95-
.. code-block:: xml
96-
97-
<!-- app/config/routing.xml -->
98-
<?xml version="1.0" encoding="UTF-8" ?>
99-
<routes xmlns="http://symfony.com/schema/routing"
100-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
101-
xsi:schemaLocation="http://symfony.com/schema/routing
102-
http://symfony.com/schema/routing/routing-1.0.xsd">
103-
104-
<import
105-
resource="@SonataAdminBundle/Resources/config/sonata_admin.xml"
106-
prefix="/admin"
107-
/>
108-
109-
<import
110-
resource="."
111-
type="sonata_admin"
112-
prefix="/admin"
113-
/>
114-
115-
</routes>
116-
117-
.. code-block:: php
118-
119-
// app/config/routing.php
120-
use Symfony\Component\Routing\RouteCollection;
121-
122-
$collection = new RouteCollection();
123-
$routing = $loader->import(
124-
"@SonataAdminBundle/Resources/config/sonata_admin.xml"
125-
);
126-
$routing->setPrefix('/admin');
127-
$collection->addCollection($routing);
128-
129-
$_sonataAdmin = $loader->import('.', 'sonata_admin');
130-
$_sonataAdmin->addPrefix('/admin');
131-
$collection->addCollection($_sonataAdmin);
132-
133-
return $collection;
134-
135-
and publish your assets (remove ``--symlink`` if you use Windows!):
136-
137-
.. code-block:: bash
138-
139-
$ php bin/console assets:install --symlink web/
10+
Configuration
11+
-------------
14012

14113
Now start a local webserver:
14214

@@ -674,3 +546,4 @@ to tell sonata about them:
674546
users to not make mistakes.
675547

676548
.. _SonataDoctrinePHPCRAdminBundle: https://sonata-project.org/bundles/doctrine-phpcr-admin/master/doc/index.html
549+
.. _Sonata installation guide: https://sonata-project.org/bundles/doctrine-phpcr-admin/1-x/doc/reference/installation.html

0 commit comments

Comments
 (0)