This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | |
// Interface implementation for testing purposes | |
class MyParameterBag implements ParameterBagInterface | |
{ | |
private $container = array(); | |
public function add(array $parameters) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// With static validation, no object is created if not valid. | |
if (Locale::isValid($localeName)) { | |
$locale = new Locale($localeName); | |
doFancyStuffWith($locale); | |
} | |
// With explicit validation | |
$locale = new Locale($localeName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace xPheRe\Bundle\TagBundle; | |
use Symfony\Component\HttpKernel\Bundle\Bundle; | |
use Symfony\Component\DependencyInjection\ContainerBuilder; | |
use xPheRe\Bundle\TagBundle\DependencyInjection\Compiler\TagCollectionPass; | |
class xPheReTagBundle extends Bundle | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Download composer as explained in http://getcomposer.org/download | |
> curl -s https://getcomposer.org/installer | php | |
# Create a new Symfony2 project | |
> composer.phar create-project symfony/framework-standard-edition directory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$geocode = new \Google\Maps\Geocode\GeocodeService(); | |
$cachePath = $this->container->getParameter('kernel.root_dir') . '/../cache'; | |
$cache = new \Doctrine\Common\Cache\FilesystemCache($cachePath); | |
$cacheAdapter = new \Guzzle\Cache\DoctrineCacheAdapter($cache); | |
$cachePlugin = new \Guzzle\Plugin\Cache\CachePlugin($cacheAdapter); | |
$geocode->getClient()->addSubscriber($cachePlugin); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$observableUniverse = new Location('Universo observable'); | |
$virgoSuperCluster = new Location('Supercúmulo de Virgo', $observableUniverse); | |
$localGroup = new Location('Grupo Local', $virgoSuperCluster); | |
$milkyWay = new Location('Via Lactea', $localGroup); | |
$orionArm = new Location('Brazo de Orión', $milkyWay); | |
$solarSystem = new Location('Sistema Solar', $orionArm); | |
$earth = new Location('La Tierra', $solarSystem); | |
$europe = new Location('Europa', $earth); | |
$spain = new Location('España', $europe); | |
$catalonia = new Location('Catalunya', $spain); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Makes fn inherit from parent class | |
// Allows "super" calls ONLY in the constructor via Class.parent(this, param1, param2, ...) | |
// Also allows to extend the prototype giving more arguments | |
function inherit(parent, fn) { | |
fn || (fn = function() { }); | |
fn.prototype = Object.create(parent.prototype); | |
for (var i = 2; i < arguments.length; ++i) { | |
extend(fn.prototype, arguments[i]); | |
} | |
fn.prototype.constructor = fn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Event() { | |
} | |
extend(Event.prototype, { | |
propagationStopped: false, | |
stopPropagation: function() { | |
this.propagationStopped = true; | |
return this; | |
}, | |
isPropagationStopped: function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function extend(object) { | |
if (arguments.length > 1) { | |
for (var i = 1; i < arguments.length; ++i) { | |
for (j in arguments[i]) { | |
object[j] = arguments[i][j]; | |
} | |
} | |
} | |
return object; | |
} |
OlderNewer