Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Ginioo committed Oct 1, 2015
1 parent 04d9510 commit 4e1d225
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#how to use?
#how to use Event?
```php
// varialbe outside of the closure bellow
$message = 'test Message';
Expand All @@ -18,3 +18,46 @@ if ($oEvent->hasEvent('test')) {
$oEvent->emit('test', array('1', '2'));
}
```

#how to use Application?
```php
use \Sandbox\Application as TestApplication;

$app = new TestApplication();
$app->on('create', function ($a) use ($message) {
echo $a . ' ' . $message . '<br>';
});

$app->on('retrieve', function ($a) use ($message) {
echo $a . ' ' . $message . '<br>';
});

$app->on('update', function ($a) use ($message) {
echo $a . ' ' . $message . '<br>';
});

$app->on('delete', function ($a) use ($message) {
echo $a . ' ' . $message . '<br>';
});

$app->on('debug', function ($message) {
error_reporting(E_ALL);
ini_set("display_errors", 1);

echo var_export($message, true) . '<br>';
});

$eventName = $app->getRequestEvent();
$input = $app->getInputData();

if (isset($input['debug']) && $app->hasEvent('debug')) {
$app->emit('debug', $input);
}

if ($app->hasEvent($eventName)) {
// 觸發事件
$message = var_export($input, true);
$app->emit($eventName, $message);
}

```

0 comments on commit 4e1d225

Please sign in to comment.