コード例 #1
0
ファイル: Config.php プロジェクト: nchervyakov/evolve2
 /**
  * Set new current context.
  * @param $context
  * @return $this
  * @throws \InvalidArgumentException
  */
 public function setCurrentContext($context)
 {
     if (is_string($context)) {
         $searchingContext = $this->currentContext ?: $this->rootContext;
         $contextObj = $searchingContext->findByPath($context);
         if (!$contextObj) {
             throw new \InvalidArgumentException('Given path is not in config context tree.');
         }
         $this->currentContext = $contextObj;
         return $this;
     } else {
         if ($context instanceof Context) {
             if ($this->rootContext->findInTree($context)) {
                 $this->currentContext = $context;
                 return $this;
             } else {
                 throw new \InvalidArgumentException('Given context is not in config context tree.');
             }
         }
     }
     throw new \InvalidArgumentException('$context must be valid path name or instance of \\VulnModule\\Config\\Context');
 }