src/Controller/DefaultController.php
protected function assembleChildrenFor(ModelInterface $model, $sortingProperty = null)
    {
        $environment   = $this->getEnvironment();
        $definition    = $environment->getDataDefinition();
        $provider      = $environment->getDataProvider($model->getProviderName());
        $config        = $environment->getBaseConfigRegistry()->getBaseConfig();
        $relationships = $definition->getModelRelationshipDefinition();

        if (BasicDefinitionInterface::MODE_HIERARCHICAL !== $definition->getBasicDefinition()->getMode()) {
            throw new DcGeneralRuntimeException('Unable to retrieve children in non hierarchical mode.');
        }

        $condition = $relationships->getChildCondition($model->getProviderName(), $model->getProviderName());
        $config->setFilter($condition->getFilter($model));

        if ($sortingProperty) {
            $config->setSorting([(string) $sortingProperty => 'ASC']);
        }

        return $provider->fetchAll($config);
    }
protected function assembleChildrenFor(ModelInterface $model, $sortingProperty = null)
    {
        $environment   = $this->getEnvironment();
        $definition    = $environment->getDataDefinition();
        $provider      = $environment->getDataProvider($model->getProviderName());
        $config        = $environment->getBaseConfigRegistry()->getBaseConfig();
        $relationships = $definition->getModelRelationshipDefinition();

        if (BasicDefinitionInterface::MODE_HIERARCHICAL !== $definition->getBasicDefinition()->getMode()) {
            throw new DcGeneralRuntimeException('Unable to retrieve children in non hierarchical mode.');
        }

        $condition = $relationships->getChildCondition($model->getProviderName(), $model->getProviderName());
        $config->setFilter($condition->getFilter($model));

        if ($sortingProperty) {
            $config->setSorting([(string) $sortingProperty => 'ASC']);
        }

        return $provider->fetchAll($config);
    }
protected function assembleChildrenFor ( ModelInterface $ model , $ sortingProperty = null ) { $ environment = $ this -> getEnvironment ( ) ; $ definition = $ environment -> getDataDefinition ( ) ; $ provider = $ environment -> getDataProvider ( $ model -> getProviderName ( ) ) ; $ config = $ environment -> getBaseConfigRegistry ( ) -> getBaseConfig ( ) ; $ relationships = $ definition -> getModelRelationshipDefinition ( ) ; if ( BasicDefinitionInterface :: MODE_HIERARCHICAL !== $ definition -> getBasicDefinition ( ) -> getMode ( ) ) { throw new DcGeneralRuntimeException ( 'Unable to retrieve children in non hierarchical mode.' ) ; } $ condition = $ relationships -> getChildCondition ( $ model -> getProviderName ( ) , $ model -> getProviderName ( ) ) ; $ config -> setFilter ( $ condition -> getFilter ( $ model ) ) ; if ( $ sortingProperty ) { $ config -> setSorting ( [ ( string ) $ sortingProperty => 'ASC' ] ) ; } return $ provider -> fetchAll ( $ config ) ; }
Retrieve children of a given model.

@param ModelInterface $model           The model for which the children shall be retrieved.
@param string|null    $sortingProperty The property name to use for sorting.

@return CollectionInterface

@throws DcGeneralRuntimeException When not in hierarchical mode.
Retrieve children of a given model .