aboutsummaryrefslogtreecommitdiffhomepage
path: root/main/app/system/Bakery/Bakery.php
diff options
context:
space:
mode:
Diffstat (limited to 'main/app/system/Bakery/Bakery.php')
-rw-r--r--main/app/system/Bakery/Bakery.php320
1 files changed, 160 insertions, 160 deletions
diff --git a/main/app/system/Bakery/Bakery.php b/main/app/system/Bakery/Bakery.php
index 273b25c..99a32b3 100644
--- a/main/app/system/Bakery/Bakery.php
+++ b/main/app/system/Bakery/Bakery.php
@@ -1,160 +1,160 @@
-<?php
-/**
- * UserFrosting (http://www.userfrosting.com)
- *
- * @link https://github.com/userfrosting/UserFrosting
- * @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
- */
-
-namespace UserFrosting\System\Bakery;
-
-use Symfony\Component\Console\Application;
-use UserFrosting\System\UserFrosting;
-use Illuminate\Support\Str;
-
-/**
- * Base class for UserFrosting Bakery CLI tools.
- *
- * @author Alex Weissman (https://alexanderweissman.com)
- */
-class Bakery
-{
- /**
- * @var $app Symfony\Component\Console\Application
- */
- protected $app;
-
- /**
- * @var ContainerInterface The global container object, which holds all your services.
- */
- protected $ci;
-
- /**
- * Constructor
- */
- public function __construct() {
- // Check for Sprinkles schema file
- $sprinklesFile = @file_get_contents(\UserFrosting\SPRINKLES_SCHEMA_FILE);
- if ($sprinklesFile === FALSE) {
- $sprinklesFile = $this->setupBaseSprinkleList();
- }
-
- // Create Symfony Console App
- $this->app = new Application("UserFrosting Bakery", \UserFrosting\VERSION);
-
- // Setup the sprinkles
- $uf = new UserFrosting();
-
- // Set argument as false, we are using the CLI
- $uf->setupSprinkles(FALSE);
-
- // Get the container
- $this->ci = $uf->getContainer();
-
- // Add each commands to the Console App
- $this->loadCommands();
- }
-
- /**
- * Run the Symfony Console App
- */
- public function run() {
- $this->app->run();
- }
-
- /**
- * Return the list of available commands for a specific sprinkle
- */
- protected function loadCommands() {
- // Get base Bakery command
- $commands = $this->getBakeryCommands();
-
- // Get the sprinkles commands
- $sprinkles = $this->ci->sprinkleManager->getSprinkleNames();
- foreach ($sprinkles as $sprinkle) {
- $commands = $commands->merge($this->getSprinkleCommands($sprinkle));
- }
-
- // Add commands to the App
- $commands->each(function ($command) {
- $instance = new $command();
- $instance->setContainer($this->ci);
- $this->app->add($instance);
- });
- }
-
- /**
- * Return the list of available commands for a specific sprinkle
- * Sprinkles commands should be located in `src/Bakery/`
- */
- protected function getSprinkleCommands($sprinkle) {
- // Find all the migration files
- $path = $this->commandDirectoryPath($sprinkle);
- $files = glob($path . "*.php");
- $commands = collect($files);
-
- // Transform the path into a class names
- $commands->transform(function ($file) use ($sprinkle, $path) {
- $className = basename($file, '.php');
- $sprinkleName = Str::studly($sprinkle);
- $className = "\\UserFrosting\\Sprinkle\\" . $sprinkleName . "\\Bakery\\" . $className;
- return $className;
- });
-
- return $commands;
- }
-
- /**
- * Return the list of available commands in system/Bakery/Command/
- */
- protected function getBakeryCommands() {
- // Find all the migration files
- $files = glob(\UserFrosting\APP_DIR . "/system/Bakery/Command/" . "*.php");
- $commands = collect($files);
-
- // Transform the path into a class names
- $commands->transform(function ($file) {
- $className = basename($file, '.php');
- $className = "\\UserFrosting\\System\\Bakery\\Command\\" . $className;
- return $className;
- });
-
- return $commands;
- }
-
- /**
- * Returns the path of the Migration directory.
- *
- * @access protected
- * @param mixed $sprinkleName
- * @return void
- */
- protected function commandDirectoryPath($sprinkleName) {
- return \UserFrosting\SPRINKLES_DIR .
- \UserFrosting\DS .
- $sprinkleName .
- \UserFrosting\DS .
- \UserFrosting\SRC_DIR_NAME .
- "/Bakery/";
- }
-
- /**
- * Write the base Sprinkles schema file if it doesn't exist.
- *
- * @access protected
- * @return void
- */
- protected function setupBaseSprinkleList() {
- $model = \UserFrosting\APP_DIR . '/sprinkles.example.json';
- $destination = \UserFrosting\SPRINKLES_SCHEMA_FILE;
- $sprinklesModelFile = @file_get_contents($model);
- if ($sprinklesModelFile === FALSE) {
- $this->io->error("File `$sprinklesModelFile` not found. Please create '$destination' manually and try again.");
- exit(1);
- }
-
- file_put_contents($destination, $sprinklesModelFile);
-
- return $sprinklesModelFile;
- }
-}
+<?php
+/**
+ * UserFrosting (http://www.userfrosting.com)
+ *
+ * @link https://github.com/userfrosting/UserFrosting
+ * @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
+ */
+
+namespace UserFrosting\System\Bakery;
+
+use Symfony\Component\Console\Application;
+use UserFrosting\System\UserFrosting;
+use Illuminate\Support\Str;
+
+/**
+ * Base class for UserFrosting Bakery CLI tools.
+ *
+ * @author Alex Weissman (https://alexanderweissman.com)
+ */
+class Bakery
+{
+ /**
+ * @var $app Symfony\Component\Console\Application
+ */
+ protected $app;
+
+ /**
+ * @var ContainerInterface The global container object, which holds all your services.
+ */
+ protected $ci;
+
+ /**
+ * Constructor
+ */
+ public function __construct() {
+ // Check for Sprinkles schema file
+ $sprinklesFile = @file_get_contents(\UserFrosting\SPRINKLES_SCHEMA_FILE);
+ if ($sprinklesFile === FALSE) {
+ $sprinklesFile = $this->setupBaseSprinkleList();
+ }
+
+ // Create Symfony Console App
+ $this->app = new Application("UserFrosting Bakery", \UserFrosting\VERSION);
+
+ // Setup the sprinkles
+ $uf = new UserFrosting();
+
+ // Set argument as false, we are using the CLI
+ $uf->setupSprinkles(FALSE);
+
+ // Get the container
+ $this->ci = $uf->getContainer();
+
+ // Add each commands to the Console App
+ $this->loadCommands();
+ }
+
+ /**
+ * Run the Symfony Console App
+ */
+ public function run() {
+ $this->app->run();
+ }
+
+ /**
+ * Return the list of available commands for a specific sprinkle
+ */
+ protected function loadCommands() {
+ // Get base Bakery command
+ $commands = $this->getBakeryCommands();
+
+ // Get the sprinkles commands
+ $sprinkles = $this->ci->sprinkleManager->getSprinkleNames();
+ foreach ($sprinkles as $sprinkle) {
+ $commands = $commands->merge($this->getSprinkleCommands($sprinkle));
+ }
+
+ // Add commands to the App
+ $commands->each(function ($command) {
+ $instance = new $command();
+ $instance->setContainer($this->ci);
+ $this->app->add($instance);
+ });
+ }
+
+ /**
+ * Return the list of available commands for a specific sprinkle
+ * Sprinkles commands should be located in `src/Bakery/`
+ */
+ protected function getSprinkleCommands($sprinkle) {
+ // Find all the migration files
+ $path = $this->commandDirectoryPath($sprinkle);
+ $files = glob($path . "*.php");
+ $commands = collect($files);
+
+ // Transform the path into a class names
+ $commands->transform(function ($file) use ($sprinkle, $path) {
+ $className = basename($file, '.php');
+ $sprinkleName = Str::studly($sprinkle);
+ $className = "\\UserFrosting\\Sprinkle\\" . $sprinkleName . "\\Bakery\\" . $className;
+ return $className;
+ });
+
+ return $commands;
+ }
+
+ /**
+ * Return the list of available commands in system/Bakery/Command/
+ */
+ protected function getBakeryCommands() {
+ // Find all the migration files
+ $files = glob(\UserFrosting\APP_DIR . "/system/Bakery/Command/" . "*.php");
+ $commands = collect($files);
+
+ // Transform the path into a class names
+ $commands->transform(function ($file) {
+ $className = basename($file, '.php');
+ $className = "\\UserFrosting\\System\\Bakery\\Command\\" . $className;
+ return $className;
+ });
+
+ return $commands;
+ }
+
+ /**
+ * Returns the path of the Migration directory.
+ *
+ * @access protected
+ * @param mixed $sprinkleName
+ * @return void
+ */
+ protected function commandDirectoryPath($sprinkleName) {
+ return \UserFrosting\SPRINKLES_DIR .
+ \UserFrosting\DS .
+ $sprinkleName .
+ \UserFrosting\DS .
+ \UserFrosting\SRC_DIR_NAME .
+ "/Bakery/";
+ }
+
+ /**
+ * Write the base Sprinkles schema file if it doesn't exist.
+ *
+ * @access protected
+ * @return void
+ */
+ protected function setupBaseSprinkleList() {
+ $model = \UserFrosting\APP_DIR . '/sprinkles.example.json';
+ $destination = \UserFrosting\SPRINKLES_SCHEMA_FILE;
+ $sprinklesModelFile = @file_get_contents($model);
+ if ($sprinklesModelFile === FALSE) {
+ $this->io->error("File `$sprinklesModelFile` not found. Please create '$destination' manually and try again.");
+ exit(1);
+ }
+
+ file_put_contents($destination, $sprinklesModelFile);
+
+ return $sprinklesModelFile;
+ }
+}