Skip to content

Instantly share code, notes, and snippets.

@makasim
makasim / gist:1264135
Created October 5, 2011 10:32
Twig. How to add dir with templates
<?php
use Symfony\Component\DependencyInjection\ContainerInterface;
class Foo_Twig_Extension extends Twig_Extension
{
protected $container;
public function __construct(ContainerInterface $container)
{
@makasim
makasim / gist:1422902
Created December 2, 2011 11:25
[doctrine2] quering entities with STI (Single table inheritance) pattern
<?php
/** @ORM\Table(name="file")
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="function", type="smallint")
* @ORM\DiscriminatorMap({
* "1" = "\..\File\CvFile",
* "2" = "\..\File\CvWebFile",
* "3" = "\..\File\KbisFile"
* })
@makasim
makasim / badaboom.bootstrap.php
Created December 8, 2011 10:31
BadaBoom usecase example
<?php
require_once 'autoload.php';
$filterClass = new \BadaBoom\ChainNode\Filter\ExceptionClassFilter();
$filterClass->allow('Exception');
$summaryProvider = new \BadaBoom\ChainNode\Provider\ExceptionSummaryProvider();
$subjectProvider = new \BadaBoom\ChainNode\Provider\ExceptionSubjectProvider();
@makasim
makasim / gist:1605987
Created January 13, 2012 13:02
Show trace in selenium tests
<?php
protected function onNotSuccessfulTest(\Exception $e)
{
try {
return parent::onNotSuccessfulTest($e);
} catch (\Exception $newException) {
if ($e instanceof \PHPUnit_Framework_ExpectationFailedException && false == $e->getComparisonFailure()) {
throw $e;
}
@makasim
makasim / gist:1876697
Created February 21, 2012 14:00
какой вариант правильней?
<?php
// var 1
$convertObjectToArray = null;
$convertObjectToArray = function($value) use (&$convertObjectToArray) {
if (is_object($value)) {
return array_map($convertObjectToArray, get_object_vars($value));
}
if (is_array($value)) {
@makasim
makasim / deploy.sh
Created March 20, 2012 10:21 — forked from Seldaek/deploy.sh
Deployment script
#!/bin/sh
targetUser="seld"
targetHost="seld.be"
parentDir="/home/seld"
childDir="packagist.org"
port="22"
configFile="~/etc/conf/$childDir"
/*
[exception] 500 | Internal Server Error | RuntimeException
[message] The source file &quot;/home/maksim/projects/RemixCv/app/../web/bundles/core/js/ember/ember-rest.js&quot; does not exist.
[1] RuntimeException: The source file &quot;/home/maksim/projects/RemixCv/app/../web/bundles/core/js/ember/ember-rest.js&quot; does not exist.
at n/a
in /home/maksim/projects/RemixCv/vendor/kriswallsmith/assetic/src/Assetic/Asset/FileAsset.php line 74
at Assetic\Asset\FileAsset-&gt;getLastModified()
in /home/maksim/projects/RemixCv/vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Controller/AsseticController.php line 72
@makasim
makasim / gist:2477272
Created April 24, 2012 07:00
jms paypal payment. sync pendings command.
<?php
namespace Foo\XXXBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use JMS\Payment\CoreBundle\Plugin\Exception\CommunicationException;
use JMS\Payment\CoreBundle\Entity\Payment;
use JMS\Payment\CoreBundle\Plugin\PluginInterface;
@makasim
makasim / gist:2971047
Created June 22, 2012 07:35
[FansFeed] europeLeague
{% include "GraphBundle:Index:_renderRound.html.twig" with { "round": round } only %}
{% if round.winnerRound %}
{% include "GraphBundle:Index:_renderEuropaLeagueRound.html.twig" with {"round": round.winnerRound } only %}
{% endif %}
@makasim
makasim / gist:3169492
Created July 24, 2012 11:34
if? ге не слышал
<?php
while ($condition) {
// do super stuff here.
break;
}