This commit is contained in:
parent
63bca659f8
commit
4d0310bfd5
@ -277,6 +277,10 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
|
|||||||
{
|
{
|
||||||
return isset($this->data[$key]);
|
return isset($this->data[$key]);
|
||||||
}
|
}
|
||||||
|
public function search(Doctrine_Record $record)
|
||||||
|
{
|
||||||
|
return array_search($record, $this->data, true);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* get
|
* get
|
||||||
* returns a record for given key
|
* returns a record for given key
|
||||||
|
@ -46,6 +46,19 @@ class Doctrine_Hydrate_Record
|
|||||||
|
|
||||||
return $coll;
|
return $coll;
|
||||||
}
|
}
|
||||||
|
public function search(Doctrine_Record $record, Doctrine_Collection $coll)
|
||||||
|
{
|
||||||
|
return array_search($record, $coll->getData(), true);
|
||||||
|
}
|
||||||
|
public function initRelated($record, $name)
|
||||||
|
{
|
||||||
|
if ( ! is_array($record)) {
|
||||||
|
$record[$name];
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
public function registerCollection(Doctrine_Collection $coll)
|
public function registerCollection(Doctrine_Collection $coll)
|
||||||
{
|
{
|
||||||
$this->_collections[] = $coll;
|
$this->_collections[] = $coll;
|
||||||
|
@ -690,11 +690,11 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
|||||||
* returns a value of a property or a related component
|
* returns a value of a property or a related component
|
||||||
*
|
*
|
||||||
* @param mixed $name name of the property or related component
|
* @param mixed $name name of the property or related component
|
||||||
* @param boolean $invoke whether or not to invoke the onGetProperty listener
|
* @param boolean $load whether or not to invoke the loading procedure
|
||||||
* @throws Doctrine_Record_Exception if trying to get a value of unknown property / related component
|
* @throws Doctrine_Record_Exception if trying to get a value of unknown property / related component
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function get($name, $invoke = true)
|
public function get($name, $load = true)
|
||||||
{
|
{
|
||||||
$value = self::$_null;
|
$value = self::$_null;
|
||||||
$lower = strtolower($name);
|
$lower = strtolower($name);
|
||||||
@ -726,9 +726,14 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ( ! isset($this->_references[$name])) {
|
|
||||||
$this->loadReference($name);
|
if ( ! isset($this->_references[$name]) && $load) {
|
||||||
|
|
||||||
|
$rel = $this->_table->getRelation($name);
|
||||||
|
|
||||||
|
$this->_references[$name] = $rel->fetchRelatedFor($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch(Doctrine_Table_Exception $e) {
|
} catch(Doctrine_Table_Exception $e) {
|
||||||
throw new Doctrine_Record_Exception("Unknown property / related component '$name'.");
|
throw new Doctrine_Record_Exception("Unknown property / related component '$name'.");
|
||||||
}
|
}
|
||||||
@ -816,7 +821,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
|||||||
|
|
||||||
// one-to-many or one-to-one relation
|
// one-to-many or one-to-one relation
|
||||||
if ($rel instanceof Doctrine_Relation_ForeignKey ||
|
if ($rel instanceof Doctrine_Relation_ForeignKey ||
|
||||||
$rel instanceof Doctrine_Relation_LocalKey) {
|
$rel instanceof Doctrine_Relation_LocalKey) {
|
||||||
if ( ! $rel->isOneToOne()) {
|
if ( ! $rel->isOneToOne()) {
|
||||||
// one-to-many relation found
|
// one-to-many relation found
|
||||||
if ( ! ($value instanceof Doctrine_Collection)) {
|
if ( ! ($value instanceof Doctrine_Collection)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user