private function packageSchemas()
    {
        if (!empty($this->exportSchemas)) {
            $schemas = [];

            foreach ($this->exportSchemas as $serviceName => $component) {
                if (is_array($component)) {
                    $component = implode(',', $component);
                }

                if (is_numeric($serviceName)) {
                    /** @type Service $service */
                    $service = Service::find($serviceName);
                } else {
                    /** @type Service $service */
                    $service = Service::whereName($serviceName)->whereDeletable(1)->first();
                }

                if (!empty($service) && !empty($component)) {
                    if ($service->type === 'sql_db') {
                        $result = ServiceManager::handleRequest(
                            $serviceName,
                            Verbs::GET,
                            '_schema',
                            ['ids' => $component]
                        );
                        if ($result->getStatusCode() >= 300) {
                            throw ResponseFactory::createExceptionFromResponse($result);
                        }

                        $schema = $result->getContent();
                        $schemas[] = [
                            'name'  => $serviceName,
                            'table' => ($this->resourceWrapped) ? $schema[$this->resourceWrapper] : $schema
                        ];
                    }
                }
            }

            if (!empty($schemas) &&
                !$this->zip->addFromString('schema.json', json_encode(['service' => $schemas], JSON_UNESCAPED_SLASHES))
            ) {
                throw new InternalServerErrorException("Can not include database schema in package file.");
            }

            return true;
        }

        return false;
    }
private function packageSchemas()
    {
        if (!empty($this->exportSchemas)) {
            $schemas = [];

            foreach ($this->exportSchemas as $serviceName => $component) {
                if (is_array($component)) {
                    $component = implode(',', $component);
                }

                if (is_numeric($serviceName)) {
                    /** @type Service $service */
                    $service = Service::find($serviceName);
                } else {
                    /** @type Service $service */
                    $service = Service::whereName($serviceName)->whereDeletable(1)->first();
                }

                if (!empty($service) && !empty($component)) {
                    if ($service->type === 'sql_db') {
                        $result = ServiceManager::handleRequest(
                            $serviceName,
                            Verbs::GET,
                            '_schema',
                            ['ids' => $component]
                        );
                        if ($result->getStatusCode() >= 300) {
                            throw ResponseFactory::createExceptionFromResponse($result);
                        }

                        $schema = $result->getContent();
                        $schemas[] = [
                            'name'  => $serviceName,
                            'table' => ($this->resourceWrapped) ? $schema[$this->resourceWrapper] : $schema
                        ];
                    }
                }
            }

            if (!empty($schemas) &&
                !$this->zip->addFromString('schema.json', json_encode(['service' => $schemas], JSON_UNESCAPED_SLASHES))
            ) {
                throw new InternalServerErrorException("Can not include database schema in package file.");
            }

            return true;
        }

        return false;
    }
private function packageSchemas ( ) { if ( ! empty ( $ this -> exportSchemas ) ) { $ schemas = [ ] ; foreach ( $ this -> exportSchemas as $ serviceName => $ component ) { if ( is_array ( $ component ) ) { $ component = implode ( ',' , $ component ) ; } if ( is_numeric ( $ serviceName ) ) { /** @type Service $service */ $ service = Service :: find ( $ serviceName ) ; } else { /** @type Service $service */ $ service = Service :: whereName ( $ serviceName ) -> whereDeletable ( 1 ) -> first ( ) ; } if ( ! empty ( $ service ) && ! empty ( $ component ) ) { if ( $ service -> type === 'sql_db' ) { $ result = ServiceManager :: handleRequest ( $ serviceName , Verbs :: GET , '_schema' , [ 'ids' => $ component ] ) ; if ( $ result -> getStatusCode ( ) >= 300 ) { throw ResponseFactory :: createExceptionFromResponse ( $ result ) ; } $ schema = $ result -> getContent ( ) ; $ schemas [ ] = [ 'name' => $ serviceName , 'table' => ( $ this -> resourceWrapped ) ? $ schema [ $ this -> resourceWrapper ] : $ schema ] ; } } } if ( ! empty ( $ schemas ) && ! $ this -> zip -> addFromString ( 'schema.json' , json_encode ( [ 'service' => $ schemas ] , JSON_UNESCAPED_SLASHES ) ) ) { throw new InternalServerErrorException ( "Can not include database schema in package file." ) ; } return true ; } return false ; }
Package schemas for export.
@return bool
@throws InternalServerErrorException
@throws \DreamFactory\Core\Exceptions\RestException
Package schemas for export .