3 * This class contains object attributes which we can now send together to
6 class SerializationContainer extends FrameworkArrayObject {
8 * Public constructor, if you like to have an object of this class...
12 public function __construct () {
13 // Call parent constructor
14 parent::constructor(__CLASS__);
17 if ((defined('DEBUG_CONTAINER')) && (defined('DEBUG_CONSTRUCT'))) $this->getDebugInstance()->output("[SerializationContainer:] Konstruktor erreicht.<br />\n");
21 * Create a SerializationContainer object by applying the limitations
22 * in $limitInstance on $object. The resulting data container will only
23 * hold the attributed and their values which we have specified in
24 * the limitation object.
26 * @param $limitInstance The instance to the object ObjectLimits
27 * @param $object The origin object. We don't touch it here.
28 * @return $containerInstance An instance of SerializationContainer
29 * @throws GetterNotFoundException If a getter was not found
31 public final static function createSerializationContainer (ObjectLimits $limitInstance, $object) {
33 $containerInstance = new SerializationContainer();
35 // Iterate through the whole limitation array
36 for ($idx = $limitInstance->getLimitArray()->getIterator(); $idx->valid(); $idx->next()) {
37 // Get current item from list
38 $curr = ucfirst($idx->current());
40 // Is the required method available?
41 if (method_exists($object, sprintf("get%s", $curr))) {
42 // Generate a command for getting it
43 $eval = sprintf("\$value = \$object->get%s();",
48 if ((defined('DEBUG_EVAL')) || (defined('DEBUG_ALL'))) $limitInstance->getDebugInstance()->output(sprintf("[%s:] Konstruierte PHP-Anweisung: <pre><em>%s</em></pre><br />\n",
56 // Add this item to the container list
57 $containerInstance->append(array(
63 throw new GetterNotFoundException(array($object, $curr), self::EXCEPTION_GETTER_IS_MISSING);
67 // Return container instance
68 return $containerInstance;