|
@@ 2007-2017 (lines=11) @@
|
| 2004 |
|
* the field data stripped off. It defaults to TRUE. |
| 2005 |
|
* @return string|null |
| 2006 |
|
*/ |
| 2007 |
|
public function belongsToComponent($component, $classOnly = true) { |
| 2008 |
|
$belongsTo = (array)Config::inst()->get($this->class, 'belongs_to', Config::INHERITED); |
| 2009 |
|
|
| 2010 |
|
if($belongsTo && array_key_exists($component, $belongsTo)) { |
| 2011 |
|
$belongsTo = $belongsTo[$component]; |
| 2012 |
|
} else { |
| 2013 |
|
return null; |
| 2014 |
|
} |
| 2015 |
|
|
| 2016 |
|
return ($classOnly) ? preg_replace('/(.+)?\..+/', '$1', $belongsTo) : $belongsTo; |
| 2017 |
|
} |
| 2018 |
|
|
| 2019 |
|
/** |
| 2020 |
|
* Return all of the database fields in this object |
|
@@ 2102-2112 (lines=11) @@
|
| 2099 |
|
* the field data stripped off. It defaults to TRUE. |
| 2100 |
|
* @return string|null |
| 2101 |
|
*/ |
| 2102 |
|
public function hasManyComponent($component, $classOnly = true) { |
| 2103 |
|
$hasMany = (array)Config::inst()->get($this->class, 'has_many', Config::INHERITED); |
| 2104 |
|
|
| 2105 |
|
if($hasMany && array_key_exists($component, $hasMany)) { |
| 2106 |
|
$hasMany = $hasMany[$component]; |
| 2107 |
|
} else { |
| 2108 |
|
return null; |
| 2109 |
|
} |
| 2110 |
|
|
| 2111 |
|
return ($classOnly) ? preg_replace('/(.+)?\..+/', '$1', $hasMany) : $hasMany; |
| 2112 |
|
} |
| 2113 |
|
|
| 2114 |
|
/** |
| 2115 |
|
* Return the many-to-many extra fields specification. |