Pimcore\Config::getPerspectivesConfig PHP Method

getPerspectivesConfig() public static method

public static getPerspectivesConfig ( ) : mixed | Zend_Config
return mixed | Zend_Config
    public static function getPerspectivesConfig()
    {
        if (\Zend_Registry::isRegistered("pimcore_config_perspectives")) {
            $config = \Zend_Registry::get("pimcore_config_perspectives");
        } else {
            try {
                $file = self::locateConfigFile("perspectives.php");
                if (file_exists($file)) {
                    $config = new \Zend_Config(include $file);
                } else {
                    throw new \Exception($file . " doesn't exist");
                }
                self::setPerspectivesConfig($config);
            } catch (\Exception $e) {
                Logger::info("Cannot find perspectives configuration, should be located at: " . $file);
                if (is_file($file)) {
                    $m = "Your perspectives.php located at " . $file . " is invalid, please check and correct it manually!";
                    Tool::exitWithError($m);
                }
                $config = new \Zend_Config(self::getStandardPerspective());
                self::setPerspectivesConfig($config);
            }
        }
        return $config;
    }

Usage Example

Example #1
0
 /**
  * @param Model\User $user
  * @return $this
  */
 public function setUser(Model\User $user)
 {
     $this->user = $user;
     \Zend_Registry::set("pimcore_admin_user", $this->user);
     $this->setLanguage($this->user->getLanguage());
     // update perspective settings
     $requestedPerspective = $this->getParam("perspective");
     if ($requestedPerspective) {
         if ($requestedPerspective != $user->getActivePerspective()) {
             $existingPerspectives = array_keys(Config::getPerspectivesConfig()->toArray());
             if (!in_array($requestedPerspective, $existingPerspectives)) {
                 $requestedPerspective = null;
             }
         }
     }
     if (!$requestedPerspective) {
         $requestedPerspective = $user->getActivePerspective();
     }
     //TODO check if perspective is still allowed
     if ($requestedPerspective != $user->getActivePerspective()) {
         $user->setActivePerspective($requestedPerspective);
         $user->save();
     }
     return $this;
 }
All Usage Examples Of Pimcore\Config::getPerspectivesConfig