flight\Engine::map PHP Méthode

map() public méthode

Maps a callback to a framework method.
public map ( string $name, callback $callback )
$name string Method name
$callback callback Callback function
    public function map($name, $callback)
    {
        if (method_exists($this, $name)) {
            throw new \Exception('Cannot override an existing framework method.');
        }
        $this->dispatcher->set($name, $callback);
    }

Usage Example

Exemple #1
0
 function testMapOverridesRegister()
 {
     $this->app->register('reg5', 'User');
     $user = $this->app->reg5();
     $this->assertTrue(is_object($user));
     $this->app->map('reg5', function () {
         return 123;
     });
     $user = $this->app->reg5();
     $this->assertEquals(123, $user);
 }
All Usage Examples Of flight\Engine::map