コード例 #1
0
ファイル: Context.php プロジェクト: nos3/aimeos-laravel
 /**
  * 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);
     }
 }
コード例 #2
0
ファイル: Context.php プロジェクト: nos3/aimeos-symfony2
 /**
  * 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);
 }