Skip to content

Instantly share code, notes, and snippets.

@saro0h
saro0h / configusersublime
Last active August 29, 2015 14:03
SublimeText config
{
"auto_complete": true,
"auto_complete_commit_on_tab": true,
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"ensure_newline_at_eof_on_save": true,
"font_size": 13.0,
"highlight_modified_tabs": true,
"ignored_packages":
[
"Vintage"
@saro0h
saro0h / timeAgoExtension.php
Last active August 29, 2015 14:04
Twig filer extension to compute how long from a date.
<?php
namespace Acme\Bundle\DemoBundle\Twig;
class TimeAgoExtension extends \Twig_Extension
{
public function getFilters()
{
return array(
new \Twig_SimpleFilter('time_ago', array($this, 'timeAgoFilter')),
@saro0h
saro0h / Paginator.php
Last active August 29, 2015 14:05
Test of a method doing a generation of URL
<?php
namespace Canopy\CoreBundle\Service;
use Doctrine\ORM\EntityManager;
use Symfony\Bundle\FrameworkBundle\Routing\Router;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
//…
class Paginator
<?php
namespace Acme\TrainingBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
class DefaultController extends Controller
{
@saro0h
saro0h / upload_file.md
Last active August 29, 2015 14:07
Upload de fichier

En tant qu'utilisateur, je dois pouvoir uploader un fichier PDF lors de la création d'un produit.

Critères d'acceptances :
[x] La création de produit se fait avec un formulaire.
[x] Un produit constitué d'un nom, d'un prix et d'un fichier PDF.
[x] Utiliser la configuration sémantique dans le bundle afin de rendre configurable le chemin d'upload de fichier et valider cette configuration.

Étapes :

@saro0h
saro0h / event-listener.md
Last active August 29, 2015 14:07
Event listener, event subscriber

En tant qu'utilisateur, je souhaite rendre mon site web disponible du dimanche au vendredi.

Critères d'acceptances :
[X] Faire un EventListener sur kernel.request qu'il soit déclenché au plus tôt
[X] N'exécuter la logique de l'eventListener uniquement s'il s'agit de la master request 
[X] La jours de disponibilité sont configurable
[X] Convertir l'eventListener en EventSubscriber 
[X] Créer un événements custom avec une méthode retournant un datetime
[X] Dans le event subscriber, dispatcher l'évènement custom 1 jour avant la fermeture. 
@saro0h
saro0h / cache.md
Last active March 14, 2016 00:32
Set some caching strategies with Symfony2

Without any strategy of cache

=> see commit: http://bit.ly/1wqwvbe

capture d ecran 2014-10-19 a 21 37 04



With the strategy of cache Cache-Control (private cache for client browser) with a max-age of 2 minutes (120 seconds)

Translation Kata

As a user, I need to see the french version of a shop when I click on the french flag, and the english version when I click on the american flag.

[X] The static message on the website must be translated.
[X] The local must be in the url.
[X] The list of products must be displayed from the database, in the two languages.
[X] The pages must look like these designs:

Kata Form Upload File

As a user, I need to upload a PDF with a Product.

[x] Create a Product through a form.
[x] A Product is composed of a name, price and a PDF document.
[x] Use semantical configuration in your Bundle so it can be possible to configure the path to the folder upload.