]> _ Git - cubist_util.git/commitdiff
wip #7894 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 15 Jan 2026 17:50:37 +0000 (18:50 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 15 Jan 2026 17:50:37 +0000 (18:50 +0100)
src/CommandLine/Docling.php

index 73bebbc224326cbcc25d858b18e55e6fefcc0057..839dd6e5647e66ac765ba4637592486999fbfd56 100644 (file)
@@ -19,8 +19,8 @@ class Docling extends CommandLine
     {
         $f = new \SplFileInfo($image);
 
-        $out = $image . '.' . md5($locale) . '.html';
-        if (!file_exists($out) || filemtime($out) < filemtime($image) || filemtime($out) < filemtime(__FILE__)) {
+        $out = self::cache($image, $locale);
+        if (self::isCached($out, $locale)) {
             $tmp = Files::tmpdir();
             $cli = new self();
             $cli->setArg('to', 'md');
@@ -43,4 +43,15 @@ class Docling extends CommandLine
             return $html ?? file_get_contents($out);
         }
     }
+
+    public static function cache($image, $locale = null)
+    {
+        return $image . '.' . md5($locale??'null') . '.html';
+    }
+
+    public static function isCached($image, $locale = null)
+    {
+        $out = self::cache($image, $locale);
+        return !(!file_exists($out) || filemtime($out) < filemtime($image) || filemtime($out) < filemtime(__FILE__));
+    }
 }
\ No newline at end of file