Page MenuHomePhabricator

D668.id2063.diff
No OneTemporary

D668.id2063.diff

diff --git a/app/services/console/CommandServiceProvider.php b/app/services/console/CommandServiceProvider.php
new file mode 100644
--- /dev/null
+++ b/app/services/console/CommandServiceProvider.php
@@ -0,0 +1,60 @@
+<?php namespace app\services\console;
+
+use spitfire\service\Provider;
+use spitfire\console\ConsoleKernel;
+
+/*
+ * The MIT License
+ *
+ * Copyright 2021 César de la Cal Bretschneider <cesar@magic3w.com>.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+class CommandProvider extends Provider
+{
+
+
+ public function register()
+ {
+ #This provider actually just loads routes and does not register any services
+ }
+
+ public function init()
+ {
+
+ /**
+ * If the kernel is not a console kernel, we are executing from a webserver and
+ * therefore there is no need to initialize the routes.
+ */
+ if (!(spitfire()->kernel() instanceof ConsoleKernel)) {
+ return;
+ }
+
+ /*
+ * Within this, we want to load our two routes files, routes.web and routes.api
+ *
+ * Please note that we expect these files to return a closure that accepts
+ * the router as parameter and then can pass our scoped router to these closures
+ * so they append the routes to the appropriate url spaces.
+ */
+ (include_once $approot . 'resources/commands.php')($router);
+ }
+
+}
\ No newline at end of file

File Metadata

Mime Type
text/plain
Expires
Tue, Apr 13, 7:02 AM (4 w, 8 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6079
Default Alt Text
D668.id2063.diff (2 KB)

Event Timeline