2017 © Pedro Peláez
 

library pipelineparser-bundle

Pipeline comments parser for FOSCommentBundle

image

smilesrg/pipelineparser-bundle

Pipeline comments parser for FOSCommentBundle

  • Monday, March 30, 2015
  • by smilesrg
  • Repository
  • 2 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Purpose

Pipeline comments parser for FOSCommentBundle. Imagine that you need to integrate ExerciseHTMLPurifierBundle parser, hashtag parser, user mention parser... it's better to have several parsers where each is responsible for their actions. That's why I decided to write this bundle. This bundle is written for make chain (pipeline) of parser classes., (*1)

Usage

First, configure parser classes as services. You don't have to use all parsers that this bundle provides. The main parser of this bundle is PipelineParser which provides pipeline for parser classes., (*2)

    markup.mention_parser:
        #This is implementation of simple user mentioning parser like Twitter does
        class: Smilesrg\PipelineParserBundle\Parser\UserMentionParser
        # If you don't plan to use this parser somewhere in the code, it's better to make it private.
        # this should increase service container performance
        public: false
        arguments:
            - @fos_user.user_manager # FOS User Manager
            - @router # Router itself
            - "user_profile_show" # The route for showing user profile
            - "/\B\@([\w\-@]+)/im" # The regular expression pattern for user mentioning

    # See https://github.com/FriendsOfSymfony/FOSCommentBundle/blob/master/Resources/doc/9a-markup_htmlpurifier.md
    markup.exercise_html_purifier:
        class: FOS\CommentBundle\Markup\HtmlPurifier
        arguments: [ @exercise_html_purifier.default ]

Then, you have to define PipelineParser as a service and configure it with parsers., (*3)

    markuper.pipeline_parser:
        class: Smilesrg\PipelineParserBundle\Parser\PipelineParser
        calls:
            - [addToPipeline, ["@markup.exercise_html_purifier"]]
            - [addToPipeline, ["@markup.mention_parser"]]

The order of parsers is important. First parser that has been added to pipeline is executed first., (*4)

The last step is to use pipeline parser as described in documentation, (*5)

# app/config/config.yml

fos_comment:
    service:
        markup: markuper.pipeline_parser # The pipeline parser service

The Versions

30/03 2015

dev-master

9999999-dev http://github.com/smilesrg/PipelineParserBundle

Pipeline comments parser for FOSCommentBundle

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Sergii Smirnov

symfony2 bundle comments foscomment markuper