Commit 3cd669ad authored by doctrine's avatar doctrine

[amadeus] added Record::has() and Table::hasForeignKey(),hasRelatedComponent()

parent a20d0544
......@@ -607,6 +607,18 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this->modified[] = $name;
}
}
/**
* has
* method for checking existence of properties and Doctrine_Record references
*
* @param mixed $name name of the property or reference
* @return boolean
*/
public function has($name) {
if(isset($this->data[$name]) OR isset($this->id[$name]))
return true;
return $this->table->hasForeignKey($name);
}
/**
* set
* method for altering properties and Doctrine_Record references
......
......@@ -513,6 +513,28 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
final public function getCache() {
return $this->cache;
}
/**
* hasRelatedComponent
* @return boolean
*/
final public function hasRelatedComponent($name, $component) {
return (strpos($this->bound[$name][0], $component.'.') !== false);
}
/**
* @param string $name component name of which a foreign key object is bound
* @return boolean
*/
final public function hasForeignKey($name) {
if(isset($this->bound[$name]))
return true;
foreach($this->bound as $k=>$v)
{
if($this->hasRelatedComponent($k, $name))
return true;
}
return false;
}
/**
* @param string $name component name of which a foreign key object is bound
* @return Doctrine_Relation
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment