hopeter1018/sequential-counter-format-bundle

此包旨在为doctrine实体生成价值。

1.0.9 2020-09-09 02:28 UTC

This package is auto-updated.

Last update: 2024-09-09 10:49:08 UTC


README

简介

此包旨在为doctrine实体生成价值。

安装

需要此包

composer require hopeter1018/sequential-counter-format-bundle

添加到内核

Symfony 4+ 或 Symfony Flex

添加 /config/bundles.php

return [
  ...,
  HoPeter1018\SequentialCounterFormatBundle\HoPeter1018SequentialCounterFormatBundle::class => ['all' => true],
];

Symfony 2+

添加 /app/AppKernel.php

$bundles = [
  ...,
  new HoPeter1018\SequentialCounterFormatBundle\HoPeter1018SequentialCounterFormatBundle(),
];

配置

通过 config.yml / config.yaml

ho_peter1018_sequential_counter_format:
  # managers: ['default'] # add / modify if you are not using 'default'
  rules:
    _rule_alias_:
        entity_class: 'Your\Bundle\Entity\EntityClass'
        property: 'yamlTargetPropertyName'
        format: '__SEE_FORMAT_SECTION__'

通过 Doctrine 注释

namespace Your\Bundle\Entity;

use HoPeter1018\SequentialCounterFormatBundle\Annotations as Scf;

/**
 * Class docblock
 *
 * @Scf\ClassRule(settings={
 *   "classAnnotationTargetPropertyName"={"format"="__SEE_FORMAT_SECTION__", "batchPrefix"="[site.id]"},
 * })
 */
class EntityClass {

  /**
   * @Scf\PropertyRule("__SEE_FORMAT_SECTION__")
   * @ORM\Column(type="string", length=255)
   */
  private $propertyAnnotationTargetPropertyName;

  /**
   * @ORM\Column(type="string", length=255)
   */
  private $classAnnotationTargetPropertyName;

  /**
   * declared in the above section: `thru config.yml / config.yaml`
   */
  private $yamlTargetPropertyName;

}

使用

格式占位符