public function remove(LocalImage $image)
{
$filesystem = new Filesystem();
if (file_exists($image->getPath())) {
$filesystem->remove($image->getPath());
}
if (file_exists($image->getThumbnailPath())) {
unlink($this->config['thumbnail_path'] . $image->getThumbnailPath(true));
}
$articleImages = $this->orm->getRepository('Newscoop\\Image\\ArticleImage')->getArticleImagesForImage($image)->getResult();
foreach ($articleImages as $articleImage) {
\ArticleImage::RemoveImageTagsFromArticleText($articleImage->getArticleNumber(), $articleImage->getNumber());
$this->orm->remove($articleImage);
}
$this->orm->remove($image);
$this->orm->flush();
$this->cacheService->clearNamespace('article_image');
$this->cacheService->clearNamespace('image');
return true;
}