protected function insertDbTableResources($service)
    {
        $data = $this->package->getResourceFromZip($service . '/_table' . '.json');
        if (!empty($data)) {
            foreach ($data as $table) {
                $tableName = array_get($table, 'name');
                $resource = '_table/' . $tableName;
                $records = array_get($table, 'record');
                $records = $this->cleanDuplicates($records, $service, $resource);

                if (!empty($records)) {
                    try {
                        foreach ($records as $i => $record) {
                            $this->fixCommonFields($record, false);
                            $this->unsetImportedRelations($record);
                            $records[$i] = $record;
                        }

                        $payload = ResourcesWrapper::wrapResources($records);
                        $result = ServiceManager::handleRequest(
                            $service,
                            Verbs::POST,
                            $resource,
                            ['continue' => true],
                            [],
                            $payload,
                            null,
                            true,
                            true
                        );
                        if ($result->getStatusCode() >= 300) {
                            throw ResponseFactory::createExceptionFromResponse($result);
                        }
                    } catch (\Exception $e) {
//                        if ($e->getCode() === HttpStatusCodes::HTTP_FORBIDDEN) {
//                            $this->log(
//                                'error',
//                                'Failed to insert ' .
//                                $service .
//                                '/' .
//                                $resource .
//                                '. ' .
//                                $this->getErrorDetails($e)
//                            );
//                        } else {
//                            throw new InternalServerErrorException('Failed to insert ' .
//                                $service .
//                                '/' .
//                                $resource .
//                                '. ' .
//                                $this->getErrorDetails($e)
//                            );
//                        }
                        $this->throwExceptions($e, 'Failed to insert ' . $service . '/' . $resource);
                    }
                }
            }

            return true;
        }

        return false;
    }
protected function insertDbTableResources($service)
    {
        $data = $this->package->getResourceFromZip($service . '/_table' . '.json');
        if (!empty($data)) {
            foreach ($data as $table) {
                $tableName = array_get($table, 'name');
                $resource = '_table/' . $tableName;
                $records = array_get($table, 'record');
                $records = $this->cleanDuplicates($records, $service, $resource);

                if (!empty($records)) {
                    try {
                        foreach ($records as $i => $record) {
                            $this->fixCommonFields($record, false);
                            $this->unsetImportedRelations($record);
                            $records[$i] = $record;
                        }

                        $payload = ResourcesWrapper::wrapResources($records);
                        $result = ServiceManager::handleRequest(
                            $service,
                            Verbs::POST,
                            $resource,
                            ['continue' => true],
                            [],
                            $payload,
                            null,
                            true,
                            true
                        );
                        if ($result->getStatusCode() >= 300) {
                            throw ResponseFactory::createExceptionFromResponse($result);
                        }
                    } catch (\Exception $e) {
//                        if ($e->getCode() === HttpStatusCodes::HTTP_FORBIDDEN) {
//                            $this->log(
//                                'error',
//                                'Failed to insert ' .
//                                $service .
//                                '/' .
//                                $resource .
//                                '. ' .
//                                $this->getErrorDetails($e)
//                            );
//                        } else {
//                            throw new InternalServerErrorException('Failed to insert ' .
//                                $service .
//                                '/' .
//                                $resource .
//                                '. ' .
//                                $this->getErrorDetails($e)
//                            );
//                        }
                        $this->throwExceptions($e, 'Failed to insert ' . $service . '/' . $resource);
                    }
                }
            }

            return true;
        }

        return false;
    }
protected function insertDbTableResources ( $ service ) { $ data = $ this -> package -> getResourceFromZip ( $ service . '/_table' . '.json' ) ; if ( ! empty ( $ data ) ) { foreach ( $ data as $ table ) { $ tableName = array_get ( $ table , 'name' ) ; $ resource = '_table/' . $ tableName ; $ records = array_get ( $ table , 'record' ) ; $ records = $ this -> cleanDuplicates ( $ records , $ service , $ resource ) ; if ( ! empty ( $ records ) ) { try { foreach ( $ records as $ i => $ record ) { $ this -> fixCommonFields ( $ record , false ) ; $ this -> unsetImportedRelations ( $ record ) ; $ records [ $ i ] = $ record ; } $ payload = ResourcesWrapper :: wrapResources ( $ records ) ; $ result = ServiceManager :: handleRequest ( $ service , Verbs :: POST , $ resource , [ 'continue' => true ] , [ ] , $ payload , null , true , true ) ; if ( $ result -> getStatusCode ( ) >= 300 ) { throw ResponseFactory :: createExceptionFromResponse ( $ result ) ; } } catch ( \ Exception $ e ) { //                        if ($e->getCode() === HttpStatusCodes::HTTP_FORBIDDEN) { //                            $this->log( //                                'error', //                                'Failed to insert ' . //                                $service . //                                '/' . //                                $resource . //                                '. ' . //                                $this->getErrorDetails($e) //                            ); //                        } else { //                            throw new InternalServerErrorException('Failed to insert ' . //                                $service . //                                '/' . //                                $resource . //                                '. ' . //                                $this->getErrorDetails($e) //                            ); //                        } $ this -> throwExceptions ( $ e , 'Failed to insert ' . $ service . '/' . $ resource ) ; } } } return true ; } return false ; }
Insert DB table data.

@param $service

@return bool
@throws \DreamFactory\Core\Exceptions\InternalServerErrorException
Insert DB table data .