mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-30 19:50:12 +02:00
execute read-the-docs.sh
This commit is contained in:
53
More/Delegation/index.rst
Normal file
53
More/Delegation/index.rst
Normal file
@@ -0,0 +1,53 @@
|
||||
Delegation
|
||||
==========
|
||||
|
||||
Purpose
|
||||
-------
|
||||
|
||||
...
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
...
|
||||
|
||||
UML Diagram
|
||||
-----------
|
||||
|
||||
.. image:: uml/uml.png
|
||||
:alt: Alt Delegation UML Diagram
|
||||
:align: center
|
||||
|
||||
Code
|
||||
----
|
||||
|
||||
You can also find these code on `GitHub`_
|
||||
|
||||
Usage.php
|
||||
|
||||
.. literalinclude:: Usage.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
TeamLead.php
|
||||
|
||||
.. literalinclude:: TeamLead.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
JuniorDeveloper.php
|
||||
|
||||
.. literalinclude:: JuniorDeveloper.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
Test
|
||||
----
|
||||
|
||||
Tests/DelegationTest.php
|
||||
|
||||
.. literalinclude:: Tests/DelegationTest.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
.. _`GitHub`: https://github.com/domnikl/DesignPatternsPHP/tree/master/More/Delegation
|
61
More/Repository/index.rst
Normal file
61
More/Repository/index.rst
Normal file
@@ -0,0 +1,61 @@
|
||||
Repository
|
||||
==========
|
||||
|
||||
Purpose
|
||||
-------
|
||||
|
||||
Mediates between the domain and data mapping layers using a
|
||||
collection-like interface for accessing domain objects. Repository
|
||||
encapsulates the set of objects persisted in a data store and the
|
||||
operations performed over them, providing a more object-oriented view of
|
||||
the persistence layer. Repository also supports the objective of
|
||||
achieving a clean separation and one-way dependency between the domain
|
||||
and data mapping layers.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
- Doctrine 2 ORM: there is Repository that mediates between Entity and
|
||||
DBAL and contains methods to retrieve objects
|
||||
- Laravel Framework
|
||||
|
||||
UML Diagram
|
||||
-----------
|
||||
|
||||
.. image:: uml/uml.png
|
||||
:alt: Alt Repository UML Diagram
|
||||
:align: center
|
||||
|
||||
Code
|
||||
----
|
||||
|
||||
You can also find these code on `GitHub`_
|
||||
|
||||
PostRepository.php
|
||||
|
||||
.. literalinclude:: PostRepository.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
Post.php
|
||||
|
||||
.. literalinclude:: Post.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
MemoryStorage.php
|
||||
|
||||
.. literalinclude:: MemoryStorage.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
Storage.php
|
||||
|
||||
.. literalinclude:: Storage.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
Test
|
||||
----
|
||||
|
||||
.. _`GitHub`: https://github.com/domnikl/DesignPatternsPHP/tree/master/More/Repository
|
83
More/ServiceLocator/index.rst
Normal file
83
More/ServiceLocator/index.rst
Normal file
@@ -0,0 +1,83 @@
|
||||
Service Locator
|
||||
===============
|
||||
|
||||
Purpose
|
||||
-------
|
||||
|
||||
To implement a loosely coupled architecture in order to get better
|
||||
testable, maintainable and extendable code. DI pattern and Service
|
||||
Locator pattern are an implementation of the Inverse of Control pattern.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
With ``ServiceLocator`` you can register a service for a given
|
||||
interface. By using the interface you can retrieve the service and use
|
||||
it in the classes of the application without knowing its implementation.
|
||||
You can configure and inject the Service Locator object on bootstrap.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
- Zend Framework 2 uses Service Locator to create and share services
|
||||
used in the framework(i.e. EventManager, ModuleManager, all custom
|
||||
user services provided by modules, etc...)
|
||||
|
||||
UML Diagram
|
||||
-----------
|
||||
|
||||
.. image:: uml/uml.png
|
||||
:alt: Alt ServiceLocator UML Diagram
|
||||
:align: center
|
||||
|
||||
Code
|
||||
----
|
||||
|
||||
You can also find these code on `GitHub`_
|
||||
|
||||
LogService.php
|
||||
|
||||
.. literalinclude:: LogService.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
LogServiceInterface.php
|
||||
|
||||
.. literalinclude:: LogServiceInterface.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
DatabaseServiceInterface.php
|
||||
|
||||
.. literalinclude:: DatabaseServiceInterface.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
ServiceLocatorInterface.php
|
||||
|
||||
.. literalinclude:: ServiceLocatorInterface.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
ServiceLocator.php
|
||||
|
||||
.. literalinclude:: ServiceLocator.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
DatabaseService.php
|
||||
|
||||
.. literalinclude:: DatabaseService.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
Test
|
||||
----
|
||||
|
||||
Tests/ServiceLocatorTest.php
|
||||
|
||||
.. literalinclude:: Tests/ServiceLocatorTest.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
.. _`GitHub`: https://github.com/domnikl/DesignPatternsPHP/tree/master/More/ServiceLocator
|
18
More/index.rst
Normal file
18
More/index.rst
Normal file
@@ -0,0 +1,18 @@
|
||||
More
|
||||
====
|
||||
|
||||
- `Delegation <Delegation>`__
|
||||
`:notebook: <http://en.wikipedia.org/wiki/Delegation_pattern>`__
|
||||
- `ServiceLocator <ServiceLocator>`__
|
||||
`:notebook: <http://en.wikipedia.org/wiki/Service_locator_pattern>`__
|
||||
- `Repository <Repository>`__
|
||||
|
||||
Code
|
||||
----
|
||||
|
||||
You can also find these code on `GitHub`_
|
||||
|
||||
Test
|
||||
----
|
||||
|
||||
.. _`GitHub`: https://github.com/domnikl/DesignPatternsPHP/tree/master/More
|
Reference in New Issue
Block a user