Skip to content

Instantly share code, notes, and snippets.

@makasim
makasim / gist:1091991
Created July 19, 2011 11:05
array_filter usage
<?php
class AdWizard
{
protected $steps = array();
// ...
/**
* How to find a step with an identifier provided using array_filter function
@makasim
makasim / gist:1134154
Created August 9, 2011 14:19
payment creation
<?php
$ppc = $this->paymentPluginController;
$price = '66.00';
$currency = 'USD';
$instruction = new PaymentInstruction($price, $currency, 'paypal_express_checkout', new ExtendedData());
$ppc->createPaymentInstruction($instruction);
@makasim
makasim / gist:1134194
Created August 9, 2011 14:29
Payment processing
<?php
public function paymentAction($paymentId)
{
$ppc = $this->container->get('payment.plugin_controller');
// todo get amount from payment
$result = $ppc->approve($paymentId, '66.00');
if (Result::STATUS_PENDING === $result->getStatus()) {
@makasim
makasim / gist:1148960
Created August 16, 2011 12:30
Doctrine2 validate schema test
<?php
<?php
namespace Foo\PaymentBundle\Tests\Database;
use Doctrine\ORM\Tools\SchemaValidator;
class ValidateSchemaTest extends BaseDatabaseTest
{
/**
@makasim
makasim / gist:1170108
Created August 25, 2011 06:37
symfony2 DI how to compile only doctrine bundle
<?php
namespace Foo;
//use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension;
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
@makasim
makasim / gist:1172832
Created August 26, 2011 06:31 — forked from vatson/gist:1171992
chain prototype
<?php
$exceptionFilter = new ExceptionFilterHandler();
$exceptionFilter->allow('MyBundle\AbstractException')
->ignore('MyBundle\ConcreteException');
$errorFilter = new ErrorFilterHandler();
$errorFilter->allow(UniversalErrorCatcher_ErrorCode::E_CORE_ERROR)
->ignore(UniversalErrorCatcher_ErrorCode::E_ERROR);
@makasim
makasim / gist:1188358
Created September 2, 2011 10:40
how to easy setup dev env for sf project
/etc/apache2/httpd.conf
<Macro sf $host $dir>
<VirtualHost $host.dev:80>
DocumentRoot /home/maksim/projects/$dir
<Directory />
Order Allow,Deny
Allow from All
</Directory>
@makasim
makasim / gist:1213811
Created September 13, 2011 13:34
[security] custom factories
<?php
private function createListenerFactories(ContainerBuilder $container, $config)
{
if (null !== $this->factories) {
return $this->factories;
}
// load service templates
$c = new ContainerBuilder();
@makasim
makasim / gist:1231469
Created September 21, 2011 07:31
IE hacks

Please use property-level hacks :)

The problem with conditional comments:

This requires to maintain IE-specific style in a separate file; What I learned from doing this is that you always forget to update the the IE-specific style as you modify the main style


The problem with .ie-[6789] classes:

@makasim
makasim / gist:1244593
Created September 27, 2011 08:19
Symfony2 + UniversalErrorHandler
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\HttpKernel\Debug\ExceptionHandler;
use UniversalErrorCatcher_Catcher;
class AppKernel extends Kernel
{
public function init()