本文整理汇总了PHP中module_enable函数的典型用法代码示例。如果您正苦于以下问题:PHP module_enable函数的具体用法?PHP module_enable怎么用?PHP module_enable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了module_enable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* Implements setUp().
*/
function setUp($modules = array())
{
if (!isset($this->time)) {
$this->time = time();
}
$this->timeLimit = 1000;
parent::setUp();
if (!module_exists('forum_access')) {
module_enable(array('acl', 'chain_menu_access', 'forum_access'), FALSE);
}
$this->assertTrue(module_exists('acl'), t('Module %module enabled!', array('%module' => 'acl')), 'Setup');
$this->assertTrue(module_exists('chain_menu_access'), t('Module %module enabled!', array('%module' => 'chain_menu_access')), 'Setup');
$this->assertTrue(module_exists('forum_access'), t('Module %module enabled!', array('%module' => 'forum_access')), 'Setup');
$modules = array('devel', 'devel_node_access') + $modules;
$files = system_rebuild_module_data();
$available_modules = array();
foreach ($modules as $module) {
if (!empty($files[$module]) && !module_exists($module)) {
$available_modules[] = $module;
}
}
if (!empty($available_modules)) {
module_enable($available_modules);
}
parent::resetAll();
$this->accesses = array('view', 'create', 'update', 'delete');
}
示例2: testPermissions
/**
* Test that the links are added to the page (no JS testing).
*/
function testPermissions()
{
module_enable(array('contact'));
$this->resetAll();
// Anonymous users should not see the menu.
$this->drupalGet('');
$this->assertNoElementByXPath('//div[@id="admin-menu"]', array(), t('Administration menu not found.'));
// Create a user who
// - can access content overview
// - cannot access drupal.org links
// - cannot administer Contact module
$permissions = $this->basePermissions + array('access content overview');
$admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($admin_user);
// Check that the user can see the admin links, but not the drupal links.
$this->assertElementByXPath('//div[@id="admin-menu"]', array(), 'Administration menu found.');
$this->assertElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path)]', array(':path' => 'admin/content'), 'Content link found.');
$this->assertNoElementByXPath('//div[@id="admin-menu"]//a[@href=:path]', array(':path' => 'http://drupal.org'), 'Icon » Drupal.org link not found.');
$this->assertNoElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path)]', array(':path' => 'admin/structure/contact'), 'Structure » Contact link not found.');
// Create a user "reversed" to the above; i.e., who
// - cannot access content overview
// - can access drupal.org links
// - can administer Contact module
$permissions = $this->basePermissions + array('display drupal links', 'administer contact forms');
$admin_user2 = $this->drupalCreateUser($permissions);
$this->drupalLogin($admin_user2);
$this->assertElementByXPath('//div[@id="admin-menu"]', array(), 'Administration menu found.');
$this->assertNoElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path)]', array(':path' => 'admin/content'), 'Content link not found.');
$this->assertElementByXPath('//div[@id="admin-menu"]//a[@href=:path]', array(':path' => 'http://drupal.org'), 'Icon » Drupal.org link found.');
$this->assertElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path)]', array(':path' => 'admin/structure/contact'), 'Structure » Contact link found.');
}
示例3: setupFeature
/**
* @BeforeFeature
*/
public static function setupFeature(BeforeFeatureScope $scope)
{
$feature = $scope->getFeature();
if ($feature->getTitle() == 'Dkan Harvest') {
module_enable(array('dkan_harvest_test'));
}
}
示例4: xautoloadTestWithCacheTypes
/**
* @param array $cache_types
* The autoloader modes that are enabled, e.g.
* array('apc' => 'apc', 'xcache' => 'xcache')
* @param bool $cache_lazy
* Whether the "lazy" mode is enabled.
*/
protected function xautoloadTestWithCacheTypes($cache_types, $cache_lazy)
{
// @FIXME
// // @FIXME
// // The correct configuration object could not be determined. You'll need to
// // rewrite this call manually.
// variable_set(XAUTOLOAD_VARNAME_CACHE_TYPES, $cache_types);
$this->pass("Set cache types: " . var_export($cache_types, TRUE));
// @FIXME
// // @FIXME
// // The correct configuration object could not be determined. You'll need to
// // rewrite this call manually.
// variable_set(XAUTOLOAD_VARNAME_CACHE_LAZY, $cache_lazy);
$this->pass("Set cache lazy mode: " . var_export($cache_lazy, TRUE));
// Enable xautoload.
module_enable(array('xautoload'), FALSE);
// At this time the xautoload_cache_mode setting is not in effect yet,
// so we have to clear old cached values from APC cache.
xautoload()->cacheManager->renewCachePrefix();
module_enable(array('xautoload_test_1', 'xautoload_test_2', 'xautoload_test_3', 'xautoload_test_4', 'xautoload_test_5'), FALSE);
menu_rebuild();
foreach (array('xautoload_test_1' => array('Drupal\\xautoload_test_1\\ExampleClass'), 'xautoload_test_2' => array('xautoload_test_2_ExampleClass'), 'xautoload_test_3' => array('Drupal\\xautoload_test_3\\ExampleClass')) as $module => $classes) {
$classes_on_include = in_array($module, array('xautoload_test_2', 'xautoload_test_3'));
$this->xautoloadModuleEnabled($module, $classes, $classes_on_include);
$this->xautoloadModuleCheckJson($module, $cache_types, $cache_lazy, $classes);
}
}
示例5: testEnable
/**
* Test successful execution of hook_requirements() during install/enable.
*
* Function module_enable() does not check requirements, unlike normal
* enabling, so we need to invoke the hook manually to simulate it.
*/
public function testEnable()
{
module_load_install(static::MODULE);
module_invoke(static::MODULE, 'requirements', 'install');
module_enable([static::MODULE], FALSE);
$this->pass('Successfully enabled mongodb.module.');
}
示例6: hook_sanmateo_is_master_set
/**
* implements hook_sanmateo_is_master_set
*
* PARAM is_master: a bool that states if this is the master site
*
* THis is called when ever this site is set as master or not master
* It can be used when other items need to be udpated
*/
function hook_sanmateo_is_master_set($is_master)
{
if ($is_master) {
module_enable(array('openid_provider'));
} else {
module_disable(array('openid_provider'));
}
}
示例7: prepTestData
function prepTestData()
{
$servers = array();
$variables = array();
$authentication = array();
$authorization = array();
$this->testFunctions = new LdapTestFunctions();
if ($this->useFeatureData) {
module_enable(array('ctools'), TRUE);
module_enable(array('strongarm'), TRUE);
module_enable(array('features'), TRUE);
module_enable(array($this->featureName), TRUE);
// will need to set non exportables such as bind password also
// also need to create fake ldap server data. use
if (!(module_exists('ctools') && module_exists('strongarm') && module_exists('features') && module_exists('$this->featureName'))) {
drupal_set_message(t('Features and Strongarm modules must be available to use Features as configuratio of simpletests'), 'warning');
}
// with test data stored in features, need to get server properties from ldap_server properties
require_once drupal_get_path('module', $this->featureName) . '/' . $this->featureName . '.ldap_servers.inc';
require_once drupal_get_path('module', $this->featureName) . '/fake_ldap_server_data.inc';
$function_name = $this->featureName . '_default_ldap_servers';
$servers = call_user_func($function_name);
foreach ($servers as $sid => $server) {
$this->testData['servers'][$sid]['properties'] = (array) $server;
// convert to array
$this->testData['servers'][$sid]['properties']['inDatabase'] = TRUE;
$this->testData['servers'][$sid]['properties']['bindpw'] = 'goodpwd';
$this->testData['servers'][$sid] = array_merge($this->testData['servers'][$sid], $fake_ldap_server_data[$sid]);
}
// make included fake sid match feature sid
$this->testFunctions->prepTestConfiguration($this->testData, TRUE);
} else {
include drupal_get_path('module', 'ldap_authorization') . '/tests/' . $this->authorizationData;
$this->testData['authorization'] = $authorization;
include drupal_get_path('module', 'ldap_authorization') . '/tests/' . $this->authenticationData;
$this->testData['authentication'] = $authentication;
include drupal_get_path('module', 'ldap_authorization') . '/tests/' . $this->serversData;
$this->testData['servers'] = $servers;
$this->testData['variables'] = $variables;
// if only one server, set as default in authentication and authorization
if (count($this->testData['servers']) == 1) {
$sids = array_keys($servers);
$this->sid = $sids[0];
foreach ($this->testData['authorization'] as $consumer_type => $consumer_conf) {
$this->testData['authorization'][$consumer_type]['consumerType'] = $consumer_type;
$this->testData['authorization'][$consumer_type]['sid'] = $this->sid;
}
$this->testData['authentication']['sids'] = array($this->sid => $this->sid);
$this->testData['servers'][$this->sid]['sid'] = $this->sid;
}
$this->testFunctions->prepTestConfiguration($this->testData, FALSE);
}
}
示例8: enableDKAN_Workflow
/**
* @BeforeFeature @enableDKAN_Workflow
*/
public static function enableDKAN_Workflow(BeforeFeatureScope $scope)
{
if (!parent::shouldEnableModule("dkan_workflow")) {
return;
}
// This order matters through drupal_flush_all_caches.
module_enable(array('link_badges', 'menu_badges', 'views_dkan_workflow_tree', 'workbench', 'workbench_moderation', 'workbench_email'));
// Enable 'open_data_federal_extras' module.
module_enable(array('dkan_workflow_permissions'));
module_enable(array('dkan_workflow'));
features_revert(array('dkan_workflow_permissions' => array('roles_permissions')));
drupal_flush_all_caches();
}
示例9: hook_environment_switch
/**
* React to an environment state change.
*
* Use this hook to specify changes to your site configuration depending on
* what kind of environment the site is operating in. For example, production
* environments should not have developer/site-builder oriented modules enabled,
* such as administrative UI modules.
*
* When defining your state change actions, be careful to account for a given
* state always consisting of the same behaviors and configuration, regardless
* of how it returns to that state (which previous environment it was in.) Be
* careful that you do not *disable* any modules in one environment that
* implement a necessary instance of hook_environment_switch().
*
* @param $target_env
* The name of the environment being activated.
* @param $current_env
* The name of the environment being deactivated.
* @param $workflow
* The name of the environment workflow whose current state is being switched.
* A "NULL" workflow is the default/generic/unspecified workflow for the site.
*
* @return
* String summarizing changes made for drush user.
*/
function hook_environment_switch($target_env, $current_env, $workflow = NULL)
{
// Declare each optional development-related module
$devel_modules = array('devel', 'devel_generate', 'devel_node_access');
switch ($target_env) {
case 'production':
module_disable($devel_modules);
drupal_set_message('Disabled development modules');
return;
case 'development':
module_enable($devel_modules);
drupal_set_message('Enabled development modules');
return;
}
}
示例10: testUninstall
/**
* Test successful execution of hook_uninstall() with Mongodb disabled.
*
* This cannot be checked by API calls, because the missing functions will
* still be loaded in PHP, hence the need to use the UI to trigger page
* reloads.
*/
public function testUninstall()
{
module_enable([static::DRIVER, static::MODULE]);
$this->pass('Successfully enabled driver and watchdog.module.');
module_disable([static::MODULE, static::DRIVER]);
$admin = $this->drupalCreateUser(['administer modules']);
$this->drupalLogin($admin);
$modules = ['uninstall[mongodb_watchdog]' => 1];
$this->drupalPost('admin/modules/uninstall', $modules, t('Uninstall'));
$this->assertResponse(200, 'Module uninstall form succeeded');
$this->drupalPost(NULL, [], t('Uninstall'));
// Broken core : this should NOT be a 200, but actually is.
// $this->assertResponse(200, 'Module uninstall confirmation succeeded');
$this->assertText(t('The selected modules have been uninstalled.'), 'Module uninstall confirmation succeeded.');
$this->pass('Successfully uninstalled watchdog module.');
}
示例11: enable_modules_if_needed
/**
* Enable modules if disabled.
*
* @param array $modules
* An array of modules
*/
function enable_modules_if_needed($modules)
{
foreach ($modules as $module) {
// Check if modules are disabled.
$result = db_select('system', 's')->fields('s', array('status'))->condition('name', $module, '=')->condition('status', 0, '=')->execute();
if ($result->fetchAssoc()) {
// Create an array of modules to enable.
$to_enable[] = $module;
}
}
if ($to_enable) {
module_enable($to_enable);
echo "Enabled new modules";
} else {
echo "No new modules to enable";
}
}
示例12: xautoloadTestWithCacheTypes
/**
* @param array $cache_types
* The autoloader modes that are enabled, e.g.
* array('apc' => 'apc', 'xcache' => 'xcache')
* @param bool $cache_lazy
* Whether the "lazy" mode is enabled.
*/
protected function xautoloadTestWithCacheTypes($cache_types, $cache_lazy)
{
variable_set('xautoload_cache_types', $cache_types);
$this->pass("Set cache types: " . var_export($cache_types, TRUE));
variable_set('xautoload_cache_lazy', $cache_lazy);
$this->pass("Set cache lazy mode: " . var_export($cache_lazy, TRUE));
// Enable xautoload.
module_enable(array('xautoload'), FALSE);
// At this time the xautoload_cache_mode setting is not in effect yet,
// so we have to clear old cached values from APC cache.
xautoload()->cacheManager->renewCachePrefix();
module_enable(array('xautoload_test_1', 'xautoload_test_2', 'xautoload_test_3'), FALSE);
menu_rebuild();
foreach (array('xautoload_test_1' => array('Drupal\\xautoload_test_1\\ExampleClass'), 'xautoload_test_2' => array('xautoload_test_2_ExampleClass'), 'xautoload_test_3' => array('Drupal\\xautoload_test_3\\ExampleClass')) as $module => $classes) {
$classes_on_include = in_array($module, array('xautoload_test_2', 'xautoload_test_3'));
$this->xautoloadModuleEnabled($module, $classes, $classes_on_include);
$this->xautoloadModuleCheckJson($module, $cache_types, $cache_lazy, $classes);
}
}
示例13: enableModule
/**
* Enables given module(s) at given location by symlinking their contents
*
* @param string $loc the location the module(s) can be found
* @param array|string|null $name the name(s) of the module(s). Defaults to basename($loc).
*
* @throws \InvalidArgumentException
*/
public static function enableModule($loc, $name = null)
{
$loc = rtrim($loc, '/');
if (!is_dir($loc) || !is_readable($loc)) {
throw new \InvalidArgumentException(sprintf('Unable to read directory %s', $loc));
}
$base = basename($loc);
$link = DRUPAL_ROOT . "/sites/all/modules/{$base}";
if (file_exists($link) && readlink($link)) {
unlink($link);
}
symlink($loc, $link);
drupal_static('system_rebuild_module_data', null, true);
$modules = (array) ($name ?: $base);
$enabled = module_enable($modules);
if (false === $enabled) {
throw new \InvalidArgumentException(sprintf('Unable to enable module(s) "%s"', implode(',', $modules)));
}
module_invoke_all('boot');
module_invoke_all('init');
}
示例14: setUp
public function setUp()
{
// For benchmarking.
$this->start = time();
// Enable any modules required for the test.
parent::setUp('better_exposed_filters', 'date', 'date_views', 'list', 'number', 'taxonomy', 'text', 'views', 'views_ui');
// One of these days I'll figure out why Features is breaking all my tests.
module_enable(array('bef_test_content'));
// User with edit views perms
$this->admin_user = $this->drupalCreateUser();
$role = user_role_load_by_name('administrator');
$this->assertTrue(!empty($role->rid), 'Found the "administrator" role.');
user_save($this->admin_user, array('roles' => array($role->rid => $role->rid)));
$this->drupalLogin($this->admin_user);
// Build a basic view for use in tests.
$this->createView();
// $this->createDisplay('Page', array('path' => array('path' => 'bef_test_page')));
// Add field to default display
// $this->addField('node.title');
// Turn of Better Exposed Filters
$this->setBefExposedForm();
}
示例15: __init
/**
* Initialize auto-inc values on dev site. Run this function only once, at setup.
*/
function __init()
{
// Bring config vars into function namespace
extract(__config());
// Enable profile module
drush_print("Installing profile module.");
if (drush_drupal_major_version() < 7) {
include_once 'includes/install.inc';
drupal_install_modules(array('profile'));
} else {
module_enable(array('profile'));
}
// Set auto-increment values
$tables = array('authmap', 'comments', 'files', 'node', 'node_revisions', 'profile_fields', 'role', 'term_data', 'url_alias', 'users', 'vocabulary');
foreach ($tables as $table) {
$value = ${$table};
db_query("ALTER TABLE `{$table}` AUTO_INCREMENT = %d", $value);
drush_print("Set auto-increment value for {$table} to {$value}");
}
unset($value);
drush_print("Initialization done!");
}