Development

Changeset 9534

You must first sign up to be able to contribute.

Changeset 9534

Show
Ignore:
Timestamp:
06/11/08 10:22:45 (2 years ago)
Author:
fabien
Message:

fixed propel:build-forms when using behaviors (closes #3476 - patch from Kris.Wallsmith)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/builder/SfObjectBuilder.php

    r7394 r9534  
    347347    $script .= $tmp; 
    348348  } 
    349    
     349 
    350350  protected function addClassClose(&$script) 
    351351  { 
    352352    parent::addClassClose($script); 
    353      
     353 
    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); 
    360     } 
    361   } 
     359 
     360      $behavior_include_script = <<<EOF 
     361 
     362 
     363if (ProjectConfiguration::getActive() instanceof sfApplicationConfiguration) 
     364
     365  include_once '%s'; 
    362366} 
     367 
     368EOF; 
     369      $script .= sprintf($behavior_include_script, $behavior_file_path); 
     370    } 
     371  } 
     372} 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/builder/SfPeerBuilder.php

    r8807 r9534  
    384384    $script .= $tmp; 
    385385  } 
    386    
     386 
    387387  protected function addClassClose(&$script) 
    388388  { 
     
    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; 
    394      
    395     if(file_exists($absolute_behavior_file_path)) 
     394 
     395    if (file_exists($absolute_behavior_file_path)) 
    396396    { 
    397397      unlink($absolute_behavior_file_path); 
    398398    } 
    399      
     399 
    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  } 
  • branches/1.1/lib/plugins/sfPropelPlugin/lib/propel/generator/sfPropelFormGenerator.class.php

    r9132 r9534  
    8282    { 
    8383      $this->table = $table; 
    84  
    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       } 
    9584 
    9685      // find the package to store forms in the same directory as the model classes 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.