当前位置: 首页>>代码示例>>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;未经允许,请勿转载。