Skip to content

Instantly share code, notes, and snippets.

View andreia's full-sized avatar
❤️
coding

Andréia Bohner andreia

❤️
coding
View GitHub Profile
<?php
namespace Acme\Component;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use OldSound\RabbitMqBundle\RabbitMq\ConsumerInterface;
use PhpAmqpLib\Message\AMQPMessage;
class GenerateImageConsumer implements ConsumerInterface
{
acme_generate_image_service:
class: Acme\Component\GenerateImageConsumer
arguments:
- @logger
acme.uploadimage:
class: Acme\Component\UploadImage
arguments:
- @old_sound_rabbit_mq.acme_generate_image_producer
- { generate_folder: "./generated/" }
<?php
namespace Acme\Component;
use OldSound\RabbitMqBundle\RabbitMq\Producer;
class UploadImage
{
protected $options = array();
protected $generateFolder = null;
<?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
@andreia
andreia / composer.json
Created March 7, 2013 11:14
From Symfony 2.1 to 2.2
diff --git a/composer.json b/composer.json
index 8f905d7..c2d7588 100644
--- a/composer.json
+++ b/composer.json
@@ -6,18 +6,18 @@
},
"require": {
"php": "&gt;=5.3.3",
- "symfony/symfony": "2.1.*",
@andreia
andreia / gist:4601078
Created January 23, 2013 01:51
Symfony2: Using absolute URLs for your assets
(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
@andreia
andreia / AddExpiresAtFieldSubscriber.php
Created January 23, 2013 01:41
Adding (and/or Removing) fields using Event Subscribers
<?php
// src/Bundle/Form/EventListener/AddExpiresAtFieldSubscriber.php
class AddExpiresAtFieldSubscriber implements EventSubscriberInterface
{
private $factory;
public function __construct(FormFactoryInterface $factory)
{
$this->factory = $factory;
<?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){
@andreia
andreia / onename
Created October 24, 2015 01:57
Verifying that +andreia is my blockchain ID. https://onename.com/andreia
Verifying that +andreia is my blockchain ID. https://onename.com/andreia