Skip to content

Commit ca530cb

Browse files
committed
expect exception plugin
1 parent d8a3079 commit ca530cb

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

public/index.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
*/
55
//declare(strict_types = 1);
66

7-
use Mvc5\Web;
7+
use Mvc5\App;
8+
use Mvc5\Plugin\Call;
9+
use Mvc5\Plugin\Expect;
810

911
/**
1012
*
@@ -19,7 +21,9 @@
1921
/**
2022
*
2123
*/
22-
(new Web(include __DIR__ . '/../config/config.php', null, true))();
24+
(new App(include __DIR__ . '/../config/config.php', null, true))(
25+
new Expect(new Call('web'), new Call('exception\response'), true)
26+
);
2327

2428
/**
2529
*
@@ -43,6 +47,6 @@
4347

4448
$parseTime = number_format(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'], 3);
4549

46-
$msg .= 'Parse Time: ' . $parseTime . 's = ' . ($parseTime * 1000) . 'ms';
50+
$msg .= 'Parse Time: ' . $parseTime . 's = ' . ($parseTime * 1000) . 'ms';
4751

4852
echo "\n", '<!-- ', $msg, '-->', "\n";

view/overview/index.phtml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,13 @@ $app-&gt;call('dashboard-&gt;home', ['form' =&gt; []]);
699699

700700
<p>The <a href="https://github.com/mvc5/mvc5/blob/master/src/Plugin/End.php">end</a> plugin will <a href="https://github.com/mvc5/mvc5/blob/master/src/Resolver/Resolver.php#L468">resolve</a> a list of plugins and return the result of the last plugin.</p>
701701

702+
<h3 id="expect"><a href="https://github.com/mvc5/mvc5/blob/master/src/Plugin/Expect.php">Expect</a></h3>
703+
<div class="language-php highlighter-rouge"><pre class="highlight"><code>new Expect(new Call('web'), new Call('exception\response'), true, false);
704+
</code></pre>
705+
</div>
706+
707+
<p>The <a href="https://github.com/mvc5/mvc5/blob/master/src/Plugin/Expect.php">expect</a> plugin is used to catch an exception when resolving a <a href="#plugin">plugin</a>. The second argument is the <a href="#plugin">plugin</a> to use when an exception is thrown. The third argument indicates whether the exception should be passed to the second <a href="#plugin">plugin</a> as a <a href="#named-arguments">named argument</a> and the fourth argument indicates whether to merge the exception with the arguments passed to the first <a href="#plugin">plugin</a>.</p>
708+
702709
<h3 id="factory"><a href="https://github.com/mvc5/mvc5/blob/master/src/Plugin/Factory.php">Factory</a></h3>
703710
<div class="language-php highlighter-rouge"><pre class="highlight"><code>'factory' =&gt; new Service(null),
704711
'Home\Controller' =&gt; new Factory(Home\Controller::class),

0 commit comments

Comments
 (0)