function EventLink($event, $params = NULL) { // Determine the base URL. $url = Bugdar::$settings['webroot']; // Use the ViewOutputHandler's closure to convert the class name to viewese. // We then reverse new_comment to get comment_new. $f = EventPump::Pump()->output_handler()->template_loader(); $parts = explode('_', $f($event)); $parts = array_reverse($parts); $url .= implode('_', $parts); // Append parameters. if ($params !== NULL) { if (KeyDescender::IsDescendable($params)) { foreach ($params as $key => $value) { $url .= '/' . Cleaner::HTML($key) . '/' . Cleaner::HTML($value); } } else { // This is a single-value type. HTML encode it and append it as the _id // parameter. $url .= '/' . Cleaner::HTML($params); } } return $url; }
public function testNestedKeyDescenders() { $array = array('foo' => 'bar', 'moo' => 'baz'); $outer = new KeyDescender($array); $inner = array('abc' => 'def'); $outer->inner = new KeyDescender($inner); $this->assertEquals('def', $outer->Get('inner.abc')); }