Skip to content

Instantly share code, notes, and snippets.

View JuanLuisGarciaBorrego's full-sized avatar
🏠
Working from home

Juan Luis García Borrego JuanLuisGarciaBorrego

🏠
Working from home
View GitHub Profile
<?php
#MegaDrive.php
class MegaDrive
{
public function jugar(){
$juego = new Sonic('nivelFacil');
return $juego->play();
<?php
#MegaDrive.php
$juego = new Sonic('nivelFacil');
class MegaDrive()
{
public function jugar(){
global $juego;
<?php
#MegaDrive.php
class MegaDrive
{
protected $juego;
public function __construct($juego){
$this->juego = $juego:
<?php
#MegaDriveJuegosDI.php
$Sonic = new Sonic('nivelFacil');
$Fifa = new Fifa();
$JugarMegaDriveHoy = new MegaDrive($Sonic);
$JugarMegaDriveHoy->jugar();
$JugarMegaDriveManana = new MegaDrive($Fifa);
<?php
#MegaDriveTiposParametrosDI.php
$Fifa = new Fifa();
//Paso mediante Constructor
$JugarMegaDrive = new MegaDrive($Fifa);
//Paso mediante método
$JugarMegaDrive = new MegaDrive();
<?php
#OptimizacionMegaDriveDI.php
//Objectos juegos disponibles
$Fifa = new Fifa();
$Sonic = new Sonic('nivelFacil');
//Una sola instancia de MegaDrive
$JugarMegaDrive = new MegaDrive();
@JuanLuisGarciaBorrego
JuanLuisGarciaBorrego / TaskType.php
Created December 17, 2014 14:07
Form/Type/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 August 29, 2015 14:11
Form/Type/TaskTypeEvent.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
@JuanLuisGarciaBorrego
JuanLuisGarciaBorrego / AddBameFieldOnlyForCreateNewTaskSusbscriber.php
Created December 17, 2014 14:36
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()
@JuanLuisGarciaBorrego
JuanLuisGarciaBorrego / TaskType-eventsubscriber.php
Last active August 29, 2015 14:11
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
{