projects / org / se7enxweb / eabcommentbundle
Find the Exponential Software extensions you want
UNIX name | Owner | Status |
---|---|---|
EabCommentBundle | 7x | stable |
Version | Compatible with |
---|---|
N/A | N/A |
Yet another comments bundle! EABCommentBundle is an integration of
FOSCommentBundle with eZ Publish.
EABCommentBundle integrates FOSCommentBundle with eZ Publish.
It also provides the following additional features:
If you haven't done so already, add the Doctrine ORM bundle:
composer require --update-no-dev --prefer-dist doctrine/orm
Edit ezpublish/config/ezpublish.yml and add under doctrine section:
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
Update the database with the new entities (you should back up the database first to be safe):
php ezpublish/console doctrine:schema:update --force
Follow the installation instructions
for FOSCommentBundle except when editing ezpublish/routing.yml add:
fos_comment_api:
resource: "../../vendor/friendsofsymfony/comment-bundle/FOS/CommentBundle/Resources/config/routing.yml"
prefix: /api
type: rest
defaults: { _format: html }
Explanation: because this bundle override FOSCommentBundle we have to define the resource
using its file path instead of resource: "@FOSCommentBundle/Resources/config/routing.yml".
Edit ezpublish/config.yml and add the bundle to the Assetic configuration:
assetic:
bundles:
...
- FOSCommentBundle
Edit ezpublish/EzPublishKernel.php and remove these lines:
use EzSystems\CommentsBundle\EzSystemsCommentsBundle;
...
new EzSystemsCommentsBundle(),
Add the following line above your main bundle:
new Eab\CommentBundle\EabCommentBundle(),
Explanation: by adding it above your main bundle you can add settings to your
bundle that will override EABCommentBundle's settings.
Include the Timeago jQuery plugin. For example, in page_head_script.html.twig:
{% javascripts
...
'@EabCommentBundle/Resources/public/js/jquery.timeago.js'
%}
{% endjavascripts %}
Read more if you don't want to use Timeago.
Decide if you want to send notification emails in real time or spool them.
If you want to spool them, then edit the swiftmailer section of ezpublish/config.yml and replace:
swiftmailer:
spool: { type: memory }
with:
swiftmailer:
spool:
type: file
path: %kernel.root_dir%/mail/queue
Decide if you want to log each comment to a log file. If you do, then edit the monolog section of
ezpublish/config.yml and add:
monolog:
handlers:
comments:
type: stream
path: ../ezpublish/logs/comments.log
channels: [comments]
channels:
- eab
- comments
Note that this will make all emails spooled, not just those sent by EABCommentBundle.
Set up a cronjob to send all the spooled emails. For example:
# Every minute, spend 10 seconds sending spooled emails
* * * * * cd /path/to/ezpublish && php ezpublish/console swiftmailer:spool:send --time-limit=10
We recommend using pathString to identify eZ Publish locations.
To display comments for a location use:
{% include 'FOSCommentBundle:Thread:async.html.twig' with { 'id': location.pathString|split( '/' )|join( '-' ) } %}
To show the comment count for a specific location use the following in a template:
{{ render( controller( "EabCommentBundle:Comment:countComments",
{ 'id': location.pathString|split( '/' )|join( '-' ) }
) ) }}
In your own bundle's services.yml you can customize the sender and receiver email addresses used for
notification, and how to construct the comment author's name (only fields of type ezstring can be used).
For example:
# Settings for comments
eab.comment.mail.sender: webmaster@mywebsite.com
eab.comment.mail.receiver: manager@mycompany.com
eab.screenname.user.fields: [ first_name ]