Skip to content

Instantly share code, notes, and snippets.

View docteurklein's full-sized avatar

Florian Klein docteurklein

View GitHub Profile
@docteurklein
docteurklein / gist:5344071
Last active December 15, 2015 23:59
Form ChoiceType: entityChoiceList vs ObjectChoiceList
<?php
//$this->getUser()->getCandidates() returns an array of EUser entities
$entityChoiceListForm = $this->createForm('choice', null, array(
'choice_list' => new EntityChoiceList(
$this->get('doctrine')->getManager(),
'SSCoreBundle:EUser',
'name',
null,
@docteurklein
docteurklein / spec.php
Created April 26, 2013 13:24
phpspec mock Symfony's request
<?php
/**
* @param Symfony\Component\HttpFoundation\Request $request
* @param Symfony\Component\HttpFoundation\ParameterBag $bag
*/
function let($request, $bag)
{
$bag->get('id')->willReturn(1);
$request->query = $bag;
<?php
use Symfony\Bundle\FrameworkBundle\Routing\Router;
use JMS\Serializer\EventDispatcher\Event;
use Symfony\Component\Form\Util\PropertyPath;
class SerializerListener
{
private $router;
private $map;
@docteurklein
docteurklein / issue-to-pr.sh
Last active December 21, 2015 07:48
change a github issue to a pr
curl --user "docteurklein" -X POST \
"https://api.github.com/repos/KnpLabs/KnpRadBundle/pulls" \
-d'{"issue": 83, "head": "KnpLabs:bugfix/83-csrf-check-option", "base":"develop"}'
@docteurklein
docteurklein / SetServiceDecoratorPass.php
Created October 25, 2013 13:33
Decorate services with other services
<?php
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\Reference;
class SetServiceDecoratorPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
"id":"30",
"name":"app_article_list",
"javascript":null,
"stylesheet":null,
"raw_headers":null,
"title":"test seo",
"meta_description":"seo",
"meta_keyword":"seo",
"template_code":"article",
sf sonata:page:render-block sonata.page.cms.page 30 10
Block Information
> Id: 10 - type: sonata.block.service.text - name: title
>> content: "NEWS!"
>> template: "SonataBlockBundle:Block:block_core_text.html.twig"
>> code: "title"
BlockContext Information
>> use_cache: true
>> extra_cache_keys: []
<?php
class SomeScreenSpec
{
function it_should_definitly_allow_to_add_something_via_a_form()
{
$this->mink->doSomeStuff()->and()->assertSomeStuff();
}
}
@docteurklein
docteurklein / CompilerPass.php
Last active August 22, 2024 16:24
Service Repository Factory
<?php
public function process(ContainerBuilder $container)
{
$factory = $container->findDefinition('app.doctrine.repository.factory');
$repositories = [];
foreach ($container->findTaggedServiceIds('app.repository') as $id => $params) {
foreach ($params as $param) {
$repositories[$param['class']] = $id;
@docteurklein
docteurklein / Collaborator.php
Created August 16, 2014 19:55
a phpspec extension to ease usage of Iterators
<?php
namespace PhpSpec\Iterator;
use PhpSpec\Wrapper\Collaborator as Base;
use Prophecy\Prophecy\ObjectProphecy;
use Prophecy\Promise\ReturnPromise;
class Collaborator extends Base
{