dotcommerce/fastentitybundle

为 Symfony 2 优化的实体包,用于比默认的 'entity' 表单类型更快地生成下拉框

dev-master 2013-02-13 11:07 UTC

This package is not auto-updated.

Last update: 2024-09-28 13:42:16 UTC


README

为 Symfony 2 优化的实体包,用于比默认的 'entity' 表单类型更快地生成下拉框。为此,需要为下拉框中使用的实体生成一个新的表单类型。

用法

您需要使用 Symfony 的命令行工具(app/console)来生成新的表单类型。语法很简单

$ app/console dotcommerce:generate:fastentity BundleName[:EntityName] [FieldName]
  • BundleName 是您的包名(例如,MyBundle)
  • EntityName(可选)是您的实体名(例如,MyEntity),如果没有定义,将为包中的所有实体生成表单类型
  • FieldName(可选)是下拉框中显示的字段名,如果没有定义,将尝试使用字段 'name'。

所以,如果我想为 StoreBundle 中的实体 Customer 生成一个快速表单类型,并在下拉框中显示客户的姓氏,我需要使用以下命令

$ app/console dotcommerce:generate:fastentity StoreBundle:Customer lastname

要使用新生成的表单类型,您必须在表单中手动指定它。您的新表单类型的名称是实体名的小写,前面加上单词 'fast',例如,对于上面生成的 Customer 实体,表单类型为 'fastcustomer'。

最近更新

2012-12-07

  • 第一个公开版本

安装

使用 composer 非常简单,添加

{
    require: {
        "dotcommerce/fastentitybundle": "dev-master"
    }
}

如果您使用 deps 文件,添加

[DotCommerceFastEntityBundle]
    git://github.com/TheDevilOnLine/Symfony-FastEntityBundle.git

或者,如果您想克隆仓库

git clone git://github.com/TheDevilOnLine/Symfony-FastEntityBundle.git vendor/dotcommerce/fastentitybundle/DotCommerce/FastEntityBundle

除非您使用 composer,否则请将命名空间添加到自动加载器中

<?php
// File: app/autoload.php
$loader->registerNamespaces(array(
    'DotCommerce\\FastEntityBundle'      => __DIR__.'/../vendor/dotcommerce/fastentitybundle/DotCommerce/FastEntityBundle',
    // ...
));

将 DotCommerceFastEntityBundle 添加到您的应用程序内核

<?php
    // File: app/AppKernel.php
    public function registerBundles()
    {
        return array(
            // ...
            new DotCommerce\FastEntityBundle\DotCommerceFastEntityBundle(),
            // ...
        );
    }