本文整理汇总了PHP中thebuggenie\core\framework\Context::setScope方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::setScope方法的具体用法?PHP Context::setScope怎么用?PHP Context::setScope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thebuggenie\core\framework\Context
的用法示例。
在下文中一共展示了Context::setScope方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_execute
public function do_execute()
{
/* Prepare variables */
try {
$project_id = $this->getProvidedArgument('projectid');
$project_row = \thebuggenie\core\entities\tables\Projects::getTable()->getById($project_id, false);
\thebuggenie\core\framework\Context::setScope(new \thebuggenie\core\entities\Scope($project_row[\thebuggenie\core\entities\tables\Projects::SCOPE]));
$project = new \thebuggenie\core\entities\Project($project_id, $project_row);
} catch (\Exception $e) {
$this->cliEcho("The project with the ID " . $this->getProvidedArgument('projectid') . " does not exist\n", 'red', 'bold');
exit;
}
$author = $this->getProvidedArgument('author');
$new_rev = $this->getProvidedArgument('revno');
$commit_msg = $this->getProvidedArgument('log');
$changed = $this->getProvidedArgument('changed');
$old_rev = $this->getProvidedArgument('oldrev', null);
$date = $this->getProvidedArgument('date', null);
$branch = $this->getProvidedArgument('branch', null);
if (\thebuggenie\core\framework\Settings::get('access_method_' . $project->getKey()) == Vcs_integration::ACCESS_HTTP) {
$this->cliEcho("This project uses the HTTP access method, and so access via the CLI has been disabled\n", 'red', 'bold');
exit;
}
if ($old_rev === null && !ctype_digit($new_rev)) {
$this->cliEcho("Error: if only the new revision is specified, it must be a number so that old revision can be calculated from it (by substracting 1 from new revision number).");
} else {
if ($old_rev === null) {
$old_rev = $new_rev - 1;
}
}
$output = Vcs_integration::processCommit($project, $commit_msg, $old_rev, $new_rev, $date, $changed, $author, $branch);
$this->cliEcho($output);
}
示例2: runUpgrade
public function runUpgrade(framework\Request $request)
{
$version_info = explode(',', file_get_contents(THEBUGGENIE_PATH . 'installed'));
$this->current_version = $version_info[0];
$this->upgrade_available = $this->current_version != framework\Settings::getVersion(false);
if ($this->upgrade_available) {
$scope = new \thebuggenie\core\entities\Scope();
$scope->setID(1);
$scope->setEnabled();
framework\Context::setScope($scope);
if ($this->current_version == '3.2') {
$this->statuses = \thebuggenie\core\entities\tables\ListTypes::getTable()->getStatusListForUpgrade();
$this->adminusername = \thebuggenie\core\modules\installation\upgrade_32\TBGUsersTable::getTable()->getAdminUsername();
}
}
$this->upgrade_complete = false;
if ($this->upgrade_available && $request->isPost()) {
$this->upgrade_complete = false;
switch ($this->current_version) {
case '3.2':
$this->_upgradeFrom3dot2($request);
break;
default:
$this->upgrade_complete = true;
}
if ($this->upgrade_complete) {
$existing_installed_content = file_get_contents(THEBUGGENIE_PATH . 'installed');
file_put_contents(THEBUGGENIE_PATH . 'installed', framework\Settings::getVersion(false, false) . ', upgraded ' . date('d.m.Y H:i') . "\n" . $existing_installed_content);
$this->current_version = framework\Settings::getVersion(false, false);
$this->upgrade_available = false;
}
} elseif ($this->upgrade_available) {
$this->permissions_ok = false;
if (is_writable(THEBUGGENIE_PATH . 'installed') && is_writable(THEBUGGENIE_PATH . 'upgrade')) {
$this->permissions_ok = true;
}
} elseif ($this->upgrade_complete) {
$this->forward(framework\Context::getRouting()->generate('home'));
}
}
示例3: _processArguments
protected final function _processArguments()
{
$cc = 1;
foreach ($this->_required_arguments as $key => $argument) {
$cc++;
if ($this->hasProvidedArgument($key)) {
continue;
}
if ($this->hasProvidedArgument($cc)) {
if (mb_substr(self::$_provided_arguments[$cc], 0, 2) == '--' && mb_substr(self::$_provided_arguments[$cc], 2, mb_strpos(self::$_provided_arguments[$cc], '=') - 1) != $key) {
continue;
}
self::$_provided_arguments[$key] = self::$_provided_arguments[$cc];
if (!is_numeric($key)) {
self::$_named_arguments[$key] = self::$_provided_arguments[$cc];
}
continue;
}
}
foreach (self::$_provided_arguments as $key => $value) {
$this->{$key} = $value;
}
$diff = array_diff(array_keys($this->_required_arguments), array_keys(self::$_named_arguments));
if (count($diff)) {
throw new \Exception('Please include all required arguments. Missing arguments: ' . join(', ', $diff));
}
foreach ($this->_optional_arguments as $key => $argument) {
$cc++;
if ($this->hasProvidedArgument($key)) {
continue;
}
if ($this->hasProvidedArgument($cc)) {
if (mb_substr(self::$_provided_arguments[$cc], 0, 2) == '--' && mb_substr(self::$_provided_arguments[$cc], 2, mb_strpos(self::$_provided_arguments[$cc], '=') - 1) != $key) {
continue;
}
self::$_provided_arguments[$key] = self::$_provided_arguments[$cc];
if (!is_numeric($key)) {
self::$_named_arguments[$key] = self::$_provided_arguments[$cc];
}
continue;
}
}
if ($this->_scoped && array_key_exists('scope', self::$_named_arguments)) {
$scope = \thebuggenie\core\entities\tables\Scopes::getTable()->selectById(self::$_named_arguments['scope']);
$this->cliEcho("Using scope " . $scope->getID() . "\n");
\thebuggenie\core\framework\Context::setScope($scope);
}
}
示例4: do_execute
//.........这里部分代码省略.........
$this->cliEcho("Permission denied when trying to save the [main folder]/thebuggenie/.user.ini\n", 'red', 'bold');
$this->cliEcho("You will have to set up the .user.ini file yourself. See the README file for more information.\n", 'white', 'bold');
$this->cliEcho('Please note: ', 'white', 'bold');
$this->cliEcho("If you're using PHP-FPM, The Bug Genie might not function properly until the .user.ini file is properly set up\n");
} else {
$content = file_get_contents(THEBUGGENIE_CORE_PATH . 'templates/htaccess.template');
file_put_contents(THEBUGGENIE_PATH . 'thebuggenie/.user.ini', $content);
if (file_get_contents(THEBUGGENIE_PATH . 'thebuggenie/.user.ini') != $content) {
$this->cliEcho("Permission denied when trying to save the [main folder]/thebuggenie/.user.ini\n", 'red', 'bold');
$this->cliEcho("You will have to set up the .user.ini file yourself. See the README file for more information.\n", 'white', 'bold');
$this->cliEcho('Please note: ', 'white', 'bold');
$this->cliEcho("If you're using PHP-FPM, The Bug Genie might not function properly until the .user.ini file is properly set up\n");
} else {
$this->cliEcho("The .user.ini file was successfully set up...\n", 'green', 'bold');
}
}
} else {
$this->cliEcho("Skipping .htaccess and .user.ini auto-setup.");
}
if ($this->getProvidedArgument('setup_htaccess') != 'yes') {
$this->cliEcho("Press ENTER to continue ... ");
$this->pressEnterToContinue();
$this->cliEcho("\n");
}
$this->cliEcho("\n");
$this->cliEcho("Creating tables ...\n", 'white', 'bold');
$b2db_entities_path = THEBUGGENIE_CORE_PATH . 'entities' . DS . 'tables' . DS;
$tables_created = array();
foreach (scandir($b2db_entities_path) as $tablefile) {
if (in_array($tablefile, array('.', '..'))) {
continue;
}
if (($tablename = mb_substr($tablefile, 0, mb_strpos($tablefile, '.'))) != '') {
$tablename = "\\thebuggenie\\core\\entities\\tables\\{$tablename}";
$reflection = new \ReflectionClass($tablename);
$docblock = $reflection->getDocComment();
$annotationset = new \b2db\AnnotationSet($docblock);
if ($annotationset->hasAnnotation('Table')) {
\b2db\Core::getTable($tablename)->create();
\b2db\Core::getTable($tablename)->createIndexes();
$tables_created[] = $tablename;
}
}
}
$this->cliEcho("\n");
$this->cliEcho("All tables successfully created...\n\n", 'green', 'bold');
$this->cliEcho("Setting up initial scope... \n", 'white', 'bold');
\thebuggenie\core\framework\Context::reinitializeI18n('en_US');
$scope = new \thebuggenie\core\entities\Scope();
$scope->setName('The default scope');
$scope->addHostname('*');
$scope->setEnabled();
\thebuggenie\core\framework\Context::setScope($scope);
$scope->save();
\thebuggenie\core\framework\Settings::saveSetting('language', 'en_US');
$this->cliEcho("Initial scope setup successfully... \n\n", 'green', 'bold');
$this->cliEcho("Setting up modules... \n", 'white', 'bold');
try {
foreach (array('publish', 'mailing', 'vcs_integration') as $module) {
$this->cliEcho("Installing {$module}... \n");
\thebuggenie\core\entities\Module::installModule($module);
}
$this->cliEcho("\n");
$this->cliEcho("All modules installed successfully...\n", 'green', 'bold');
$this->cliEcho("\n");
$this->cliEcho("Finishing installation... \n", 'white', 'bold');
$installed_string = \thebuggenie\core\framework\Settings::getMajorVer() . '.' . \thebuggenie\core\framework\Settings::getMinorVer() . ', installed ' . date('d.m.Y H:i');
if (file_exists(THEBUGGENIE_PATH . 'installed') && !is_writable(THEBUGGENIE_PATH . 'installed') || !file_exists(THEBUGGENIE_PATH . 'installed') && !is_writable(THEBUGGENIE_PATH)) {
$this->cliEcho("\n");
$this->cliEcho("Could not create the 'installed' file.\n", 'red', 'bold');
$this->cliEcho("Please create the file ");
$this->cliEcho(THEBUGGENIE_PATH . "installed\n", 'white', 'bold');
$this->cliEcho("with the following line inside:\n");
$this->cliEcho($installed_string, 'blue', 'bold');
$this->cliEcho("\n");
$this->cliEcho("This can be done by running the following command when installation has finished:\n");
$this->cliEcho('echo "' . $installed_string . '" > ' . THEBUGGENIE_PATH . 'installed', 'white', 'bold');
$this->cliEcho("\n");
$this->cliEcho("Press ENTER to continue ... ");
$this->pressEnterToContinue();
$this->cliEcho("\n");
$this->cliEcho("\n");
} else {
file_put_contents(THEBUGGENIE_PATH . 'installed', $installed_string);
}
$this->cliEcho("The installation was completed successfully!\n", 'green', 'bold');
$this->cliEcho("\nTo use The Bug Genie, access http://example.com" . $url_subdir . "index.php with a web-browser.\n");
$this->cliEcho("The default username is ") . $this->cliEcho('Administrator') . $this->cliEcho(' and the password is ') . $this->cliEcho('admin');
$this->cliEcho("\n\nFor support, please visit ") . $this->cliEcho('http://www.thebuggenie.com/', 'blue', 'underline');
$this->cliEcho("\n");
} catch (\Exception $e) {
throw new \Exception("Could not install the {$module} module:\n" . $e->getMessage());
}
}
} catch (\Exception $e) {
$this->cliEcho("\n\nThe installation was interrupted\n", 'red');
$this->cliEcho($e->getMessage() . "\n");
}
$this->cliEcho("\n");
}
示例5: runScope
public function runScope(framework\Request $request)
{
$this->scope = new entities\Scope($request['id']);
$modules = tables\Modules::getTable()->getModulesForScope($this->scope->getID());
$this->modules = $modules;
$this->scope_save_error = framework\Context::getMessageAndClear('scope_save_error');
if ($request->isPost()) {
try {
if ($request['scope_action'] == 'delete') {
if (!$this->scope->isDefault()) {
$this->scope->delete();
framework\Context::setMessage('scope_deleted', true);
$this->forward(make_url('configure_scopes'));
} else {
$this->scope_save_error = $this->getI18n()->__('You cannot delete the default scope');
}
} else {
if (!$request['name']) {
throw new \Exception($this->getI18n()->__('Please specify a scope name'));
}
$this->scope->setName($request['name']);
$this->scope->setDescription($request['description']);
$this->scope->setCustomWorkflowsEnabled((bool) $request['custom_workflows_enabled']);
$this->scope->setMaxWorkflowsLimit((int) $request['workflow_limit']);
$this->scope->setUploadsEnabled((bool) $request['file_uploads_enabled']);
$this->scope->setMaxUploadLimit((int) $request['upload_limit']);
$this->scope->setMaxProjects((int) $request['project_limit']);
$this->scope->setMaxUsers((int) $request['user_limit']);
$this->scope->setMaxTeams((int) $request['team_limit']);
$this->scope->save();
$enabled_modules = $request['module_enabled'];
$prev_scope = framework\Context::getScope();
foreach ($enabled_modules as $module => $enabled) {
if (!framework\Context::getModule($module)->isCore() && !$enabled && array_key_exists($module, $modules)) {
$module = tables\Modules::getTable()->getModuleForScope($module, $this->scope->getID());
$module->uninstall($this->scope->getID());
} elseif (!framework\Context::getModule($module)->isCore() && $enabled && !array_key_exists($module, $modules)) {
framework\Context::setScope($this->scope);
entities\Module::installModule($module);
framework\Context::setScope($prev_scope);
}
}
framework\Context::setMessage('scope_saved', true);
$this->forward(make_url('configure_scopes'));
}
} catch (\Exception $e) {
framework\Context::setMessage('scope_save_error', $e->getMessage());
}
}
}
示例6: testRunAddUser
/**
* Makes sure adding a user happens without errors
*
* @link http://issues.thebuggenie.com/thebuggenie/issues/2494
*
* @covers thebuggenie\core\modules\configuration\Actions::runAddUser
* @dataProvider addUserRequestProvider
*/
public function testRunAddUser($username, $buddyname, $email, $password, $group_id)
{
\b2db\Core::resetMocks();
$scope = $this->getMockBuilder('thebuggenie\\core\\entities\\Scope')->setMethods(array('hasUsersAvailable'))->getMock();
$scope->method('hasUsersAvailable')->willReturn(true);
\thebuggenie\core\framework\Context::setScope($scope);
$request = new \thebuggenie\core\framework\Request();
$request->setParameter('username', $username);
$request->setParameter('buddyname', $buddyname);
$request->setParameter('email', $email);
$request->setParameter('password', $password);
$request->setParameter('password_repeat', $password);
$request->setParameter('group_id', $group_id);
$usertablestub = $this->getMockBuilder('b2db\\Table')->setMethods(array('isUsernameAvailable'))->getMock();
$userscopestablestub = $this->getMockBuilder('b2db\\Table')->getMock();
\b2db\Core::setTableMock('thebuggenie\\core\\entities\\tables\\UserScopes', $userscopestablestub);
\b2db\Core::setTableMock('thebuggenie\\core\\entities\\User', $usertablestub);
\b2db\Core::setTableMock('thebuggenie\\core\\entities\\tables\\Users', $usertablestub);
$usertablestub->method('isUsernameAvailable')->will($this->returnValue(true));
// Expect action to verify that username is available
$usertablestub->expects($this->once())->method('isUsernameAvailable')->with($username);
$userscopestablestub->expects($this->once())->method('countUsers');
$this->object->runAddUser($request);
$userobject = \b2db\Core::getTable('thebuggenie\\core\\entities\\tables\\Users')->getLastMockObject();
// Expect action to set correct user properties
$this->assertEquals($userobject->getUsername(), $username);
$this->assertEquals($userobject->getBuddyname(), $buddyname);
$this->assertEquals($userobject->getRealname(), $username);
$this->assertEquals($userobject->getEmail(), $email);
}
示例7: _postSave
protected function _postSave($is_new)
{
tables\ScopeHostnames::getTable()->saveScopeHostnames($this->getHostnames(), $this->getID());
// Load fixtures for this scope if it's a new scope
if ($is_new) {
if (!$this->isDefault()) {
$prev_scope = framework\Context::getScope();
framework\Context::setScope($this);
}
$this->loadFixtures();
if (!$this->isDefault()) {
Module::installModule('publish', $this);
framework\Context::setScope($prev_scope);
framework\Context::clearPermissionsCache();
}
}
}