Skip to content

Instantly share code, notes, and snippets.

View ger86's full-sized avatar
๐Ÿ 
Working from home

Gerardo Fernรกndez Moreno ger86

๐Ÿ 
Working from home
View GitHub Profile
<?php
namespace App\Tests;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class BlogPostsControllerTest extends WebTestCase {
public function testShowPost() {
$client = static::createClient();
<?php
namespace App\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormEvent;
<?php
namespace App\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormEvent;
<?php
namespace App\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\RouterInterface;
use App\Model\Person;
use App\Form\Type\Select2Type;
import 'select2/dist/js/select2.full.min.js';
export default () => {
const $select2 = $('.select2');
const autocompleteUrl = $select2.data('autocomplete-url');
$select2.select2({
ajax: {
url: autocompleteUrl,
data: params => ({ s: params.term}),
processResults: data => ({ results: data.map(d => ({id: d.id, text: d.name}))})
<?php
namespace App\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormInterface;
<?php
/**
* Get request
*
* @param string $path
* @param array $queryParams
* @return array
*/
public function get(string $path, array $queryParams = []): array {
<?php
...
use Symfony\Component\HttpFoundation\Session\SessionInterface;
...
class GuzzleApiRequest implements ApiRequestInterface {
/**
* Constructor
*
<?php
...
use Symfony\Component\HttpFoundation\RequestStack;
use GuzzleHttp\Cookie\CookieJar;
...
class GuzzleApiRequest implements ApiRequestInterface {
/**
<?php
namespace App\Service\Api;
interface ApiRequestInterface {
/**
* Get
*
* @param string $path