Documentation

CurrentUser

\Bitrix\Main\Engine\CurrentUser class is responsible for current user.

You can get CurrentUser using two options:

  1.     \Bitrix\Main\Engine\Controller::getCurrentUser()
    
         public function getAction(Folder $folder)
         {
         	$securityContext = $folder->getStorage()->getSecurityContext($this->getCurrentUser()->getId());
         	if(!$folder->canRead($securityContext))
         	{
         		$this->addError(new Error('Could not read the folder.'));
    
         		return null;
         	}
        		
         	return $folder->toArray();
         }
  2. Integrate dependency via method parameters of AJAX action
         public function getAction(Folder $folder, CurrentUser $currentUser)
         {
         	$securityContext = $folder->getStorage()->getSecurityContext($currentUser->getId());
         	...
         }

© «Bitrix24», 2001-2024
Up