protected function _getI18nBehaviors($behaviors, $inputs) { $i18nBehaviors = array(); foreach ($behaviors as $behaviorName => $behaviorConfig) { if (!Garp_Spawn_Behavior_Factory::isI18nBehavior($behaviorName, $behaviorConfig, $inputs)) { continue; } $i18nBehaviors[$behaviorName] = $behaviorConfig; } return $i18nBehaviors; }
protected function _add($origin, $behaviorName, $behaviorConfig = null) { $behaviorType = $this->_isValidatorBehavior($behaviorName) ? 'Validator' : null; $behaviorModule = 'Garp'; if ($behaviorConfig) { $behaviorConfig = (array) $behaviorConfig; $hasModule = array_key_exists('module', $behaviorConfig); $behaviorModule = $hasModule ? $behaviorConfig['module'] : $behaviorModule; unset($behaviorConfig['module']); } if (!array_key_exists($behaviorName, $this->_behaviors)) { $factory = new Garp_Spawn_Behavior_Factory(); $behavior = $factory->produce($this->_model, $origin, $behaviorName, $behaviorConfig, $behaviorType, $behaviorModule); $this->_behaviors[$behaviorName] = $behavior; // generate fields which are necessary for this behavior in the accompanying Model $generatedFields = $this->_behaviors[$behaviorName]->getFields(); foreach ($generatedFields as $fieldName => $fieldParams) { $this->_model->fields->add('behavior', $fieldName, $fieldParams); } return; } throw new Exception("The {$behaviorName} behavior is already registered."); }