]> BookStack Code Mirror - bookstack/blobdiff - app/Theming/ThemeService.php
Updated minimum php version from 7.3 to 7.4
[bookstack] / app / Theming / ThemeService.php
index 895108e3e2aac8ee5791c266bd30c9ba6c1e951e..275dc9d8c94d421fa4af8467e98146e73fa4404b 100644 (file)
@@ -1,6 +1,11 @@
-<?php namespace BookStack\Theming;
+<?php
+
+namespace BookStack\Theming;
 
 use BookStack\Auth\Access\SocialAuthService;
+use Illuminate\Console\Application;
+use Illuminate\Console\Application as Artisan;
+use Symfony\Component\Console\Command\Command;
 
 class ThemeService
 {
@@ -26,6 +31,7 @@ class ThemeService
      *
      * If a callback returns a non-null value, this method will
      * stop and return that value itself.
+     *
      * @return mixed
      */
     public function dispatch(string $event, ...$args)
@@ -36,16 +42,27 @@ class ThemeService
                 return $result;
             }
         }
+
         return null;
     }
 
+    /**
+     * Register a new custom artisan command to be available.
+     */
+    public function registerCommand(Command $command)
+    {
+        Artisan::starting(function (Application $application) use ($command) {
+            $application->addCommands([$command]);
+        });
+    }
+
     /**
      * Read any actions from the set theme path if the 'functions.php' file exists.
      */
     public function readThemeActions()
     {
         $themeActionsFile = theme_path('functions.php');
-        if (file_exists($themeActionsFile)) {
+        if ($themeActionsFile && file_exists($themeActionsFile)) {
             require $themeActionsFile;
         }
     }
@@ -58,4 +75,4 @@ class ThemeService
         $socialAuthService = app()->make(SocialAuthService::class);
         $socialAuthService->addSocialDriver($driverName, $config, $socialiteHandler, $configureForRedirect);
     }
-}
\ No newline at end of file
+}