Development

#3476: propel-build-forms-behaviors-v2.patch

You must first sign up to be able to contribute.

Ticket #3476: propel-build-forms-behaviors-v2.patch

File propel-build-forms-behaviors-v2.patch, 3.2 kB (added by Kris.Wallsmith, 5 months ago)

updated patch to rollback earlier patch

  • lib/plugins/sfPropelPlugin/lib/propel/builder/SfPeerBuilder.php

    old new  
    392392    $behavior_file_path = $this->getFilePath($this->getStubObjectBuilder()->getPackage().'.om.'.$behavior_file_name); 
    393393    $absolute_behavior_file_path = sfConfig::get('sf_root_dir').'/'.$behavior_file_path; 
    394394     
    395     if(file_exists($absolute_behavior_file_path)) 
     395    if (file_exists($absolute_behavior_file_path)) 
    396396    { 
    397397      unlink($absolute_behavior_file_path); 
    398398    } 
    399399     
    400400    $behaviors = $this->getTable()->getAttribute('behaviors'); 
    401     if($behaviors) 
     401    if ($behaviors) 
    402402    { 
    403403      file_put_contents($absolute_behavior_file_path, sprintf("<?php\nsfPropelBehavior::add('%s', %s);\n", $this->getTable()->getPhpName(), var_export(unserialize($behaviors), true))); 
    404       $script .= sprintf("\n\ninclude_once '%s';\n", $behavior_file_path); 
     404       
     405      $behavior_include_script = <<<EOF 
     406 
     407 
     408if (ProjectConfiguration::getActive() instanceof sfApplicationConfiguration) 
     409
     410  include_once '%s'; 
     411
     412 
     413EOF; 
     414      $script .= sprintf($behavior_include_script, $behavior_file_path); 
    405415    } 
    406416  } 
    407417 
  • lib/plugins/sfPropelPlugin/lib/propel/builder/SfObjectBuilder.php

    old new  
    352352    parent::addClassClose($script); 
    353353     
    354354    $behaviors = $this->getTable()->getAttribute('behaviors'); 
    355     if($behaviors) 
     355    if ($behaviors) 
    356356    { 
    357357      $behavior_file_name = 'Base'.$this->getTable()->getPhpName().'Behaviors'; 
    358358      $behavior_file_path = $this->getFilePath($this->getStubObjectBuilder()->getPackage().'.om.'.$behavior_file_name); 
    359       $script .= sprintf("\n\ninclude_once '%s';\n", $behavior_file_path); 
     359       
     360      $behavior_include_script = <<<EOF 
     361 
     362 
     363if (ProjectConfiguration::getActive() instanceof sfApplicationConfiguration) 
     364
     365  include_once '%s'; 
     366
     367 
     368EOF; 
     369      $script .= sprintf($behavior_include_script, $behavior_file_path); 
    360370    } 
    361371  } 
    362372} 
  • lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelFormGenerator.class.php

    old new  
    8282    { 
    8383      $this->table = $table; 
    8484 
    85       try 
    86       { 
    87         // trigger the include_once of any behaviors now, and catch the 
    88         // exception that is thrown due to no plugin behaviors having been 
    89         // registered 
    90         class_exists($table->getPhpName()); 
    91       } 
    92       catch (sfConfigurationException $e) 
    93       { 
    94       } 
    95  
    9685      // find the package to store forms in the same directory as the model classes 
    9786      $packages = explode('.', constant($table->getPhpName().'Peer::CLASS_DEFAULT')); 
    9887      array_pop($packages);