Skip to content
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c15f204
fix of deprecated functions
DenysMedvid Feb 26, 2016
6c0d24a
fix deprecated security.context
DenysMedvid Feb 26, 2016
5a5aaf0
Add Czech translation
dfridrich Apr 2, 2016
f502d35
Fix a typo
dfridrich Apr 2, 2016
e7e0ca5
Merge pull request #276 from dfridrich/patch-2
tgalopin Apr 2, 2016
e8f7956
Merge pull request #277 from dfridrich/patch-1
tgalopin Apr 2, 2016
fd2752f
Fixing deprecations
bassrock Apr 16, 2016
c78c9a7
Fix a typo
dfridrich Apr 18, 2016
f824ef8
Merge pull request #279 from dfridrich/patch-4
tgalopin Apr 18, 2016
cd4d911
Merge pull request #1 from Klinche/master
ownede May 6, 2016
e3a8d89
Merge pull request #2 from FriendsOfSymfony/symfony3
ownede May 6, 2016
ce904d7
Removed use of ContainerAware (removed in Symfony 3.0)
May 6, 2016
1837ca1
Update scoped services to use request_stack
ubermuda May 11, 2016
d0c3481
Update services to use token storage instead of security context
ubermuda May 11, 2016
f5843ea
Switch from ContainerAware to ContainerAwareInterface
ubermuda May 11, 2016
e367a88
Make container property protected in message controller
ubermuda May 11, 2016
b865d10
Update form factory configuration
ubermuda May 11, 2016
946e99e
Update form handler to use handleRequest instead of bind
ubermuda May 11, 2016
77bf522
Update forms to use new type declaration
ubermuda May 11, 2016
0608251
Update forms to use configureOptions
ubermuda May 11, 2016
aa9eaf5
Merge branch 'symfony3' of https://github.com/ubermuda/FOSMessageBund…
Jul 7, 2016
c334607
Merge branch 'symfony3' of https://github.com/ubermuda/FOSMessageBund…
Jul 7, 2016
90912fc
Merge branch 'ubermuda-symfony3' into symfony3
Jul 7, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions Controller/MessageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,28 @@

namespace FOS\MessageBundle\Controller;

use FOS\MessageBundle\Provider\ProviderInterface;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
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;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class MessageController extends Controller
class MessageController implements ContainerAwareInterface
{
/**
* @var ContainerInterface
*/
protected $container;

/**
* {@inheritDoc}
*/
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}

/**
* Displays the authenticated participant inbox
*
Expand Down Expand Up @@ -56,7 +70,7 @@ public function deletedAction()
* Displays a thread, also allows to reply to it
*
* @param string $threadId the thread id
*
*
* @return Response
*/
public function threadAction($threadId)
Expand Down Expand Up @@ -101,9 +115,9 @@ public function newThreadAction()

/**
* Deletes a thread
*
*
* @param string $threadId the thread id
*
*
* @return RedirectResponse
*/
public function deleteAction($threadId)
Expand All @@ -114,12 +128,12 @@ public function deleteAction($threadId)

return new RedirectResponse($this->container->get('router')->generate('fos_message_inbox'));
}

/**
* Undeletes a thread
*
*
* @param string $threadId
*
*
* @return RedirectResponse
*/
public function undeleteAction($threadId)
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,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('class')->defaultValue('FOS\MessageBundle\FormType\NewThreadMessageFormType')->cannotBeEmpty()->end()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is clearly a bc break, we need a bc layer to keep supporting the old option

->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()
Expand All @@ -61,7 +61,7 @@ public function getConfigTreeBuilder()
->addDefaultsIfNotSet()
->children()
->scalarNode('factory')->defaultValue('fos_message.reply_form.factory.default')->cannotBeEmpty()->end()
->scalarNode('type')->defaultValue('fos_message.reply_form.type.default')->cannotBeEmpty()->end()
->scalarNode('class')->defaultValue('FOS\MessageBundle\FormType\ReplyMessageFormType')->cannotBeEmpty()->end()
->scalarNode('handler')->defaultValue('fos_message.reply_form.handler.default')->cannotBeEmpty()->end()
->scalarNode('name')->defaultValue('message')->cannotBeEmpty()->end()
->scalarNode('model')->defaultValue('FOS\MessageBundle\FormModel\ReplyMessage')->end()
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/FOSMessageExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ public function load(array $configs, ContainerBuilder $container)
$container->setParameter('fos_message.message_class', $config['message_class']);
$container->setParameter('fos_message.thread_class', $config['thread_class']);

$container->setParameter('fos_message.new_thread_form.class', $config['new_thread_form']['class']);
$container->setParameter('fos_message.new_thread_form.model', $config['new_thread_form']['model']);
$container->setParameter('fos_message.new_thread_form.name', $config['new_thread_form']['name']);
$container->setParameter('fos_message.reply_form.class', $config['reply_form']['class']);
$container->setParameter('fos_message.reply_form.model', $config['reply_form']['model']);
$container->setParameter('fos_message.reply_form.name', $config['reply_form']['name']);

