aboutsummaryrefslogtreecommitdiff
path: root/app/class/Modelrender.php
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2020-04-25 17:53:44 +0200
committervincent-peugnet <v.peugnet@free.fr>2020-04-25 17:53:44 +0200
commit0efeef6b6693d62675ec8a45e73c71f69e0a0362 (patch)
tree4b86b3bd62217fc4c60e2827e30a45209ce82605 /app/class/Modelrender.php
parentbd16dc7c6fc630a6b59ca3b041dde146ab50c72b (diff)
parent385b3f4adf86606e03941171c136d8f2eb2b35c2 (diff)
downloadwcms-0efeef6b6693d62675ec8a45e73c71f69e0a0362.tar.gz
wcms-0efeef6b6693d62675ec8a45e73c71f69e0a0362.zip
Merge branch master with implement-exception
Diffstat (limited to 'app/class/Modelrender.php')
-rw-r--r--app/class/Modelrender.php13
1 files changed, 9 insertions, 4 deletions
diff --git a/app/class/Modelrender.php b/app/class/Modelrender.php
index 553857b..7322955 100644
--- a/app/class/Modelrender.php
+++ b/app/class/Modelrender.php
@@ -3,6 +3,7 @@
namespace Wcms;
use Exception;
+use LogicException;
use Michelf\MarkdownExtra;
class Modelrender extends Modelpage
@@ -56,7 +57,11 @@ class Modelrender extends Modelpage
*/
public function upage(string $id): string
{
- return $this->generate('pageread/', ['page' => $id]);
+ try {
+ return $this->router->generate('pageread/', ['page' => $id]);
+ } catch (Exception $e) {
+ throw new LogicException($e->getMessage(), $e->getCode(), $e);
+ }
}
@@ -128,7 +133,7 @@ class Modelrender extends Modelpage
$matches = $this->match($body, $regex);
// First, analyse the synthax and call the corresponding methods
- if (isset($matches)) {
+ if (!empty($matches)) {
foreach ($matches as $key => $match) {
$element = new Element($this->page->id(), $match);
$element->setcontent($this->getelementcontent($element->sources(), $element->type()));
@@ -534,7 +539,7 @@ class Modelrender extends Modelpage
{
$matches = $this->match($text, 'MEDIA');
- if (isset($matches)) {
+ if (!empty($matches)) {
foreach ($matches as $match) {
$medialist = new Medialist($match);
$medialist->readoptions();
@@ -575,7 +580,7 @@ class Modelrender extends Modelpage
$modelhome = new Modelhome();
- if (isset($matches)) {
+ if (!empty($matches)) {
foreach ($matches as $match) {
$optlist = new Optlist(['render' => $this]);
$optlist->parsehydrate($match['options']);