Using object initialization flags
Imported From: http://groups.google.com/group/in-portal-dev/browse_thread/thread/6556c91c70151085#
In-Portal uses late binding pattern to create object, only when they are
needed. Method "*kApplication::recallObject*" is used for that.
$return_item =& $this->Application->recallObject('return-item', null, Array
('skip_autoload' => true));
If there is a need to pass additional parameters to object build event (sort
of constructor), then 3rd parameter $params is used.
There are 3 parameters, that always has true/false value (with false by
default):
- *skip_autoload* - don't preload object from database, based on it'd ID,
given in url
- *live_table* - connect object with live table, when it should be
connected to temporary table
- *populate_ml_fields* - alter error processing, when translatable fields
from all languages are visible on the form at once
Other parameters, like "per_page", "sort_by" and so on can have various
values.
To be honest I'm using *Array ('skip_autoload' => true)* a lot and it's very
annoying to type "skip_autoload" word every time.
Maybe there is reasonable solution, that will all usage of BIT CONSTANTS of
something like that, that can be auto-completed by PHP editor.
For example Array ('mode' => kDBItem::SKIP_AUTOLOAD + kDBItem::LIVE_TABLE)
looks pretty auto-completable to me.
--
Best Regards,