]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5740 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 16 Feb 2023 14:17:47 +0000 (15:17 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 16 Feb 2023 14:17:47 +0000 (15:17 +0100)
app/Jobs/FluidbookCompiler.php

index 3b85117056d469ad03e16dd206effa248e98063b..5af7cf59307078b1ad279429d1487f5341211276 100644 (file)
@@ -39,6 +39,7 @@ use Fluidbook\Tools\Links\AnchorLink;
 use Fluidbook\Tools\Links\ContentLink;
 use Fluidbook\Tools\SVG\SVGTools;
 use Illuminate\Console\Command;
+use Illuminate\Support\Facades\Log;
 use SimpleXMLElement;
 use SplFileInfo;
 
@@ -2438,33 +2439,37 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
             }
 
             foreach ($linksToAdd as $lta) {
-                /** @var $lta Link */
-                // Keep this line because some properties of the link (like blend mode) are parsed with this function
-                $c = $lta->getHTMLContainer();
-                $css[] = $lta->getCSSContainer();
-                if (!isset($pages[$lta->page])) {
-                    $pages[$lta->page] = ['normal' => []];
-                    $cpages[$lta->page] = ['normal' => []];
-                    $ctpages[$lta->page] = ['normal' => []];
-                }
+                try {
+                    /** @var $lta Link */
+                    // Keep this line because some properties of the link (like blend mode) are parsed with this function
+                    $c = $lta->getHTMLContainer();
+                    $css[] = $lta->getCSSContainer();
+                    if (!isset($pages[$lta->page])) {
+                        $pages[$lta->page] = ['normal' => []];
+                        $cpages[$lta->page] = ['normal' => []];
+                        $ctpages[$lta->page] = ['normal' => []];
+                    }
 
 
-                $d = $lta->getDepth();
-                if ($d < 30) {
-                    $v = 'ctpages';
-                } else if ($d < 50) {
-                    $v = 'cpages';
-                } else {
-                    $v = 'pages';
-                }
+                    $d = $lta->getDepth();
+                    if ($d < 30) {
+                        $v = 'ctpages';
+                    } else if ($d < 50) {
+                        $v = 'cpages';
+                    } else {
+                        $v = 'pages';
+                    }
 
-                $lta->setInitialOrder($i);
-                if (!isset($$v[$lta->page][$lta->blendmode])) {
-                    $$v[$lta->page][$lta->blendmode] = [];
-                }
+                    $lta->setInitialOrder($i);
+                    if (!isset($$v[$lta->page][$lta->blendmode])) {
+                        $$v[$lta->page][$lta->blendmode] = [];
+                    }
 
-                array_push($$v[$lta->page][$lta->blendmode], $lta);
-                $i++;
+                    array_push($$v[$lta->page][$lta->blendmode], $lta);
+                    $i++;
+                } catch (\Exception $e) {
+                    $this->triggerLinkError($e, $lta);
+                }
             }
             // Make old "aftersearch" link compatible with new "extra" menu option by extracting link URL
             if ($link->page == 'aftersearch') {
@@ -2513,6 +2518,23 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
         return $css;
     }
 
+    /**
+     * @param $e \Exception
+     * @param $link Link
+     * @return void
+     * @throws \Exception
+     */
+    protected function triggerLinkError($e, $link)
+    {
+        Log::error($e);
+
+        $c=explode('\\',get_class($link));
+        $type=array_pop($c);
+        $type=str_replace('Link','',$type);
+
+        throw new \Exception('Error on the '.$type.' link to ' . $link->to . ' on page ' . $link->page . '  with message : ' . $e->getMessage());
+    }
+
     protected function _htmlLinkList($list)
     {
         if (!count($list)) {