Files
DesignPatternsPHP/Structural/Composite
Matt Campbell 4f7d797567 Composite Test: Add information about nested forms
Add information for composite pattern test to hopefully
help to not mislead anyone viewing this test, into thinking
that they can nest HTML form elements.

Closes #264
2017-02-17 20:16:41 +00:00
..
2016-09-23 15:41:28 +02:00
2016-09-22 20:44:28 +02:00
2016-09-22 20:44:28 +02:00
2016-09-22 20:44:28 +02:00
2016-09-22 20:44:28 +02:00
2016-09-22 20:44:28 +02:00

`Composite`__
=============

Purpose
-------

To treat a group of objects the same way as a single instance of the
object.

Examples
--------

-  a form class instance handles all its form elements like a single
   instance of the form, when ``render()`` is called, it subsequently
   runs through all its child elements and calls ``render()`` on them
-  ``Zend_Config``: a tree of configuration options, each one is a
   ``Zend_Config`` object itself

UML Diagram
-----------

.. image:: uml/uml.png
   :alt: Alt Composite UML Diagram
   :align: center

Code
----

You can also find these code on `GitHub`_

RenderableInterface.php

.. literalinclude:: RenderableInterface.php
   :language: php
   :linenos:

Form.php

.. literalinclude:: Form.php
   :language: php
   :linenos:

InputElement.php

.. literalinclude:: InputElement.php
   :language: php
   :linenos:

TextElement.php

.. literalinclude:: TextElement.php
   :language: php
   :linenos:

Test
----

Tests/CompositeTest.php

.. literalinclude:: Tests/CompositeTest.php
   :language: php
   :linenos:

.. _`GitHub`: https://github.com/domnikl/DesignPatternsPHP/tree/master/Structural/Composite
.. __: http://en.wikipedia.org/wiki/Composite_pattern