Exemplo n.º 1
0
 /**
  * Retirve information about one basket
  *
  * @param  Basket $basket
  * @return array
  */
 public function list_basket(Basket $basket)
 {
     $ret = ['basket_id' => $basket->getId(), 'created_on' => $basket->getCreated()->format(DATE_ATOM), 'description' => (string) $basket->getDescription(), 'name' => $basket->getName(), 'pusher_usr_id' => $basket->getPusher() ? $basket->getPusher()->getId() : null, 'updated_on' => $basket->getUpdated()->format(DATE_ATOM), 'unread' => !$basket->getIsRead(), 'validation_basket' => !!$basket->getValidation()];
     if ($basket->getValidation()) {
         $users = [];
         foreach ($basket->getValidation()->getParticipants() as $participant) {
             /* @var $participant ValidationParticipant */
             $user = $participant->getUser();
             $users[] = ['usr_id' => $user->getId(), 'usr_name' => $user->getDisplayName(), 'confirmed' => $participant->getIsConfirmed(), 'can_agree' => $participant->getCanAgree(), 'can_see_others' => $participant->getCanSeeOthers(), 'readonly' => $user->getId() != $this->app['authentication']->getUser()->getId()];
         }
         $expires_on_atom = $basket->getValidation()->getExpires();
         if ($expires_on_atom instanceof DateTime) {
             $expires_on_atom = $expires_on_atom->format(DATE_ATOM);
         }
         $ret = array_merge(['validation_users' => $users, 'expires_on' => $expires_on_atom, 'validation_infos' => $basket->getValidation()->getValidationString($this->app, $this->app['authentication']->getUser()), 'validation_confirmed' => $basket->getValidation()->getParticipant($this->app['authentication']->getUser())->getIsConfirmed(), 'validation_initiator' => $basket->getValidation()->isInitiator($this->app['authentication']->getUser())], $ret);
     }
     return $ret;
 }
Exemplo n.º 2
0
 /**
  * Retrieve information about one basket
  *
  * @param  Basket $basket
  *
  * @return array
  */
 private function list_basket(Application $app, Basket $basket)
 {
     $ret = ['basket_id' => $basket->getId(), 'owner' => $this->list_user($basket->getUser()), 'created_on' => $basket->getCreated()->format(DATE_ATOM), 'description' => (string) $basket->getDescription(), 'name' => $basket->getName(), 'pusher_usr_id' => $basket->getPusher() ? $basket->getPusher()->getId() : null, 'pusher' => $basket->getPusher() ? $this->list_user($basket->getPusher()) : null, 'updated_on' => $basket->getUpdated()->format(DATE_ATOM), 'unread' => !$basket->getIsRead(), 'validation_basket' => !!$basket->getValidation()];
     if ($basket->getValidation()) {
         $users = array_map(function ($participant) use($app) {
             $user = $participant->getUser();
             return ['usr_id' => $user->getId(), 'usr_name' => $user->getDisplayName(), 'confirmed' => $participant->getIsConfirmed(), 'can_agree' => $participant->getCanAgree(), 'can_see_others' => $participant->getCanSeeOthers(), 'readonly' => $user->getId() != $app['authentication']->getUser()->getId(), 'user' => $this->list_user($user)];
         }, iterator_to_array($basket->getValidation()->getParticipants()));
         $expires_on_atom = $basket->getValidation()->getExpires();
         if ($expires_on_atom instanceof \DateTime) {
             $expires_on_atom = $expires_on_atom->format(DATE_ATOM);
         }
         $ret = array_merge(['validation_users' => $users, 'expires_on' => $expires_on_atom, 'validation_infos' => $basket->getValidation()->getValidationString($app, $app['authentication']->getUser()), 'validation_confirmed' => $basket->getValidation()->getParticipant($app['authentication']->getUser())->getIsConfirmed(), 'validation_initiator' => $basket->getValidation()->isInitiator($app['authentication']->getUser()), 'validation_initiator_user' => $this->list_user($basket->getValidation()->getInitiator())], $ret);
     }
     return $ret;
 }
 /**
  * {@inheritDoc}
  */
 public function getCreated()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCreated', array());
     return parent::getCreated();
 }