当前位置: 首页>>代码示例>>PHP>>正文


PHP Event::getData方法代码示例

本文整理汇总了PHP中Event::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::getData方法的具体用法?PHP Event::getData怎么用?PHP Event::getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Event的用法示例。


在下文中一共展示了Event::getData方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSetData

 public function testSetData()
 {
     $event = new Event('test');
     $data = array('a' => 'b');
     $event->setData($data);
     $this->assertSame($data, $event->getData());
 }
开发者ID:nelsonsar,项目名称:armadillo,代码行数:7,代码来源:EventTest.php

示例2: reload

if ($event === false) {
    $tmpl->renderBadLink();
    return;
}
if (!Event::isActive($db, $_GET['key'])) {
    $tmpl->renderBadLink();
    return;
}
$user_ch = $db->query('SELECT user_id, nick, email FROM users WHERE nick = ' . $db->quote($_GET['nick']))->fetch();
if ($user_ch === false) {
    $tmpl->renderBadLink();
    return;
}
if ((int) $event['user_id'] !== (int) $user_ch['user_id']) {
    $tmpl->renderBadLink();
    return;
}
$value = Event::getData($db, $_GET['key']);
if ($value === false) {
    reload('?fb=change_email_failed');
}
$db->beginTransaction();
try {
    Event::setComplete($db, $_GET['key']);
    $db->update('users', ['email' => $value], 'user_id = ' . $db->quote($user_ch['user_id']));
    $db->commit();
    reload('?fb=change_email_new_success');
} catch (\Snabb\Database\Exception $e) {
    $db->rollback();
    reload('?fb=change_email_failed');
}
开发者ID:WeaponMan,项目名称:Todolist,代码行数:31,代码来源:new_email.php

示例3: Event

    (new Event('before-routing'))->trigger();
    /*** Execute action just after routing ***/
    Event::on('after-routing', function ($event) {
        $route = $event->getData('route');
        if (!App::conf()->has('db') && App::request()->getUri() == App::router()->getUri('index')) {
            // The application is not installed yet
            App::logger()->notice('Hawk is not installed yet, redirect to install process page');
            App::response()->redirectToAction('install');
            return;
        }
    });
    /*** Compute the routage ***/
    App::router()->route();
} catch (HTTPException $err) {
    App::response()->setStatus($err->getStatusCode());
    $response = array('message' => $err->getMessage(), 'details' => $err->getDetails());
    if (App::request()->getWantedType() === 'json') {
        App::response()->setContentType('json');
        App::response()->setBody($response);
    } else {
        App::response()->setBody($response['message']);
    }
} catch (AppStopException $e) {
}
// Finish the script
App::logger()->debug('end of script');
$event = new Event('process-end', array('output' => App::response()->getBody(), 'execTime' => microtime(true) - SCRIPT_START_TIME));
$event->trigger();
App::response()->setBody($event->getData('output'));
/*** Return the response to the client ***/
App::response()->end();
开发者ID:elvyrra,项目名称:hawk,代码行数:31,代码来源:index.php

示例4: testGetData

 /**
  */
 public function testGetData()
 {
     $this->assertTrue(is_array($this->object->getData()));
 }
开发者ID:fwk,项目名称:events,代码行数:6,代码来源:EventTest.php

示例5: getMainMenu

 /**
  * Get the main menu items
  * @return array The main menu items
  */
 public function getMainMenu()
 {
     if (!App::isInstalled()) {
         return array();
     }
     $user = App::session()->getUser();
     $menus = array('applications' => array(), 'settings' => array());
     // Get the menus
     $items = MenuItem::getAvailableItems($user);
     // Filter the menus that have no action and no item
     $items = array_filter($items, function ($item) {
         return $item->action || count($item->visibleItems) > 0;
     });
     foreach ($items as $id => $item) {
         if ($item->labelKey === 'user.username') {
             $item->label = $user->getUsername();
         }
         if (in_array($item->plugin, PLugin::$mainPlugins)) {
             $menus['settings'][] = $item;
         } else {
             $menus['applications'][] = $item;
         }
     }
     // Trigger an event to add or remove menus from plugins
     $event = new Event(self::EVENT_AFTER_GET_MENUS, array('menus' => $menus));
     $event->trigger();
     $menus = $event->getData('menus');
     App::response()->setContentType('json');
     return $menus;
     return View::make(Theme::getSelected()->getView('main-menu.tpl'), array('menus' => $menus, 'logo' => Option::get('main.logo') ? Plugin::current()->getUserfilesUrl(Option::get('main.logo')) : ''));
 }
