protected function getBehaviorInfo($class)
 {
     if (array_key_exists($class, $this->behaviorInfoCache)) {
         return $this->behaviorInfoCache[$class];
     }
     $library = ControllerBehaviorLibrary::instance();
     $behaviorInfo = $library->getBehaviorInfo($class);
     if (!$behaviorInfo) {
         throw new ApplicationException('The requested behavior class information is not found.');
     }
     return $this->behaviorInfoCache[$class] = $behaviorInfo;
 }
 protected function generateConfigFiles()
 {
     if (!$this->sourceModel->behaviors) {
         return;
     }
     $controllerPath = $this->sourceModel->getControllerFilePath(true);
     $behaviorLibrary = ControllerBehaviorLibrary::instance();
     $dumper = new YamlDumper();
     foreach ($this->sourceModel->behaviors as $behaviorClass) {
         $behaviorInfo = $behaviorLibrary->getBehaviorInfo($behaviorClass);
         $configFileName = $behaviorInfo['configFileName'];
         if (!strlen($configFileName)) {
             continue;
         }
         $provider = $this->getBehaviorDesignTimeProvider($behaviorInfo['designTimeProvider']);
         $destFilePath = $controllerPath . '/' . $configFileName;
         try {
             $configArray = $provider->getDefaultConfiguration($behaviorClass, $this->sourceModel, $this);
         } catch (Exception $ex) {
             throw new ValidationException(['baseModelClassName' => $ex->getMessage()]);
         }
         $code = $dumper->dump($configArray, 20, 0, false, true);
         $this->writeFile($destFilePath, $code);
     }
 }
 protected function loadControllerBehaviors()
 {
     $filePath = $this->getControllerFilePath();
     if (!File::isFile($filePath)) {
         throw new ApplicationException(Lang::get('rainlab.builder::lang.controller.error_controller_not_found'));
     }
     $fileContents = File::get($filePath);
     $parser = new ControllerFileParser($fileContents);
     $behaviors = $parser->listBehaviors();
     if (!$behaviors) {
         throw new ApplicationException(Lang::get('rainlab.builder::lang.controller.error_controller_has_no_behaviors'));
     }
     $library = ControllerBehaviorLibrary::instance();
     $this->behaviors = [];
     foreach ($behaviors as $behaviorClass) {
         $behaviorInfo = $library->getBehaviorInfo($behaviorClass);
         if (!$behaviorInfo) {
             continue;
         }
         $propertyName = $behaviorInfo['configPropertyName'];
         $propertyValue = $parser->getStringPropertyValue($propertyName);
         if (!strlen($propertyValue)) {
             continue;
         }
         $configuration = $this->loadBehaviorConfiguration($propertyValue, $behaviorClass);
         if ($configuration === false) {
             continue;
         }
         $this->behaviors[$behaviorClass] = $configuration;
     }
 }