/** * Class constructor. * pass in alternate to $_REQUEST */ public function __construct($data = NULL) { if ($data === NULL) { $data = $_REQUEST; } parent::__construct($data); $trim_chars = "/\n\r\t\v "; $server = \Wukka\ShortCircuit::server(); $this->uri = '/' . trim($server->REQUEST_URI, $trim_chars); if (isset($this->{'_'})) { $action = $this->{'_'}; } elseif (isset($server->PATH_INFO)) { $action = $server->PATH_INFO; } else { $pos = strpos($this->uri, '?'); $action = $pos === FALSE ? $this->uri : substr($this->uri, 0, $pos); } $script_name = $server->SCRIPT_NAME; $action = str_replace(array($script_name, $script_name . '?_='), '', $action); $action = trim($action, $trim_chars); $this->action = '/' . $action; if (strpos($this->uri, $script_name) === 0) { $this->base = $script_name; } else { $this->base = ''; } }
/** * Class constructor. * pass in alternate to $_REQUEST */ public function __construct($data = NULL) { if ($data === NULL) { $this->__d =& $_SERVER; } else { parent::__construct($data); } }
/** * Specify storage and an entity key. * This will load a bunch of key/value pairs associated with the entity */ public function __construct(Iface $storage, $entity) { $this->storage = $storage; // a way to populate an entity without having to read from storage. // for internal use only. used by the EAV::bulkLoad() method. if (is_array($entity)) { $this->entity = $entity["._entity"]; unset($entity["._entity"]); $this->load($entity); $this->state = $this->checksum(); return; } // standard approach. $this->entity = $entity; parent::__construct($this->storage->get($entity)); $this->state = $this->checksum(); }
<?php include_once __DIR__ . '/../autoload.php'; use Wukka\Test as T; use Wukka\Store\Iterator as Container; T::plan(22); $c = new Container(); foreach (array('result_set', 'result_get', 'result_isset', 'result_unset') as $key) { ${$key} = array(); } if (!isset($input) || !is_array($input)) { $input = array(); } foreach ($input as $k => $v) { $result_set[$k] = $c->{$k} = $v; $result_isset[$k] = isset($c->{$k}); $result_get[$k] = $c->{$k}; unset($c->{$k}); $result_unset[$k] = $c->{$k}; } T::is($input, $result_set, 'set works properly'); T::is($input, $result_get, 'get works properly'); T::is(array_fill_keys(array_keys($input), TRUE), $result_isset, 'isset works properly'); T::is(array_fill_keys(array_keys($input), NULL), $result_unset, 'unset works properly'); T::is($c->non_existent, NULL, 'non-existent variables are null'); $c->load($input); T::is($c->get(array_keys($input)), $input, 'multi-get works properly'); T::is($c->all(), $input, 'grabbed all of the data at once'); $each = array(); while (list($k, $v) = $c->each()) { $each[$k] = $v;