Library/Bullhorn/FastRest/Api/Services/ControllerHelper/Index.php
private function buildSearchFieldsRecursive(Search $search, ApiInterface $entity) {
        $isRoot = false;
        $alias = $search->getAlias();
        if(is_null($alias)) {
            $isRoot = true;
            $alias = get_class($entity);
        }

        foreach($search->getFields() as $field => $value) {
            if(in_array(preg_replace("/[<|>]$/", "", $field), $entity->getModelsMetaData()->getColumnMap($entity))) {
                $this->addSearchField($field, $value, $entity, $alias);
            } else {
                if(!$isRoot || !in_array($field, $this->getWhiteList())) {
                    throw new Exception('Could not find the field: ' . ($isRoot ? '' : $alias . '.') . $field, 400);
                }
            }
        }
        foreach($search->getChildren() as $child) {
            if(in_array($child->getAlias(), $entity->getParentRelationships())) {
                $subEntity = $this->addJoin($entity, $child->getAlias(), false);
                $this->buildSearchFieldsRecursive($child, $subEntity);
            } elseif(in_array($child->getAlias(), $entity->getChildrenRelationships())) {
                throw new Exception('Cannot search on children: ' . ($isRoot ? '' : $alias . '.') . $child->getAlias(), 400);
            } else {
                throw new Exception('Could not find the parent: ' . ($isRoot ? '' : $alias . '.') . $child->getAlias(), 400);
            }
        }

        $this->addSoftDelete($entity, $alias);
    }
private function buildSearchFieldsRecursive(Search $search, ApiInterface $entity) {
        $isRoot = false;
        $alias = $search->getAlias();
        if(is_null($alias)) {
            $isRoot = true;
            $alias = get_class($entity);
        }

        foreach($search->getFields() as $field => $value) {
            if(in_array(preg_replace("/[<|>]$/", "", $field), $entity->getModelsMetaData()->getColumnMap($entity))) {
                $this->addSearchField($field, $value, $entity, $alias);
            } else {
                if(!$isRoot || !in_array($field, $this->getWhiteList())) {
                    throw new Exception('Could not find the field: ' . ($isRoot ? '' : $alias . '.') . $field, 400);
                }
            }
        }
        foreach($search->getChildren() as $child) {
            if(in_array($child->getAlias(), $entity->getParentRelationships())) {
                $subEntity = $this->addJoin($entity, $child->getAlias(), false);
                $this->buildSearchFieldsRecursive($child, $subEntity);
            } elseif(in_array($child->getAlias(), $entity->getChildrenRelationships())) {
                throw new Exception('Cannot search on children: ' . ($isRoot ? '' : $alias . '.') . $child->getAlias(), 400);
            } else {
                throw new Exception('Could not find the parent: ' . ($isRoot ? '' : $alias . '.') . $child->getAlias(), 400);
            }
        }

        $this->addSoftDelete($entity, $alias);
    }
private function buildSearchFieldsRecursive ( Search $ search , ApiInterface $ entity ) { $ isRoot = false ; $ alias = $ search -> getAlias ( ) ; if ( is_null ( $ alias ) ) { $ isRoot = true ; $ alias = get_class ( $ entity ) ; } foreach ( $ search -> getFields ( ) as $ field => $ value ) { if ( in_array ( preg_replace ( "/[<|>]$/" , "" , $ field ) , $ entity -> getModelsMetaData ( ) -> getColumnMap ( $ entity ) ) ) { $ this -> addSearchField ( $ field , $ value , $ entity , $ alias ) ; } else { if ( ! $ isRoot || ! in_array ( $ field , $ this -> getWhiteList ( ) ) ) { throw new Exception ( 'Could not find the field: ' . ( $ isRoot ? '' : $ alias . '.' ) . $ field , 400 ) ; } } } foreach ( $ search -> getChildren ( ) as $ child ) { if ( in_array ( $ child -> getAlias ( ) , $ entity -> getParentRelationships ( ) ) ) { $ subEntity = $ this -> addJoin ( $ entity , $ child -> getAlias ( ) , false ) ; $ this -> buildSearchFieldsRecursive ( $ child , $ subEntity ) ; } elseif ( in_array ( $ child -> getAlias ( ) , $ entity -> getChildrenRelationships ( ) ) ) { throw new Exception ( 'Cannot search on children: ' . ( $ isRoot ? '' : $ alias . '.' ) . $ child -> getAlias ( ) , 400 ) ; } else { throw new Exception ( 'Could not find the parent: ' . ( $ isRoot ? '' : $ alias . '.' ) . $ child -> getAlias ( ) , 400 ) ; } } $ this -> addSoftDelete ( $ entity , $ alias ) ; }
Builds the search fields

@param Search $search
@param ApiInterface $entity

@return void
@throws Exception
Builds the search fields