swisscom/referencedataimport 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

swisscom/referencedataimport

最新稳定版本:0.5.0

Composer 安装命令:

composer require swisscom/referencedataimport

包简介

Reference data importer based on Swisscom.AliceConnector

README 文档

README

Neos Flow package to import reference data into your project based on Swisscom.AliceConnector.

This allows to define the reference data in YAML, JSON or PHP files. YAML example:

Your\Package\Domain\Model\Vat:
  vat_normal:
    name: 'Normal'
    rate: '7.7'
  vat_special:
    name: 'Special'
    rate: '3.7'
  vat_reduced:
    name: 'Reduced'
    rate: '3.5'

See the readme in Swisscom.AliceConnector or Alice for further documentation.

Getting started

Install the package through composer.

composer require swisscom/referencedataimport

Configuration

Set the path to your reference data files in the Settings.yaml. The path is specified as a fixture set with the referenceData key as part of the Swisscom.AliceConnector package.

Swisscom:
  AliceConnector:
    fixtureSets:
      referenceData: '%FLOW_PATH_PACKAGES%Application/Your.Package/Resources/Private/ReferenceData/{name}.yaml''

Annotations

Annotate the data model classes that should get imported with Swisscom\ReferenceDataImport\Annotation\Entity. If the property should get updated on further executions, annotate it with Updatable.

<?php
namespace Your\Package\Domain\Model;

use Neos\Flow\Annotations as Flow;
use Swisscom\ReferenceDataImport\Annotation as ReferenceData;

/**
 * @Flow\Entity
 * @ReferenceData\Entity
 */
class Vat
{
    /**
     * @var string
     */
    protected $name;
    
    /**
     * @var float
     * @ReferenceData\Updatable
     */
    protected $rate;
}

Repository

Each entity repository that supports reference data import should implement the \Swisscom\ReferenceDataImport\ReferenceDataRepositoryInterface. It defines the method findByReferenceDataEntity which is called to determine wheter the object exists already or not.

Example for the Your\Package\Domain\Repository\VatRepository:

public function findByReferenceDataEntity(object $object): ?Vat
{
    $query = $this->createQuery();
    return $query->matching($query->equals('name', $object->getName()))->execute()->getFirst();
}

Usage

The data are imported via the CLI:

./flow referencedata:import

Limitation

Object relations (OneToMany, ManyToMany, ManyToOne) annotated with Updatable will point to the newly imported object even if the source object is existing. Handling those relations need to be done individually. The provided signals may be the entry point therefore.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-04