/**
  * Adds the user ID and name if available
  *
  * @param \MShop_Context_Item_Interface $context Context object
  */
 protected function addUser(\MShop_Context_Item_Interface $context)
 {
     if (($userid = \Auth::id()) !== null) {
         $context->setUserId($userid);
     }
     if (($user = \Auth::user()) !== null) {
         $context->setEditor($user->name);
     }
 }
Exemple #2
0
 /**
  * Adds the user ID and name if available
  *
  * @param \MShop_Context_Item_Interface $context Context object
  */
 protected function addUser(\MShop_Context_Item_Interface $context)
 {
     if (($userid = \Auth::id()) !== null) {
         $context->setUserId($userid);
         $context->setGroupIds(function () use($context, $userid) {
             $manager = \MShop_Factory::createManager($context, 'customer');
             return $manager->getItem($userid, array('customer/group'))->getGroups();
         });
     }
     if (($user = \Auth::user()) !== null) {
         $context->setEditor($user->name);
     }
 }
Exemple #3
0
 /**
  * Adds the user ID and name if available
  *
  * @param \MShop_Context_Item_Interface $context Context object
  */
 protected function addUser(\MShop_Context_Item_Interface $context)
 {
     $username = '';
     if ($this->container->has('security.context')) {
         $token = $this->container->get('security.context')->getToken();
         if (is_object($token)) {
             if (method_exists($token->getUser(), 'getId')) {
                 $userid = $token->getUser()->getId();
                 $context->setUserId($userid);
                 $context->setGroupIds(function () use($context, $userid) {
                     $manager = \MShop_Factory::createManager($context, 'customer');
                     return $manager->getItem($userid, array('customer/group'))->getGroups();
                 });
             }
             if (is_object($token->getUser())) {
                 $username = $token->getUser()->getUsername();
             } else {
                 $username = $token->getUser();
             }
         }
     }
     $context->setEditor($username);
 }