Skip to content

Instantly share code, notes, and snippets.

View makasim's full-sized avatar

Max Kotliar makasim

View GitHub Profile
@makasim
makasim / gist:1014202
Created June 8, 2011 10:57
Symfony2 Command and logging
protected function execute(InputInterface $input, OutputInterface $output)
{
$fixtureDir = \APPLICATION_PATH . '/' . $input->getArgument('dir');
if (!\is_dir($fixtureDir)) {
throw new \Exception('The fixture dir `'.$fixtureDir.'` is not exist.');
}
$loader = new Loader();
$loader->loadFromDirectory($fixtureDir);
@makasim
makasim / gist:1038284
Created June 21, 2011 16:42
selenium in different window
#! /bin/bash
vncserver -kill :1
vncserver
DISPLAY=:1 selenium-server-standalone-2.0rc2.jar
@makasim
makasim / gist:1071844
Created July 8, 2011 13:39
list usage
<?php
/**
* Unserializes the user.
*
* @param string $serialized
*/
public function unserialize($serialized)
{
list(
<?php
/**
* @see Symfony\Component\Security\Core\Encoder\EncoderFactory::getEncoder()
*/
public function getEncoder(SecurityUserInterface $user)
{
if (!$user instanceof UserInterface) {
return $this->genericFactory->getEncoder($user);
}
@makasim
makasim / gist:1082450
Created July 14, 2011 13:30
doctrin2 + pagination
<?php
// Repository
namespace Rj\BlogBundle\Entity;
use Pagerfanta\Pagerfanta;
use Pagerfanta\Adapter\DoctrineORMAdapter;
/**
@makasim
makasim / gist:1084388
Created July 15, 2011 09:31
how to add custom action for selected ids in WhiteOctoberAdminBundle
<?php
class ArticleAdmin extends DoctrineORMAdmin
{
protected function configure()
{
// this clouse will be called
$batchActions['approve'] = function($selected, $container, $batchAction) {
var_dump($selected);
};
<?php
namespace Rj\CoreBundle\Enum;
abstract class Enum
{
/**
*
* @var array
*/
@makasim
makasim / gist:1089711
Created July 18, 2011 14:42
wizard controller
<?php
// Controller
namespace Rj\EmployerBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class AdWizardController extends Controller
{
@makasim
makasim / gist:1089714
Created July 18, 2011 14:43
wizard dic
parameters:
services:
rj.employer.ad.wizard:
class: Rj\EmployerBundle\AdWizard\AdWizard
scope: request
calls:
- [addStep, [@rj.employer.ad.wizard.choosePass]]
- [addStep, [@rj.employer.ad.wizard.employerProfile]]
@makasim
makasim / gist:1089716
Created July 18, 2011 14:44
wizard basic step
<?php
namespace Rj\Employer\AdWizard\Step;
abstract class BaseStep
{
abstract public function process();
abstract public function finished();