src/controller/PageSliceControllerExtension.php
public function handleSlice()
    {
        if (!$id = $this->owner->getRequest()->param('ID')) {
            return false;
        }

        $sliceRelations = array();
        if (!$hasManyRelations = $this->owner->data()->hasMany()) {
            return false;
        }

        foreach ($hasManyRelations as $relationName => $relationClass) {
            if ($relationClass == PageSlice::class || is_subclass_of($relationClass, PageSlice::class)) {
                $sliceRelations[] = $relationName;
            }
        }

        $slice = null;
        foreach ($sliceRelations as $sliceRelation) {
            if ($slice) {
                break;
            }
            /** @var PageSlice $slice */
            $slice = $this->owner->data()->$sliceRelation()->find('ID', $id);
        }

        if (!$slice) {
            user_error('No slice found', E_USER_ERROR);
        }

        return $slice->getController();
    }
public function handleSlice()
    {
        if (!$id = $this->owner->getRequest()->param('ID')) {
            return false;
        }

        $sliceRelations = array();
        if (!$hasManyRelations = $this->owner->data()->hasMany()) {
            return false;
        }

        foreach ($hasManyRelations as $relationName => $relationClass) {
            if ($relationClass == PageSlice::class || is_subclass_of($relationClass, PageSlice::class)) {
                $sliceRelations[] = $relationName;
            }
        }

        $slice = null;
        foreach ($sliceRelations as $sliceRelation) {
            if ($slice) {
                break;
            }
            /** @var PageSlice $slice */
            $slice = $this->owner->data()->$sliceRelation()->find('ID', $id);
        }

        if (!$slice) {
            user_error('No slice found', E_USER_ERROR);
        }

        return $slice->getController();
    }
public function handleSlice ( ) { if ( ! $ id = $ this -> owner -> getRequest ( ) -> param ( 'ID' ) ) { return false ; } $ sliceRelations = array ( ) ; if ( ! $ hasManyRelations = $ this -> owner -> data ( ) -> hasMany ( ) ) { return false ; } foreach ( $ hasManyRelations as $ relationName => $ relationClass ) { if ( $ relationClass == PageSlice :: class || is_subclass_of ( $ relationClass , PageSlice :: class ) ) { $ sliceRelations [ ] = $ relationName ; } } $ slice = null ; foreach ( $ sliceRelations as $ sliceRelation ) { if ( $ slice ) { break ; } /** @var PageSlice $slice */ $ slice = $ this -> owner -> data ( ) -> $ sliceRelation ( ) -> find ( 'ID' , $ id ) ; } if ( ! $ slice ) { user_error ( 'No slice found' , E_USER_ERROR ) ; } return $ slice -> getController ( ) ; }
Handle the slice

@return bool|PageSliceController
Handle the slice