Skip to content

Refactored docs to use adders/removers #2434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2013
Merged

Conversation

wouterj
Copy link
Member

@wouterj wouterj commented Mar 30, 2013

Q A
Doc fix? yes
New docs? yes
Applies to 2.1+
Fixed tickets #1057

This is the first draw to fix this document for 2.1. I have not tested the code yet, that's why I called it a WIP.

@wouterj
Copy link
Member Author

wouterj commented Mar 31, 2013

The code is tested on 2.1 and it works.

I have one question though. There is a note that says:

First, unless you iterate over all of the new Tag objects and
call $em->persist($tag) on each, you'll receive an error from
Doctrine:

A new entity was found through the relationship
Acme\TaskBundle\Entity\Task#tags that was not configured to
cascade persist operations for entity...

I tested it with Doctrine 2.3.1 and I got no error.

@stof
Copy link
Member

stof commented Apr 6, 2013

@wouterj Are you adding new elements in the collection or only editing exsting ones ?

@stof
Copy link
Member

stof commented Apr 6, 2013

And are you cascading the persist on the relation ? If yes, it is indeed useless to persist explicitly each tag

{
// ...

public function addTag($tag)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to define both addTag and removeTag. If one of them is missing, the setter for the collection will be used when using by_reference => false, not the adder and remover for each element

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@weaverryan
Copy link
Member

Ping @wouterj! I'm waiting for answers on Stof's questions before moving on :)

@wouterj
Copy link
Member Author

wouterj commented Apr 27, 2013

Sorry for my delay on this. I need to finish some PRs now! :)

@stof was correct, the entity I used was cascading the persist action. (I just used your entity, so I wasn't aware of that)

@wouterj
Copy link
Member Author

wouterj commented Apr 27, 2013

@weaverryan I've updated the article, I think it's ready now

weaverryan added a commit that referenced this pull request May 3, 2013
Refactored docs to use adders/removers
@weaverryan weaverryan merged commit e9b063c into symfony:2.1 May 3, 2013
weaverryan added a commit that referenced this pull request May 3, 2013
@weaverryan
Copy link
Member

Nice work @wouter - I moved the new text further down in the article, but I have very few changes otherwise.

Tweaks at sha: ec49d58

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants