From 92b7dd3335a6572debeacfb5faa82c63a5e67888 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Fri, 8 Jun 2018 20:03:25 +0200 Subject: Some minor fixes --- main/app/system/Bakery/Bakery.php | 320 +++++++++++++++++++------------------- 1 file changed, 160 insertions(+), 160 deletions(-) (limited to 'main/app/system/Bakery/Bakery.php') 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 @@ -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; - } -} +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; + } +} -- cgit v1.2.3