本文整理汇总了PHP中Context::method方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::method方法的具体用法?PHP Context::method怎么用?PHP Context::method使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context::method方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: goNext
private static function goNext(Context $ctx)
{
if ($ctx->method('post')) {
foreach ($ctx->post('next', array()) as $k => $v) {
if (!empty($v) and null !== $ctx->post($k)) {
return new Redirect($v);
}
}
}
return $ctx->getRedirect();
}
示例2: hookRemoteCall
public static function hookRemoteCall(Context $ctx, $className)
{
$default = 'default';
if ($ctx->method('post')) {
$default = $ctx->post('action', $default);
}
$action = $ctx->get('action', $default);
$call = array(array($className, 'rpc_' . strtolower($ctx->method()) . '_' . $action), array($className, 'rpc_' . $action));
foreach ($call as $args) {
if (method_exists($args[0], $args[1])) {
if (null === ($result = call_user_func(array($args[0], $args[1]), $ctx))) {
$result = $ctx->getRedirect();
}
return $result;
}
}
if (null !== ($next = $ctx->getRedirect())) {
return $next;
}
return false;
}
示例3: hookRemoteCall
public static function hookRemoteCall(Context $ctx)
{
switch ($ctx->get('action')) {
case 'add':
$ctx->user->checkAccess(ACL::CREATE, 'todo');
$node = Node::create('todo', array('name' => $ctx->post('name'), 'uid' => $ctx->user->id, 'to' => $ctx->post('user', $ctx->user->id), 'published' => 1, 'rel' => $ctx->post('rel')));
if (empty($node->name)) {
$msg = t('не указан текст задачи.');
bebop_on_json(array('status' => 'error', 'message' => $msg));
throw new InvalidArgumentException($msg);
}
$node->save();
bebop_on_json(array('status' => 'created', 'id' => $node->id, 'html' => $node->render()));
break;
case 'toggle':
try {
$node = Node::load(array('class' => 'todo', 'id' => $ctx->get('id')));
} catch (ObjectNotFoundException $e) {
bebop_on_json(array('status' => 'error', 'message' => 'todo ' . $ctx->get('id') . ' not found'));
throw new PageNotFoundException();
}
if (empty($node->closed)) {
$node->closed = date('Y-m-d H:i:s', time() - date('Z', time()));
} else {
$node->closed = null;
}
$node->save();
if ($ctx->method('POST') and null !== ($comment = $ctx->post('comment'))) {
$tmp = Node::create('comment', array('uid' => $ctx->user->id, 'author' => $ctx->user->name, 'name' => t('Комментарий к напоминанию'), 'text' => $comment));
$tmp->save();
$tmp->linkAddParent($node->id);
}
$state = $node->closed ? 'closed' : 'open';
bebop_on_json(array('status' => 'ok', 'state' => $state));
break;
}
}
示例4: getNodes
/**
* Возвращает обрабатываемые ноды.
* Для запросов методом POST использует массив selected[],
* для запросов методом GET — параметр node.
*/
private static function getNodes(Context $ctx)
{
if ($ctx->method('post')) {
$ids = $ctx->post('selected', array());
} else {
$ids = explode(' ', $ctx->get('node'));
}
if (empty($ids)) {
throw new BadRequestException(t('Не указаны идентификаторы документов (POST-массив selected[] или GET-параметр node)'));
}
return Node::find(array('id' => $ids), $ctx->db);
}
示例5: find
public function find(Context $ctx, $realQuery)
{
$args = array();
$query = '/' . $realQuery;
$prefix = strtoupper($ctx->method()) . '/';
$q = array($prefix . $query, $prefix . $ctx->host() . $query, $prefix . 'localhost' . $query);
foreach ($q as $mask) {
if (array_key_exists($mask, $this->static)) {
return array($this->static[$mask], array());
}
if (false !== ($tmp = $this->findre($mask))) {
return $tmp;
}
}
return false;
}