The Clean Architecture in php



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

class
CustomerFactory
{
protected
$managerRepository
;
public function
__construct
(AccountManagerRepositoryInterface
$repo
) {
$this
->
managerRepository
=
$repo
;
}
// ...
}
The
CustomerFactory
is deeper in the onion than that persistence layer, so it can’t be dependent
upon a concrete
CustomerRepository
, nor would we want it to be. Instead, it declares, via the
constructor, that it needs something that implements
AccountManagerRepositoryInterface
. It
doesn’t care what you give it, so long as the what is passed in adheres to the interface. We call
this programming by contract.
So how exactly does a
CustomerRepository
get into the
CustomerFactory
? Whatever means is
responsible for instantiating this Factory would take care of passing in the correct implementa-
tion:
$customerFactory
=
new
CustomerFactory(
new
CustomerRepository(
$entityManager
)
);
How this works is largely dependent upon your framework and how it handles Dependency
Injection Containers or Service Locators. We’ll discuss this more when we talk about the
framework, and explore how it works in our Case Study. The important thing to note here is
that our code should only be dependent upon interfaces, not concrete implementations of the
Persistence layer.

Download 2,26 Mb.

Do'stlaringiz bilan baham:
1   ...   124   125   126   127   128   129   130   131   ...   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