Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converted to PSR-2 #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 57 additions & 51 deletions code/commands/ConsoleRole.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,61 @@
/**
* Provides an interactive PHP interface to the site.
*/
class ConsoleRole extends DataExtension {
const CMD_CONSOLE = 'console';

/**
* Tell sake more about this command.
*/
public function commands(&$list) {
$list[self::CMD_CONSOLE] = array($this, 'startConsole');
}

/**
* Gives sake a brief for the help section.
*/
public function help_brief(&$details) {
$details[self::CMD_CONSOLE] = 'Provides a PHP shell with Silverstripe loaded.';
}

/**
* Gives sake a list of the parameters used.
*/
public function help_parameters(&$details) {
// @todo Add in how much bootstrapping to do.
}

/**
* Gives sake a list of examples of how to use this command.
*/
public function help_examples(&$examples) {
$examples[self::CMD_CONSOLE] = array(
self::CMD_CONSOLE,
);
}

/**
* Attempts to start a PHP console.
*/
public function startConsole() {
// Prepare variables.
$sakebase = dirname(dirname(__DIR__));
$sitebase = dirname($sakebase);

// Find the PHPSH script.
$path = $sakebase . '/thirdparty/phpsh/phpsh';

// Run this helper script to initialise Silverstripe.
$arg = sprintf('%s/scripts/consolerole-init.php', $sakebase);

// Run the console.
$cmd = $path . ' ' . $arg;
SakeMoreHelper::runCLI($cmd);
}
class ConsoleRole extends DataExtension
{
const CMD_CONSOLE = 'console';

/**
* Tell sake more about this command.
*/
public function commands(&$list)
{
$list[self::CMD_CONSOLE] = array($this, 'startConsole');
}

/**
* Gives sake a brief for the help section.
*/
public function help_brief(&$details)
{
$details[self::CMD_CONSOLE] = 'Provides a PHP shell with Silverstripe loaded.';
}

/**
* Gives sake a list of the parameters used.
*/
public function help_parameters(&$details)
{
// @todo Add in how much bootstrapping to do.
}

/**
* Gives sake a list of examples of how to use this command.
*/
public function help_examples(&$examples)
{
$examples[self::CMD_CONSOLE] = array(
self::CMD_CONSOLE,
);
}

/**
* Attempts to start a PHP console.
*/
public function startConsole()
{
// Prepare variables.
$sakebase = dirname(dirname(__DIR__));
$sitebase = dirname($sakebase);

// Find the PHPSH script.
$path = $sakebase . '/thirdparty/phpsh/phpsh';

// Run this helper script to initialise Silverstripe.
$arg = sprintf('%s/scripts/consolerole-init.php', $sakebase);

// Run the console.
$cmd = $path . ' ' . $arg;
SakeMoreHelper::runCLI($cmd);
}
}
Loading