Comments (11)
Can you show what you did put in your config here?
from fosmessagebundle.
My config.yml I have:
fos_message:
db_driver: orm
thread_class: myproject\MessageBundle\Entity\Thread
message_class: myproject\MessageBundle\Entity\Message
When I write all the config of documentation :
(
message_manager: fos_message.message_manager # See ModelManager\MessageManagerInterface
thread_manager: fos_message.thread_manager # See ModelManager\ThreadManagerInterface
...... )
I get the error.
In my composer.json:
"require" : {
....
"friendsofsymfony/message-bundle": "dev-master",
}
from fosmessagebundle.
Well, if you want to set explicitly the default value for the message_manager service, you should set fos_message.message_manager.default
(which is the default value). You cannot ask the bundle to use fos_message.message_manager
as target of the alias as this is the alias.
from fosmessagebundle.
and btw, you don't need to set it explicitly to personalize the form if you rely on the default value
from fosmessagebundle.
You can define your own classes as follows:
fos_message:
db_driver: mongodb
thread_class: Xxxx\MessageBundle\Document\MessageThread
message_class: Xxxx\MessageBundle\Document\Message
new_thread_form:
type: Xxxx.type.new_thread_form
handler: Xxxx.message_bundle.form_handler
model: Xxxx\MessageBundle\FormModel\NewThreadMessage
Where Xxxx.type.new_thread_form
references a service that you have defined in your configuration.
from fosmessagebundle.
Ok thank you very much @khepin
from fosmessagebundle.
But I have a question.
I can create my service and define my fields of form, in my services.yml:
message.type.new_thread_form:
class: myProject\MessageBundle\Form\MyMessageType
But handler and model ??
How it works?
Thanks for you time!
from fosmessagebundle.
There are a few versions of your models in this bundle.
- A generic abstract one
- One tied to your specific database (RDBMS / MongoDB as of today)
- One for the forms
So here the model is the one used by the forms. Example: check https://github.com/FriendsOfSymfony/FOSMessageBundle/blob/master/FormModel/NewThreadMessage.php
The form handler takes the form and does whatever should be done with it (validate / send the message etc...)
https://github.com/FriendsOfSymfony/FOSMessageBundle/blob/master/FormHandler/NewThreadMessageFormHandler.php
from fosmessagebundle.
Ok.
I have a other problem.
Now it is my config.yml
fos_message:
db_driver: orm
thread_class: chatea\MessageBundle\Entity\Thread
message_class: chatea\MessageBundle\Entity\Message
new_thread_form:
type: message.type.new_thread_form
handler: message.message_bundle.form_handler
model: chatea\MessageBundle\FormModel\NewThreadMessage
My services.yml
services:
message.type.new_thread_form:
class: chatea\MessageBundle\Form\MessageType
message.message_bundle.form_handler:
class: chatea\MessageBundle\FormHandler\NewThreadMessageFormHandler
I had created folder Form, FormHandler and FormModel.
MessageType.php , NewThreadMessageFormHandler.php and NewThreadMessage.php
But I get the following error:
Catchable Fatal Error: Argument 1 passed to FOS\MessageBundle\FormHandler\AbstractMessageFormHandler::__construct() must be an instance of Symfony\Component\HttpFoundation\Request, none given, called in /var/www/workspace/chateagratis/app/cache/dev/appDevDebugProjectContainer.php on line 2521 and defined in /var/www/workspace/chateagratis/vendor/friendsofsymfony/message-bundle/FOS/MessageBundle/FormHandler/AbstractMessageFormHandler.php line 25
So I think that I have include arguments in my service, message.message_bundle.form_handler..
message.message_bundle.form_handler:
class: chatea\MessageBundle\FormHandler\NewThreadMessageFormHandler
arguments: [ @Request , @ComposerInterface, @SenderInterface, @ParticipantProviderInterface ]
But I get this error:
ScopeWideningInjectionException: Scope Widening Injection detected: The definition "message.message_bundle.form_handler" references the service "request" which belongs to a narrower scope. Generally, it is safer to either move "message.message_bundle.form_handler" to scope "request" or alternatively rely on the provider pattern by injecting the container itself, and requesting the service "request" each time it is needed. In rare, special cases however that might not be necessary, then you can set the reference to strict=false to get rid of this error.
I include:
scope: request
But now this problem!
ServiceNotFoundException: The service "message.message_bundle.form_handler" has a dependency on a non-existent service "composerinterface".
How can I add this arguments ?What am I doing wrong ?
Thanks! ; )
from fosmessagebundle.
Well it's pretty easy, you're asking the container to create your service with the @ComposerInterface
service as a parameter!
So you want something more like:
xxx.message_bundle.form_handler:
class: xxx\MessageBundle\FormHandler\NewThreadMessageFormHandler
arguments: [@request, @fos_message.composer, @fos_message.sender, @fos_message.participant_provider]
scope: request
from fosmessagebundle.
Ok @khepin thank you very much
Not understand why it did not work, took many hours with this problem.
You're a genius, Now it works! you saved me. :)
from fosmessagebundle.
Related Issues (20)
- FORM TARGETS INSECURE URL HOT 1
- I want to customize form type with custom entity fields HOT 1
- This bundle is obsolete? HOT 2
- How get all user threads HOT 1
- The service "fos_user.resetting.controller" has a dependency on a non-existent service "templating". HOT 3
- How add custom field in Thread HOT 1
- fos message alert by mail HOT 2
- The project has been abandoned? HOT 1
- Symfony 4 / v2 / is this bundle obsolete? HOT 14
- multiple recipients exists but isn't referenced in the documentation
- automated tests HOT 3
- sort through pull requests HOT 1
- packagist web hook HOT 8
- Is form submitted HOT 1
- The "Symfony\Component\Config\Definition\Builder\TreeBuilder::root()" method called for the "fos_message" configuration is deprecated since Symfony 4.3, pass the root name to the constructor instead. HOT 1
- What's the status of this bundle? Will it be updated to support [Popular/Latest Symfony version X]? HOT 3
- docker composer install HOT 1
- Symfony 4, Twig 3 and FosMessage 2 HOT 1
- Nasreddine HOT 1
- Twig MessageExtension method getNbUnread() should return an int instead of null
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fosmessagebundle.