Open Station95 opened 3 years ago
I figured out that the above code should probably be something like:
// Delete the photo items in that album
$photoitems = $this->getManyManyComponents("PhotoItems");
foreach ($photoitems as $photoitem) {
$photoitemfile = Image::get()->byID($photoitem->ID);
if ($photoitemfile) {
$photoitemfile->delete();
}
}
Good catch, thank you! Any chance you could do a pull request for that?
Thanks @andrewhoule I have created a pull request
When trying to unpublish a photo gallery that has an Album I am getting the following error:
[Emergency] Uncaught InvalidArgumentException: DataObject::getComponents(): Unknown 1-to-many component 'PhotoItems' on class 'AndrewHoule\PhotoGallery\Models\PhotoAlbum' Trace SilverStripe\ORM\DataObject->getComponents(PhotoItems) PhotoAlbum.php:205 AndrewHoule\PhotoGallery\Models\PhotoAlbum->OnBeforeDelete() DataObject.php:1686
Specifically, it appears that the code that deletes the photo items in the album is not working: