Development

Changeset 3679

You must first sign up to be able to contribute.

Changeset 3679

Show
Ignore:
Timestamp:
03/29/07 18:00:01 (2 years ago)
Author:
gnat
Message:

modified model creation to use new doctrine class hasOne/Many syntax with onDelete as an array parameter.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfDoctrinePlugin/addon/sfDoctrineRelationSchema.class.php

    r3675 r3679  
    6868  { 
    6969    // special behaviour for xref tables with cascade delete 
    70     $verb = 'has'; 
    71     if ($this->get('cascadeDelete') && $this->get('counterpart')
    72       $verb = 'owns'
     70    $options = ''; 
     71    if ($this->get('cascadeDelete') && ( $this->get('counterpart') || $this->get('unique'))
     72      $options = ", 'onDelete'=>'cascade'"
    7373 
    74     return "\$this->$verb"."One('{$this->get('foreignClass')} as {$this->get('foreignName')}', '{$this->get('localClass')}.{$this->get('localReference')}', array('foreign' => '{$this->get('foreignReference')}'));"; 
     74    return "\$this->hasOne('{$this->get('foreignClass')} as {$this->get('foreignName')}', '{$this->get('localClass')}.{$this->get('localReference')}', array('foreign' => '{$this->get('foreignReference')}' $options));"; 
    7575  } 
    7676 
     
    9393 
    9494    // using "owns" for cascade delete except in xref tables 
    95     $verb = 'has'; 
     95    $options = ''; 
    9696    if ($this->get('cascadeDelete') && !$this->get('counterpart')) 
    97       $verb = 'owns'
     97      $options = ", array( 'onDelete'=>'cascade')"
    9898 
    99     return "\$this->$verb$quantity('$otherClass as {$this->get('localName')}', '{$this->get('localClass')}.$localReference');"; 
     99 
     100    return "\$this->has$quantity('$otherClass as {$this->get('localName')}', '{$this->get('localClass')}.$localReference' $options);"; 
    100101  } 
    101102