aboutsummaryrefslogtreecommitdiffhomepage
path: root/main/app/system
diff options
context:
space:
mode:
Diffstat (limited to 'main/app/system')
-rw-r--r--main/app/system/Bakery/Bakery.php44
-rw-r--r--main/app/system/Bakery/BaseCommand.php7
-rw-r--r--main/app/system/Bakery/Command/Bake.php11
-rw-r--r--main/app/system/Bakery/Command/BuildAssets.php35
-rw-r--r--main/app/system/Bakery/Command/ClearCache.php18
-rw-r--r--main/app/system/Bakery/Command/Debug.php33
-rw-r--r--main/app/system/Bakery/Command/Migrate.php13
-rw-r--r--main/app/system/Bakery/Command/MigrateRefresh.php15
-rw-r--r--main/app/system/Bakery/Command/MigrateReset.php13
-rw-r--r--main/app/system/Bakery/Command/MigrateRollback.php15
-rw-r--r--main/app/system/Bakery/Command/Setup.php31
-rw-r--r--main/app/system/Bakery/Command/Test.php11
-rw-r--r--main/app/system/Bakery/DatabaseTest.php10
-rw-r--r--main/app/system/Bakery/Migration.php13
-rw-r--r--main/app/system/Bakery/Migrator.php72
-rw-r--r--main/app/system/Database/Migrations/v410/MigrationTable.php7
-rw-r--r--main/app/system/Database/Model/Migrations.php6
-rw-r--r--main/app/system/Facade.php59
-rw-r--r--main/app/system/ServicesProvider.php4
-rw-r--r--main/app/system/SlimAppEvent.php7
-rw-r--r--main/app/system/Sprinkle/Sprinkle.php7
-rw-r--r--main/app/system/Sprinkle/SprinkleManager.php43
-rw-r--r--main/app/system/UserFrosting.php34
23 files changed, 214 insertions, 294 deletions
diff --git a/main/app/system/Bakery/Bakery.php b/main/app/system/Bakery/Bakery.php
index 8be8480..273b25c 100644
--- a/main/app/system/Bakery/Bakery.php
+++ b/main/app/system/Bakery/Bakery.php
@@ -5,6 +5,7 @@
* @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;
@@ -31,11 +32,10 @@ class Bakery
/**
* Constructor
*/
- public function __construct()
- {
+ public function __construct() {
// Check for Sprinkles schema file
$sprinklesFile = @file_get_contents(\UserFrosting\SPRINKLES_SCHEMA_FILE);
- if ($sprinklesFile === false) {
+ if ($sprinklesFile === FALSE) {
$sprinklesFile = $this->setupBaseSprinkleList();
}
@@ -46,7 +46,7 @@ class Bakery
$uf = new UserFrosting();
// Set argument as false, we are using the CLI
- $uf->setupSprinkles(false);
+ $uf->setupSprinkles(FALSE);
// Get the container
$this->ci = $uf->getContainer();
@@ -58,16 +58,14 @@ class Bakery
/**
* Run the Symfony Console App
*/
- public function run()
- {
+ public function run() {
$this->app->run();
}
/**
* Return the list of available commands for a specific sprinkle
*/
- protected function loadCommands()
- {
+ protected function loadCommands() {
// Get base Bakery command
$commands = $this->getBakeryCommands();
@@ -78,7 +76,7 @@ class Bakery
}
// Add commands to the App
- $commands->each(function($command) {
+ $commands->each(function ($command) {
$instance = new $command();
$instance->setContainer($this->ci);
$this->app->add($instance);
@@ -89,8 +87,7 @@ class Bakery
* Return the list of available commands for a specific sprinkle
* Sprinkles commands should be located in `src/Bakery/`
*/
- protected function getSprinkleCommands($sprinkle)
- {
+ protected function getSprinkleCommands($sprinkle) {
// Find all the migration files
$path = $this->commandDirectoryPath($sprinkle);
$files = glob($path . "*.php");
@@ -100,7 +97,7 @@ class Bakery
$commands->transform(function ($file) use ($sprinkle, $path) {
$className = basename($file, '.php');
$sprinkleName = Str::studly($sprinkle);
- $className = "\\UserFrosting\\Sprinkle\\".$sprinkleName."\\Bakery\\".$className;
+ $className = "\\UserFrosting\\Sprinkle\\" . $sprinkleName . "\\Bakery\\" . $className;
return $className;
});
@@ -110,8 +107,7 @@ class Bakery
/**
* Return the list of available commands in system/Bakery/Command/
*/
- protected function getBakeryCommands()
- {
+ protected function getBakeryCommands() {
// Find all the migration files
$files = glob(\UserFrosting\APP_DIR . "/system/Bakery/Command/" . "*.php");
$commands = collect($files);
@@ -119,7 +115,7 @@ class Bakery
// Transform the path into a class names
$commands->transform(function ($file) {
$className = basename($file, '.php');
- $className = "\\UserFrosting\\System\\Bakery\\Command\\".$className;
+ $className = "\\UserFrosting\\System\\Bakery\\Command\\" . $className;
return $className;
});
@@ -133,14 +129,13 @@ class Bakery
* @param mixed $sprinkleName
* @return void
*/
- protected function commandDirectoryPath($sprinkleName)
- {
+ protected function commandDirectoryPath($sprinkleName) {
return \UserFrosting\SPRINKLES_DIR .
- \UserFrosting\DS .
- $sprinkleName .
- \UserFrosting\DS .
- \UserFrosting\SRC_DIR_NAME .
- "/Bakery/";
+ \UserFrosting\DS .
+ $sprinkleName .
+ \UserFrosting\DS .
+ \UserFrosting\SRC_DIR_NAME .
+ "/Bakery/";
}
/**
@@ -149,12 +144,11 @@ class Bakery
* @access protected
* @return void
*/
- protected function setupBaseSprinkleList()
- {
+ protected function setupBaseSprinkleList() {
$model = \UserFrosting\APP_DIR . '/sprinkles.example.json';
$destination = \UserFrosting\SPRINKLES_SCHEMA_FILE;
$sprinklesModelFile = @file_get_contents($model);
- if ($sprinklesModelFile === false) {
+ if ($sprinklesModelFile === FALSE) {
$this->io->error("File `$sprinklesModelFile` not found. Please create '$destination' manually and try again.");
exit(1);
}
diff --git a/main/app/system/Bakery/BaseCommand.php b/main/app/system/Bakery/BaseCommand.php
index 1a59141..bc1c005 100644
--- a/main/app/system/Bakery/BaseCommand.php
+++ b/main/app/system/Bakery/BaseCommand.php
@@ -5,6 +5,7 @@
* @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\Command\Command;
@@ -42,8 +43,7 @@ abstract class BaseCommand extends Command
/**
* {@inheritDoc}
*/
- protected function initialize(InputInterface $input, OutputInterface $output)
- {
+ protected function initialize(InputInterface $input, OutputInterface $output) {
$this->io = new SymfonyStyle($input, $output);
$this->projectRoot = \UserFrosting\ROOT_DIR;
}
@@ -51,8 +51,7 @@ abstract class BaseCommand extends Command
/**
* Setup the global container object
*/
- public function setContainer(ContainerInterface $ci)
- {
+ public function setContainer(ContainerInterface $ci) {
$this->ci = $ci;
}
}
diff --git a/main/app/system/Bakery/Command/Bake.php b/main/app/system/Bakery/Command/Bake.php
index 5dc0e27..d12dccd 100644
--- a/main/app/system/Bakery/Command/Bake.php
+++ b/main/app/system/Bakery/Command/Bake.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System\Bakery\Command;
use Symfony\Component\Console\Input\InputInterface;
@@ -42,18 +43,16 @@ class Bake extends BaseCommand
/**
* {@inheritDoc}
*/
- protected function configure()
- {
+ protected function configure() {
$this->setName("bake")
- ->setDescription("UserFrosting installation command")
- ->setHelp("This command combine the <info>debug</info>, <info>migrate</info> and <info>build-assets</info> commands.");
+ ->setDescription("UserFrosting installation command")
+ ->setHelp("This command combine the <info>debug</info>, <info>migrate</info> and <info>build-assets</info> commands.");
}
/**
* {@inheritDoc}
*/
- protected function execute(InputInterface $input, OutputInterface $output)
- {
+ protected function execute(InputInterface $input, OutputInterface $output) {
$this->io->writeln("<info>{$this->title}</info>");
$command = $this->getApplication()->find('setup');
diff --git a/main/app/system/Bakery/Command/BuildAssets.php b/main/app/system/Bakery/Command/BuildAssets.php
index 055fa43..4a1ab99 100644
--- a/main/app/system/Bakery/Command/BuildAssets.php
+++ b/main/app/system/Bakery/Command/BuildAssets.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System\Bakery\Command;
use Symfony\Component\Console\Input\InputInterface;
@@ -29,20 +30,18 @@ class BuildAssets extends BaseCommand
/**
* {@inheritDoc}
*/
- protected function configure()
- {
+ protected function configure() {
$this->setName("build-assets")
- ->setDescription("Build the assets using node and npm")
- ->setHelp("The build directory contains the scripts and configuration files required to download Javascript, CSS, and other assets used by UserFrosting. This command will install Gulp, Bower, and several other required npm packages locally. With <info>npm</info> set up with all of its required packages, it can be use it to automatically download and install the assets in the correct directories. For more info, see <comment>https://learn.userfrosting.com/basics/installation</comment>")
- ->addOption("compile", "c", InputOption::VALUE_NONE, "Compile the assets and asset bundles for production environment")
- ->addOption("force", "f", InputOption::VALUE_NONE, "Force assets compilation by deleting cached data and installed assets before proceeding");
+ ->setDescription("Build the assets using node and npm")
+ ->setHelp("The build directory contains the scripts and configuration files required to download Javascript, CSS, and other assets used by UserFrosting. This command will install Gulp, Bower, and several other required npm packages locally. With <info>npm</info> set up with all of its required packages, it can be use it to automatically download and install the assets in the correct directories. For more info, see <comment>https://learn.userfrosting.com/basics/installation</comment>")
+ ->addOption("compile", "c", InputOption::VALUE_NONE, "Compile the assets and asset bundles for production environment")
+ ->addOption("force", "f", InputOption::VALUE_NONE, "Force assets compilation by deleting cached data and installed assets before proceeding");
}
/**
* {@inheritDoc}
*/
- protected function execute(InputInterface $input, OutputInterface $output)
- {
+ protected function execute(InputInterface $input, OutputInterface $output) {
// Display header,
$this->io->title("UserFrosting's Assets Builder");
@@ -76,8 +75,7 @@ class BuildAssets extends BaseCommand
* @access protected
* @return void
*/
- protected function npmInstall()
- {
+ protected function npmInstall() {
$this->io->section("<info>Installing npm dependencies</info>");
$this->io->writeln("> <comment>npm install</comment>");
@@ -94,8 +92,7 @@ class BuildAssets extends BaseCommand
* @access protected
* @return void
*/
- protected function assetsInstall()
- {
+ protected function assetsInstall() {
$this->io->section("Installing assets bundles");
$this->io->writeln("> <comment>npm run uf-assets-install</comment>");
passthru("npm run uf-assets-install --prefix " . $this->buildPath);
@@ -107,8 +104,7 @@ class BuildAssets extends BaseCommand
* @access protected
* @return void
*/
- protected function buildAssets()
- {
+ protected function buildAssets() {
$this->io->section("Building assets for production");
$this->io->writeln("> <comment>npm run uf-bundle-build</comment>");
@@ -127,15 +123,14 @@ class BuildAssets extends BaseCommand
* @access protected
* @return void
*/
- protected function checkAssets()
- {
+ protected function checkAssets() {
$this->io->section("Testing assets installation");
// Get path and vendor files
$vendorPath = \UserFrosting\SPRINKLES_DIR . "/core/assets/vendor/*";
$coreVendorFiles = glob($vendorPath);
- if (!$coreVendorFiles){
+ if (!$coreVendorFiles) {
$this->io->error("Assets installation seems to have failed. Directory `$vendorPath` is empty, but it shouldn't be. Check the above log for any errors.");
exit(1);
}
@@ -156,8 +151,7 @@ class BuildAssets extends BaseCommand
* @access protected
* @return void
*/
- protected function clean()
- {
+ protected function clean() {
$this->io->section("Cleaning cached data");
$this->io->writeln("> <comment>npm run uf-clean</comment>");
passthru("npm run uf-clean --prefix " . $this->buildPath);
@@ -169,8 +163,7 @@ class BuildAssets extends BaseCommand
* @access protected
* @return bool
*/
- protected function isProduction()
- {
+ protected function isProduction() {
// N.B.: Need to touch the config service first to load dotenv values
$config = $this->ci->config;
$mode = getenv("UF_MODE") ?: '';
diff --git a/main/app/system/Bakery/Command/ClearCache.php b/main/app/system/Bakery/Command/ClearCache.php
index d38f382..4d30209 100644
--- a/main/app/system/Bakery/Command/ClearCache.php
+++ b/main/app/system/Bakery/Command/ClearCache.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System\Bakery\Command;
use Symfony\Component\Console\Input\InputInterface;
@@ -24,17 +25,15 @@ class ClearCache extends BaseCommand
/**
* {@inheritDoc}
*/
- protected function configure()
- {
+ protected function configure() {
$this->setName("clear-cache")
- ->setDescription("Clears the application cache. Includes cache service, Twig and Router cached data");
+ ->setDescription("Clears the application cache. Includes cache service, Twig and Router cached data");
}
/**
* {@inheritDoc}
*/
- protected function execute(InputInterface $input, OutputInterface $output)
- {
+ protected function execute(InputInterface $input, OutputInterface $output) {
$this->io->title("Clearing cache");
// Clear normal cache
@@ -65,8 +64,7 @@ class ClearCache extends BaseCommand
* @access protected
* @return void
*/
- protected function clearIlluminateCache()
- {
+ protected function clearIlluminateCache() {
$this->ci->cache->flush();
}
@@ -76,8 +74,7 @@ class ClearCache extends BaseCommand
* @access protected
* @return bool true/false if operation is successfull
*/
- protected function clearTwigCache()
- {
+ protected function clearTwigCache() {
$cacheHelper = new CacheHelper($this->ci);
return $cacheHelper->clearCache();
}
@@ -88,8 +85,7 @@ class ClearCache extends BaseCommand
* @access protected
* @return bool true/false if operation is successfull
*/
- protected function clearRouterCache()
- {
+ protected function clearRouterCache() {
return $this->ci->router->clearCache();
}
} \ No newline at end of file
diff --git a/main/app/system/Bakery/Command/Debug.php b/main/app/system/Bakery/Command/Debug.php
index 4e8a3e4..60565a4 100644
--- a/main/app/system/Bakery/Command/Debug.php
+++ b/main/app/system/Bakery/Command/Debug.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System\Bakery\Command;
use Symfony\Component\Console\Input\InputInterface;
@@ -26,18 +27,16 @@ class Debug extends BaseCommand
/**
* {@inheritDoc}
*/
- protected function configure()
- {
+ protected function configure() {
$this->setName("debug")
- ->setDescription("Test the UserFrosting installation and setup the database")
- ->setHelp("This command is used to check if the various dependencies of UserFrosting are met and display useful debugging information. \nIf any error occurs, check out the online documentation for more info about that error. \nThis command also provide the necessary tools to setup the database credentials");
+ ->setDescription("Test the UserFrosting installation and setup the database")
+ ->setHelp("This command is used to check if the various dependencies of UserFrosting are met and display useful debugging information. \nIf any error occurs, check out the online documentation for more info about that error. \nThis command also provide the necessary tools to setup the database credentials");
}
/**
* {@inheritDoc}
*/
- protected function execute(InputInterface $input, OutputInterface $output)
- {
+ protected function execute(InputInterface $input, OutputInterface $output) {
// Display header,
$this->io->title("UserFrosting");
$this->io->writeln("UserFrosing version : " . \UserFrosting\VERSION);
@@ -67,11 +66,10 @@ class Debug extends BaseCommand
* @access public
* @return void
*/
- protected function checkPhpVersion()
- {
+ protected function checkPhpVersion() {
$this->io->writeln("PHP Version : " . phpversion());
if (version_compare(phpversion(), \UserFrosting\PHP_MIN_VERSION, '<')) {
- $this->io->error("UserFrosting requires php version ".\UserFrosting\PHP_MIN_VERSION." or above. You'll need to update you PHP version before you can continue.");
+ $this->io->error("UserFrosting requires php version " . \UserFrosting\PHP_MIN_VERSION . " or above. You'll need to update you PHP version before you can continue.");
exit(1);
}
}
@@ -82,8 +80,7 @@ class Debug extends BaseCommand
* @access public
* @return void
*/
- protected function checkNodeVersion()
- {
+ protected function checkNodeVersion() {
$npmVersion = trim(exec('node -v'));
$this->io->writeln("Node Version : $npmVersion");
@@ -99,8 +96,7 @@ class Debug extends BaseCommand
* @access public
* @return void
*/
- protected function checkNpmVersion()
- {
+ protected function checkNpmVersion() {
$npmVersion = trim(exec('npm -v'));
$this->io->writeln("NPM Version : $npmVersion");
@@ -117,12 +113,11 @@ class Debug extends BaseCommand
* @access protected
* @return void
*/
- protected function listSprinkles()
- {
+ protected function listSprinkles() {
// Check for Sprinkles schema file
$path = \UserFrosting\SPRINKLES_SCHEMA_FILE;
$sprinklesFile = @file_get_contents($path);
- if ($sprinklesFile === false) {
+ if ($sprinklesFile === FALSE) {
$this->io->error("The file `$path` not found.");
}
@@ -145,8 +140,7 @@ class Debug extends BaseCommand
* @access protected
* @return void
*/
- protected function checkDatabase()
- {
+ protected function checkDatabase() {
$this->io->section("Testing database connection...");
try {
@@ -166,8 +160,7 @@ class Debug extends BaseCommand
* @access protected
* @return void
*/
- protected function showConfig()
- {
+ protected function showConfig() {
// Get config
$config = $this->ci->config;
diff --git a/main/app/system/Bakery/Command/Migrate.php b/main/app/system/Bakery/Command/Migrate.php
index c0a5b4f..e398628 100644
--- a/main/app/system/Bakery/Command/Migrate.php
+++ b/main/app/system/Bakery/Command/Migrate.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System\Bakery\Command;
use Symfony\Component\Console\Input\InputInterface;
@@ -25,19 +26,17 @@ class Migrate extends BaseCommand
/**
* {@inheritDoc}
*/
- protected function configure()
- {
+ protected function configure() {
$this->setName("migrate")
- ->setDescription("Perform database migration")
- ->setHelp("This command runs all the pending database migrations.")
- ->addOption('pretend', 'p', InputOption::VALUE_NONE, 'Run migrations in "dry run" mode');
+ ->setDescription("Perform database migration")
+ ->setHelp("This command runs all the pending database migrations.")
+ ->addOption('pretend', 'p', InputOption::VALUE_NONE, 'Run migrations in "dry run" mode');
}
/**
* {@inheritDoc}
*/
- protected function execute(InputInterface $input, OutputInterface $output)
- {
+ protected function execute(InputInterface $input, OutputInterface $output) {
$this->io->title("UserFrosting's Migrator");
$pretend = $input->getOption('pretend');
diff --git a/main/app/system/Bakery/Command/MigrateRefresh.php b/main/app/system/Bakery/Command/MigrateRefresh.php
index 3d18c41..eb05b61 100644
--- a/main/app/system/Bakery/Command/MigrateRefresh.php
+++ b/main/app/system/Bakery/Command/MigrateRefresh.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System\Bakery\Command;
use Symfony\Component\Console\Input\InputInterface;
@@ -25,20 +26,18 @@ class MigrateRefresh extends BaseCommand
/**
* {@inheritDoc}
*/
- protected function configure()
- {
+ protected function configure() {
$this->setName("migrate:refresh")
- ->setDescription("Rollback the last migration operation and run it up again")
- ->addOption('steps', 's', InputOption::VALUE_REQUIRED, 'Number of steps to rollback', 1)
- ->addOption('sprinkle', null, InputOption::VALUE_REQUIRED, 'The sprinkle to rollback', "")
- ->addOption('pretend', 'p', InputOption::VALUE_NONE, 'Run migrations in "dry run" mode');
+ ->setDescription("Rollback the last migration operation and run it up again")
+ ->addOption('steps', 's', InputOption::VALUE_REQUIRED, 'Number of steps to rollback', 1)
+ ->addOption('sprinkle', NULL, InputOption::VALUE_REQUIRED, 'The sprinkle to rollback', "")
+ ->addOption('pretend', 'p', InputOption::VALUE_NONE, 'Run migrations in "dry run" mode');
}
/**
* {@inheritDoc}
*/
- protected function execute(InputInterface $input, OutputInterface $output)
- {
+ protected function execute(InputInterface $input, OutputInterface $output) {
$this->io->title("Migration refresh");
$step = $input->getOption('steps');
diff --git a/main/app/system/Bakery/Command/MigrateReset.php b/main/app/system/Bakery/Command/MigrateReset.php
index 9e38cbb..ad66a6c 100644
--- a/main/app/system/Bakery/Command/MigrateReset.php
+++ b/main/app/system/Bakery/Command/MigrateReset.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System\Bakery\Command;
use Symfony\Component\Console\Input\InputInterface;
@@ -25,19 +26,17 @@ class MigrateReset extends BaseCommand
/**
* {@inheritDoc}
*/
- protected function configure()
- {
+ protected function configure() {
$this->setName("migrate:reset")
- ->setDescription("Reset the whole database to an empty state")
- ->addOption('sprinkle', null, InputOption::VALUE_REQUIRED, 'The sprinkle to rollback', "")
- ->addOption('pretend', 'p', InputOption::VALUE_NONE, 'Run migrations in "dry run" mode');
+ ->setDescription("Reset the whole database to an empty state")
+ ->addOption('sprinkle', NULL, InputOption::VALUE_REQUIRED, 'The sprinkle to rollback', "")
+ ->addOption('pretend', 'p', InputOption::VALUE_NONE, 'Run migrations in "dry run" mode');
}
/**
* {@inheritDoc}
*/
- protected function execute(InputInterface $input, OutputInterface $output)
- {
+ protected function execute(InputInterface $input, OutputInterface $output) {
$this->io->title("Migration reset");
$sprinkle = $input->getOption('sprinkle');
diff --git a/main/app/system/Bakery/Command/MigrateRollback.php b/main/app/system/Bakery/Command/MigrateRollback.php
index 916f5ee..ca2302a 100644
--- a/main/app/system/Bakery/Command/MigrateRollback.php
+++ b/main/app/system/Bakery/Command/MigrateRollback.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System\Bakery\Command;
use Symfony\Component\Console\Input\InputInterface;
@@ -25,20 +26,18 @@ class MigrateRollback extends BaseCommand
/**
* {@inheritDoc}
*/
- protected function configure()
- {
+ protected function configure() {
$this->setName("migrate:rollback")
- ->setDescription("Rollback last database migration")
- ->addOption('steps', 's', InputOption::VALUE_REQUIRED, 'Number of steps to rollback', 1)
- ->addOption('sprinkle', null, InputOption::VALUE_REQUIRED, 'The sprinkle to rollback', "")
- ->addOption('pretend', 'p', InputOption::VALUE_NONE, 'Run migrations in "dry run" mode');
+ ->setDescription("Rollback last database migration")
+ ->addOption('steps', 's', InputOption::VALUE_REQUIRED, 'Number of steps to rollback', 1)
+ ->addOption('sprinkle', NULL, InputOption::VALUE_REQUIRED, 'The sprinkle to rollback', "")
+ ->addOption('pretend', 'p', InputOption::VALUE_NONE, 'Run migrations in "dry run" mode');
}
/**
* {@inheritDoc}
*/
- protected function execute(InputInterface $input, OutputInterface $output)
- {
+ protected function execute(InputInterface $input, OutputInterface $output) {
$this->io->title("Migration rollback");
$step = $input->getOption('steps');
diff --git a/main/app/system/Bakery/Command/Setup.php b/main/app/system/Bakery/Command/Setup.php
index b489ce2..afea37b 100644
--- a/main/app/system/Bakery/Command/Setup.php
+++ b/main/app/system/Bakery/Command/Setup.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System\Bakery\Command;
use Illuminate\Database\Capsule\Manager as Capsule;
@@ -25,24 +26,22 @@ class Setup extends BaseCommand
/**
* envfile path
*/
- protected $envPath = \UserFrosting\APP_DIR. '/.env';
+ protected $envPath = \UserFrosting\APP_DIR . '/.env';
/**
* {@inheritDoc}
*/
- protected function configure()
- {
+ protected function configure() {
$this->setName("setup")
- ->setDescription("UserFrosting configuration wizard")
- ->setHelp("Helper command to setup the database and email configuration. This can also be done manually by editing the <comment>app/.env</comment> file or using global server environment variables.")
- ->addOption("force", "f", InputOption::VALUE_NONE, "If `.env` file exist, force setup to run again");
+ ->setDescription("UserFrosting configuration wizard")
+ ->setHelp("Helper command to setup the database and email configuration. This can also be done manually by editing the <comment>app/.env</comment> file or using global server environment variables.")
+ ->addOption("force", "f", InputOption::VALUE_NONE, "If `.env` file exist, force setup to run again");
}
/**
* {@inheritDoc}
*/
- protected function execute(InputInterface $input, OutputInterface $output)
- {
+ protected function execute(InputInterface $input, OutputInterface $output) {
// Get config
$config = $this->ci->config;
@@ -75,8 +74,7 @@ class Setup extends BaseCommand
* @access public
* @return void
*/
- public function setupEnv()
- {
+ public function setupEnv() {
// Get config
$config = $this->ci->config;
@@ -112,7 +110,7 @@ class Setup extends BaseCommand
// Use custom validator to accept empty password
return $password;
});
-
+
$dbParams = [
'driver' => $driverName,
'host' => $host,
@@ -133,10 +131,10 @@ class Setup extends BaseCommand
$conn = $capsule->getConnection();
$conn->getPdo();
$this->io->success("Database connection successful");
- $success = true;
+ $success = TRUE;
} catch (\PDOException $e) {
- $message = "Could not connect to the database '{$dbParams['username']}@{$dbParams['host']}/{$dbParams['database']}':".PHP_EOL;
- $message .= "Exception: " . $e->getMessage() . PHP_EOL.PHP_EOL;
+ $message = "Could not connect to the database '{$dbParams['username']}@{$dbParams['host']}/{$dbParams['database']}':" . PHP_EOL;
+ $message .= "Exception: " . $e->getMessage() . PHP_EOL . PHP_EOL;
$message .= "Please check your database configuration and/or google the exception shown above and run the command again.";
$this->io->error($message);
exit(1);
@@ -191,8 +189,7 @@ class Setup extends BaseCommand
* @access protected
* @return void
*/
- protected function databaseDrivers()
- {
+ protected function databaseDrivers() {
return collect([
[
"driver" => "mysql",
@@ -216,7 +213,7 @@ class Setup extends BaseCommand
"driver" => "sqlite",
"name" => "SQLite",
"defaultDBName" => \UserFrosting\DB_DIR . \UserFrosting\DS . 'userfrosting.db',
- "defaultPort" => null
+ "defaultPort" => NULL
]
]);
}
diff --git a/main/app/system/Bakery/Command/Test.php b/main/app/system/Bakery/Command/Test.php
index 553fddd..dde187f 100644
--- a/main/app/system/Bakery/Command/Test.php
+++ b/main/app/system/Bakery/Command/Test.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System\Bakery\Command;
use Symfony\Component\Console\Input\InputInterface;
@@ -29,18 +30,16 @@ class Test extends BaseCommand
/**
* {@inheritDoc}
*/
- protected function configure()
- {
+ protected function configure() {
$this->setName("test")
- ->setDescription("Run tests")
- ->setHelp("Run php unit tests");
+ ->setDescription("Run tests")
+ ->setHelp("Run php unit tests");
}
/**
* {@inheritDoc}
*/
- protected function execute(InputInterface $input, OutputInterface $output)
- {
+ protected function execute(InputInterface $input, OutputInterface $output) {
$this->io->title("UserFrosting's Tester");
// Get command
diff --git a/main/app/system/Bakery/DatabaseTest.php b/main/app/system/Bakery/DatabaseTest.php
index 0e4f3bf..91d2c2b 100644
--- a/main/app/system/Bakery/DatabaseTest.php
+++ b/main/app/system/Bakery/DatabaseTest.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System\Bakery;
use Illuminate\Database\Capsule\Manager as Capsule;
@@ -23,8 +24,7 @@ trait DatabaseTest
* @access protected
* @return bool True if success
*/
- protected function testDB()
- {
+ protected function testDB() {
// Boot db
$this->ci->db;
@@ -41,12 +41,12 @@ trait DatabaseTest
try {
Capsule::connection()->getPdo();
} catch (\PDOException $e) {
- $message = "Could not connect to the database '{$dbParams['username']}@{$dbParams['host']}/{$dbParams['database']}':".PHP_EOL;
- $message .= "Exception: " . $e->getMessage() . PHP_EOL.PHP_EOL;
+ $message = "Could not connect to the database '{$dbParams['username']}@{$dbParams['host']}/{$dbParams['database']}':" . PHP_EOL;
+ $message .= "Exception: " . $e->getMessage() . PHP_EOL . PHP_EOL;
$message .= "Please check your database configuration and/or google the exception shown above and run command again.";
throw new \Exception($message);
}
- return true;
+ return TRUE;
}
} \ No newline at end of file
diff --git a/main/app/system/Bakery/Migration.php b/main/app/system/Bakery/Migration.php
index e6c6ae0..7c4ef62 100644
--- a/main/app/system/Bakery/Migration.php
+++ b/main/app/system/Bakery/Migration.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System\Bakery;
use Illuminate\Database\Schema\Builder;
@@ -41,8 +42,7 @@ abstract class Migration
* @param Illuminate\Database\Schema\Builder $schema
* @return void
*/
- public function __construct(Builder $schema, SymfonyStyle $io)
- {
+ public function __construct(Builder $schema, SymfonyStyle $io) {
$this->schema = $schema;
$this->io = $io;
}
@@ -50,15 +50,18 @@ abstract class Migration
/**
* Method to apply changes to the database
*/
- public function up() {}
+ public function up() {
+ }
/**
* Method to revert changes applied by the `up` method
*/
- public function down() {}
+ public function down() {
+ }
/**
* Method to seed new information to the database
*/
- public function seed() {}
+ public function seed() {
+ }
}
diff --git a/main/app/system/Bakery/Migrator.php b/main/app/system/Bakery/Migrator.php
index 611f73f..ff00b0b 100644
--- a/main/app/system/Bakery/Migrator.php
+++ b/main/app/system/Bakery/Migrator.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System\Bakery;
use Illuminate\Database\Capsule\Manager as Capsule;
@@ -44,7 +45,7 @@ class Migrator
*/
protected $schema;
- /**
+ /**
* @var String table The name of the migration table
*/
protected $table = "migrations";
@@ -91,8 +92,7 @@ class Migrator
* @param ContainerInterface $ci
* @return void
*/
- public function __construct(SymfonyStyle $io, ContainerInterface $ci)
- {
+ public function __construct(SymfonyStyle $io, ContainerInterface $ci) {
$this->io = $io;
$this->ci = $ci;
@@ -120,8 +120,7 @@ class Migrator
* @param bool $pretend (default: false)
* @return void
*/
- public function runUp($pretend = false)
- {
+ public function runUp($pretend = FALSE) {
// Get installed migrations and pluck by class name. We only need this for now
$migrations = Migrations::get();
$this->installed = $migrations->pluck('migration');
@@ -192,8 +191,7 @@ class Migrator
* @param bool $pretend (default: false)
* @return void
*/
- public function runDown($step = 1, $sprinkle = "", $pretend = false)
- {
+ public function runDown($step = 1, $sprinkle = "", $pretend = FALSE) {
// Can't go furhter down than 1 step
if ($step <= 0 && $step != -1) {
throw new \InvalidArgumentException("Step can't be 0 or less");
@@ -234,7 +232,7 @@ class Migrator
$this->io->listing($migrations->pluck('migration')->toArray());
// Ask confirmation to continue.
- if (!$pretend && !$this->io->confirm("Continue?", false)) {
+ if (!$pretend && !$this->io->confirm("Continue?", FALSE)) {
exit(1);
}
@@ -278,8 +276,7 @@ class Migrator
* @param mixed $migration
* @param string $method up/down
*/
- protected function pretendToRun($migration, $method)
- {
+ protected function pretendToRun($migration, $method) {
foreach ($this->getQueries($migration, $method) as $query) {
$this->io->writeln($query['query'], OutputInterface::VERBOSITY_VERBOSE);
}
@@ -293,8 +290,7 @@ class Migrator
* @param string $method up/down
* @return void
*/
- protected function getQueries($migration, $method)
- {
+ protected function getQueries($migration, $method) {
$db = $this->schema->getConnection();
return $db->pretend(function () use ($migration, $method) {
@@ -311,8 +307,7 @@ class Migrator
* @access protected
* @return void
*/
- protected function getPendingMigrations()
- {
+ protected function getPendingMigrations() {
$pending = collect([]);
// Get the sprinkle list
@@ -337,7 +332,7 @@ class Migrator
// Make sure the class exist
if (!class_exists($migrationClass)) {
- throw new BadClassNameException("Unable to find the migration class '$migrationClass'." );
+ throw new BadClassNameException("Unable to find the migration class '$migrationClass'.");
}
// Load the migration class
@@ -371,8 +366,7 @@ class Migrator
* @param string $sprinkleName
* @return void
*/
- public function getMigrations($sprinkle)
- {
+ public function getMigrations($sprinkle) {
// Find all the migration files
$path = $this->migrationDirectoryPath($sprinkle);
$files = glob($path . "*/*.php");
@@ -389,7 +383,7 @@ class Migrator
$version = str_replace("/$className.php", "", $migration);
// Reconstruct the classname
- $className = "\\UserFrosting\\Sprinkle\\".$sprinkleName."\\Database\\Migrations\\".$version."\\".$className;
+ $className = "\\UserFrosting\\Sprinkle\\" . $sprinkleName . "\\Database\\Migrations\\" . $version . "\\" . $className;
return $className;
});
@@ -404,8 +398,7 @@ class Migrator
* @access protected
* @return void
*/
- protected function resolveDependencies()
- {
+ protected function resolveDependencies() {
$this->io->writeln("\n<info>Resolving migrations dependencies...</info>", OutputInterface::VERBOSITY_VERBOSE);
// Reset fulfillable/unfulfillable lists
@@ -435,20 +428,19 @@ class Migrator
* @param $migration
* @return bool true/false if all conditions are met
*/
- protected function validateClassDependencies($migration)
- {
+ protected function validateClassDependencies($migration) {
$this->io->writeln("> Checking dependencies for {$migration->className}", OutputInterface::VERBOSITY_VERBOSE);
// If it's already marked as fulfillable, it's fulfillable
// Return true directly (it's already marked)
if ($this->fulfillable->contains($migration)) {
- return true;
+ return TRUE;
}
// If it's already marked as unfulfillable, it's unfulfillable
// Return false directly (it's already marked)
if ($this->unfulfillable->contains($migration)) {
- return false;
+ return FALSE;
}
// If it's already run, it's fulfillable
@@ -487,10 +479,9 @@ class Migrator
* @param $migration
* @return true
*/
- protected function markAsFulfillable($migration)
- {
+ protected function markAsFulfillable($migration) {
$this->fulfillable->push($migration);
- return true;
+ return TRUE;
}
/**
@@ -501,10 +492,9 @@ class Migrator
* @param $migration
* @return false
*/
- protected function markAsUnfulfillable($migration)
- {
+ protected function markAsUnfulfillable($migration) {
$this->unfulfillable->push($migration);
- return false;
+ return FALSE;
}
/**
@@ -514,8 +504,7 @@ class Migrator
* @param mixed $migration
* @return void
*/
- protected function log($migration)
- {
+ protected function log($migration) {
// Get the next batch number if not defined
if (!$this->batch) {
$this->batch = $this->getNextBatchNumber();
@@ -536,8 +525,7 @@ class Migrator
* @access public
* @return int the next batch number
*/
- public function getNextBatchNumber()
- {
+ public function getNextBatchNumber() {
$batch = Migrations::max('batch');
return ($batch) ? $batch + 1 : 1;
}
@@ -550,8 +538,7 @@ class Migrator
* @access public
* @return void
*/
- protected function setupVersionTable()
- {
+ protected function setupVersionTable() {
// Check if the `migrations` table exist. Create it manually otherwise
if (!$this->schema->hasColumn($this->table, 'id')) {
$this->io->section("Creating the `{$this->table}` table");
@@ -570,14 +557,13 @@ class Migrator
* @param mixed $sprinkleName
* @return void
*/
- protected function migrationDirectoryPath($sprinkleName)
- {
+ protected function migrationDirectoryPath($sprinkleName) {
$path = \UserFrosting\SPRINKLES_DIR .
- \UserFrosting\DS .
- $sprinkleName .
- \UserFrosting\DS .
- \UserFrosting\SRC_DIR_NAME .
- "/Database/Migrations/";
+ \UserFrosting\DS .
+ $sprinkleName .
+ \UserFrosting\DS .
+ \UserFrosting\SRC_DIR_NAME .
+ "/Database/Migrations/";
return $path;
}
diff --git a/main/app/system/Database/Migrations/v410/MigrationTable.php b/main/app/system/Database/Migrations/v410/MigrationTable.php
index fb833df..265305a 100644
--- a/main/app/system/Database/Migrations/v410/MigrationTable.php
+++ b/main/app/system/Database/Migrations/v410/MigrationTable.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System\Database\Migrations\v410;
use Illuminate\Database\Schema\Blueprint;
@@ -29,8 +30,7 @@ class MigrationTable extends Migration
/**
* {@inheritDoc}
*/
- public function up()
- {
+ public function up() {
$this->schema->create('migrations', function (Blueprint $table) {
$table->increments('id');
$table->string('sprinkle');
@@ -52,8 +52,7 @@ class MigrationTable extends Migration
/**
* {@inheritDoc}
*/
- public function down()
- {
+ public function down() {
$this->schema->drop('migrations');
}
}
diff --git a/main/app/system/Database/Model/Migrations.php b/main/app/system/Database/Model/Migrations.php
index 6a0942e..da690f8 100644
--- a/main/app/system/Database/Model/Migrations.php
+++ b/main/app/system/Database/Model/Migrations.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System\Database\Model;
use Illuminate\Database\Capsule\Manager as Capsule;
@@ -29,7 +30,7 @@ class Migrations extends Model
/**
* @var bool Enable timestamps for this class.
*/
- public $timestamps = true;
+ public $timestamps = TRUE;
/**
* @var array List of fields that can be edited by this model
@@ -48,8 +49,7 @@ class Migrations extends Model
* @param string $sprinkleName
* @return void
*/
- protected function scopeForSprinkle($query, $sprinkleName)
- {
+ protected function scopeForSprinkle($query, $sprinkleName) {
return $query->where('sprinkle', $sprinkleName);
}
}
diff --git a/main/app/system/Facade.php b/main/app/system/Facade.php
index 0d1ad82..d11d9bf 100644
--- a/main/app/system/Facade.php
+++ b/main/app/system/Facade.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System;
use Illuminate\Support\Facades\Mockery;
@@ -40,11 +41,10 @@ abstract class Facade
/**
* Hotswap the underlying service instance behind the facade.
*
- * @param mixed $instance
+ * @param mixed $instance
* @return void
*/
- public static function swap($instance)
- {
+ public static function swap($instance) {
$name = static::getFacadeAccessor();
static::$resolvedInstance[$name] = $instance;
@@ -60,8 +60,7 @@ abstract class Facade
* @param mixed
* @return \Mockery\Expectation
*/
- public static function shouldReceive()
- {
+ public static function shouldReceive() {
$name = static::getFacadeAccessor();
if (static::isMock()) {
@@ -76,11 +75,10 @@ abstract class Facade
/**
* Create a fresh mock instance for the given class.
*
- * @param string $name
+ * @param string $name
* @return \Mockery\Expectation
*/
- protected static function createFreshMockInstance($name)
- {
+ protected static function createFreshMockInstance($name) {
static::$resolvedInstance[$name] = $mock = static::createMockByName($name);
$mock->shouldAllowMockingProtectedMethods();
@@ -95,11 +93,10 @@ abstract class Facade
/**
* Create a fresh mock instance for the given class.
*
- * @param string $name
+ * @param string $name
* @return \Mockery\Expectation
*/
- protected static function createMockByName($name)
- {
+ protected static function createMockByName($name) {
$class = static::getMockableClass($name);
return $class ? Mockery::mock($class) : Mockery::mock();
@@ -110,8 +107,7 @@ abstract class Facade
*
* @return bool
*/
- protected static function isMock()
- {
+ protected static function isMock() {
$name = static::getFacadeAccessor();
return isset(static::$resolvedInstance[$name]) && static::$resolvedInstance[$name] instanceof MockInterface;
@@ -122,8 +118,7 @@ abstract class Facade
*
* @return string|null
*/
- protected static function getMockableClass()
- {
+ protected static function getMockableClass() {
if ($root = static::getFacadeRoot()) {
return get_class($root);
}
@@ -134,8 +129,7 @@ abstract class Facade
*
* @return mixed
*/
- public static function getFacadeRoot()
- {
+ public static function getFacadeRoot() {
return static::resolveFacadeInstance(static::getFacadeAccessor());
}
@@ -146,19 +140,17 @@ abstract class Facade
*
* @throws \RuntimeException
*/
- protected static function getFacadeAccessor()
- {
+ protected static function getFacadeAccessor() {
throw new RuntimeException('Facade does not implement getFacadeAccessor method.');
}
/**
* Resolve the facade root instance from the container.
*
- * @param string|object $name
+ * @param string|object $name
* @return mixed
*/
- protected static function resolveFacadeInstance($name)
- {
+ protected static function resolveFacadeInstance($name) {
if (is_object($name)) {
return $name;
}
@@ -173,11 +165,10 @@ abstract class Facade
/**
* Clear a resolved facade instance.
*
- * @param string $name
+ * @param string $name
* @return void
*/
- public static function clearResolvedInstance($name)
- {
+ public static function clearResolvedInstance($name) {
unset(static::$resolvedInstance[$name]);
}
@@ -186,8 +177,7 @@ abstract class Facade
*
* @return void
*/
- public static function clearResolvedInstances()
- {
+ public static function clearResolvedInstances() {
static::$resolvedInstance = [];
}
@@ -196,8 +186,7 @@ abstract class Facade
*
* @return \Interop\Container\ContainerInterface
*/
- public static function getFacadeContainer()
- {
+ public static function getFacadeContainer() {
return static::$container;
}
@@ -207,25 +196,23 @@ abstract class Facade
* @param \Interop\Container\ContainerInterface $container
* @return void
*/
- public static function setFacadeContainer($container)
- {
+ public static function setFacadeContainer($container) {
static::$container = $container;
}
/**
* Handle dynamic, static calls to the object.
*
- * @param string $method
- * @param array $args
+ * @param string $method
+ * @param array $args
* @return mixed
*
* @throws \RuntimeException
*/
- public static function __callStatic($method, $args)
- {
+ public static function __callStatic($method, $args) {
$instance = static::getFacadeRoot();
- if (! $instance) {
+ if (!$instance) {
throw new RuntimeException('A facade root has not been set.');
}
diff --git a/main/app/system/ServicesProvider.php b/main/app/system/ServicesProvider.php
index 6286bc0..f8fe666 100644
--- a/main/app/system/ServicesProvider.php
+++ b/main/app/system/ServicesProvider.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System;
use Interop\Container\ContainerInterface;
@@ -27,8 +28,7 @@ class ServicesProvider
*
* @param ContainerInterface $container A DI container implementing ArrayAccess and container-interop.
*/
- public function register(ContainerInterface $container)
- {
+ public function register(ContainerInterface $container) {
/**
* Set up the event dispatcher, required by Sprinkles to hook into the UF lifecycle.
*/
diff --git a/main/app/system/SlimAppEvent.php b/main/app/system/SlimAppEvent.php
index f1217a5..4bec240 100644
--- a/main/app/system/SlimAppEvent.php
+++ b/main/app/system/SlimAppEvent.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System;
use RocketTheme\Toolbox\Event\Event;
@@ -17,13 +18,11 @@ class SlimAppEvent extends Event
{
protected $app;
- public function __construct(App $app)
- {
+ public function __construct(App $app) {
$this->app = $app;
}
- public function getApp()
- {
+ public function getApp() {
return $this->app;
}
}
diff --git a/main/app/system/Sprinkle/Sprinkle.php b/main/app/system/Sprinkle/Sprinkle.php
index 4707025..1f1820b 100644
--- a/main/app/system/Sprinkle/Sprinkle.php
+++ b/main/app/system/Sprinkle/Sprinkle.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System\Sprinkle;
use Interop\Container\ContainerInterface;
@@ -30,8 +31,7 @@ class Sprinkle implements EventSubscriberInterface
*
* @return array
*/
- public static function getSubscribedEvents()
- {
+ public static function getSubscribedEvents() {
$methods = get_class_methods(get_called_class());
$list = [];
@@ -49,8 +49,7 @@ class Sprinkle implements EventSubscriberInterface
*
* @param ContainerInterface $ci The global container object, which holds all your services.
*/
- public function __construct(ContainerInterface $ci)
- {
+ public function __construct(ContainerInterface $ci) {
$this->ci = $ci;
}
}
diff --git a/main/app/system/Sprinkle/SprinkleManager.php b/main/app/system/Sprinkle/SprinkleManager.php
index c206cea..53eae50 100644
--- a/main/app/system/Sprinkle/SprinkleManager.php
+++ b/main/app/system/Sprinkle/SprinkleManager.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System\Sprinkle;
use Illuminate\Support\Str;
@@ -47,8 +48,7 @@ class SprinkleManager
*
* @param ContainerInterface $ci The global container object, which holds all your services.
*/
- public function __construct(ContainerInterface $ci)
- {
+ public function __construct(ContainerInterface $ci) {
$this->ci = $ci;
$this->sprinklesPath = \UserFrosting\APP_DIR_NAME . \UserFrosting\DS . \UserFrosting\SPRINKLES_DIR_NAME . \UserFrosting\DS;
@@ -72,14 +72,13 @@ class SprinkleManager
* @param string $sprinkleName
* @return string|bool The full path to specified resource for the specified Sprinkle (if found).
*/
- public function addResource($resourceName, $sprinkleName)
- {
+ public function addResource($resourceName, $sprinkleName) {
$resourcePath = $this->resourcePaths[$resourceName];
$fullPath = $this->sprinklesPath . $sprinkleName . $resourcePath;
$this->ci->locator->addPath($resourceName, '', $fullPath);
- return $this->ci->locator->findResource("$resourceName://", true, false);
+ return $this->ci->locator->findResource("$resourceName://", TRUE, FALSE);
/* This would allow a stream to subnavigate to a specific sprinkle (e.g. "templates://core/")
Not sure if we need this.
@@ -90,8 +89,7 @@ class SprinkleManager
/**
* Register resource streams for all base sprinkles.
*/
- public function addResources()
- {
+ public function addResources() {
// For each sprinkle, register its resources and then run its initializer
foreach ($this->sprinkles as $sprinkleName => $sprinkle) {
$this->addResource('config', $sprinkleName);
@@ -113,8 +111,7 @@ class SprinkleManager
* Otherwise, returns null.
* @param $name The name of the Sprinkle to initialize.
*/
- public function bootSprinkle($name)
- {
+ public function bootSprinkle($name) {
$className = Str::studly($name);
$fullClassName = "\\UserFrosting\\Sprinkle\\$className\\$className";
@@ -123,7 +120,7 @@ class SprinkleManager
$sprinkle = new $fullClassName($this->ci);
return $sprinkle;
} else {
- return null;
+ return NULL;
}
}
@@ -132,8 +129,7 @@ class SprinkleManager
*
* @return string[]
*/
- public function getSprinkleNames()
- {
+ public function getSprinkleNames() {
return array_keys($this->sprinkles);
}
@@ -142,8 +138,7 @@ class SprinkleManager
*
* @return Sprinkle[]
*/
- public function getSprinkles()
- {
+ public function getSprinkles() {
return $this->sprinkles;
}
@@ -153,8 +148,7 @@ class SprinkleManager
*
* @param string[] $baseSprinkleNames
*/
- public function init($sprinkleNames)
- {
+ public function init($sprinkleNames) {
foreach ($sprinkleNames as $sprinkleName) {
$sprinkle = $this->bootSprinkle($sprinkleName);
@@ -172,8 +166,7 @@ class SprinkleManager
*
* @param string $schemaPath
*/
- public function initFromSchema($schemaPath)
- {
+ public function initFromSchema($schemaPath) {
$baseSprinkleNames = $this->loadSchema($schemaPath)->base;
$this->init($baseSprinkleNames);
}
@@ -184,8 +177,7 @@ class SprinkleManager
*
* @param $name The name of the Sprinkle
*/
- public function isAvailable($name)
- {
+ public function isAvailable($name) {
return in_array($name, $this->getSprinkleNames());
}
@@ -193,8 +185,7 @@ class SprinkleManager
/**
* Interate through the list of loaded Sprinkles, and invoke their ServiceProvider classes.
*/
- public function registerAllServices()
- {
+ public function registerAllServices() {
foreach ($this->getSprinkleNames() as $sprinkleName) {
$this->registerServices($sprinkleName);
}
@@ -203,8 +194,7 @@ class SprinkleManager
/**
* Register services for a specified Sprinkle.
*/
- public function registerServices($name)
- {
+ public function registerServices($name) {
$className = Str::studly($name);
$fullClassName = "\\UserFrosting\\Sprinkle\\$className\\ServicesProvider\\ServicesProvider";
@@ -222,11 +212,10 @@ class SprinkleManager
* @param string $schemaPath
* @return string[]
*/
- protected function loadSchema($schemaPath)
- {
+ protected function loadSchema($schemaPath) {
$sprinklesFile = @file_get_contents($schemaPath);
- if ($sprinklesFile === false) {
+ if ($sprinklesFile === FALSE) {
$errorMessage = "Error: Unable to determine Sprinkle load order. File '$schemaPath' not found or unable to read. Please create a 'sprinkles.json' file and try again.";
throw new FileNotFoundException($errorMessage);
}
diff --git a/main/app/system/UserFrosting.php b/main/app/system/UserFrosting.php
index 4f569ec..9fc61d1 100644
--- a/main/app/system/UserFrosting.php
+++ b/main/app/system/UserFrosting.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\System;
use RocketTheme\Toolbox\Event\EventDispatcher;
@@ -29,8 +30,7 @@ class UserFrosting
/**
* Create the UserFrosting application instance.
*/
- public function __construct()
- {
+ public function __construct() {
// First, we create our DI container
$this->ci = new Container;
@@ -42,12 +42,11 @@ class UserFrosting
* Fires an event with optional parameters.
*
* @param string $eventName
- * @param Event $event
+ * @param Event $event
*
* @return Event
*/
- public function fireEvent($eventName, Event $event = null)
- {
+ public function fireEvent($eventName, Event $event = NULL) {
/** @var EventDispatcher $events */
$eventDispatcher = $this->ci->eventDispatcher;
@@ -59,8 +58,7 @@ class UserFrosting
*
* @return Slim\App
*/
- public function getApp()
- {
+ public function getApp() {
return $this->app;
}
@@ -69,8 +67,7 @@ class UserFrosting
*
* @return Slim\Container
*/
- public function getContainer()
- {
+ public function getContainer() {
return $this->ci;
}
@@ -79,13 +76,12 @@ class UserFrosting
*
* Include them in reverse order to allow higher priority routes to override lower priority.
*/
- public function loadRoutes()
- {
+ public function loadRoutes() {
// Since routes aren't encapsulated in a class yet, we need this workaround :(
global $app;
$app = $this->app;
- $routePaths = array_reverse($this->ci->locator->findResources('routes://', true, true));
+ $routePaths = array_reverse($this->ci->locator->findResources('routes://', TRUE, TRUE));
foreach ($routePaths as $path) {
$routeFiles = glob($path . '/*.php');
foreach ($routeFiles as $routeFile) {
@@ -97,8 +93,7 @@ class UserFrosting
/**
* Initialize the application. Set up Sprinkles and the Slim app, define routes, register global middleware, and run Slim.
*/
- public function run()
- {
+ public function run() {
$this->setupSprinkles();
// Set the configuration settings for Slim in the 'settings' service
@@ -125,8 +120,7 @@ class UserFrosting
*
* @param bool $isWeb Set to true if setting up in an HTTP/web environment, false if setting up for CLI scripts.
*/
- public function setupSprinkles($isWeb = true)
- {
+ public function setupSprinkles($isWeb = TRUE) {
// Register system services
$serviceProvider = new ServicesProvider();
$serviceProvider->register($this->ci);
@@ -158,12 +152,11 @@ class UserFrosting
/**
* Render a basic error page for problems with loading Sprinkles.
*/
- protected function renderSprinkleErrorPage($errorMessage = "")
- {
+ protected function renderSprinkleErrorPage($errorMessage = "") {
ob_clean();
$title = "UserFrosting Application Error";
$errorMessage = "Unable to start site. Contact owner.<br/><br/>" .
- "Version: UserFrosting ".\UserFrosting\VERSION."<br/>" .
+ "Version: UserFrosting " . \UserFrosting\VERSION . "<br/>" .
$errorMessage;
$output = sprintf(
"<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" .
@@ -180,8 +173,7 @@ class UserFrosting
/**
* Render a CLI error message for problems with loading Sprinkles.
*/
- protected function renderSprinkleErrorCli($errorMessage = "")
- {
+ protected function renderSprinkleErrorCli($errorMessage = "") {
exit($errorMessage . PHP_EOL);
}
}