2015-05-29 12:11:16 +02:00
|
|
|
`Proxy`__
|
|
|
|
=========
|
2015-04-02 00:03:33 +02:00
|
|
|
|
|
|
|
Purpose
|
|
|
|
-------
|
|
|
|
|
|
|
|
To interface to anything that is expensive or impossible to duplicate.
|
|
|
|
|
|
|
|
Examples
|
|
|
|
--------
|
|
|
|
|
|
|
|
- Doctrine2 uses proxies to implement framework magic (e.g. lazy
|
|
|
|
initialization) in them, while the user still works with his own
|
|
|
|
entity classes and will never use nor touch the proxies
|
|
|
|
|
|
|
|
UML Diagram
|
|
|
|
-----------
|
|
|
|
|
|
|
|
.. image:: uml/uml.png
|
|
|
|
:alt: Alt Proxy UML Diagram
|
|
|
|
:align: center
|
|
|
|
|
|
|
|
Code
|
|
|
|
----
|
|
|
|
|
|
|
|
You can also find these code on `GitHub`_
|
|
|
|
|
2015-04-08 22:42:16 +02:00
|
|
|
Record.php
|
2015-04-02 00:03:33 +02:00
|
|
|
|
2015-04-08 22:42:16 +02:00
|
|
|
.. literalinclude:: Record.php
|
2015-04-02 00:03:33 +02:00
|
|
|
:language: php
|
|
|
|
:linenos:
|
|
|
|
|
2015-04-08 22:42:16 +02:00
|
|
|
RecordProxy.php
|
2015-04-02 00:03:33 +02:00
|
|
|
|
2015-04-08 22:42:16 +02:00
|
|
|
.. literalinclude:: RecordProxy.php
|
2015-04-02 00:03:33 +02:00
|
|
|
:language: php
|
|
|
|
:linenos:
|
|
|
|
|
|
|
|
Test
|
|
|
|
----
|
|
|
|
|
|
|
|
.. _`GitHub`: https://github.com/domnikl/DesignPatternsPHP/tree/master/Structural/Proxy
|
2015-05-29 12:11:16 +02:00
|
|
|
.. __: http://en.wikipedia.org/wiki/Proxy_pattern
|