Download the PHP package edsi-tech/sir-trevor-bundle without Composer
On this page you can find all versions of the php package edsi-tech/sir-trevor-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download edsi-tech/sir-trevor-bundle
More information about edsi-tech/sir-trevor-bundle
Files in edsi-tech/sir-trevor-bundle
Package sir-trevor-bundle
Short Description Bundle integrating SirTrevor library
License MIT
Informations about the package sir-trevor-bundle
SirTrevor Bundle by EDSI-Tech Sarl
Integration of SirTrevor JS library into a Symfony2 bundle.
SirTrevor editor works with "blocks", fragment of content of different types. This bundle allow you to map those to Doctrine entities. Secondly, it provides a TwigExtension & templates to easily achieve a clean SirTrevor integration.
Installation
Using packing, require edsi-tech/sir-trevor-bundle
Then register it in app/AppKernel.php
.
Usage
Model
You must extend EdsiTech\SirTrevorBundle\Entity\AbstractBlock
.
AbstractBlock
represent a block as SirTrevor knows it. It can be easily mapped to a Doctrine ORM entity, for this for already put some annotations.
Rendering the editor
To render the editor, put in a Twig template:
You must pass to this template a blocks
variable , containing a collection of AbstractBlock
.
Moreover, using a is_editable
variable, you can decide whether to render a content editable with SirTrevor or just to render the blocks as plain old HTML.
By default we use the theme EdsiTechSirTrevorBundle:Render:_blocks_theme.html.twig
.
You can change it via Bundle config:
Saving blocks
Blocks will be re-send to your controller, via POST.
To handle those, you should use the provided edsi_tech_sir_trevor.handler.block_handler
service.
It will read the Request and return you an array of EdsiTech\SirTrevorBundle\Model\EditedBlock
.
Bonus
Loading Bar
It includes a progress bar for editor loading. Available using Pace.
Flash messages
Request flash messages are displayed as nice messages powered by HubSport Messenger
Controller example:
"back" button
The bar on top added by this bundle can include a "back" button. Just provide the URL it should point to in your controller:
Even more buttons
You can provide more buttons/HTML to add to the bar on top of the page via save_bar_buttons
:
Full working example
The controller:
The template:
Configuration
Allowed blocks
By defaults not all SirTrevor blocks are enabled, you can modify it in bundle configuration:
Themes
When the content is rendered, we are using a blocks_theme
to determine the HTML for each block (in a manner pretty similar to Symfony2 Form theme).
A default implementation is included; if you want to customize it, you can set your own Twig template in configuration.
All blocks are rendered within a render_template
you can also override.
Adding an extra CSS or JS file
You can inject another JS file, loaded after included JS libraries but before the editor is initialized. A common use case is to add some SirTrevor blocks.
In the same manner, you can also add a CSS file, that will be included after all ours stylesheets.
Going further
Getting Editor instance
You can retrieve the SirTrevor instance in JS by doing SirTrevor.getInstance()
All versions of sir-trevor-bundle with dependencies
symfony/symfony Version ~2.3
doctrine/orm Version ~2.2,>=2.2.3
doctrine/doctrine-bundle Version ~1.2
twig/extensions Version ~1.0
symfony/assetic-bundle Version ~2.3
erusev/parsedown Version ~1.1