i have a problem with doctrine.
I have a filemanager with folders and files.
Now i want to save groups to an directory or an single file.
For a single item it works.
But if i want to save the group rights recursive it wont work.
Doctrine doesn’t throw an error or an exception. But it saves no changes to the subdirs and files in the subdirs.
This is my Model:
Both Models Model_File_Item and Model_File_Dir extend this Model.
Everything works finde until the method “setGroupsRecursive()” want to save the group to the dir or file.
I’ve writed logs in the file.. everything is fine and every item will be saved but the changes don’t be saved in the database and i dont know why.
EDIT: the group definition looks like this:
Model_File_Dir & Model_File_Item:
/**
* Owning Side
*
* @ManyToMany(targetEntity="Model_Group", inversedBy="dirs")
* @JoinTable(name="dir_groups",
* joinColumns={@JoinColumn(name="dir_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id")}
* )
*/
protected $groups;
and the Model_Group looks like this:
/**
* @ManyToMany(targetEntity="Model_File_Dir", mappedBy="groups")
*/
protected $dirs;
/**
* @ManyToMany(targetEntity="Model_File_Item", mappedBy="groups")
*/
protected $files;
I think you need cascade operations for this. Think wisely using bi-directional relationships (especially using cascade operations) as described here and here. Hope this helps!