Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use bbcode_clean directly in controller ? #124

Open
QuentinPi opened this issue Oct 15, 2015 · 16 comments
Open

How to use bbcode_clean directly in controller ? #124

QuentinPi opened this issue Oct 15, 2015 · 16 comments

Comments

@QuentinPi
Copy link

Hello,
I have a new question about your bundle !
I would like to use the bbcode_clean filter directly in a controller, without using any twig view.
I think there is a proper way to call it in a Symfony controller...

@helios-ag
Copy link
Owner

Get 'fm_bbcode.decoda_manager' service in your controller, and use it like here https://github.com/helios-ag/FMBbCodeBundle/blob/master/Templating/BbcodeExtension.php#L79

@QuentinPi
Copy link
Author

Thanks a lot ! It works but I have a problem with the quote and code tags. When I use the bbcode cleaner, it renders nothing !

EDIT : I have also a question about the emoticons, is it possible to configure them with a emoticons.php file like in decoda ? (https://github.com/milesj/decoda/blob/master/src/config/emoticons.php)
I read your doc and I call the php file in the config.yml but it doesn't work. I think a .yml is expected.
I found a solution for that, by changing the EmoticonHook.php

@helios-ag
Copy link
Owner

problem with the quote and code tags

If you apply bbcode_clean, inside twig template, did this filter strip code/quote tags from your string?

About second question: this hook expects yml configuration for emoticons file, another way, is to register custom hook, that will look for your emoticons php file

@QuentinPi
Copy link
Author

About the first question, yes, the filter strips code and quote tags but also the content. I discovered there is an option in decoda : stripContent, I turn it off and now it's perfect ! But I have a problem with the usage of bbcode_clean in a twig view : how can I pass a filterset string in parameter ?

@helios-ag
Copy link
Owner

The same way as bbcode_filter(filterSet) -> bbcode_clean(filterSet)

@QuentinPi
Copy link
Author

Good ! Your bundle is very powerful ! I have one more question... Does it exist a way to avoid line break with decoda manager ? In the decoda documentation, I see options like "setLineBreaks" or "setMaxNewlines" but it doesn't work in the config.yml...

@helios-ag
Copy link
Owner

Well, yes. Option setMaxNewlines is not available. But you can make a PR :)
Opened issue #125

@alquerci
Copy link
Contributor

Hello @QuozPowa

@helios-ag has already responded very well to all questions but I would like to provide some clarifications.

I would like to use the bbcode_clean filter directly in a controller, without using any twig view.

You can also use the fm_bbcode.templating.helper service (ref).

I have also a question about the emoticons, is it possible to configure them with a emoticons.php file like in decoda ? (https://github.com/milesj/decoda/blob/master/src/config/emoticons.php)
I read your doc and I call the php file in the config.yml but it doesn't work. I think a .yml is expected.
I found a solution for that, by changing the EmoticonHook.php

Both PHP and Yaml configuration files are supported (ref). It uses a delegated loader to use the good one. On PHP format the file must return an FM\BbcodeBundle\Emoticon\EmoticonCollection it is because the emoticons.php file like in Decoda does not work. It is possible to write a loader that support emoticons configuration like in Decoda.

@helios-ag
Copy link
Owner

Well explained @alquerci, thank you!

@QuentinPi
Copy link
Author

Yes thank you everyone ! I managed to do what I wanted. Your bundle is very very useful ! 👍

@QuentinPi
Copy link
Author

I have again another question ! Do you know if it's possible to get the EntityManager in a filter file ?

@helios-ag
Copy link
Owner

Can you explain what goal do you plan to achieve with this, and btw what do you mean under 'filter file'?

@QuentinPi
Copy link
Author

Sorry, I just realize that it is a decoda file (https://github.com/milesj/decoda/blob/master/src/Decoda/Filter/QuoteFilter.php). Actually, I would like to check the author attribute (quote tag) in the database in order to display a link. I can add my own parse method in this filter but the EntityManager isn't available.

@alquerci
Copy link
Contributor

Hello @QuozPowa,

There are many ways to achive that the main goal is to extends the Decoda\Filter\QuoteFilter class:
* override fm_bbcode.decoda.filter.quote.class configuration
* create a new filter for exemple enhanced_quote or what you want, doc

@helios-ag
Copy link
Owner

IMHO injecting EM even in filter isn't a good idea, i think this can be achieved with simpler solution, like providing route to user profile.

@QuentinPi
Copy link
Author

Thanks you, I managed to do it :)
I meet a new problem with special spaces and emoticons, I will create a new issue !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants