function testLocatorClassLoader() { $locator = new A_Locator(); $dir = dirname(__FILE__); // set directory for classes that use PEAR Foo_Bar style naming $locator->setDir("{$dir}/../include/", 'Foo'); $result = $locator->loadClass('Foo_Bar'); $this->assertTrue($result); $this->assertTrue(class_exists('Foo_Bar', false)); $locator->setDir("{$dir}/../include/Foo", '/^Foo.*/'); $result = $locator->loadClass('FooBar'); }
public function render() { // if no value and addtype set then use it if ($this->addtype && $this->value == '') { $savetype = $this->type; $this->type = $this->addtype; } else { $savetype = null; } if (isset($this->type['renderer'])) { if (!isset($this->renderer)) { $this->renderer = $this->type['renderer']; unset($this->type['renderer']); } } // string is name of class with underscores in loadable convention if (is_string($this->renderer)) { // load locator if not loaded if (A_Locator::loadClass($this->renderer)) { // instantiate render passing the array of field $this->renderer = new $this->renderer(); } } if (isset($this->renderer) && method_exists($this->renderer, 'render')) { // set name and value in array passed to renderer $this->type['name'] = $this->name; $this->type['value'] = $this->value; $this->renderer->import($this->type); return $this->renderer->render(); } // restore type if ($savetype) { $this->type = $savetype; } return $this->value; }