This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Listen to the bootstrap event | |
* | |
* @param EventInterface $e | |
* @return array | |
*/ | |
public function onBootstrap(EventInterface $e) | |
{ | |
$serviceManager = $e->getApplication()->getServiceManager(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @return ViewModel | |
*/ | |
public function registerAction() | |
{ | |
$form = new RegisterForm(); | |
if (($result = $this->prg()) instanceof Response) { | |
return $result; | |
} elseif ($result !== false) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Entité Membre | |
class Membre | |
{ | |
protected $name; | |
protected $rank; // Relation vers une entité Rank | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'routes' => array( | |
'post-mission' => array( | |
'type' => 'Literal', | |
'options' => array( | |
'route' => '/poster-une-mission', | |
'defaults' => array( | |
'controller' => 'Mission\Controller\Mission', | |
'action' => 'create' | |
) | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$dateTime = $user->getCreatedAt(); | |
$dateTime->setDate(2012, 10, 10); | |
$user->setCreatedAt($dateTime); | |
$em->flush($user); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MessageService implements ServiceLocatorAwareInterface | |
{ | |
/** | |
* @var ServiceLocatorInterface | |
*/ | |
protected $serviceLocator; | |
/** | |
* @var MessageMapper | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Clé étrangère : fk | |
// Index : idx | |
// Clé unique : uniq | |
function generateIdentifier($tableName, $columnNames, $prefix='idx', $maxSize=20) | |
{ | |
if ($prefix == 'uniq') { | |
$maxSize = 21; | |
} |