]> BookStack Code Mirror - bookstack/blobdiff - app/Theming/ThemeService.php
Added test for logical-theme-system command registration
[bookstack] / app / Theming / ThemeService.php
index 54e476ae2a896b65abaeafa2689406659affa1a1..f0f8f033c4d9c4542259906835cb1bf98d4651a3 100644 (file)
@@ -1,6 +1,10 @@
-<?php namespace BookStack\Theming;
+<?php
+
+namespace BookStack\Theming;
 
 use BookStack\Auth\Access\SocialAuthService;
+use Illuminate\Contracts\Console\Kernel;
+use Symfony\Component\Console\Command\Command;
 
 class ThemeService
 {
@@ -26,6 +30,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 +41,27 @@ class ThemeService
                 return $result;
             }
         }
+
         return null;
     }
 
+    /**
+     * Register a new custom artisan command to be available.
+     */
+    public function registerCommand(Command $command)
+    {
+        /** @var \Illuminate\Foundation\Console\Kernel $consoleKernel */
+        $consoleKernel = app()->make(Kernel::class);
+        $consoleKernel->registerCommand($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;
         }
     }
@@ -53,9 +69,9 @@ class ThemeService
     /**
      * @see SocialAuthService::addSocialDriver
      */
-    public function addSocialDriver(string $driverName, array $config, string $socialiteHandler)
+    public function addSocialDriver(string $driverName, array $config, string $socialiteHandler, callable $configureForRedirect = null)
     {
         $socialAuthService = app()->make(SocialAuthService::class);
-        $socialAuthService->addSocialDriver($driverName, $config, $socialiteHandler);
+        $socialAuthService->addSocialDriver($driverName, $config, $socialiteHandler, $configureForRedirect);
     }
-}
\ No newline at end of file
+}