Last active
February 8, 2019 12:12
-
-
Save mikemix/c0092208216e4f07dd0f0c6e4978fbe7 to your computer and use it in GitHub Desktop.
Focused repositories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace Base\Organizers\Infrastructure\Domain\Repository; | |
use Base\Organizers\Domain\Model\Company; | |
use Base\Organizers\Domain\Repository\CompanyCollection; | |
use Doctrine\Common\Persistence\ObjectManager; | |
final class DoctrineCompanyCollection implements CompanyCollection | |
{ | |
private $objectManager; | |
public function __construct(ObjectManager $objectManager) | |
{ | |
$this->objectManager = $objectManager; | |
} | |
public function add(Company $company): void | |
{ | |
$this->objectManager->persist($company); | |
$this->objectManager->flush(); | |
} | |
public function remove(Company $company): void | |
{ | |
$this->objectManager->remove($company); | |
$this->objectManager->flush(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace Base\Organizers\Infrastructure\Domain\Repository; | |
use Base\Organizers\Domain\Model\Field; | |
use Base\Organizers\Domain\Repository\FieldsByCompany; | |
use Base\SharedKernel\Identification\CompanyId; | |
use Doctrine\Common\Persistence\ObjectManager; | |
final class DoctrineFieldsByCompany implements FieldsByCompany | |
{ | |
private $objectManager; | |
public function __construct(ObjectManager $objectManager) | |
{ | |
$this->objectManager = $objectManager; | |
} | |
public function getFieldsByCompany(CompanyId $companyId): array | |
{ | |
return $this->objectManager->getRepository(Field::class)->findBy(['company' => $companyId], ['position' => 'asc']); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment