/** * Calculate the query parameters that should be inherited from the base many_many * to the nested has_many list. * * @param DataQuery $query * @return mixed */ public function extractInheritableQueryParameters(DataQuery $query) { $params = $query->getQueryParams(); // Remove `Foreign.` query parameters for created objects, // as this would interfere with relations on those objects. foreach (array_keys($params) as $key) { if (stripos($key, 'Foreign.') === 0) { unset($params[$key]); } } // Get inheritable parameters from an instance of the base query dataclass $inst = Injector::inst()->create($query->dataClass()); $inst->setSourceQueryParams($params); return $inst->getInheritableQueryParams(); }