public function getLayers() { if (!$this->layers) { $this->layers = LayerManager::layers_for($this->owner); foreach ($this->layers as $l) { $others = $l->getLayers(); } if ($this->owner && $this->owner->ID) { } if (!$this->layers) { $this->layers = ArrayList::create(); } } return $this->layers; }
public static function init_layers() { $allTypes = func_get_args(); foreach ($allTypes as $classType) { // In an ideal world, we'd recursively generate a collated set of DB Fields from all // of our related layers. HOWEVER - we can't create an object of type $classType, because // the act of doing so is what binds all the extra methods pertinent to our relationships - which haven't // been defined yet. So we _need_ to do it using just the string representation of the // classname instead. // $sng = singleton($classType); // foreach ($sng->getLayers() as $l) { // $allDb = array_merge($allDb, $l->collatedDb()); // } $allDb = LayerManager::db_for_layers($classType); Config::inst()->update($classType, 'db', $allDb); $extraRels = LayerManager::rels_for_layers($classType); if (count($extraRels['has_one'])) { Config::inst()->update($classType, 'has_one', $extraRels['has_one']); } if (count($extraRels['many_many'])) { Config::inst()->update($classType, 'many_many', $extraRels['many_many']); } } }
public function manyMany() { $spec = LayerManager::layer_relationships(get_class($this), $this->name); $rels = $spec['many_many']; return $rels; }