/** * @return string * @throws NotSupportedException */ protected function resolveComponentAttributeStringContentForNestedAttribute() { $attributeAndRelationData = $this->componentForm->getAttributeAndRelationData(); $count = 0; $moduleClassName = $this->componentForm->getModuleClassName(); $modelClassName = $this->componentForm->getModelClassName(); $onTableAliasName = null; $startingModelClassName = null; foreach ($attributeAndRelationData as $key => $relationOrAttribute) { $modelToReportAdapter = ModelRelationsAndAttributesToReportAdapter::make($moduleClassName, $modelClassName, $this->componentForm->getReportType()); $modelAttributeToDataProviderAdapter = $this->makeModelAttributeToDataProviderAdapter($modelToReportAdapter, $relationOrAttribute); if ($this->shouldPrematurelyStopBuildingJoinsForAttribute($modelToReportAdapter, $modelAttributeToDataProviderAdapter)) { $attribute = 'id'; $modelAttributeToDataProviderAdapter = $this->makeModelAttributeToDataProviderAdapter($modelToReportAdapter, $attribute); break; } elseif ($modelToReportAdapter->isReportedOnAsARelation($relationOrAttribute)) { $modelClassName = $modelToReportAdapter->getRelationModelClassName($relationOrAttribute); $moduleClassName = $modelToReportAdapter->getRelationModuleClassName($relationOrAttribute); if ($modelToReportAdapter->isInferredRelation($relationOrAttribute) || $modelToReportAdapter->isDerivedRelationsViaCastedUpModelRelation($relationOrAttribute)) { static::resolveCastingHintForAttribute($modelToReportAdapter, $modelAttributeToDataProviderAdapter, $modelClassName, $modelToReportAdapter->resolveRealAttributeName($attributeAndRelationData[$key + 1])); } $modelAttributeToDataProviderAdapter->setCastingHintStartingModelClassName($startingModelClassName); $builder = new ModelJoinBuilder($modelAttributeToDataProviderAdapter, $this->joinTablesAdapter); $onTableAliasName = $builder->resolveJoins($onTableAliasName, ModelDataProviderUtil::resolveCanUseFromJoins($onTableAliasName)); $startingModelClassName = $modelAttributeToDataProviderAdapter->getCastingHintModelClassNameForAttribute(); } else { if ($count + 1 != count($attributeAndRelationData)) { throw new NotSupportedException('The final element in array must be an attribute, not a relation'); } } $count++; } $modelAttributeToDataProviderAdapter->setCastingHintStartingModelClassName($startingModelClassName); return $this->resolveFinalContent($modelAttributeToDataProviderAdapter, $onTableAliasName); }