Skip to content

Instantly share code, notes, and snippets.

View bakura10's full-sized avatar

Michaël Gallego bakura10

View GitHub Profile
public function markAsRead(ThreadEntity $thread, UserEntity $user)
{
$queryBuilder = $this->getEntityManager()->createQueryBuilder();
$queryBuilder->update('u')
->set('u.status', UserThreadEntity::READ)
->set('u.firstNotReadMessage', null)
->from('NhxSimpleMessaging\Entity\UserThread', 'u')
->where('u.user = :user')
->andWhere('u.thread = :thread')
->setParameter('user', $user)
public function getLatestThreads(UserEntity $user)
{
$dql = 'SELECT t FROM Thread t ' .
'JOIN UserThread u WITH u.user = :user AND u.status <> :deleted ' .
'JOIN Message m WITH t = m.thread ' .
'JOIN Message m2 WITH t = m2.thread AND m.id < m2.id ' .
'WHERE m2.id IS NULL ' .
'ORDER BY m.sentAt DESC';
$query = $this->getEntityManager()->createQuery($dql)
'resolve_target_entities' => array(
'orm_default' => array(
array(
'old_entity' => 'fff',
'new_entity' => 'gggg',
'mapping' => 'regtrg'
)
)
)
$this->threadService->getEventManager()->attach('create', function ($e) use ($participantC) {
$thread = $e->getParam('thread');
$thread->addParticipant($participantC);
});
/**
* @ORM\Entity
* @ORM\Table(name="Messages")
* @ORM\HasLifecycleCallbacks
*/
class Message
{
/**
* @var int
*
'resolve_target_entities' => array(
'NhxUser\Entity\UserInterface' => array(
'new_entity' => 'NhxPrivateMessagingTest\Asset\SimpleUserTest'
)
)
$this->add(array(
'type' => 'Zend\Form\Element\Select',
'options' => array(
'label' => 'my option'
),
'attributes' => array(
'options' => array(key value array)
)
));
class Folder
{
/**
* @var Folder
*
* @ORM\ManyToOne(targetEntity="Folder", inversedBy="childrenFolders")
* @ORM\JoinColumn(onDelete="cascade")
*/
protected $parentFolder;
public function getServiceConfig()
{
return array(
'invokables' => array(
'MyFooMapper' => 'My\Mapper\Foo'
),
'aliases' => array(
'ApplicationNameNotExists' => 'My\Validator\NameNotExists'
),
// Dans ton layout :
<?php echo $this->placeholder('widget'); ?>
// Dans un hypothétique fichier Messagerie/view/messagerie/widget.phtml :
<?php $this->placeholder('widget')->captureStart(); ?>
<h1>Mon widget<h1>