1 |
joko |
1.1 |
<?php |
2 |
|
|
/** |
3 |
|
|
* This file contains the Class::Abstract class. |
4 |
|
|
* |
5 |
|
|
* @author Andreas Motl <andreas.motl@ilo.de> |
6 |
joko |
1.2 |
* @name Class::Abstract |
7 |
joko |
1.1 |
* |
8 |
|
|
*/ |
9 |
|
|
|
10 |
|
|
/** |
11 |
joko |
1.2 |
* $Id: Abstract.php,v 1.1 2003/03/03 21:25:51 joko Exp $ |
12 |
|
|
* |
13 |
|
|
* $Log: Abstract.php,v $ |
14 |
|
|
* Revision 1.1 2003/03/03 21:25:51 joko |
15 |
|
|
* + initial commit |
16 |
joko |
1.1 |
* |
17 |
|
|
* |
18 |
|
|
*/ |
19 |
|
|
|
20 |
|
|
|
21 |
|
|
/** |
22 |
|
|
* --- An attempt to implement some software design patterns... |
23 |
|
|
* |
24 |
|
|
* @author Andreas Motl <andreas.motl@ilo.de> |
25 |
|
|
* @copyright (c) 2003 - All Rights reserved. |
26 |
|
|
* @license GNU LGPL (GNU Lesser General Public License) |
27 |
|
|
* |
28 |
joko |
1.2 |
* @link http://www.netfrag.org/~joko/ |
29 |
|
|
* @link http://www.gnu.org/licenses/lgpl.txt |
30 |
joko |
1.1 |
* |
31 |
|
|
* @package org.netfrag.glib |
32 |
joko |
1.2 |
* @subpackage Class |
33 |
|
|
* @name Class::Abstract |
34 |
joko |
1.1 |
* |
35 |
|
|
*/ |
36 |
|
|
class Class_Abstract { |
37 |
|
|
|
38 |
|
|
// --- "core" |
39 |
|
|
|
40 |
|
|
function __call_abstract_method($method, $required_by = '', $message = '') { |
41 |
|
|
|
42 |
|
|
/* |
43 |
|
|
$address = array(); |
44 |
|
|
array_push($address, "DesignPattern::Facade", $package_p, $package); |
45 |
|
|
*/ |
46 |
|
|
|
47 |
|
|
$inheritance_tree = php::get_ancestors_class($this); |
48 |
|
|
array_push($inheritance_tree, get_class($this)); |
49 |
|
|
$inheritance_tree_serialized = join(' -> ', $inheritance_tree); |
50 |
|
|
|
51 |
|
|
$out = "Base class '$required_by' requires method '$method' to be implemented in inherited class. inheritance_tree: [$inheritance_tree_serialized] (additional info: $message)"; |
52 |
|
|
user_error($out); |
53 |
|
|
|
54 |
|
|
$this->__call_concrete_methods(array('about', 'usage')); |
55 |
|
|
|
56 |
|
|
} |
57 |
|
|
|
58 |
|
|
function __call_concrete_method($method, $args = array()) { |
59 |
|
|
if (method_exists($this, $method)) { $this->$method($args); } |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
function __call_concrete_methods($methods = array(), $args = array()) { |
63 |
|
|
foreach ($methods as $method) { |
64 |
|
|
$this->__call_concrete_method($method, $args); |
65 |
|
|
} |
66 |
|
|
} |
67 |
|
|
|
68 |
|
|
|
69 |
|
|
// --- "api" |
70 |
|
|
|
71 |
|
|
function _abstract_method($method, $required_by = '', $message = '') { |
72 |
|
|
$this->__call_abstract_method($method, $required_by, $message); |
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
function _concrete_method($method, $args = array()) { |
76 |
|
|
$this->__call_concrete_method($method, $args); |
77 |
|
|
} |
78 |
|
|
|
79 |
|
|
function usage() { |
80 |
|
|
print "<pre>" . htmlentities($this->_about) . "</pre>"; |
81 |
|
|
} |
82 |
|
|
|
83 |
|
|
} |
84 |
|
|
|
85 |
|
|
?> |