Issue #2210197 by sun, longwave: Remove public access to Extension::$type, ::$name, ::$filename.
parent
2187fd1ee3
commit
2c51074d59
|
@ -835,7 +835,7 @@ function install_tasks($install_state) {
|
|||
// Load the profile install file, because it is not always loaded when
|
||||
// hook_install_tasks() is invoked (e.g. batch processing).
|
||||
$profile = $install_state['parameters']['profile'];
|
||||
$profile_install_file = dirname($install_state['profiles'][$profile]->uri) . '/' . $profile . '.install';
|
||||
$profile_install_file = $install_state['profiles'][$profile]->getPath() . '/' . $profile . '.install';
|
||||
if (file_exists($profile_install_file)) {
|
||||
include_once DRUPAL_ROOT . '/' . $profile_install_file;
|
||||
}
|
||||
|
@ -1351,19 +1351,19 @@ function _install_select_profile($profiles) {
|
|||
$request_params = \Drupal::request()->request;
|
||||
if (count($profiles) == 1) {
|
||||
$profile = array_pop($profiles);
|
||||
return $profile->name;
|
||||
return $profile->getName();
|
||||
}
|
||||
elseif ($request_params->has('profile') && ($profile = $request_params->get('profile')) && isset($profiles[$profile])) {
|
||||
return $profiles[$profile]->name;
|
||||
return $profiles[$profile]->getName();
|
||||
}
|
||||
// Check for a profile marked as "exclusive" and ensure that only one
|
||||
// profile is marked as such.
|
||||
$exclusive_profile = NULL;
|
||||
foreach ($profiles as $profile) {
|
||||
$profile_info = install_profile_info($profile->name);
|
||||
$profile_info = install_profile_info($profile->getName());
|
||||
if (!empty($profile_info['exclusive'])) {
|
||||
if (empty($exclusive_profile)) {
|
||||
$exclusive_profile = $profile->name;
|
||||
$exclusive_profile = $profile->getName();
|
||||
}
|
||||
else {
|
||||
// We found a second "exclusive" profile. There's no way to choose
|
||||
|
@ -1388,7 +1388,7 @@ function install_select_profile_form($form, &$form_state, $install_state) {
|
|||
$names = array();
|
||||
|
||||
foreach ($install_state['profiles'] as $profile) {
|
||||
$details = install_profile_info($profile->name);
|
||||
$details = install_profile_info($profile->getName());
|
||||
// Skip this extension if its type is not profile.
|
||||
if (!isset($details['type']) || $details['type'] != 'profile') {
|
||||
continue;
|
||||
|
@ -1398,12 +1398,12 @@ function install_select_profile_form($form, &$form_state, $install_state) {
|
|||
if ($details['hidden'] === TRUE) {
|
||||
continue;
|
||||
}
|
||||
$profiles[$profile->name] = $details;
|
||||
$profiles[$profile->getName()] = $details;
|
||||
|
||||
// Determine the name of the profile; default to file name if defined name
|
||||
// is unspecified.
|
||||
$name = isset($details['name']) ? $details['name'] : $profile->name;
|
||||
$names[$profile->name] = $name;
|
||||
$name = isset($details['name']) ? $details['name'] : $profile->getName();
|
||||
$names[$profile->getName()] = $name;
|
||||
}
|
||||
|
||||
// Display radio buttons alphabetically by human-readable name, but always
|
||||
|
|
|
@ -573,9 +573,7 @@ function drupal_verify_profile($install_state) {
|
|||
include_once __DIR__ . '/common.inc';
|
||||
|
||||
$profile = $install_state['parameters']['profile'];
|
||||
$profile_file = $install_state['profiles'][$profile]->uri;
|
||||
|
||||
if (!isset($profile) || !file_exists($profile_file)) {
|
||||
if (!isset($profile) || !isset($install_state['profiles'][$profile])) {
|
||||
throw new Exception(install_no_profile_error());
|
||||
}
|
||||
$info = $install_state['profile_info'];
|
||||
|
@ -584,7 +582,7 @@ function drupal_verify_profile($install_state) {
|
|||
$listing = new ExtensionDiscovery();
|
||||
$present_modules = array();
|
||||
foreach ($listing->scan('module') as $present_module) {
|
||||
$present_modules[] = $present_module->name;
|
||||
$present_modules[] = $present_module->getName();
|
||||
}
|
||||
|
||||
// The installation profile is also a module, which needs to be installed
|
||||
|
|
|
@ -63,7 +63,7 @@ function system_list($type) {
|
|||
$lists['filepaths'][] = array(
|
||||
'type' => 'theme',
|
||||
'name' => $name,
|
||||
'filepath' => $theme->filename,
|
||||
'filepath' => $theme->getPathname(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ const RESPONSIVE_PRIORITY_LOW = 'priority-low';
|
|||
*/
|
||||
function drupal_theme_access($theme) {
|
||||
if ($theme instanceof Extension) {
|
||||
$theme = $theme->name;
|
||||
$theme = $theme->getName();
|
||||
}
|
||||
return \Drupal::service('access_check.theme')->checkAccess($theme);
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ function _drupal_theme_initialize($theme, $base_theme = array()) {
|
|||
$theme_info = $theme;
|
||||
$base_theme_info = $base_theme;
|
||||
|
||||
$theme_path = dirname($theme->filename);
|
||||
$theme_path = $theme->getPath();
|
||||
|
||||
// Prepare stylesheets from this theme as well as all ancestor themes.
|
||||
// We work it this way so that we can have child themes override parent
|
||||
|
@ -155,7 +155,7 @@ function _drupal_theme_initialize($theme, $base_theme = array()) {
|
|||
}
|
||||
}
|
||||
}
|
||||
$base_theme_path = dirname($base->filename);
|
||||
$base_theme_path = $base->getPath();
|
||||
if (!empty($base->info['stylesheets-remove'])) {
|
||||
foreach ($base->info['stylesheets-remove'] as $basename) {
|
||||
$theme->stylesheets_remove[$basename] = $base_theme_path . '/' . $basename;
|
||||
|
@ -793,7 +793,7 @@ function drupal_find_theme_templates($cache, $extension, $path) {
|
|||
$theme_paths = array();
|
||||
foreach (list_themes() as $theme_info) {
|
||||
if (!empty($theme_info->base_theme)) {
|
||||
$theme_paths[$theme_info->base_theme][$theme_info->name] = dirname($theme_info->filename);
|
||||
$theme_paths[$theme_info->base_theme][$theme_info->getName()] = $theme_info->getPath();
|
||||
}
|
||||
}
|
||||
foreach ($theme_paths as $basetheme => $subthemes) {
|
||||
|
@ -955,7 +955,7 @@ function theme_get_setting($setting_name, $theme = NULL) {
|
|||
if ($cache[$theme]->get('features.logo')) {
|
||||
$logo_path = $cache[$theme]->get('logo.path');
|
||||
if ($cache[$theme]->get('logo.use_default')) {
|
||||
$cache[$theme]->set('logo.url', file_create_url(dirname($theme_object->filename) . '/logo.png'));
|
||||
$cache[$theme]->set('logo.url', file_create_url($theme_object->getPath() . '/logo.png'));
|
||||
}
|
||||
elseif ($logo_path) {
|
||||
$cache[$theme]->set('logo.url', file_create_url($logo_path));
|
||||
|
@ -966,7 +966,7 @@ function theme_get_setting($setting_name, $theme = NULL) {
|
|||
if ($cache[$theme]->get('features.favicon')) {
|
||||
$favicon_path = $cache[$theme]->get('favicon.path');
|
||||
if ($cache[$theme]->get('favicon.use_default')) {
|
||||
if (file_exists($favicon = dirname($theme_object->filename) . '/favicon.ico')) {
|
||||
if (file_exists($favicon = $theme_object->getPath() . '/favicon.ico')) {
|
||||
$cache[$theme]->set('favicon.url', file_create_url($favicon));
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -290,10 +290,8 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
|
|||
* @param $module
|
||||
* The name of the module.
|
||||
*
|
||||
* @return \stdClass|bool
|
||||
* Returns a stdClass object if the module data is found containing at
|
||||
* least an uri property with the module path, for example
|
||||
* core/modules/user/user.module.
|
||||
* @return \Drupal\Core\Extension\Extension|bool
|
||||
* Returns an Extension object if the module is found, FALSE otherwise.
|
||||
*/
|
||||
protected function moduleData($module) {
|
||||
if (!$this->moduleData) {
|
||||
|
|
|
@ -15,11 +15,9 @@ class Extension implements \Serializable {
|
|||
/**
|
||||
* The type of the extension (e.g., 'module').
|
||||
*
|
||||
* @todo Replace all uses of $type with getType() method.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* The relative pathname of the extension (e.g., 'core/modules/node/node.info.yml').
|
||||
|
@ -28,15 +26,6 @@ class Extension implements \Serializable {
|
|||
*/
|
||||
protected $pathname;
|
||||
|
||||
/**
|
||||
* The internal name of the extension (e.g., 'node').
|
||||
*
|
||||
* @todo Replace all uses of $name with getName() method.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* The relative pathname of the main extension file (e.g., 'core/modules/node/node.module').
|
||||
*
|
||||
|
@ -50,21 +39,9 @@ class Extension implements \Serializable {
|
|||
/**
|
||||
* The filename of the main extension file (e.g., 'node.module').
|
||||
*
|
||||
* Note that this is not necessarily a filename but a pathname and also not
|
||||
* necessarily the filename of the info file. Due to legacy code and property
|
||||
* value overloading, it is either the filename of the main extension file or
|
||||
* the relative pathname of the main extension file (== $uri), depending on
|
||||
* whether the object has been post-processed or not.
|
||||
*
|
||||
* @see _system_rebuild_module_data()
|
||||
* @see \Drupal\Core\Extension\ThemeHandler::rebuildThemeData()
|
||||
*
|
||||
* @todo Remove this property and do not require .module/.profile files.
|
||||
* @see https://drupal.org/node/340723
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $filename;
|
||||
protected $filename;
|
||||
|
||||
/**
|
||||
* An SplFileInfo instance for the extension's info file.
|
||||
|
@ -90,7 +67,6 @@ class Extension implements \Serializable {
|
|||
$this->type = $type;
|
||||
$this->pathname = $pathname;
|
||||
// Set legacy public properties.
|
||||
$this->name = basename($pathname, '.info.yml');
|
||||
$this->filename = $filename;
|
||||
$this->uri = dirname($pathname) . '/' . $filename;
|
||||
}
|
||||
|
@ -207,7 +183,6 @@ class Extension implements \Serializable {
|
|||
// @todo Remove these properties and do not require .module/.profile files.
|
||||
// @see https://drupal.org/node/340723
|
||||
// @see Extension::$filename
|
||||
$this->name = basename($data['pathname'], '.info.yml');
|
||||
$this->uri = dirname($data['pathname']) . '/' . $data['filename'];
|
||||
$this->filename = $data['filename'];
|
||||
|
||||
|
|
|
@ -278,14 +278,14 @@ class ExtensionDiscovery {
|
|||
// e.g. new modules were introduced in core while older contrib modules with
|
||||
// the same name still exist in a later search path.
|
||||
foreach ($all_files as $file) {
|
||||
if (isset($files[$file->name])) {
|
||||
if (isset($files[$file->getName()])) {
|
||||
// Skip the extension if it is incompatible with Drupal core.
|
||||
$info = $this->getInfoParser()->parse($file->getPathname());
|
||||
if (!isset($info['core']) || $info['core'] != \Drupal::CORE_COMPATIBILITY) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$files[$file->name] = $file;
|
||||
$files[$file->getName()] = $file;
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
|
@ -366,16 +366,12 @@ class ExtensionDiscovery {
|
|||
$name = $fileinfo->getBasename('.info.yml');
|
||||
$pathname = $dir_prefix . $fileinfo->getSubPathname();
|
||||
|
||||
// Supply main extension filename being used throughout Drupal.
|
||||
// For themes, the filename is the info file itself.
|
||||
if ($type == 'theme') {
|
||||
$filename = $fileinfo->getFilename();
|
||||
}
|
||||
// Determine whether the extension has a main extension file.
|
||||
// For theme engines, the file extension is .engine.
|
||||
elseif ($type == 'theme_engine') {
|
||||
if ($type == 'theme_engine') {
|
||||
$filename = $name . '.engine';
|
||||
}
|
||||
// Otherwise, it is .module/.profile; i.e., the extension type.
|
||||
// For profiles/modules/themes, it is the extension type.
|
||||
else {
|
||||
$filename = $name . '.' . $type;
|
||||
}
|
||||
|
|
|
@ -145,11 +145,11 @@ class ModuleHandler implements ModuleHandlerInterface {
|
|||
*/
|
||||
public function buildModuleDependencies(array $modules) {
|
||||
foreach ($modules as $module) {
|
||||
$graph[$module->name]['edges'] = array();
|
||||
$graph[$module->getName()]['edges'] = array();
|
||||
if (isset($module->info['dependencies']) && is_array($module->info['dependencies'])) {
|
||||
foreach ($module->info['dependencies'] as $dependency) {
|
||||
$dependency_data = static::parseDependency($dependency);
|
||||
$graph[$module->name]['edges'][$dependency_data['name']] = $dependency_data;
|
||||
$graph[$module->getName()]['edges'][$dependency_data['name']] = $dependency_data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ class ModuleHandler implements ModuleHandlerInterface {
|
|||
if (isset($theme)) {
|
||||
$theme_keys = array();
|
||||
foreach ($base_theme_info as $base) {
|
||||
$theme_keys[] = $base->name;
|
||||
$theme_keys[] = $base->getName();
|
||||
}
|
||||
$theme_keys[] = $theme;
|
||||
foreach ($theme_keys as $theme_key) {
|
||||
|
|
|
@ -220,7 +220,7 @@ class ThemeHandler implements ThemeHandlerInterface {
|
|||
if (!isset($theme->status)) {
|
||||
$theme->status = 0;
|
||||
}
|
||||
$this->list[$theme->name] = $theme;
|
||||
$this->list[$theme->getName()] = $theme;
|
||||
}
|
||||
}
|
||||
return $this->list;
|
||||
|
@ -271,7 +271,6 @@ class ThemeHandler implements ThemeHandlerInterface {
|
|||
$sub_themes = array();
|
||||
// Read info files for each theme.
|
||||
foreach ($themes as $key => $theme) {
|
||||
$theme->filename = $theme->uri;
|
||||
$theme->info = $this->infoParser->parse($theme->getPathname()) + $defaults;
|
||||
|
||||
// Add the info file modification time, so it becomes available for
|
||||
|
@ -292,7 +291,7 @@ class ThemeHandler implements ThemeHandlerInterface {
|
|||
$engine = $theme->info['engine'];
|
||||
if (isset($engines[$engine])) {
|
||||
$theme->owner = $engines[$engine]->uri;
|
||||
$theme->prefix = $engines[$engine]->name;
|
||||
$theme->prefix = $engines[$engine]->getName();
|
||||
}
|
||||
|
||||
// Prefix stylesheets, scripts, and screenshot with theme path.
|
||||
|
|
|
@ -39,13 +39,16 @@ class TwigEnvironment extends \Twig_Environment {
|
|||
$this->cache_object = \Drupal::cache();
|
||||
|
||||
// Set twig path namespace for themes and modules.
|
||||
$namespaces = $module_handler->getModuleList();
|
||||
foreach ($theme_handler->listInfo() as $theme => $info) {
|
||||
$namespaces[$theme] = $info->filename;
|
||||
$namespaces = array();
|
||||
foreach ($module_handler->getModuleList() as $name => $filename) {
|
||||
$namespaces[$name] = dirname($filename);
|
||||
}
|
||||
foreach ($theme_handler->listInfo() as $name => $extension) {
|
||||
$namespaces[$name] = $extension->getPath();
|
||||
}
|
||||
|
||||
foreach ($namespaces as $name => $filename) {
|
||||
$templatesDirectory = dirname($filename) . '/templates';
|
||||
foreach ($namespaces as $name => $path) {
|
||||
$templatesDirectory = $path . '/templates';
|
||||
if (file_exists($templatesDirectory)) {
|
||||
$loader->addPath($templatesDirectory, $name);
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ class Registry implements DestructableInterface {
|
|||
}
|
||||
// #2: The testing framework only cares for the global $theme variable at
|
||||
// this point. Cope with that.
|
||||
if ($GLOBALS['theme'] != $GLOBALS['theme_info']->name) {
|
||||
if ($GLOBALS['theme'] != $GLOBALS['theme_info']->getName()) {
|
||||
unset($this->runtimeRegistry);
|
||||
unset($this->registry);
|
||||
$this->initializeTheme();
|
||||
|
@ -207,7 +207,7 @@ class Registry implements DestructableInterface {
|
|||
if (isset($this->registry)) {
|
||||
return $this->registry;
|
||||
}
|
||||
if ($cache = $this->cache->get('theme_registry:' . $this->theme->name)) {
|
||||
if ($cache = $this->cache->get('theme_registry:' . $this->theme->getName())) {
|
||||
$this->registry = $cache->data;
|
||||
}
|
||||
else {
|
||||
|
@ -230,7 +230,7 @@ class Registry implements DestructableInterface {
|
|||
*/
|
||||
public function getRuntime() {
|
||||
if (!isset($this->runtimeRegistry)) {
|
||||
$this->runtimeRegistry = new ThemeRegistry('theme_registry:runtime:' . $this->theme->name, $this->cache, $this->lock, array('theme_registry' => TRUE), $this->moduleHandler->isLoaded());
|
||||
$this->runtimeRegistry = new ThemeRegistry('theme_registry:runtime:' . $this->theme->getName(), $this->cache, $this->lock, array('theme_registry' => TRUE), $this->moduleHandler->isLoaded());
|
||||
}
|
||||
return $this->runtimeRegistry;
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ class Registry implements DestructableInterface {
|
|||
* Persists the theme registry in the cache backend.
|
||||
*/
|
||||
protected function setCache() {
|
||||
$this->cache->set('theme_registry:' . $this->theme->name, $this->registry, Cache::PERMANENT, array('theme_registry' => TRUE));
|
||||
$this->cache->set('theme_registry:' . $this->theme->getName(), $this->registry, Cache::PERMANENT, array('theme_registry' => TRUE));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -319,20 +319,20 @@ class Registry implements DestructableInterface {
|
|||
// Process each base theme.
|
||||
foreach ($this->baseThemes as $base) {
|
||||
// If the base theme uses a theme engine, process its hooks.
|
||||
$base_path = dirname($base->filename);
|
||||
$base_path = $base->getPath();
|
||||
if ($this->engine) {
|
||||
$this->processExtension($cache, $this->engine, 'base_theme_engine', $base->name, $base_path);
|
||||
$this->processExtension($cache, $this->engine, 'base_theme_engine', $base->getName(), $base_path);
|
||||
}
|
||||
$this->processExtension($cache, $base->name, 'base_theme', $base->name, $base_path);
|
||||
$this->processExtension($cache, $base->getName(), 'base_theme', $base->getName(), $base_path);
|
||||
}
|
||||
|
||||
// And then the same thing, but for the theme.
|
||||
if ($this->engine) {
|
||||
$this->processExtension($cache, $this->engine, 'theme_engine', $this->theme->name, dirname($this->theme->filename));
|
||||
$this->processExtension($cache, $this->engine, 'theme_engine', $this->theme->getName(), $this->theme->getPath());
|
||||
}
|
||||
|
||||
// Finally, hooks provided by the theme itself.
|
||||
$this->processExtension($cache, $this->theme->name, 'theme', $this->theme->name, dirname($this->theme->filename));
|
||||
$this->processExtension($cache, $this->theme->getName(), 'theme', $this->theme->getName(), $this->theme->getPath());
|
||||
|
||||
// Let modules alter the registry.
|
||||
$this->moduleHandler->alter('theme_registry', $cache);
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
namespace Drupal\Core\Utility;
|
||||
|
||||
use Drupal\Core\Extension\Extension;
|
||||
|
||||
/**
|
||||
* Performs operations on drupal.org project data.
|
||||
*/
|
||||
|
@ -94,8 +96,7 @@ class ProjectInfo {
|
|||
// which is left alone by tar and correctly set to the time the .info.yml
|
||||
// file was unpacked.
|
||||
if (!isset($file->info['_info_file_ctime'])) {
|
||||
$info_filename = dirname($file->uri) . '/' . $file->name . '.info.yml';
|
||||
$file->info['_info_file_ctime'] = filectime($info_filename);
|
||||
$file->info['_info_file_ctime'] = $file->getCTime();
|
||||
}
|
||||
|
||||
if (!isset($file->info['datestamp'])) {
|
||||
|
@ -142,7 +143,7 @@ class ProjectInfo {
|
|||
// not bloat our RAM usage needlessly.
|
||||
'info' => $this->filterProjectInfo($file->info, $additional_whitelist),
|
||||
'datestamp' => $file->info['datestamp'],
|
||||
'includes' => array($file->name => $file->info['name']),
|
||||
'includes' => array($file->getName() => $file->info['name']),
|
||||
'project_type' => $project_display_type,
|
||||
'project_status' => $status,
|
||||
'sub_themes' => $sub_themes,
|
||||
|
@ -155,7 +156,7 @@ class ProjectInfo {
|
|||
// $project_display_type). This prevents listing all the disabled
|
||||
// modules included with an enabled project if we happen to be checking
|
||||
// for disabled modules, too.
|
||||
$projects[$project_name]['includes'][$file->name] = $file->info['name'];
|
||||
$projects[$project_name]['includes'][$file->getName()] = $file->info['name'];
|
||||
$projects[$project_name]['info']['_info_file_ctime'] = max($projects[$project_name]['info']['_info_file_ctime'], $file->info['_info_file_ctime']);
|
||||
$projects[$project_name]['datestamp'] = max($projects[$project_name]['datestamp'], $file->info['datestamp']);
|
||||
if (!empty($sub_themes)) {
|
||||
|
@ -170,7 +171,7 @@ class ProjectInfo {
|
|||
// does not, it means we're processing a disabled module or theme that
|
||||
// belongs to a project that has some enabled code. In this case, we add
|
||||
// the disabled thing into a separate array for separate display.
|
||||
$projects[$project_name]['disabled'][$file->name] = $file->info['name'];
|
||||
$projects[$project_name]['disabled'][$file->getName()] = $file->info['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -184,12 +185,12 @@ class ProjectInfo {
|
|||
* @return string
|
||||
* The canonical project short name.
|
||||
*/
|
||||
function getProjectName($file) {
|
||||
function getProjectName(Extension $file) {
|
||||
$project_name = '';
|
||||
if (isset($file->info['project'])) {
|
||||
$project_name = $file->info['project'];
|
||||
}
|
||||
elseif (isset($file->filename) && (strpos($file->filename, 'core/modules') === 0)) {
|
||||
elseif (strpos($file->getPath(), 'core/modules') === 0) {
|
||||
$project_name = 'drupal';
|
||||
}
|
||||
return $project_name;
|
||||
|
|
|
@ -72,7 +72,7 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa
|
|||
$directories[$module] = dirname($filename);
|
||||
}
|
||||
foreach ($theme_handler->listInfo() as $theme) {
|
||||
$directories[$theme->name] = dirname($theme->filename);
|
||||
$directories[$theme->getName()] = $theme->getPath();
|
||||
}
|
||||
|
||||
// Check for files named MODULE.config_translation.yml and
|
||||
|
|
|
@ -8,6 +8,7 @@ use Drupal\Component\Utility\Html;
|
|||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Entity\ContentEntityInterface;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Extension\Extension;
|
||||
use Drupal\Core\Template\Attribute;
|
||||
use Drupal\entity\Entity\EntityViewDisplay;
|
||||
use Drupal\field\Field;
|
||||
|
@ -157,11 +158,11 @@ function field_cron() {
|
|||
* Goes through a list of all modules that provide a field type and makes them
|
||||
* required if there are any active fields of that type.
|
||||
*/
|
||||
function field_system_info_alter(&$info, $file, $type) {
|
||||
function field_system_info_alter(&$info, Extension $file, $type) {
|
||||
// It is not safe to call entity_load_multiple_by_properties() during
|
||||
// maintenance mode.
|
||||
if ($type == 'module' && !defined('MAINTENANCE_MODE')) {
|
||||
$fields = entity_load_multiple_by_properties('field_config', array('module' => $file->name, 'include_deleted' => TRUE));
|
||||
$fields = entity_load_multiple_by_properties('field_config', array('module' => $file->getName(), 'include_deleted' => TRUE));
|
||||
if ($fields) {
|
||||
$info['required'] = TRUE;
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* @file
|
||||
* Simulate a custom module with a local po file.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Extension\Extension;
|
||||
use Drupal\Core\StreamWrapper\PublicStream;
|
||||
|
||||
/**
|
||||
|
@ -12,13 +14,13 @@ use Drupal\Core\StreamWrapper\PublicStream;
|
|||
* Make the test scripts to be believe this is not a hidden test module, but
|
||||
* a regular custom module.
|
||||
*/
|
||||
function locale_test_system_info_alter(&$info, $file, $type) {
|
||||
function locale_test_system_info_alter(&$info, Extension $file, $type) {
|
||||
// Only modify the system info if required.
|
||||
// By default the locale_test modules are hidden and have a project specified.
|
||||
// To test the module detection process by locale_project_list() the
|
||||
// test modules should mimic a custom module. I.e. be non-hidden.
|
||||
if (\Drupal::state()->get('locale.test_system_info_alter')) {
|
||||
if ($file->name == 'locale_test' || $file->name == 'locale_test_translate') {
|
||||
if ($file->getName() == 'locale_test' || $file->getName() == 'locale_test_translate') {
|
||||
// Don't hide the module.
|
||||
$info['hidden'] = FALSE;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* Simulates a custom module with a local po file.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Extension\Extension;
|
||||
|
||||
/**
|
||||
* Implements hook_system_info_alter().
|
||||
*
|
||||
|
@ -12,8 +14,8 @@
|
|||
* (not hidden) module. This hook implementation changes the .info.yml data by
|
||||
* setting the hidden status to FALSE.
|
||||
*/
|
||||
function locale_test_translate_system_info_alter(&$info, $file, $type) {
|
||||
if ($file->name == 'locale_test_translate') {
|
||||
function locale_test_translate_system_info_alter(&$info, Extension $file, $type) {
|
||||
if ($file->getName() == 'locale_test_translate') {
|
||||
// Don't hide the module.
|
||||
$info['hidden'] = FALSE;
|
||||
}
|
||||
|
|
|
@ -200,17 +200,17 @@ class SystemController extends ControllerBase {
|
|||
if (!empty($theme->info['hidden'])) {
|
||||
continue;
|
||||
}
|
||||
$theme->is_default = ($theme->name == $theme_default);
|
||||
$theme->is_default = ($theme->getName() == $theme_default);
|
||||
|
||||
// Identify theme screenshot.
|
||||
$theme->screenshot = NULL;
|
||||
// Create a list which includes the current theme and all its base themes.
|
||||
if (isset($themes[$theme->name]->base_themes)) {
|
||||
$theme_keys = array_keys($themes[$theme->name]->base_themes);
|
||||
$theme_keys[] = $theme->name;
|
||||
if (isset($themes[$theme->getName()]->base_themes)) {
|
||||
$theme_keys = array_keys($themes[$theme->getName()]->base_themes);
|
||||
$theme_keys[] = $theme->getName();
|
||||
}
|
||||
else {
|
||||
$theme_keys = array($theme->name);
|
||||
$theme_keys = array($theme->getName());
|
||||
}
|
||||
// Look for a screenshot in the current theme or in its closest ancestor.
|
||||
foreach (array_reverse($theme_keys) as $theme_key) {
|
||||
|
@ -239,18 +239,18 @@ class SystemController extends ControllerBase {
|
|||
$theme->operations = array();
|
||||
if (!empty($theme->status) || !$theme->incompatible_core && !$theme->incompatible_php && !$theme->incompatible_base && !$theme->incompatible_engine) {
|
||||
// Create the operations links.
|
||||
$query['theme'] = $theme->name;
|
||||
if ($this->themeAccess->checkAccess($theme->name)) {
|
||||
$query['theme'] = $theme->getName();
|
||||
if ($this->themeAccess->checkAccess($theme->getName())) {
|
||||
$theme->operations[] = array(
|
||||
'title' => $this->t('Settings'),
|
||||
'route_name' => 'system.theme_settings_theme',
|
||||
'route_parameters' => array('theme' => $theme->name),
|
||||
'route_parameters' => array('theme' => $theme->getName()),
|
||||
'attributes' => array('title' => $this->t('Settings for !theme theme', array('!theme' => $theme->info['name']))),
|
||||
);
|
||||
}
|
||||
if (!empty($theme->status)) {
|
||||
if (!$theme->is_default) {
|
||||
if ($theme->name != $admin_theme) {
|
||||
if ($theme->getName() != $admin_theme) {
|
||||
$theme->operations[] = array(
|
||||
'title' => $this->t('Disable'),
|
||||
'route_name' => 'system.theme_disable',
|
||||
|
@ -265,7 +265,7 @@ class SystemController extends ControllerBase {
|
|||
'attributes' => array('title' => $this->t('Set !theme as default theme', array('!theme' => $theme->info['name']))),
|
||||
);
|
||||
}
|
||||
$admin_theme_options[$theme->name] = $theme->info['name'];
|
||||
$admin_theme_options[$theme->getName()] = $theme->info['name'];
|
||||
}
|
||||
else {
|
||||
$theme->operations[] = array(
|
||||
|
@ -290,7 +290,7 @@ class SystemController extends ControllerBase {
|
|||
$theme->classes[] = 'theme-default';
|
||||
$theme->notes[] = $this->t('default theme');
|
||||
}
|
||||
if ($theme->name == $admin_theme || ($theme->is_default && $admin_theme == '0')) {
|
||||
if ($theme->getName() == $admin_theme || ($theme->is_default && $admin_theme == '0')) {
|
||||
$theme->classes[] = 'theme-admin';
|
||||
$theme->notes[] = $this->t('admin theme');
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ use Drupal\Component\Utility\Unicode;
|
|||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Entity\Query\QueryFactory;
|
||||
use Drupal\Core\Entity\Query\QueryFactoryInterface;
|
||||
use Drupal\Core\Extension\Extension;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface;
|
||||
|
@ -176,14 +177,14 @@ class ModulesListForm extends FormBase {
|
|||
*
|
||||
* @param array $modules
|
||||
* The list existing modules.
|
||||
* @param object $module
|
||||
* @param \Drupal\Core\Extension\Extension $module
|
||||
* The module for which to build the form row.
|
||||
* @param $distribution
|
||||
*
|
||||
* @return array
|
||||
* The form row for the given module.
|
||||
*/
|
||||
protected function buildRow(array $modules, $module, $distribution) {
|
||||
protected function buildRow(array $modules, Extension $module, $distribution) {
|
||||
// Set the basic properties.
|
||||
$row['#required'] = array();
|
||||
$row['#requires'] = array();
|
||||
|
@ -199,12 +200,12 @@ class ModulesListForm extends FormBase {
|
|||
|
||||
// Generate link for module's help page, if there is one.
|
||||
$row['links']['help'] = array();
|
||||
if ($help && $module->status && in_array($module->name, $this->moduleHandler->getImplementations('help'))) {
|
||||
if ($this->moduleHandler->invoke($module->name, 'help', array("admin/help#$module->name", $help))) {
|
||||
if ($help && $module->status && in_array($module->getName(), $this->moduleHandler->getImplementations('help'))) {
|
||||
if ($this->moduleHandler->invoke($module->getName(), 'help', array('admin/help#' . $module->getName(), $help))) {
|
||||
$row['links']['help'] = array(
|
||||
'#type' => 'link',
|
||||
'#title' => $this->t('Help'),
|
||||
'#href' => "admin/help/$module->name",
|
||||
'#href' => 'admin/help/' . $module->getName(),
|
||||
'#options' => array('attributes' => array('class' => array('module-link', 'module-link-help'), 'title' => $this->t('Help'))),
|
||||
);
|
||||
}
|
||||
|
@ -212,12 +213,12 @@ class ModulesListForm extends FormBase {
|
|||
|
||||
// Generate link for module's permission, if the user has access to it.
|
||||
$row['links']['permissions'] = array();
|
||||
if ($module->status && user_access('administer permissions') && in_array($module->name, $this->moduleHandler->getImplementations('permission'))) {
|
||||
if ($module->status && user_access('administer permissions') && in_array($module->getName(), $this->moduleHandler->getImplementations('permission'))) {
|
||||
$row['links']['permissions'] = array(
|
||||
'#type' => 'link',
|
||||
'#title' => $this->t('Permissions'),
|
||||
'#href' => 'admin/people/permissions',
|
||||
'#options' => array('fragment' => 'module-' . $module->name, 'attributes' => array('class' => array('module-link', 'module-link-permissions'), 'title' => $this->t('Configure permissions'))),
|
||||
'#options' => array('fragment' => 'module-' . $module->getName(), 'attributes' => array('class' => array('module-link', 'module-link-permissions'), 'title' => $this->t('Configure permissions'))),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ class ModulesUninstallForm extends FormBase {
|
|||
// Get a list of disabled, installed modules.
|
||||
$modules = system_rebuild_module_data();
|
||||
$uninstallable = array_filter($modules, function ($module) use ($modules) {
|
||||
return empty($modules[$module->name]->info['required']) && drupal_get_installed_schema_version($module->name) > SCHEMA_UNINSTALLED;
|
||||
return empty($modules[$module->getName()]->info['required']) && drupal_get_installed_schema_version($module->getName()) > SCHEMA_UNINSTALLED;
|
||||
});
|
||||
|
||||
$form['modules'] = array();
|
||||
|
@ -89,12 +89,12 @@ class ModulesUninstallForm extends FormBase {
|
|||
|
||||
$form['uninstall'] = array('#tree' => TRUE);
|
||||
foreach ($uninstallable as $module) {
|
||||
$name = $module->info['name'] ?: $module->name;
|
||||
$form['modules'][$module->name]['#module_name'] = $name;
|
||||
$form['modules'][$module->name]['name']['#markup'] = $name;
|
||||
$form['modules'][$module->name]['description']['#markup'] = $this->t($module->info['description']);
|
||||
$name = $module->info['name'] ?: $module->getName();
|
||||
$form['modules'][$module->getName()]['#module_name'] = $name;
|
||||
$form['modules'][$module->getName()]['name']['#markup'] = $name;
|
||||
$form['modules'][$module->getName()]['description']['#markup'] = $this->t($module->info['description']);
|
||||
|
||||
$form['uninstall'][$module->name] = array(
|
||||
$form['uninstall'][$module->getName()] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Uninstall @module module', array('@module' => $name)),
|
||||
'#title_display' => 'invisible',
|
||||
|
@ -106,8 +106,8 @@ class ModulesUninstallForm extends FormBase {
|
|||
foreach (array_keys($module->required_by) as $dependent) {
|
||||
if ($dependent != $profile && drupal_get_installed_schema_version($dependent) != SCHEMA_UNINSTALLED) {
|
||||
$name = isset($modules[$dependent]->info['name']) ? $modules[$dependent]->info['name'] : $dependent;
|
||||
$form['modules'][$module->name]['#required_by'][] = $name;
|
||||
$form['uninstall'][$module->name]['#disabled'] = TRUE;
|
||||
$form['modules'][$module->getName()]['#required_by'][] = $name;
|
||||
$form['uninstall'][$module->getName()]['#disabled'] = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -288,7 +288,7 @@ class ThemeSettingsForm extends ConfigFormBase {
|
|||
// Process the theme and all its base themes.
|
||||
foreach ($theme_keys as $theme) {
|
||||
// Include the theme-settings.php file.
|
||||
$filename = DRUPAL_ROOT . '/' . str_replace("/$theme.info.yml", '', $themes[$theme]->filename) . '/theme-settings.php';
|
||||
$filename = DRUPAL_ROOT . '/' . $themes[$theme]->getPath() . '/theme-settings.php';
|
||||
if (file_exists($filename)) {
|
||||
require_once $filename;
|
||||
}
|
||||
|
|
|
@ -35,17 +35,17 @@ class GetFilenameUnitTest extends UnitTestBase {
|
|||
// does not exist.
|
||||
$this->assertFalse(\Drupal::hasService('keyvalue'), 'The container has no keyvalue service.');
|
||||
// Retrieving the location of a module.
|
||||
$this->assertIdentical(drupal_get_filename('module', 'xmlrpc'), 'core/modules/xmlrpc/xmlrpc.module', 'Retrieve module location.');
|
||||
$this->assertIdentical(drupal_get_filename('module', 'xmlrpc'), 'core/modules/xmlrpc/xmlrpc.module');
|
||||
|
||||
// Retrieving the location of a theme.
|
||||
$this->assertIdentical(drupal_get_filename('theme', 'stark'), 'core/themes/stark/stark.info.yml', 'Retrieve theme location.');
|
||||
$this->assertIdentical(drupal_get_filename('theme', 'stark'), 'core/themes/stark/stark.theme');
|
||||
|
||||
// Retrieving the location of a theme engine.
|
||||
$this->assertIdentical(drupal_get_filename('theme_engine', 'phptemplate'), 'core/themes/engines/phptemplate/phptemplate.engine', 'Retrieve theme engine location.');
|
||||
$this->assertIdentical(drupal_get_filename('theme_engine', 'phptemplate'), 'core/themes/engines/phptemplate/phptemplate.engine');
|
||||
|
||||
// Retrieving the location of a profile. Profiles are a special case with
|
||||
// a fixed location and naming.
|
||||
$this->assertIdentical(drupal_get_filename('profile', 'standard'), 'core/profiles/standard/standard.profile', 'Retrieve installation profile location.');
|
||||
$this->assertIdentical(drupal_get_filename('profile', 'standard'), 'core/profiles/standard/standard.profile');
|
||||
|
||||
// Searching for an item that does not exist returns NULL.
|
||||
$this->assertNull(drupal_get_filename('module', uniqid("", TRUE)), 'Searching for an item that does not exist returns NULL.');
|
||||
|
|
|
@ -49,7 +49,7 @@ class SystemListingTest extends DrupalUnitTestBase {
|
|||
// meaning, so assert their presence first.
|
||||
foreach ($expected_directories as $module => $directories) {
|
||||
foreach ($directories as $directory) {
|
||||
$filename = "$directory/$module/$module.module";
|
||||
$filename = "$directory/$module/$module.info.yml";
|
||||
$this->assertTrue(file_exists(DRUPAL_ROOT . '/' . $filename), format_string('@filename exists.', array('@filename' => $filename)));
|
||||
}
|
||||
}
|
||||
|
@ -61,9 +61,9 @@ class SystemListingTest extends DrupalUnitTestBase {
|
|||
$files = $listing->scan('module');
|
||||
foreach ($expected_directories as $module => $directories) {
|
||||
$expected_directory = array_shift($directories);
|
||||
$expected_uri = "$expected_directory/$module/$module.module";
|
||||
$this->assertEqual($files[$module]->uri, $expected_uri, format_string('Module @actual was found at @expected.', array(
|
||||
'@actual' => $files[$module]->uri,
|
||||
$expected_uri = "$expected_directory/$module/$module.info.yml";
|
||||
$this->assertEqual($files[$module]->getPathname(), $expected_uri, format_string('Module @actual was found at @expected.', array(
|
||||
'@actual' => $files[$module]->getPathname(),
|
||||
'@expected' => $expected_uri,
|
||||
)));
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Extension\Extension;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
|
||||
|
@ -61,20 +62,20 @@ function system_theme_default() {
|
|||
* incompatible files as the keys, their values being TRUE.
|
||||
* @param $files
|
||||
* The set of files that will be tested.
|
||||
* @param $file
|
||||
* @param \Drupal\Core\Extension\Extension $file
|
||||
* The file at which the check starts.
|
||||
* @return
|
||||
* Returns TRUE if an incompatible file is found, NULL (no return value)
|
||||
* otherwise.
|
||||
*/
|
||||
function _system_is_incompatible(&$incompatible, $files, $file) {
|
||||
if (isset($incompatible[$file->name])) {
|
||||
function _system_is_incompatible(&$incompatible, $files, Extension $file) {
|
||||
if (isset($incompatible[$file->getName()])) {
|
||||
return TRUE;
|
||||
}
|
||||
// Recursively traverse required modules, looking for incompatible modules.
|
||||
foreach ($file->requires as $requires) {
|
||||
if (isset($files[$requires]) && _system_is_incompatible($incompatible, $files, $files[$requires])) {
|
||||
$incompatible[$file->name] = TRUE;
|
||||
$incompatible[$file->getName()] = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -993,19 +993,18 @@ function hook_system_breadcrumb_alter(array &$breadcrumb, array $attributes, arr
|
|||
* add to or alter the data generated by reading the .info.yml file with
|
||||
* \Drupal\Core\Extension\InfoParser.
|
||||
*
|
||||
* @param $info
|
||||
* @param array $info
|
||||
* The .info.yml file contents, passed by reference so that it can be altered.
|
||||
* @param $file
|
||||
* Full information about the module or theme, including $file->name, and
|
||||
* $file->filename
|
||||
* @param $type
|
||||
* @param \Drupal\Core\Extension\Extension $file
|
||||
* Full information about the module or theme.
|
||||
* @param string $type
|
||||
* Either 'module' or 'theme', depending on the type of .info.yml file that
|
||||
* was passed.
|
||||
*/
|
||||
function hook_system_info_alter(&$info, $file, $type) {
|
||||
function hook_system_info_alter(array &$info, \Drupal\Core\Extension\Extension $file, $type) {
|
||||
// Only fill this in if the .info.yml file does not define a 'datestamp'.
|
||||
if (empty($info['datestamp'])) {
|
||||
$info['datestamp'] = filemtime($file->filename);
|
||||
$info['datestamp'] = $file->getMTime();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1463,7 +1462,7 @@ function hook_cache_flush() {
|
|||
function hook_rebuild() {
|
||||
$themes = list_themes();
|
||||
foreach ($themes as $theme) {
|
||||
_block_rehash($theme->name);
|
||||
_block_rehash($theme->getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2496,7 +2495,7 @@ function hook_system_themes_page_alter(&$theme_groups) {
|
|||
$theme->operations[] = array(
|
||||
'title' => t('Foo'),
|
||||
'href' => 'admin/appearance/foo',
|
||||
'query' => array('theme' => $theme->name)
|
||||
'query' => array('theme' => $theme->getName())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
use Drupal\Core\Cache\CacheBackendInterface;
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Language\Language;
|
||||
use Drupal\Core\Extension\Extension;
|
||||
use Drupal\Core\Extension\ExtensionDiscovery;
|
||||
use Drupal\Core\Utility\ModuleInfo;
|
||||
use Drupal\block\BlockPluginInterface;
|
||||
|
@ -1377,10 +1378,6 @@ function _system_rebuild_module_data() {
|
|||
|
||||
// Read info files for each module.
|
||||
foreach ($modules as $key => $module) {
|
||||
// The module system uses the key 'filename' instead of 'uri' so copy the
|
||||
// value so it will be used by the modules system.
|
||||
$modules[$key]->filename = $module->uri;
|
||||
|
||||
// Look for the info file.
|
||||
$module->info = \Drupal::service('info_parser')->parse($module->getPathname());
|
||||
|
||||
|
@ -1437,7 +1434,7 @@ function _system_rebuild_module_data_ensure_required($module, &$modules) {
|
|||
foreach ($module->info['dependencies'] as $dependant) {
|
||||
if (!isset($modules[$dependant]->info['required'])) {
|
||||
$modules[$dependant]->info['required'] = TRUE;
|
||||
$modules[$dependant]->info['explanation'] = t('Dependency of required module @module', array('@module' => $module->name));
|
||||
$modules[$dependant]->info['explanation'] = t('Dependency of required module @module', array('@module' => $module->info['name']));
|
||||
// Ensure any dependencies it has are required.
|
||||
_system_rebuild_module_data_ensure_required($modules[$dependant], $modules);
|
||||
}
|
||||
|
@ -1595,7 +1592,7 @@ function system_sort_themes($a, $b) {
|
|||
/**
|
||||
* Implements hook_system_info_alter().
|
||||
*/
|
||||
function system_system_info_alter(&$info, $file, $type) {
|
||||
function system_system_info_alter(&$info, Extension $file, $type) {
|
||||
// Remove page-top and page-bottom from the blocks UI since they are reserved for
|
||||
// modules to populate from outside the blocks system.
|
||||
if ($type == 'theme') {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Drupal\Core\Extension\Extension;
|
||||
|
||||
/**
|
||||
* Implements hook_permission().
|
||||
*/
|
||||
|
@ -14,45 +16,45 @@ function module_test_permission() {
|
|||
*
|
||||
* Manipulate module dependencies to test dependency chains.
|
||||
*/
|
||||
function module_test_system_info_alter(&$info, $file, $type) {
|
||||
function module_test_system_info_alter(&$info, Extension $file, $type) {
|
||||
if (\Drupal::state()->get('module_test.dependency') == 'missing dependency') {
|
||||
if ($file->name == 'forum') {
|
||||
if ($file->getName() == 'forum') {
|
||||
// Make forum module depend on ban.
|
||||
$info['dependencies'][] = 'ban';
|
||||
}
|
||||
elseif ($file->name == 'ban') {
|
||||
elseif ($file->getName() == 'ban') {
|
||||
// Make ban depend on a made-up module.
|
||||
$info['dependencies'][] = 'foo';
|
||||
}
|
||||
}
|
||||
elseif (\Drupal::state()->get('module_test.dependency') == 'dependency') {
|
||||
if ($file->name == 'forum') {
|
||||
if ($file->getName() == 'forum') {
|
||||
// Make the forum module depend on ban.
|
||||
$info['dependencies'][] = 'ban';
|
||||
}
|
||||
elseif ($file->name == 'ban') {
|
||||
elseif ($file->getName() == 'ban') {
|
||||
// Make ban depend on xmlrpc module.
|
||||
$info['dependencies'][] = 'xmlrpc';
|
||||
}
|
||||
}
|
||||
elseif (\Drupal::state()->get('module_test.dependency') == 'version dependency') {
|
||||
if ($file->name == 'forum') {
|
||||
if ($file->getName() == 'forum') {
|
||||
// Make the forum module depend on ban.
|
||||
$info['dependencies'][] = 'ban';
|
||||
}
|
||||
elseif ($file->name == 'ban') {
|
||||
elseif ($file->getName() == 'ban') {
|
||||
// Make ban depend on a specific version of xmlrpc module.
|
||||
$info['dependencies'][] = 'xmlrpc (1.x)';
|
||||
}
|
||||
elseif ($file->name == 'xmlrpc') {
|
||||
elseif ($file->getName() == 'xmlrpc') {
|
||||
// Set xmlrpc module to a version compatible with the above.
|
||||
$info['version'] = '8.x-1.0';
|
||||
}
|
||||
}
|
||||
if ($file->name == 'seven' && $type == 'theme') {
|
||||
if ($file->getName() == 'seven' && $type == 'theme') {
|
||||
$info['regions']['test_region'] = t('Test region');
|
||||
}
|
||||
if ($file->name == 'module_test' && \Drupal::state()->get('module_test.hook_system_info_alter')) {
|
||||
if ($file->getName() == 'module_test' && \Drupal::state()->get('module_test.hook_system_info_alter')) {
|
||||
$info['required'] = TRUE;
|
||||
$info['explanation'] = 'Testing hook_system_info_alter()';
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Drupal\Core\Extension\Extension;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
|
||||
/**
|
||||
|
@ -38,27 +39,27 @@ function system_test_modules_uninstalled($modules) {
|
|||
/**
|
||||
* Implements hook_system_info_alter().
|
||||
*/
|
||||
function system_test_system_info_alter(&$info, $file, $type) {
|
||||
function system_test_system_info_alter(&$info, Extension $file, $type) {
|
||||
// We need a static otherwise the last test will fail to alter common_test.
|
||||
static $test;
|
||||
if (($dependencies = \Drupal::state()->get('system_test.dependencies')) || $test) {
|
||||
if ($file->name == 'module_test') {
|
||||
if ($file->getName() == 'module_test') {
|
||||
$info['hidden'] = FALSE;
|
||||
$info['dependencies'][] = array_shift($dependencies);
|
||||
\Drupal::state()->set('system_test.dependencies', $dependencies);
|
||||
$test = TRUE;
|
||||
}
|
||||
if ($file->name == 'common_test') {
|
||||
if ($file->getName() == 'common_test') {
|
||||
$info['hidden'] = FALSE;
|
||||
$info['version'] = '8.x-2.4-beta3';
|
||||
}
|
||||
}
|
||||
|
||||
// Make the system_dependencies_test visible by default.
|
||||
if ($file->name == 'system_dependencies_test') {
|
||||
if ($file->getName() == 'system_dependencies_test') {
|
||||
$info['hidden'] = FALSE;
|
||||
}
|
||||
if (in_array($file->name, array(
|
||||
if (in_array($file->getName(), array(
|
||||
'system_incompatible_module_version_dependencies_test',
|
||||
'system_incompatible_core_version_dependencies_test',
|
||||
'system_incompatible_module_version_test',
|
||||
|
@ -66,7 +67,7 @@ function system_test_system_info_alter(&$info, $file, $type) {
|
|||
))) {
|
||||
$info['hidden'] = FALSE;
|
||||
}
|
||||
if ($file->name == 'requirements1_test' || $file->name == 'requirements2_test') {
|
||||
if ($file->getName() == 'requirements1_test' || $file->getName() == 'requirements2_test') {
|
||||
$info['hidden'] = FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
<?php
|
||||
|
||||
use Drupal\Core\Extension\Extension;
|
||||
|
||||
/**
|
||||
* Implements hook_system_info_alter().
|
||||
*/
|
||||
function theme_page_test_system_info_alter(&$info, $file, $type) {
|
||||
function theme_page_test_system_info_alter(&$info, Extension $file, $type) {
|
||||
// Make sure that all themes are visible on the Appearance form.
|
||||
if ($type == 'theme') {
|
||||
unset($info['hidden']);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Drupal\Core\Extension\Extension;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
|
@ -19,9 +20,9 @@ use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
|||
* module or theme short name ($file->name) and the subarrays contain settings
|
||||
* just for that module or theme.
|
||||
*/
|
||||
function update_test_system_info_alter(&$info, $file) {
|
||||
function update_test_system_info_alter(&$info, Extension $file) {
|
||||
$setting = \Drupal::config('update_test.settings')->get('system_info');
|
||||
foreach (array('#all', $file->name) as $id) {
|
||||
foreach (array('#all', $file->getName()) as $id) {
|
||||
if (!empty($setting[$id])) {
|
||||
foreach ($setting[$id] as $key => $value) {
|
||||
$info[$key] = $value;
|
||||
|
|
|
@ -1361,7 +1361,7 @@ class ViewExecutable extends DependencySerialization {
|
|||
// Let the themes play too, because pre render is a very themey thing.
|
||||
if (isset($GLOBALS['base_theme_info']) && isset($GLOBALS['theme'])) {
|
||||
foreach ($GLOBALS['base_theme_info'] as $base) {
|
||||
$module_handler->invoke($base->name, 'views_pre_render', array($this));
|
||||
$module_handler->invoke($base->getName(), 'views_pre_render', array($this));
|
||||
}
|
||||
|
||||
$module_handler->invoke($GLOBALS['theme'], 'views_pre_render', array($this));
|
||||
|
@ -1385,7 +1385,7 @@ class ViewExecutable extends DependencySerialization {
|
|||
// Let the themes play too, because post render is a very themey thing.
|
||||
if (isset($GLOBALS['base_theme_info']) && isset($GLOBALS['theme'])) {
|
||||
foreach ($GLOBALS['base_theme_info'] as $base) {
|
||||
$module_handler->invoke($base->name, 'views_post_render', array($this));
|
||||
$module_handler->invoke($base->getName(), 'views_post_render', array($this));
|
||||
}
|
||||
|
||||
$module_handler->invoke($GLOBALS['theme'], 'views_post_render', array($this));
|
||||
|
|
|
@ -242,13 +242,13 @@ class ThemeHandlerTest extends UnitTestCase {
|
|||
->method('scan')
|
||||
->with('theme')
|
||||
->will($this->returnValue(array(
|
||||
'seven' => new Extension('theme', DRUPAL_ROOT . '/core/themes/seven/seven.info.yml', 'seven.info.yml'),
|
||||
'seven' => new Extension('theme', DRUPAL_ROOT . '/core/themes/seven/seven.info.yml', 'seven.theme'),
|
||||
)));
|
||||
$this->extensionDiscovery->expects($this->at(1))
|
||||
->method('scan')
|
||||
->with('theme_engine')
|
||||
->will($this->returnValue(array(
|
||||
'twig' => new Extension('theme_engine', DRUPAL_ROOT . '/core/themes/engines/twig.info.yml', 'twig.info.yml'),
|
||||
'twig' => new Extension('theme_engine', DRUPAL_ROOT . '/core/themes/engines/twig/twig.info.yml', 'twig.engine'),
|
||||
)));
|
||||
$this->infoParser->expects($this->once())
|
||||
->method('parse')
|
||||
|
@ -267,10 +267,10 @@ class ThemeHandlerTest extends UnitTestCase {
|
|||
|
||||
// Ensure some basic properties.
|
||||
$this->assertInstanceOf('Drupal\Core\Extension\Extension', $info);
|
||||
$this->assertEquals('seven', $info->name);
|
||||
$this->assertEquals(DRUPAL_ROOT . '/core/themes/seven/seven.info.yml', $info->uri);
|
||||
$this->assertEquals(DRUPAL_ROOT . '/core/themes/seven/seven.info.yml', $info->filename);
|
||||
$this->assertEquals(DRUPAL_ROOT . '/core/themes/engines/twig.info.yml', $info->owner);
|
||||
$this->assertEquals('seven', $info->getName());
|
||||
$this->assertEquals(DRUPAL_ROOT . '/core/themes/seven/seven.info.yml', $info->getPathname());
|
||||
$this->assertEquals(DRUPAL_ROOT . '/core/themes/seven/seven.theme', $info->uri);
|
||||
$this->assertEquals(DRUPAL_ROOT . '/core/themes/engines/twig/twig.engine', $info->owner);
|
||||
$this->assertEquals('twig', $info->prefix);
|
||||
|
||||
$this->assertEquals('twig', $info->info['engine']);
|
||||
|
@ -303,7 +303,7 @@ class ThemeHandlerTest extends UnitTestCase {
|
|||
->method('scan')
|
||||
->with('theme_engine')
|
||||
->will($this->returnValue(array(
|
||||
'twig' => new Extension('theme_engine', DRUPAL_ROOT . '/core/themes/engines/twig.info.yml', 'twig.info.yml'),
|
||||
'twig' => new Extension('theme_engine', DRUPAL_ROOT . '/core/themes/engines/twig/twig.info.yml', 'twig.engine'),
|
||||
)));
|
||||
$this->infoParser->expects($this->at(0))
|
||||
->method('parse')
|
||||
|
@ -328,17 +328,17 @@ class ThemeHandlerTest extends UnitTestCase {
|
|||
|
||||
// Ensure some basic properties.
|
||||
$this->assertInstanceOf('Drupal\Core\Extension\Extension', $info_basetheme);
|
||||
$this->assertEquals('test_basetheme', $info_basetheme->name);
|
||||
$this->assertEquals('test_basetheme', $info_basetheme->getName());
|
||||
$this->assertInstanceOf('Drupal\Core\Extension\Extension', $info_subtheme);
|
||||
$this->assertEquals('test_subtheme', $info_subtheme->name);
|
||||
$this->assertEquals('test_subtheme', $info_subtheme->getName());
|
||||
|
||||
// Test the parent/child-theme properties.
|
||||
$info_subtheme->info['base theme'] = 'test_basetheme';
|
||||
$info_basetheme->sub_themes = array('test_subtheme');
|
||||
|
||||
$this->assertEquals(DRUPAL_ROOT . '/core/themes/engines/twig.info.yml', $info_basetheme->owner);
|
||||
$this->assertEquals(DRUPAL_ROOT . '/core/themes/engines/twig/twig.engine', $info_basetheme->owner);
|
||||
$this->assertEquals('twig', $info_basetheme->prefix);
|
||||
$this->assertEquals(DRUPAL_ROOT . '/core/themes/engines/twig.info.yml', $info_subtheme->owner);
|
||||
$this->assertEquals(DRUPAL_ROOT . '/core/themes/engines/twig/twig.engine', $info_subtheme->owner);
|
||||
$this->assertEquals('twig', $info_subtheme->prefix);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Drupal\Tests\Core\Theme;
|
||||
|
||||
use Drupal\Core\Extension\Extension;
|
||||
use Drupal\Core\Theme\Registry;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
|
@ -75,10 +76,7 @@ class RegistryTest extends UnitTestCase {
|
|||
*/
|
||||
public function testGetRegistryForModule() {
|
||||
$this->setupTheme('test_theme');
|
||||
$this->registry->setTheme((object) array(
|
||||
'name' => 'test_theme',
|
||||
'filename' => 'core/modules/system/tests/themes/test_theme/test_theme.theme',
|
||||
));
|
||||
$this->registry->setTheme(new Extension('theme', 'core/modules/system/tests/themes/test_theme/test_theme.info.yml', 'test_theme.theme'));
|
||||
$this->registry->setBaseThemes(array());
|
||||
|
||||
// Include the module so that hook_theme can be called.
|
||||
|
@ -120,7 +118,7 @@ class RegistryTest extends UnitTestCase {
|
|||
|
||||
class TestRegistry extends Registry {
|
||||
|
||||
public function setTheme(\stdClass $theme) {
|
||||
public function setTheme(Extension $theme) {
|
||||
$this->theme = $theme;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,13 +5,14 @@
|
|||
* Handles integration of PHP templates with the Drupal theme system.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Extension\Extension;
|
||||
|
||||
/**
|
||||
* Implements hook_init().
|
||||
*/
|
||||
function phptemplate_init($template) {
|
||||
$file = dirname($template->filename) . '/' . $template->name . '.theme';
|
||||
if (file_exists($file)) {
|
||||
include_once DRUPAL_ROOT . '/' . $file;
|
||||
function phptemplate_init(Extension $theme) {
|
||||
if (file_exists($theme->uri)) {
|
||||
include_once DRUPAL_ROOT . '/' . $theme->uri;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* @file
|
||||
* Handles integration of Twig templates with the Drupal theme system.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Extension\Extension;
|
||||
use Drupal\Core\Template\TwigReference;
|
||||
|
||||
/**
|
||||
|
@ -25,10 +27,9 @@ function twig_extension() {
|
|||
/**
|
||||
* Implements hook_init().
|
||||
*/
|
||||
function twig_init($template) {
|
||||
$file = dirname($template->filename) . '/' . $template->name . '.theme';
|
||||
if (file_exists($file)) {
|
||||
include_once DRUPAL_ROOT . '/' . $file;
|
||||
function twig_init(Extension $theme) {
|
||||
if (file_exists($theme->uri)) {
|
||||
include_once DRUPAL_ROOT . '/' . $theme->uri;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue