1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
<?php
namespace Catapult;
abstract class MetaResource extends BaseResource {
public function __construct($depends=null) {
$this->terms = array();
$checks = array("plural", "mandatory");
if (!is_array($depends))
return;
foreach ($depends as $k => $d) {
$this->terms[$k] = new SubFunctionObject($d);
}
}
}
abstract class Multi {
public function __construct($args) {
if (is_array($args)) {
foreach ($this->terms as $t) {
if (!in_array($t, array_keys($args))) {
$this->$t = false;
continue;
}
$this->$t = $args[$t];
}
}
}
}
final class SubfunctionObject extends Multi {
public $terms = array( "term", "type", "singular" );
}
final class DependsObject extends Multi {
public $terms = array(
"term",
"plural",
"mandatoryId"
);
}
class SubFunctionResource extends MetaResource {
public $terms = array(
"term",
"type",
"id",
"plural"
);
}
class RemoveResource {
public function __construct(&$object, $terms) {
foreach ($terms as $v) {
unset($object->$v);
}
}
}
final class DependsResource extends BaseResource {
public static $keywords = array(
"plural",
"term",
"mandatoryId"
);
public function __construct($depends=null) {
$this->terms = array();
if (!is_array($depends))
return;
foreach ($depends as $k => $d) {
if (!in_array($k, $this::$keywords))
throw new \CatapultApiException("Fields were built improperly for " . __CLASS__);
$this->terms[$k] = new DependsObject($d);
}
}
}
class ClientResource extends BaseResource {
public static function attach(&$object) {
$client = Client::Get();
$object->client = &$client;
if ($object->client == null) {
throw new \CatapultApiException("You have not initialized the client yet. Please use: Catapult\Client(params..)");
}
}
}
?>