Expand All @@ -51,10 +53,8 @@ public function load(array $configs, ContainerBuilder $container)
$container->setAlias('fos_message.spam_detector', $config['spam_detector']);
$container->setAlias('fos_message.twig_extension', $config['twig_extension']);

$container->setAlias('fos_message.new_thread_form.type', $config['new_thread_form']['type']);
$container->setAlias('fos_message.new_thread_form.factory', $config['new_thread_form']['factory']);
$container->setAlias('fos_message.new_thread_form.handler', $config['new_thread_form']['handler']);
$container->setAlias('fos_message.reply_form.type', $config['reply_form']['type']);
$container->setAlias('fos_message.reply_form.factory', $config['reply_form']['factory']);
$container->setAlias('fos_message.reply_form.handler', $config['reply_form']['handler']);

Expand Down
13 changes: 6 additions & 7 deletions FormFactory/AbstractMessageFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

namespace FOS\MessageBundle\FormFactory;

use FOS\MessageBundle\FormModel\AbstractMessage;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormFactoryInterface;
use FOS\MessageBundle\FormModel\AbstractMessage;

/**
* Instanciates message forms
Expand All @@ -21,11 +20,11 @@ abstract class AbstractMessageFormFactory
protected $formFactory;

/**
* The message form type
* The message form class
*
* @var AbstractType
* @var string
*/
protected $formType;
protected $formClass;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a bc break as well


/**
* The name of the form
Expand All @@ -41,10 +40,10 @@ abstract class AbstractMessageFormFactory
*/
protected $messageClass;

public function __construct(FormFactoryInterface $formFactory, AbstractType $formType, $formName, $messageClass)
public function __construct(FormFactoryInterface $formFactory, $formClass, $formName, $messageClass)
{
$this->formFactory = $formFactory;
$this->formType = $formType;
$this->formClass = $formClass;
$this->formName = $formName;
$this->messageClass = $messageClass;
}
Expand Down
2 changes: 1 addition & 1 deletion FormFactory/NewThreadMessageFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public function create()
{
$message = $this->createModelInstance();

return $this->formFactory->createNamed($this->formName, $this->formType, $message);
return $this->formFactory->createNamed($this->formName, $this->formClass, $message);
}
}
2 changes: 1 addition & 1 deletion FormFactory/ReplyMessageFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public function create(ThreadInterface $thread)
$message = $this->createModelInstance();
$message->setThread($thread);

return $this->formFactory->createNamed($this->formName, $this->formType, $message);
return $this->formFactory->createNamed($this->formName, $this->formClass, $message);
}
}
10 changes: 6 additions & 4 deletions FormHandler/AbstractMessageFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace FOS\MessageBundle\FormHandler;

use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\RequestStack;
use FOS\MessageBundle\Composer\ComposerInterface;
use FOS\MessageBundle\FormModel\AbstractMessage;
use FOS\MessageBundle\Model\ParticipantInterface;
Expand All @@ -25,9 +27,9 @@ abstract class AbstractMessageFormHandler

public function __construct(RequestStack $requestStack, ComposerInterface $composer, SenderInterface $sender, ParticipantProviderInterface $participantProvider)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bc break

{
$this->request = $requestStack->getCurrentRequest();
$this->composer = $composer;
$this->sender = $sender;
$this->request = $requestStack->getCurrentRequest();
Copy link
Member

@GuilhemN GuilhemN Jul 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The request must not be retrieved in the constructor.
You can do something like:

/**
 * @param Request|RequestStack $request
 */
public function __construct($request, ...) {
    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);
    }
    $this->request = $request;
    // ...
}

private function getCurrentRequest() {
   if ($this->request instanceof Request) {
      return $this->request;
   }

   return $this->request->getCurrentRequest();
}

public function process() {
    // ...
    $request = $this->getCurrentRequest();
}

$this->composer = $composer;
$this->sender = $sender;
$this->participantProvider = $participantProvider;
}

Expand All @@ -43,7 +45,7 @@ public function process(Form $form)
return false;
}

$form->bind($this->request);
$form->handleRequest($this->request);

if ($form->isValid()) {
return $this->processValidForm($form);
Expand Down
5 changes: 3 additions & 2 deletions FormType/NewThreadMessageFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace FOS\MessageBundle\FormType;

use FOS\UserBundle\Form\Type\UsernameFormType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

Expand All @@ -18,7 +19,7 @@ class NewThreadMessageFormType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('recipient', 'fos_user_username', array('label' => 'recipient', 'translation_domain' => 'FOSMessageBundle'))
->add('recipient', UsernameFormType::class, array('label' => 'recipient', 'translation_domain' => 'FOSMessageBundle'))
->add('subject', TextType::class, array('label' => 'subject', 'translation_domain' => 'FOSMessageBundle'))
->add('body', TextareaType::class, array('label' => 'body', 'translation_domain' => 'FOSMessageBundle'));
}
Expand Down
2 changes: 1 addition & 1 deletion FormType/RecipientsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
namespace FOS\MessageBundle\FormType;

use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\OptionsResolver\OptionsResolver;
use FOS\MessageBundle\DataTransformer\RecipientsDataTransformer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* Description of RecipientsType
Expand Down
38 changes: 20 additions & 18 deletions Resources/config/form.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,42 @@

<services>

<service id="fos_message.new_thread_form.type.default" class="FOS\MessageBundle\FormType\NewThreadMessageFormType" public="false" />

<service id="fos_message.new_thread_multiple_form.type" class="FOS\MessageBundle\FormType\NewThreadMultipleMessageFormType" public="false" />

<service id="fos_message.reply_form.type.default" class="FOS\MessageBundle\FormType\ReplyMessageFormType" public="false" />

<service id="fos_message.new_thread_form.factory.default" class="FOS\MessageBundle\FormFactory\NewThreadMessageFormFactory" public="false">
<argument type="service" id="form.factory" />
<argument type="service" id="fos_message.new_thread_form.type" />
<argument>%fos_message.new_thread_form.class%</argument>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be managed in a compiler pass

<argument>%fos_message.new_thread_form.name%</argument>
<argument>%fos_message.new_thread_form.model%</argument>
</service>

<service id="fos_message.reply_form.factory.default" class="FOS\MessageBundle\FormFactory\ReplyMessageFormFactory" public="false">
<argument type="service" id="form.factory" />
<argument type="service" id="fos_message.reply_form.type" />
<argument>%fos_message.reply_form.class%</argument>
<argument>%fos_message.reply_form.name%</argument>
<argument>%fos_message.reply_form.model%</argument>
</service>

<service id="fos_message.new_thread_form.handler.default"
class="FOS\MessageBundle\FormHandler\NewThreadMessageFormHandler"
parent="fos_message.reply_form.factory.default"
public="false" />
<service id="fos_message.new_thread_form.handler.default" class="FOS\MessageBundle\FormHandler\NewThreadMessageFormHandler" public="false">
<argument type="service" id="request_stack" />
<argument type="service" id="fos_message.composer" />
<argument type="service" id="fos_message.sender" />
<argument type="service" id="fos_message.participant_provider" />
</service>

<service id="fos_message.new_thread_multiple_form.handler"
class="FOS\MessageBundle\FormHandler\NewThreadMultipleMessageFormHandler"
parent="fos_message.reply_form.factory.default"
public="false" />
<service id="fos_message.new_thread_multiple_form.handler" class="FOS\MessageBundle\FormHandler\NewThreadMultipleMessageFormHandler" public="false">
<argument type="service" id="request_stack" />
<argument type="service" id="fos_message.composer" />
<argument type="service" id="fos_message.sender" />
<argument type="service" id="fos_message.participant_provider" />
</service>

<service id="fos_message.reply_form.handler.default"
class="FOS\MessageBundle\FormHandler\ReplyMessageFormHandler"
parent="fos_message.reply_form.factory.default"
public="false"/>
<service id="fos_message.reply_form.handler.default" class="FOS\MessageBundle\FormHandler\ReplyMessageFormHandler" public="false">
<argument type="service" id="request_stack" />
<argument type="service" id="fos_message.composer" />
<argument type="service" id="fos_message.sender" />
<argument type="service" id="fos_message.participant_provider" />
</service>

<service id="fos_message.recipients_data_transformer" class="FOS\MessageBundle\DataTransformer\RecipientsDataTransformer" public="false">
<argument type="service" id="fos_user.user_to_username_transformer" />
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/spam_detection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<service id="fos_message.noop_spam_detector" class="FOS\MessageBundle\SpamDetection\NoopSpamDetector" public="false" />

<service id="fos_message.akismet_spam_detector" class="FOS\MessageBundle\SpamDetection\AkismetSpamDetector" public="false" >
<service id="fos_message.akismet_spam_detector" class="FOS\MessageBundle\SpamDetection\AkismetSpamDetector" public="false">
<argument type="service" id="ornicar_akismet" />
<argument type="service" id="fos_message.participant_provider" />
</service>
Expand Down
4 changes: 2 additions & 2 deletions Search/QueryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class QueryFactory implements QueryFactoryInterface
/**
* @var Request
*/
protected $request;
protected $request = null;

/**
* the query parameter containing the search term
Expand All @@ -30,7 +30,7 @@ class QueryFactory implements QueryFactoryInterface
*/
public function __construct(RequestStack $requestStack, $queryParameter)
{
$this->request = $requestStack->getCurrentRequest();
$this->request = $requestStack->getCurrentRequest();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be implemented as described earlier

$this->queryParameter = $queryParameter;
}

Expand Down
6 changes: 5 additions & 1 deletion Security/ParticipantProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
*/
class ParticipantProvider implements ParticipantProviderInterface
{
/** @var TokenStorageInterface */
/**
* The token storage
*
* @var TokenStorageInterface
*/
protected $tokenStorage;

public function __construct(TokenStorageInterface $tokenStorage)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a bc break, the class should support both implementations.

Expand Down