Skip to content

Instantly share code, notes, and snippets.

View bakura10's full-sized avatar

Michaël Gallego bakura10

View GitHub Profile
@bakura10
bakura10 / gist:3025309
Created June 30, 2012 20:11
Form collection
The simplest case allow to have the same element, multiple time. For instance, let's say we want to have two colors :
$element = new \Zend\Form\Element\Color();
$this->add(array(
'type' => 'Zend\Form\Element\Collection',
'name' => 'colors',
'attributes' => array(
'count' => 2,
'targetElement' => $element
)
@bakura10
bakura10 / gist:3028917
Created July 1, 2012 16:41
Multiple hydrator usage
class CreateForm extends \Zend\Form\Form
{
public function __construct()
{
parent::__construct('create_address');
$this->setAttribute('method', 'post')
->setHydrator(new ClassMethodsHydrator())
->setInputFilter(new InputFilter());
$this->setValidationGroup('company' => array('id'), 'year', 'month');
@bakura10
bakura10 / gist:3068163
Created July 7, 2012 21:41
Some code that make you want to use Zend\Registry
// FIRST :
class Register extends Form
{
/**
* Init the form
*/
public function init()
{
$this->setHydrator(new ClassMethodsHydrator())
@bakura10
bakura10 / gist:3072082
Created July 8, 2012 18:04
Strange problem
// In my controller :
/**
* @return array
*/
public function logoutAction()
{
$this->getUserService()->logout();
return $this->redirect()->toRoute('home');
}
<?php
<?php
/**
* Doctrine ORM Configuration
*/
return array(
'doctrine' => array(
'driver' => array(
'application_driver' => array(
SELECT
COUNT(a0_.id) AS sentApplications,
SUM(IF(a0_.status = 16, 1, 0)) AS acceptedApplications,
SUM(IF(a0_.status = 32 AND m1.`status` = 1, 1, 0)) as finished
FROM Applications a0_
JOIN Missions m1 ON a0_.mission_id = m1.id
WHERE a0_.student_id = 7
@bakura10
bakura10 / gist:3131456
Created July 17, 2012 19:29
Common\Authentication\Service\ConfigurationFactory
<?php
namespace Common\Authentication\Service;
use Common\Authentication\Options\Configuration as AuthenticationOptions;
use Common\Authentication\Storage\Db as DbStorage;
use DoctrineModule\Authentication\Adapter\DoctrineObjectRepository as DoctrineAdapter;
use Zend\Authentication\AuthenticationService;
use Zend\Authentication\Storage\Session as SessionStorage;
use Zend\ServiceManager\FactoryInterface;
@bakura10
bakura10 / gist:3131459
Created July 17, 2012 19:30
Common\Authentication\Storage\Db
<?php
namespace Common\Authentication\Storage;
use Doctrine\Common\Persistence\ObjectRepository;
use Zend\Authentication\Storage\StorageInterface;
/**
* This class implements StorageInterface and allow to save the result of an authentication against a database
*/
@bakura10
bakura10 / gist:3131450
Created July 17, 2012 19:29
Common\Authentication\Options\Configuration
<?php
namespace Common\Authentication\Options;
use Zend\Stdlib\AbstractOptions;
class Configuration extends AbstractOptions
{
/**
* Entity's class name