Skip to content
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

PersistentCollection::clear does not clear the collection #8

Closed
jtousek opened this issue Oct 17, 2010 · 1 comment
Closed

PersistentCollection::clear does not clear the collection #8

jtousek opened this issue Oct 17, 2010 · 1 comment

Comments

@jtousek
Copy link

jtousek commented Oct 17, 2010

use Doctrine\Common\Collections\ArrayCollection;

/**
 * @Entity(repositoryClass = "AdminRepository")
 * @Table(name = "user")
 */
class UserEntity extends StateEntity
{

    //...

    /**
     * @ManyToMany(targetEntity = "RoleEntity")
     * @JoinTable(name = "user_role",
     *      joinColumns = {@JoinColumn(name = "user")},
     *      inverseJoinColumns = {@JoinColumn(name = "role")}
     *      )
     * @var Doctrine\Common\Collections\ArrayCollection
     */
    private $roles;

    public function __construct() {
        //...
        $this->roles = new ArrayCollection;
    }

    public function clearRoles() {
        $this->roles->clear();
        if ($this->roles->count() > 0) {
            //THE CONDITION ABOVE SHOULD NEVER BE TRUE, BUT IT IS!!
            //don't know if it's important, but the association between users and roles IS bidirectional
            echo 'ERROR!!';
        }
        return $this;
    }

    //...

}
@beberlei
Copy link
Member

Please report this issue on www.doctrine-project.org/jira - i will close this issue tracker here because we dont use it.

aldisanta pushed a commit to aldisanta/doctrine2 that referenced this issue Oct 31, 2016
Kern046 pushed a commit to Kern046/doctrine-orm that referenced this issue Apr 15, 2022
Improve the XML Mapping Driver tests for XSD validation
This issue was closed.
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

No branches or pull requests

2 participants