diff options
Diffstat (limited to 'main/app/system/Bakery')
-rw-r--r-- | main/app/system/Bakery/Bakery.php | 44 | ||||
-rw-r--r-- | main/app/system/Bakery/BaseCommand.php | 7 | ||||
-rw-r--r-- | main/app/system/Bakery/Command/Bake.php | 11 | ||||
-rw-r--r-- | main/app/system/Bakery/Command/BuildAssets.php | 35 | ||||
-rw-r--r-- | main/app/system/Bakery/Command/ClearCache.php | 18 | ||||
-rw-r--r-- | main/app/system/Bakery/Command/Debug.php | 33 | ||||
-rw-r--r-- | main/app/system/Bakery/Command/Migrate.php | 13 | ||||
-rw-r--r-- | main/app/system/Bakery/Command/MigrateRefresh.php | 15 | ||||
-rw-r--r-- | main/app/system/Bakery/Command/MigrateReset.php | 13 | ||||
-rw-r--r-- | main/app/system/Bakery/Command/MigrateRollback.php | 15 | ||||
-rw-r--r-- | main/app/system/Bakery/Command/Setup.php | 31 | ||||
-rw-r--r-- | main/app/system/Bakery/Command/Test.php | 11 | ||||
-rw-r--r-- | main/app/system/Bakery/DatabaseTest.php | 10 | ||||
-rw-r--r-- | main/app/system/Bakery/Migration.php | 13 | ||||
-rw-r--r-- | main/app/system/Bakery/Migrator.php | 72 |
15 files changed, 148 insertions, 193 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; } |