Skip to content

Commit 68c93f1

Browse files
committed
Fixed router
- so that a 404'd blog page will not return an exception but rolover to the magento 404 page
1 parent 691ff16 commit 68c93f1

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"magento/magento-composer-installer": "*"
77
},
88
"type": "magento2-module",
9-
"version": "0.1.1",
9+
"version": "0.1.2",
1010
"autoload": {
1111
"files": [
1212
"src/registration.php"

src/Controller/Router.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
use Skywire\WordpressApi\Helper\RequestHelper;
2525
use Skywire\WordpressApi\Helper\UrlHelper;
26+
use Skywire\WordpressApi\Model\Api\ApiException;
2627
use Skywire\WordpressApi\Model\Api\Category;
2728
use Skywire\WordpressApi\Model\Api\Post;
2829
use Skywire\WordpressApi\Model\Api\Page;
@@ -112,7 +113,12 @@ public function __construct(
112113
*/
113114
public function match(\Magento\Framework\App\RequestInterface $request)
114115
{
115-
$identifier = $this->requestHelper->getSlug($request);
116+
try {
117+
$isMatch = call_user_func([$this, $method], $identifier);
118+
}
119+
catch (ApiException $exception) {
120+
return false;
121+
}
116122

117123
foreach ($this->_matchers as $action => $method) {
118124
$isMatch = call_user_func([$this, $method], $identifier);

src/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3-
<module name="Skywire_WordpressApi" setup_version="0.1.1">
3+
<module name="Skywire_WordpressApi" setup_version="0.1.2">
44
</module>
55
</config>

0 commit comments

Comments
 (0)