當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Assert::fileExists方法代碼示例

本文整理匯總了PHP中Puli\Manager\Assert\Assert::fileExists方法的典型用法代碼示例。如果您正苦於以下問題:PHP Assert::fileExists方法的具體用法?PHP Assert::fileExists怎麽用?PHP Assert::fileExists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Puli\Manager\Assert\Assert的用法示例。


在下文中一共展示了Assert::fileExists方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: loadConfigFile

 private function loadConfigFile($homeDir, Config $baseConfig)
 {
     if (null === $homeDir) {
         return null;
     }
     Assert::fileExists($homeDir, 'Could not load Puli context: The home directory %s does not exist.');
     Assert::directory($homeDir, 'Could not load Puli context: The home directory %s is a file. Expected a directory.');
     // Create a storage without the factory manager
     $configStorage = new ConfigFileStorage($this->getStorage(), $this->getConfigFileSerializer());
     $configPath = Path::canonicalize($homeDir) . '/config.json';
     try {
         return $configStorage->loadConfigFile($configPath, $baseConfig);
     } catch (FileNotFoundException $e) {
         // It's ok if no config.json exists. We'll work with
         // DefaultConfig instead
         return null;
     }
 }
開發者ID:xabbuh,項目名稱:manager,代碼行數:18,代碼來源:Puli.php

示例2: createProjectContext

 /**
  * Creates the context of a Puli project.
  *
  * The home directory is read from the context variable "PULI_HOME".
  * If this variable is not set, the home directory defaults to:
  *
  *  * `$HOME/.puli` on Linux, where `$HOME` is the context variable
  *    "HOME".
  *  * `$APPDATA/Puli` on Windows, where `$APPDATA` is the context
  *    variable "APPDATA".
  *
  * If none of these variables can be found, an exception is thrown.
  *
  * A .htaccess file is put into the home directory to protect it from web
  * access.
  *
  * @param string $rootDir The path to the project.
  *
  * @return ProjectContext The project context.
  */
 private function createProjectContext($rootDir, $env)
 {
     Assert::fileExists($rootDir, 'Could not load Puli context: The root %s does not exist.');
     Assert::directory($rootDir, 'Could not load Puli context: The root %s is a file. Expected a directory.');
     $homeDir = self::parseHomeDirectory();
     if (null !== $homeDir) {
         Assert::fileExists($homeDir, 'Could not load Puli context: The home directory %s does not exist.');
         Assert::directory($homeDir, 'Could not load Puli context: The home directory %s is a file. Expected a directory.');
         // Create a storage without the factory manager
         $configStorage = new ConfigFileStorage($this->getStorage(), $this->getConfigFileSerializer());
         $configPath = Path::canonicalize($homeDir) . '/config.json';
         $configFile = $configStorage->loadConfigFile($configPath, new DefaultConfig());
         $baseConfig = $configFile->getConfig();
     } else {
         $configFile = null;
         $baseConfig = new DefaultConfig();
     }
     // Create a storage without the factory manager
     $packageFileStorage = new PackageFileStorage($this->getStorage(), $this->getPackageFileSerializer());
     $rootDir = Path::canonicalize($rootDir);
     $rootFilePath = $this->rootDir . '/puli.json';
     $rootPackageFile = $packageFileStorage->loadRootPackageFile($rootFilePath, $baseConfig);
     $config = new EnvConfig($rootPackageFile->getConfig());
     return new ProjectContext($homeDir, $rootDir, $config, $rootPackageFile, $configFile, $this->dispatcher, $env);
 }
開發者ID:kormik,項目名稱:manager,代碼行數:45,代碼來源:Puli.php


注:本文中的Puli\Manager\Assert\Assert::fileExists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。