Skip to content

Instantly share code, notes, and snippets.

View bakura10's full-sized avatar

Michaël Gallego bakura10

View GitHub Profile
// fichier config :
'routes' => array(
'mere' => array(
'type' => 'Literal',
''options' => array(
'route' => '/jeu'
)
)
)
// In my form :
$hydrator = new ClassMethodsHydrator(false);
$hydrator->addStrategy('city', new HydratorStrategy\City());
$this->setHydrator(new DoctrineHydrator(Registry::get('EntityManager'), $hydrator))
->setObject(new AddressEntity());
$this->add(array(
'name' => 'city',
$this->add(array(
'type' => 'Zend\Form\Element\Csrf',
'name' => 'csrf',
'options' => array(
'csrf_options' => array(
'timeout' => 456,
// autres options du CSRF
)
)
));
$this->add(array(
'type' => 'Zend\Form\Element\Csrf',
'name' => 'csrf',
'options' => array(
'csrf_options' => array(
'timeout' => ...
)
)
));
<?php if (count($bases) === 0): ?>
<?php foreach ($bases as $base): ?>
<?php echo $base->getName(); ?>
<?php endforeach; ?>
<?php else: ?>
<p>Aucune base</p>
<?php endif; ?>
{% for base in bases if base.active() %}
{{ base.getName() }}
{% else %}
<p>Aucune base</p>
$queryBuilder->select('COUNT(a.id) AS sentApplications')
->addSelect('SUM(CASE WHEN a.status = :accepted THEN 1 ELSE 0 END) AS acceptedApplications')
->addSelect('SUM(CASE WHEN a.status = :accepted AND m.status = :filled THEN 1 ELSE 0 END) AS activeMissions')
->addSelect('SUM(CASE WHEN a.status = :accepted AND m.status = :finished THEN 1 ELSE 0 END) AS finishedMissions')
->from('Mission\Entity\Application', 'a')
->join('a.mission', 'm')
->where('a.student = :student')
->setParameter('accepted', ApplicationEntity::ACCEPTED)
->setParameter('filled', MissionEntity::FILLED)
->setParameter('finished', MissionEntity::FINISHED)
@bakura10
bakura10 / gist:3705417
Created September 12, 2012 09:06
DateSelect element for ZF 2
$this->add(array(
'type' => 'Zend\Form\Element\DateSelect',
'name' => 'birthDate',
'options' => array(
'label' => 'Date de naissance',
'create_empty_option' => true,
'min_year' => date('Y') - 30,
'max_year' => date('Y') - 18,
'day_attributes' => array(
'data-placeholder' => 'Jour',
<?php
// Par défaut, Doctrine t'offre ces différents events :
// PostLoad, PostPersist, PostRemove, PostUpdate
// PrePersist, PreRemove, PreUpdate
/**
* @ORM\Entity
* @ORM\HasLifecycleCallbacks // <=== Active le mécanisme d'évènements
*/
// layout.phtml
<!doctype html>
<html>
<head>
<?php echo $this->headStyle(); ?>
<?php echo $this->headScript(); ?>
</head>
</html>