本文整理汇总了PHP中midcom_core_context::get_handler方法的典型用法代码示例。如果您正苦于以下问题:PHP midcom_core_context::get_handler方法的具体用法?PHP midcom_core_context::get_handler怎么用?PHP midcom_core_context::get_handler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类midcom_core_context
的用法示例。
在下文中一共展示了midcom_core_context::get_handler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run_handler
public function run_handler($topic, array $args = array())
{
if (is_object($topic)) {
$component = $topic->component;
} else {
$component = $topic;
$topic = $this->get_component_node($component);
}
$context = new midcom_core_context(null, $topic);
$context->set_current();
$context->set_key(MIDCOM_CONTEXT_URI, midcom_connection::get_url('self') . $topic->name . '/' . implode('/', $args) . '/');
// Parser Init: Generate arguments and instantiate it.
$context->parser = midcom::get('serviceloader')->load('midcom_core_service_urlparser');
$context->parser->parse($args);
$handler = $context->get_handler($topic);
$context->set_key(MIDCOM_CONTEXT_CONTENTTOPIC, $topic);
$this->assertTrue(is_a($handler, 'midcom_baseclasses_components_interface'), $component . ' found no handler for ./' . implode('/', $args) . '/');
$result = $handler->handle();
$this->assertTrue($result !== false, $component . ' handle returned false on ./' . implode('/', $args) . '/');
$data =& $handler->_context_data[$context->id]['handler']->_handler['handler'][0]->_request_data;
if (is_object($result) && $result instanceof midcom_response) {
$data['__openpsa_testcase_response'] = $result;
}
$data['__openpsa_testcase_handler'] = $handler->_context_data[$context->id]['handler']->_handler['handler'][0];
$data['__openpsa_testcase_handler_method'] = $handler->_context_data[$context->id]['handler']->_handler['handler'][1];
// added to simulate http uri composition
$_SERVER['REQUEST_URI'] = $context->get_key(MIDCOM_CONTEXT_URI);
return $data;
}
示例2: process
/**
* Matches the current request to a handler if possible
*
* @throws midcom_error If topic can't be loaded
* @return mixed Handler or false if there is no match
*/
public function process()
{
$this->_process_urlmethods();
midcom::get()->set_status(MIDCOM_STATUS_CANHANDLE);
do {
$object = $this->_context->parser->get_current_object();
if (!is_object($object) || !$object->guid) {
throw new midcom_error('Root node missing.');
}
if (is_a($object, 'midcom_db_attachment')) {
$this->serve_attachment($object);
}
// Check whether the component can handle the request.
// If so, execute it, if not, continue.
if ($handler = $this->_context->get_handler($object)) {
return $handler;
}
} while ($this->_context->parser->get_object() !== false);
return false;
}