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

Commit 9f7244e

Browse files
committed
back to relative url for images
2 parents cc02983 + 8eedeab commit 9f7244e

11 files changed

+191
-37
lines changed

bundles/block.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ BlockBundle
22
===========
33

44
The `BlockBundle <https://github.com/symfony-cmf/BlockBundle#readme>`_ provides integration with SonataBlockBundle.
5-
It assists you in managing fragments of contents, so called blocks. What the BlockBundle does is similar
6-
to what Twig does, but for blocks that are persisted in a DB. Thus the blocks can be made editable for an editor.
5+
It assists you in managing fragments of contents, so-called blocks. What the BlockBundle does is similar
6+
to what Twig does, but for blocks that are persisted in a DB. Thus, the blocks can be made editable for an editor.
77
Also the BlockBundle provides the logic to determine which block should be rendered on which pages.
88

99
The BlockBundle does not provide an editing functionality for blocks itself. However, you can find examples
@@ -64,7 +64,7 @@ The BlockBundle comes with four general purpose blocks:
6464
* SimpleBlock: A simple block with nothing but a title and a field of hypertext. This would usually be what an editor edits directly, for example contact information
6565
* ContainerBlock: A block that contains 0 to n child blocks
6666
* ReferenceBlock: A block that references a block stored somewhere else in the content tree. For example you might want to refer parts of the contact information from the homepage
67-
* ActionBlock: A block that calls a Symfony2 action. "Why would I use this instead of directly calling the action from my template?" you might wonder. Well imagine the following case: You provide a block that renders teasers of your latest news. However, there is no rule where they should appear. Instead, your customer wants to decide himself on what pages this block is to be displayed. Providing an according ActionBlock, you allow your customer to do so without calling you to change some templates (over and over again!).
67+
* ActionBlock: A block that calls a Symfony2 action. "Why would I use this instead of directly calling the action from my template?", you might wonder. Well imagine the following case: You provide a block that renders teasers of your latest news. However, there is no rule where they should appear. Instead, your customer wants to decide himself on what pages this block is to be displayed. Providing an according ActionBlock, you allow your customer to do so without calling you to change some templates (over and over again!).
6868

6969
Create your own blocks
7070
----------------------
@@ -86,7 +86,7 @@ template stored in 'templateName'. You can again extend ``Sonata\BlockBundle\Blo
8686
It is important, that the 'name' property of the service is called 'my_bundle.block.rss' (this makes
8787
sure the relation between entity and service can be found).
8888

89-
The last thing you need is to define the service in a config file. It is important, to tag your
89+
The last thing you need is to define the service in a config file. It is important to tag your
9090
BlockService with 'sonata.block', otherwise it will not be known by the Bundle.
9191

9292
Examples
@@ -104,5 +104,5 @@ It replaces components of the bundle where needed to be compatible with PHPCR.
104104

105105
The following picture shows where we use our own components (blue):
106106

107-
.. image:: /images/bundles/classdiagram.jpg
107+
.. image:: ../images/bundles/classdiagram.jpg
108108
:align: center

bundles/core.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ One of the provided features is an interface and implementation of a publish wor
99
with an accompanying interface that models can implement that want to support this checker.
1010

1111
Furthermore it provides a twig helper exposing several useful functions for twig templates
12-
to interact with PHPCR-ODM documents
12+
to interact with PHPCR-ODM documents.
1313

1414
.. index:: CoreBundle, PHPCR, ODM, publish workflow
1515

@@ -49,7 +49,7 @@ Implements the following functions:
4949
* ``cmf_prev``: returns the previous published document by examining the child nodes of the parent of the provided
5050
* ``cmf_next``: returns the next published document by examining the child nodes of the parent of the provided
5151
* ``cmf_children``: returns an array of all the children documents of the provided documents that are published
52-
* ``cmf_document_locales``: get the locales of the provided document
52+
* ``cmf_document_locales``: gets the locales of the provided document
5353

5454
.. code-block:: jinja
5555

bundles/routing-extra.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,16 @@ The possible mappings are (in order of precedence):
204204
manager_registry: doctrine_phpcr
205205
manager_name: default
206206
207-
# if you use the default doctrine route repository servie, you can use this to customize
207+
# if you use the default doctrine route repository service, you can use this to customize
208208
# the root path for the `PHPCR-ODM`_ RouteRepository
209209
# this base path will be injected by the Listener\IdPrefix - but only to routes
210210
# matching the prefix, to allow for more than one route source.
211211
routing_repositoryroot: /cms/routes
212212
213+
# If you want to replace the default route or content reposititories
214+
# you can specify their service IDs here.
215+
route_repository_service_id: my_bundle.repository.endpoint
216+
content_repository_service_id: my_bundle.repository.endpoint
213217
214218
To see some examples, please look at the `CMF sandbox`_ and specifically the routing fixtures loading.
215219

@@ -266,7 +270,8 @@ redirections and locales.
266270

267271
Notes:
268272

269-
* RouteObjectInterface: The provided documents implement this interface to map content to routes
273+
* RouteObjectInterface: The provided documents implement this interface to map content to routes and to (optional) provide
274+
a custom route name instead of the symfony core compatible route name.
270275
* Redirections: This bundle provides a RedirectController.
271276

272277
TODO: see DependencyInjection/Configuration.php of this bundle. I could not figure out how to set
@@ -297,3 +302,8 @@ extend it. You can also write your own routers to hook into the chain.
297302
.. _`CMF sandbox`: https://github.com/symfony-cmf/cmf-sandbox
298303
.. _`CMF Routing component`: https://github.com/symfony-cmf/Routing
299304
.. _`PHPCR-ODM`: https://github.com/doctrine/phpcr-odm
305+
306+
Learn more from the Cookbook
307+
----------------------------
308+
309+
* :doc:`../cookbook/using-a-custom-route-repository`

components/routing.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,15 @@ The match method of the DynamicRouter does the following steps
7979
RouteObjectInterface
8080
~~~~~~~~~~~~~~~~~~~~
8181

82-
Routes that implement this interface are linked to a content document.
82+
Routes that implement this interface can be linked to a content document using
83+
the ``getRouteContent`` method. If non-null, this content is passed to the
84+
controller. If there is no specific content for this route this may return null.
85+
86+
Furthermore, routes that implement this interface can also provide a custom route
87+
name. The key returned by ``getRouteKey`` will be used as route name instead of
88+
the Symfony core compatible route name and can contain any characters. This allows
89+
you, for example, to set a path as the route name.
90+
8391
All routes still need to extend the base class ``Symfony\Component\Routing\Route``
8492

8593
Redirections
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
Using a custom route repository with Dynmaic Router
2+
===================================================
3+
4+
The Dynamic Router allows you to customize the route Repository (i.e. the class
5+
responsible for retrieving routes from the database), and by extension, the
6+
Route objects.
7+
8+
Creating the route repository
9+
-----------------------------
10+
11+
The route repository must implement the `RouteRepositoryInterface` The
12+
following class provides a simple solution using an ODM Repository.
13+
14+
.. code-block:: php
15+
16+
<?php
17+
18+
namespace MyVendor\Bundle\MyBundle\Repository;
19+
use Doctrine\ODM\PHPCR\DocumentRepository;
20+
use Symfony\Cmf\Component\Routing\RouteRepositoryInterface;
21+
use Symfony\Component\Routing\RouteCollection;
22+
use Symfony\Component\Routing\Route as SymfonyRoute;
23+
24+
class RouteRepository extends DocumentRepository implements RouteRepositoryInterface
25+
26+
{
27+
// this method is used to find routes matching the given URL
28+
public function findManyByUrl($url)
29+
{
30+
// for simplicity we retrieve one route
31+
$myDocument = $this->findOneBy(array(
32+
'url' => $url,
33+
));
34+
35+
$pattern = $myDocument->getUrl(); // e.g. "/this/is/a/url"
36+
37+
$collection = new RouteCollection();
38+
39+
// create a new Route and set our document as
40+
// a default (so that we can retrieve it from the request)
41+
$route = new SymfonyRoute($ep->getPath(), array(
42+
'document' => $document,
43+
));
44+
45+
// add the route to the RouteCollection using
46+
// a unique ID as the key.
47+
$collection->add('my_route_'.uniqid(), $route);
48+
49+
return $collection;
50+
}
51+
52+
// this method is used to generate URLs, e.g. {{ path('foobar') }}
53+
public function getRouteByName($name, $params = array())
54+
{
55+
$document = $this->findOneBy(array(
56+
'name' => $name,
57+
));
58+
59+
if ($route) {
60+
$route = new SymfonyRoute($route->getPattern(), array(
61+
'document' => $document,
62+
));
63+
}
64+
65+
return $route;
66+
}
67+
}
68+
69+
.. tip::
70+
71+
As you may have noticed we return a `RouteCollection` object - why not return
72+
a single `Route`? The Dynamic Router allows us to return many *candidate* routes,
73+
in other words, routes that *might* match the incoming URL. This is important to
74+
enable the possibility of matching *dynamic* routes, `/page/{page_id}/edit` for example.
75+
In our example we match the given URL exactly and only ever return a single `Route`.
76+
77+
Replacing the default CMF repository
78+
------------------------------------
79+
80+
To replace the default `RouteRepository` it is necessary to modify your configuration
81+
as follows:
82+
83+
.. configuration-block::
84+
85+
.. code-block:: yaml
86+
87+
# app/config/config.yml
88+
symfony_cmf_routing_extra:
89+
dynamic:
90+
enabled: true
91+
route_repository_service_id: my_bundle.repository.endpoint
92+
93+
Where `my_bundle.repository.endpoint` is the service ID of your repository.
94+
See `Creating and configuring services in the container <http://symfony.com/doc/current/book/service_container.html#creating-configuring-services-in-the-container/>`_
95+
for information on creating custom services.

index.rst

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,42 @@
33

44
Welcome to the official documentation of the `Symfony Content Management Framework`_.
55

6+
The Symfony2 Content Management Framework project is organized by the Symfony
7+
community and has several sponsoring companies and prominent open source leaders
8+
implementing the philosophy of the decoupled CMS. You can read learn more about the
9+
project on the about page.
10+
611
This documentation is currently in development and far from complete. See `Documentation planning`_ for an
712
overview of the work left to do. Want to help? Thank you, all help greatly appreciated! The source of
813
the `documentation is hosted here`_.
914

15+
Mission Statement
16+
-----------------
17+
18+
The Symfony CMF project makes it easier for developers to add CMS functionality to
19+
applications built with the Symfony2 PHP framework. Key development principles for
20+
the provided set of bundles are scalability, usability, documentation and testing.
21+
22+
Why another CMS?
23+
----------------
24+
25+
Actually we consider this project to be a CMF, a content management framework, rather
26+
than a CMS, a content management system. The reason is that we are only providing tools
27+
to build a custom CMS. There are obviously many CMS solutions available today already,
28+
but they tend to be tailored first and foremost towards end users and also many tend
29+
to carry a lot of legacy baggage which make them less than ideal for truly custom
30+
development like what is possible with `Symfony2`_.
31+
32+
What is our target audience?
33+
----------------------------
34+
35+
There are basically to main target audiences:
36+
37+
#. Developers that have build a custom application with Symfony2 and just need to also
38+
support a few content pages for things like the about/contact pages or a news section
39+
#. Developers that need to build a highly customized authoring and content delivery
40+
solution that no out of the box CMS can properly provide through customization.
41+
1042
Tutorials
1143
---------
1244

@@ -15,8 +47,8 @@ Learning or want to learn the CMF? Want to know if the CMF fits your project? Th
1547
.. toctree::
1648
:maxdepth: 1
1749

18-
tutorials/choosing-a-storage-layer
1950
tutorials/installing-configuring-cmf
51+
tutorials/choosing-a-storage-layer
2052
tutorials/installing-configuring-doctrine-phpcr-odm
2153
tutorials/installing-configuring-simple-cms
2254
tutorials/installing-configuring-inline-editing
@@ -55,6 +87,7 @@ Special solutions for special needs that go beyond standard usage.
5587
:maxdepth: 1
5688

5789
cookbook/phpcr-odm-custom-documentclass-mapper
90+
cookbook/using-a-custom-route-repository
5891

5992
Components
6093
----------
@@ -75,6 +108,7 @@ Contributing
75108
contributing/code
76109
contributing/license
77110

111+
.. _`Symfony2`: http://symfony.com
78112
.. _`Documentation planning`: https://github.com/symfony-cmf/symfony-cmf/wiki/Documentation-Planning
79113
.. _`Symfony Content Management Framework`: http://cmf.symfony.com
80114
.. _`documentation is hosted here`: https://github.com/symfony-cmf/symfony-cmf-docs

0 commit comments

Comments
 (0)