deblan/fos-rest-behavior

该包的最新版本(v1.0)没有提供许可证信息。

安装: 219

依赖: 0

建议者: 0

安全: 0

类型:propel-behavior

v1.0 2016-09-23 09:48 UTC

This package is auto-updated.

Last update: 2024-08-29 04:19:53 UTC


README

这是一个用于自动生成FOSRestBundle方法的propel行为。

安装

composer require deblan/fos-rest-behavior

如何使用

<table name="foo">
    <column name="id" type="INTEGER" primaryKey="true" autoIncrement="true" required="true" />
    <column name="label" type="VARCHAR" size="256"/>
    <column name="is_active" type="BOOLEAN" size="1"/>

    <behavior name="Deblan\Propel\Behavior\FOSRestBehavior">
        <parameter name="id" value="all"/>
        <parameter name="label" value="myGroup"/>
        <parameter name="is_active" value="myGroup, anotherGroup"/>
    </behavior>
</table>

模型生成后,抽象类Foo将被更新为新注解和方法

/**
 * [...]
 *
 * @JMS\Serializer\Annotation\ExclusionPolicy("all")
 */
abstract class Foo implements ActiveRecordInterface
{
    ...

    /**
     * @JMS\Serializer\Annotation\SerializedName("id")
     * @JMS\Serializer\Annotation\Groups({"all"})
     * @JMS\Serializer\Annotation\VirtualProperty
    */
    public function getRestId()
    {
        return $this->getId();
    }
    
    /**
     * @JMS\Serializer\Annotation\SerializedName("label")
     * @JMS\Serializer\Annotation\Groups({"myGroup"})
     * @JMS\Serializer\Annotation\VirtualProperty
    */
    public function getRestLabel()
    {
        return $this->getLabel();
    }

    /**
     * @JMS\Serializer\Annotation\SerializedName("is_active")
     * @JMS\Serializer\Annotation\Groups({"myGroup", "anotherGroup"})
     * @JMS\Serializer\Annotation\VirtualProperty
    */
    public function getRestIsActive()
    {
        return $this->getIsActive();
    }

    ...
}