public function getServiceLocator() { if (!$this->serviceLocater) { $this->setServiceLocator(\FrontCore\Factories\FrontCoreServiceProviderFactory::getInstance()); } //end if return $this->serviceLocator; }
/** * * {@inheritDoc} * @see \Zend\Mvc\Controller\AbstractController::getServiceLocator() * @return Zend\ServiceManager\ServiceManager */ public function getServiceLocator() { if (!$this->serviceManager) { $this->serviceManager = \FrontCore\Factories\FrontCoreServiceProviderFactory::getInstance(); } //end function return $this->serviceManager; }
/** * Static access proxy function * @return \FrontProfileSettings\Entities\FrontProfileNativeSettingsProfileEntity */ public static function readProfileSettings() { $sm = FrontCoreServiceProviderFactory::getInstance(); $model = $sm->get("FrontProfileSettings\\Models\\NativeProfileSettingsModel"); return $model->fetchProfileSettings(); }
/** * Simple check if a user has access to a given resource * @TODO create proper zend acl * @param string $resource * @return boolean */ public static function userHasAccess($resource, ServiceLocatorInterface $serviceLocator = NULL) { //default routes to be allowed switch ($resource) { case "home": case "front-profile-native-settings": case "front-user-login": case "front-profile-settings": case "front-locations": return TRUE; break; } //end switch //instantiate the user session $objUserSession = new Container("user"); if (!isset($objUserSession->id) || $objUserSession->id == "") { return FALSE; } //end if //check if user acl has been set already, if not temporarily allow access in frontend, api will catch unauthorized requests if (count((array) $objUserSession->acl->user_acl_access_allowed < 10)) { return TRUE; } //end if //check api resources if (in_array($resource, (array) $objUserSession->acl->user_acl_access_allowed)) { return TRUE; } //end if //check user navigation array if (!is_array($objUserSession->arr_user_acl)) { //attempt to construct user acl session data via the navigation factory $sm = \FrontCore\Factories\FrontCoreServiceProviderFactory::getInstance(); $objNavigation = $sm->get("FrontCore\\Navigation\\FrontNavigationFactory"); $objNavigation->createService($sm); //reload user session $objUserSession = new Container("user"); } //end if if (!is_array($objUserSession->arr_user_acl)) { //user acl not set, no point in continuing return FALSE; } //end if if (in_array($resource, $objUserSession->arr_user_acl)) { return TRUE; } //end if return FALSE; }