3 * This object limits other objects. This is mostly being used to prepare
4 * objects to the datatabase connection or else a lot heap would be saved.
6 class ObjectLimits extends BaseFrameworkSystem {
8 * Limitation array for storing all attribute names we will use later
11 private $limitArray = null;
18 private final function __construct () {
19 // Call parent constructor
20 parent::constructor(__CLASS__);
22 // Set part description
23 $this->setPartDescr("Limitierungsobjekt");
25 // Create unique ID number
26 $this->createUniqueID();
29 $this->removeNumberFormaters();
33 * Create a new ObjectLimits object and (maybe prepare it a little)
35 * @param $limitationArray The limitation array we "walk" through
36 * @return $limitInstance The instance to an ObjectLimits object
38 public final static function createObjectLimits (array $limitationArray) {
39 // Is there a limitation array given?
40 if (count($limitationArray) > 0) {
42 $limitInstance = new ObjectLimits();
44 // Get all limitations and do them
45 foreach ($limitationArray as $limit) {
46 // What shall we limitate?
47 if ($limit instanceof FrameworkInterface) {
49 $limitInstance->addObject($limit);
50 } elseif (is_string($limit)) {
52 $limitInstance->addString($limit);
54 // Others are not supported (yet)
55 throw new UnsupportedLimitationPartException($limit, self::EXCEPTION_LIMIT_ELEMENT_IS_UNSUPPORTED);
60 return $limitInstance;
62 // No limitation given so we send "null" back
68 * Add an object's name to the limitation list
70 * @param $object The object's name we shall add to the list
73 private final function addObject (FrameworkInterface $object) {
74 // Auto-initialization
75 if (is_null($this->limitArray)) {
76 // Initialize this array
77 $this->limitArray = new FrameworkArrayObject();
80 // Add the object's name to it
81 $this->limitArray->append($object->__toString());
85 * Add a string directly to the limitation list
87 * @param $str The string we want to add directly
90 private final function addString ($str) {
91 // Auto-initialization
92 if (is_null($this->limitArray)) {
93 // Initialize this array
94 $this->limitArray = new FrameworkArrayObject();
97 // Add the direct string to ArrayObject
98 $this->limitArray->append($str);
102 * Getter for limitArray
104 * @return $limitArray The object ArrayObject which holds limitations
106 public final function getLimitArray () {
107 return $this->limitArray;