--- /dev/null
+<?php
+/**
+ * This class contains object attributes which we can now send together to
+ * other classes
+ */
+class SerializationContainer extends FrameworkArrayObject {
+ /**
+ * Public constructor, if you like to have an object of this class...
+ *
+ * @return void
+ */
+ public function __construct () {
+ // Call parent constructor
+ parent::constructor(__CLASS__);
+
+ // Debug message
+ if ((defined('DEBUG_CONTAINER')) && (defined('DEBUG_CONSTRUCT'))) $this->getDebugInstance()->output("[SerializationContainer:] Konstruktor erreicht.<br />\n");
+ }
+
+ /**
+ * Create a SerializationContainer object by applying the limitations
+ * in $limitInstance on $object. The resulting data container will only
+ * hold the attributed and their values which we have specified in
+ * the limitation object.
+ *
+ * @param $limitInstance The instance to the object ObjectLimits
+ * @param $object The origin object. We don't touch it here.
+ * @return $containerInstance An instance of SerializationContainer
+ * @throws GetterNotFoundException If a getter was not found
+ */
+ public final static function createSerializationContainer (ObjectLimits $limitInstance, $object) {
+ // Get an instance
+ $containerInstance = new SerializationContainer();
+
+ // Iterate through the whole limitation array
+ for ($idx = $limitInstance->getLimitArray()->getIterator(); $idx->valid(); $idx->next()) {
+ // Get current item from list
+ $curr = ucfirst($idx->current());
+
+ // Is the required method available?
+ if (method_exists($object, sprintf("get%s", $curr))) {
+ // Generate a command for getting it
+ $eval = sprintf("\$value = \$object->get%s();",
+ $curr
+ );
+
+ // Debug eval command
+ if ((defined('DEBUG_EVAL')) || (defined('DEBUG_ALL'))) $limitInstance->getDebugInstance()->output(sprintf("[%s:] Konstruierte PHP-Anweisung: <pre><em>%s</em></pre><br />\n",
+ $this->__toString(),
+ htmlentities($eval)
+ ));
+
+ // Run it
+ @eval($eval);
+
+ // Add this item to the container list
+ $containerInstance->append(array(
+ 'name' => $curr,
+ 'value' => $value
+ ));
+ } else {
+ // Throw an exception
+ throw new GetterNotFoundException(array($object, $curr), self::EXCEPTION_GETTER_IS_MISSING);
+ }
+ } // END - for
+
+ // Return container instance
+ return $containerInstance;
+ }
+}
+
+// [EOF]
+?>