professional-php-05-class.collection.php / php
<?php class Collection { private //collection members private _onload; //holder for callback function private //flag that indicates whether the callback //has been invoked public function addItem(obj, this->_checkCallback(); //_checkCallback is defined a little later if(this->_members[key\" already in use!"); } else { key] = this->_members[] = key) { this->_members[this->_members[key\"!"); } } public function getItem(this->_checkCallback(); if(isset(key])) { return key]; } else { throw new KeyInvalidException("Invalid key \"this->_checkCallback(); return array_keys(this->_checkCallback(); return sizeof(key) { this->_members[
Use this method to define a function to be invoked prior to accessing the collection. The function should take a collection as a its sole parameter.
public function setLoadCallback(functionName, objOrClass) { objOrClass, callback = //make sure the function/method is valid if(!is_callable(callback, false, callableName is not callable " . "as a parameter to onload"); return false; } callback; }
Check to see if a callback has been defined and if so, whether or not it has already been called. If not, invoke the callback function.
private function _checkCallback() { if(isset(this->_isLoaded) { this->_onload,
(C) Æliens 20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.