protected function addDoInsert(&$script) { $tmp = ''; parent::addDoInsert($tmp); if (DataModelBuilder::getBuildProperty('builderAddBehaviors')) { // add sfMixer call $pre_mixer_script = "\n\n foreach (sfMixer::getCallables('{$this->getClassname()}:doInsert:pre') as \$callable)\n {\n \$ret = call_user_func(\$callable, '{$this->getClassname()}', \$values, \$con);\n if (false !== \$ret)\n {\n return \$ret;\n }\n }\n\n"; $post_mixer_script = "\n foreach (sfMixer::getCallables('{$this->getClassname()}:doInsert:post') as \$callable)\n {\n call_user_func(\$callable, '{$this->getClassname()}', \$values, \$con, \$pk);\n }\n\n return"; $tmp = preg_replace('/{/', '{' . $pre_mixer_script, $tmp, 1); $tmp = preg_replace("/\t\treturn/", "\t\t" . $post_mixer_script, $tmp, 1); } $script .= $tmp; }
protected function addClassClose(&$script) { parent::addClassClose($script); $behavior_file_name = 'Base' . $this->getTable()->getPhpName() . 'Behaviors'; $behavior_file_path = $this->getFilePath($this->getStubObjectBuilder()->getPackage() . '.om.' . $behavior_file_name); $absolute_behavior_file_path = sfConfig::get('sf_root_dir') . '/' . $behavior_file_path; if (file_exists($absolute_behavior_file_path)) { unlink($absolute_behavior_file_path); } $behaviors = $this->getTable()->getAttribute('behaviors'); if ($behaviors) { file_put_contents($absolute_behavior_file_path, sprintf("<?php\nsfPropelBehavior::add('%s', %s);\n", $this->getTable()->getPhpName(), var_export(unserialize($behaviors), true))); $script .= sprintf("\n\ninclude_once '%s';\n", $behavior_file_path); } }