Skip to content

Instantly share code, notes, and snippets.

<?php
public function testSecurityRolesCanCreateChannelAction()
{
// Create a new client to browse the application
$client = static::createClient();
$mock_event_dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')
->disableOriginalConstructor()
->getMock();
1) Chatea\MyBundle\Tests\Controller\ChannelControllerTest::testSecurityRolesCanCreateChannelAction
Invalid argument supplied for foreach()
/var/www/workspace/apiChatea/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php:371
/var/www/workspace/apiChatea/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php:129
/var/www/workspace/apiChatea/app/bootstrap.php.cache:2867
/var/www/workspace/apiChatea/app/bootstrap.php.cache:2820
/var/www/workspace/apiChatea/app/bootstrap.php.cache:2944
/var/www/workspace/apiChatea/app/bootstrap.php.cache:2245
/var/www/workspace/apiChatea/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Client.php:81
@Chrysweel
Chrysweel / gist:6172811
Last active December 20, 2015 17:59
Entities: Section & Category with table intermediare. Relation ManyToOne - OneToMany. How can I get the categories of a section ?
Class Intermediare: CategorySection
<?php
/**
* @ORM\Entity(repositoryClass="xxx\SectionBundle\Repositories\GiftCategorySectionRepositoryDoctrine")
* @ORM\Table(name="gift_category_section")
*/
class GiftCategorySection
{
/**
* @ORM\Id
@Chrysweel
Chrysweel / gist:6139735
Created August 2, 2013 13:07
Serialize twice
My controller:
/**
* @ParamConverter("channel", class="ApiBundle:Channel")
*/
public function showAction(Channel $channel, Request $request)
{
$serializer = $this->container->get('serializer');
$channel = $serializer->serialize($channel, 'json', SerializationContext::create()->setGroups(array('list')));
@Chrysweel
Chrysweel / gist:5908221
Created July 2, 2013 10:23
Get the error from a form and send this error by rest
public function createAction(Request $request)
{
$entity = new Channel();
$form = $this->createForm(new ChannelType(), $entity);
$form->bind($request);
if ($form->isValid()) {
$this->get('api.model.channel_manager')->save($entity);
$view = $this->view($entity, 201);
@Chrysweel
Chrysweel / gist:5720254
Last active December 18, 2015 03:48
Relation Many to Many, Artist - Event. One artist can to be a lot of events, and Event can to have a lot of artist.
I want to recuperate events of one artist.
My entity event:
/**
* @ORM\ManyToMany(targetEntity="myproject\ArtisaBundle\Entity\Artist", inversedBy="events")
* @ORM\JoinTable(name="events_artists")
**/
protected $artists;
public function setArtists($artists){
@Chrysweel
Chrysweel / gist:5575135
Created May 14, 2013 10:55
Recuperate object with DQL
/**
* @ORM\Entity
* @ORM\Table(name="asistencia")
* @ORM\Entity(repositoryClass="sdfs\sdfsBundle\EntityManager\AsistenciaRepository")
*/
class Asist{
/**
* @ORM\Id
@Chrysweel
Chrysweel / gist:5489407
Last active December 16, 2015 19:59
How Can I send object with Http.request ?? The call with "curl" works correctly!
In my config is:
"url": {
"host": "localhost",
"path": "/workspace/xxx",
"method": "GET",
"headers": {
"accept": "application/json"
}
}
@Chrysweel
Chrysweel / gist:5029390
Last active December 14, 2015 04:39
error pagination timeline
An exception has been thrown during the rendering of a template ("An exception occurred while executing 'SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id6 FROM (SELECT s0_.verb AS verb0, s0_.status_current AS status_current1, s0_.status_wanted AS status_wanted2, s0_.duplicate_key AS duplicate_key3, s0_.duplicate_priority AS duplicate_priority4, s0_.created_at AS created_at5, s0_.id AS id6, s1_.type AS type7, s1_.text AS text8, s1_.id AS id9, s2_.model AS model10, s2_.identifier AS identifier11, s2_.hash AS hash12, s2_.id AS id13, s1_.action_id AS action_id14, s1_.component_id AS component_id15 FROM spy_timeline_action s0_ INNER JOIN spy_timeline_action_component s3_ ON s0_.id = s3_.action_id AND ((s3_.action_id = s0_.id AND s3_.component_id = ? AND s3_.type = ?)) LEFT JOIN spy_timeline_action_component s1_ ON s0_.id = s1_.action_id LEFT JOIN spy_timeline_component s2_ ON s1_.component_id = s2_.id WHERE s0_.status_current = ? ORDER BY s0_.created_at DESC) dctrn_result) dctrn_table' with params {"1":"sub
@Chrysweel
Chrysweel / es.sh
Created February 7, 2012 17:53 — forked from aaronshaf/es.sh
Install ElasticSearch on Ubuntu 11.04
cd ~
sudo apt-get install unzip
sudo apt-get install python-software-properties -y
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
sudo apt-get install sun-java6-jre sun-java6-plugin -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.17.6.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz