Example #1
0
 private function updateUserAndConfig($result, MOXMAN_Auth_User $user, MOXMAN_Util_Config $config)
 {
     if ($result["user"]) {
         $config->replaceVariable("user", $result["user"]);
         $user->setName($result["user"]);
     }
     $config->extend($result["config"]);
 }
Example #2
0
 /**
  * Returns a new config object based on the specified files path.
  * This will match the file path with the path.overrides in the config.
  *
  * @param MOXMAN_Vfs_IFile $file File to match agains path.overrides.
  * @return MOXMAN_Util_Config New path specific config instance.
  */
 public function getFileConfig(MOXMAN_Vfs_IFile $file)
 {
     $config = new MOXMAN_Util_Config($this->items);
     $pathOverrides = $this->get("filesystem.directories");
     if (is_array($pathOverrides) && !empty($pathOverrides)) {
         if ($file->isFile()) {
             $file = $file->getParentFile();
             // @codeCoverageIgnoreStart
             if (!$file) {
                 return $config;
             }
             // @codeCoverageIgnoreEnd
         }
         $path = $file->getPublicPath();
         foreach (array_keys($pathOverrides) as $pattern) {
             $overrides = $this->getOverrides($pattern);
             if (strpos($pattern, 'regexp:') === 0) {
                 // regexp:/pattern/
                 if (preg_match(substr($pattern, 7), $path)) {
                     $config->extend($overrides);
                 }
             } else {
                 foreach (explode(',', $pattern) as $pattern) {
                     if (strpos($pattern, '/') === false) {
                         // Directory name
                         $pattern = "/\\/" . preg_quote($pattern) . "(\\/|\$)/";
                         if (preg_match($pattern, $path)) {
                             $config->extend($overrides);
                         }
                     } else {
                         if (strrchr($pattern, '/') === '/') {
                             $pattern = substr($pattern, 0, strlen($pattern) - 1);
                         }
                         if (preg_match("/\\/\\.\$/", $pattern)) {
                             // Directory path with /. at the end
                             if ($path === substr($pattern, 0, strlen($pattern) - 2)) {
                                 $config->extend($overrides);
                             }
                         } else {
                             if ($path === $pattern || strpos($path, $pattern . '/') === 0) {
                                 // Directory path
                                 $config->extend($overrides);
                             }
                         }
                     }
                 }
             }
         }
     }
     return $config;
 }