Commit 28d0b8ef authored by alexpott's avatar alexpott

Issue #2210197 by sun, longwave, Sutharsan: Remove public access to...

Issue #2210197 by sun, longwave, Sutharsan: Remove public access to Extension::$type, ::$name, ::$filename.
parent f658a90d
...@@ -684,7 +684,7 @@ function install_tasks($install_state) { ...@@ -684,7 +684,7 @@ function install_tasks($install_state) {
// Load the profile install file, because it is not always loaded when // Load the profile install file, because it is not always loaded when
// hook_install_tasks() is invoked (e.g. batch processing). // hook_install_tasks() is invoked (e.g. batch processing).
$profile = $install_state['parameters']['profile']; $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)) { if (file_exists($profile_install_file)) {
include_once DRUPAL_ROOT . '/' . $profile_install_file; include_once DRUPAL_ROOT . '/' . $profile_install_file;
} }
...@@ -1256,19 +1256,19 @@ function _install_select_profile($profiles) { ...@@ -1256,19 +1256,19 @@ function _install_select_profile($profiles) {
$request_params = \Drupal::request()->request; $request_params = \Drupal::request()->request;
if (count($profiles) == 1) { if (count($profiles) == 1) {
$profile = array_pop($profiles); $profile = array_pop($profiles);
return $profile->name; return $profile->getName();
} }
elseif ($request_params->has('profile') && ($profile = $request_params->get('profile')) && isset($profiles[$profile])) { 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 // Check for a profile marked as "exclusive" and ensure that only one
// profile is marked as such. // profile is marked as such.
$exclusive_profile = NULL; $exclusive_profile = NULL;
foreach ($profiles as $profile) { 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($profile_info['exclusive'])) {
if (empty($exclusive_profile)) { if (empty($exclusive_profile)) {
$exclusive_profile = $profile->name; $exclusive_profile = $profile->getName();
} }
else { else {
// We found a second "exclusive" profile. There's no way to choose // We found a second "exclusive" profile. There's no way to choose
...@@ -1294,7 +1294,7 @@ function install_select_profile_form($form, &$form_state, $install_state) { ...@@ -1294,7 +1294,7 @@ function install_select_profile_form($form, &$form_state, $install_state) {
$profiles = array(); $profiles = array();
$names = array(); $names = array();
foreach ($install_state['profiles'] as $profile) { 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. // Skip this extension if its type is not profile.
if (!isset($details['type']) || $details['type'] != 'profile') { if (!isset($details['type']) || $details['type'] != 'profile') {
continue; continue;
...@@ -1304,12 +1304,12 @@ function install_select_profile_form($form, &$form_state, $install_state) { ...@@ -1304,12 +1304,12 @@ function install_select_profile_form($form, &$form_state, $install_state) {
if ($details['hidden'] === TRUE) { if ($details['hidden'] === TRUE) {
continue; continue;
} }
$profiles[$profile->name] = $details; $profiles[$profile->getName()] = $details;
// Determine the name of the profile; default to file name if defined name // Determine the name of the profile; default to file name if defined name
// is unspecified. // is unspecified.
$name = isset($details['name']) ? $details['name'] : $profile->name; $name = isset($details['name']) ? $details['name'] : $profile->getName();
$names[$profile->name] = $name; $names[$profile->getName()] = $name;
} }
// Display radio buttons alphabetically by human-readable name, but always // Display radio buttons alphabetically by human-readable name, but always
......
...@@ -573,9 +573,7 @@ function drupal_verify_profile($install_state) { ...@@ -573,9 +573,7 @@ function drupal_verify_profile($install_state) {
include_once __DIR__ . '/common.inc'; include_once __DIR__ . '/common.inc';
$profile = $install_state['parameters']['profile']; $profile = $install_state['parameters']['profile'];
$profile_file = $install_state['profiles'][$profile]->uri; if (!isset($profile) || !isset($install_state['profiles'][$profile])) {
if (!isset($profile) || !file_exists($profile_file)) {
throw new Exception(install_no_profile_error()); throw new Exception(install_no_profile_error());
} }
$info = $install_state['profile_info']; $info = $install_state['profile_info'];
...@@ -584,7 +582,7 @@ function drupal_verify_profile($install_state) { ...@@ -584,7 +582,7 @@ function drupal_verify_profile($install_state) {
$listing = new ExtensionDiscovery(); $listing = new ExtensionDiscovery();
$present_modules = array(); $present_modules = array();
foreach ($listing->scan('module') as $present_module) { 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 // The installation profile is also a module, which needs to be installed
......
...@@ -63,7 +63,7 @@ function system_list($type) { ...@@ -63,7 +63,7 @@ function system_list($type) {
$lists['filepaths'][] = array( $lists['filepaths'][] = array(
'type' => 'theme', 'type' => 'theme',
'name' => $name, 'name' => $name,
'filepath' => $theme->filename, 'filepath' => $theme->getPathname(),
); );
} }
} }
......
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
*/ */
function drupal_theme_access($theme) { function drupal_theme_access($theme) {
if ($theme instanceof Extension) { if ($theme instanceof Extension) {
$theme = $theme->name; $theme = $theme->getName();
} }
return \Drupal::service('access_check.theme')->checkAccess($theme); return \Drupal::service('access_check.theme')->checkAccess($theme);
} }
...@@ -135,7 +135,7 @@ function _drupal_theme_initialize($theme, $base_theme = array()) { ...@@ -135,7 +135,7 @@ function _drupal_theme_initialize($theme, $base_theme = array()) {
$theme_info = $theme; $theme_info = $theme;
$base_theme_info = $base_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. // 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 // 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()) { ...@@ -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'])) { if (!empty($base->info['stylesheets-remove'])) {
foreach ($base->info['stylesheets-remove'] as $basename) { foreach ($base->info['stylesheets-remove'] as $basename) {
$theme->stylesheets_remove[$basename] = $base_theme_path . '/' . $basename; $theme->stylesheets_remove[$basename] = $base_theme_path . '/' . $basename;
...@@ -793,7 +793,7 @@ function drupal_find_theme_templates($cache, $extension, $path) { ...@@ -793,7 +793,7 @@ function drupal_find_theme_templates($cache, $extension, $path) {
$theme_paths = array(); $theme_paths = array();
foreach (list_themes() as $theme_info) { foreach (list_themes() as $theme_info) {
if (!empty($theme_info->base_theme)) { 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) { foreach ($theme_paths as $basetheme => $subthemes) {
...@@ -955,7 +955,7 @@ function theme_get_setting($setting_name, $theme = NULL) { ...@@ -955,7 +955,7 @@ function theme_get_setting($setting_name, $theme = NULL) {
if ($cache[$theme]->get('features.logo')) { if ($cache[$theme]->get('features.logo')) {
$logo_path = $cache[$theme]->get('logo.path'); $logo_path = $cache[$theme]->get('logo.path');
if ($cache[$theme]->get('logo.use_default')) { 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) { elseif ($logo_path) {
$cache[$theme]->set('logo.url', file_create_url($logo_path)); $cache[$theme]->set('logo.url', file_create_url($logo_path));
...@@ -966,7 +966,7 @@ function theme_get_setting($setting_name, $theme = NULL) { ...@@ -966,7 +966,7 @@ function theme_get_setting($setting_name, $theme = NULL) {
if ($cache[$theme]->get('features.favicon')) { if ($cache[$theme]->get('features.favicon')) {
$favicon_path = $cache[$theme]->get('favicon.path'); $favicon_path = $cache[$theme]->get('favicon.path');
if ($cache[$theme]->get('favicon.use_default')) { 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)); $cache[$theme]->set('favicon.url', file_create_url($favicon));
} }
else { else {
......
...@@ -290,10 +290,8 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ ...@@ -290,10 +290,8 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ
* @param $module * @param $module
* The name of the module. * The name of the module.
* *
* @return \stdClass|bool * @return \Drupal\Core\Extension\Extension|bool
* Returns a stdClass object if the module data is found containing at * Returns an Extension object if the module is found, FALSE otherwise.
* least an uri property with the module path, for example
* core/modules/user/user.module.
*/ */
protected function moduleData($module) { protected function moduleData($module) {
if (!$this->moduleData) { if (!$this->moduleData) {
......
...@@ -15,7 +15,7 @@ class Extension implements \Serializable { ...@@ -15,7 +15,7 @@ class Extension implements \Serializable {
/** /**
* The type of the extension (e.g., 'module'). * The type of the extension (e.g., 'module').
* *
* @todo Replace all uses of $type with getType() method. * @todo Change to protected once external test dependencies are resolved.
* *
* @var string * @var string
*/ */
...@@ -31,7 +31,7 @@ class Extension implements \Serializable { ...@@ -31,7 +31,7 @@ class Extension implements \Serializable {
/** /**
* The internal name of the extension (e.g., 'node'). * The internal name of the extension (e.g., 'node').
* *
* @todo Replace all uses of $name with getName() method. * @todo Remove this property once external test dependencies are resolved.
* *
* @var string * @var string
*/ */
...@@ -48,23 +48,22 @@ class Extension implements \Serializable { ...@@ -48,23 +48,22 @@ class Extension implements \Serializable {
public $uri; public $uri;
/** /**
* The filename of the main extension file (e.g., 'node.module'). * Same as $uri.
* *
* Note that this is not necessarily a filename but a pathname and also not * @todo Remove this property once external test dependencies are resolved.
* 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() * @var string
* @see \Drupal\Core\Extension\ThemeHandler::rebuildThemeData() */
public $filename;
/**
* The filename of the main extension file (e.g., 'node.module').
* *
* @todo Remove this property and do not require .module/.profile files. * @todo Rename to $filename once external test dependencies are resolved.
* @see https://drupal.org/node/340723
* *
* @var string * @var string
*/ */
public $filename; protected $_filename;
/** /**
* An SplFileInfo instance for the extension's info file. * An SplFileInfo instance for the extension's info file.
...@@ -89,10 +88,11 @@ class Extension implements \Serializable { ...@@ -89,10 +88,11 @@ class Extension implements \Serializable {
public function __construct($type, $pathname, $filename) { public function __construct($type, $pathname, $filename) {
$this->type = $type; $this->type = $type;
$this->pathname = $pathname; $this->pathname = $pathname;
$this->_filename = $filename;
// Set legacy public properties. // Set legacy public properties.
$this->name = basename($pathname, '.info.yml'); $this->name = $this->getName();
$this->filename = $filename; $this->uri = $this->getPath() . '/' . $filename;
$this->uri = dirname($pathname) . '/' . $filename; $this->filename = $this->uri;
} }
/** /**
...@@ -177,14 +177,9 @@ public function serialize() { ...@@ -177,14 +177,9 @@ public function serialize() {
$data = array( $data = array(
'type' => $this->type, 'type' => $this->type,
'pathname' => $this->pathname, 'pathname' => $this->pathname,
'_filename' => $this->_filename,
); );
// Include legacy public properties.
// @todo Remove this property and do not require .module/.profile files.
// @see https://drupal.org/node/340723
// @see Extension::$filename
$data['filename'] = basename($this->uri);
// @todo ThemeHandler::listInfo(), ThemeHandler::rebuildThemeData(), and // @todo ThemeHandler::listInfo(), ThemeHandler::rebuildThemeData(), and
// system_list() are adding custom properties to the Extension object. // system_list() are adding custom properties to the Extension object.
$info = new \ReflectionObject($this); $info = new \ReflectionObject($this);
...@@ -202,14 +197,14 @@ public function unserialize($data) { ...@@ -202,14 +197,14 @@ public function unserialize($data) {
$data = unserialize($data); $data = unserialize($data);
$this->type = $data['type']; $this->type = $data['type'];
$this->pathname = $data['pathname']; $this->pathname = $data['pathname'];
$this->_filename = $data['_filename'];
// Restore legacy public properties. // Restore legacy public properties.
// @todo Remove these properties and do not require .module/.profile files. // @todo Remove these properties and do not require .module/.profile files.
// @see https://drupal.org/node/340723 // @see https://drupal.org/node/340723
// @see Extension::$filename $this->name = $this->getName();
$this->name = basename($data['pathname'], '.info.yml'); $this->uri = $this->getPath() . '/' . $this->_filename;
$this->uri = dirname($data['pathname']) . '/' . $data['filename']; $this->filename = $this->uri;
$this->filename = $data['filename'];
// @todo ThemeHandler::listInfo(), ThemeHandler::rebuildThemeData(), and // @todo ThemeHandler::listInfo(), ThemeHandler::rebuildThemeData(), and
// system_list() are adding custom properties to the Extension object. // system_list() are adding custom properties to the Extension object.
......
...@@ -278,14 +278,14 @@ protected function process(array $all_files) { ...@@ -278,14 +278,14 @@ protected function process(array $all_files) {
// e.g. new modules were introduced in core while older contrib modules with // e.g. new modules were introduced in core while older contrib modules with
// the same name still exist in a later search path. // the same name still exist in a later search path.
foreach ($all_files as $file) { 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. // Skip the extension if it is incompatible with Drupal core.
$info = $this->getInfoParser()->parse($file->getPathname()); $info = $this->getInfoParser()->parse($file->getPathname());
if (!isset($info['core']) || $info['core'] != \Drupal::CORE_COMPATIBILITY) { if (!isset($info['core']) || $info['core'] != \Drupal::CORE_COMPATIBILITY) {
continue; continue;
} }
} }
$files[$file->name] = $file; $files[$file->getName()] = $file;
} }
return $files; return $files;
} }
...@@ -366,16 +366,12 @@ protected function scanDirectory($dir, $include_tests) { ...@@ -366,16 +366,12 @@ protected function scanDirectory($dir, $include_tests) {
$name = $fileinfo->getBasename('.info.yml'); $name = $fileinfo->getBasename('.info.yml');
$pathname = $dir_prefix . $fileinfo->getSubPathname(); $pathname = $dir_prefix . $fileinfo->getSubPathname();
// Supply main extension filename being used throughout Drupal. // Determine whether the extension has a main extension file.
// For themes, the filename is the info file itself.
if ($type == 'theme') {
$filename = $fileinfo->getFilename();
}
// For theme engines, the file extension is .engine. // For theme engines, the file extension is .engine.
elseif ($type == 'theme_engine') { if ($type == 'theme_engine') {
$filename = $name . '.engine'; $filename = $name . '.engine';
} }
// Otherwise, it is .module/.profile; i.e., the extension type. // For profiles/modules/themes, it is the extension type.
else { else {
$filename = $name . '.' . $type; $filename = $name . '.' . $type;
} }
......
...@@ -145,11 +145,11 @@ public function setModuleList(array $module_list = array()) { ...@@ -145,11 +145,11 @@ public function setModuleList(array $module_list = array()) {
*/ */
public function buildModuleDependencies(array $modules) { public function buildModuleDependencies(array $modules) {
foreach ($modules as $module) { foreach ($modules as $module) {
$graph[$module->name]['edges'] = array(); $graph[$module->getName()]['edges'] = array();
if (isset($module->info['dependencies']) && is_array($module->info['dependencies'])) { if (isset($module->info['dependencies']) && is_array($module->info['dependencies'])) {
foreach ($module->info['dependencies'] as $dependency) { foreach ($module->info['dependencies'] as $dependency) {
$dependency_data = static::parseDependency($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 @@ public function alter($type, &$data, &$context1 = NULL, &$context2 = NULL) { ...@@ -382,7 +382,7 @@ public function alter($type, &$data, &$context1 = NULL, &$context2 = NULL) {
if (isset($theme)) { if (isset($theme)) {
$theme_keys = array(); $theme_keys = array();
foreach ($base_theme_info as $base) { foreach ($base_theme_info as $base) {
$theme_keys[] = $base->name; $theme_keys[] = $base->getName();
} }
$theme_keys[] = $theme; $theme_keys[] = $theme;
foreach ($theme_keys as $theme_key) { foreach ($theme_keys as $theme_key) {
......
...@@ -220,7 +220,7 @@ public function listInfo() { ...@@ -220,7 +220,7 @@ public function listInfo() {
if (!isset($theme->status)) { if (!isset($theme->status)) {
$theme->status = 0; $theme->status = 0;
} }
$this->list[$theme->name] = $theme; $this->list[$theme->getName()] = $theme;
} }
} }
return $this->list; return $this->list;
...@@ -271,7 +271,6 @@ public function rebuildThemeData() { ...@@ -271,7 +271,6 @@ public function rebuildThemeData() {
$sub_themes = array(); $sub_themes = array();
// Read info files for each theme. // Read info files for each theme.
foreach ($themes as $key => $theme) { foreach ($themes as $key => $theme) {
$theme->filename = $theme->uri;
$theme->info = $this->infoParser->parse($theme->getPathname()) + $defaults; $theme->info = $this->infoParser->parse($theme->getPathname()) + $defaults;
// Add the info file modification time, so it becomes available for // Add the info file modification time, so it becomes available for
...@@ -292,7 +291,7 @@ public function rebuildThemeData() { ...@@ -292,7 +291,7 @@ public function rebuildThemeData() {
$engine = $theme->info['engine']; $engine = $theme->info['engine'];
if (isset($engines[$engine])) { if (isset($engines[$engine])) {
$theme->owner = $engines[$engine]->uri; $theme->owner = $engines[$engine]->uri;
$theme->prefix = $engines[$engine]->name; $theme->prefix = $engines[$engine]->getName();
} }
// Prefix stylesheets, scripts, and screenshot with theme path. // Prefix stylesheets, scripts, and screenshot with theme path.
......
...@@ -39,13 +39,16 @@ public function __construct(\Twig_LoaderInterface $loader = NULL, $options = arr ...@@ -39,13 +39,16 @@ public function __construct(\Twig_LoaderInterface $loader = NULL, $options = arr
$this->cache_object = \Drupal::cache(); $this->cache_object = \Drupal::cache();
// Set twig path namespace for themes and modules. // Set twig path namespace for themes and modules.
$namespaces = $module_handler->getModuleList(); $namespaces = array();
foreach ($theme_handler->listInfo() as $theme => $info) { foreach ($module_handler->getModuleList() as $name => $filename) {
$namespaces[$theme] = $info->filename; $namespaces[$name] = dirname($filename);
}
foreach ($theme_handler->listInfo() as $name => $extension) {
$namespaces[$name] = $extension->getPath();
} }
foreach ($namespaces as $name => $filename) { foreach ($namespaces as $name => $path) {
$templatesDirectory = dirname($filename) . '/templates'; $templatesDirectory = $path . '/templates';
if (file_exists($templatesDirectory)) { if (file_exists($templatesDirectory)) {
$loader->addPath($templatesDirectory, $name); $loader->addPath($templatesDirectory, $name);
} }
......
...@@ -154,7 +154,7 @@ protected function init($theme_name = NULL) { ...@@ -154,7 +154,7 @@ protected function init($theme_name = NULL) {
} }
// #2: The testing framework only cares for the global $theme variable at // #2: The testing framework only cares for the global $theme variable at
// this point. Cope with that. // this point. Cope with that.
if ($GLOBALS['theme'] != $GLOBALS['theme_info']->name) { if ($GLOBALS['theme'] != $GLOBALS['theme_info']->getName()) {
unset($this->runtimeRegistry); unset($this->runtimeRegistry);
unset($this->registry); unset($this->registry);
$this->initializeTheme(); $this->initializeTheme();
...@@ -207,7 +207,7 @@ public function get() { ...@@ -207,7 +207,7 @@ public function get() {
if (isset($this->registry)) { if (isset($this->registry)) {
return $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; $this->registry = $cache->data;
} }
else { else {
...@@ -230,7 +230,7 @@ public function get() { ...@@ -230,7 +230,7 @@ public function get() {
*/ */
public function getRuntime() { public function getRuntime() {
if (!isset($this->runtimeRegistry)) { 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; return $this->runtimeRegistry;
} }
...@@ -239,7 +239,7 @@ public function getRuntime() { ...@@ -239,7 +239,7 @@ public function getRuntime() {
* Persists the theme registry in the cache backend. * Persists the theme registry in the cache backend.
*/ */
protected function setCache() { 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 @@ protected function build() { ...@@ -319,20 +319,20 @@ protected function build() {
// Process each base theme. // Process each base theme.
foreach ($this->baseThemes as $base) { foreach ($this->baseThemes as $base) {
// If the base theme uses a theme engine, process its hooks. // If the base theme uses a theme engine, process its hooks.
$base_path = dirname($base->filename); $base_path = $base->getPath();
if ($this->engine) { 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. // And then the same thing, but for the theme.
if ($this->engine) { 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. // 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. // Let modules alter the registry.
$this->moduleHandler->alter('theme_registry', $cache); $this->moduleHandler->alter('theme_registry', $cache);
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
namespace Drupal\Core\Utility; namespace Drupal\Core\Utility;
use Drupal\Core\Extension\Extension;
/** /**
* Performs operations on drupal.org project data. * Performs operations on drupal.org project data.
*/ */
...@@ -94,8 +96,7 @@ function processInfoList(array &$projects, array $list, $project_type, $status, ...@@ -94,8 +96,7 @@ function processInfoList(array &$projects, array $list, $project_type, $status,
// which is left alone by tar and correctly set to the time the .info.yml // which is left alone by tar and correctly set to the time the .info.yml
// file was unpacked. // file was unpacked.
if (!isset($file->info['_info_file_ctime'])) { if (!isset($file->info['_info_file_ctime'])) {
$info_filename = dirname($file->uri) . '/' . $file->name . '.info.yml'; $file->info['_info_file_ctime'] = $file->getCTime();
$file->info['_info_file_ctime'] = filectime($info_filename);
} }
if (!isset($file->info['datestamp'])) { if (!isset($file->info['datestamp'])) {
...@@ -142,7 +143,7 @@ function processInfoList(array &$projects, array $list, $project_type, $status, ...@@ -142,7 +143,7 @@ function processInfoList(array &$projects, array $list, $project_type, $status,
// not bloat our RAM usage needlessly. // not bloat our RAM usage needlessly.
'info' => $this->filterProjectInfo($file->info, $additional_whitelist), 'info' => $this->filterProjectInfo($file->info, $additional_whitelist),
'datestamp' => $file->info['datestamp'], 'datestamp' => $file->info['datestamp'],
'includes' => array($file->name => $file->info['name']), 'includes' => array($file->getName() => $file->info['name']),
'project_type' => $project_display_type, 'project_type' => $project_display_type,
'project_status' => $status, 'project_status' => $status,
'sub_themes' => $sub_themes, 'sub_themes' => $sub_themes,
...@@ -155,7 +156,7 @@ function processInfoList(array &$projects, array $list, $project_type, $status, ...@@ -155,7 +156,7 @@ function processInfoList(array &$projects, array $list, $project_type, $status,
// $project_display_type). This prevents listing all the disabled // $project_display_type). This prevents listing all the disabled
// modules included with an enabled project if we happen to be checking // modules included with an enabled project if we happen to be checking
// for disabled modules, too. // 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]['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']); $projects[$project_name]['datestamp'] = max($projects[$project_name]['datestamp'], $file->info['datestamp']);
if (!empty($sub_themes)) { if (!empty($sub_themes)) {
...@@ -170,7 +171,7 @@ function processInfoList(array &$projects, array $list, $project_type, $status, ...@@ -170,7 +171,7 @@ function processInfoList(array &$projects, array $list, $project_type, $status,
// does not, it means we're processing a disabled module or theme that // 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 // belongs to a project that has some enabled code. In this case, we add
// the disabled thing into a separate array for separate display. // 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 @@ function processInfoList(array &$projects, array $list, $project_type, $status, ...@@ -184,12 +185,12 @@ function processInfoList(array &$projects, array $list, $project_type, $status,
* @return string * @return string
* The canonical project short name. * The canonical project short name.
*/ */
function getProjectName($file) { function getProjectName(Extension $file) {
$project_name = ''; $project_name = '';
if (isset($file->info['project'])) { if (isset($file->info['project'])) {
$project_name = $file->info['project']; $project_name = $file->info['project'];
}