protected function getDeliveryClassByParameters()
    {
        $rootDeliveryClass = $this->getDeliveryRootClass();

        // If an uri is provided, check if it's an existing delivery class
        if ($this->hasRequestParameter(self::REST_DELIVERY_CLASS_URI)) {
            $deliveryClass = $this->getClass($this->getRequestParameter(self::REST_DELIVERY_CLASS_URI));
            if ($deliveryClass == $rootDeliveryClass
                || ($deliveryClass->exists() && $deliveryClass->isSubClassOf($rootDeliveryClass))) {
                return $deliveryClass;
            }
            throw new \common_Exception(__('Delivery class uri provided is not a valid delivery class.'));
        }

        if ($this->hasRequestParameter(self::REST_DELIVERY_CLASS_LABEL)) {
            $label = $this->getRequestParameter(self::REST_DELIVERY_CLASS_LABEL);

            $deliveryClasses = $rootDeliveryClass->getSubClasses(true);
            $classes = [$rootDeliveryClass->getUri()];
            foreach ($deliveryClasses as $class) {
                $classes[] = $class->getUri();
            }

            /** @var ComplexSearchService $search */
            $search = $this->getServiceManager()->get(ComplexSearchService::SERVICE_ID);
            $queryBuilder = $search->query();
            $criteria = $queryBuilder->newQuery()
                ->add(OntologyRdfs::RDFS_LABEL)->equals($label)
                ->add(OntologyRdfs::RDFS_SUBCLASSOF)->in($classes)
            ;
            $queryBuilder->setCriteria($criteria);
            $result = $search->getGateway()->search($queryBuilder);

            switch ($result->count()) {
                case 0:
                    throw new \common_exception_NotFound(__('Delivery with label "%s" not found', $label));
                case 1:
                    return $this->getClass($result->current()->getUri());
                default:
                    $availableClasses = [];
                    foreach ($result as $raw) {
                        $availableClasses[] = $raw->getUri();
                    }
                    throw new \common_exception_NotFound(__('Multiple delivery class found for label "%s": %s',
                        $label, implode(',',$availableClasses)
                    ));
            }
        }

        return $rootDeliveryClass;
    }
protected function getDeliveryClassByParameters()
    {
        $rootDeliveryClass = $this->getDeliveryRootClass();

        // If an uri is provided, check if it's an existing delivery class
        if ($this->hasRequestParameter(self::REST_DELIVERY_CLASS_URI)) {
            $deliveryClass = $this->getClass($this->getRequestParameter(self::REST_DELIVERY_CLASS_URI));
            if ($deliveryClass == $rootDeliveryClass
                || ($deliveryClass->exists() && $deliveryClass->isSubClassOf($rootDeliveryClass))) {
                return $deliveryClass;
            }
            throw new \common_Exception(__('Delivery class uri provided is not a valid delivery class.'));
        }

        if ($this->hasRequestParameter(self::REST_DELIVERY_CLASS_LABEL)) {
            $label = $this->getRequestParameter(self::REST_DELIVERY_CLASS_LABEL);

            $deliveryClasses = $rootDeliveryClass->getSubClasses(true);
            $classes = [$rootDeliveryClass->getUri()];
            foreach ($deliveryClasses as $class) {
                $classes[] = $class->getUri();
            }

            /** @var ComplexSearchService $search */
            $search = $this->getServiceManager()->get(ComplexSearchService::SERVICE_ID);
            $queryBuilder = $search->query();
            $criteria = $queryBuilder->newQuery()
                ->add(OntologyRdfs::RDFS_LABEL)->equals($label)
                ->add(OntologyRdfs::RDFS_SUBCLASSOF)->in($classes)
            ;
            $queryBuilder->setCriteria($criteria);
            $result = $search->getGateway()->search($queryBuilder);

            switch ($result->count()) {
                case 0:
                    throw new \common_exception_NotFound(__('Delivery with label "%s" not found', $label));
                case 1:
                    return $this->getClass($result->current()->getUri());
                default:
                    $availableClasses = [];
                    foreach ($result as $raw) {
                        $availableClasses[] = $raw->getUri();
                    }
                    throw new \common_exception_NotFound(__('Multiple delivery class found for label "%s": %s',
                        $label, implode(',',$availableClasses)
                    ));
            }
        }

        return $rootDeliveryClass;
    }
protected function getDeliveryClassByParameters ( ) { $ rootDeliveryClass = $ this -> getDeliveryRootClass ( ) ; // If an uri is provided, check if it's an existing delivery class if ( $ this -> hasRequestParameter ( self :: REST_DELIVERY_CLASS_URI ) ) { $ deliveryClass = $ this -> getClass ( $ this -> getRequestParameter ( self :: REST_DELIVERY_CLASS_URI ) ) ; if ( $ deliveryClass == $ rootDeliveryClass || ( $ deliveryClass -> exists ( ) && $ deliveryClass -> isSubClassOf ( $ rootDeliveryClass ) ) ) { return $ deliveryClass ; } throw new \ common_Exception ( __ ( 'Delivery class uri provided is not a valid delivery class.' ) ) ; } if ( $ this -> hasRequestParameter ( self :: REST_DELIVERY_CLASS_LABEL ) ) { $ label = $ this -> getRequestParameter ( self :: REST_DELIVERY_CLASS_LABEL ) ; $ deliveryClasses = $ rootDeliveryClass -> getSubClasses ( true ) ; $ classes = [ $ rootDeliveryClass -> getUri ( ) ] ; foreach ( $ deliveryClasses as $ class ) { $ classes [ ] = $ class -> getUri ( ) ; } /** @var ComplexSearchService $search */ $ search = $ this -> getServiceManager ( ) -> get ( ComplexSearchService :: SERVICE_ID ) ; $ queryBuilder = $ search -> query ( ) ; $ criteria = $ queryBuilder -> newQuery ( ) -> add ( OntologyRdfs :: RDFS_LABEL ) -> equals ( $ label ) -> add ( OntologyRdfs :: RDFS_SUBCLASSOF ) -> in ( $ classes ) ; $ queryBuilder -> setCriteria ( $ criteria ) ; $ result = $ search -> getGateway ( ) -> search ( $ queryBuilder ) ; switch ( $ result -> count ( ) ) { case 0 : throw new \ common_exception_NotFound ( __ ( 'Delivery with label "%s" not found' , $ label ) ) ; case 1 : return $ this -> getClass ( $ result -> current ( ) -> getUri ( ) ) ; default : $ availableClasses = [ ] ; foreach ( $ result as $ raw ) { $ availableClasses [ ] = $ raw -> getUri ( ) ; } throw new \ common_exception_NotFound ( __ ( 'Multiple delivery class found for label "%s": %s' , $ label , implode ( ',' , $ availableClasses ) ) ) ; } } return $ rootDeliveryClass ; }
Get a delivery class based on parameters

If an uri parameter is provided, and it is a delivery class, this delivery class is returned
If a label parameter is provided, and only one delivery class has this label, this delivery class is returned

@return \core_kernel_classes_Class
@throws \common_Exception
@throws \common_exception_NotFound
Get a delivery class based on parameters