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


PHP Slim::applyHook方法代码示例

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


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

示例1: testHookInvocationIfNotExists

 /**
  * Test hook invocation if hook does not exist
  *
  * Pre-conditions:
  * Slim app instantiated;
  * Hook name does not exist;
  *
  * Post-conditions:
  * Hook is created;
  * Hook initialized with empty array;
  */
 public function testHookInvocationIfNotExists()
 {
     $app = new Slim();
     $app->applyHook('test.hook.one');
     $this->assertEquals(array(array()), $app->getHooks('test.hook.one'));
 }
开发者ID:rs3d,项目名称:Slimplr,代码行数:17,代码来源:SlimTest.php

示例2: testHookFilterBehavior

 /**
  * Test hook filter behavior
  */
 public function testHookFilterBehavior()
 {
     $app = new Slim();
     $app->hook('test.hook', function ($arg) {
         return $arg . 'foo';
     });
     $this->assertEquals('barfoo', $app->applyHook('test.hook', 'bar'));
 }
开发者ID:inscriptionweb,项目名称:lebonmail,代码行数:11,代码来源:SlimTest.php

示例3: run

 /**
  * Run the Slim application
  *
  * This method is the "meat and potatoes" of Slim and should be the last
  * method called. This fires up Slim, invokes the Route that matches
  * the current request, and returns the response to the client.
  *
  * This method will invoke the Not Found handler if no matching
  * routes are found.
  *
  * @return void
  */
 public static function run()
 {
     try {
         self::applyHook('slim.before');
         ob_start();
         self::applyHook('slim.before.router');
         $dispatched = false;
         foreach (self::router()->getMatchedRoutes() as $route) {
             try {
                 Slim::applyHook('slim.before.dispatch');
                 $dispatched = $route->dispatch();
                 Slim::applyHook('slim.after.dispatch');
                 if ($dispatched) {
                     break;
                 }
             } catch (Slim_Exception_Pass $e) {
                 continue;
             }
         }
         if (!$dispatched) {
             self::notFound();
         }
         self::response()->write(ob_get_clean());
         self::applyHook('slim.after.router');
         self::$app->flash->save();
         session_write_close();
         self::response()->send();
         self::applyHook('slim.after');
     } catch (Slim_Exception_RequestSlash $e) {
         self::redirect(self::request()->getRootUri() . self::request()->getResourceUri() . '/', 301);
     }
 }
开发者ID:alanvivona,项目名称:scawTP,代码行数:44,代码来源:Slim.php

示例4: testHookFilterBehavior

 /**
  * Test hook filter behavior
  *
  */
 public function testHookFilterBehavior()
 {
     Slim::init();
     Slim::hook('test.hook', function ($arg) {
         return $arg . 'foo';
     });
     $this->assertEquals('barfoo', Slim::applyHook('test.hook', 'bar'));
 }
开发者ID:alanvivona,项目名称:scawTP,代码行数:12,代码来源:SlimTest.php


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