public function testGetRelationReturnsForeignKeyObjectForNestRelation() { $r = new Doctrine_Relation_Parser($this->conn->getTable('Entity')); $p = array('type' => Doctrine_Relation::MANY, 'refClass' => 'EntityReference', 'local' => 'entity1', 'foreign' => 'entity2'); $r->bind('Entity', $p); $rel = $r->getRelation('Entity'); $this->assertTrue($rel instanceof Doctrine_Relation_Nest); $rel = $r->getRelation('EntityReference'); $this->assertTrue($rel instanceof Doctrine_Relation_ForeignKey); }
/** * DESCRIBE WHAT THIS METHOD DOES, PLEASE! * * @todo Name proposal: addRelation */ public function bind($args, $type) { $options = !isset($args[1]) ? array() : $args[1]; $options['type'] = $type; $this->_parser->bind($args[0], $options); }
/** * DESCRIBE WHAT THIS METHOD DOES, PLEASE! * * @todo Name proposal: addRelation */ public function bind($args, $type) { $options = array(); $options['type'] = $type; if (!isset($args[1])) { $args[1] = array(); } // the following is needed for backwards compatibility if (is_string($args[1])) { if (!isset($args[2])) { $args[2] = array(); } elseif (is_string($args[2])) { $args[2] = (array) $args[2]; } $classes = array_merge($this->_options['parents'], array($this->getComponentName())); $e = explode('.', $args[1]); if (in_array($e[0], $classes)) { if ($options['type'] >= Doctrine_Relation::MANY) { $options['foreign'] = $e[1]; } else { $options['local'] = $e[1]; } } else { $e2 = explode(' as ', $args[0]); if ($e[0] !== $e2[0] && (!isset($e2[1]) || $e[0] !== $e2[1])) { $options['refClass'] = $e[0]; } $options['foreign'] = $e[1]; } $options = array_merge($args[2], $options); $this->_parser->bind($args[0], $options); } else { $options = array_merge($args[1], $options); $this->_parser->bind($args[0], $options); } }