mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-10 17:04:01 +02:00
execute read-the-docs.sh
This commit is contained in:
54
Behavioral/Mediator/index.rst
Normal file
54
Behavioral/Mediator/index.rst
Normal file
@@ -0,0 +1,54 @@
|
||||
Mediator
|
||||
========
|
||||
|
||||
Purpose
|
||||
-------
|
||||
|
||||
This pattern provides an easy to decouple many components working
|
||||
together. It is a good alternative over Observer IF you have a "central
|
||||
intelligence", like a controller (but not in the sense of the MVC).
|
||||
|
||||
All components (called Colleague) are only coupled to the
|
||||
MediatorInterface and it is a good thing because in OOP, one good friend
|
||||
is better than many. This is the key-feature of this pattern.
|
||||
|
||||
UML Diagram
|
||||
-----------
|
||||
|
||||
.. image:: uml/uml.png
|
||||
:alt: Alt Mediator UML Diagram
|
||||
:align: center
|
||||
|
||||
Code
|
||||
----
|
||||
|
||||
You can also find these code on `GitHub`_
|
||||
|
||||
MediatorInterface.php
|
||||
|
||||
.. literalinclude:: MediatorInterface.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
Mediator.php
|
||||
|
||||
.. literalinclude:: Mediator.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
Colleague.php
|
||||
|
||||
.. literalinclude:: Colleague.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
Test
|
||||
----
|
||||
|
||||
Tests/MediatorTest.php
|
||||
|
||||
.. literalinclude:: Tests/MediatorTest.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
.. _`GitHub`: https://github.com/domnikl/DesignPatternsPHP/tree/master/Behavioral/Mediator
|
Reference in New Issue
Block a user