<commit_before><?php
class EqualNestParentBehaviorObjectBuilderModifier
{
  protected $behavior, $table, $builder, $objectClassname, $peerClassname;
  
  /** @var Table */
  protected $middle_table;  
  
  /** @var EqualNestBehavior */
  protected $middle_behavior;  
  
  public function __construct($behavior, $middle_table)
  {
    $this->behavior = $behavior;
    $this->table = $behavior->getTable();
    $this->middle_table = $middle_table; 
    $this->middle_behavior = $this->middle_table->getBehavior('equal_nest');     
  }
  
  protected function getMiddleTable()
  {
    return $this->getTable()->getDatabase()->getTable($this->getParameter('extends'));  
  }
  
  protected function getParameter($key)
  {
    return $this->behavior->getParameter($key);
  }
  
  protected function getColumnAttribute($name)
  {
    return strtolower($this->behavior->getColumnForParameter($name)->getName());
  }

  protected function getColumnPhpName($name)
  {
    return $this->behavior->getColumnForParameter($name)->getPhpName();
  }
  
  protected function setBuilder($builder)
  {
    $this->builder = $builder;
    $this->objectClassname = $builder->getStubObjectBuilder()->getClassname();
    $this->queryClassname = $builder->getStubQueryBuilder()->getClassname();
    $this->peerClassname = $builder->getStubPeerBuilder()->getClassname();
  }  
  
  
  public function objectAttributes($builder)
  {
    $this->builder = $builder;                        
    $objectClassname = $builder->getStubObjectBuilder()->getClassname();

    return "
/** 
 * @var        array List of PKs of {$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())} for this $objectClassname
 */
protected \$listEqualNest{$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())}PKs;


/** 
 * @var        PropelObjectCollection09 {$objectClassname}[] Collection to store Equal Nest {$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())} of this $objectClassname
 */            
protected \$collEqualNest{$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())};

/**
 * @var        boolean Flag to prevent endless processing loop which occurs when 2 new objects are set as twins
 */
protected \$alreadyInEqualNestProcessing = false;
";
  }
  
  public function postSave($builder)
  {
    return "\$this->processEqualNestQueries(\$con);";
  }
    
  
  public function objectClearReferences($builder)
  {
    $this->builder = $builder;

    return "
if (\$deep) {
  if (\$this->collEqualNest{$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())}) {
    foreach ((array) \$this->collEqualNest{$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())} as \$o) {
      \$o->clearAllReferences(\$deep);
    }
  }
}

\$this->listEqualNest{$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())}PKs = null;<commit_msg>Added some custom relation cleaning code, but did not enable it. It is actually not needed for the behavior, because Propel will automatically take care of cleaning related objects on deletion. (The equal nest relation table should use onDelete="cascade" rules for the foreign key constraints; maybe have a check and include this code only if necessary?)<commit_after><?php
class EqualNestParentBehaviorObjectBuilderModifier
{
  protected $behavior, $table, $builder, $objectClassname, $peerClassname;
  
  /** @var Table */
  protected $middle_table;  
  
  /** @var EqualNestBehavior */
  protected $middle_behavior;  
  
  public function __construct($behavior, $middle_table)
  {
    $this->behavior = $behavior;
    $this->table = $behavior->getTable();
    $this->middle_table = $middle_table; 
    $this->middle_behavior = $this->middle_table->getBehavior('equal_nest');     
  }
  
  protected function getMiddleTable()
  {
    return $this->getTable()->getDatabase()->getTable($this->getParameter('extends'));  
  }
  
  protected function getParameter($key)
  {
    return $this->behavior->getParameter($key);
  }
  
  protected function getColumnAttribute($name)
  {
    return strtolower($this->behavior->getColumnForParameter($name)->getName());
  }

  protected function getColumnPhpName($name)
  {
    return $this->behavior->getColumnForParameter($name)->getPhpName();
  }
  
  protected function setBuilder($builder)
  {
    $this->builder = $builder;
    $this->objectClassname = $builder->getStubObjectBuilder()->getClassname();
    $this->queryClassname = $builder->getStubQueryBuilder()->getClassname();
    $this->peerClassname = $builder->getStubPeerBuilder()->getClassname();
  }  
  
  
  public function objectAttributes($builder)
  {
    $this->builder = $builder;                        
    $objectClassname = $builder->getStubObjectBuilder()->getClassname();

    return "
/** 
 * @var        array List of PKs of {$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())} for this $objectClassname
 */
protected \$listEqualNest{$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())}PKs;


/** 
 * @var        PropelObjectCollection09 {$objectClassname}[] Collection to store Equal Nest {$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())} of this $objectClassname
 */            
protected \$collEqualNest{$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())};

/**
 * @var        boolean Flag to prevent endless processing loop which occurs when 2 new objects are set as twins
 */
protected \$alreadyInEqualNestProcessing = false;
";
  }
  
  public function postSave($builder)
  {
    return "\$this->processEqualNestQueries(\$con);";
  }
  
  
  /**
  * I initially thought this code has to be executed to remove any and all slibling relations,
  * but then I remembered that Propel does that automatically. Calling delete on an object deletes all
  * relations, and from propel's standpoint the Equal Nest relation is a simple 1:M.
  * 
  * Long live Propel! :)
  * 
  */
  public function preSave($builder)
  {
    $script =  "
\$this->listEqualNest{$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())}PKs = array();
\$this->processEqualNestQueries(\$con);
    ";
  }
  
  public function objectClearReferences($builder)
  {
    $this->builder = $builder;

    return "
if (\$deep) {
  if (\$this->collEqualNest{$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())}) {
    foreach ((array) \$this->collEqualNest{$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())} as \$o) {
      \$o->clearAllReferences(\$deep);
    }
  }
}

\$this->listEqualNest{$this->builder->getPluralizer()->getPluralForm($this->middle_table->getPhpName())}PKs = null;
{'fraction_non_alphanumeric': 0.1506849315068493, 'fraction_numerical': 0.0010201107548819587, 'mean_word_length': 4.287365177195686, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 156, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2133400', 'n_tokens_mistral': 2099, 'n_tokens_neox': 2036, 'n_words': 385}