diff --git a/.php_cs b/.php_cs
new file mode 100644
index 00000000..a8c78047
--- /dev/null
+++ b/.php_cs
@@ -0,0 +1,10 @@
+exclude('Resources')
+ ->in(__DIR__)
+;
+
+return Symfony\CS\Config::create()
+ ->finder($finder)
+;
diff --git a/.travis.yml b/.travis.yml
index 4a33db1e..23aff848 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,30 +1,45 @@
language: php
-php:
- - 5.3
- - 5.4
- - 5.5
- - 5.6
- - hhvm
+sudo: false
-env:
- - SYMFONY_VERSION=2.1.*
- - SYMFONY_VERSION=2.2.*
- - SYMFONY_VERSION=2.3.*
- - SYMFONY_VERSION=dev-master
+branches:
+ only:
+ - master
+
+matrix:
+ include:
+ - php: 5.3
+ env:
+ - deps=low
+ - SYMFONY_VERSION=2.7.*
+ - php: 5.4
+ env:
+ - deps=high
+ - SYMFONY_VERSION=2.7.*
+ - php: 5.5
+ env:
+ - deps=low
+ - SYMFONY_VERSION=2.8.*
+ - php: 5.6
+ env:
+ - deps=high
+ - SYMFONY_VERSION=3.0.*
+ - php: 7.0
+ env:
+ - deps=low
+ - SYMFONY_VERSION=3.1.*
+ - php: 7.1
+ env:
+ - deps=high
+ - SYMFONY_VERSION=3.1.*
before_script:
- composer require symfony/framework-bundle:${SYMFONY_VERSION} --no-update
- - composer update --dev
+ - if [[ $deps = high ]]; then composer update --no-progress --ansi; fi
+ - if [[ $deps = low ]]; then composer update --no-progress --ansi --prefer-lowest --prefer-stable; fi
script: phpunit --coverage-text
notifications:
email:
- friendsofsymfony-dev@googlegroups.com
-
-matrix:
- allow_failures:
- - env: SYMFONY_VERSION=dev-master
- - php: 5.6
- - php: hhvm
diff --git a/Command/MongoDBMigrateMetadataCommand.php b/Command/MongoDBMigrateMetadataCommand.php
index d8fe41dd..3a14fce9 100644
--- a/Command/MongoDBMigrateMetadataCommand.php
+++ b/Command/MongoDBMigrateMetadataCommand.php
@@ -110,7 +110,8 @@ protected function initialize(InputInterface $input, OutputInterface $output)
'fsync' => $input->getOption('fsync'),
);
- $this->printStatusCallback = function() {};
+ $this->printStatusCallback = function () {
+ };
register_tick_function(array($this, 'printStatus'));
}
@@ -128,7 +129,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
/**
- * Migrate message documents
+ * Migrate message documents.
*/
private function migrateMessages(OutputInterface $output)
{
@@ -145,10 +146,11 @@ private function migrateMessages(OutputInterface $output)
if (!$numTotal = $cursor->count()) {
$output->writeln('There are no message documents to migrate.');
+
return;
}
- $this->printStatusCallback = function() use ($output, &$numProcessed, $numTotal) {
+ $this->printStatusCallback = function () use ($output, &$numProcessed, $numTotal) {
$output->write(sprintf("Processed: %d / Complete: %d%%\r", $numProcessed, round(100 * ($numProcessed / $numTotal))));
};
@@ -169,12 +171,12 @@ private function migrateMessages(OutputInterface $output)
}
}
- $output->write(str_repeat(' ', 28 + ceil(log10($numProcessed))) . "\r");
+ $output->write(str_repeat(' ', 28 + ceil(log10($numProcessed)))."\r");
$output->writeln(sprintf('Migrated %d message documents.', $numProcessed));
}
/**
- * Migrate thread documents
+ * Migrate thread documents.
*/
private function migrateThreads(OutputInterface $output)
{
@@ -194,10 +196,11 @@ private function migrateThreads(OutputInterface $output)
if (!$numTotal = $cursor->count()) {
$output->writeln('There are no thread documents to migrate.');
+
return;
}
- $this->printStatusCallback = function() use ($output, &$numProcessed, $numTotal) {
+ $this->printStatusCallback = function () use ($output, &$numProcessed, $numTotal) {
$output->write(sprintf("Processed: %d / Complete: %d%%\r", $numProcessed, round(100 * ($numProcessed / $numTotal))));
};
@@ -222,7 +225,7 @@ private function migrateThreads(OutputInterface $output)
}
}
- $output->write(str_repeat(' ', 28 + ceil(log10($numProcessed))) . "\r");
+ $output->write(str_repeat(' ', 28 + ceil(log10($numProcessed)))."\r");
$output->writeln(sprintf('Migrated %d thread documents.', $numProcessed));
}
@@ -250,6 +253,7 @@ private function createMessageMetadata(array &$message)
* Sets the unreadForParticipants array on the message.
*
* @see Message::doEnsureUnreadForParticipantsArray()
+ *
* @param array &$message
*/
private function createMessageUnreadForParticipants(array &$message)
@@ -328,6 +332,7 @@ private function createThreadLastMessageDate(array &$thread)
* Sets the active participant arrays on the thread.
*
* @see Thread::doEnsureActiveParticipantArrays()
+ *
* @param array $thread
*/
private function createThreadActiveParticipantArrays(array &$thread)
@@ -386,11 +391,13 @@ private function createThreadActiveParticipantArrays(array &$thread)
}
/**
- * Get the MongoCollection for the given class
+ * Get the MongoCollection for the given class.
*
* @param ManagerRegistry $registry
* @param string $class
+ *
* @return \MongoCollection
+ *
* @throws \RuntimeException if the class has no DocumentManager
*/
private function getMongoCollectionForClass(ManagerRegistry $registry, $class)
@@ -403,7 +410,7 @@ private function getMongoCollectionForClass(ManagerRegistry $registry, $class)
}
/**
- * Invokes the print status callback
+ * Invokes the print status callback.
*
* Since unregister_tick_function() does not support anonymous functions, it
* is easier to register one method (this) and invoke a dynamic callback.
diff --git a/Composer/Composer.php b/Composer/Composer.php
index b76a9e02..b9850c2e 100644
--- a/Composer/Composer.php
+++ b/Composer/Composer.php
@@ -3,28 +3,27 @@
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;
/**
- * Factory for message builders
+ * Factory for message builders.
*
* @author Thibault Duplessis
*/
class Composer implements ComposerInterface
{
/**
- * Message manager
+ * Message manager.
*
* @var MessageManagerInterface
*/
protected $messageManager;
/**
- * Thread manager
+ * Thread manager.
*
* @var ThreadManagerInterface
*/
@@ -37,7 +36,7 @@ public function __construct(MessageManagerInterface $messageManager, ThreadManag
}
/**
- * Starts composing a message, starting a new thread
+ * Starts composing a message, starting a new thread.
*
* @return NewThreadMessageBuilder
*/
@@ -50,7 +49,7 @@ public function newThread()
}
/**
- * Starts composing a message in a reply to a thread
+ * Starts composing a message in a reply to a thread.
*
* @return ReplyMessageBuilder
*/
diff --git a/Composer/ComposerInterface.php b/Composer/ComposerInterface.php
index 8b9b9ef2..a4ca6a33 100644
--- a/Composer/ComposerInterface.php
+++ b/Composer/ComposerInterface.php
@@ -6,21 +6,21 @@
use FOS\MessageBundle\Model\ThreadInterface;
/**
- * Factory for message builders
+ * Factory for message builders.
*
* @author Thibault Duplessis
*/
interface ComposerInterface
{
/**
- * Starts composing a message, starting a new thread
+ * Starts composing a message, starting a new thread.
*
* @return AbstractMessageBuilder
*/
public function newThread();
/**
- * Starts composing a message in a reply to a thread
+ * Starts composing a message in a reply to a thread.
*
* @return AbstractMessageBuilder
*/
diff --git a/Controller/MessageController.php b/Controller/MessageController.php
index ffb9f8a5..8d9c52e7 100644
--- a/Controller/MessageController.php
+++ b/Controller/MessageController.php
@@ -2,15 +2,21 @@
namespace FOS\MessageBundle\Controller;
-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
{
/**
- * Displays the authenticated participant inbox
+ * @var ContainerInterface
+ */
+ protected $container;
+
+ /**
+ * Displays the authenticated participant inbox.
*
* @return Response
*/
@@ -19,12 +25,12 @@ public function inboxAction()
$threads = $this->getProvider()->getInboxThreads();
return $this->container->get('templating')->renderResponse('FOSMessageBundle:Message:inbox.html.twig', array(
- 'threads' => $threads
+ 'threads' => $threads,
));
}
/**
- * Displays the authenticated participant messages sent
+ * Displays the authenticated participant messages sent.
*
* @return Response
*/
@@ -33,12 +39,12 @@ public function sentAction()
$threads = $this->getProvider()->getSentThreads();
return $this->container->get('templating')->renderResponse('FOSMessageBundle:Message:sent.html.twig', array(
- 'threads' => $threads
+ 'threads' => $threads,
));
}
/**
- * Displays the authenticated participant deleted threads
+ * Displays the authenticated participant deleted threads.
*
* @return Response
*/
@@ -47,15 +53,15 @@ public function deletedAction()
$threads = $this->getProvider()->getDeletedThreads();
return $this->container->get('templating')->renderResponse('FOSMessageBundle:Message:deleted.html.twig', array(
- 'threads' => $threads
+ 'threads' => $threads,
));
}
/**
- * Displays a thread, also allows to reply to it
+ * Displays a thread, also allows to reply to it.
*
* @param string $threadId the thread id
- *
+ *
* @return Response
*/
public function threadAction($threadId)
@@ -66,18 +72,18 @@ public function threadAction($threadId)
if ($message = $formHandler->process($form)) {
return new RedirectResponse($this->container->get('router')->generate('fos_message_thread_view', array(
- 'threadId' => $message->getThread()->getId()
+ 'threadId' => $message->getThread()->getId(),
)));
}
return $this->container->get('templating')->renderResponse('FOSMessageBundle:Message:thread.html.twig', array(
'form' => $form->createView(),
- 'thread' => $thread
+ 'thread' => $thread,
));
}
/**
- * Create a new message thread
+ * Create a new message thread.
*
* @return Response
*/
@@ -88,21 +94,21 @@ public function newThreadAction()
if ($message = $formHandler->process($form)) {
return new RedirectResponse($this->container->get('router')->generate('fos_message_thread_view', array(
- 'threadId' => $message->getThread()->getId()
+ 'threadId' => $message->getThread()->getId(),
)));
}
return $this->container->get('templating')->renderResponse('FOSMessageBundle:Message:newThread.html.twig', array(
'form' => $form->createView(),
- 'data' => $form->getData()
+ 'data' => $form->getData(),
));
}
/**
- * Deletes a thread
- *
+ * Deletes a thread.
+ *
* @param string $threadId the thread id
- *
+ *
* @return RedirectResponse
*/
public function deleteAction($threadId)
@@ -113,12 +119,12 @@ public function deleteAction($threadId)
return new RedirectResponse($this->container->get('router')->generate('fos_message_inbox'));
}
-
+
/**
- * Undeletes a thread
- *
+ * Undeletes a thread.
+ *
* @param string $threadId
- *
+ *
* @return RedirectResponse
*/
public function undeleteAction($threadId)
@@ -131,7 +137,7 @@ public function undeleteAction($threadId)
}
/**
- * Searches for messages in the inbox and sentbox
+ * Searches for messages in the inbox and sentbox.
*
* @return Response
*/
@@ -142,12 +148,12 @@ public function searchAction()
return $this->container->get('templating')->renderResponse('FOSMessageBundle:Message:search.html.twig', array(
'query' => $query,
- 'threads' => $threads
+ 'threads' => $threads,
));
}
/**
- * Gets the provider service
+ * Gets the provider service.
*
* @return ProviderInterface
*/
@@ -155,4 +161,12 @@ protected function getProvider()
{
return $this->container->get('fos_message.provider');
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setContainer(ContainerInterface $container = null)
+ {
+ $this->container = $container;
+ }
}
diff --git a/DataTransformer/RecipientsDataTransformer.php b/DataTransformer/RecipientsDataTransformer.php
index 50e4356d..9f8cdf86 100644
--- a/DataTransformer/RecipientsDataTransformer.php
+++ b/DataTransformer/RecipientsDataTransformer.php
@@ -1,4 +1,5 @@
*/
@@ -25,7 +27,7 @@ public function __construct(DataTransformerInterface $userToUsernameTransformer)
}
/**
- * Transforms a collection of recipients into a string
+ * Transforms a collection of recipients into a string.
*
* @param Collection $recipients
*
@@ -47,12 +49,13 @@ public function transform($recipients)
}
/**
- * Transforms a string (usernames) to a Collection of UserInterface
+ * Transforms a string (usernames) to a Collection of UserInterface.
*
* @param string $usernames
*
* @throws UnexpectedTypeException
* @throws TransformationFailedException
+ *
* @return Collection $recipients
*/
public function reverseTransform($usernames)
diff --git a/Deleter/Deleter.php b/Deleter/Deleter.php
index 33fa346b..4b6085dc 100644
--- a/Deleter/Deleter.php
+++ b/Deleter/Deleter.php
@@ -12,28 +12,28 @@
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
- * Marks threads as deleted
+ * Marks threads as deleted.
*
* @author Thibault Duplessis
*/
class Deleter implements DeleterInterface
{
/**
- * The authorizer instance
+ * The authorizer instance.
*
* @var AuthorizerInterface
*/
protected $authorizer;
/**
- * The participant provider instance
+ * The participant provider instance.
*
* @var ParticipantProviderInterface
*/
protected $participantProvider;
/**
- * The event dispatcher
+ * The event dispatcher.
*
* @var EventDispatcherInterface
*/
@@ -73,7 +73,7 @@ public function markAsUndeleted(ThreadInterface $thread)
}
/**
- * Gets the current authenticated user
+ * Gets the current authenticated user.
*
* @return ParticipantInterface
*/
diff --git a/Deleter/DeleterInterface.php b/Deleter/DeleterInterface.php
index dc1badf9..3fbcd733 100644
--- a/Deleter/DeleterInterface.php
+++ b/Deleter/DeleterInterface.php
@@ -5,19 +5,19 @@
use FOS\MessageBundle\Model\ThreadInterface;
/**
- * Marks threads as deleted
+ * Marks threads as deleted.
*
* @author Thibault Duplessis
*/
interface DeleterInterface
{
/**
- * Marks the thread as deleted by the current authenticated user
+ * Marks the thread as deleted by the current authenticated user.
*/
public function markAsDeleted(ThreadInterface $thread);
/**
- * Marks the thread as undeleted by the current authenticated user
+ * Marks the thread as undeleted by the current authenticated user.
*/
public function markAsUndeleted(ThreadInterface $thread);
}
diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php
index d2f6ebf5..1b2d8899 100644
--- a/DependencyInjection/Configuration.php
+++ b/DependencyInjection/Configuration.php
@@ -6,7 +6,7 @@
use Symfony\Component\Config\Definition\ConfigurationInterface;
/**
- * This class defines the configuration information for the bundle
+ * This class defines the configuration information for the bundle.
*/
class Configuration implements ConfigurationInterface
{
@@ -50,7 +50,7 @@ public function getConfigTreeBuilder()
->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('type')->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()
@@ -60,7 +60,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('type')->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..8d49218b 100644
--- a/DependencyInjection/FOSMessageExtension.php
+++ b/DependencyInjection/FOSMessageExtension.php
@@ -23,6 +23,7 @@ public function load(array $configs, ContainerBuilder $container)
if (!in_array(strtolower($config['db_driver']), array('orm', 'mongodb'))) {
throw new \InvalidArgumentException(sprintf('Invalid db driver "%s".', $config['db_driver']));
}
+
$loader->load(sprintf('%s.xml', $config['db_driver']));
$loader->load('config.xml');
$loader->load('form.xml');
@@ -51,10 +52,34 @@ 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']);
+ // BC management
+ $newThreadFormType = $config['new_thread_form']['type'];
+ $replyFormType = $config['reply_form']['type'];
+
+ if (!class_exists($newThreadFormType)) {
+ @trigger_error('Using a service reference in configuration key "fos_message.new_thread_form.type" is deprecated since version 1.2 and will be removed in 2.0. Use the class name of your form type instead.', E_USER_DEPRECATED);
+
+ // Old syntax (service reference)
+ $container->setAlias('fos_message.new_thread_form.type', $newThreadFormType);
+ } else {
+ // New syntax (class name)
+ $container->getDefinition('fos_message.new_thread_form.factory.default')
+ ->replaceArgument(1, $newThreadFormType);
+ }
+
+ if (!class_exists($replyFormType)) {
+ @trigger_error('Using a service reference in configuration key "fos_message.reply_form.type" is deprecated since version 1.2 and will be removed in 2.0. Use the class name of your form type instead.', E_USER_DEPRECATED);
+
+ // Old syntax (service reference)
+ $container->setAlias('fos_message.reply_form.type', $replyFormType);
+ } else {
+ // New syntax (class name)
+ $container->getDefinition('fos_message.reply_form.factory.default')
+ ->replaceArgument(1, $replyFormType);
+ }
+
$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/Message.php b/Document/Message.php
index 7f49e0ea..c92760ff 100644
--- a/Document/Message.php
+++ b/Document/Message.php
@@ -8,9 +8,9 @@ abstract class Message extends BaseMessage
{
/**
* Tells if the message is spam or flood
- * This denormalizes Thread.isSpam
+ * This denormalizes Thread.isSpam.
*
- * @var boolean
+ * @var bool
*/
protected $isSpam = false;
@@ -23,11 +23,11 @@ abstract class Message extends BaseMessage
protected $unreadForParticipants = array();
/**
- * @param boolean $isSpam
+ * @param bool $isSpam
*/
public function setIsSpam($isSpam)
{
- $this->isSpam = (boolean) $isSpam;
+ $this->isSpam = (bool) $isSpam;
}
/*
@@ -37,7 +37,7 @@ public function setIsSpam($isSpam)
*/
/**
- * Performs denormalization tricks
+ * Performs denormalization tricks.
*/
public function denormalize()
{
@@ -46,7 +46,7 @@ public function denormalize()
}
/**
- * Ensures that the sender is considered to have read this message
+ * Ensures that the sender is considered to have read this message.
*/
protected function doSenderIsRead()
{
diff --git a/Document/Thread.php b/Document/Thread.php
index f19571c4..bfba710b 100644
--- a/Document/Thread.php
+++ b/Document/Thread.php
@@ -8,7 +8,7 @@
abstract class Thread extends AbstractThread
{
/**
- * Date that the last message in this thread was created at
+ * Date that the last message in this thread was created at.
*
* This denormalization field is used for sorting threads in the inbox and
* sent list.
@@ -19,7 +19,7 @@ abstract class Thread extends AbstractThread
/**
* All text contained in the thread messages
- * Used for the full text search
+ * Used for the full text search.
*
* @var string
*/
@@ -52,7 +52,7 @@ abstract class Thread extends AbstractThread
protected $activeSenders = array();
/**
- * Gets the users participating in this conversation
+ * Gets the users participating in this conversation.
*
* @return ParticipantInterface[]
*/
@@ -66,7 +66,6 @@ public function getParticipants()
* If it already exists, nothing is done.
*
* @param ParticipantInterface $participant
- * @return void
*/
public function addParticipant(ParticipantInterface $participant)
{
@@ -76,10 +75,11 @@ public function addParticipant(ParticipantInterface $participant)
}
/**
- * Tells if the user participates to the conversation
+ * Tells if the user participates to the conversation.
*
* @param ParticipantInterface $participant
- * @return boolean
+ *
+ * @return bool
*/
public function isParticipant(ParticipantInterface $participant)
{
@@ -93,7 +93,7 @@ public function isParticipant(ParticipantInterface $participant)
*/
/**
- * Performs denormalization tricks
+ * Performs denormalization tricks.
*/
public function denormalize()
{
@@ -106,7 +106,7 @@ public function denormalize()
}
/**
- * Ensures that the createdBy & createdAt properties are set
+ * Ensures that the createdBy & createdAt properties are set.
*/
protected function doCreatedByAndAt()
{
@@ -123,7 +123,7 @@ protected function doCreatedByAndAt()
}
/**
- * Ensures that the lastMessageDate property is up to date
+ * Ensures that the lastMessageDate property is up to date.
*/
protected function doLastMessageDate()
{
@@ -135,7 +135,7 @@ protected function doLastMessageDate()
}
/**
- * Adds all messages contents to the keywords property
+ * Adds all messages contents to the keywords property.
*/
protected function doKeywords()
{
@@ -150,7 +150,7 @@ protected function doKeywords()
}
/**
- * Denormalizes the value of isSpam to messages
+ * Denormalizes the value of isSpam to messages.
*/
protected function doSpam()
{
@@ -160,7 +160,7 @@ protected function doSpam()
}
/**
- * Ensures that metadata last message dates are up to date
+ * Ensures that metadata last message dates are up to date.
*
* Precondition: metadata exists for all thread participants
*/
diff --git a/DocumentManager/MessageManager.php b/DocumentManager/MessageManager.php
index b2a8f718..d319819c 100644
--- a/DocumentManager/MessageManager.php
+++ b/DocumentManager/MessageManager.php
@@ -46,14 +46,14 @@ class MessageManager extends BaseMessageManager
*/
public function __construct(DocumentManager $dm, $class, $metaClass)
{
- $this->dm = $dm;
+ $this->dm = $dm;
$this->repository = $dm->getRepository($class);
- $this->class = $dm->getClassMetadata($class)->name;
- $this->metaClass = $dm->getClassMetadata($metaClass)->name;
+ $this->class = $dm->getClassMetadata($class)->name;
+ $this->metaClass = $dm->getClassMetadata($metaClass)->name;
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function getNbUnreadMessageByParticipant(ParticipantInterface $participant)
{
@@ -64,7 +64,7 @@ public function getNbUnreadMessageByParticipant(ParticipantInterface $participan
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function markAsReadByParticipant(ReadableInterface $readable, ParticipantInterface $participant)
{
@@ -72,7 +72,7 @@ public function markAsReadByParticipant(ReadableInterface $readable, Participant
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function markAsUnreadByParticipant(ReadableInterface $readable, ParticipantInterface $participant)
{
@@ -80,40 +80,40 @@ public function markAsUnreadByParticipant(ReadableInterface $readable, Participa
}
/**
- * Marks all messages of this thread as read by this participant
+ * Marks all messages of this thread as read by this participant.
*
- * @param ThreadInterface $thread
+ * @param ThreadInterface $thread
* @param ParticipantInterface $participant
- * @param boolean $isRead
+ * @param bool $isRead
*/
public function markIsReadByThreadAndParticipant(ThreadInterface $thread, ParticipantInterface $participant, $isRead)
{
- $this->markIsReadByCondition($participant, $isRead, function(Builder $queryBuilder) use ($thread) {
+ $this->markIsReadByCondition($participant, $isRead, function (Builder $queryBuilder) use ($thread) {
$queryBuilder->field('thread.$id')->equals(new \MongoId($thread->getId()));
});
}
/**
- * Marks the message as read or unread by this participant
+ * Marks the message as read or unread by this participant.
*
- * @param MessageInterface $message
+ * @param MessageInterface $message
* @param ParticipantInterface $participant
- * @param boolean $isRead
+ * @param bool $isRead
*/
protected function markIsReadByParticipant(MessageInterface $message, ParticipantInterface $participant, $isRead)
{
- $this->markIsReadByCondition($participant, $isRead, function(Builder $queryBuilder) use ($message) {
+ $this->markIsReadByCondition($participant, $isRead, function (Builder $queryBuilder) use ($message) {
$queryBuilder->field('_id')->equals(new \MongoId($message->getId()));
});
}
/**
* Marks messages as read/unread
- * by updating directly the storage
+ * by updating directly the storage.
*
* @param ParticipantInterface $participant
- * @param boolean $isRead
- * @param \Closure $condition
+ * @param bool $isRead
+ * @param \Closure $condition
*/
protected function markIsReadByCondition(ParticipantInterface $participant, $isRead, \Closure $condition)
{
@@ -132,7 +132,7 @@ protected function markIsReadByCondition(ParticipantInterface $participant, $isR
}
$queryBuilder
- ->field('metadata.$.isRead')->set((boolean) $isRead)
+ ->field('metadata.$.isRead')->set((bool) $isRead)
->getQuery(array('multiple' => true))
->execute();
@@ -153,7 +153,7 @@ protected function markIsReadByCondition(ParticipantInterface $participant, $isR
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function saveMessage(MessageInterface $message, $andFlush = true)
{
@@ -165,7 +165,7 @@ public function saveMessage(MessageInterface $message, $andFlush = true)
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function getClass()
{
@@ -173,7 +173,7 @@ public function getClass()
}
/**
- * Creates a new MessageMetadata instance
+ * Creates a new MessageMetadata instance.
*
* @return MessageMetadata
*/
@@ -189,7 +189,7 @@ protected function createMessageMetadata()
*/
/**
- * Performs denormalization tricks
+ * Performs denormalization tricks.
*
* @param Message $message
*/
@@ -200,7 +200,7 @@ public function denormalize(Message $message)
}
/**
- * Ensures that the message has metadata for each thread participant
+ * Ensures that the message has metadata for each thread participant.
*
* @param Message $message
*/
diff --git a/DocumentManager/ThreadManager.php b/DocumentManager/ThreadManager.php
index 2a3e5007..ba1b4a7d 100644
--- a/DocumentManager/ThreadManager.php
+++ b/DocumentManager/ThreadManager.php
@@ -9,7 +9,6 @@
use FOS\MessageBundle\Model\ReadableInterface;
use FOS\MessageBundle\ModelManager\ThreadManager as BaseThreadManager;
use FOS\MessageBundle\Model\ParticipantInterface;
-use Doctrine\ODM\MongoDB\Query\Builder;
/**
* Default MongoDB ThreadManager.
@@ -55,15 +54,15 @@ class ThreadManager extends BaseThreadManager
*/
public function __construct(DocumentManager $dm, $class, $metaClass, MessageManager $messageManager)
{
- $this->dm = $dm;
- $this->repository = $dm->getRepository($class);
- $this->class = $dm->getClassMetadata($class)->name;
- $this->metaClass = $dm->getClassMetadata($metaClass)->name;
+ $this->dm = $dm;
+ $this->repository = $dm->getRepository($class);
+ $this->class = $dm->getClassMetadata($class)->name;
+ $this->metaClass = $dm->getClassMetadata($metaClass)->name;
$this->messageManager = $messageManager;
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function findThreadById($id)
{
@@ -71,7 +70,7 @@ public function findThreadById($id)
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function getParticipantInboxThreadsQueryBuilder(ParticipantInterface $participant)
{
@@ -85,7 +84,7 @@ public function getParticipantInboxThreadsQueryBuilder(ParticipantInterface $par
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function findParticipantInboxThreads(ParticipantInterface $participant)
{
@@ -93,7 +92,7 @@ public function findParticipantInboxThreads(ParticipantInterface $participant)
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function getParticipantSentThreadsQueryBuilder(ParticipantInterface $participant)
{
@@ -107,7 +106,7 @@ public function getParticipantSentThreadsQueryBuilder(ParticipantInterface $part
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function findParticipantSentThreads(ParticipantInterface $participant)
{
@@ -115,7 +114,7 @@ public function findParticipantSentThreads(ParticipantInterface $participant)
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function getParticipantDeletedThreadsQueryBuilder(ParticipantInterface $participant)
{
@@ -126,7 +125,7 @@ public function getParticipantDeletedThreadsQueryBuilder(ParticipantInterface $p
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function findParticipantDeletedThreads(ParticipantInterface $participant)
{
@@ -134,7 +133,7 @@ public function findParticipantDeletedThreads(ParticipantInterface $participant)
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function getParticipantThreadsBySearchQueryBuilder(ParticipantInterface $participant, $search)
{
@@ -155,7 +154,7 @@ public function getParticipantThreadsBySearchQueryBuilder(ParticipantInterface $
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function findParticipantThreadsBySearch(ParticipantInterface $participant, $search)
{
@@ -163,7 +162,7 @@ public function findParticipantThreadsBySearch(ParticipantInterface $participant
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function findThreadsCreatedBy(ParticipantInterface $participant)
{
@@ -174,7 +173,7 @@ public function findThreadsCreatedBy(ParticipantInterface $participant)
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function markAsReadByParticipant(ReadableInterface $readable, ParticipantInterface $participant)
{
@@ -182,7 +181,7 @@ public function markAsReadByParticipant(ReadableInterface $readable, Participant
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function markAsUnreadByParticipant(ReadableInterface $readable, ParticipantInterface $participant)
{
@@ -190,7 +189,7 @@ public function markAsUnreadByParticipant(ReadableInterface $readable, Participa
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function saveThread(ThreadInterface $thread, $andFlush = true)
{
@@ -202,7 +201,7 @@ public function saveThread(ThreadInterface $thread, $andFlush = true)
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function deleteThread(ThreadInterface $thread)
{
@@ -211,7 +210,7 @@ public function deleteThread(ThreadInterface $thread)
}
/**
- * Returns the fully qualified comment thread class name
+ * Returns the fully qualified comment thread class name.
*
* @return string
*/
@@ -221,7 +220,7 @@ public function getClass()
}
/**
- * Creates a new ThreadMetadata instance
+ * Creates a new ThreadMetadata instance.
*
* @return ThreadMetadata
*/
@@ -237,7 +236,7 @@ protected function createThreadMetadata()
*/
/**
- * Performs denormalization tricks
+ * Performs denormalization tricks.
*
* @param Thread $thread
*/
@@ -253,7 +252,7 @@ protected function denormalize(Thread $thread)
}
/**
- * Ensures that the thread participants are up to date
+ * Ensures that the thread participants are up to date.
*/
protected function doParticipants(Thread $thread)
{
@@ -264,7 +263,7 @@ protected function doParticipants(Thread $thread)
/**
* Ensures that metadata exists for each thread participant and that the
- * last message dates are current
+ * last message dates are current.
*
* @param Thread $thread
*/
diff --git a/Entity/Message.php b/Entity/Message.php
index 3c80b359..3349aaea 100644
--- a/Entity/Message.php
+++ b/Entity/Message.php
@@ -4,7 +4,6 @@
use Doctrine\Common\Collections\Collection;
use FOS\MessageBundle\Model\Message as BaseMessage;
-
use FOS\MessageBundle\Model\MessageMetadata as ModelMessageMetadata;
abstract class Message extends BaseMessage
@@ -20,7 +19,7 @@ public function getAllMetadata()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function addMetadata(ModelMessageMetadata $meta)
{
diff --git a/Entity/MessageMetadata.php b/Entity/MessageMetadata.php
index f76e3164..b3f842a5 100644
--- a/Entity/MessageMetadata.php
+++ b/Entity/MessageMetadata.php
@@ -11,7 +11,7 @@ abstract class MessageMetadata extends BaseMessageMetadata
protected $message;
/**
- * @return integer
+ * @return int
*/
public function getId()
{
diff --git a/Entity/Thread.php b/Entity/Thread.php
index adfd36f1..ede0e92b 100644
--- a/Entity/Thread.php
+++ b/Entity/Thread.php
@@ -7,27 +7,26 @@
use FOS\MessageBundle\Model\MessageInterface;
use FOS\MessageBundle\Model\Thread as BaseThread;
use FOS\MessageBundle\Model\ParticipantInterface;
-
use FOS\MessageBundle\Model\ThreadMetadata as ModelThreadMetadata;
abstract class Thread extends BaseThread
{
/**
- * Messages contained in this thread
+ * Messages contained in this thread.
*
* @var Collection|MessageInterface[]
*/
protected $messages;
/**
- * Users participating in this conversation
+ * Users participating in this conversation.
*
* @var Collection|ParticipantInterface[]
*/
protected $participants;
/**
- * Thread metadata
+ * Thread metadata.
*
* @var Collection|ModelThreadMetadata[]
*/
@@ -35,28 +34,28 @@ abstract class Thread extends BaseThread
/**
* All text contained in the thread messages
- * Used for the full text search
+ * Used for the full text search.
*
* @var string
*/
protected $keywords = '';
/**
- * Participant that created the thread
+ * Participant that created the thread.
*
* @var ParticipantInterface
*/
protected $createdBy;
/**
- * Date this thread was created at
+ * Date this thread was created at.
*
* @var \DateTime
*/
protected $createdAt;
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function getParticipants()
{
@@ -64,7 +63,7 @@ public function getParticipants()
}
/**
- * Gets the users participating in this conversation
+ * Gets the users participating in this conversation.
*
* Since the ORM schema does not map the participants collection field, it
* must be created on demand.
@@ -85,7 +84,7 @@ protected function getParticipantsCollection()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function addParticipant(ParticipantInterface $participant)
{
@@ -95,11 +94,12 @@ public function addParticipant(ParticipantInterface $participant)
}
/**
- * Adds many participants to the thread
+ * Adds many participants to the thread.
*
* @param array|\Traversable
*
* @throws \InvalidArgumentException
+ *
* @return Thread
*/
public function addParticipants($participants)
@@ -116,7 +116,7 @@ public function addParticipants($participants)
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function isParticipant(ParticipantInterface $participant)
{
@@ -134,7 +134,7 @@ public function getAllMetadata()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function addMetadata(ModelThreadMetadata $meta)
{
diff --git a/Entity/ThreadMetadata.php b/Entity/ThreadMetadata.php
index bcbbf354..68b4bccb 100644
--- a/Entity/ThreadMetadata.php
+++ b/Entity/ThreadMetadata.php
@@ -11,9 +11,9 @@ abstract class ThreadMetadata extends BaseThreadMetadata
protected $thread;
/**
- * Gets the thread map id
+ * Gets the thread map id.
*
- * @return integer
+ * @return int
*/
public function getId()
{
diff --git a/EntityManager/MessageManager.php b/EntityManager/MessageManager.php
index 10a5eea7..76ad012c 100644
--- a/EntityManager/MessageManager.php
+++ b/EntityManager/MessageManager.php
@@ -8,7 +8,6 @@
use FOS\MessageBundle\Model\ReadableInterface;
use FOS\MessageBundle\Model\ParticipantInterface;
use FOS\MessageBundle\Model\ThreadInterface;
-use Doctrine\ORM\Query\Builder;
/**
* Default ORM MessageManager.
@@ -38,26 +37,26 @@ class MessageManager extends BaseMessageManager
protected $metaClass;
/**
- * @param EntityManager $em
- * @param string $class
- * @param string $metaClass
+ * @param EntityManager $em
+ * @param string $class
+ * @param string $metaClass
*/
public function __construct(EntityManager $em, $class, $metaClass)
{
- $this->em = $em;
+ $this->em = $em;
$this->repository = $em->getRepository($class);
- $this->class = $em->getClassMetadata($class)->name;
- $this->metaClass = $em->getClassMetadata($metaClass)->name;
+ $this->class = $em->getClassMetadata($class)->name;
+ $this->metaClass = $em->getClassMetadata($metaClass)->name;
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function getNbUnreadMessageByParticipant(ParticipantInterface $participant)
{
$builder = $this->repository->createQueryBuilder('m');
- return (int)$builder
+ return (int) $builder
->select($builder->expr()->count('mm.id'))
->innerJoin('m.metadata', 'mm')
@@ -77,7 +76,7 @@ public function getNbUnreadMessageByParticipant(ParticipantInterface $participan
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function markAsReadByParticipant(ReadableInterface $readable, ParticipantInterface $participant)
{
@@ -85,7 +84,7 @@ public function markAsReadByParticipant(ReadableInterface $readable, Participant
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function markAsUnreadByParticipant(ReadableInterface $readable, ParticipantInterface $participant)
{
@@ -93,11 +92,11 @@ public function markAsUnreadByParticipant(ReadableInterface $readable, Participa
}
/**
- * Marks all messages of this thread as read by this participant
+ * Marks all messages of this thread as read by this participant.
*
- * @param ThreadInterface $thread
+ * @param ThreadInterface $thread
* @param ParticipantInterface $participant
- * @param boolean $isRead
+ * @param bool $isRead
*/
public function markIsReadByThreadAndParticipant(ThreadInterface $thread, ParticipantInterface $participant, $isRead)
{
@@ -107,11 +106,11 @@ public function markIsReadByThreadAndParticipant(ThreadInterface $thread, Partic
}
/**
- * Marks the message as read or unread by this participant
+ * Marks the message as read or unread by this participant.
*
- * @param MessageInterface $message
+ * @param MessageInterface $message
* @param ParticipantInterface $participant
- * @param boolean $isRead
+ * @param bool $isRead
*/
protected function markIsReadByParticipant(MessageInterface $message, ParticipantInterface $participant, $isRead)
{
@@ -123,7 +122,7 @@ protected function markIsReadByParticipant(MessageInterface $message, Participan
$this->em->createQueryBuilder()
->update($this->metaClass, 'm')
->set('m.isRead', '?1')
- ->setParameter('1', (bool)$isRead, \PDO::PARAM_BOOL)
+ ->setParameter('1', (bool) $isRead, \PDO::PARAM_BOOL)
->where('m.id = :id')
->setParameter('id', $meta->getId())
@@ -133,7 +132,7 @@ protected function markIsReadByParticipant(MessageInterface $message, Participan
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function saveMessage(MessageInterface $message, $andFlush = true)
{
@@ -145,7 +144,7 @@ public function saveMessage(MessageInterface $message, $andFlush = true)
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function getClass()
{
@@ -159,7 +158,7 @@ public function getClass()
*/
/**
- * Performs denormalization tricks
+ * Performs denormalization tricks.
*/
protected function denormalize(MessageInterface $message)
{
@@ -167,7 +166,7 @@ protected function denormalize(MessageInterface $message)
}
/**
- * Ensures that the message metadata are up to date
+ * Ensures that the message metadata are up to date.
*/
protected function doMetadata(MessageInterface $message)
{
diff --git a/EntityManager/ThreadManager.php b/EntityManager/ThreadManager.php
index 03ff7253..ae004ec5 100644
--- a/EntityManager/ThreadManager.php
+++ b/EntityManager/ThreadManager.php
@@ -7,7 +7,6 @@
use FOS\MessageBundle\Model\ThreadInterface;
use FOS\MessageBundle\Model\ReadableInterface;
use FOS\MessageBundle\Model\ParticipantInterface;
-use Doctrine\ORM\Query\Builder;
/**
* Default ORM ThreadManager.
@@ -27,14 +26,14 @@ class ThreadManager extends BaseThreadManager
protected $repository;
/**
- * The model class
+ * The model class.
*
* @var string
*/
protected $class;
/**
- * The model class
+ * The model class.
*
* @var string
*/
@@ -42,29 +41,29 @@ class ThreadManager extends BaseThreadManager
/**
* The message manager, required to mark
- * the messages of a thread as read/unread
+ * the messages of a thread as read/unread.
*
* @var MessageManager
*/
protected $messageManager;
/**
- * @param EntityManager $em
- * @param string $class
- * @param string $metaClass
- * @param MessageManager $messageManager
+ * @param EntityManager $em
+ * @param string $class
+ * @param string $metaClass
+ * @param MessageManager $messageManager
*/
public function __construct(EntityManager $em, $class, $metaClass, MessageManager $messageManager)
{
- $this->em = $em;
- $this->repository = $em->getRepository($class);
- $this->class = $em->getClassMetadata($class)->name;
- $this->metaClass = $em->getClassMetadata($metaClass)->name;
+ $this->em = $em;
+ $this->repository = $em->getRepository($class);
+ $this->class = $em->getClassMetadata($class)->name;
+ $this->metaClass = $em->getClassMetadata($metaClass)->name;
$this->messageManager = $messageManager;
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function findThreadById($id)
{
@@ -72,7 +71,7 @@ public function findThreadById($id)
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function getParticipantInboxThreadsQueryBuilder(ParticipantInterface $participant)
{
@@ -101,7 +100,7 @@ public function getParticipantInboxThreadsQueryBuilder(ParticipantInterface $par
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function findParticipantInboxThreads(ParticipantInterface $participant)
{
@@ -111,7 +110,7 @@ public function findParticipantInboxThreads(ParticipantInterface $participant)
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function getParticipantSentThreadsQueryBuilder(ParticipantInterface $participant)
{
@@ -140,7 +139,7 @@ public function getParticipantSentThreadsQueryBuilder(ParticipantInterface $part
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function findParticipantSentThreads(ParticipantInterface $participant)
{
@@ -150,7 +149,7 @@ public function findParticipantSentThreads(ParticipantInterface $participant)
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function getParticipantDeletedThreadsQueryBuilder(ParticipantInterface $participant)
{
@@ -172,7 +171,7 @@ public function getParticipantDeletedThreadsQueryBuilder(ParticipantInterface $p
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function findParticipantDeletedThreads(ParticipantInterface $participant)
{
@@ -182,7 +181,7 @@ public function findParticipantDeletedThreads(ParticipantInterface $participant)
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function getParticipantThreadsBySearchQueryBuilder(ParticipantInterface $participant, $search)
{
@@ -195,7 +194,7 @@ public function getParticipantThreadsBySearchQueryBuilder(ParticipantInterface $
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function findParticipantThreadsBySearch(ParticipantInterface $participant, $search)
{
@@ -205,7 +204,7 @@ public function findParticipantThreadsBySearch(ParticipantInterface $participant
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function findThreadsCreatedBy(ParticipantInterface $participant)
{
@@ -220,7 +219,7 @@ public function findThreadsCreatedBy(ParticipantInterface $participant)
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function markAsReadByParticipant(ReadableInterface $readable, ParticipantInterface $participant)
{
@@ -228,7 +227,7 @@ public function markAsReadByParticipant(ReadableInterface $readable, Participant
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function markAsUnreadByParticipant(ReadableInterface $readable, ParticipantInterface $participant)
{
@@ -236,7 +235,7 @@ public function markAsUnreadByParticipant(ReadableInterface $readable, Participa
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function saveThread(ThreadInterface $thread, $andFlush = true)
{
@@ -248,7 +247,7 @@ public function saveThread(ThreadInterface $thread, $andFlush = true)
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function deleteThread(ThreadInterface $thread)
{
@@ -257,7 +256,7 @@ public function deleteThread(ThreadInterface $thread)
}
/**
- * Returns the fully qualified comment thread class name
+ * Returns the fully qualified comment thread class name.
*
* @return string
*/
@@ -273,7 +272,7 @@ public function getClass()
*/
/**
- * Performs denormalization tricks
+ * Performs denormalization tricks.
*/
protected function denormalize(ThreadInterface $thread)
{
@@ -283,7 +282,7 @@ protected function denormalize(ThreadInterface $thread)
}
/**
- * Ensures that the thread metadata are up to date
+ * Ensures that the thread metadata are up to date.
*/
protected function doMetadata(ThreadInterface $thread)
{
@@ -312,7 +311,7 @@ protected function doMetadata(ThreadInterface $thread)
}
/**
- * Ensures that the createdBy & createdAt properties are set
+ * Ensures that the createdBy & createdAt properties are set.
*/
protected function doCreatedByAndAt(ThreadInterface $thread)
{
@@ -330,7 +329,7 @@ protected function doCreatedByAndAt(ThreadInterface $thread)
}
/**
- * Update the dates of last message written by other participants
+ * Update the dates of last message written by other participants.
*/
protected function doDatesOfLastMessageWrittenByOtherParticipant(ThreadInterface $thread)
{
diff --git a/Event/FOSMessageEvents.php b/Event/FOSMessageEvents.php
index 7ad25bb5..29e08167 100644
--- a/Event/FOSMessageEvents.php
+++ b/Event/FOSMessageEvents.php
@@ -3,13 +3,13 @@
namespace FOS\MessageBundle\Event;
/**
- * Declares all events thrown in the MessageBundle
+ * Declares all events thrown in the MessageBundle.
*/
final class FOSMessageEvents
{
/**
* The POST_SEND event occurs after a message has been sent
- * The event is an instance of FOS\MessageBundle\Event\MessageEvent
+ * The event is an instance of FOS\MessageBundle\Event\MessageEvent.
*
* @var string
*/
@@ -17,7 +17,7 @@ final class FOSMessageEvents
/**
* The POST_DELETE event occurs after a thread has been marked as deleted
- * The event is an instance of FOS\MessageBundle\Event\ThreadEvent
+ * The event is an instance of FOS\MessageBundle\Event\ThreadEvent.
*
* @var string
*/
@@ -25,7 +25,7 @@ final class FOSMessageEvents
/**
* The POST_UNDELETE event occurs after a thread has been marked as undeleted
- * The event is an instance of FOS\MessageBundle\Event\ThreadEvent
+ * The event is an instance of FOS\MessageBundle\Event\ThreadEvent.
*
* @var string
*/
@@ -33,7 +33,7 @@ final class FOSMessageEvents
/**
* The POST_READ event occurs after a thread has been marked as read
- * The event is an instance of FOS\MessageBundle\Event\ReadableEvent
+ * The event is an instance of FOS\MessageBundle\Event\ReadableEvent.
*
* @var string
*/
@@ -41,7 +41,7 @@ final class FOSMessageEvents
/**
* The POST_UNREAD event occurs after a thread has been unread
- * The event is an instance of FOS\MessageBundle\Event\ReadableEvent
+ * The event is an instance of FOS\MessageBundle\Event\ReadableEvent.
*
* @var string
*/
diff --git a/FormFactory/AbstractMessageFormFactory.php b/FormFactory/AbstractMessageFormFactory.php
index 77eef977..e1085eeb 100644
--- a/FormFactory/AbstractMessageFormFactory.php
+++ b/FormFactory/AbstractMessageFormFactory.php
@@ -7,42 +7,50 @@
use FOS\MessageBundle\FormModel\AbstractMessage;
/**
- * Instanciates message forms
+ * Instanciates message forms.
*
* @author Thibault Duplessis
*/
abstract class AbstractMessageFormFactory
{
/**
- * The Symfony form factory
+ * The Symfony form factory.
*
* @var FormFactoryInterface
*/
protected $formFactory;
/**
- * The message form type
+ * The message form type.
*
- * @var AbstractType
+ * @var AbstractType|string
*/
protected $formType;
/**
- * The name of the form
+ * The name of the form.
*
* @var string
*/
protected $formName;
/**
- * The FQCN of the message model
+ * The FQCN of the message model.
*
* @var string
*/
protected $messageClass;
- public function __construct(FormFactoryInterface $formFactory, AbstractType $formType, $formName, $messageClass)
+ public function __construct(FormFactoryInterface $formFactory, $formType, $formName, $messageClass)
{
+ if (!is_string($formType) && !$formType instanceof AbstractType) {
+ throw new \InvalidArgumentException(sprintf(
+ 'Form type provided is not valid (class name or instance of %s expected, %s given)',
+ 'Symfony\Component\Form\AbstractType',
+ is_object($formType) ? get_class($formType) : gettype($formType)
+ ));
+ }
+
$this->formFactory = $formFactory;
$this->formType = $formType;
$this->formName = $formName;
@@ -50,12 +58,14 @@ public function __construct(FormFactoryInterface $formFactory, AbstractType $for
}
/**
- * Creates a new instance of the form model
+ * Creates a new instance of the form model.
*
* @return AbstractMessage
*/
protected function createModelInstance()
{
- return new $this->messageClass();
+ $class = $this->messageClass;
+
+ return new $class();
}
}
diff --git a/FormFactory/NewThreadMessageFormFactory.php b/FormFactory/NewThreadMessageFormFactory.php
index 29d49879..271beda5 100644
--- a/FormFactory/NewThreadMessageFormFactory.php
+++ b/FormFactory/NewThreadMessageFormFactory.php
@@ -5,14 +5,14 @@
use Symfony\Component\Form\FormInterface;
/**
- * Instanciates message forms
+ * Instanciates message forms.
*
* @author Thibault Duplessis
*/
class NewThreadMessageFormFactory extends AbstractMessageFormFactory
{
/**
- * Creates a new thread message
+ * Creates a new thread message.
*
* @return FormInterface
*/
diff --git a/FormFactory/ReplyMessageFormFactory.php b/FormFactory/ReplyMessageFormFactory.php
index 98cfb700..27cc599a 100644
--- a/FormFactory/ReplyMessageFormFactory.php
+++ b/FormFactory/ReplyMessageFormFactory.php
@@ -6,16 +6,17 @@
use Symfony\Component\Form\FormInterface;
/**
- * Instanciates message forms
+ * Instanciates message forms.
*
* @author Thibault Duplessis
*/
class ReplyMessageFormFactory extends AbstractMessageFormFactory
{
/**
- * Creates a reply message
+ * Creates a reply message.
*
* @param ThreadInterface $thread the thread we answer to
+ *
* @return FormInterface
*/
public function create(ThreadInterface $thread)
diff --git a/FormHandler/AbstractMessageFormHandler.php b/FormHandler/AbstractMessageFormHandler.php
index 923aa592..2b66b5d2 100644
--- a/FormHandler/AbstractMessageFormHandler.php
+++ b/FormHandler/AbstractMessageFormHandler.php
@@ -5,6 +5,7 @@
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;
@@ -12,7 +13,7 @@
use FOS\MessageBundle\Sender\SenderInterface;
/**
- * Handles messages forms, from binding request to sending the message
+ * Handles messages forms, from binding request to sending the message.
*
* @author Thibault Duplessis
*/
@@ -23,8 +24,20 @@ abstract class AbstractMessageFormHandler
protected $sender;
protected $participantProvider;
- public function __construct(Request $request, ComposerInterface $composer, SenderInterface $sender, ParticipantProviderInterface $participantProvider)
+ /**
+ * @param Request|RequestStack $request
+ * @param ComposerInterface $composer
+ * @param SenderInterface $sender
+ * @param ParticipantProviderInterface $participantProvider
+ */
+ public function __construct($request, ComposerInterface $composer, SenderInterface $sender, ParticipantProviderInterface $participantProvider)
{
+ if ($request instanceof Request) {
+ @trigger_error(sprintf('Using an instance of "%s" as first parameter of "%s" is deprecated since version 1.3 and won\'t be supported in 2.0. Use an instance of "Symfony\Component\HttpFoundation\RequestStack" instead.', get_class($request), __METHOD__), E_USER_DEPRECATED);
+ } elseif (!$request instanceof RequestStack) {
+ throw new \InvalidArgumentException(sprintf('AbstractMessageFormHandler expected a Request or RequestStack, %s given', is_object($request) ? get_class($request) : gettype($request)));
+ }
+
$this->request = $request;
$this->composer = $composer;
$this->sender = $sender;
@@ -32,18 +45,21 @@ public function __construct(Request $request, ComposerInterface $composer, Sende
}
/**
- * Processes the form with the request
+ * Processes the form with the request.
*
* @param Form $form
+ *
* @return MessageInterface|false the sent message if the form is bound and valid, false otherwise
*/
public function process(Form $form)
{
- if ('POST' !== $this->request->getMethod()) {
+ $request = $this->getCurrentRequest();
+
+ if ('POST' !== $request->getMethod()) {
return false;
}
- $form->bind($this->request);
+ $form->handleRequest($request);
if ($form->isValid()) {
return $this->processValidForm($form);
@@ -53,30 +69,31 @@ public function process(Form $form)
}
/**
- * Processes the valid form, sends the message
+ * Processes the valid form, sends the message.
*
* @param Form $form
+ *
* @return MessageInterface the sent message
*/
public function processValidForm(Form $form)
{
$message = $this->composeMessage($form->getData());
-
$this->sender->send($message);
return $message;
}
/**
- * Composes a message from the form data
+ * Composes a message from the form data.
*
* @param AbstractMessage $message
+ *
* @return MessageInterface the composed message ready to be sent
*/
abstract protected function composeMessage(AbstractMessage $message);
/**
- * Gets the current authenticated user
+ * Gets the current authenticated user.
*
* @return ParticipantInterface
*/
@@ -84,4 +101,26 @@ protected function getAuthenticatedParticipant()
{
return $this->participantProvider->getAuthenticatedParticipant();
}
+
+ /**
+ * BC layer to retrieve the current request directly or from a stack.
+ *
+ * @return Request
+ */
+ private function getCurrentRequest()
+ {
+ if (!$this->request) {
+ throw new \RuntimeException('Current request was not provided to the form handler.');
+ }
+
+ if ($this->request instanceof Request) {
+ return $this->request;
+ }
+
+ if (!$this->request->getCurrentRequest()) {
+ throw new \RuntimeException('Request stack provided to the form handler did not contains a current request.');
+ }
+
+ return $this->request->getCurrentRequest();
+ }
}
diff --git a/FormHandler/NewThreadMessageFormHandler.php b/FormHandler/NewThreadMessageFormHandler.php
index 3ac3faa4..7d8c56e7 100644
--- a/FormHandler/NewThreadMessageFormHandler.php
+++ b/FormHandler/NewThreadMessageFormHandler.php
@@ -9,10 +9,12 @@
class NewThreadMessageFormHandler extends AbstractMessageFormHandler
{
/**
- * Composes a message from the form data
+ * Composes a message from the form data.
*
* @param AbstractMessage $message
+ *
* @return MessageInterface the composed message ready to be sent
+ *
* @throws \InvalidArgumentException if the message is not a NewThreadMessage
*/
public function composeMessage(AbstractMessage $message)
diff --git a/FormHandler/NewThreadMultipleMessageFormHandler.php b/FormHandler/NewThreadMultipleMessageFormHandler.php
index 9eea3e6c..7daf7355 100644
--- a/FormHandler/NewThreadMultipleMessageFormHandler.php
+++ b/FormHandler/NewThreadMultipleMessageFormHandler.php
@@ -1,4 +1,5 @@
*/
class NewThreadMultipleMessageFormHandler extends AbstractMessageFormHandler
{
/**
- * Composes a message from the form data
+ * Composes a message from the form data.
*
* @param AbstractMessage $message
*
* @return MessageInterface the composed message ready to be sent
+ *
* @throws \InvalidArgumentException if the message is not a NewThreadMessage
*/
public function composeMessage(AbstractMessage $message)
diff --git a/FormHandler/ReplyMessageFormHandler.php b/FormHandler/ReplyMessageFormHandler.php
index c703bb22..b69e1e0b 100644
--- a/FormHandler/ReplyMessageFormHandler.php
+++ b/FormHandler/ReplyMessageFormHandler.php
@@ -9,10 +9,12 @@
class ReplyMessageFormHandler extends AbstractMessageFormHandler
{
/**
- * Composes a message from the form data
+ * Composes a message from the form data.
*
* @param AbstractMessage $message
+ *
* @return MessageInterface the composed message ready to be sent
+ *
* @throws \InvalidArgumentException if the message is not a ReplyMessage
*/
public function composeMessage(AbstractMessage $message)
diff --git a/FormModel/AbstractMessage.php b/FormModel/AbstractMessage.php
index e8b9a89d..9d284e4c 100644
--- a/FormModel/AbstractMessage.php
+++ b/FormModel/AbstractMessage.php
@@ -24,5 +24,4 @@ public function setBody($body)
{
$this->body = $body;
}
-
}
diff --git a/FormModel/NewThreadMessage.php b/FormModel/NewThreadMessage.php
index 06f8c65a..adae44ff 100644
--- a/FormModel/NewThreadMessage.php
+++ b/FormModel/NewThreadMessage.php
@@ -7,14 +7,14 @@
class NewThreadMessage extends AbstractMessage
{
/**
- * The user who receives the message
+ * The user who receives the message.
*
* @var ParticipantInterface
*/
protected $recipient;
/**
- * The thread subject
+ * The thread subject.
*
* @var string
*/
diff --git a/FormModel/NewThreadMultipleMessage.php b/FormModel/NewThreadMultipleMessage.php
index 1fa8de23..bc751f51 100644
--- a/FormModel/NewThreadMultipleMessage.php
+++ b/FormModel/NewThreadMultipleMessage.php
@@ -1,28 +1,29 @@
recipients = new ArrayCollection();
@@ -53,7 +54,7 @@ public function getRecipients()
}
/**
- * Adds single recipient to collection
+ * Adds single recipient to collection.
*
* @param ParticipantInterface $recipient
*/
@@ -65,7 +66,7 @@ public function addRecipient(ParticipantInterface $recipient)
}
/**
- * Removes recipient from collection
+ * Removes recipient from collection.
*
* @param ParticipantInterface $recipient
*/
diff --git a/FormModel/ReplyMessage.php b/FormModel/ReplyMessage.php
index 1761124e..7d94008f 100644
--- a/FormModel/ReplyMessage.php
+++ b/FormModel/ReplyMessage.php
@@ -7,7 +7,7 @@
class ReplyMessage extends AbstractMessage
{
/**
- * The thread we reply to
+ * The thread we reply to.
*
* @var ThreadInterface
*/
diff --git a/FormType/NewThreadMessageFormType.php b/FormType/NewThreadMessageFormType.php
index 772e6921..7acfc1fe 100644
--- a/FormType/NewThreadMessageFormType.php
+++ b/FormType/NewThreadMessageFormType.php
@@ -2,12 +2,14 @@
namespace FOS\MessageBundle\FormType;
+use FOS\MessageBundle\Util\LegacyFormHelper;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
/**
- * Message form type for starting a new conversation
+ * Message form type for starting a new conversation.
*
* @author Thibault Duplessis
*/
@@ -16,20 +18,48 @@ 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', LegacyFormHelper::getType('FOS\UserBundle\Form\Type\UsernameFormType'), array(
+ 'label' => 'recipient',
+ 'translation_domain' => 'FOSMessageBundle',
+ ))
+ ->add('subject', LegacyFormHelper::getType('Symfony\Component\Form\Extension\Core\Type\TextType'), array(
+ 'label' => 'subject',
+ 'translation_domain' => 'FOSMessageBundle',
+ ))
+ ->add('body', LegacyFormHelper::getType('Symfony\Component\Form\Extension\Core\Type\TextareaType'), array(
+ 'label' => 'body',
+ 'translation_domain' => 'FOSMessageBundle',
+ ));
}
- public function setDefaultOptions(OptionsResolverInterface $resolver)
+ public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
- 'intention' => 'message',
+ 'intention' => 'message',
));
}
- public function getName()
+ /**
+ * {@inheritdoc}
+ */
+ public function getBlockPrefix()
{
return 'fos_message_new_thread';
}
+
+ /**
+ * @deprecated To remove when supporting only Symfony 3
+ */
+ public function setDefaultOptions(OptionsResolverInterface $resolver)
+ {
+ $this->configureOptions($resolver);
+ }
+
+ /**
+ * @deprecated To remove when supporting only Symfony 3
+ */
+ public function getName()
+ {
+ return $this->getBlockPrefix();
+ }
}
diff --git a/FormType/NewThreadMultipleMessageFormType.php b/FormType/NewThreadMultipleMessageFormType.php
index a9836baf..f0bb1881 100644
--- a/FormType/NewThreadMultipleMessageFormType.php
+++ b/FormType/NewThreadMultipleMessageFormType.php
@@ -1,11 +1,13 @@
*/
@@ -14,13 +16,33 @@ class NewThreadMultipleMessageFormType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
- ->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', LegacyFormHelper::getType('FOS\MessageBundle\FormType\RecipientsType'), array(
+ 'label' => 'recipients',
+ 'translation_domain' => 'FOSMessageBundle',
+ ))
+ ->add('subject', LegacyFormHelper::getType('Symfony\Component\Form\Extension\Core\Type\TextType'), array(
+ 'label' => 'subject',
+ 'translation_domain' => 'FOSMessageBundle',
+ ))
+ ->add('body', LegacyFormHelper::getType('Symfony\Component\Form\Extension\Core\Type\TextareaType'), array(
+ 'label' => 'body',
+ 'translation_domain' => 'FOSMessageBundle',
+ ));
}
- public function getName()
+ /**
+ * {@inheritdoc}
+ */
+ public function getBlockPrefix()
{
return 'fos_message_new_multiperson_thread';
}
+
+ /**
+ * @deprecated To remove when supporting only Symfony 3
+ */
+ public function getName()
+ {
+ return $this->getBlockPrefix();
+ }
}
diff --git a/FormType/RecipientsType.php b/FormType/RecipientsType.php
index d8cc7090..043c2e87 100644
--- a/FormType/RecipientsType.php
+++ b/FormType/RecipientsType.php
@@ -1,14 +1,16 @@
*/
@@ -28,7 +30,7 @@ public function __construct(RecipientsDataTransformer $transformer)
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
@@ -36,28 +38,41 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
- public function setDefaultOptions(OptionsResolverInterface $resolver)
+ public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'invalid_message' => 'The selected recipient does not exist',
));
}
+ public function setDefaultOptions(OptionsResolverInterface $resolver)
+ {
+ $this->configureOptions($resolver);
+ }
+
/**
- * {@inheritDoc}
+ * {@inheritdoc}
+ */
+ public function getBlockPrefix()
+ {
+ return 'recipients_selector';
+ }
+
+ /**
+ * {@inheritdoc}
*/
public function getParent()
{
- return 'text';
+ return LegacyFormHelper::getType('Symfony\Component\Form\Extension\Core\Type\TextType');
}
/**
- * {@inheritDoc}
+ * @deprecated To remove when supporting only Symfony 3
*/
public function getName()
{
- return 'recipients_selector';
+ return $this->getBlockPrefix();
}
}
diff --git a/FormType/ReplyMessageFormType.php b/FormType/ReplyMessageFormType.php
index c2780ba4..3d1592e5 100644
--- a/FormType/ReplyMessageFormType.php
+++ b/FormType/ReplyMessageFormType.php
@@ -2,12 +2,14 @@
namespace FOS\MessageBundle\FormType;
+use FOS\MessageBundle\Util\LegacyFormHelper;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
/**
- * Form type for a reply
+ * Form type for a reply.
*
* @author Thibault Duplessis
*/
@@ -16,18 +18,40 @@ class ReplyMessageFormType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
- ->add('body', 'textarea', array('label' => 'body', 'translation_domain' => 'FOSMessageBundle'));
+ ->add('body', LegacyFormHelper::getType('Symfony\Component\Form\Extension\Core\Type\TextareaType'), array(
+ 'label' => 'body',
+ 'translation_domain' => 'FOSMessageBundle',
+ ));
}
- public function setDefaultOptions(OptionsResolverInterface $resolver)
+ public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
- 'intention' => 'reply',
+ 'intention' => 'reply',
));
}
- public function getName()
+ /**
+ * {@inheritdoc}
+ */
+ public function getBlockPrefix()
{
return 'fos_message_reply_message';
}
+
+ /**
+ * @deprecated To remove when supporting only Symfony 3
+ */
+ public function setDefaultOptions(OptionsResolverInterface $resolver)
+ {
+ $this->configureOptions($resolver);
+ }
+
+ /**
+ * @deprecated To remove when supporting only Symfony 3
+ */
+ public function getName()
+ {
+ return $this->getBlockPrefix();
+ }
}
diff --git a/MessageBuilder/AbstractMessageBuilder.php b/MessageBuilder/AbstractMessageBuilder.php
index 40d71309..0d788741 100644
--- a/MessageBuilder/AbstractMessageBuilder.php
+++ b/MessageBuilder/AbstractMessageBuilder.php
@@ -7,21 +7,21 @@
use FOS\MessageBundle\Model\ThreadInterface;
/**
- * Fluent interface message builder
+ * Fluent interface message builder.
*
* @author Thibault Duplessis
*/
abstract class AbstractMessageBuilder
{
/**
- * The message we are building
+ * The message we are building.
*
* @var MessageInterface
*/
protected $message;
/**
- * The thread the message goes in
+ * The thread the message goes in.
*
* @var ThreadInterface
*/
@@ -48,6 +48,7 @@ public function getMessage()
/**
* @param string
+ *
* @return AbstractMessageBuilder (fluent interface)
*/
public function setBody($body)
@@ -58,7 +59,8 @@ public function setBody($body)
}
/**
- * @param ParticipantInterface $sender
+ * @param ParticipantInterface $sender
+ *
* @return AbstractMessageBuilder (fluent interface)
*/
public function setSender(ParticipantInterface $sender)
diff --git a/MessageBuilder/NewThreadMessageBuilder.php b/MessageBuilder/NewThreadMessageBuilder.php
index 3e319aa5..22c98849 100644
--- a/MessageBuilder/NewThreadMessageBuilder.php
+++ b/MessageBuilder/NewThreadMessageBuilder.php
@@ -6,16 +6,17 @@
use Doctrine\Common\Collections\Collection;
/**
- * Fluent interface message builder for new thread messages
+ * Fluent interface message builder for new thread messages.
*
* @author Thibault Duplessis
*/
class NewThreadMessageBuilder extends AbstractMessageBuilder
{
/**
- * The thread subject
+ * The thread subject.
*
* @param string
+ *
* @return NewThreadMessageBuilder (fluent interface)
*/
public function setSubject($subject)
@@ -26,7 +27,8 @@ public function setSubject($subject)
}
/**
- * @param ParticipantInterface $recipient
+ * @param ParticipantInterface $recipient
+ *
* @return NewThreadMessageBuilder (fluent interface)
*/
public function addRecipient(ParticipantInterface $recipient)
@@ -37,7 +39,8 @@ public function addRecipient(ParticipantInterface $recipient)
}
/**
- * @param Collection $recipients
+ * @param Collection $recipients
+ *
* @return NewThreadMessageBuilder
*/
public function addRecipients(Collection $recipients)
@@ -48,5 +51,4 @@ public function addRecipients(Collection $recipients)
return $this;
}
-
}
diff --git a/MessageBuilder/ReplyMessageBuilder.php b/MessageBuilder/ReplyMessageBuilder.php
index c0bc9959..b8dd677a 100644
--- a/MessageBuilder/ReplyMessageBuilder.php
+++ b/MessageBuilder/ReplyMessageBuilder.php
@@ -3,7 +3,7 @@
namespace FOS\MessageBundle\MessageBuilder;
/**
- * Fluent interface message builder for reply to a thread
+ * Fluent interface message builder for reply to a thread.
*
* @author Thibault Duplessis
*/
diff --git a/Model/Message.php b/Model/Message.php
index a8b48d57..f2a8f584 100644
--- a/Model/Message.php
+++ b/Model/Message.php
@@ -6,49 +6,49 @@
use Doctrine\Common\Collections\Collection;
/**
- * Abstract message model
+ * Abstract message model.
*
* @author Thibault Duplessis
*/
abstract class Message implements MessageInterface
{
/**
- * Unique id of the message
+ * Unique id of the message.
*
* @var mixed
*/
protected $id;
/**
- * User who sent the message
+ * User who sent the message.
*
* @var ParticipantInterface
*/
protected $sender;
/**
- * Text body of the message
+ * Text body of the message.
*
* @var string
*/
protected $body;
/**
- * Date when the message was sent
+ * Date when the message was sent.
*
* @var \DateTime
*/
protected $createdAt;
/**
- * Thread the message belongs to
+ * Thread the message belongs to.
*
* @var ThreadInterface
*/
protected $thread;
/**
- * Collection of MessageMetadata
+ * Collection of MessageMetadata.
*
* @var Collection|MessageMetadata[]
*/
@@ -128,7 +128,7 @@ public function setSender(ParticipantInterface $sender)
}
/**
- * Gets the created at timestamp
+ * Gets the created at timestamp.
*
* @return int
*/
@@ -151,6 +151,7 @@ public function addMetadata(MessageMetadata $meta)
* Get the MessageMetadata for a participant.
*
* @param ParticipantInterface $participant
+ *
* @return MessageMetadata
*/
public function getMetadataForParticipant(ParticipantInterface $participant)
diff --git a/Model/MessageInterface.php b/Model/MessageInterface.php
index c1e77c44..36384a31 100644
--- a/Model/MessageInterface.php
+++ b/Model/MessageInterface.php
@@ -3,14 +3,14 @@
namespace FOS\MessageBundle\Model;
/**
- * Message model
+ * Message model.
*
* @author Thibault Duplessis
*/
interface MessageInterface extends ReadableInterface
{
/**
- * Gets the message unique id
+ * Gets the message unique id.
*
* @return mixed
*/
@@ -23,7 +23,6 @@ public function getThread();
/**
* @param ThreadInterface
- * @return null
*/
public function setThread(ThreadInterface $thread);
@@ -39,7 +38,6 @@ public function getBody();
/**
* @param string
- * @return null
*/
public function setBody($body);
@@ -50,7 +48,6 @@ public function getSender();
/**
* @param ParticipantInterface
- * @return null
*/
public function setSender(ParticipantInterface $sender);
}
diff --git a/Model/MessageMetadata.php b/Model/MessageMetadata.php
index 39b27871..c24b29a1 100644
--- a/Model/MessageMetadata.php
+++ b/Model/MessageMetadata.php
@@ -15,16 +15,13 @@ public function getParticipant()
return $this->participant;
}
- /**
- * @param ParticipantInterface $participant
- */
public function setParticipant(ParticipantInterface $participant)
{
$this->participant = $participant;
}
/**
- * @return boolean
+ * @return bool
*/
public function getIsRead()
{
@@ -32,10 +29,10 @@ public function getIsRead()
}
/**
- * @param boolean $isRead
+ * @param bool $isRead
*/
public function setIsRead($isRead)
{
- $this->isRead = (boolean)$isRead;
+ $this->isRead = (bool) $isRead;
}
}
diff --git a/Model/ParticipantInterface.php b/Model/ParticipantInterface.php
index 40222450..6849dec9 100644
--- a/Model/ParticipantInterface.php
+++ b/Model/ParticipantInterface.php
@@ -12,9 +12,9 @@
interface ParticipantInterface
{
/**
- * Gets the unique identifier of the participant
+ * Gets the unique identifier of the participant.
*
- * @return string
+ * @return mixed
*/
public function getId();
}
diff --git a/Model/ReadableInterface.php b/Model/ReadableInterface.php
index 142839b5..5a4dcb0a 100644
--- a/Model/ReadableInterface.php
+++ b/Model/ReadableInterface.php
@@ -5,17 +5,17 @@
interface ReadableInterface
{
/**
- * Tells if this is read by this participant
+ * Tells if this is read by this participant.
*
* @return bool
*/
public function isReadByParticipant(ParticipantInterface $participant);
/**
- * Sets whether or not this participant has read this
+ * Sets whether or not this participant has read this.
*
* @param ParticipantInterface $participant
- * @param boolean $isRead
+ * @param bool $isRead
*/
public function setIsReadByParticipant(ParticipantInterface $participant, $isRead);
}
diff --git a/Model/Thread.php b/Model/Thread.php
index 7083f24b..fb1396c4 100644
--- a/Model/Thread.php
+++ b/Model/Thread.php
@@ -6,63 +6,63 @@
use Doctrine\Common\Collections\Collection;
/**
- * Abstract thread model
+ * Abstract thread model.
*
* @author Thibault Duplessis
*/
abstract class Thread implements ThreadInterface
{
/**
- * Unique id of the thread
+ * Unique id of the thread.
*
* @var mixed
*/
protected $id;
/**
- * Text subject of the thread
+ * Text subject of the thread.
*
* @var string
*/
protected $subject;
/**
- * Tells if the thread is spam or flood
+ * Tells if the thread is spam or flood.
*
- * @var boolean
+ * @var bool
*/
protected $isSpam = false;
/**
- * Messages contained in this thread
+ * Messages contained in this thread.
*
* @var Collection|MessageInterface[]
*/
protected $messages;
/**
- * Thread metadata
+ * Thread metadata.
*
* @var Collection|ThreadMetadata[]
*/
protected $metadata;
/**
- * Users participating in this conversation
+ * Users participating in this conversation.
*
* @var Collection|ParticipantInterface[]
*/
protected $participants;
/**
- * Date this thread was created at
+ * Date this thread was created at.
*
* @var \DateTime
*/
protected $createdAt;
/**
- * Participant that created the thread
+ * Participant that created the thread.
*
* @var ParticipantInterface
*/
@@ -135,7 +135,7 @@ public function setSubject($subject)
}
/**
- * @return boolean
+ * @return bool
*/
public function getIsSpam()
{
@@ -143,11 +143,11 @@ public function getIsSpam()
}
/**
- * @param boolean
+ * @param bool
*/
public function setIsSpam($isSpam)
{
- $this->isSpam = (boolean) $isSpam;
+ $this->isSpam = (bool) $isSpam;
}
/**
@@ -218,7 +218,7 @@ public function setIsDeletedByParticipant(ParticipantInterface $participant, $is
*/
public function setIsDeleted($isDeleted)
{
- foreach($this->getParticipants() as $participant) {
+ foreach ($this->getParticipants() as $participant) {
$this->setIsDeletedByParticipant($participant, $isDeleted);
}
}
@@ -261,6 +261,7 @@ public function addMetadata(ThreadMetadata $meta)
* Gets the ThreadMetadata for a participant.
*
* @param ParticipantInterface $participant
+ *
* @return ThreadMetadata
*/
public function getMetadataForParticipant(ParticipantInterface $participant)
diff --git a/Model/ThreadInterface.php b/Model/ThreadInterface.php
index 181e928c..7e230698 100644
--- a/Model/ThreadInterface.php
+++ b/Model/ThreadInterface.php
@@ -7,7 +7,7 @@
interface ThreadInterface extends ReadableInterface
{
/**
- * Gets the message unique id
+ * Gets the message unique id.
*
* @return mixed
*/
@@ -19,42 +19,39 @@ public function getId();
public function getSubject();
/**
- * @param string
- * @return null
+ * @param string
*/
public function setSubject($subject);
/**
- * Gets the messages contained in the thread
+ * Gets the messages contained in the thread.
*
- * @return Collection of MessageInterface
+ * @return MessageInterface[]|Collection
*/
public function getMessages();
/**
- * Adds a new message to the thread
- *
- * @param MessageInterface $message
+ * Adds a new message to the thread.
*/
public function addMessage(MessageInterface $message);
/**
- * Gets the first message of the thread
+ * Gets the first message of the thread.
*
- * @return MessageInterface the first message
+ * @return MessageInterface
*/
public function getFirstMessage();
/**
- * Gets the last message of the thread
+ * Gets the last message of the thread.
*
- * @return MessageInterface the last message
+ * @return MessageInterface
*/
public function getLastMessage();
/**
* Gets the participant that created the thread
- * Generally the sender of the first message
+ * Generally the sender of the first message.
*
* @return ParticipantInterface
*/
@@ -62,15 +59,13 @@ public function getCreatedBy();
/**
* Sets the participant that created the thread
- * Generally the sender of the first message
- *
- * @param ParticipantInterface
+ * Generally the sender of the first message.
*/
public function setCreatedBy(ParticipantInterface $participant);
/**
* Gets the date this thread was created at
- * Generally the date of the first message
+ * Generally the date of the first message.
*
* @return \DateTime
*/
@@ -78,55 +73,51 @@ public function getCreatedAt();
/**
* Sets the date this thread was created at
- * Generally the date of the first message
- *
- * @param \DateTime $createdAt
+ * Generally the date of the first message.
*/
public function setCreatedAt(\DateTime $createdAt);
/**
- * Gets the users participating in this conversation
+ * Gets the users participating in this conversation.
*
- * @return ParticipantInterface[]
+ * @return ParticipantInterface[]|Collection
*/
public function getParticipants();
/**
- * Tells if the user participates to the conversation
+ * Tells if the user participates to the conversation.
*
* @param ParticipantInterface $participant
- * @return boolean
+ *
+ * @return bool
*/
public function isParticipant(ParticipantInterface $participant);
/**
* Adds a participant to the thread
* If it already exists, nothing is done.
- *
- * @param ParticipantInterface $participant
- * @return null
*/
public function addParticipant(ParticipantInterface $participant);
/**
- * Tells if this thread is deleted by this participant
+ * Tells if this thread is deleted by this participant.
*
* @return bool
*/
public function isDeletedByParticipant(ParticipantInterface $participant);
/**
- * Sets whether or not this participant has deleted this thread
+ * Sets whether or not this participant has deleted this thread.
*
* @param ParticipantInterface $participant
- * @param boolean $isDeleted
+ * @param bool $isDeleted
*/
public function setIsDeletedByParticipant(ParticipantInterface $participant, $isDeleted);
/**
- * Sets the thread as deleted or not deleted for all participants
+ * Sets the thread as deleted or not deleted for all participants.
*
- * @param boolean $isDeleted
+ * @param bool $isDeleted
*/
public function setIsDeleted($isDeleted);
diff --git a/Model/ThreadMetadata.php b/Model/ThreadMetadata.php
index f988db8a..664fb474 100644
--- a/Model/ThreadMetadata.php
+++ b/Model/ThreadMetadata.php
@@ -8,14 +8,14 @@ abstract class ThreadMetadata
protected $isDeleted = false;
/**
- * Date of last message written by the participant
- *
- * @var \DateTime
- */
+ * Date of last message written by the participant.
+ *
+ * @var \DateTime
+ */
protected $lastParticipantMessageDate;
/**
- * Date of last message written by another participant
+ * Date of last message written by another participant.
*
* @var \DateTime
*/
@@ -29,16 +29,13 @@ public function getParticipant()
return $this->participant;
}
- /**
- * @param ParticipantInterface
- */
public function setParticipant(ParticipantInterface $participant)
{
$this->participant = $participant;
}
/**
- * @return boolean
+ * @return bool
*/
public function getIsDeleted()
{
@@ -46,11 +43,11 @@ public function getIsDeleted()
}
/**
- * @param boolean $isDeleted
+ * @param bool $isDeleted
*/
public function setIsDeleted($isDeleted)
{
- $this->isDeleted = (boolean)$isDeleted;
+ $this->isDeleted = (bool) $isDeleted;
}
/**
@@ -61,9 +58,6 @@ public function getLastParticipantMessageDate()
return $this->lastParticipantMessageDate;
}
- /**
- * @param \DateTime $date
- */
public function setLastParticipantMessageDate(\DateTime $date)
{
$this->lastParticipantMessageDate = $date;
@@ -77,9 +71,6 @@ public function getLastMessageDate()
return $this->lastMessageDate;
}
- /**
- * @param \DateTime $date
- */
public function setLastMessageDate(\DateTime $date)
{
$this->lastMessageDate = $date;
diff --git a/ModelManager/MessageManager.php b/ModelManager/MessageManager.php
index 16e00ec5..a2f092f0 100644
--- a/ModelManager/MessageManager.php
+++ b/ModelManager/MessageManager.php
@@ -13,7 +13,7 @@
abstract class MessageManager implements MessageManagerInterface
{
/**
- * Creates an empty message instance
+ * Creates an empty message instance.
*
* @return MessageInterface
*/
diff --git a/ModelManager/MessageManagerInterface.php b/ModelManager/MessageManagerInterface.php
index 072b0ceb..d68b1b6b 100644
--- a/ModelManager/MessageManagerInterface.php
+++ b/ModelManager/MessageManagerInterface.php
@@ -16,25 +16,26 @@
interface MessageManagerInterface extends ReadableManagerInterface
{
/**
- * Tells how many unread, non-spam, messages this participant has
+ * Tells how many unread, non-spam, messages this participant has.
*
* @param ParticipantInterface $participant
+ *
* @return int the number of unread messages
*/
public function getNbUnreadMessageByParticipant(ParticipantInterface $participant);
/**
- * Creates an empty message instance
+ * Creates an empty message instance.
*
* @return MessageInterface
*/
public function createMessage();
/**
- * Saves a message
+ * Saves a message.
*
* @param MessageInterface $message
- * @param Boolean $andFlush Whether to flush the changes (default true)
+ * @param bool $andFlush Whether to flush the changes (default true)
*/
public function saveMessage(MessageInterface $message, $andFlush = true);
diff --git a/ModelManager/ReadableManagerInterface.php b/ModelManager/ReadableManagerInterface.php
index c284e7d4..6e93feac 100644
--- a/ModelManager/ReadableManagerInterface.php
+++ b/ModelManager/ReadableManagerInterface.php
@@ -7,7 +7,7 @@
/**
* Capable of updating the read state of objects directly in the storage,
- * without modifying the state of the object
+ * without modifying the state of the object.
*
* @author Thibault Duplessis
*/
@@ -20,15 +20,15 @@ interface ReadableManagerInterface
* We want to show the unread readables on the page,
* as well as marking them as read.
*
- * @param ReadableInterface $readable
+ * @param ReadableInterface $readable
* @param ParticipantInterface $user
*/
public function markAsReadByParticipant(ReadableInterface $readable, ParticipantInterface $user);
/**
- * Marks the readable as unread by this participant
+ * Marks the readable as unread by this participant.
*
- * @param ReadableInterface $readable
+ * @param ReadableInterface $readable
* @param ParticipantInterface $user
*/
public function markAsUnreadByParticipant(ReadableInterface $readable, ParticipantInterface $user);
diff --git a/ModelManager/ThreadManager.php b/ModelManager/ThreadManager.php
index bab2e4ed..6a7a507c 100644
--- a/ModelManager/ThreadManager.php
+++ b/ModelManager/ThreadManager.php
@@ -13,7 +13,7 @@
abstract class ThreadManager implements ThreadManagerInterface
{
/**
- * Creates an empty comment thread instance
+ * Creates an empty comment thread instance.
*
* @return ThreadInterface
*/
diff --git a/ModelManager/ThreadManagerInterface.php b/ModelManager/ThreadManagerInterface.php
index 17e848d5..fa3155d1 100644
--- a/ModelManager/ThreadManagerInterface.php
+++ b/ModelManager/ThreadManagerInterface.php
@@ -16,7 +16,7 @@
interface ThreadManagerInterface extends ReadableManagerInterface
{
/**
- * Finds a thread by its ID
+ * Finds a thread by its ID.
*
* @return ThreadInterface or null
*/
@@ -29,6 +29,7 @@ public function findThreadById($id);
* In one word: an inbox.
*
* @param ParticipantInterface $participant
+ *
* @return Builder a query builder suitable for pagination
*/
public function getParticipantInboxThreadsQueryBuilder(ParticipantInterface $participant);
@@ -40,6 +41,7 @@ public function getParticipantInboxThreadsQueryBuilder(ParticipantInterface $par
* In one word: an inbox.
*
* @param ParticipantInterface $participant
+ *
* @return ThreadInterface[]
*/
public function findParticipantInboxThreads(ParticipantInterface $participant);
@@ -51,6 +53,7 @@ public function findParticipantInboxThreads(ParticipantInterface $participant);
* In one word: an sentbox.
*
* @param ParticipantInterface $participant
+ *
* @return Builder a query builder suitable for pagination
*/
public function getParticipantSentThreadsQueryBuilder(ParticipantInterface $participant);
@@ -62,24 +65,27 @@ public function getParticipantSentThreadsQueryBuilder(ParticipantInterface $part
* In one word: an sentbox.
*
* @param ParticipantInterface $participant
+ *
* @return ThreadInterface[]
*/
public function findParticipantSentThreads(ParticipantInterface $participant);
/**
* Finds deleted threads from a participant,
- * ordered by last message date
+ * ordered by last message date.
*
* @param ParticipantInterface $participant
+ *
* @return Builder a query builder suitable for pagination
*/
public function getParticipantDeletedThreadsQueryBuilder(ParticipantInterface $participant);
/**
* Finds deleted threads from a participant,
- * ordered by last message date
+ * ordered by last message date.
*
* @param ParticipantInterface $participant
+ *
* @return ThreadInterface[]
*/
public function findParticipantDeletedThreads(ParticipantInterface $participant);
@@ -90,7 +96,8 @@ public function findParticipantDeletedThreads(ParticipantInterface $participant)
* ordered by last message not written by this participant in reverse order.
*
* @param ParticipantInterface $participant
- * @param string $search
+ * @param string $search
+ *
* @return Builder a query builder suitable for pagination
*/
public function getParticipantThreadsBySearchQueryBuilder(ParticipantInterface $participant, $search);
@@ -101,37 +108,39 @@ public function getParticipantThreadsBySearchQueryBuilder(ParticipantInterface $
* ordered by last message not written by this participant in reverse order.
*
* @param ParticipantInterface $participant
- * @param string $search
+ * @param string $search
+ *
* @return ThreadInterface[]
*/
public function findParticipantThreadsBySearch(ParticipantInterface $participant, $search);
/**
- * Gets threads created by a participant
+ * Gets threads created by a participant.
*
* @param ParticipantInterface $participant
+ *
* @return ThreadInterface[]
*/
public function findThreadsCreatedBy(ParticipantInterface $participant);
/**
- * Creates an empty comment thread instance
+ * Creates an empty comment thread instance.
*
* @return ThreadInterface
*/
public function createThread();
/**
- * Saves a thread
+ * Saves a thread.
*
* @param ThreadInterface $thread
- * @param Boolean $andFlush Whether to flush the changes (default true)
+ * @param bool $andFlush Whether to flush the changes (default true)
*/
public function saveThread(ThreadInterface $thread, $andFlush = true);
/**
* Deletes a thread
- * This is not participant deletion but real deletion
+ * This is not participant deletion but real deletion.
*
* @param ThreadInterface $thread the thread to delete
*/
diff --git a/Provider/Provider.php b/Provider/Provider.php
index 56287583..7e249395 100644
--- a/Provider/Provider.php
+++ b/Provider/Provider.php
@@ -3,7 +3,6 @@
namespace FOS\MessageBundle\Provider;
use FOS\MessageBundle\Model\ParticipantInterface;
-use FOS\MessageBundle\Model\ThreadInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use FOS\MessageBundle\ModelManager\ThreadManagerInterface;
@@ -13,42 +12,42 @@
use FOS\MessageBundle\ModelManager\MessageManagerInterface;
/**
- * Provides threads for the current authenticated user
+ * Provides threads for the current authenticated user.
*
* @author Thibault Duplessis
*/
class Provider implements ProviderInterface
{
/**
- * The thread manager
+ * The thread manager.
*
* @var ThreadManagerInterface
*/
protected $threadManager;
/**
- * The message manager
+ * The message manager.
*
* @var MessageManagerInterface
*/
protected $messageManager;
/**
- * The reader used to mark threads as read
+ * The reader used to mark threads as read.
*
* @var ReaderInterface
*/
protected $threadReader;
/**
- * The authorizer manager
+ * The authorizer manager.
*
* @var authorizerInterface
*/
protected $authorizer;
/**
- * The participant provider instance
+ * The participant provider instance.
*
* @var ParticipantProviderInterface
*/
@@ -84,7 +83,7 @@ public function getSentThreads()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function getDeletedThreads()
{
@@ -122,7 +121,7 @@ public function getNbUnreadMessages()
}
/**
- * Gets the current authenticated user
+ * Gets the current authenticated user.
*
* @return ParticipantInterface
*/
diff --git a/Provider/ProviderInterface.php b/Provider/ProviderInterface.php
index ec7c02ee..f7adaf4b 100644
--- a/Provider/ProviderInterface.php
+++ b/Provider/ProviderInterface.php
@@ -5,28 +5,28 @@
use FOS\MessageBundle\Model\ThreadInterface;
/**
- * Provides threads for the current authenticated user
+ * Provides threads for the current authenticated user.
*
* @author Thibault Duplessis
*/
interface ProviderInterface
{
/**
- * Gets the thread in the inbox of the current user
+ * Gets the thread in the inbox of the current user.
*
* @return ThreadInterface[]
*/
public function getInboxThreads();
/**
- * Gets the thread in the sentbox of the current user
+ * Gets the thread in the sentbox of the current user.
*
* @return ThreadInterface[]
*/
public function getSentThreads();
/**
- * Gets the deleted threads of the current user
+ * Gets the deleted threads of the current user.
*
* @return ThreadInterface[]
*/
@@ -35,14 +35,14 @@ public function getDeletedThreads();
/**
* Gets a thread by its ID
* Performs authorization checks
- * Marks the thread as read
+ * Marks the thread as read.
*
* @return ThreadInterface
*/
public function getThread($threadId);
/**
- * Tells how many unread messages the authenticated participant has
+ * Tells how many unread messages the authenticated participant has.
*
* @return int the number of unread messages
*/
diff --git a/README.md b/README.md
index e171fef3..f373d7a5 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,7 @@
FOSMessageBundle
================
-> A maintainer has been found for this bundle but a new version is being rewritten from scratch.
-> This version (1.2) is maintained for bugs and issues but no features will be added. If you need more
-> features, don't hesitate to propose them in the library.
->
-> [Read more in the new library repository](https://github.com/FriendsOfSymfony/FOSMessage)
-
-This bundle provides messaging features for a Symfony2 application. Features available include:
+This bundle provides messaging features for a Symfony application. Features available include:
- Support for both the Doctrine ORM and ODM for message storage
- Threaded conversations
diff --git a/Reader/Reader.php b/Reader/Reader.php
index fd5442c7..49d9e587 100644
--- a/Reader/Reader.php
+++ b/Reader/Reader.php
@@ -11,28 +11,28 @@
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
- * Marks messages and threads as read or unread
+ * Marks messages and threads as read or unread.
*
* @author Thibault Duplessis
*/
class Reader implements ReaderInterface
{
/**
- * The participantProvider instance
+ * The participantProvider instance.
*
* @var ParticipantProviderInterface
*/
protected $participantProvider;
/**
- * The readable manager
+ * The readable manager.
*
* @var ReadableManagerInterface
*/
protected $readableManager;
/**
- * The event dispatcher
+ * The event dispatcher.
*
* @var EventDispatcherInterface
*/
@@ -74,7 +74,7 @@ public function markAsUnread(ReadableInterface $readable)
}
/**
- * Gets the current authenticated user
+ * Gets the current authenticated user.
*
* @return ParticipantInterface
*/
diff --git a/Reader/ReaderInterface.php b/Reader/ReaderInterface.php
index ad1acdb2..0319ffc7 100644
--- a/Reader/ReaderInterface.php
+++ b/Reader/ReaderInterface.php
@@ -5,23 +5,19 @@
use FOS\MessageBundle\Model\ReadableInterface;
/**
- * Marks messages and threads as read or unread
+ * Marks messages and threads as read or unread.
*
* @author Thibault Duplessis
*/
interface ReaderInterface
{
/**
- * Marks the readable as read by the current authenticated user
- *
- * @param ReadableInterface $readable
+ * Marks the readable as read by the current authenticated user.
*/
public function markAsRead(ReadableInterface $readable);
/**
- * Marks the readable as unread by the current authenticated user
- *
- * @param ReadableInterface $readable
+ * Marks the readable as unread by the current authenticated user.
*/
public function markAsUnread(ReadableInterface $readable);
}
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..ed532f0c 100644
--- a/Resources/config/form.xml
+++ b/Resources/config/form.xml
@@ -26,22 +26,22 @@
%fos_message.reply_form.model%
-
-
+
+
-
-
+
+
-
-
+
+
diff --git a/Resources/config/routing.xml b/Resources/config/routing.xml
index d4329c05..965840e0 100644
--- a/Resources/config/routing.xml
+++ b/Resources/config/routing.xml
@@ -4,37 +4,35 @@
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
-
+
FOSMessageBundle:Message:undelete
- 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/99-config-reference.md b/Resources/doc/99-config-reference.md
index 3b2dd2d4..d85a58dd 100644
--- a/Resources/doc/99-config-reference.md
+++ b/Resources/doc/99-config-reference.md
@@ -29,12 +29,12 @@ fos_message:
query_parameter: 'q' # Request query parameter containing the term
new_thread_form:
factory: fos_message.new_thread_form.factory # See FormFactory\NewThreadMessageFormFactory
- type: fos_message.new_thread_form.type # See FormType\NewThreadMessageFormType
+ type: FOS\MessageBundle\FormType\NewThreadMessageFormType
handler: fos_message.new_thread_form.handler # See FormHandler\NewThreadMessageFormHandler
name: message
reply_form:
factory: fos_message.reply_form.factory # See FormFactory\ReplyMessageFormFactory
- type: fos_message.reply_form.type # See FormType\ReplyMessageFormType
+ type: FOS\MessageBundle\FormType\ReplyMessageFormType
handler: fos_message.reply_form.handler # See FormHandler\ReplyMessageFormHandler
name: message
```
diff --git a/Resources/doc/99-using-other-user-bundles.md b/Resources/doc/99-using-other-user-bundles.md
index 157fb111..206dc925 100644
--- a/Resources/doc/99-using-other-user-bundles.md
+++ b/Resources/doc/99-using-other-user-bundles.md
@@ -150,8 +150,7 @@ You can copy and paste the bundle versions into your application and define them
-
+
%fos_message.new_thread_form.name%
diff --git a/Search/Finder.php b/Search/Finder.php
index 53d3d0f4..181e8e4c 100644
--- a/Search/Finder.php
+++ b/Search/Finder.php
@@ -3,26 +3,25 @@
namespace FOS\MessageBundle\Search;
use FOS\MessageBundle\Model\ParticipantInterface;
-use FOS\MessageBundle\Model\ThreadInterface;
use FOS\MessageBundle\ModelManager\ThreadManagerInterface;
use FOS\MessageBundle\Security\ParticipantProviderInterface;
/**
- * Finds threads of a participant, matching a given query
+ * Finds threads of a participant, matching a given query.
*
* @author Thibault Duplessis
*/
class Finder implements FinderInterface
{
/**
- * The participant provider instance
+ * The participant provider instance.
*
* @var ParticipantProviderInterface
*/
protected $participantProvider;
/**
- * The thread manager
+ * The thread manager.
*
* @var ThreadManagerInterface
*/
@@ -51,7 +50,7 @@ public function getQueryBuilder(Query $query)
}
/**
- * Gets the current authenticated user
+ * Gets the current authenticated user.
*
* @return ParticipantInterface
*/
diff --git a/Search/FinderInterface.php b/Search/FinderInterface.php
index 597dd9ed..b745d46b 100644
--- a/Search/FinderInterface.php
+++ b/Search/FinderInterface.php
@@ -5,24 +5,26 @@
use FOS\MessageBundle\Model\ThreadInterface;
/**
- * Finds threads of a participant, matching a given query
+ * Finds threads of a participant, matching a given query.
*
* @author Thibault Duplessis
*/
interface FinderInterface
{
/**
- * Finds threads of a participant, matching a given query
+ * Finds threads of a participant, matching a given query.
*
* @param Query $query
+ *
* @return ThreadInterface[]
*/
public function find(Query $query);
/**
- * Finds threads of a participant, matching a given query
+ * Finds threads of a participant, matching a given query.
*
* @param Query $query
+ *
* @return Builder a query builder suitable for pagination
*/
public function getQueryBuilder(Query $query);
diff --git a/Search/Query.php b/Search/Query.php
index eab152f9..12dc1638 100644
--- a/Search/Query.php
+++ b/Search/Query.php
@@ -3,7 +3,7 @@
namespace FOS\MessageBundle\Search;
/**
- * Search term
+ * Search term.
*/
class Query
{
@@ -60,7 +60,7 @@ public function setEscaped($escaped)
}
/**
- * Converts to the original term string
+ * Converts to the original term string.
*
* @return string
*/
diff --git a/Search/QueryFactory.php b/Search/QueryFactory.php
index 70e801a3..d000a1d8 100644
--- a/Search/QueryFactory.php
+++ b/Search/QueryFactory.php
@@ -3,33 +3,31 @@
namespace FOS\MessageBundle\Search;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\RequestStack;
/**
- * Gets the search term from the request and prepares it
+ * Gets the search term from the request and prepares it.
*/
class QueryFactory implements QueryFactoryInterface
{
- /**
- * @var Request
- */
protected $request;
/**
- * the query parameter containing the search term
+ * The query parameter containing the search term.
*
* @var string
*/
protected $queryParameter;
/**
- * Instanciates a new TermGetter
+ * Instanciates a new TermGetter.
*
- * @param Request $request
- * @param string $queryParameter
+ * @param RequestStack|Request $requestStack
+ * @param string $queryParameter
*/
- public function __construct(Request $request, $queryParameter)
+ public function __construct($requestStack, $queryParameter)
{
- $this->request = $request;
+ $this->request = $requestStack;
$this->queryParameter = $queryParameter;
}
@@ -38,7 +36,7 @@ public function __construct(Request $request, $queryParameter)
*/
public function createFromRequest()
{
- $original = $this->request->query->get($this->queryParameter);
+ $original = $this->getCurrentRequest()->query->get($this->queryParameter);
$original = trim($original);
$escaped = $this->escapeTerm($original);
@@ -47,7 +45,7 @@ public function createFromRequest()
}
/**
- * Sets: the query parameter containing the search term
+ * Sets: the query parameter containing the search term.
*
* @param string $queryParameter
*/
@@ -60,4 +58,18 @@ protected function escapeTerm($term)
{
return $term;
}
+
+ /**
+ * BC layer to retrieve the current request directly or from a stack.
+ *
+ * @return null|Request
+ */
+ private function getCurrentRequest()
+ {
+ if ($this->request instanceof Request) {
+ return $this->request;
+ }
+
+ return $this->request->getCurrentRequest();
+ }
}
diff --git a/Search/QueryFactoryInterface.php b/Search/QueryFactoryInterface.php
index ceaee7bf..3b365321 100644
--- a/Search/QueryFactoryInterface.php
+++ b/Search/QueryFactoryInterface.php
@@ -3,12 +3,12 @@
namespace FOS\MessageBundle\Search;
/**
- * Gets the search term from the request and prepares it
+ * Gets the search term from the request and prepares it.
*/
interface QueryFactoryInterface
{
/**
- * Gets the search term
+ * Gets the search term.
*
* @return Query the term object
*/
diff --git a/Security/Authorizer.php b/Security/Authorizer.php
index b699ae57..9abe3e5c 100644
--- a/Security/Authorizer.php
+++ b/Security/Authorizer.php
@@ -6,7 +6,7 @@
use FOS\MessageBundle\Model\ParticipantInterface;
/**
- * Manages permissions to manipulate threads and messages
+ * Manages permissions to manipulate threads and messages.
*
* @author Thibault Duplessis
*/
@@ -47,7 +47,7 @@ public function canMessageParticipant(ParticipantInterface $participant)
}
/**
- * Gets the current authenticated user
+ * Gets the current authenticated user.
*
* @return ParticipantInterface
*/
diff --git a/Security/AuthorizerInterface.php b/Security/AuthorizerInterface.php
index a922efd4..62eac8dc 100644
--- a/Security/AuthorizerInterface.php
+++ b/Security/AuthorizerInterface.php
@@ -6,7 +6,7 @@
use FOS\MessageBundle\Model\ParticipantInterface;
/**
- * Manages permissions to manipulate threads and messages
+ * Manages permissions to manipulate threads and messages.
*
* @author Thibault Duplessis
*/
@@ -14,28 +14,31 @@ interface AuthorizerInterface
{
/**
* Tells if the current user is allowed
- * to see this thread
+ * to see this thread.
*
* @param ThreadInterface $thread
- * @return boolean
+ *
+ * @return bool
*/
public function canSeeThread(ThreadInterface $thread);
/**
* Tells if the current participant is allowed
- * to delete this thread
+ * to delete this thread.
*
* @param ThreadInterface $thread
- * @return boolean
+ *
+ * @return bool
*/
public function canDeleteThread(ThreadInterface $thread);
/**
* Tells if the current participant is allowed
- * to send a message to this other participant
+ * to send a message to this other participant.
*
* @param ParticipantInterface $participant the one we want to send a message to
- * @return boolean
+ *
+ * @return bool
*/
public function canMessageParticipant(ParticipantInterface $participant);
}
diff --git a/Security/ParticipantProvider.php b/Security/ParticipantProvider.php
index 0fbc89d4..64582bcf 100644
--- a/Security/ParticipantProvider.php
+++ b/Security/ParticipantProvider.php
@@ -3,23 +3,33 @@
namespace FOS\MessageBundle\Security;
use Symfony\Component\Security\Core\SecurityContextInterface;
+use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use FOS\MessageBundle\Model\ParticipantInterface;
/**
- * Provides the authenticated participant
+ * Provides the authenticated participant.
*
* @author Thibault Duplessis
*/
class ParticipantProvider implements ParticipantProviderInterface
{
/**
- * @var SecurityContextInterface
+ * @var SecurityContextInterface|TokenStorageInterface
*/
protected $securityContext;
- public function __construct(SecurityContextInterface $securityContext)
+ public function __construct($securityContext)
{
+ if (!$securityContext instanceof SecurityContextInterface && !$securityContext instanceof TokenStorageInterface) {
+ throw new \InvalidArgumentException(sprintf(
+ 'Argument 1 passed to ParticipantProvider::__construct is not valid (instance of %s or %s expected, %s given)',
+ 'Symfony\Component\Security\Core\SecurityContextInterface',
+ 'Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface',
+ is_object($securityContext) ? get_class($securityContext) : gettype($securityContext)
+ ));
+ }
+
$this->securityContext = $securityContext;
}
diff --git a/Security/ParticipantProviderInterface.php b/Security/ParticipantProviderInterface.php
index a49a1763..2a53fecd 100644
--- a/Security/ParticipantProviderInterface.php
+++ b/Security/ParticipantProviderInterface.php
@@ -5,14 +5,14 @@
use FOS\MessageBundle\Model\ParticipantInterface;
/**
- * Provides the authenticated participant
+ * Provides the authenticated participant.
*
* @author Thibault Duplessis
*/
interface ParticipantProviderInterface
{
/**
- * Gets the current authenticated user
+ * Gets the current authenticated user.
*
* @return ParticipantInterface
*/
diff --git a/Sender/Sender.php b/Sender/Sender.php
index 0fb607bf..f0986b26 100644
--- a/Sender/Sender.php
+++ b/Sender/Sender.php
@@ -10,7 +10,7 @@
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
- * Sends messages
+ * Sends messages.
*
* @author Thibault Duplessis
*/
diff --git a/Sender/SenderInterface.php b/Sender/SenderInterface.php
index c038ebdb..7d86d77a 100644
--- a/Sender/SenderInterface.php
+++ b/Sender/SenderInterface.php
@@ -5,16 +5,14 @@
use FOS\MessageBundle\Model\MessageInterface;
/**
- * Sends messages
+ * Sends messages.
*
* @author Thibault Duplessis
*/
interface SenderInterface
{
/**
- * Sends the message
- *
- * @param MessageInterface $message
+ * Sends the given message.
*/
public function send(MessageInterface $message);
}
diff --git a/SpamDetection/AkismetSpamDetector.php b/SpamDetection/AkismetSpamDetector.php
index 5e5ebd40..3f6577bf 100644
--- a/SpamDetection/AkismetSpamDetector.php
+++ b/SpamDetection/AkismetSpamDetector.php
@@ -30,8 +30,8 @@ public function __construct(AkismetInterface $akismet, ParticipantProviderInterf
public function isSpam(NewThreadMessage $message)
{
return $this->akismet->isSpam(array(
- 'comment_author' => (string) $this->participantProvider->getAuthenticatedParticipant(),
- 'comment_content' => $message->getBody()
+ 'comment_author' => (string) $this->participantProvider->getAuthenticatedParticipant(),
+ 'comment_content' => $message->getBody(),
));
}
}
diff --git a/SpamDetection/SpamDetectorInterface.php b/SpamDetection/SpamDetectorInterface.php
index cfa38a14..f206dbb2 100644
--- a/SpamDetection/SpamDetectorInterface.php
+++ b/SpamDetection/SpamDetectorInterface.php
@@ -5,17 +5,18 @@
use FOS\MessageBundle\FormModel\NewThreadMessage;
/**
- * Tells whether or not a new message looks like spam
+ * Tells whether or not a new message looks like spam.
*
* @author Thibault Duplessis
*/
interface SpamDetectorInterface
{
/**
- * Tells whether or not a new message looks like spam
+ * Tells whether or not a new message looks like spam.
*
* @param NewThreadMessage $message
- * @return boolean true if it is spam, false otherwise
+ *
+ * @return bool true if it is spam, false otherwise
*/
public function isSpam(NewThreadMessage $message);
}
diff --git a/Tests/Document/ThreadDenormalizerTest.php b/Tests/Document/ThreadDenormalizerTest.php
index 2051998a..b5d35d4d 100644
--- a/Tests/Document/ThreadDenormalizerTest.php
+++ b/Tests/Document/ThreadDenormalizerTest.php
@@ -19,7 +19,7 @@ protected function setUp()
new DateTime('- 3 days'),
new DateTime('- 2 days'),
new DateTime('- 1 days'),
- new DateTime('- 1 hour')
+ new DateTime('- 1 hour'),
);
}
@@ -29,7 +29,7 @@ public function testDenormalize()
$user1 = $this->createParticipantMock('u1');
$user2 = $this->createParticipantMock('u2');
- /**
+ /*
* First message
*/
$message = $this->createMessageMock($user1, $user2, $this->dates[0]);
@@ -41,7 +41,7 @@ public function testDenormalize()
$this->assertSame(array('u2' => $this->dates[0]->getTimestamp()), $thread->getDatesOfLastMessageWrittenByOtherParticipant());
$this->assertSame(array('u1' => $this->dates[0]->getTimestamp()), $thread->getDatesOfLastMessageWrittenByParticipant());
- /**
+ /*
* Second message
*/
$message = $this->createMessageMock($user2, $user1, $this->dates[1]);
@@ -51,7 +51,7 @@ public function testDenormalize()
$this->assertSame(array('u1' => $this->dates[1]->getTimestamp(), 'u2' => $this->dates[0]->getTimestamp()), $thread->getDatesOfLastMessageWrittenByOtherParticipant());
$this->assertSame(array('u1' => $this->dates[0]->getTimestamp(), 'u2' => $this->dates[1]->getTimestamp()), $thread->getDatesOfLastMessageWrittenByParticipant());
- /**
+ /*
* Third message
*/
$message = $this->createMessageMock($user2, $user1, $this->dates[2]);
@@ -61,7 +61,7 @@ public function testDenormalize()
$this->assertSame(array('u1' => $this->dates[2]->getTimestamp(), 'u2' => $this->dates[0]->getTimestamp()), $thread->getDatesOfLastMessageWrittenByOtherParticipant());
$this->assertSame(array('u1' => $this->dates[0]->getTimestamp(), 'u2' => $this->dates[2]->getTimestamp()), $thread->getDatesOfLastMessageWrittenByParticipant());
- /**
+ /*
* Fourth message
*/
$message = $this->createMessageMock($user1, $user2, $this->dates[3]);
@@ -139,7 +139,7 @@ public function addMessage(MessageInterface $message)
}
/**
- * Sort denormalized properties to ease testing
+ * Sort denormalized properties to ease testing.
*/
protected function sortDenormalizedProperties()
{
@@ -147,7 +147,7 @@ protected function sortDenormalizedProperties()
ksort($this->datesOfLastMessageWrittenByParticipant);
ksort($this->datesOfLastMessageWrittenByOtherParticipant);
$participants = $this->participants->toArray();
- usort($participants, function(ParticipantInterface $p1, ParticipantInterface $p2) {
+ usort($participants, function (ParticipantInterface $p1, ParticipantInterface $p2) {
return $p1->getId() > $p2->getId();
});
$this->participants = new ArrayCollection($participants);
diff --git a/Tests/EntityManager/ThreadManagerTest.php b/Tests/EntityManager/ThreadManagerTest.php
index c55af149..128312b9 100644
--- a/Tests/EntityManager/ThreadManagerTest.php
+++ b/Tests/EntityManager/ThreadManagerTest.php
@@ -1,11 +1,12 @@
expects($this->exactly($createdByCalls))
->method('setCreatedBy')
@@ -151,7 +152,7 @@ protected function addThreadExpectations(&$thread, $createdByCalls=1, $createdAt
}
/**
- * Get a Participant
+ * Get a Participant.
*
* @param $id
*
@@ -171,7 +172,7 @@ protected function createParticipantMock($id)
}
/**
- * Returns a thread mock
+ * Returns a thread mock.
*
* @return mixed
*/
@@ -186,15 +187,16 @@ protected function createThreadMock()
class TestThreadManager extends ThreadManager
{
/**
- * Empty constructor
+ * Empty constructor.
*/
- public function __construct() { }
+ public function __construct()
+ {
+ }
/**
- * Make the function public
+ * Make the function public.
*
* @param ThreadInterface $thread
- *
*/
public function doCreatedByAndAt(ThreadInterface $thread)
{
diff --git a/Tests/Model/ThreadTest.php b/Tests/Model/ThreadTest.php
index 7f0b4555..d63b6e91 100644
--- a/Tests/Model/ThreadTest.php
+++ b/Tests/Model/ThreadTest.php
@@ -17,7 +17,7 @@ public function testGetOtherParticipants()
->method('getParticipants')
->will($this->returnValue(array($u1, $u2, $u3)));
- $toIds = function(array $participants) {
+ $toIds = function (array $participants) {
return array_map(function (ParticipantInterface $participant) {
return $participant->getId();
}, $participants);
diff --git a/Tests/Twig/Extension/MessageExtensionTest.php b/Tests/Twig/Extension/MessageExtensionTest.php
index 7716f6db..a61aeafb 100644
--- a/Tests/Twig/Extension/MessageExtensionTest.php
+++ b/Tests/Twig/Extension/MessageExtensionTest.php
@@ -5,90 +5,90 @@
use FOS\MessageBundle\Twig\Extension\MessageExtension;
/**
- * Testfile for MessageExtension
+ * Testfile for MessageExtension.
*/
class MessageExtensionTest extends \PHPUnit_Framework_TestCase
{
private $extension;
- private $participantProvider;
+ private $participantProvider;
private $provider;
private $authorizer;
private $participant;
-
- public function setUp()
- {
+
+ public function setUp()
+ {
$this->participantProvider = $this->getMock('FOS\MessageBundle\Security\ParticipantProviderInterface');
$this->provider = $this->getMock('FOS\MessageBundle\Provider\ProviderInterface');
- $this->authorizer = $this->getMock('FOS\MessageBundle\Security\AuthorizerInterface');
- $this->participant = $this->getMock('FOS\MessageBundle\Model\ParticipantInterface');
+ $this->authorizer = $this->getMock('FOS\MessageBundle\Security\AuthorizerInterface');
+ $this->participant = $this->getMock('FOS\MessageBundle\Model\ParticipantInterface');
$this->extension = new MessageExtension($this->participantProvider, $this->provider, $this->authorizer);
}
-
- public function testIsReadReturnsTrueWhenRead()
+
+ public function testIsReadReturnsTrueWhenRead()
{
$this->participantProvider->expects($this->once())->method('getAuthenticatedParticipant')->will($this->returnValue($this->participant));
$readAble = $this->getMock('FOS\MessageBundle\Model\ReadableInterface');
- $readAble->expects($this->once())->method('isReadByParticipant')->with($this->participant)->will($this->returnValue(true));
+ $readAble->expects($this->once())->method('isReadByParticipant')->with($this->participant)->will($this->returnValue(true));
$this->assertTrue($this->extension->isRead($readAble));
}
-
- public function testIsReadReturnsFalseWhenNotRead()
+
+ public function testIsReadReturnsFalseWhenNotRead()
{
$this->participantProvider->expects($this->once())->method('getAuthenticatedParticipant')->will($this->returnValue($this->participant));
$readAble = $this->getMock('FOS\MessageBundle\Model\ReadableInterface');
- $readAble->expects($this->once())->method('isReadByParticipant')->with($this->participant)->will($this->returnValue(false));
+ $readAble->expects($this->once())->method('isReadByParticipant')->with($this->participant)->will($this->returnValue(false));
$this->assertFalse($this->extension->isRead($readAble));
}
-
- public function testCanDeleteThreadWhenHasPermission()
+
+ public function testCanDeleteThreadWhenHasPermission()
{
$thread = $this->getThreadMock();
$this->authorizer->expects($this->once())->method('canDeleteThread')->with($thread)->will($this->returnValue(true));
- $this->assertTrue($this->extension->canDeleteThread($thread));
+ $this->assertTrue($this->extension->canDeleteThread($thread));
}
-
- public function testCanDeleteThreadWhenNoPermission()
+
+ public function testCanDeleteThreadWhenNoPermission()
{
$thread = $this->getThreadMock();
$this->authorizer->expects($this->once())->method('canDeleteThread')->with($thread)->will($this->returnValue(false));
- $this->assertFalse($this->extension->canDeleteThread($thread));
+ $this->assertFalse($this->extension->canDeleteThread($thread));
}
-
- public function testIsThreadDeletedByParticipantWhenDeleted()
+
+ public function testIsThreadDeletedByParticipantWhenDeleted()
{
$thread = $this->getThreadMock();
$this->participantProvider->expects($this->once())->method('getAuthenticatedParticipant')->will($this->returnValue($this->participant));
$thread->expects($this->once())->method('isDeletedByParticipant')->with($this->participant)->will($this->returnValue(true));
- $this->assertTrue($this->extension->isThreadDeletedByParticipant($thread));
+ $this->assertTrue($this->extension->isThreadDeletedByParticipant($thread));
}
-
- public function testGetNbUnreadCacheStartsEmpty()
- {
+
+ public function testGetNbUnreadCacheStartsEmpty()
+ {
$this->assertAttributeEmpty('nbUnreadMessagesCache', $this->extension);
$this->extension->getNbUnread();
}
-
- public function testGetNbUnread()
+
+ public function testGetNbUnread()
{
$this->assertAttributeEmpty('nbUnreadMessagesCache', $this->extension);
$this->provider->expects($this->once())->method('getNbUnreadMessages')->will($this->returnValue(3));
$this->assertEquals(3, $this->extension->getNbUnread());
}
-
- public function testGetNbUnreadStoresCache()
+
+ public function testGetNbUnreadStoresCache()
{
$this->provider->expects($this->once())->method('getNbUnreadMessages')->will($this->returnValue(3));
//we call it twice but expect to only get one call
$this->extension->getNbUnread();
$this->extension->getNbUnread();
}
-
- public function testGetName()
+
+ public function testGetName()
{
- $this->assertEquals('fos_message' , $this->extension->getName());
+ $this->assertEquals('fos_message', $this->extension->getName());
}
-
- protected function getThreadMock()
+
+ protected function getThreadMock()
{
return $this->getMock('FOS\MessageBundle\Model\ThreadInterface');
}
diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php
index 70526bb5..384da18c 100644
--- a/Tests/bootstrap.php
+++ b/Tests/bootstrap.php
@@ -4,7 +4,7 @@
use Composer\Autoload\ClassLoader;
/**
- * @var ClassLoader $loader
+ * @var ClassLoader
*/
$loader = require __DIR__.'/../vendor/autoload.php';
diff --git a/Twig/Extension/MessageExtension.php b/Twig/Extension/MessageExtension.php
index 84cdbc5e..4865fcf0 100644
--- a/Twig/Extension/MessageExtension.php
+++ b/Twig/Extension/MessageExtension.php
@@ -38,42 +38,41 @@ public function getFunctions()
}
/**
- * Tells if this readable (thread or message) is read by the current user
+ * Tells if this readable (thread or message) is read by the current user.
*
- * @return boolean
+ * @return bool
*/
public function isRead(ReadableInterface $readable)
{
return $readable->isReadByParticipant($this->getAuthenticatedParticipant());
}
-
-
+
/**
- * Checks if the participant can mark a thread as deleted
- *
+ * Checks if the participant can mark a thread as deleted.
+ *
* @param ThreadInterface $thread
- *
- * @return boolean true if participant can mark a thread as deleted, false otherwise
+ *
+ * @return bool true if participant can mark a thread as deleted, false otherwise
*/
public function canDeleteThread(ThreadInterface $thread)
{
return $this->authorizer->canDeleteThread($thread);
}
-
+
/**
- * Checks if the participant has marked the thread as deleted
- *
+ * Checks if the participant has marked the thread as deleted.
+ *
* @param ThreadInterface $thread
- *
- * @return boolean true if participant has marked the thread as deleted, false otherwise
+ *
+ * @return bool true if participant has marked the thread as deleted, false otherwise
*/
public function isThreadDeletedByParticipant(ThreadInterface $thread)
{
- return $thread->isDeletedByParticipant($this->getAuthenticatedParticipant());
+ return $thread->isDeletedByParticipant($this->getAuthenticatedParticipant());
}
/**
- * Gets the number of unread messages for the current user
+ * Gets the number of unread messages for the current user.
*
* @return int
*/
@@ -87,7 +86,7 @@ public function getNbUnread()
}
/**
- * Gets the current authenticated user
+ * Gets the current authenticated user.
*
* @return ParticipantInterface
*/
diff --git a/UPGRADING.md b/UPGRADING.md
new file mode 100644
index 00000000..74a9257a
--- /dev/null
+++ b/UPGRADING.md
@@ -0,0 +1,36 @@
+Upgrade from 1.2 to 1.3
+=======================
+
+The 1.3 version added the support for Symfony 3.0+. Several changes were made for the code to work with the new version.
+
+ * **BC break**: `Controller\MessageController` now implements `Symfony\Component\DependencyInjection\ContainerAwareInterface`
+ instead of extending the abstract class `Symfony\Component\DependencyInjection\ContainerAware` (removed in Symfony 3.0).
+ If you relied on this (for instance by using `MessageController instanceof ContainerAware`), you may have to change
+ your code.
+
+ * Form types are now classes names instead of service references (the usage of service references is therefore deprecated).
+ If you used your own form types for new threads and replies, you should update your configuration:
+
+ Before:
+
+ ```yaml
+ fos_message:
+ # ...
+
+ new_thread_form:
+ type: app.custom_new_thread_form_service
+ reply_form:
+ type: app.custom_reply_form_service
+ ```
+
+ After:
+
+ ```yaml
+ fos_message:
+ # ...
+
+ new_thread_form:
+ type: AppBundle\Form\Type\NewThreadFormType
+ reply_form:
+ type: AppBundle\Form\Type\ReplyFormType
+ ```
diff --git a/Util/LegacyFormHelper.php b/Util/LegacyFormHelper.php
new file mode 100644
index 00000000..54cc5bf5
--- /dev/null
+++ b/Util/LegacyFormHelper.php
@@ -0,0 +1,49 @@
+
+ */
+final class LegacyFormHelper
+{
+ private static $map = array(
+ 'FOS\UserBundle\Form\Type\UsernameFormType' => 'fos_user_username',
+ 'FOS\MessageBundle\FormType\RecipientsType' => 'recipients_selector',
+ 'Symfony\Component\Form\Extension\Core\Type\EmailType' => 'email',
+ 'Symfony\Component\Form\Extension\Core\Type\PasswordType' => 'password',
+ 'Symfony\Component\Form\Extension\Core\Type\RepeatedType' => 'repeated',
+ 'Symfony\Component\Form\Extension\Core\Type\TextType' => 'text',
+ 'Symfony\Component\Form\Extension\Core\Type\TextareaType' => 'textarea',
+ );
+
+ public static function getType($class)
+ {
+ if (!self::isLegacy()) {
+ return $class;
+ }
+
+ if (!isset(self::$map[$class])) {
+ throw new \InvalidArgumentException(sprintf('Form type with class "%s" can not be found. Please check for typos or add it to the map in LegacyFormHelper', $class));
+ }
+
+ return self::$map[$class];
+ }
+
+ public static function isLegacy()
+ {
+ return !method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix');
+ }
+
+ private function __construct()
+ {
+ }
+
+ private function __clone()
+ {
+ }
+}
diff --git a/Validator/Authorization.php b/Validator/Authorization.php
index df448400..60c4655e 100644
--- a/Validator/Authorization.php
+++ b/Validator/Authorization.php
@@ -14,7 +14,7 @@ public function validatedBy()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function getTargets()
{
diff --git a/Validator/AuthorizationValidator.php b/Validator/AuthorizationValidator.php
index 328017e2..de565910 100644
--- a/Validator/AuthorizationValidator.php
+++ b/Validator/AuthorizationValidator.php
@@ -19,7 +19,7 @@ public function __construct(AuthorizerInterface $authorizer)
}
/**
- * Indicates whether the constraint is valid
+ * Indicates whether the constraint is valid.
*
* @param object $recipient
* @param Constraint $constraint
diff --git a/Validator/ReplyAuthorization.php b/Validator/ReplyAuthorization.php
index b42c9986..a9d16cfe 100644
--- a/Validator/ReplyAuthorization.php
+++ b/Validator/ReplyAuthorization.php
@@ -14,7 +14,7 @@ public function validatedBy()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function getTargets()
{
diff --git a/Validator/ReplyAuthorizationValidator.php b/Validator/ReplyAuthorizationValidator.php
index e7cc65f3..7f25c4c0 100644
--- a/Validator/ReplyAuthorizationValidator.php
+++ b/Validator/ReplyAuthorizationValidator.php
@@ -26,7 +26,7 @@ public function __construct(AuthorizerInterface $authorizer, ParticipantProvider
}
/**
- * Indicates whether the constraint is valid
+ * Indicates whether the constraint is valid.
*
* @param object $value
* @param Constraint $constraint
@@ -39,6 +39,7 @@ public function validate($value, Constraint $constraint)
foreach ($recipients as $recipient) {
if (!$this->authorizer->canMessageParticipant($recipient)) {
$this->context->addViolation($constraint->message);
+
return;
}
}
diff --git a/Validator/SelfRecipient.php b/Validator/SelfRecipient.php
index dcd5b91d..9c49b65d 100644
--- a/Validator/SelfRecipient.php
+++ b/Validator/SelfRecipient.php
@@ -14,7 +14,7 @@ public function validatedBy()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function getTargets()
{
diff --git a/Validator/SelfRecipientValidator.php b/Validator/SelfRecipientValidator.php
index f48b8fb2..596b5292 100644
--- a/Validator/SelfRecipientValidator.php
+++ b/Validator/SelfRecipientValidator.php
@@ -19,7 +19,7 @@ public function __construct(ParticipantProviderInterface $participantProvider)
}
/**
- * Indicates whether the constraint is valid
+ * Indicates whether the constraint is valid.
*
* @param object $recipient
* @param Constraint $constraint
diff --git a/Validator/Spam.php b/Validator/Spam.php
index f2621328..455cee15 100644
--- a/Validator/Spam.php
+++ b/Validator/Spam.php
@@ -14,7 +14,7 @@ public function validatedBy()
}
/**
- * {@inheritDoc}
+ * {@inheritdoc}
*/
public function getTargets()
{
diff --git a/Validator/SpamValidator.php b/Validator/SpamValidator.php
index db0530f2..9b0d1105 100644
--- a/Validator/SpamValidator.php
+++ b/Validator/SpamValidator.php
@@ -19,7 +19,7 @@ public function __construct(SpamDetectorInterface $spamDetector)
}
/**
- * Indicates whether the constraint is valid
+ * Indicates whether the constraint is valid.
*
* @param object $value
* @param Constraint $constraint
diff --git a/composer.json b/composer.json
index 2f088c19..5b172aeb 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "friendsofsymfony/message-bundle",
"type": "symfony-bundle",
- "description": "Provides user-to-user messaging features for your Symfony2 application.",
+ "description": "Provides user-to-user messaging features for your Symfony application.",
"keywords": ["symfony", "message", "messaging"],
"homepage": "https://github.com/FriendsOfSymfony/FOSMessageBundle",
"license": "MIT",
@@ -18,10 +18,14 @@
],
"require": {
"php": ">=5.3.2",
- "symfony/form": "~2.1",
- "symfony/framework-bundle": "~2.1",
- "symfony/security": "~2.1",
- "symfony/twig-bundle": "~2.1"
+ "doctrine/collections": "^1.3",
+ "symfony/form": "^2.7|^3.0",
+ "symfony/framework-bundle": "^2.7|^3.0",
+ "symfony/security": "^2.7|^3.0",
+ "symfony/twig-bundle": "^2.7|^3.0"
+ },
+ "require-dev": {
+ "symfony/phpunit-bridge": "^3.0"
},
"suggest": {
"doctrine/doctrine-bundle": "dev-master",