The Clean Architecture in php



Download 2,26 Mb.
Pdf ko'rish
bet126/179
Sana24.06.2021
Hajmi2,26 Mb.
#100337
1   ...   122   123   124   125   126   127   128   129   ...   179
Bog'liq
The-Clean-Architecture-in-PHP-Kristopher-Wilson

abstract class
AbstractRepository
{
protected
$entityManager
;
protected
$entityClass
=
''
;
public function
__construct
(EntityManager
$entityManager
) {
$this
->
entityManager
=
$entityManager
;
if
(
empty
(
$this
->
entityClass
)) {
throw new
\RuntimeException(
'entityClass not specified for '
.
__CLASS__
);
}
}


Database Independence
91
public function
getAll
()
{
return
$this
->
entityManager
->
getRepository
(
$this
->
entityClass
)
->
getAll
();
}
public function
getById
(
$id
)
{
return
$this
->
entityManager
->
find
(
$this
->
entityClass
,
$id
);
}
}
Our
CustomerRepository
then simply becomes:
class
CustomerRepository
extends
AbstractRepository
implements
CustomerRepositoryInterface {
protected
$entityClass
=
'MyVendor\Domain\Entity\Customer'
;
}
Now we only need to add customer-specific logic to this repository, as needed.
Utilizing Persistence
The Persistence layer is meant to sit on one of the outer layers of the onion. It is not central to the
application. Again, our Domain Model and Domain Services are. The Persistence layer simply
provides meaning to that Domain Services layer by implementing the repository interfaces that
we setup. Nothing should be dependent upon this Persistence layer. In fact, we should be able to
swap out Persistence layers with other implementations, and all of the code that ends up using
this layer (through using the interfaces) should be none the wiser, and continue to function
properly.
We’ll experiment with this concept once we start working on our Case Study.

Download 2,26 Mb.

Do'stlaringiz bilan baham:
1   ...   122   123   124   125   126   127   128   129   ...   179




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish