Skip to content

Commit

Permalink
Fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarStark committed Feb 5, 2020
1 parent 28f73b4 commit c086398
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 37 deletions.
4 changes: 2 additions & 2 deletions docs/cookbook/rapid_prototyping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ You start integrating your HTML with the ``sonata.block.service.template`` block

The usage is very simple:

.. code-block:: jinja
.. code-block:: twig
{{ sonata_block_render({ 'type': 'sonata.block.service.template' }, {
'template': '@SonataDemo/Block/myblock.html'
Expand All @@ -41,7 +41,7 @@ Example

The main template might look like:

.. code-block:: jinja
.. code-block:: twig
<!DOCTYPE html>
<html>
Expand Down
6 changes: 3 additions & 3 deletions docs/reference/advanced_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Block Context Manager - context cache

When using ``Varnish``, ``Ssi`` or ``Js`` cache, the settings passed here are lost:

.. code-block:: jinja
.. code-block:: twig
{{ sonata_block_render({ 'type': 'sonata.block.service.rss' }, {
'title': 'Sonata Project\'s Feeds',
Expand Down Expand Up @@ -58,6 +58,6 @@ Empty block
-----------

By default, the loader interface expects the exception ``Sonata\BlockBundle\Exception\BlockNotFoundException`` if a block is not found.
Return an empty block from your loader class if the default behaviour for your blocks is to always return content.
Return an empty block from your loader class if the default behavior for your blocks is to always return content.

.. _SonataCacheBundle: https://github.com/sonata-project/SonataCacheBundle
.. _SonataCacheBundle: https://github.com/sonata-project/SonataCacheBundle
16 changes: 9 additions & 7 deletions docs/reference/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ As part of a full stack solution, you don't know which solution is going to be u

The `Event mechanism` implemented in the ``SonataBlockBundle`` tries to address this situation, and to provide a clean syntax:

.. code-block:: jinja
.. code-block:: twig
{# post.twig.html #}
<h1>{{ post.title }}</h1>
<div> {{ post.message }} </div>
Expand All @@ -30,12 +31,6 @@ So, the current the name will be ``sonata.block.event.blog.comment``.

.. configuration-block::

.. code-block:: xml
<service id="disqus.comment" class="Sonata\CommentBundle\Event\Discus">
<tag name="kernel.event_listener" event="sonata.block.event.blog.comment" method="onBlock"/>
</service>
.. code-block:: yaml
# config/services.yaml
Expand All @@ -46,6 +41,13 @@ So, the current the name will be ``sonata.block.event.blog.comment``.
tags:
- { name: kernel.event_listener, event: sonata.block.event.blog.comment, method: onBlock }
.. code-block:: xml
<service id="disqus.comment" class="Sonata\CommentBundle\Event\Discus">
<tag name="kernel.event_listener" event="sonata.block.event.blog.comment" method="onBlock"/>
</service>
The `event listener` must push one or some ``BlockInterface`` instances into ``BlockEvent`` passed in so the rendering workflow will work properly::

use Sonata\BlockBundle\Model\Block;
Expand Down
12 changes: 6 additions & 6 deletions docs/reference/twig_helpers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ Twig Helpers

Render a block from its instance:

.. code-block:: jinja
.. code-block:: twig
{{ sonata_block_render(block) }}
Render a block by providing the block's type and options:

.. code-block:: jinja
.. code-block:: twig
{{ sonata_block_render({ 'type': 'sonata.block.service.rss' }, {
'title': 'Sonata Project\'s Feeds',
Expand All @@ -26,7 +26,7 @@ Render a block by providing the block's type and options:
Render a block by providing the block's cache options:

.. code-block:: jinja
.. code-block:: twig
{{ sonata_block_render(block, {
'use_cache': use_cache,
Expand All @@ -35,7 +35,7 @@ Render a block by providing the block's cache options:
Render a block by calling an event:

.. code-block:: jinja
.. code-block:: twig
{{ sonata_block_render_event('node.comment', {
'target': post
Expand All @@ -47,9 +47,9 @@ Render a block by calling an event:

Rendering a block related to javascripts and stylesheets for the current page implies the helpers to be called at the end of the page:

.. code-block:: jinja
.. code-block:: twig
{{ sonata_block_include_stylesheets('screen', app.request.basePath) }}
{{ sonata_block_include_javascripts('screen', app.request.basePath) }}
The ``app.request.basePath`` must be provided if your application is stored in a sub-folder.
The ``app.request.basePath`` must be provided if your application is stored in a sub-folder.
39 changes: 20 additions & 19 deletions docs/reference/your_first_block.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,7 @@ The current RSS block will extend this base class. The other `use` statements ar
Default settings
----------------

A `block service` needs settings to work properly, so to ensure consistency, the service should define a ``configureOptions`` method.
In the current tutorial, the default settings are:

* `URL`: the feed url,
* `title`: the block title,
* `template`: the template to render the block.

.. code-block:: php
A `block service` needs settings to work properly, so to ensure consistency, the service should define a ``configureOptions`` method::

public function configureSettings(OptionsResolver $resolver)
{
Expand All @@ -47,8 +40,16 @@ In the current tutorial, the default settings are:
]);
}

In the current tutorial, the default settings are:

* `URL`: the feed url,
* `title`: the block title,
* `template`: the template to render the block.


Form Editing
------------

You can define an editing config the following way::

public function buildEditForm(FormMapper $formMapper, BlockInterface $block)
Expand Down Expand Up @@ -127,7 +128,7 @@ Template

In this tutorial, the block template is very simple. We loop through feeds, or if none are available, an error message is displayed.

.. code-block:: jinja
.. code-block:: twig
{% extends sonata_block.templates.block_base %}
Expand All @@ -153,16 +154,6 @@ We are almost done! Now, just declare the block as a service:

.. configuration-block::

.. code-block:: xml
<!-- config/services.xml -->
<service id="sonata.block.service.rss" class="Sonata\BlockBundle\Block\Service\RssBlockService">
<tag name="sonata.block"/>
<argument/>
<argument type="service" id="twig"/>
</service>
.. code-block:: yaml
# config/services.yaml
Expand All @@ -176,6 +167,16 @@ We are almost done! Now, just declare the block as a service:
tags:
- { name: sonata.block }
.. code-block:: xml
<!-- config/services.xml -->
<service id="sonata.block.service.rss" class="Sonata\BlockBundle\Block\Service\RssBlockService">
<tag name="sonata.block"/>
<argument/>
<argument type="service" id="twig"/>
</service>
Then, add the service to Sonata configuration:

.. configuration-block::
Expand Down

0 comments on commit c086398

Please sign in to comment.