开发者ID:elvyrra,项目名称:hawk,代码行数:35,代码来源:MainController.php

示例6: testGetSetData

 public function testGetSetData()
 {
     $event = new Event(1, 'test');
     $event->setData('new test');
     $this->assertEquals('new test', $event->getData(), 'Проверка getter/setter data');
 }
开发者ID:bashka,项目名称:bricks_http_realtimeserver_longpolling,代码行数:6,代码来源:EventTest.php

示例7: __call

 /**
  * Call a method of the controller
  *
  * @param string $method    The method to call
  * @param array  $arguments The arguments of the method call
  *
  * @return mixed The result of the method call
  */
 public function __call($method, $arguments)
 {
     $this->controller->executingMethod = $method;
     /*** Load widgets before calling the controller method ***/
     $class = $this->controller->getClassname();
     $eventBasename = $this->controller->_plugin . '.' . $class . '.' . $method . '.';
     $event = new Event($eventBasename . Controller::BEFORE_ACTION, array('controller' => $this->controller));
     $event->trigger();
     /*** Call the controller method ***/
     $result = call_user_func_array(array($this->controller, $method), $arguments);
     if (App::response()->getContentType() == 'html' && is_string($result)) {
         // Create a phpQuery object to be modified by event listeners (widgets)
         $result = \phpQuery::newDocument($result);
     }
     /*** Load the widgets after calling the controller method ***/
     $event = new Event($eventBasename . Controller::AFTER_ACTION, array('controller' => $this->controller, 'result' => $result));
     $event->trigger();
     // Return the result of the action
     $result = $event->getData('result');
     if ($result instanceof \phpQuery || $result instanceof \phpQueryObject) {
         return $result->htmlOuter();
     } else {
         return $result;
     }
     $this->controller->executingMethod = null;
 }
开发者ID:elvyrra,项目名称:hawk,代码行数:34,代码来源:Controller.php

示例8: route

 /**
  * Compute the routing, and execute the controller method associated to the URI
  */
 public function route()
 {
     $path = str_replace(BASE_PATH, '', parse_url(App::request()->getUri(), PHP_URL_PATH));
     // Scan each row
     foreach ($this->routes as $route) {
         if ($route->match($path)) {
             // The URI matches with the route
             $this->currentRoute =& $route;
             // Check if the route is accessible with the current method
             if (!$route->isCallableBy(App::request()->getMethod())) {
                 throw new BadMethodException($route->url, App::request()->getMethod());
             }
             // Emit an event, saying the routing action is finished
             $event = new Event('after-routing', array('route' => $route));
             $event->trigger();
             $route = $event->getData('route');
             if (!$route->isAccessible()) {
                 // The route is not accessible
                 App::logger()->warning(sprintf('A user with the IP address %s tried to access %s without the necessary privileges', App::request()->clientIp(), App::request()->getUri()));
                 if (!App::session()->isLogged()) {
                     throw new UnauthorizedException();
                 } else {
                     throw new ForbiddenException();
                 }
             }
             // The route authentications are validated
             list($classname, $method) = explode(".", $route->action);
             // call a controller method
             $this->currentController = $classname::getInstance($route->getData());
             App::logger()->debug(sprintf('URI %s has been routed => %s::%s', App::request()->getUri(), $classname, $method));
             // Set the controller result to the HTTP response
             App::response()->setBody($this->currentController->{$method}());
             return;
         }
     }
     App::logger()->warning('The URI ' . App::request()->getUri() . ' has not been routed');
     throw new PageNotFoundException();
 }
开发者ID:elvyrra,项目名称:hawk,代码行数:41,代码来源:Router.php


注:本文中的Event::getData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。