Ejemplo n.º 1
0
 protected function resolve($projectName = null)
 {
     if ($projectName !== null && isset($this->projects[$projectName])) {
         $project = $this->projects[$projectName];
     } else {
         foreach ($this->projects as $project) {
             if (!isset($project['rule'])) {
                 throw new \yii\base\InvalidConfigException('Invalid sandbox project config given.');
             }
             /* @var $rule Rule */
             $rule = P::createObject($project['rule']);
             if ($rule->isValid()) {
                 break;
             }
         }
     }
     if (empty($project)) {
         throw new NotDetectingException('Not found project configuration.');
     } else {
         if (!isset($project['projectId']) || !isset($project['siteId'])) {
             throw new \yii\base\InvalidConfigException('Invalid sandbox project config given.');
         }
     }
     return $project;
 }
Ejemplo n.º 2
0
 /**
  * Returns the detector for the given configure.
  * @param detectors\Detector|array $detector
  * @return detectors\Detector
  * @throws InvalidConfigException
  */
 public function getDetector($detector)
 {
     if ($detector instanceof detectors\Detector) {
         $class = get_class($detector);
     } else {
         if (isset($detector['class'])) {
             $class = $detector['class'];
         } else {
             throw new InvalidConfigException("Unable to create locale detector '{$detector}'.");
         }
     }
     if (!isset($this->detectors[$class])) {
         $this->detectors[$class] = P::createObject($detector);
     }
     return $this->detectors[$class];
 }