定制 dbp/relay-verity-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dbp/relay-verity-bundle

最新稳定版本:v0.1.9

Composer 安装命令:

composer require dbp/relay-verity-bundle

包简介

A validation bundle for the Relay API gateway

README 文档

README

GitHub | Packagist

The verity bundle provides an API for interacting with objects to validate (e.g. a PDF to validate against PDF/A-1b).

Bundle installation

You can install the bundle directly from packagist.org.

composer require dbp/relay-verity-bundle

Integration into the Relay API Server

  • Add the bundle to your config/bundles.php in front of DbpRelayCoreBundle:
...
Dbp\Relay\VerityBundle\DbpRelayVerityBundle::class => ['all' => true],
Dbp\Relay\CoreBundle\DbpRelayCoreBundle::class => ['all' => true],
];

If you were using the DBP API Server Template as template for your Symfony application, then this should have already been generated for you.

  • Run composer install to clear caches

Configuration

For this create config/packages/dbp_relay_verity.yaml in the app with the following content:

dbp_relay_verity:
  backends:
    pdfa:
      validator: 'Dbp\Relay\VerityConnectorVerapdfBundle\Service\PDFAValidationAPI'
    
  profiles:
    archive:
      name: 'Check PDFs for archiving complacency'
      rule: 'pdfa.validity == true && pdfa_b2.validity == true'
      checks:
        pdfa:
          backend: 'pdfa'
          config: '{"flavour": "1b"}'
        pdfa_b2:
          backend: 'pdfa'
          config: '{"flavour": "2b"}'

There are two sections in this bundle configuration:

  1. backends for the configuration of backend services
  2. profiles for the checks available via the API

In this example, a backend with the name pdfa is implemented by the PHP class PDFAValidationAPI. There is also a profile defines with the name archive. A profile performs all checks and stores the results (the validity and also errors) in a variable named like the check, here pdfa and pdfa_b2. Each check has the name of its backend to use and a config to set the type of check to perform. The results of all checks are then evaluated by the rule of the profile. The syntax of the rule is almost PHP syntax, but before any function is available, they must be registered first!

If you were using the DBP API Server Template as template for your Symfony application, then the configuration file should have already been generated for you.

For more info on bundle configuration see https://symfony.com/doc/current/bundles/configuration.html.

Development & Testing

  • Install dependencies: composer install
  • Run tests: composer test
  • Run linters: composer run lint
  • Run cs-fixer: composer run cs-fix

Bundle dependencies

Don't forget you need to pull down your dependencies in your main application if you are installing packages in a bundle.

# updates and installs dependencies of dbp/relay-verity-bundle
composer update dbp/relay-verity-bundle

Scripts

Error codes

/verity/reports

POST

relay:errorId Status code Description
'verity:create-report-missing-profile' 400 Unknown profile "$profileName"!
'verity:create-report-missing-file' 400 No file with parameter key "file" was received!
'verity:create-report-file-hash-mismatch' 400 Parameter file hash mismatch.
'verity:create-report-file-size-zero' 400 Parameter file size is 0 (zero).
'verity:create-report-file-content-empty' 400 File content is empty.
'verity:create-report-file-size-mismatch' 400 Parameter file size mismatch.
'verity:create-report-backend-exception' 400 $profileName throws an exception

/verity/reports/{identifier}

GET

relay:errorId Status code Description relay:errorDetails Example
verity:report-not-found 404 Submission was not found.

Roles

This bundle needs the role ROLE_SCOPE_VALIDATION assigned to the user to get permissions to fetch data. To create a new submission entry the Symfony role ROLE_SCOPE_VALIDATION-POST is required.

Events

To extend the behavior of the bundle the following event is registered:

VerityRequestEvent

This event allows you to send a request for validation internally. See tests/EventSubscriberTest.php as an example.

VerityEvent

This event allows you to get notifications for (all) verity reports.

An event subscriber receives a Dbp\Relay\VerityBundle\Event\VerityEvent instance:

<?php

namespace App\EventSubscriber;

use Dbp\Relay\VerityBundle\Event\VerityEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class VerityEventSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents(): array
    {
        return [
            VerityEvent::NAME => 'onVerity',
        ];
    }

    public function onVerity(VerityEvent $event)
    {
        $report = $event->getReport();

        // TODO: extract relevant information
        $valid = $report->isValid();
    }
}

统计信息

  • 总下载量: 6.6k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: AGPL-3.0-or-later
  • 更新时间: 未知

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固