diff --git a/Composer/Composer.php b/Composer/Composer.php index b76a9e02..78adc343 100644 --- a/Composer/Composer.php +++ b/Composer/Composer.php @@ -2,12 +2,12 @@ namespace FOS\MessageBundle\Composer; -use FOS\MessageBundle\ModelManager\MessageManagerInterface; -use FOS\MessageBundle\Sender\SenderInterface; -use FOS\MessageBundle\Model\ThreadInterface; -use FOS\MessageBundle\ModelManager\ThreadManagerInterface; use FOS\MessageBundle\MessageBuilder\NewThreadMessageBuilder; use FOS\MessageBundle\MessageBuilder\ReplyMessageBuilder; +use FOS\MessageBundle\Model\ThreadInterface; +use FOS\MessageBundle\ModelManager\MessageManagerInterface; +use FOS\MessageBundle\ModelManager\ThreadManagerInterface; +use FOS\MessageBundle\Sender\SenderInterface; /** * Factory for message builders diff --git a/Controller/MessageController.php b/Controller/MessageController.php index 28c06a63..e8bcdc25 100644 --- a/Controller/MessageController.php +++ b/Controller/MessageController.php @@ -3,12 +3,27 @@ namespace FOS\MessageBundle\Controller; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Component\DependencyInjection\ContainerAware; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use FOS\MessageBundle\Provider\ProviderInterface; +use Symfony\Component\HttpFoundation\Response; -class MessageController extends ContainerAware +class MessageController implements ContainerAwareInterface { + /** + * @var ContainerInterface + */ + protected $container; + + /** + * {@inheritDoc} + */ + public function setContainer(ContainerInterface $container = null) + { + $this->container = $container; + } + /** * Displays the authenticated participant inbox * @@ -55,7 +70,7 @@ public function deletedAction() * Displays a thread, also allows to reply to it * * @param string $threadId the thread id - * + * * @return Response */ public function threadAction($threadId) @@ -100,9 +115,9 @@ public function newThreadAction() /** * Deletes a thread - * + * * @param string $threadId the thread id - * + * * @return RedirectResponse */ public function deleteAction($threadId) @@ -113,12 +128,12 @@ public function deleteAction($threadId) return new RedirectResponse($this->container->get('router')->generate('fos_message_inbox')); } - + /** * Undeletes a thread - * + * * @param string $threadId - * + * * @return RedirectResponse */ public function undeleteAction($threadId) diff --git a/DataTransformer/RecipientsDataTransformer.php b/DataTransformer/RecipientsDataTransformer.php index 39cd4d07..245146f2 100644 --- a/DataTransformer/RecipientsDataTransformer.php +++ b/DataTransformer/RecipientsDataTransformer.php @@ -1,13 +1,13 @@ addDefaultsIfNotSet() ->children() ->scalarNode('factory')->defaultValue('fos_message.new_thread_form.factory.default')->cannotBeEmpty()->end() - ->scalarNode('type')->defaultValue('fos_message.new_thread_form.type.default')->cannotBeEmpty()->end() + ->scalarNode('class')->defaultValue('FOS\MessageBundle\FormType\NewThreadMessageFormType')->cannotBeEmpty()->end() ->scalarNode('handler')->defaultValue('fos_message.new_thread_form.handler.default')->cannotBeEmpty()->end() ->scalarNode('name')->defaultValue('message')->cannotBeEmpty()->end() ->scalarNode('model')->defaultValue('FOS\MessageBundle\FormModel\NewThreadMessage')->end() @@ -61,7 +61,7 @@ public function getConfigTreeBuilder() ->addDefaultsIfNotSet() ->children() ->scalarNode('factory')->defaultValue('fos_message.reply_form.factory.default')->cannotBeEmpty()->end() - ->scalarNode('type')->defaultValue('fos_message.reply_form.type.default')->cannotBeEmpty()->end() + ->scalarNode('class')->defaultValue('FOS\MessageBundle\FormType\ReplyMessageFormType')->cannotBeEmpty()->end() ->scalarNode('handler')->defaultValue('fos_message.reply_form.handler.default')->cannotBeEmpty()->end() ->scalarNode('name')->defaultValue('message')->cannotBeEmpty()->end() ->scalarNode('model')->defaultValue('FOS\MessageBundle\FormModel\ReplyMessage')->end() diff --git a/DependencyInjection/FOSMessageExtension.php b/DependencyInjection/FOSMessageExtension.php index 15ec2786..b4685a35 100644 --- a/DependencyInjection/FOSMessageExtension.php +++ b/DependencyInjection/FOSMessageExtension.php @@ -3,11 +3,11 @@ namespace FOS\MessageBundle\DependencyInjection; use Symfony\Component\Config\Definition\Processor; +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\DependencyInjection\Extension; -use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\Config\FileLocator; class FOSMessageExtension extends Extension { @@ -32,8 +32,10 @@ public function load(array $configs, ContainerBuilder $container) $container->setParameter('fos_message.message_class', $config['message_class']); $container->setParameter('fos_message.thread_class', $config['thread_class']); + $container->setParameter('fos_message.new_thread_form.class', $config['new_thread_form']['class']); $container->setParameter('fos_message.new_thread_form.model', $config['new_thread_form']['model']); $container->setParameter('fos_message.new_thread_form.name', $config['new_thread_form']['name']); + $container->setParameter('fos_message.reply_form.class', $config['reply_form']['class']); $container->setParameter('fos_message.reply_form.model', $config['reply_form']['model']); $container->setParameter('fos_message.reply_form.name', $config['reply_form']['name']); @@ -51,10 +53,8 @@ public function load(array $configs, ContainerBuilder $container) $container->setAlias('fos_message.spam_detector', $config['spam_detector']); $container->setAlias('fos_message.twig_extension', $config['twig_extension']); - $container->setAlias('fos_message.new_thread_form.type', $config['new_thread_form']['type']); $container->setAlias('fos_message.new_thread_form.factory', $config['new_thread_form']['factory']); $container->setAlias('fos_message.new_thread_form.handler', $config['new_thread_form']['handler']); - $container->setAlias('fos_message.reply_form.type', $config['reply_form']['type']); $container->setAlias('fos_message.reply_form.factory', $config['reply_form']['factory']); $container->setAlias('fos_message.reply_form.handler', $config['reply_form']['handler']); diff --git a/Document/Thread.php b/Document/Thread.php index 0fde6299..f0c972d2 100644 --- a/Document/Thread.php +++ b/Document/Thread.php @@ -2,11 +2,11 @@ namespace FOS\MessageBundle\Document; -use FOS\MessageBundle\Model\Thread as AbstractThread; -use FOS\MessageBundle\Model\MessageInterface; -use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; +use FOS\MessageBundle\Model\MessageInterface; use FOS\MessageBundle\Model\ParticipantInterface; +use FOS\MessageBundle\Model\Thread as AbstractThread; abstract class Thread extends AbstractThread { diff --git a/DocumentManager/MessageManager.php b/DocumentManager/MessageManager.php index f925a6e6..84697f18 100644 --- a/DocumentManager/MessageManager.php +++ b/DocumentManager/MessageManager.php @@ -3,13 +3,13 @@ namespace FOS\MessageBundle\DocumentManager; use Doctrine\ODM\MongoDB\DocumentManager; +use Doctrine\ODM\MongoDB\Query\Builder; use FOS\MessageBundle\Document\Message; use FOS\MessageBundle\Model\MessageInterface; -use FOS\MessageBundle\ModelManager\MessageManager as BaseMessageManager; -use FOS\MessageBundle\Model\ReadableInterface; use FOS\MessageBundle\Model\ParticipantInterface; +use FOS\MessageBundle\Model\ReadableInterface; use FOS\MessageBundle\Model\ThreadInterface; -use Doctrine\ODM\MongoDB\Query\Builder; +use FOS\MessageBundle\ModelManager\MessageManager as BaseMessageManager; /** * Default MongoDB MessageManager. diff --git a/DocumentManager/ThreadManager.php b/DocumentManager/ThreadManager.php index bb51e673..25d04264 100644 --- a/DocumentManager/ThreadManager.php +++ b/DocumentManager/ThreadManager.php @@ -3,12 +3,12 @@ namespace FOS\MessageBundle\DocumentManager; use Doctrine\ODM\MongoDB\DocumentManager; +use Doctrine\ODM\MongoDB\Query\Builder; use FOS\MessageBundle\Document\Thread; -use FOS\MessageBundle\Model\ThreadInterface; +use FOS\MessageBundle\Model\ParticipantInterface; use FOS\MessageBundle\Model\ReadableInterface; +use FOS\MessageBundle\Model\ThreadInterface; use FOS\MessageBundle\ModelManager\ThreadManager as BaseThreadManager; -use FOS\MessageBundle\Model\ParticipantInterface; -use Doctrine\ODM\MongoDB\Query\Builder; /** * Default MongoDB ThreadManager. diff --git a/Entity/MessageMetadata.php b/Entity/MessageMetadata.php index 8ae0ccf9..518af8f6 100644 --- a/Entity/MessageMetadata.php +++ b/Entity/MessageMetadata.php @@ -2,8 +2,8 @@ namespace FOS\MessageBundle\Entity; -use FOS\MessageBundle\Model\MessageMetadata as BaseMessageMetadata; use FOS\MessageBundle\Model\MessageInterface; +use FOS\MessageBundle\Model\MessageMetadata as BaseMessageMetadata; abstract class MessageMetadata extends BaseMessageMetadata { diff --git a/Entity/Thread.php b/Entity/Thread.php index 3f1c192a..0af68ef6 100644 --- a/Entity/Thread.php +++ b/Entity/Thread.php @@ -5,8 +5,8 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use FOS\MessageBundle\Model\MessageInterface; -use FOS\MessageBundle\Model\Thread as BaseThread; use FOS\MessageBundle\Model\ParticipantInterface; +use FOS\MessageBundle\Model\Thread as BaseThread; use FOS\MessageBundle\Model\ThreadMetadata as ModelThreadMetadata; diff --git a/EntityManager/MessageManager.php b/EntityManager/MessageManager.php index cba01273..1755a50f 100644 --- a/EntityManager/MessageManager.php +++ b/EntityManager/MessageManager.php @@ -2,13 +2,13 @@ namespace FOS\MessageBundle\EntityManager; -use FOS\MessageBundle\ModelManager\MessageManager as BaseMessageManager; use Doctrine\ORM\EntityManager; +use Doctrine\ORM\Query\Builder; use FOS\MessageBundle\Model\MessageInterface; -use FOS\MessageBundle\Model\ReadableInterface; use FOS\MessageBundle\Model\ParticipantInterface; +use FOS\MessageBundle\Model\ReadableInterface; use FOS\MessageBundle\Model\ThreadInterface; -use Doctrine\ORM\Query\Builder; +use FOS\MessageBundle\ModelManager\MessageManager as BaseMessageManager; /** * Default ORM MessageManager. diff --git a/EntityManager/ThreadManager.php b/EntityManager/ThreadManager.php index 65929f17..de7fe34a 100644 --- a/EntityManager/ThreadManager.php +++ b/EntityManager/ThreadManager.php @@ -2,12 +2,12 @@ namespace FOS\MessageBundle\EntityManager; -use FOS\MessageBundle\ModelManager\ThreadManager as BaseThreadManager; use Doctrine\ORM\EntityManager; -use FOS\MessageBundle\Model\ThreadInterface; -use FOS\MessageBundle\Model\ReadableInterface; -use FOS\MessageBundle\Model\ParticipantInterface; use Doctrine\ORM\Query\Builder; +use FOS\MessageBundle\Model\ParticipantInterface; +use FOS\MessageBundle\Model\ReadableInterface; +use FOS\MessageBundle\Model\ThreadInterface; +use FOS\MessageBundle\ModelManager\ThreadManager as BaseThreadManager; /** * Default ORM ThreadManager. diff --git a/Event/MessageEvent.php b/Event/MessageEvent.php index df553ec7..5fcde541 100644 --- a/Event/MessageEvent.php +++ b/Event/MessageEvent.php @@ -2,10 +2,10 @@ namespace FOS\MessageBundle\Event; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\EventDispatcher\Event; use FOS\MessageBundle\Model\MessageInterface; use FOS\MessageBundle\Model\ThreadInterface; +use Symfony\Component\EventDispatcher\Event; +use Symfony\Component\HttpKernel\HttpKernelInterface; class MessageEvent extends ThreadEvent { diff --git a/Event/ReadableEvent.php b/Event/ReadableEvent.php index b7340d78..30d65175 100644 --- a/Event/ReadableEvent.php +++ b/Event/ReadableEvent.php @@ -2,9 +2,9 @@ namespace FOS\MessageBundle\Event; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\EventDispatcher\Event; use FOS\MessageBundle\Model\ReadableInterface; +use Symfony\Component\EventDispatcher\Event; +use Symfony\Component\HttpKernel\HttpKernelInterface; class ReadableEvent extends Event { diff --git a/Event/ThreadEvent.php b/Event/ThreadEvent.php index 76c9807d..bfcd0f4a 100644 --- a/Event/ThreadEvent.php +++ b/Event/ThreadEvent.php @@ -2,9 +2,9 @@ namespace FOS\MessageBundle\Event; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\EventDispatcher\Event; use FOS\MessageBundle\Model\ThreadInterface; +use Symfony\Component\EventDispatcher\Event; +use Symfony\Component\HttpKernel\HttpKernelInterface; class ThreadEvent extends Event { diff --git a/FormFactory/AbstractMessageFormFactory.php b/FormFactory/AbstractMessageFormFactory.php index 49806c0b..e742ab7a 100644 --- a/FormFactory/AbstractMessageFormFactory.php +++ b/FormFactory/AbstractMessageFormFactory.php @@ -2,7 +2,6 @@ namespace FOS\MessageBundle\FormFactory; -use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormFactoryInterface; use FOS\MessageBundle\FormModel\AbstractMessage; @@ -21,11 +20,11 @@ abstract class AbstractMessageFormFactory protected $formFactory; /** - * The message form type + * The message form class * - * @var AbstractType + * @var string */ - protected $formType; + protected $formClass; /** * The name of the form @@ -41,10 +40,10 @@ abstract class AbstractMessageFormFactory */ protected $messageClass; - public function __construct(FormFactoryInterface $formFactory, AbstractType $formType, $formName, $messageClass) + public function __construct(FormFactoryInterface $formFactory, $formClass, $formName, $messageClass) { $this->formFactory = $formFactory; - $this->formType = $formType; + $this->formClass = $formClass; $this->formName = $formName; $this->messageClass = $messageClass; } diff --git a/FormFactory/NewThreadMessageFormFactory.php b/FormFactory/NewThreadMessageFormFactory.php index 5e00668f..423b681a 100644 --- a/FormFactory/NewThreadMessageFormFactory.php +++ b/FormFactory/NewThreadMessageFormFactory.php @@ -18,6 +18,6 @@ public function create() { $message = $this->createModelInstance(); - return $this->formFactory->createNamed($this->formName, $this->formType, $message); + return $this->formFactory->createNamed($this->formName, $this->formClass, $message); } } diff --git a/FormFactory/ReplyMessageFormFactory.php b/FormFactory/ReplyMessageFormFactory.php index cc24ed9a..d70e9c3a 100644 --- a/FormFactory/ReplyMessageFormFactory.php +++ b/FormFactory/ReplyMessageFormFactory.php @@ -22,6 +22,6 @@ public function create(ThreadInterface $thread) $message = $this->createModelInstance(); $message->setThread($thread); - return $this->formFactory->createNamed($this->formName, $this->formType, $message); + return $this->formFactory->createNamed($this->formName, $this->formClass, $message); } } diff --git a/FormHandler/AbstractMessageFormHandler.php b/FormHandler/AbstractMessageFormHandler.php index 07a8ad73..ddf45901 100644 --- a/FormHandler/AbstractMessageFormHandler.php +++ b/FormHandler/AbstractMessageFormHandler.php @@ -2,12 +2,13 @@ namespace FOS\MessageBundle\FormHandler; +use FOS\MessageBundle\Model\MessageInterface; use Symfony\Component\Form\Form; -use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; use FOS\MessageBundle\Composer\ComposerInterface; use FOS\MessageBundle\FormModel\AbstractMessage; -use FOS\MessageBundle\Security\ParticipantProviderInterface; use FOS\MessageBundle\Model\ParticipantInterface; +use FOS\MessageBundle\Security\ParticipantProviderInterface; use FOS\MessageBundle\Sender\SenderInterface; /** @@ -22,9 +23,9 @@ abstract class AbstractMessageFormHandler protected $sender; protected $participantProvider; - public function __construct(Request $request, ComposerInterface $composer, SenderInterface $sender, ParticipantProviderInterface $participantProvider) + public function __construct(RequestStack $requestStack, ComposerInterface $composer, SenderInterface $sender, ParticipantProviderInterface $participantProvider) { - $this->request = $request; + $this->request = $requestStack->getCurrentRequest(); $this->composer = $composer; $this->sender = $sender; $this->participantProvider = $participantProvider; @@ -42,7 +43,7 @@ public function process(Form $form) return false; } - $form->bind($this->request); + $form->handleRequest($this->request); if ($form->isValid()) { return $this->processValidForm($form); diff --git a/FormType/NewThreadMessageFormType.php b/FormType/NewThreadMessageFormType.php index 772e6921..cbb01f3b 100644 --- a/FormType/NewThreadMessageFormType.php +++ b/FormType/NewThreadMessageFormType.php @@ -2,9 +2,12 @@ namespace FOS\MessageBundle\FormType; +use FOS\UserBundle\Form\Type\UsernameFormType; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; /** * Message form type for starting a new conversation @@ -16,19 +19,19 @@ class NewThreadMessageFormType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('recipient', 'fos_user_username', array('label' => 'recipient', 'translation_domain' => 'FOSMessageBundle')) - ->add('subject', 'text', array('label' => 'subject', 'translation_domain' => 'FOSMessageBundle')) - ->add('body', 'textarea', array('label' => 'body', 'translation_domain' => 'FOSMessageBundle')); + ->add('recipient', UsernameFormType::class, array('label' => 'recipient', 'translation_domain' => 'FOSMessageBundle')) + ->add('subject', TextType::class, array('label' => 'subject', 'translation_domain' => 'FOSMessageBundle')) + ->add('body', TextareaType::class, array('label' => 'body', 'translation_domain' => 'FOSMessageBundle')); } - public function setDefaultOptions(OptionsResolverInterface $resolver) + public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'intention' => 'message', )); } - public function getName() + public function getBlockPrefix() { return 'fos_message_new_thread'; } diff --git a/FormType/NewThreadMultipleMessageFormType.php b/FormType/NewThreadMultipleMessageFormType.php index a9836baf..47d63e89 100644 --- a/FormType/NewThreadMultipleMessageFormType.php +++ b/FormType/NewThreadMultipleMessageFormType.php @@ -1,8 +1,10 @@ add('recipients', 'recipients_selector', array('label' => 'recipients', 'translation_domain' => 'FOSMessageBundle')) - ->add('subject', 'text', array('label' => 'subject', 'translation_domain' => 'FOSMessageBundle')) - ->add('body', 'textarea', array('label' => 'body', 'translation_domain' => 'FOSMessageBundle')); + ->add('recipients', RecipientsType::class, array('label' => 'recipients', 'translation_domain' => 'FOSMessageBundle')) + ->add('subject', TextType::class, array('label' => 'subject', 'translation_domain' => 'FOSMessageBundle')) + ->add('body', TextareaType::class, array('label' => 'body', 'translation_domain' => 'FOSMessageBundle')); } - public function getName() + public function getBlockPrefix() { return 'fos_message_new_multiperson_thread'; } diff --git a/FormType/RecipientsType.php b/FormType/RecipientsType.php index d8cc7090..53462171 100644 --- a/FormType/RecipientsType.php +++ b/FormType/RecipientsType.php @@ -1,11 +1,12 @@ setDefaults(array( 'invalid_message' => 'The selected recipient does not exist', @@ -50,13 +51,13 @@ public function setDefaultOptions(OptionsResolverInterface $resolver) */ public function getParent() { - return 'text'; + return TextType::class; } /** * {@inheritDoc} */ - public function getName() + public function getBlockPrefix() { return 'recipients_selector'; } diff --git a/FormType/ReplyMessageFormType.php b/FormType/ReplyMessageFormType.php index c2780ba4..f7dda0b5 100644 --- a/FormType/ReplyMessageFormType.php +++ b/FormType/ReplyMessageFormType.php @@ -3,8 +3,9 @@ namespace FOS\MessageBundle\FormType; use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; /** * Form type for a reply @@ -16,17 +17,17 @@ class ReplyMessageFormType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('body', 'textarea', array('label' => 'body', 'translation_domain' => 'FOSMessageBundle')); + ->add('body', TextareaType::class, array('label' => 'body', 'translation_domain' => 'FOSMessageBundle')); } - public function setDefaultOptions(OptionsResolverInterface $resolver) + public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'intention' => 'reply', )); } - public function getName() + public function getBlockPrefix() { return 'fos_message_reply_message'; } diff --git a/MessageBuilder/NewThreadMessageBuilder.php b/MessageBuilder/NewThreadMessageBuilder.php index 6cd13d5e..dfadbf32 100644 --- a/MessageBuilder/NewThreadMessageBuilder.php +++ b/MessageBuilder/NewThreadMessageBuilder.php @@ -2,10 +2,10 @@ namespace FOS\MessageBundle\MessageBuilder; +use Doctrine\Common\Collections\Collection; use FOS\MessageBundle\Model\MessageInterface; use FOS\MessageBundle\Model\ParticipantInterface; use FOS\MessageBundle\Sender\SenderInterface; -use Doctrine\Common\Collections\Collection; /** * Fluent interface message builder for new thread messages diff --git a/MessageBuilder/ReplyMessageBuilder.php b/MessageBuilder/ReplyMessageBuilder.php index 964a0135..b1deb553 100644 --- a/MessageBuilder/ReplyMessageBuilder.php +++ b/MessageBuilder/ReplyMessageBuilder.php @@ -4,8 +4,8 @@ use FOS\MessageBundle\Model\MessageInterface; use FOS\MessageBundle\Model\ParticipantInterface; -use FOS\MessageBundle\Sender\SenderInterface; use FOS\MessageBundle\Model\ThreadInterface; +use FOS\MessageBundle\Sender\SenderInterface; /** * Fluent interface message builder for reply to a thread diff --git a/ModelManager/ReadableManagerInterface.php b/ModelManager/ReadableManagerInterface.php index 94b90868..8df5633a 100644 --- a/ModelManager/ReadableManagerInterface.php +++ b/ModelManager/ReadableManagerInterface.php @@ -2,8 +2,8 @@ namespace FOS\MessageBundle\ModelManager; -use FOS\MessageBundle\Model\ReadableInterface; use FOS\MessageBundle\Model\ParticipantInterface; +use FOS\MessageBundle\Model\ReadableInterface; /** * Capable of updating the read state of objects directly in the storage, diff --git a/Provider/Provider.php b/Provider/Provider.php index 55fe1ce6..232d308b 100644 --- a/Provider/Provider.php +++ b/Provider/Provider.php @@ -2,13 +2,13 @@ namespace FOS\MessageBundle\Provider; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Symfony\Component\Security\Core\Exception\AccessDeniedException; +use FOS\MessageBundle\ModelManager\MessageManagerInterface; use FOS\MessageBundle\ModelManager\ThreadManagerInterface; -use FOS\MessageBundle\Security\AuthorizerInterface; use FOS\MessageBundle\Reader\ReaderInterface; +use FOS\MessageBundle\Security\AuthorizerInterface; use FOS\MessageBundle\Security\ParticipantProviderInterface; -use FOS\MessageBundle\ModelManager\MessageManagerInterface; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Symfony\Component\Security\Core\Exception\AccessDeniedException; /** * Provides threads for the current authenticated user diff --git a/Reader/Reader.php b/Reader/Reader.php index 1ddcf463..1bd72e1e 100644 --- a/Reader/Reader.php +++ b/Reader/Reader.php @@ -2,11 +2,11 @@ namespace FOS\MessageBundle\Reader; -use FOS\MessageBundle\Security\ParticipantProviderInterface; -use FOS\MessageBundle\Model\ReadableInterface; -use FOS\MessageBundle\ModelManager\ReadableManagerInterface; use FOS\MessageBundle\Event\FOSMessageEvents; use FOS\MessageBundle\Event\ReadableEvent; +use FOS\MessageBundle\Model\ReadableInterface; +use FOS\MessageBundle\ModelManager\ReadableManagerInterface; +use FOS\MessageBundle\Security\ParticipantProviderInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** diff --git a/Resources/config/config.xml b/Resources/config/config.xml index 89291466..8734dd5a 100644 --- a/Resources/config/config.xml +++ b/Resources/config/config.xml @@ -18,7 +18,7 @@ - + @@ -58,8 +58,8 @@ - - + + diff --git a/Resources/config/form.xml b/Resources/config/form.xml index 45524a66..66efaf1f 100644 --- a/Resources/config/form.xml +++ b/Resources/config/form.xml @@ -6,42 +6,38 @@ - - - - - + %fos_message.new_thread_form.class% %fos_message.new_thread_form.name% %fos_message.new_thread_form.model% - + %fos_message.reply_form.class% %fos_message.reply_form.name% %fos_message.reply_form.model% - - + + - - + + - - + + diff --git a/Resources/config/routing.xml b/Resources/config/routing.xml index d4329c05..0416272d 100644 --- a/Resources/config/routing.xml +++ b/Resources/config/routing.xml @@ -4,37 +4,37 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> - + FOSMessageBundle:Message:inbox - + FOSMessageBundle:Message:sent - + FOSMessageBundle:Message:deleted - + FOSMessageBundle:Message:search - + FOSMessageBundle:Message:newThread - + FOSMessageBundle:Message:delete - POST|DELETE + POST DELETE - + FOSMessageBundle:Message:undelete - POST + POST - + FOSMessageBundle:Message:thread diff --git a/Resources/config/spam_detection.xml b/Resources/config/spam_detection.xml index 8e0e27d2..e1edd393 100644 --- a/Resources/config/spam_detection.xml +++ b/Resources/config/spam_detection.xml @@ -8,7 +8,7 @@ - + diff --git a/Resources/config/validator.xml b/Resources/config/validator.xml index a7f111fb..4126a42c 100644 --- a/Resources/config/validator.xml +++ b/Resources/config/validator.xml @@ -17,7 +17,7 @@ - + diff --git a/Resources/doc/90-sending-a-message-programatically.md b/Resources/doc/90-sending-a-message-programatically.md index fa0ca0c3..db010c50 100644 --- a/Resources/doc/90-sending-a-message-programatically.md +++ b/Resources/doc/90-sending-a-message-programatically.md @@ -18,7 +18,7 @@ This is probably all you will need in many cases. To compose a message we retrieve the composer service and compose our message: ```php - $sender = $this->get('security.context')->getToken()->getUser(); + $sender = $this->get('security.token_storage')->getToken()->getUser(); $threadBuilder = $this->get('fos_message.composer')->newThread(); $threadBuilder ->addRecipient($recipient) // Retrieved from your backend, your user manager or ... diff --git a/Resources/translations/FOSMessageBundle.cs.yml b/Resources/translations/FOSMessageBundle.cs.yml new file mode 100644 index 00000000..d505ef2f --- /dev/null +++ b/Resources/translations/FOSMessageBundle.cs.yml @@ -0,0 +1,27 @@ +messenger: Zprávy +inbox: Přijaté +sent: Odeslané +deleted: Smazané +send_new: Poslat novou zprávu +search: Hledat +threads_found: "{1}Nalezena %num% konverzace s|[2,4]Nalezeny %num% konverzace s|[5,Inf]Nalezeno %count% konverzací s" + +message_info: Od %sender% z %date% +reply: Odpovědět + +subject: Předmět +starter: Započal +startdate: Začátek +messages: Zprávy +last_message: Poslední zpráva +actions: Akce +new: Nová +goto_last: Jít na poslední zprávu +on: Z %date% +by: Od %sender% +no_thread: Žádná konverzace ke zobrazení +delete: Smazat +undelete: Obnovit +recipient: Příjemce +recipients: Příjemci +body: Obsah diff --git a/Resources/translations/FOSMessageBundle.en.yml b/Resources/translations/FOSMessageBundle.en.yml index 816a4723..d8923642 100644 --- a/Resources/translations/FOSMessageBundle.en.yml +++ b/Resources/translations/FOSMessageBundle.en.yml @@ -11,7 +11,7 @@ reply: Reply subject: Subject starter: Starter -startdate: StartDate +startdate: Start date messages: Messages last_message: Last message actions: Actions diff --git a/Search/QueryFactory.php b/Search/QueryFactory.php index a735205c..dc871d4f 100644 --- a/Search/QueryFactory.php +++ b/Search/QueryFactory.php @@ -3,6 +3,7 @@ namespace FOS\MessageBundle\Search; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; /** * Gets the search term from the request and prepares it @@ -24,12 +25,12 @@ class QueryFactory implements QueryFactoryInterface /** * Instanciates a new TermGetter * - * @param Request $request + * @param RequestStack $requestStack * @param string $queryParameter */ - public function __construct(Request $request, $queryParameter) + public function __construct(RequestStack $requestStack, $queryParameter) { - $this->request = $request; + $this->request = $requestStack->getCurrentRequest(); $this->queryParameter = $queryParameter; } diff --git a/Security/Authorizer.php b/Security/Authorizer.php index 432af194..e2c5e08f 100644 --- a/Security/Authorizer.php +++ b/Security/Authorizer.php @@ -2,10 +2,10 @@ namespace FOS\MessageBundle\Security; -use FOS\MessageBundle\Model\ThreadInterface; -use Symfony\Component\Security\Core\Exception\AccessDeniedException; use FOS\MessageBundle\Model\ParticipantInterface; +use FOS\MessageBundle\Model\ThreadInterface; use FOS\MessageBundle\Security\ParticipantProviderInterface; +use Symfony\Component\Security\Core\Exception\AccessDeniedException; /** * Manages permissions to manipulate threads and messages diff --git a/Security/AuthorizerInterface.php b/Security/AuthorizerInterface.php index f4ec91ec..0de44910 100644 --- a/Security/AuthorizerInterface.php +++ b/Security/AuthorizerInterface.php @@ -2,8 +2,8 @@ namespace FOS\MessageBundle\Security; -use FOS\MessageBundle\Model\ThreadInterface; use FOS\MessageBundle\Model\ParticipantInterface; +use FOS\MessageBundle\Model\ThreadInterface; /** * Manages permissions to manipulate threads and messages diff --git a/Security/ParticipantProvider.php b/Security/ParticipantProvider.php index f1fd7b70..27a9cf45 100644 --- a/Security/ParticipantProvider.php +++ b/Security/ParticipantProvider.php @@ -2,9 +2,9 @@ namespace FOS\MessageBundle\Security; -use Symfony\Component\Security\Core\SecurityContextInterface; -use Symfony\Component\Security\Core\Exception\AccessDeniedException; use FOS\MessageBundle\Model\ParticipantInterface; +use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; +use Symfony\Component\Security\Core\Exception\AccessDeniedException; /** * Provides the authenticated participant @@ -14,15 +14,15 @@ class ParticipantProvider implements ParticipantProviderInterface { /** - * The security context + * The token storage * - * @var SecurityContextInterface + * @var TokenStorageInterface */ - protected $securityContext; + protected $tokenStorage; - public function __construct(SecurityContextInterface $securityContext) + public function __construct(TokenStorageInterface $tokenStorage) { - $this->securityContext = $securityContext; + $this->tokenStorage = $tokenStorage; } /** @@ -32,7 +32,7 @@ public function __construct(SecurityContextInterface $securityContext) */ public function getAuthenticatedParticipant() { - $participant = $this->securityContext->getToken()->getUser(); + $participant = $this->tokenStorage->getToken()->getUser(); if (!$participant instanceof ParticipantInterface) { throw new AccessDeniedException('Must be logged in with a ParticipantInterface instance'); diff --git a/Sender/Sender.php b/Sender/Sender.php index 5fa3cc33..2af463f4 100644 --- a/Sender/Sender.php +++ b/Sender/Sender.php @@ -2,11 +2,11 @@ namespace FOS\MessageBundle\Sender; +use FOS\MessageBundle\Event\FOSMessageEvents; +use FOS\MessageBundle\Event\MessageEvent; +use FOS\MessageBundle\Model\MessageInterface; use FOS\MessageBundle\ModelManager\MessageManagerInterface; use FOS\MessageBundle\ModelManager\ThreadManagerInterface; -use FOS\MessageBundle\Model\MessageInterface; -use FOS\MessageBundle\Event\MessageEvent; -use FOS\MessageBundle\Event\FOSMessageEvents; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** diff --git a/SpamDetection/AkismetSpamDetector.php b/SpamDetection/AkismetSpamDetector.php index 6bba9bd8..c4e2e897 100644 --- a/SpamDetection/AkismetSpamDetector.php +++ b/SpamDetection/AkismetSpamDetector.php @@ -2,9 +2,9 @@ namespace FOS\MessageBundle\SpamDetection; -use Ornicar\AkismetBundle\Akismet\AkismetInterface; use FOS\MessageBundle\FormModel\NewThreadMessage; use FOS\MessageBundle\Security\ParticipantProviderInterface; +use Ornicar\AkismetBundle\Akismet\AkismetInterface; class AkismetSpamDetector implements SpamDetectorInterface { diff --git a/Tests/Document/ThreadDenormalizerTest.php b/Tests/Document/ThreadDenormalizerTest.php index 2051998a..cf791920 100644 --- a/Tests/Document/ThreadDenormalizerTest.php +++ b/Tests/Document/ThreadDenormalizerTest.php @@ -3,9 +3,9 @@ namespace FOS\MessageBundle\Document; use DateTime; -use FOS\MessageBundle\Model\ParticipantInterface; use Doctrine\Common\Collections\ArrayCollection; use FOS\MessageBundle\Model\MessageInterface; +use FOS\MessageBundle\Model\ParticipantInterface; class ThreadDenormalizerTest extends \PHPUnit_Framework_TestCase { diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php index 70526bb5..88a46abb 100644 --- a/Tests/bootstrap.php +++ b/Tests/bootstrap.php @@ -1,7 +1,7 @@