Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Juan Luis García Borrego JuanLuisGarciaBorrego

🏠
Working from home
View GitHub Profile
View MegaDrive-var-globales.php
<?php
#MegaDrive.php
$juego = new Sonic('nivelFacil');
class MegaDrive()
{
public function jugar(){
global $juego;
View MegaDrive-sin-DI.php
<?php
#MegaDrive.php
class MegaDrive
{
public function jugar(){
$juego = new Sonic('nivelFacil');
return $juego->play();
View MegaDrive-con-DI.php
<?php
#MegaDrive.php
class MegaDrive
{
protected $juego;
public function __construct($juego){
$this->juego = $juego:
View #MegaDriveJuegosDI.php
<?php
#MegaDriveJuegosDI.php
$Sonic = new Sonic('nivelFacil');
$Fifa = new Fifa();
$JugarMegaDriveHoy = new MegaDrive($Sonic);
$JugarMegaDriveHoy->jugar();
$JugarMegaDriveManana = new MegaDrive($Fifa);
View MegaDriveTiposParametrosDI.php
<?php
#MegaDriveTiposParametrosDI.php
$Fifa = new Fifa();
//Paso mediante Constructor
$JugarMegaDrive = new MegaDrive($Fifa);
//Paso mediante método
$JugarMegaDrive = new MegaDrive();
View OptimizacionMegaDriveDI.php
<?php
#OptimizacionMegaDriveDI.php
//Objectos juegos disponibles
$Fifa = new Fifa();
$Sonic = new Sonic('nivelFacil');
//Una sola instancia de MegaDrive
$JugarMegaDrive = new MegaDrive();
View TaskType-eventsubscriber.php
<?php
namespace JuanLuis\LabBundle\Form\Type;
use JuanLuis\LabBundle\Form\EventListener\AddNameFieldOnlyForCreateNewTaskSubscriber;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class TaskType extends AbstractType
{
View TaskType.php
<?php
namespace JuanLuis\LabBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class TaskType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
@JuanLuisGarciaBorrego
JuanLuisGarciaBorrego / Event-TaskType.php
Last active Aug 29, 2015
Form/Type/TaskTypeEvent.php
View Event-TaskType.php
<?php
namespace JuanLuis\LabBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
/*
* La Clase FormEvent es una clase que extiende el EventDispatcher
*
* La Clase FormEvents contiene los diferentes eventos que pueden
View AddBameFieldOnlyForCreateNewTaskSusbscriber.php
<?php
namespace JuanLuis\LabBundle\Form\EventListener;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class AddNameFieldOnlyForCreateNewTaskSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()