em = $em; $this->attachment_helper = $attachmentHelper; } /** * Find all attachments that use the given file * @param File $file * @return Attachment[] */ public function findAttachmentsByFile(\SplFileInfo $file) : array { //Path with %MEDIA% $relative_path_new = $this->attachment_helper->realPathToPlaceholder($file->getPathname()); //Path with %BASE% $relative_path_old = $this->attachment_helper->realPathToPlaceholder($file->getPathname(), true); $repo = $this->em->getRepository(Attachment::class); return $repo->findBy(['path' => [$relative_path_new, $relative_path_old]]); } }