This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| old_sound_rabbit_mq: | |
| connections: | |
| default: | |
| host: 'localhost' | |
| port: 5672 | |
| user: 'guest' | |
| password: 'guest' | |
| vhost: '/' | |
| lazy: false | |
| producers: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| acme_generate_image_service: | |
| class: Acme\Component\GenerateImageConsumer | |
| arguments: | |
| - @logger |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Acme\Component; | |
| use Symfony\Component\HttpKernel\Log\LoggerInterface; | |
| use OldSound\RabbitMqBundle\RabbitMq\ConsumerInterface; | |
| use PhpAmqpLib\Message\AMQPMessage; | |
| class GenerateImageConsumer implements ConsumerInterface | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| acme.uploadimage: | |
| class: Acme\Component\UploadImage | |
| arguments: | |
| - @old_sound_rabbit_mq.acme_generate_image_producer | |
| - { generate_folder: "./generated/" } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Acme\Component; | |
| use OldSound\RabbitMqBundle\RabbitMq\Producer; | |
| class UploadImage | |
| { | |
| protected $options = array(); | |
| protected $generateFolder = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * @Route("/acme/upload") | |
| */ | |
| public function uploadAction() | |
| { | |
| // realiza algum processamento, recebe o arquivo $file de um formulário, por exemplo | |
| // chama o serviço que faz o upload da imagem |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/composer.json b/composer.json | |
| index 8f905d7..c2d7588 100644 | |
| --- a/composer.json | |
| +++ b/composer.json | |
| @@ -6,18 +6,18 @@ | |
| }, | |
| "require": { | |
| "php": ">=5.3.3", | |
| - "symfony/symfony": "2.1.*", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (e.g. for email templates) | |
| Just set the assets_base_urls option under framework - templating key in your app/config/config.yml: | |
| framework: | |
| templating: | |
| assets_base_urls: http://www.something.com/web/ | |
| http://symfony.com/doc/current/reference/configuration/framework.html#assets-base-urls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // src/Bundle/Form/EventListener/AddExpiresAtFieldSubscriber.php | |
| class AddExpiresAtFieldSubscriber implements EventSubscriberInterface | |
| { | |
| private $factory; | |
| public function __construct(FormFactoryInterface $factory) | |
| { | |
| $this->factory = $factory; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| try{ | |
| $em = $this->getDoctrine()->getManager(); | |
| $em->persist($entity); | |
| $em->flush(); | |
| $this->get('session')->setFlash('notice', 'Article inserted!'); | |
| return $this->redirect($this->generateUrl('article_show', array('id' => $entity->getId()))); | |
| }catch(\Exception $e){ |