netvlies/doctrinebridgebundle

此包的最新版本(dev-master)没有可用的许可证信息。

dev-master 2013-07-19 11:54 UTC

This package is not auto-updated.

Last update: 2024-09-14 12:36:29 UTC


README

此包提供不同Doctrine管理者之间的桥梁功能。桥梁功能使得可以使用注解在实体和文档(反之亦然)之间建立关联关系。以下是一个文档示例

use Netvlies\Bundle\DoctrineBridgeBundle\Mapping\Annotations as BRIDGE;

/**
 *
 * @PHPCRODM\Document(referenceable=true)
 */
class MyPage
{
     * @PHPCRODM\String
     * @BRIDGE\Entity(targetEntity="MyBundle:Media", entityManager="default")
     */
    protected $media;

反之亦然

use Netvlies\Bundle\DoctrineBridgeBundle\Mapping\Annotations as BRIDGE;

/**
 * @ORM\Table()
 * @ORM\Entity
 */
class OrderLine
{
     * @ORM\Column(name="product", type="string", length=255)
     * @BRIDGE\Document(targetDocument="MyBundle:Product", documentManager="default")
     */
    private $product;

使用此注解,在检索时将加载引用对象,并在请求时从存储引擎中解析。同时,在分配并保存时,它将存储另一侧的UID,以便在再次检索时可以解析。

待办事项

  • 尚未进行测试。目前此包很简单,但在进一步开发中应添加并检查Travis测试。
  • 目前它只支持x-to-one关系。因此,必须稍后添加以至少支持one-to-many关系。
  • 目前它仅支持ORM和PHPCR。因此,可能在将来添加对mongoDB和其他存储引擎的支持。

安装

您可以使用composer或将其包含在deps文件中。对于composer

"netvlies/doctrinebridgebundle": "dev-master",

deps文件

[doctrineBridgeBundle]
git=http://github.com/netvlies/DoctrineBridgeBundle.git

之后,您需要将以下行添加到您的autoload.php文件中,并根据需要更改路径

AnnotationRegistry::registerFile(__DIR__.'/../vendor/netvlies/doctrinebridge/Netvlies/Bundle/DoctrineBridgeBundle/Mapping/Annotations/DoctrineAnnotations.php');

并且不要忘记将其包含到您的AppKernel.php中

new Netvlies\Bundle\DoctrineBridgeBundle\NetvliesDoctrineBridgeBundle(),