Skip to content
This repository was archived by the owner on Mar 29, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/MPWAR/Module/Economy/Domain/AccountRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@ public function add(Account $account);
* @return Account|null
*/
public function search(AccountOwner $owner);

/**
* @param Account $account
*
* @return void
*/
public function save(Account $account);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,21 @@ public function __construct()

public function add(Account $account)
{
$this->accounts->set($account->owner()->value(), $account);
$this->persist($account);
}

public function search(AccountOwner $owner)
{
return $this->accounts->get($owner->value());
}

public function save(Account $account)
{
$this->persist($account);
}

private function persist(Account $account)
{
$this->accounts->set($account->owner()->value(), $account);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,25 @@ public function __construct(EntityManager $entityManager)

public function add(Account $account)
{
$this->entityManager->persist($account);
$this->entityManager->flush($account);
$this->persist($account);
}

public function search(AccountOwner $owner)
{
return $this->repository()->find($owner);
}

public function save(Account $account)
{
$this->persist($account);
}

protected function persist(Account $account)
{
$this->entityManager->persist($account);
$this->entityManager->flush($account);
}

private function repository()
{
return $this->entityManager->getRepository(Account::class);
Expand Down