2017 © Pedro Peláez
 

library entity-attacher

Utility to Attach Doctrine Entities to existing instances

image

geosocio/entity-attacher

Utility to Attach Doctrine Entities to existing instances

  • Sunday, February 18, 2018
  • by davidbarratt
  • Repository
  • 1 Watchers
  • 2 Stars
  • 207 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 28 % Grown

The README.md

Entity Attacher Build Status Coverage Status

Provides a method to attach related entities to the current unattached entity.This library is the product of a missing API that was found in doctrine/doctrine2#6459. If you want to create a new entity with a lot of existing related entities, you would have to manually go through each relation and attach the related entities., (*1)

This can be tedious for entities that have a large number of relationships., (*2)

Configuration

Add something like this to your service configuration:, (*3)

app.entity_attacher:
        class: GeoSocio\EntityAttacher\EntityAttacher
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@annotations.reader'

You may also need to add the GeoSocio\EntityAttacher\Annotation\Attach annotation to your annotation reader., (*4)

Usage

Add the @Attach annotation to the relationships that should be attached., (*5)

/**
 * @ORM\Entity()
 * @ORM\Table(name="post")
 */
class Post
{

    /**
     * @ORM\ManyToOne(targetEntity="GeoSocio\Core\Entity\User\User")
     * @ORM\JoinColumn(name="user_id", referencedColumnName="user_id")
     * @Attach()
     */
    private $user;
}

Then when a new Post is created, you can attach the entity:, (*6)

$post = $this->attacher->attach($post);

Doing this will retrieve the $user from the database and prevent the A new entity was found through the relationship error. If you still receive that error, it means the $user was not found (and thus, should be persisted)., (*7)

The Versions

18/02 2018

dev-develop

dev-develop

Utility to Attach Doctrine Entities to existing instances

  Sources   Download

LGPL-3 LGPL-3.0-only

The Requires

 

The Development Requires

18/02 2018

1.0.6

1.0.6.0

Utility to Attach Doctrine Entities to existing instances

  Sources   Download

LGPL-3.0-only

The Requires

 

The Development Requires

08/07 2017

1.0.5

1.0.5.0

Utility to Attach Doctrine Entities to existing instances

  Sources   Download

LGPL-3

The Requires

 

The Development Requires

01/07 2017

1.0.4

1.0.4.0

Utility to Attach Doctrine Entities to existing instances

  Sources   Download

LGPL-3

The Requires

 

The Development Requires

27/06 2017

1.0.3

1.0.3.0

Utility to Attach Doctrine Entities to existing instances

  Sources   Download

LGPL-3

The Requires

 

The Development Requires

25/06 2017

1.0.2

1.0.2.0

Utility to Attach Doctrine Entities to existing instances

  Sources   Download

LGPL-3

The Requires

 

The Development Requires

23/06 2017

1.0.1

1.0.1.0

Utility to Attach Doctrine Entities to existing instances

  Sources   Download

LGPL-3

The Requires

 

The Development Requires

23/06 2017

1.0.0

1.0.0.0

Utility to Attach Doctrine Entities to existing instances

  Sources   Download

LGPL-3

The Requires

 

The Development Requires