Skip to content

Instantly share code, notes, and snippets.

View bakura10's full-sized avatar

Michaël Gallego bakura10

View GitHub Profile
/**
* Listen to the bootstrap event
*
* @param EventInterface $e
* @return array
*/
public function onBootstrap(EventInterface $e)
{
$serviceManager = $e->getApplication()->getServiceManager();
/**
* @return ViewModel
*/
public function registerAction()
{
$form = new RegisterForm();
if (($result = $this->prg()) instanceof Response) {
return $result;
} elseif ($result !== false) {
// Entité Membre
class Membre
{
protected $name;
protected $rank; // Relation vers une entité Rank
}
'routes' => array(
'post-mission' => array(
'type' => 'Literal',
'options' => array(
'route' => '/poster-une-mission',
'defaults' => array(
'controller' => 'Mission\Controller\Mission',
'action' => 'create'
)
),
$dateTime = $user->getCreatedAt();
$dateTime->setDate(2012, 10, 10);
$user->setCreatedAt($dateTime);
$em->flush($user);
/**
* Get the details for a specific invoice
*
* @return ViewModel
*/
public function invoiceDetailsAction()
{
$invoiceId = $this->params('id');
$invoiceWidget = $this->forward()->dispatch('Mission\Controller\Profit', array(
'action' => 'display-invoice',
// Use Reflection
// if by_val === true (or by_reference === false)
extract :
$data = array();
for every elements in object
getter = getElementName
if element is scalar (object or primitive type)
class MessageService implements ServiceLocatorAwareInterface
{
/**
* @var ServiceLocatorInterface
*/
protected $serviceLocator;
/**
* @var MessageMapper
*/
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
{
/** @var \Doctrine\ORM\EntityManager $entityManager */
$entityManager = $serviceLocator->get('Doctrine\ORM\EntityManager');
$parts = explode('\\', $name);
$entityName = substr(end($parts), 0, -6);
$entityClass = 'ZfrForum\\Entity\\' . $entityName;
return $entityManager->getRepository($entityClass);
<?php
// Clé étrangère : fk
// Index : idx
// Clé unique : uniq
function generateIdentifier($tableName, $columnNames, $prefix='idx', $maxSize=20)
{
if ($prefix == 'uniq') {
$maxSize = 21;
}