From ae5a902740a59453ae58267cdf8fe8e9cd0bb924 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 12 Jan 2008 15:19:12 -0800 Subject: [PATCH] Start providing a fluent interface for the printer stuff. All printer elemnets now have a make() method that calls the constructor --- PrinterBaseElement.php | 12 ++++++++++++ PrinterElement.php | 5 +++++ PrinterLabelElement.php | 12 ++++++++++++ PrinterRootElementForm.php | 12 ++++++++++++ PrinterRootElementPage.php | 12 ++++++++++++ PrinterRootElementTable.php | 12 ++++++++++++ PrinterTableElement.php | 12 ++++++++++++ 7 files changed, 77 insertions(+) diff --git a/PrinterBaseElement.php b/PrinterBaseElement.php index 071329f..99e22fb 100644 --- a/PrinterBaseElement.php +++ b/PrinterBaseElement.php @@ -93,6 +93,18 @@ class BSPrinterBaseElement extends BSPrinterElement } } + /** + * Makes a new instance of the object in a static fashion + * + * @return object + */ + public static function make() + { + $obj = new ReflectionClass(__CLASS__); + $args = func_get_args(); + return $obj->newInstanceArgs($args); + } + // ################################################################### /** * If the type is either checkbox, radio, or option then this will diff --git a/PrinterElement.php b/PrinterElement.php index f1c503e..e28bbe9 100644 --- a/PrinterElement.php +++ b/PrinterElement.php @@ -50,6 +50,11 @@ abstract class BSPrinterElement */ protected $cssClass = ':swap:'; + /** + * Fluent object instantiation + */ + public abstract static function make(); + /** * Tells the element to paint itself (and any children) */ diff --git a/PrinterLabelElement.php b/PrinterLabelElement.php index 63866dc..05fe979 100644 --- a/PrinterLabelElement.php +++ b/PrinterLabelElement.php @@ -58,6 +58,18 @@ class BSPrinterLabelElement extends BSPrinterElement $this->setCssClass(null); } + /** + * Makes a new instance of the object in a static fashion + * + * @return object + */ + public static function make() + { + $obj = new ReflectionClass(__CLASS__); + $args = func_get_args(); + return $obj->newInstanceArgs($args); + } + // ################################################################### /** * Prints the string diff --git a/PrinterRootElementForm.php b/PrinterRootElementForm.php index 4ea6075..9bc2ce1 100644 --- a/PrinterRootElementForm.php +++ b/PrinterRootElementForm.php @@ -75,6 +75,18 @@ class BSPrinterRootElementForm extends BSPrinterRootElement $this->name = $name; } + /** + * Makes a new instance of the object in a static fashion + * + * @return object + */ + public static function make() + { + $obj = new ReflectionClass(__CLASS__); + $args = func_get_args(); + return $obj->newInstanceArgs($args); + } + // ################################################################### /** * Should this form be used for upload? diff --git a/PrinterRootElementPage.php b/PrinterRootElementPage.php index b002a22..85c7b15 100644 --- a/PrinterRootElementPage.php +++ b/PrinterRootElementPage.php @@ -57,6 +57,18 @@ class BSPrinterRootElementPage extends BSPrinterRootElement $this->title = $title; } + /** + * Makes a new instance of the object in a static fashion + * + * @return object + */ + public static function make() + { + $obj = new ReflectionClass(__CLASS__); + $args = func_get_args(); + return $obj->newInstanceArgs($args); + } + // ################################################################### /** * Creates a redirect to another page; constructs the header and footer diff --git a/PrinterRootElementTable.php b/PrinterRootElementTable.php index f6e87be..47bdade 100644 --- a/PrinterRootElementTable.php +++ b/PrinterRootElementTable.php @@ -67,6 +67,18 @@ class BSPrinterRootElementTable extends BSPrinterRootElement $this->setCssClass('tborder'); } + /** + * Makes a new instance of the object in a static fashion + * + * @return object + */ + public static function make() + { + $obj = new ReflectionClass(__CLASS__); + $args = func_get_args(); + return $obj->newInstanceArgs($args); + } + // ################################################################### /** * Adds a table row into the child list diff --git a/PrinterTableElement.php b/PrinterTableElement.php index f1305be..ee65946 100644 --- a/PrinterTableElement.php +++ b/PrinterTableElement.php @@ -68,6 +68,18 @@ class BSPrinterTableElement extends BSPrinterElement } } + /** + * Makes a new instance of the object in a static fashion + * + * @return object + */ + public static function make() + { + $obj = new ReflectionClass(__CLASS__); + $args = func_get_args(); + return $obj->newInstanceArgs($args); + } + // ################################################################### /** * Prints a simple row of text and text -- 2.22.5