Skip to content

Override EmailRepository #6

@sonjadeissenboeck

Description

@sonjadeissenboeck

I'd like to override the Email Repository to customize one function for my needs. Has anyone ever done this? I couldn't find any documentation on overriding an entity repository. Why I need to do: the DatabaseSpool Service calls the markCompleteSending() function from the repository. But I'd like to change one part of it.
What I tried: create an own Entity repository class:

namespace NotificationBundle\Entity;  
use Doctrine\ORM\EntityRepository; 
use Citrax\Bundle\DatabaseSwiftMailerBundle\Entity\Email; 
use Citrax\Bundle\DatabaseSwiftMailerBundle\Entity\EmailRepository as BaseRepository;  class EmailRepository extends BaseRepository {      
public function markCompleteSending(Email $email)     {         
$email->setStatus(Email::STATUS_COMPLETE);        
$email->setSentAt(new \DateTime());         
$email->setErrorMessage('');         
$em = $this->getEntityManager();         
$em->remove($email);         
$em->flush();     
} }

it extends the parent repository and overrides only this function, the rest I didn't touch. I then registered that repository as a service. Anyway it's not working!
Anything else needed? Please let me know! I'd be glad about some help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions