Skip to content

Instantly share code, notes, and snippets.

Genar Trias Ortiz gtrias

View GitHub Profile
View gist:c2d5af1da4b2672998c1
<?php
namespace Acme\Bundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
View KernelAwareTest.php
<?php
require_once dirname(__DIR__).'/../../../../app/AppKernel.php';
/**
* Test case class helpful with Entity tests requiring the database interaction.
* For regular entity tests it's better to extend standard \PHPUnit_Framework_TestCase instead.
*/
abstract class KernelAwareTest extends \PHPUnit_Framework_TestCase
{
View src\Acme\UserBundle\Entity\UserRepository.php
<?php
namespace Acme\UserBundle\Entity;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\Expr;
/**
* UserRepository
*
View ACLHelper.php
<?php
namespace WSL\BaseBundle\Util\Helper;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Security\Acl\Permission\MaskBuilder;
/*
* To change this template, choose Tools | Templates
@gtrias
gtrias / gist:bcfed8d66dd3ff4ea759
Created Jan 8, 2015
Get wordpress thumbnail url
View gist:bcfed8d66dd3ff4ea759
$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
@gtrias
gtrias / wp-config.php
Created Jan 8, 2015
Wordpress direct upload of files
View wp-config.php
define('FS_METHOD','direct');
View CompilerPass.php
<?php
public function process(ContainerBuilder $container)
{
$factory = $container->findDefinition('app.doctrine.repository.factory');
$repositories = [];
foreach ($container->findTaggedServiceIds('app.repository') as $id => $params) {
foreach ($params as $param) {
$repositories[$param['class']] = $id;
@gtrias
gtrias / gist:05ad8f5bd266d4b25ae1
Created Jan 26, 2015
Updating symfony2 bootstrap
View gist:05ad8f5bd266d4b25ae1
# In the 2.0 release the original file is here:
./vendor/bundles/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php
# In release 2.3 the file is here
vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php
View camel_case_functions.php
<?php
/**
* Translates a camel case string into a string with
* underscores (e.g. firstName -> first_name)
*
* @param string $str String in camel case format
* @return string $str Translated into underscore format
*/
function from_camel_case($str) {
$str[0] = strtolower($str[0]);
@gtrias
gtrias / .htaccess
Created Feb 19, 2015
Change document root from htaccess
View .htaccess
RewriteEngine on
RewriteBase /Retailer/
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
You can’t perform that action at this time.