diff --git a/core/MAINTAINERS.txt b/core/MAINTAINERS.txt index 28153ec..b5f0c8d 100644 --- a/core/MAINTAINERS.txt +++ b/core/MAINTAINERS.txt @@ -129,7 +129,6 @@ Markup Migrate - Ben Dougherty 'benjy' https://drupal.org/user/1852732 -- Claudiu Cristea "claudiu.cristea" https://drupal.org/user/56348 - Mike Ryan 'mikeryan' http://drupal.org/user/4420 Menu system diff --git a/core/UPGRADE.txt b/core/UPGRADE.txt index 420f6ad..f035b6c 100644 --- a/core/UPGRADE.txt +++ b/core/UPGRADE.txt @@ -5,7 +5,7 @@ This document describes how to: * Update your Drupal site from one minor 8.x version to another minor 8.x version; for example, from 8.8 to 8.9, or from 8.6 to 8.10. - * Migrate your Drupal site to version 8.x. + * Upgrade your Drupal site's major version from 7.x to 8.x. First steps and definitions: @@ -121,10 +121,118 @@ following the instructions in the INTRODUCTION section at the top of this file: Disable the "Put site into maintenance mode" checkbox and save the configuration. -MAJOR VERSION MIGRATION ------------------------ -Upgrading from a prior major version of Drupal to Drupal 8.x is not possible. -The process now requires a migration to a Drupal 8.x site, utilizing the Migrate -module in Drupal core. +MAJOR VERSION UPGRADE +--------------------- +To upgrade from a previous major version of Drupal to Drupal 8.x, after +following the instructions in the INTRODUCTION section at the top of this file: + +1. Check on the Drupal 8 status of your contributed and custom modules and + themes. See http://drupal.org/node/948216 for information on upgrading + contributed modules and themes. See http://drupal.org/node/895314 for a list + of modules that have been moved into core for Drupal 8, and instructions on + how to update them. See http://drupal.org/update/modules for information on + how to update your custom modules, and http://drupal.org/update/theme for + custom themes. + + You may decide at this point that you cannot upgrade your site because + needed modules or themes are not ready for Drupal 8 + +2. Update to the latest available version of Drupal 7.x (if your current version + is Drupal 6.x, you have to upgrade to 7.x first). If you need to update, + download Drupal 7.x and follow the instructions in its UPGRADE.txt. This + document only applies for upgrades from 7.x to 8.x. + +3. In addition to updating to the latest available version of Drupal 7.x core, + you must also upgrade all of your contributed modules for Drupal to their + latest Drupal 7.x versions. + +4. Log in as user ID 1 (the site maintenance user). + +5. Go to Administer > Site configuration > Site maintenance. Select + "Off-line" and save the configuration. + +6. Go to Administer > Site building > Themes. Enable "Bartik" and select it as + the default theme. + +7. Go to Administer > Site building > Modules. Disable all modules that are not + listed under "Core - required" or "Core - optional". It is possible that some + modules cannot be disabled because others depend on them. Repeat this step + until all non-core modules are disabled. + + If you know that you will not re-enable some modules for Drupal 8.x and you + no longer need their data, then you can uninstall them under the Uninstall + tab after disabling them. + +8. On the command line or in your FTP client, remove the file + + sites/default/default.settings.php + +9. Remove all old core files and directories, except for the 'sites' directory + and any custom files you added elsewhere. + + If you made modifications to files like .htaccess or robots.txt, you will + need to re-apply them from your backup, after the new files are in place. + +10. If you uninstalled any modules, remove them from the /modules and other + sites/*/modules directories. Leave other modules in place, even though they + are incompatible with Drupal 8.x. + +11. Download the latest Drupal 8.x release from http://drupal.org to a + directory outside of your web root. Extract the archive and copy the files + into your Drupal directory. + + On a typical Unix/Linux command line, use the following commands to download + and extract: + + wget http://drupal.org/files/projects/drupal-x.y.tar.gz + tar -zxvf drupal-x.y.tar.gz + + This creates a new directory drupal-x.y/ containing all Drupal files and + directories. Copy the files into your Drupal installation directory: + + cp -R drupal-x.y/* drupal-x.y/.htaccess /path/to/your/installation + + If you do not have command line access to your server, download the archive + from http://drupal.org using your web browser, extract it, and then use an + FTP client to upload the files to your web root. + +12. Re-apply any modifications to files such as .htaccess or robots.txt. + +13. Make your settings.php file writeable, so that the update process can + convert it to the format of Drupal 8.x. settings.php is usually located in + + sites/default/settings.php + +14. Run update.php by visiting http://www.example.com/core/update.php (replace + www.example.com with your domain name). This will update the core database + tables. + + If you are unable to access update.php do the following: + + - Open settings.php with a text editor. + + - Find the line that says: + $settings['update_free_access'] = FALSE; + + - Change it into: + $settings['update_free_access'] = TRUE; + + - Once the upgrade is done, $settings['update_free_access'] must be + reverted to FALSE. + +15. Backup your database after the core upgrade has run. + +16. Replace and update your non-core modules and themes, following the + procedures at http://drupal.org/node/948216 + +17. Go to Administration > Reports > Status report. Verify that everything is + working as expected. + +18. Ensure that $settings['update_free_access'] is FALSE in settings.php. + +19. Go to Administration > Configuration > Development > Maintenance mode. + Disable the "Put site into maintenance mode" checkbox and save the + configuration. -Note that migration support in Drupal 8 is currently only partially implemented. +To get started with Drupal 8 administration, visit +http://drupal.org/getting-started/7/admin diff --git a/core/assets/vendor/domready/ready.min.js b/core/assets/vendor/domready/ready.min.js index c4ebe97..0d681c7 100644 --- a/core/assets/vendor/domready/ready.min.js +++ b/core/assets/vendor/domready/ready.min.js @@ -1,4 +1,4 @@ /*! - * domready (c) Dustin Diaz 2014 - License MIT + * domready (c) Dustin Diaz 2012 - License MIT */ -!function(e,t){typeof module!="undefined"?module.exports=t():typeof define=="function"&&typeof define.amd=="object"?define(t):this[e]=t()}("domready",function(){var e=[],t,n=document,r="DOMContentLoaded",i=/^loaded|^i|^c/.test(n.readyState);return i||n.addEventListener(r,t=function(){n.removeEventListener(r,t),i=1;while(t=e.shift())t()}),function(t){i?t():e.push(t)}}) +!function(e,t){typeof module!="undefined"?module.exports=t():typeof define=="function"&&typeof define.amd=="object"?define(t):this[e]=t()}("domready",function(e){function p(e){h=1;while(e=t.shift())e()}var t=[],n,r=!1,i=document,s=i.documentElement,o=s.doScroll,u="DOMContentLoaded",a="addEventListener",f="onreadystatechange",l="readyState",c=o?/^loaded|^c/:/^loaded|c/,h=c.test(i[l]);return i[a]&&i[a](u,n=function(){i.removeEventListener(u,n,r),p()},r),o&&i.attachEvent(f,n=function(){/^c/.test(i[l])&&(i.detachEvent(f,n),p())}),e=o?function(n){self!=top?h?n():t.push(n):function(){try{s.doScroll("left")}catch(t){return setTimeout(function(){e(n)},50)}n()}()}:function(e){h?e():t.push(e)}}) diff --git a/core/authorize.php b/core/authorize.php index ba71c5d..d812f2e 100644 --- a/core/authorize.php +++ b/core/authorize.php @@ -71,6 +71,9 @@ function authorize_access_allowed() { \Drupal::moduleHandler()->load('system'); \Drupal::moduleHandler()->load('user'); +// Initialize the language system. +drupal_language_initialize(); + // Initialize the maintenance theme for this administrative script. drupal_maintenance_theme(); diff --git a/core/core.libraries.yml b/core/core.libraries.yml index d2c35b9..bc3cb37 100644 --- a/core/core.libraries.yml +++ b/core/core.libraries.yml @@ -25,7 +25,8 @@ ckeditor: domready: remote: https://github.com/ded/domready - version: 1.0.4 + # @todo Stable release required for Drupal 8.0. + version: master js: assets/vendor/domready/ready.min.js: { weight: -21 } @@ -280,7 +281,7 @@ html5shiv: remote: https://github.com/aFarkas/html5shiv version: 3.6.2 js: - assets/vendor/html5shiv/html5.js: { every_page: true, weight: -22, browsers: { IE: 'lte IE 8', '!IE': false } } + assets/vendor/html5shiv/html5.js: { weight: -22, browsers: { IE: 'lte IE 8', '!IE': false } } jquery: remote: https://github.com/jquery/jquery diff --git a/core/core.services.yml b/core/core.services.yml index ac24e17..c158be4 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -18,6 +18,7 @@ services: class: Drupal\Core\Cache\CacheBackendInterface tags: - { name: cache.bin } + - { name: persist } factory_method: get factory_service: cache_factory arguments: [config] @@ -73,9 +74,12 @@ services: config.storage: class: Drupal\Core\Config\CachedStorage arguments: ['@config.cachedstorage.storage', '@cache.config'] + tags: + - { name: persist } config.factory: class: Drupal\Core\Config\ConfigFactory tags: + - { name: persist } - { name: event_subscriber } arguments: ['@config.storage', '@event_dispatcher', '@config.typed'] config.installer: @@ -130,6 +134,8 @@ services: state: class: Drupal\Core\KeyValueStore\State arguments: ['@keyvalue'] + tags: + - { name: persist } queue: class: Drupal\Core\Queue\QueueFactory arguments: ['@settings'] @@ -177,9 +183,6 @@ services: default_plugin_manager: abstract: true arguments: ['@container.namespaces', '@cache.cache', '@language_manager', '@module_handler'] - module_handler: - class: Drupal\Core\Extension\CachedModuleHandler - arguments: ['%container.modules%', '@state', '@cache.bootstrap'] theme_handler: class: Drupal\Core\Extension\ThemeHandler arguments: ['@config.factory', '@module_handler', '@cache.cache', '@info_parser', '@config.installer', '@router.builder'] @@ -608,9 +611,13 @@ services: image.toolkit.manager: class: Drupal\Core\ImageToolkit\ImageToolkitManager arguments: ['@container.namespaces', '@cache.cache', '@language_manager', '@config.factory', '@module_handler'] + image.toolkit: + class: Drupal\Core\ImageToolkit\ImageToolkitInterface + factory_method: getDefaultToolkit + factory_service: image.toolkit.manager image.factory: class: Drupal\Core\Image\ImageFactory - arguments: ['@image.toolkit.manager'] + arguments: ['@image.toolkit'] breadcrumb: class: Drupal\Core\Breadcrumb\BreadcrumbManager arguments: ['@module_handler'] diff --git a/core/includes/ajax.inc b/core/includes/ajax.inc index 7a98472..59941a0 100644 --- a/core/includes/ajax.inc +++ b/core/includes/ajax.inc @@ -332,8 +332,8 @@ function ajax_pre_render_element($element) { // Attach JavaScript settings to the element. if (isset($element['#ajax']['event'])) { - $element['#attached']['library'][] = 'core/jquery.form'; - $element['#attached']['library'][] = 'core/drupal.ajax'; + $element['#attached']['library'][] = array('core', 'jquery.form'); + $element['#attached']['library'][] = array('core', 'drupal.ajax'); $settings = $element['#ajax']; diff --git a/core/includes/batch.inc b/core/includes/batch.inc index daa7b2f..d78248d 100644 --- a/core/includes/batch.inc +++ b/core/includes/batch.inc @@ -47,38 +47,42 @@ function _batch_page(Request $request) { // Register database update for the end of processing. drupal_register_shutdown_function('_batch_shutdown'); - $build = array(); - // Add batch-specific CSS. + $attached = array('#attached' => array('css' => array())); foreach ($batch['sets'] as $batch_set) { if (isset($batch_set['css'])) { foreach ($batch_set['css'] as $css) { - $build['#attached']['css'][$css] = array(); + $attached['#attached']['css'][$css] = array(); } } } + drupal_render($attached); $op = $request->get('op', ''); + $output = NULL; switch ($op) { case 'start': - case 'do_nojs': // Display the full progress page on startup and on each additional // non-JavaScript iteration. - $current_set = _batch_current_set(); - $build['#title'] = $current_set['title']; - $build['content'] = _batch_progress_page(); + $output = _batch_progress_page(); break; case 'do': // JavaScript-based progress page callback. - return _batch_do(); + $output = _batch_do(); + break; + + case 'do_nojs': + // Non-JavaScript-based progress page. + $output = _batch_progress_page(); + break; case 'finished': - // _batch_finished() returns a RedirectResponse. - return _batch_finished(); + $output = _batch_finished(); + break; } - return $build; + return $output; } /** @@ -103,6 +107,7 @@ function _batch_progress_page() { $batch = &batch_get(); $current_set = _batch_current_set(); + drupal_set_title($current_set['title'], PASS_THROUGH); $new_op = 'do_nojs'; @@ -123,7 +128,6 @@ function _batch_progress_page() { $fallback = $current_set['error_message'] . '
' . $batch['error_message']; $fallback = array( '#theme' => 'maintenance_page', - '#title' => $current_set['title'], '#content' => $fallback, '#show_messages' => FALSE, ); @@ -187,11 +191,11 @@ function _batch_progress_page() { ), ), 'library' => array( - 'core/drupal.batch', + array('core', 'drupal.batch'), ), ), ); - return $build; + return drupal_render($build); } /** diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 7962015..222ac0c 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -184,6 +184,13 @@ define('REQUEST_TIME', (int) $_SERVER['REQUEST_TIME']); /** + * Flag for drupal_set_title(); text has already been sanitized. + * + * @todo Move to the Title class. + */ +const PASS_THROUGH = -1; + +/** * Regular expression to match PHP function names. * * @see http://php.net/manual/language.functions.php @@ -341,6 +348,75 @@ function config_get_config_directory($type = CONFIG_ACTIVE_DIRECTORY) { } /** + * Sets appropriate server variables needed for command line scripts to work. + * + * This function can be called by command line scripts before bootstrapping + * Drupal, to ensure that the page loads with the desired server parameters. + * This is because many parts of Drupal assume that they are running in a web + * browser and therefore use information from the global PHP $_SERVER variable + * that does not get set when Drupal is run from the command line. + * + * In many cases, the default way in which this function populates the $_SERVER + * variable is sufficient, and it can therefore be called without passing in + * any input. However, command line scripts running on a multisite installation + * (or on any installation that has settings.php stored somewhere other than + * the sites/default folder) need to pass in the URL of the site to allow + * Drupal to detect the correct location of the settings.php file. Passing in + * the 'url' parameter is also required for functions like request_uri() to + * return the expected values. + * + * Most other parameters do not need to be passed in, but may be necessary in + * some cases; for example, if \Drupal::request()->getClientIP() + * needs to return anything but the standard localhost value ('127.0.0.1'), + * the command line script should pass in the desired value via the + * 'REMOTE_ADDR' key. + * + * @param $variables + * (optional) An associative array of variables within + * \Drupal::request()->server that should be replaced. If the special element + * 'url' is provided in this array, it will be used to populate some of the + * server defaults; it should be set to the URL of the current page request, + * excluding any GET request but including the script name + * (e.g., http://www.example.com/mysite/index.php). + * + * @see conf_path() + * @see request_uri() + * @see \Symfony\Component\HttpFoundation\Request::getClientIP() + */ +function drupal_override_server_variables($variables = array()) { + $request = \Drupal::request(); + $server_vars = $request->server->all(); + // Allow the provided URL to override any existing values in $_SERVER. + if (isset($variables['url'])) { + $url = parse_url($variables['url']); + if (isset($url['host'])) { + $server_vars['HTTP_HOST'] = $url['host']; + } + if (isset($url['path'])) { + $server_vars['SCRIPT_NAME'] = $url['path']; + } + unset($variables['url']); + } + // Define default values for $_SERVER keys. These will be used if $_SERVER + // does not already define them and no other values are passed in to this + // function. + $defaults = array( + 'HTTP_HOST' => 'localhost', + 'SCRIPT_NAME' => NULL, + 'REMOTE_ADDR' => '127.0.0.1', + 'REQUEST_METHOD' => 'GET', + 'SERVER_NAME' => NULL, + 'SERVER_SOFTWARE' => NULL, + 'HTTP_USER_AGENT' => NULL, + ); + // Replace elements of the $_SERVER array, as appropriate. + $request->server->replace($variables + $server_vars + $defaults); + + // @todo remove once conf_path() no longer uses $_SERVER. + $_SERVER = $request->server->all(); +} + +/** * Initializes the PHP environment. */ function drupal_environment_initialize() { @@ -1324,6 +1400,46 @@ function drupal_get_messages($type = NULL, $clear_queue = TRUE) { } /** + * Gets the title of the current page. + * + * The title is displayed on the page and in the title bar. + * + * @return + * The current page's title. + */ +function drupal_get_title() { + return drupal_set_title() ?: ''; +} + +/** + * Sets the title of the current page. + * + * The title is displayed on the page and in the title bar. + * + * @param $title + * Optional string value to assign to the page title; or if set to NULL + * (default), leaves the current title unchanged. + * @param $output + * Optional flag - normally should be left as Title::CHECK_PLAIN. Only set to + * PASS_THROUGH if you have already removed any possibly dangerous code + * from $title using a function like + * \Drupal\Component\Utility\String::checkPlain() or filter_xss(). With this + * flag the string will be passed through unchanged. + * + * @return + * The updated title of the current page. + */ +function drupal_set_title($title = NULL, $output = Title::CHECK_PLAIN) { + $stored_title = &drupal_static(__FUNCTION__); + + if (isset($title)) { + $stored_title = ($output == PASS_THROUGH) ? $title : String::checkPlain($title); + } + + return $stored_title; +} + +/** * Generates a default anonymous $user object. * * @return \Drupal\Core\Session\AccountInterface @@ -1893,6 +2009,15 @@ function drupal_installation_attempted() { } /** + * Initializes all the defined language types and sets the default langcode. + */ +function drupal_language_initialize() { + $language_manager = \Drupal::languageManager(); + $language_manager->init(); + \Drupal::translation()->setDefaultLangcode($language_manager->getCurrentLanguage()->id); +} + +/** * Returns the language object for a given language type. * * @see \Drupal\Core\Language\LanguageManager diff --git a/core/includes/common.inc b/core/includes/common.inc index d18c0c1..57095f7 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -2457,7 +2457,7 @@ function drupal_pre_render_scripts($elements) { * FALSE if there were any missing library dependencies; TRUE if all library * dependencies were met. * - * @see _drupal_add_library() + * @see drupal_add_library() * @see _drupal_add_js() * @see _drupal_add_css() * @see drupal_render() @@ -2473,7 +2473,7 @@ function drupal_process_attached($elements, $dependency_check = FALSE) { // Add the libraries first. $success = TRUE; foreach ($elements['#attached']['library'] as $library) { - if (_drupal_add_library($library) === FALSE) { + if (drupal_add_library($library[0], $library[1]) === FALSE) { $success = FALSE; // Exit if the dependency is missing. if ($dependency_check) { @@ -2641,7 +2641,7 @@ function drupal_process_attached($elements, $dependency_check = FALSE) { * @see form_example_states_form() */ function drupal_process_states(&$elements) { - $elements['#attached']['library'][] = 'core/drupal.states'; + $elements['#attached']['library'][] = array('core', 'drupal.states'); // Elements of '#type' => 'item' are not actual form input elements, but we // still want to be able to show/hide them. Since there's no actual HTML input // element available, setting #attributes does not make sense, but a wrapper @@ -2660,7 +2660,9 @@ function drupal_process_states(&$elements) { * depending module, without having to add all files of the library separately. * Each library is only loaded once. * - * @param $library_name + * @param $module + * The name of the module that registered the library. + * @param $name * The name of the library to add. * @param $every_page * Set to TRUE if this library is added to every page on the site. @@ -2672,16 +2674,15 @@ function drupal_process_states(&$elements) { * @see drupal_get_library() * @see hook_library_info_alter() */ -function _drupal_add_library($library_name, $every_page = NULL) { +function drupal_add_library($module, $name, $every_page = NULL) { $added = &drupal_static(__FUNCTION__, array()); - list($extension, $name) = explode('/', $library_name, 2); // Only process the library if it exists and it was not added already. - if (!isset($added[$extension][$name])) { - if ($library = drupal_get_library($library_name)) { + if (!isset($added[$module][$name])) { + if ($library = drupal_get_library($module, $name)) { // Allow modules and themes to dynamically attach request and context // specific data for this library; e.g., localization. - \Drupal::moduleHandler()->alter('library', $library, $library_name); + \Drupal::moduleHandler()->alter('library', $library, $module, $name); // Add all components within the library. $elements['#attached'] = array( @@ -2698,15 +2699,15 @@ function _drupal_add_library($library_name, $every_page = NULL) { } } - $added[$extension][$name] = drupal_process_attached($elements, TRUE); + $added[$module][$name] = drupal_process_attached($elements, TRUE); } else { // Requested library does not exist. - $added[$extension][$name] = FALSE; + $added[$module][$name] = FALSE; } } - return $added[$extension][$name]; + return $added[$module][$name]; } /** @@ -2722,27 +2723,26 @@ function _drupal_add_library($library_name, $every_page = NULL) { * - Two (or more) modules can still register the same library and use it * without conflicts in case the libraries are loaded on certain pages only. * - * @param $library_name - * The name of a registered library to retrieve. By default, all - * libraries registered by the extension are returned. + * @param $extension + * The name of the extension that registered a library. + * @param $name + * (optional) The name of a registered library to retrieve. By default, all + * libraries registered by $extension are returned. * * @return * The definition of the requested library, if $name was passed and it exists, * or FALSE if it does not exist. If no $name was passed, an associative array - * of libraries registered by the module is returned (which may be empty). + * of libraries registered by $extension is returned (which may be empty). * - * @see _drupal_add_library() + * @see drupal_add_library() * @see hook_library_info_alter() * * @todo The purpose of drupal_get_*() is completely different to other page * requisite API functions; find and use a different name. */ -function drupal_get_library($library_name) { +function drupal_get_library($extension, $name = NULL) { $libraries = &drupal_static(__FUNCTION__, array()); - $library_info = explode('/', $library_name, 2); - $extension = $library_info[0]; - $name = isset($library_info[1]) ? $library_info[1] : NULL; if (!isset($libraries[$extension]) && ($cache = \Drupal::cache()->get('library:info:' . $extension))) { $libraries[$extension] = $cache->data; } @@ -2875,6 +2875,13 @@ function drupal_get_library($library_name) { ); unset($library['settings']); } + // @todo Convert all uses of #attached[library][]=array('provider','name') + // into #attached[library][]='provider/name' and remove this. + foreach ($library['dependencies'] as $i => $dependency) { + if (!is_array($dependency)) { + $library['dependencies'][$i] = explode('/', $dependency, 2); + } + } } \Drupal::cache()->set('library:info:' . $extension, $libraries[$extension], Cache::PERMANENT, array( 'extension' => array(TRUE, $extension), @@ -3039,7 +3046,7 @@ function drupal_attach_tabledrag(&$element, array $options) { 'limit' => $options['limit'], ); - $element['#attached']['library'][] = 'core/drupal.tabledrag'; + $element['#attached']['library'][] = array('core', 'drupal.tabledrag'); $element['#attached']['js'][] = array('data' => $settings, 'type' => 'setting'); } @@ -3203,6 +3210,10 @@ function _drupal_bootstrap_full($skip = FALSE) { return; } + // Initialize language (which can strip path prefix) prior to initializing + // current_path(). + drupal_language_initialize(); + // Let all modules take action before the menu system handles the request. // We do not want this while running update.php. if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') { @@ -3587,7 +3598,7 @@ function drupal_pre_render_links($element) { * Pre-render callback: Attaches the dropbutton library and required markup. */ function drupal_pre_render_dropbutton($element) { - $element['#attached']['library'][] = 'core/drupal.dropbutton'; + $element['#attached']['library'][] = array('core', 'drupal.dropbutton'); $element['#attributes']['class'][] = 'dropbutton'; if (!isset($element['#theme_wrappers'])) { $element['#theme_wrappers'] = array(); @@ -3894,12 +3905,6 @@ function drupal_render(&$elements, $is_recursive_call = FALSE) { drupal_process_states($elements); } - // Add additional libraries, CSS, JavaScript and other custom - // attached data associated with this element. - if (!empty($elements['#attached'])) { - drupal_process_attached($elements); - } - // Get the children of the element, sorted by weight. $children = Element::children($elements, TRUE); @@ -3945,6 +3950,12 @@ function drupal_render(&$elements, $is_recursive_call = FALSE) { $elements['#children'] = $elements['#markup'] . $elements['#children']; } + // Add additional libraries, CSS, JavaScript an other custom + // attached data associated with this element. + if (!empty($elements['#attached'])) { + drupal_process_attached($elements); + } + // Let the theme functions in #theme_wrappers add markup around the rendered // children. // #states and #attached have to be processed before #theme_wrappers, because @@ -4560,7 +4571,7 @@ function drupal_render_cache_by_query($query, $function, $expire = Cache::PERMAN * $granularity was passed in, more parts are added. */ function drupal_render_cid_parts($granularity = NULL) { - global $theme, $base_root; + global $theme, $base_root, $user; $cid_parts[] = $theme; @@ -4577,10 +4588,10 @@ function drupal_render_cid_parts($granularity = NULL) { // resource drag for sites with many users, so when a module is being // equivocal, we favor the less expensive 'PER_ROLE' pattern. if ($granularity & DRUPAL_CACHE_PER_ROLE) { - $cid_parts[] = 'r.' . implode(',', \Drupal::currentUser()->getRoles()); + $cid_parts[] = 'r.' . implode(',', $user->getRoles()); } elseif ($granularity & DRUPAL_CACHE_PER_USER) { - $cid_parts[] = 'u.' . \Drupal::currentUser()->id(); + $cid_parts[] = 'u.' . $user->id(); } if ($granularity & DRUPAL_CACHE_PER_PAGE) { diff --git a/core/includes/entity.inc b/core/includes/entity.inc index 51b0f79..fa5f370 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -241,7 +241,11 @@ function entity_revision_delete($entity_type, $revision_id) { function entity_load_by_uuid($entity_type_id, $uuid, $reset = FALSE) { $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); - if (!$uuid_key = $entity_type->getKey('uuid')) { + // Configuration entities do not use annotations to set the UUID key. + if ($entity_type->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface')) { + $uuid_key = 'uuid'; + } + elseif (!$uuid_key = $entity_type->getKey('uuid')) { throw new EntityStorageException("Entity type $entity_type_id does not support UUIDs."); } diff --git a/core/includes/errors.inc b/core/includes/errors.inc index 56c276f..761b7bd 100644 --- a/core/includes/errors.inc +++ b/core/includes/errors.inc @@ -218,22 +218,19 @@ function _drupal_log_error($error, $fatal = FALSE) { } if ($fatal) { + // Should not translate the string to avoid errors producing more errors. + drupal_set_title('Error'); // We fallback to a maintenance page at this point, because the page generation // itself can generate errors. // Should not translate the string to avoid errors producing more errors. $message = 'The website has encountered an error. Please try again later.'; if ($is_installer) { // install_display_output() prints the output and ends script execution. - $output = array( - '#title' => 'Error', - '#markup' => $message, - ); - install_display_output($output, $GLOBALS['install_state']); + install_display_output($message, $GLOBALS['install_state']); } else { $output = array( '#theme' => 'maintenance_page', - '#title' => 'Error', '#content' => $message, ); $output = drupal_render($output); diff --git a/core/includes/form.inc b/core/includes/form.inc index f4a7718..20edb53 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -9,7 +9,6 @@ use Drupal\Component\Utility\Number; use Drupal\Component\Utility\String; use Drupal\Component\Utility\UrlHelper; -use Drupal\Component\Utility\Xss; use Drupal\Core\Database\Database; use Drupal\Core\Language\Language; use Drupal\Core\Template\Attribute; @@ -877,9 +876,7 @@ function form_process_select($element) { } /** - * Prepares variables for select element templates. - * - * Default template: select.html.twig. + * Returns HTML for a select form element. * * It is possible to group options together; to do this, change the format of * $options to an associative array in which the keys are group labels, and the @@ -890,14 +887,15 @@ function form_process_select($element) { * - element: An associative array containing the properties of the element. * Properties used: #title, #value, #options, #description, #extra, * #multiple, #required, #name, #attributes, #size. + * + * @ingroup themeable */ -function template_preprocess_select(&$variables) { +function theme_select($variables) { $element = $variables['element']; element_set_attributes($element, array('id', 'name', 'size')); _form_set_attributes($element, array('form-select')); - $variables['attributes'] = $element['#attributes']; - $variables['options'] = form_select_options($element); + return '' . form_select_options($element) . ''; } /** @@ -1002,59 +1000,68 @@ function form_get_options($element, $key) { } /** - * Prepares variables for fieldset element templates. - * - * Default template: fieldset.html.twig. + * Returns HTML for a fieldset form element and its children. * - * @param array $variables + * @param $variables * An associative array containing: * - element: An associative array containing the properties of the element. - * Properties used: #attributes, #children, #description, #id, #title, - * #value. + * Properties used: #attributes, #children, #description, #id, + * #title, #value. + * + * @ingroup themeable */ -function template_preprocess_fieldset(&$variables) { +function theme_fieldset($variables) { $element = $variables['element']; element_set_attributes($element, array('id')); _form_set_attributes($element, array('form-wrapper')); - $variables['attributes'] = $element['#attributes']; - $variables['attributes']['class'][] = 'form-item'; + + $element['#attributes']['class'][] = 'form-item'; + + if (!empty($element['#description'])) { + $description_id = $element['#attributes']['id'] . '--description'; + $element['#attributes']['aria-describedby'] = $description_id; + } // If the element is required, a required marker is appended to the label. - $variables['required'] = ''; + // @see theme_form_element_label() + $required = ''; if (!empty($element['#required'])) { - $variables['required'] = array( + $marker = array( '#theme' => 'form_required_marker', '#element' => $element, ); + $required = drupal_render($marker); } - $variables['prefix'] = isset($element['#field_prefix']) ? $element['#field_prefix'] : NULL; - $variables['suffix'] = isset($element['#field_suffix']) ? $element['#field_suffix'] : NULL; - $variables['children'] = $element['#children']; - - // Build legend properties. - $variables['legend'] = array(); $legend_attributes = array(); if (isset($element['#title_display']) && $element['#title_display'] == 'invisible') { $legend_attributes['class'][] = 'visually-hidden'; } - $variables['legend']['attributes'] = new Attribute($legend_attributes); - $variables['legend']['title'] = (isset($element['#title']) && $element['#title'] !== '') ? Xss::filterAdmin($element['#title']) : ''; - // Build description properties. - $variables['description'] = array(); - if (!empty($element['#description'])) { - $description_id = $element['#attributes']['id'] . '--description'; - $description_attributes = array( - 'class' => 'description', - 'id' => $description_id, - ); - $variables['description']['attributes'] = new Attribute($description_attributes); - $variables['description']['content'] = $element['#description']; + $output = ''; - // Add the description's id to the fieldset aria attributes. - $variables['attributes']['aria-describedby'] = $description_id; + if ((isset($element['#title']) && $element['#title'] !== '') || !empty($element['#required'])) { + // Always wrap fieldset legends in a SPAN for CSS positioning. + $output .= ''; + $output .= t('!title!required', array('!title' => $element['#title'], '!required' => $required)); + $output .= ''; } + $output .= '
'; + + if (isset($element['#field_prefix'])) { + $output .= '' . $element['#field_prefix'] . ' '; + } + $output .= $element['#children']; + if (isset($element['#field_suffix'])) { + $output .= ' ' . $element['#field_suffix'] . ''; + } + if (!empty($element['#description'])) { + $attributes = array('class' => 'description', 'id' => $description_id); + $output .= '' . $element['#description'] . '
'; + } + $output .= ''; + $output .= "\n"; + return $output; } /** @@ -1600,7 +1607,7 @@ function form_process_container($element, &$form_state) { function theme_tableselect($variables) { $element = $variables['element']; $table = array( - '#type' => 'table', + '#theme' => 'table', ); $rows = array(); $header = $element['#header']; @@ -1641,7 +1648,7 @@ function theme_tableselect($variables) { // checkboxes/radios in the first table column. if ($element['#js_select']) { // Add a "Select all" checkbox. - $table['#attached']['library'][] = 'core/drupal.tableselect'; + $table['#attached']['library'][] = array('core', 'drupal.tableselect'); array_unshift($header, array('class' => array('select-all'))); } else { @@ -1763,7 +1770,7 @@ function form_process_table($element, &$form_state) { // Add a "Select all" checkbox column to the header. // @todo D8: Rename into #select_all? if ($element['#js_select']) { - $element['#attached']['library'][] = 'core/drupal.tableselect'; + $element['#attached']['library'][] = array('core', 'drupal.tableselect'); array_unshift($element['#header'], array('class' => array('select-all'))); } // Add an empty header column for radio buttons or when a "Select all" @@ -1992,7 +1999,7 @@ function form_process_machine_name($element, &$form_state) { 'langcode' => $language->id, ), ); - $element['#attached']['library'][] = 'core/drupal.machine-name'; + $element['#attached']['library'][] = array('core', 'drupal.machine-name'); $element['#attached']['js'][] = $js_settings; return $element; @@ -2085,7 +2092,7 @@ function form_pre_render_details($element) { _form_set_attributes($element, array('form-wrapper')); // Collapsible details. - $element['#attached']['library'][] = 'core/drupal.collapse'; + $element['#attached']['library'][] = array('core', 'drupal.collapse'); if (!empty($element['#open'])) { $element['#attributes']['open'] = 'open'; } @@ -2139,7 +2146,7 @@ function form_pre_render_group($element) { if (isset($element['#group'])) { // Contains form element summary functionalities. - $element['#attached']['library'][] = 'core/drupal.form'; + $element['#attached']['library'][] = array('core', 'drupal.form'); $group = $element['#group']; // If this element belongs to a group, but the group-holding element does @@ -2188,7 +2195,7 @@ function form_process_vertical_tabs($element, &$form_state) { $element['#title_display'] = 'invisible'; } - $element['#attached']['library'][] = 'core/drupal.vertical-tabs'; + $element['#attached']['library'][] = array('core', 'drupal.vertical-tabs'); // The JavaScript stores the currently selected tab in this hidden // field so that the active tab can be restored the next time the @@ -2278,7 +2285,7 @@ function form_process_autocomplete($element, &$form_state) { } if ($access) { $element['#attributes']['class'][] = 'form-autocomplete'; - $element['#attached']['library'][] = 'core/drupal.autocomplete'; + $element['#attached']['library'][] = array('core', 'drupal.autocomplete'); // Provide a data attribute for the JavaScript behavior to bind to. $element['#attributes']['data-autocomplete-path'] = $path; } @@ -2672,16 +2679,16 @@ function form_pre_render_color($element) { } /** - * Prepares variables for form templates. - * - * Default template: form.html.twig. + * Returns HTML for a form. * * @param $variables * An associative array containing: * - element: An associative array containing the properties of the element. * Properties used: #action, #method, #attributes, #children + * + * @ingroup themeable */ -function template_preprocess_form(&$variables) { +function theme_form($variables) { $element = $variables['element']; if (isset($element['#action'])) { $element['#attributes']['action'] = UrlHelper::stripDangerousProtocols($element['#action']); @@ -2690,8 +2697,8 @@ function template_preprocess_form(&$variables) { if (empty($element['#attributes']['accept-charset'])) { $element['#attributes']['accept-charset'] = "UTF-8"; } - $variables['attributes'] = $element['#attributes']; - $variables['children'] = $element['#children']; + // Anonymous DIV to satisfy XHTML compliance. + return '
' . $element['#children'] . '
'; } /** diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 61d9fee..8d08d94 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -6,17 +6,16 @@ use Drupal\Component\Utility\Settings; use Drupal\Core\Config\FileStorage; use Drupal\Core\DrupalKernel; +use Drupal\Core\CoreServiceProvider; use Drupal\Core\Database\Database; use Drupal\Core\Database\DatabaseExceptionWrapper; use Drupal\Core\Database\Install\TaskException; -use Drupal\Core\Installer\Exception\AlreadyInstalledException; -use Drupal\Core\Installer\Exception\InstallerException; -use Drupal\Core\Installer\Exception\NoProfilesException; use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManager; use Drupal\Core\StringTranslation\Translator\FileTranslation; use Drupal\Core\Extension\ExtensionDiscovery; use Drupal\Core\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -90,24 +89,12 @@ function install_drupal($settings = array()) { $interactive = empty($settings); $install_state = $settings + array('interactive' => $interactive) + install_state_defaults(); - try { - // Begin the page request. This adds information about the current state of - // the Drupal installation to the passed-in array. - install_begin_request($install_state); - // Based on the installation state, run the remaining tasks for this page - // request, and collect any output. - $output = install_run_tasks($install_state); - } - catch (InstallerException $e) { - // In the non-interactive installer, exceptions are always thrown directly. - if (!$install_state['interactive']) { - throw $e; - } - $output = array( - '#title' => $e->getTitle(), - '#markup' => $e->getMessage(), - ); - } + // Begin the page request. This adds information about the current state of + // the Drupal installation to the passed-in array. + install_begin_request($install_state); + // Based on the installation state, run the remaining tasks for this page + // request, and collect any output. + $output = install_run_tasks($install_state); // After execution, all tasks might be complete, in which case // $install_state['installation_finished'] is TRUE. In case the last task @@ -205,6 +192,10 @@ function install_state_defaults() { 'profile_info' => array(), // An array of available installation profiles. 'profiles' => array(), + // An array of server variables that will be substituted into the global + // $_SERVER array via drupal_override_server_variables(). Used by + // non-interactive installations only. + 'server' => array(), // The server URL where the interface translation files can be downloaded. // Tokens in the pattern will be replaced by appropriate values for the // required translation file. @@ -249,8 +240,16 @@ function install_state_defaults() { * modified with information gleaned from the beginning of the page request. */ function install_begin_request(&$install_state) { + // A request object from the HTTPFoundation to tell us about the request. $request = Request::createFromGlobals(); + // Create a minimal container so that t() and $request will work. This + // container will be overriden but it's needed for the very early installation + // process when database tasks run. + $container = new ContainerBuilder(); + $container->set('request', $request); + \Drupal::setContainer($container); + // Add any installation parameters passed in via the URL. if ($install_state['interactive']) { $install_state['parameters'] += $request->query->all(); @@ -267,6 +266,10 @@ function install_begin_request(&$install_state) { // Allow command line scripts to override server variables used by Drupal. require_once __DIR__ . '/bootstrap.inc'; + if (!$install_state['interactive']) { + drupal_override_server_variables($install_state['server']); + } + // Initialize conf_path(). // This primes the site path to be used during installation. By not requiring // settings.php, a bare site folder can be prepared in the /sites directory, @@ -303,22 +306,23 @@ function install_begin_request(&$install_state) { include_once __DIR__ . '/session.inc'; require_once __DIR__ . '/entity.inc'; - // Create a minimal mocked container to support calls to t() in the pre-kernel - // base system verification code paths below. The strings are not actually - // used or output for these calls. - // @todo Separate API level checks from UI-facing error messages. - $container = new ContainerBuilder(); - $container->setParameter('language.default_values', Language::$defaultValues); - $container - ->register('language.default', 'Drupal\Core\Language\LanguageDefault') + // If we have a language selected and it is not yet saved in the system (eg. + // pre-database data screens we are unable to persistently store the default + // language), we should set language_default so the proper language is used to + // display installer pages as early as possible. + $default_language_values = Language::$defaultValues; + if (!empty($install_state['parameters']['langcode']) && $default_language_values['id'] != $install_state['parameters']['langcode']) { + $default_language_values = array('id' => $install_state['parameters']['langcode']); + } + // Register the 'language_manager' service. + $container->setParameter('language.default_values', $default_language_values); + $container->register('language.default', 'Drupal\Core\Language\LanguageDefault') ->addArgument('%language.default_values%'); - $container - ->register('language_manager', 'Drupal\Core\Language\LanguageManager') + $container->register('language_manager', 'Drupal\Core\Language\LanguageManager') ->addArgument(new Reference('language.default')); - $container - ->register('string_translation', 'Drupal\Core\StringTranslation\TranslationManager') - ->addArgument(new Reference('language_manager')); + // Register the translation services. + install_register_translation_service($container); \Drupal::setContainer($container); // Determine whether base system services are ready to operate. @@ -342,36 +346,144 @@ function install_begin_request(&$install_state) { } } - // Replace services with in-memory and null implementations. This kernel is - // replaced with a regular one in drupal_install_system(). - if (!$install_state['base_system_verified']) { - $environment = 'install'; - $GLOBALS['conf']['container_service_providers']['InstallerServiceProvider'] = 'Drupal\Core\Installer\InstallerServiceProvider'; + if ($install_state['base_system_verified']) { + $kernel = new DrupalKernel('install', drupal_classloader(), FALSE); + $kernel->boot(); + $container = $kernel->getContainer(); + // Add the file translation service to the container. + $container->set('string_translator.file_translation', install_file_translation_service()); + $container->get('string_translation')->addTranslator($container->get('string_translator.file_translation')); } + // Replace services with in-memory implementations and specialized installer + // implementations. This service container is reverted to a regular + // DrupalKernel in install_bootstrap_full(). else { - $environment = 'prod'; - } + // @todo Move into a proper Drupal\Core\DependencyInjection\InstallContainerBuilder. + $container = new ContainerBuilder(); + $container->register('event_dispatcher', 'Symfony\Component\EventDispatcher\EventDispatcher'); - $kernel = new DrupalKernel($environment, drupal_classloader(), FALSE); - $kernel->boot(); + $container->register('config.storage', 'Drupal\Core\Config\InstallStorage'); - // Enter the request scope and add the Request. - // @todo Remove this after converting all installer screens into controllers. - $container = $kernel->getContainer(); - $container->enterScope('request'); - $container->set('request', $request, 'request'); + $container->register('config.storage.schema', 'Drupal\Core\Config\Schema\SchemaStorage') + ->addArgument(new Reference('config.storage')); - // Register the file translation service. - if (isset($GLOBALS['config']['locale.settings']['translation.path'])) { - $directory = $GLOBALS['config']['locale.settings']['translation.path']; - } - else { - $directory = conf_path() . '/files/translations'; - } - $container->set('string_translator.file_translation', new FileTranslation($directory)); - $container->get('string_translation') - ->addTranslator($container->get('string_translator.file_translation')); + $container->register('config.typed', 'Drupal\Core\Config\TypedConfigManager') + ->addArgument(new Reference('config.storage')) + ->addArgument(new Reference('config.storage.schema')) + ->addArgument(new Reference('cache.config')); + + $container->setParameter('language.default_values', Language::$defaultValues); + $container->register('language.default', 'Drupal\Core\Language\LanguageDefault') + ->addArgument('%language.default_values%'); + + $container->register('config.factory', 'Drupal\Core\Config\ConfigFactory') + ->addArgument(new Reference('config.storage')) + ->addArgument(new Reference('event_dispatcher')) + ->addArgument(new Reference('config.typed')); + + // Register the 'language_manager' service. + $container->register('language_manager', 'Drupal\Core\Language\LanguageManager') + ->addArgument(new Reference('language.default')); + + // Register the translation services. + install_register_translation_service($container); + + foreach (array('bootstrap', 'config', 'cache', 'menu', 'page', 'path') as $bin) { + $container + ->register("cache.$bin", 'Drupal\Core\Cache\MemoryBackend') + ->addArgument($bin); + } + // The install process cannot use the database lock backend since the database + // is not fully up, so we use a null backend implementation during the + // installation process. This will also speed up the installation process. + // The site being installed will use the real lock backend when doing AJAX + // requests but, except for a WSOD, there is no chance for a a lock to stall + // (as opposed to the cache backend) so we can afford having a null + // implementation here. + $container->register('lock', 'Drupal\Core\Lock\NullLockBackend'); + + $container + ->register('theme.registry', 'Drupal\Core\Theme\Registry') + ->addArgument(new Reference('cache.cache')) + ->addArgument(new Reference('lock')) + ->addArgument(new Reference('module_handler')) + ->addTag('needs_destruction'); + + // Register a module handler for managing enabled modules. + $container + ->register('module_handler', 'Drupal\Core\Extension\ModuleHandler'); + + // Register the Guzzle HTTP client for fetching translation files from a + // remote translation server such as localization.drupal.org. + $container->register('http_default_client', 'Guzzle\Http\Client') + ->addArgument(NULL) + ->addArgument(array( + 'curl.CURLOPT_TIMEOUT' => 30.0, + 'curl.CURLOPT_MAXREDIRS' => 3, + )) + ->addMethodCall('setUserAgent', array('Drupal (+http://drupal.org/)')); + + $container->register('settings', 'Drupal\Component\Utility\Settings') + ->setFactoryClass('Drupal\Component\Utility\Settings') + ->setFactoryMethod('getSingleton'); + + $container + ->register('keyvalue', 'Drupal\Core\KeyValueStore\KeyValueMemoryFactory'); + $container + ->register('keyvalue.expirable', 'Drupal\Core\KeyValueStore\KeyValueNullExpirableFactory'); + + $container->register('state', 'Drupal\Core\KeyValueStore\State') + ->addArgument(new Reference('keyvalue')); + + // Register Twig template engine for use during install. + CoreServiceProvider::registerTwig($container); + + $container->register('url_generator', 'Drupal\Core\Routing\NullGenerator'); + + $container->register('form_builder', 'Drupal\Core\Form\FormBuilder') + ->addArgument(new Reference('module_handler')) + ->addArgument(new Reference('keyvalue.expirable')) + ->addArgument(new Reference('event_dispatcher')) + ->addArgument(new Reference('url_generator')) + ->addArgument(new Reference('string_translation')) + ->addArgument(new Reference('csrf_token', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)) + ->addArgument(new Reference('http_kernel', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)) + ->addMethodCall('setRequest', array(new Reference('request'))); + + // Register UUID. + CoreServiceProvider::registerUuid($container); + + // Register the CSS and JavaScript asset collection renderers. + $container->register('asset.css.collection_renderer', 'Drupal\Core\Asset\CssCollectionRenderer') + ->addArgument(new Reference('state')); + $container->register('asset.js.collection_renderer', 'Drupal\Core\Asset\JsCollectionRenderer') + ->addArgument(new Reference('state')); + + // Register the info parser. + $container->register('info_parser', 'Drupal\Core\Extension\InfoParser'); + + $container->register('theme_handler', 'Drupal\Core\Extension\ThemeHandler') + ->addArgument(new Reference('config.factory')) + ->addArgument(new Reference('module_handler')) + ->addArgument(new Reference('cache.cache')) + ->addArgument(new Reference('info_parser')); + + // Overrides can not work at this point since this would cause the + // ConfigFactory to try to load language override configuration which is not + // supported by \Drupal\Core\Config\InstallStorage since loading a + // non-existing file would throw an exception. + $container->get('config.factory')->setOverrideState(FALSE); + } + + // Set the request in the kernel to the new created Request above + // so it is available to the rest of the installation process. + $container->set('request', $request); + + \Drupal::setContainer($container); + + // Set up $language, so t() caller functions will still work. + drupal_language_initialize(); // Add in installation language if present. if (isset($install_state['parameters']['langcode'])) { \Drupal::translation()->setDefaultLangcode($install_state['parameters']['langcode']); @@ -414,7 +526,7 @@ function install_begin_request(&$install_state) { // Do not install over a configured settings.php. if (!empty($GLOBALS['databases'])) { - throw new AlreadyInstalledException($container->get('string_translation')); + throw new Exception(install_already_done_error()); } } @@ -424,7 +536,7 @@ function install_begin_request(&$install_state) { $config = glob(config_get_config_directory(CONFIG_ACTIVE_DIRECTORY) . '/*.' . FileStorage::getFileExtension()); if (!empty($config)) { $task = NULL; - throw new AlreadyInstalledException($container->get('string_translation')); + throw new Exception(install_already_done_error()); } } @@ -499,8 +611,47 @@ function install_run_task($task, &$install_state) { $function = $task['function']; if ($task['type'] == 'form') { - return install_get_form($function, $install_state); + if ($install_state['interactive']) { + // For interactive forms, build the form and ensure that it will not + // redirect, since the installer handles its own redirection only after + // marking the form submission task complete. + $form_state = array( + // We need to pass $install_state by reference in order for forms to + // modify it, since the form API will use it in call_user_func_array(), + // which requires that referenced variables be passed explicitly. + 'build_info' => array('args' => array(&$install_state)), + 'no_redirect' => TRUE, + ); + $form = drupal_build_form($function, $form_state); + // If a successful form submission did not occur, the form needs to be + // rendered, which means the task is not complete yet. + if (empty($form_state['executed'])) { + $install_state['task_not_complete'] = TRUE; + return drupal_render($form); + } + // Otherwise, return nothing so the next task will run in the same + // request. + return; + } + else { + // For non-interactive forms, submit the form programmatically with the + // values taken from the installation state. Throw an exception if any + // errors were encountered. + $form_state = array( + 'values' => !empty($install_state['forms'][$function]) ? $install_state['forms'][$function] : array(), + // We need to pass $install_state by reference in order for forms to + // modify it, since the form API will use it in call_user_func_array(), + // which requires that referenced variables be passed explicitly. + 'build_info' => array('args' => array(&$install_state)), + ); + drupal_form_submit($function, $form_state); + $errors = form_get_errors($form_state); + if (!empty($errors)) { + throw new Exception(implode("\n", $errors)); + } + } } + elseif ($task['type'] == 'batch') { // Start a new batch based on the task function, if one is not running // already. @@ -684,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 = $install_state['profiles'][$profile]->getPath() . '/' . $profile . '.install'; + $profile_install_file = dirname($install_state['profiles'][$profile]->uri) . '/' . $profile . '.install'; if (file_exists($profile_install_file)) { include_once DRUPAL_ROOT . '/' . $profile_install_file; } @@ -768,57 +919,6 @@ function install_tasks_to_display($install_state) { } /** - * Builds and processes a form for the installer environment. - * - * Ensures that FormBuilder does not redirect after submitting a form, since the - * installer uses a custom step/flow logic via install_run_tasks(). - * - * @param string|array $form_id - * The form ID to build and process. - * @param array $install_state - * The current state of the installation. - * - * @return array|null - * A render array containing the form to render, or NULL in case the form was - * successfully submitted. - * - * @throws \Drupal\Core\Installer\Exception\InstallerException - */ -function install_get_form($form_id, array &$install_state) { - // Ensure the form will not redirect, since install_run_tasks() uses a custom - // redirection logic. - $form_state = array( - 'build_info' => array( - 'args' => array(&$install_state), - ), - 'no_redirect' => TRUE, - ); - if ($install_state['interactive']) { - $form = drupal_build_form($form_id, $form_state); - // If the form submission was not successful, the form needs to be rendered, - // which means the task is not complete yet. - if (empty($form_state['executed'])) { - $install_state['task_not_complete'] = TRUE; - return $form; - } - } - else { - // For non-interactive installs, submit the form programmatically with the - // values taken from the installation state. - $form_state['values'] = array(); - if (!empty($install_state['forms'][$form_id])) { - $form_state['values'] = $install_state['forms'][$form_id]; - } - drupal_form_submit($form_id, $form_state); - - // Throw an exception in case of any form validation error. - if ($errors = form_get_errors($form_state)) { - throw new InstallerException(implode("\n", $errors)); - } - } -} - -/** * Returns the URL that should be redirected to during an installation request. * * The output of this function is suitable for sending to install_goto(). @@ -854,7 +954,7 @@ function install_full_redirect_url($install_state) { /** * Displays themed installer output and ends the page request. * - * Installation tasks should use #title to set the desired page + * Installation tasks should use drupal_set_title() to set the desired page * title, but otherwise this function takes care of theming the overall page * output during every step of the installation. * @@ -900,17 +1000,7 @@ function install_display_output($output, $install_state) { ); drupal_add_region_content('sidebar_first', drupal_render($task_list)); } - $install_page = array( - '#theme' => 'install_page', - // $output has to be rendered here, because the install page template is not - // wrapped into the html template, which means that any #attached libraries - // in $output will not be loaded, because the wrapping HTML has been printed - // already. - '#content' => drupal_render($output), - ); - if (isset($output['#title'])) { - $install_page['#page']['#title'] = $output['#title']; - } + $install_page = array('#theme' => 'install_page', '#content' => $output); print drupal_render($install_page); exit; } @@ -982,11 +1072,11 @@ function install_verify_completed_task() { } // Do not trigger an error if the database query fails, since the database // might not be set up yet. - catch (\Exception $e) { + catch (Exception $e) { } if (isset($task)) { if ($task == 'done') { - throw new AlreadyInstalledException(\Drupal::service('string_translation')); + throw new Exception(install_already_done_error()); } return $task; } @@ -1024,7 +1114,7 @@ function install_settings_form($form, &$form_state, &$install_state) { $conf_path = './' . conf_path(FALSE); $settings_file = $conf_path . '/settings.php'; - $form['#title'] = t('Database configuration'); + drupal_set_title(t('Database configuration')); $drivers = drupal_get_database_types(); $drivers_keys = array_keys($drivers); @@ -1215,21 +1305,26 @@ function install_settings_form_submit($form, &$form_state) { */ function install_select_profile(&$install_state) { if (empty($install_state['parameters']['profile'])) { - // If there are no profiles at all, installation cannot proceed. - if (empty($install_state['profiles'])) { - throw new NoProfilesException(\Drupal::service('string_translation')); - } - // Try to automatically select a profile. - if ($profile = _install_select_profile($install_state['profiles'])) { - $install_state['parameters']['profile'] = $profile; + // Try to find a profile. + $profile = _install_select_profile($install_state['profiles']); + if (empty($profile)) { + // We still don't have a profile, so display a form for selecting one. + // Only do this in the case of interactive installations, since this is + // not a real form with submit handlers (the database isn't even set up + // yet), rather just a convenience method for setting parameters in the + // URL. + if ($install_state['interactive']) { + include_once __DIR__ . '/form.inc'; + drupal_set_title(t('Select an installation profile')); + $form = drupal_get_form('install_select_profile_form', $install_state); + return drupal_render($form); + } + else { + throw new Exception(install_no_profile_error()); + } } else { - // The non-interactive installer requires a profile parameter. - if (!$install_state['interactive']) { - throw new InstallerException(t('Missing profile parameter.')); - } - // Otherwise, display a form to select a profile. - return install_get_form('install_select_profile_form', $install_state); + $install_state['parameters']['profile'] = $profile; } } } @@ -1256,19 +1351,19 @@ function _install_select_profile($profiles) { $request_params = \Drupal::request()->request; if (count($profiles) == 1) { $profile = array_pop($profiles); - return $profile->getName(); + return $profile->name; } elseif ($request_params->has('profile') && ($profile = $request_params->get('profile')) && isset($profiles[$profile])) { - return $profiles[$profile]->getName(); + return $profiles[$profile]->name; } // 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->getName()); + $profile_info = install_profile_info($profile->name); if (!empty($profile_info['exclusive'])) { if (empty($exclusive_profile)) { - $exclusive_profile = $profile->getName(); + $exclusive_profile = $profile->name; } else { // We found a second "exclusive" profile. There's no way to choose @@ -1289,12 +1384,11 @@ function _install_select_profile($profiles) { * @ingroup forms */ function install_select_profile_form($form, &$form_state, $install_state) { - $form['#title'] = t('Select an installation profile'); - $profiles = array(); $names = array(); + foreach ($install_state['profiles'] as $profile) { - $details = install_profile_info($profile->getName()); + $details = install_profile_info($profile->name); // Skip this extension if its type is not profile. if (!isset($details['type']) || $details['type'] != 'profile') { continue; @@ -1304,12 +1398,12 @@ function install_select_profile_form($form, &$form_state, $install_state) { if ($details['hidden'] === TRUE) { continue; } - $profiles[$profile->getName()] = $details; + $profiles[$profile->name] = $details; // Determine the name of the profile; default to file name if defined name // is unspecified. - $name = isset($details['name']) ? $details['name'] : $profile->getName(); - $names[$profile->getName()] = $name; + $name = isset($details['name']) ? $details['name'] : $profile->name; + $names[$profile->name] = $name; } // Display radio buttons alphabetically by human-readable name, but always @@ -1378,6 +1472,53 @@ function install_find_translations() { } /** + * Build a file translation service for installation. + * + * @return \Drupal\Core\StringTranslation\Translator\FileTranslation + * File translation service for the installer. + */ +function install_file_translation_service() { + static $translation; + if (!isset($translation)) { + $translation = new FileTranslation(install_translations_directory()); + } + return $translation; +} + +/** + * Finds the translations directory for the installation. + * + * @return string + * The path to the installation directory. + */ +function install_translations_directory() { + if (isset($GLOBALS['conf']['locale.settings']['translation.path'])) { + $directory = $GLOBALS['conf']['locale.settings']['translation.path']; + } + else { + $directory = conf_path() . '/files/translations'; + } + return $directory; +} + +/** + * Build a file translation service for installation. + * + * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container + * The container to append translation related services. + */ +function install_register_translation_service(ContainerBuilder $container) { + $container->register('string_translator.file_translation', 'Drupal\Core\StringTranslation\Translator\FileTranslation') + ->addArgument(install_translations_directory()); + $container->register('string_translator.custom_strings', 'Drupal\Core\StringTranslation\Translator\CustomStrings') + ->addArgument(settings()); + $container->register('string_translation', 'Drupal\Core\StringTranslation\TranslationManager') + ->addArgument(new Reference('language_manager')) + ->addMethodCall('addTranslator', array(new Reference('string_translator.file_translation'))) + ->addMethodCall('addTranslator', array(new Reference('string_translator.custom_strings'))); +} + +/** * Selects which language to use during installation. * * @param $install_state @@ -1395,6 +1536,7 @@ function install_select_language(&$install_state) { // Find all available translation files. $files = install_find_translations(); $install_state['translations'] += $files; + $request_params = \Drupal::request()->request; // If a valid language code is set, continue with the next installation step. // When translations from the localization server are used, any language code @@ -1402,9 +1544,9 @@ function install_select_language(&$install_state) { // langauges available at http://localize.drupal.org. // When files from the translation directory are used, we only accept // languages for which a file is available. - if (!empty($install_state['parameters']['langcode'])) { + if ($request_params->has('langcode')) { $standard_languages = LanguageManager::getStandardLanguageList(); - $langcode = $install_state['parameters']['langcode']; + $langcode = $request_params->get('langcode'); if ($langcode == 'en' || isset($files[$langcode]) || isset($standard_languages[$langcode])) { $install_state['parameters']['langcode'] = $langcode; return; @@ -1418,7 +1560,10 @@ function install_select_language(&$install_state) { // translation files were found the form shows a select list of the // corresponding languages to choose from. if ($install_state['interactive']) { - return install_get_form('install_select_language_form', $install_state); + drupal_set_title(t('Choose language')); + include_once __DIR__ . '/form.inc'; + $elements = drupal_get_form('install_select_language_form', count($files) > 1 ? $files : array()); + return drupal_render($elements); } // If we are performing a non-interactive installation. If only one language // (English) is available, assume the user knows what he is doing. Otherwise @@ -1429,7 +1574,7 @@ function install_select_language(&$install_state) { return; } else { - throw new InstallerException(t('Sorry, you must select a language to continue the installation.')); + throw new Exception(t('Sorry, you must select a language to continue the installation.')); } } } @@ -1438,25 +1583,18 @@ function install_select_language(&$install_state) { /** * Form constructor for the language selection form. * - * @param $install_state - * An array of information about the current installation state. + * @param array $files + * (optional) An associative array of file URIs keyed by language code as + * returned by file_scan_directory(). Defaults to all standard languages. * * @see file_scan_directory() * @ingroup forms */ -function install_select_language_form($form, &$form_state, &$install_state) { - if (count($install_state['translations']) > 1) { - $files = $install_state['translations']; - } - else { - $files = array(); - } +function install_select_language_form($form, &$form_state, $files = array()) { $standard_languages = LanguageManager::getStandardLanguageList(); $select_options = array(); $browser_options = array(); - $form['#title'] = t('Choose language'); - // Build a select list with language names in native language for the user // to choose from. And build a list of available languages for the browser // to select the language default from. @@ -1510,14 +1648,6 @@ function install_select_language_form($form, &$form_state, &$install_state) { } /** - * Form submission handler for the language selection form. - */ -function install_select_language_form_submit($form, &$form_state) { - $install_state = &$form_state['build_info']['args'][0]; - $install_state['parameters']['langcode'] = $form_state['values']['langcode']; -} - -/** * Download a translation file for the selected langaguage. * * @param array $install_state @@ -1690,7 +1820,7 @@ function install_get_localization_release($version = \Drupal::VERSION) { } } - // All releases may fall back to the previous major release (e.g., 8.1 falls + // All releases may a fallback to the previous major release (e.g., 8.1 falls // back to 7.0, 8.x-dev falls back to 7.0). This will probably only be used // for early dev releases or languages with an inactive translation team. $alternatives[] = $info['major'] - 1 . '.0'; @@ -1743,6 +1873,24 @@ function _install_get_version_info($version) { } /** + * Indicates that there are no profiles available. + */ +function install_no_profile_error() { + drupal_set_title(t('No profiles available')); + return t('We were unable to find any installation profiles. Installation profiles tell us what modules to enable and what schema to install in the database. A profile is necessary to continue with the installation process.'); +} + +/** + * Indicates that Drupal has already been installed. + */ +function install_already_done_error() { + global $base_url; + + drupal_set_title(t('Drupal already installed')); + return t('
  • To start over, you must empty your existing database, delete your active configuration, and copy default.settings.php over settings.php.
  • To install to a different database, edit the appropriate settings.php file in the sites folder.
  • To locate your active configuration, view the appropriate settings.php file in the sites folder.
  • To upgrade an existing installation, proceed to the update script.
  • View your existing site.
', array('@base-url' => $base_url)); +} + +/** * Loads information about the chosen profile during installation. * * @param $install_state @@ -1758,7 +1906,7 @@ function install_load_profile(&$install_state) { $install_state['profile_info'] = install_profile_info($install_state['parameters']['profile'], $install_state['parameters']['langcode']); } else { - throw new InstallerException(t('Sorry, the profile you have chosen cannot be loaded.')); + throw new Exception(t('Sorry, the profile you have chosen cannot be loaded.')); } } @@ -1924,7 +2072,7 @@ function _install_prepare_import($langcode) { * @ingroup forms */ function install_configure_form($form, &$form_state, &$install_state) { - $form['#title'] = t('Configure site'); + drupal_set_title(t('Configure site')); // Warn about settings.php permissions risk $settings_dir = conf_path(); @@ -1941,9 +2089,9 @@ function install_configure_form($form, &$form_state, &$install_state) { drupal_set_message(t('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the online handbook.', array('%dir' => $settings_dir, '%file' => $settings_file, '@handbook_url' => 'http://drupal.org/server-permissions')), 'warning'); } - $form['#attached']['library'][] = 'system/drupal.system'; + $form['#attached']['library'][] = array('system', 'drupal.system'); // Add JavaScript time zone detection. - $form['#attached']['library'][] = 'core/drupal.timezone'; + $form['#attached']['library'][] = array('core', 'drupal.timezone'); // We add these strings as settings because JavaScript translation does not // work during installation. $js = array('copyFieldValue' => array('edit-site-mail' => array('edit-account-mail'))); @@ -2026,6 +2174,8 @@ function install_finished(&$install_state) { // registered by the installation profile are registered correctly. drupal_flush_all_caches(); + drupal_set_title(t('@drupal installation complete', array('@drupal' => drupal_install_profile_distribution_name())), PASS_THROUGH); + $messages = drupal_set_message(); $output = '

' . t('Congratulations, you installed @drupal!', array('@drupal' => drupal_install_profile_distribution_name())) . '

'; // Ensure the URL that is generated for the home page does not have 'install.php' @@ -2047,11 +2197,7 @@ function install_finished(&$install_state) { $snapshot = \Drupal::service('config.storage.snapshot'); \Drupal::service('config.manager')->createSnapshot($active, $snapshot); - $build = array( - '#title' => t('@drupal installation complete', array('@drupal' => drupal_install_profile_distribution_name())), - '#markup' => $output, - ); - return $build; + return $output; } /** @@ -2379,7 +2525,7 @@ function install_check_requirements($install_state) { * in the URL. Otherwise, no output is returned, so that the next task can be * run in the same page request. * - * @throws \Drupal\Core\Installer\Exception\InstallerException + * @thows \Exception */ function install_display_requirements($install_state, $requirements) { // Check the severity of the requirements reported. @@ -2390,13 +2536,14 @@ function install_display_requirements($install_state, $requirements) { // and indicating a desire to continue anyway. See drupal_requirements_url(). if ($severity == REQUIREMENT_ERROR || ($severity == REQUIREMENT_WARNING && empty($install_state['parameters']['continue']))) { if ($install_state['interactive']) { - $build['#title'] = t('Requirements problem'); - $build['report'] = array( + drupal_set_title(t('Requirements problem')); + $status_report = array( '#theme' => 'status_report', '#requirements' => $requirements, - '#suffix' => t('Check the messages and try again.', array('!url' => check_url(drupal_requirements_url($severity)))), ); - return $build; + $status_report = drupal_render($status_report); + $status_report .= t('Check the messages and try again.', array('!url' => check_url(drupal_requirements_url($severity)))); + return $status_report; } else { // Throw an exception showing any unmet requirements. @@ -2410,7 +2557,7 @@ function install_display_requirements($install_state, $requirements) { } } if (!empty($failures)) { - throw new InstallerException(implode("\n\n", $failures)); + throw new \Exception(implode("\n\n", $failures)); } } } @@ -2578,7 +2725,7 @@ function install_configure_form_submit($form, &$form_state) { $account->pass = $form_state['values']['account']['pass']; $account->name = $form_state['values']['account']['name']; $account->save(); - // Load current user and perform final login tasks. + // Load global $user and perform final login tasks. $account = user_load(1); user_login_finalize($account); diff --git a/core/includes/install.inc b/core/includes/install.inc index c2a138c..74d8e39 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -573,7 +573,9 @@ function drupal_verify_profile($install_state) { include_once __DIR__ . '/common.inc'; $profile = $install_state['parameters']['profile']; - if (!isset($profile) || !isset($install_state['profiles'][$profile])) { + $profile_file = $install_state['profiles'][$profile]->uri; + + if (!isset($profile) || !file_exists($profile_file)) { throw new Exception(install_no_profile_error()); } $info = $install_state['profile_info']; @@ -582,7 +584,7 @@ function drupal_verify_profile($install_state) { $listing = new ExtensionDiscovery(); $present_modules = array(); foreach ($listing->scan('module') as $present_module) { - $present_modules[] = $present_module->getName(); + $present_modules[] = $present_module->name; } // The installation profile is also a module, which needs to be installed @@ -623,16 +625,19 @@ function drupal_install_system($install_state) { // Create tables. drupal_install_schema('system'); - // Immediately boot a new kernel into the regular production environment. - $request = \Drupal::hasRequest() ? \Drupal::request() : FALSE; - - unset($GLOBALS['conf']['container_service_providers']['InstallerServiceProvider']); - $kernel = new DrupalKernel('prod', drupal_classloader(), FALSE); - $kernel->boot(); + if (!\Drupal::hasService('kernel')) { + // Immediately boot a kernel to have real services ready. If there's already + // an initialized request object in the pre-kernel container, persist it in + // the post-kernel container. + if (\Drupal::getContainer()->initialized('request')) { + $request = \Drupal::request(); + } + $kernel = new DrupalKernel('install', drupal_classloader(), FALSE); + $kernel->boot(); + if (isset($request)) { + \Drupal::getContainer()->set('request', $request); + } - if ($request) { - $kernel->getContainer()->enterScope('request'); - $kernel->getContainer()->set('request', $request, 'request'); } $system_path = drupal_get_path('module', 'system'); diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 838b32a..a1c8a01 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -342,7 +342,7 @@ function menu_tree($menu_name) { } /** - * Returns an output structure for rendering a menu tree. + * Returns a rendered menu tree. * * The menu item's LI element is given one of the following classes: * - expanded: The menu item is showing its submenu. diff --git a/core/includes/module.inc b/core/includes/module.inc index 7bb0e3e..e412598 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -63,7 +63,7 @@ function system_list($type) { $lists['filepaths'][] = array( 'type' => 'theme', 'name' => $name, - 'filepath' => $theme->getPathname(), + 'filepath' => $theme->filename, ); } } diff --git a/core/includes/tablesort.inc b/core/includes/tablesort.inc index cd5c0c1..5b1440c 100644 --- a/core/includes/tablesort.inc +++ b/core/includes/tablesort.inc @@ -9,7 +9,7 @@ * @file * Functions to aid in the creation of sortable tables. * - * All tables created when rendering a '#type' => 'table' have the option of + * All tables created when rendering a '#theme' => 'table' have the option of * having column headers that the user can click on to sort the table by that * column. */ @@ -33,7 +33,7 @@ function tablesort_init($header) { * @param $cell * The cell to format. * @param $header - * An array of column headers in the format described in '#type' => 'table'. + * An array of column headers in the format described in '#theme' => 'table'. * @param $ts * The current table sort context as returned from tablesort_init(). * @@ -77,7 +77,7 @@ function tablesort_header($cell, $header, $ts) { * @param $cell * The cell to format. * @param $header - * An array of column headers in the format described in '#type' => 'table'. + * An array of column headers in the format described in '#theme' => 'table'. * @param $ts * The current table sort context as returned from tablesort_init(). * @param $i @@ -113,7 +113,7 @@ function tablesort_get_query_parameters() { * Determines the current sort criterion. * * @param $headers - * An array of column headers in the format described in '#type' => 'table'. + * An array of column headers in the format described in '#theme' => 'table'. * * @return * An associative array describing the criterion, containing the keys: @@ -150,7 +150,7 @@ function tablesort_get_order($headers) { * Determines the current sort direction. * * @param $headers - * An array of column headers in the format described in '#type' => 'table'. + * An array of column headers in the format described in '#theme' => 'table'. * * @return * The current sort direction ("asc" or "desc"). diff --git a/core/includes/theme.inc b/core/includes/theme.inc index bbeb9cb..1526113 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -79,7 +79,7 @@ */ function drupal_theme_access($theme) { if ($theme instanceof Extension) { - $theme = $theme->getName(); + $theme = $theme->name; } return \Drupal::service('access_check.theme')->checkAccess($theme); } @@ -88,7 +88,7 @@ function drupal_theme_access($theme) { * Initializes the theme system by loading the theme. */ function drupal_theme_initialize() { - global $theme, $theme_key; + global $theme, $user, $theme_key; // If $theme is already set, assume the others are set, too, and do nothing if (isset($theme)) { @@ -135,7 +135,7 @@ function _drupal_theme_initialize($theme, $base_theme = array()) { $theme_info = $theme; $base_theme_info = $base_theme; - $theme_path = $theme->getPath(); + $theme_path = dirname($theme->filename); // 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 = $base->getPath(); + $base_theme_path = dirname($base->filename); if (!empty($base->info['stylesheets-remove'])) { foreach ($base->info['stylesheets-remove'] as $basename) { $theme->stylesheets_remove[$basename] = $base_theme_path . '/' . $basename; @@ -340,23 +340,87 @@ function list_themes($refresh = FALSE) { } /** - * Generates themed output (internal use only). - * - * _theme() is an internal function. Do not call this function directly as it - * will prevent the following items from working correctly: - * - Render caching. - * - JavaScript and CSS asset attachment. - * - Pre / post render hooks. - * - Defaults provided by hook_element_info(), including attached assets. - * Instead, build a render array with a #theme key, and either return the - * array (where possible) or call drupal_render() to convert it to HTML. - * - * All requests for themed output must go through this function, which is - * invoked as part of the @link theme_render drupal_render() process @endlink. - * The appropriate theme function is indicated by the #theme property - * of a renderable array. _theme() examines the request and routes it to the - * appropriate @link themeable theme function or template @endlink, by checking - * the theme registry. + * Generates themed output. + * + * All requests for themed output must go through this function (however, + * calling the _theme() function directly is very strongly discouraged - see + * next paragraph). It examines the request and routes it to the appropriate + * @link themeable theme function or template @endlink, by checking the theme + * registry. + * + * Avoid calling this function directly. It is preferable to replace direct + * calls to the _theme() function with calls to drupal_render() by passing a + * render array with a #theme key to drupal_render(), which in turn calls + * _theme(). + * + * @section sec_theme_hooks Theme Hooks + * Most commonly, the first argument to this function is the name of the theme + * hook. For instance, to theme a taxonomy term, the theme hook name is + * 'taxonomy_term'. Modules register theme hooks within a hook_theme() + * implementation and provide a default implementation via a function named + * theme_HOOK() (e.g., theme_taxonomy_term()) or via a template file named + * according to the value of the 'template' key registered with the theme hook + * (see hook_theme() for details). Default templates are implemented with the + * Twig rendering engine and are named the same as the theme hook, with + * underscores changed to hyphens, so for the 'taxonomy_term' theme hook, the + * default template is 'taxonomy-term.html.twig'. + * + * @subsection sub_overriding_theme_hooks Overriding Theme Hooks + * Themes may also register new theme hooks within a hook_theme() + * implementation, but it is more common for themes to override default + * implementations provided by modules than to register entirely new theme + * hooks. Themes can override a default implementation by implementing a + * function named THEME_HOOK() (for example, the 'bartik' theme overrides the + * default implementation of the 'menu_tree' theme hook by implementing a + * bartik_menu_tree() function), or by adding a template file within its folder + * structure that follows the template naming structure used by the theme's + * rendering engine (for example, since the Bartik theme uses the Twig rendering + * engine, it overrides the default implementation of the 'page' theme hook by + * containing a 'page.html.twig' file within its folder structure). + * + * @subsection sub_preprocess_templates Preprocessing for Template Files + * If the implementation is a template file, several functions are called before + * the template file is invoked to modify the $variables array. These make up + * the "preprocessing" phase, and are executed (if they exist), in the following + * order (note that in the following list, HOOK indicates the theme hook name, + * MODULE indicates a module name, THEME indicates a theme name, and ENGINE + * indicates a theme engine name): + * - template_preprocess(&$variables, $hook): Creates a default set of variables + * for all theme hooks with template implementations. + * - template_preprocess_HOOK(&$variables): Should be implemented by the module + * that registers the theme hook, to set up default variables. + * - MODULE_preprocess(&$variables, $hook): hook_preprocess() is invoked on all + * implementing modules. + * - MODULE_preprocess_HOOK(&$variables): hook_preprocess_HOOK() is invoked on + * all implementing modules, so that modules that didn't define the theme hook + * can alter the variables. + * - ENGINE_engine_preprocess(&$variables, $hook): Allows the theme engine to + * set necessary variables for all theme hooks with template implementations. + * - ENGINE_engine_preprocess_HOOK(&$variables): Allows the theme engine to set + * necessary variables for the particular theme hook. + * - THEME_preprocess(&$variables, $hook): Allows the theme to set necessary + * variables for all theme hooks with template implementations. + * - THEME_preprocess_HOOK(&$variables): Allows the theme to set necessary + * variables specific to the particular theme hook. + * + * @subsection sub_preprocess_theme_funcs Preprocessing for Theme Functions + * If the implementation is a function, only the theme-hook-specific preprocess + * functions (the ones ending in _HOOK) are called from the list above. This is + * because theme hooks with function implementations need to be fast, and + * calling the non-theme-hook-specific preprocess functions for them would incur + * a noticeable performance penalty. + * + * @subsection sub_alternate_suggestions Suggesting Alternate Hooks + * Alternate hooks can be suggested by implementing the hook-specific + * hook_theme_suggestions_HOOK_alter() or the generic + * hook_theme_suggestions_alter(). These alter hooks are used to manipulate an + * array of suggested alternate theme hooks to use, in reverse order of + * priority. _theme() will use the highest priority implementation that exists. + * If none exists, _theme() will use the implementation for the theme hook it + * was called with. These suggestions are similar to and are used for similar + * reasons as calling _theme() with an array as the $hook parameter (see below). + * The difference is whether the suggestions are determined by the code that + * calls _theme() or by altering the suggestions via the suggestion alter hooks. * * @param $hook * The name of the theme hook to call. If the name contains a @@ -729,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->getName()] = $theme_info->getPath(); + $theme_paths[$theme_info->base_theme][$theme_info->name] = dirname($theme_info->filename); } } foreach ($theme_paths as $basetheme => $subthemes) { @@ -864,17 +928,17 @@ function theme_get_setting($setting_name, $theme = NULL) { } foreach ($theme_keys as $theme_key) { if (!empty($themes[$theme_key]->info['settings'])) { - $cache[$theme]->merge($themes[$theme_key]->info['settings']); + $cache[$theme]->mergeData($themes[$theme_key]->info['settings']); } } } // Get the global settings from configuration. - $cache[$theme]->merge(\Drupal::config('system.theme.global')->get()); + $cache[$theme]->mergeData(\Drupal::config('system.theme.global')->get()); if ($theme) { // Get the saved theme-specific settings from the configuration system. - $cache[$theme]->merge(\Drupal::config($theme . '.settings')->get()); + $cache[$theme]->mergeData(\Drupal::config($theme . '.settings')->get()); // If the theme does not support a particular feature, override the global // setting and set the value to NULL. @@ -891,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($theme_object->getPath() . '/logo.png')); + $cache[$theme]->set('logo.url', file_create_url(dirname($theme_object->filename) . '/logo.png')); } elseif ($logo_path) { $cache[$theme]->set('logo.url', file_create_url($logo_path)); @@ -902,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 = $theme_object->getPath() . '/favicon.ico')) { + if (file_exists($favicon = dirname($theme_object->filename) . '/favicon.ico')) { $cache[$theme]->set('favicon.url', file_create_url($favicon)); } else { @@ -1352,24 +1416,6 @@ function drupal_pre_render_table(array $element) { // Take over $element['#id'] as HTML ID attribute, if not already set. element_set_attributes($element, array('id')); - - // Add sticky headers, if applicable. - if (count($element['#header']) && $element['#sticky']) { - $element['#attached']['library'][] = 'core/drupal.tableheader'; - // Add 'sticky-enabled' class to the table to identify it for JS. - // This is needed to target tables constructed by this function. - $element['#attributes']['class'][] = 'sticky-enabled'; - } - // If the table has headers and it should react responsively to columns hidden - // with the classes represented by the constants RESPONSIVE_PRIORITY_MEDIUM - // and RESPONSIVE_PRIORITY_LOW, add the tableresponsive behaviors. - if (count($element['#header']) && $element['#responsive']) { - $element['#attached']['library'][] = 'core/drupal.tableresponsive'; - // Add 'responsive-enabled' class to the table to identify it for JS. - // This is needed to target tables constructed by this function. - $element['#attributes']['class'][] = 'responsive-enabled'; - } - // If the custom #tabledrag is set and there is a HTML ID, add the table's // HTML ID to the options and attach the behavior. if (!empty($element['#tabledrag']) && isset($element['#attributes']['id'])) { @@ -1477,6 +1523,23 @@ function theme_table($variables) { $responsive = $variables['responsive']; $empty = $variables['empty']; + // Add sticky headers, if applicable. + if (count($header) && $sticky) { + drupal_add_library('core', 'drupal.tableheader'); + // Add 'sticky-enabled' class to the table to identify it for JS. + // This is needed to target tables constructed by this function. + $attributes['class'][] = 'sticky-enabled'; + } + // If the table has headers and it should react responsively to columns hidden + // with the classes represented by the constants RESPONSIVE_PRIORITY_MEDIUM + // and RESPONSIVE_PRIORITY_LOW, add the tableresponsive behaviors. + if (count($header) && $responsive) { + drupal_add_library('core', 'drupal.tableresponsive'); + // Add 'responsive-enabled' class to the table to identify it for JS. + // This is needed to target tables constructed by this function. + $attributes['class'][] = 'responsive-enabled'; + } + $output = '\n"; if (isset($caption)) { @@ -1630,7 +1693,8 @@ function theme_table($variables) { */ function theme_mark($variables) { $type = $variables['status']; - if (\Drupal::currentUser()->isAuthenticated()) { + global $user; + if ($user->isAuthenticated()) { if ($type == MARK_NEW) { return ' ' . t('new') . ''; } @@ -1760,16 +1824,20 @@ function theme_indentation($variables) { } /** - * Prepares variables for container templates. + * Returns HTML to wrap child elements in a container. * - * Default template: container.html.twig. + * Used for grouped form items. Can also be used as a #theme_wrapper for any + * renderable element, to surround it with a
and add attributes such as + * classes or an HTML id. * - * @param array $variables + * @param $variables * An associative array containing: * - element: An associative array containing the properties of the element. * Properties used: #id, #attributes, #children. + * + * @ingroup themeable */ -function template_preprocess_container(&$variables) { +function theme_container($variables) { $element = $variables['element']; // Ensure #attributes is set. $element += array('#attributes' => array()); @@ -1784,8 +1852,7 @@ function template_preprocess_container(&$variables) { $element['#attributes']['class'][] = 'form-wrapper'; } - $variables['children'] = $element['#children']; - $variables['attributes'] = $element['#attributes']; + return '' . $element['#children'] . '
'; } /** @@ -1905,28 +1972,6 @@ function _template_preprocess_default_variables() { } /** - * #pre_render callback for the html element type. - * - * @param array $element - * A structured array containing the html element type build properties. - * - * @see system_element_info() - */ -function drupal_pre_render_html(array $element) { - // Add favicon. - if (theme_get_setting('features.favicon')) { - $favicon = theme_get_setting('favicon.url'); - $type = theme_get_setting('favicon.mimetype'); - $element['#attached']['drupal_add_html_head_link'][][] = array( - 'rel' => 'shortcut icon', - 'href' => UrlHelper::stripDangerousProtocols($favicon), - 'type' => $type, - ); - } - - return $element; -} -/** * Prepares variables for HTML document templates. * * Default template: html.html.twig. @@ -1975,6 +2020,18 @@ function template_preprocess_html(&$variables) { $variables['html_attributes']['lang'] = $language_interface->id; $variables['html_attributes']['dir'] = $language_interface->direction ? 'rtl' : 'ltr'; + // Add favicon. + if (theme_get_setting('features.favicon')) { + $favicon = theme_get_setting('favicon.url'); + $type = theme_get_setting('favicon.mimetype'); + $build['#attached']['drupal_add_html_head_link'][][] = array( + 'rel' => 'shortcut icon', + 'href' => UrlHelper::stripDangerousProtocols($favicon), + 'type' => $type, + ); + drupal_render($build); + } + $site_config = \Drupal::config('system.site'); // Construct page title. if ($page->hasTitle()) { @@ -1983,6 +2040,12 @@ function template_preprocess_html(&$variables) { 'name' => String::checkPlain($site_config->get('name')), ); } + elseif (drupal_get_title()) { + $head_title = array( + 'title' => strip_tags(drupal_get_title()), + 'name' => String::checkPlain($site_config->get('name')), + ); + } // @todo Remove once views is not bypassing the view subscriber anymore. // @see http://drupal.org/node/2068471 elseif (drupal_is_front_page()) { @@ -2029,6 +2092,8 @@ function template_preprocess_html(&$variables) { drupal_add_html_head($element, $name); } + drupal_add_library('core', 'html5shiv', TRUE); + $variables['page_top'][] = array('#markup' => $page->getBodyTop()); $variables['page_bottom'][] = array('#markup' => $page->getBodyBottom()); @@ -2055,6 +2120,9 @@ function template_preprocess_html(&$variables) { * Uses the arg() function to generate a series of page template suggestions * based on the current path. * + * Any changes to variables in this preprocessor should also be changed inside + * template_preprocess_maintenance_page() to keep all of them consistent. + * * @see drupal_render_page() */ function template_preprocess_page(&$variables) { @@ -2063,7 +2131,6 @@ function template_preprocess_page(&$variables) { // Move some variables to the top level for themer convenience and template cleanliness. $variables['show_messages'] = $variables['page']['#show_messages']; - $variables['title'] = $variables['page']['#title']; foreach (system_region_list($GLOBALS['theme']) as $region_key => $region_name) { if (!isset($variables['page'][$region_key])) { @@ -2093,6 +2160,13 @@ function template_preprocess_page(&$variables) { $variables['site_slogan'] = (theme_get_setting('features.slogan') ? filter_xss_admin($site_config->get('slogan')) : ''); $variables['tabs'] = menu_local_tabs(); + if (isset($variables['page']['#title'])) { + $variables['title'] = $variables['page']['#title']; + } + else { + $variables['title'] = new RenderWrapper('drupal_get_title'); + } + // Pass the main menu and secondary menu to the template as render arrays. if (!empty($variables['main_menu'])) { $variables['main_menu'] = array( @@ -2277,6 +2351,12 @@ function template_preprocess_maintenance_page(&$variables) { 'name' => String::checkPlain($site_config->get('name')), ); } + elseif (drupal_get_title()) { + $head_title = array( + 'title' => strip_tags(drupal_get_title()), + 'name' => String::checkPlain($site_config->get('name')), + ); + } else { $head_title = array('name' => String::checkPlain($site_name)); if ($site_slogan) { @@ -2286,8 +2366,8 @@ function template_preprocess_maintenance_page(&$variables) { // These are usually added from system_page_build() except maintenance.css. // When the database is inactive it's not called so we add it here. - $default_css['library'][] = 'core/normalize'; - $default_css['library'][] = 'system/maintenance'; + $default_css['library'][] = array('core', 'normalize'); + $default_css['library'][] = array('system', 'maintenance'); $attached = array('#attached' => $default_css); drupal_render($attached); $variables['messages'] = array( @@ -2297,12 +2377,19 @@ function template_preprocess_maintenance_page(&$variables) { $variables['head_title_array'] = $head_title; $variables['head_title'] = implode(' | ', $head_title); + $variables['base_path'] = base_path(); $variables['front_page'] = url(); + $variables['breadcrumb'] = ''; + $variables['feed_icons'] = ''; $variables['help'] = ''; $variables['language'] = $language_interface; + $variables['language']->dir = $language_interface->direction ? 'rtl' : 'ltr'; $variables['logo'] = theme_get_setting('logo.url'); + $variables['main_menu'] = array(); + $variables['secondary_menu'] = array(); $variables['site_name'] = (theme_get_setting('features.name') ? String::checkPlain($site_name) : ''); $variables['site_slogan'] = (theme_get_setting('features.slogan') ? filter_xss_admin($site_slogan) : ''); + $variables['tabs'] = ''; // Compile a list of classes that are going to be applied to the body element. $variables['attributes']['class'][] = 'maintenance-page'; @@ -2337,6 +2424,9 @@ function template_preprocess_maintenance_page(&$variables) { if (isset($variables['page']['#title'])) { $variables['title'] = $variables['page']['#title']; } + if (!isset($variables['title'])) { + $variables['title'] = drupal_get_title(); + } } /** @@ -2357,7 +2447,6 @@ function template_preprocess_maintenance_page(&$variables) { */ function template_preprocess_install_page(&$variables) { template_preprocess_maintenance_page($variables); - $variables['attributes']['class'][] = 'install-page'; // Override the site name that is displayed on the page, since Drupal is // still in the process of being installed. $variables['site_name'] = drupal_install_profile_distribution_name(); @@ -2472,7 +2561,7 @@ function drupal_common_theme() { 'template' => 'maintenance-page', ), 'install_page' => array( - 'variables' => array('content' => NULL, 'show_messages' => TRUE, 'page' => array()), + 'variables' => array('content' => NULL, 'show_messages' => TRUE), 'template' => 'install-page', ), 'task_list' => array( @@ -2511,11 +2600,9 @@ function drupal_common_theme() { ), 'select' => array( 'render element' => 'element', - 'template' => 'select', ), 'fieldset' => array( 'render element' => 'element', - 'template' => 'fieldset', ), 'details' => array( 'render element' => 'element', @@ -2532,7 +2619,6 @@ function drupal_common_theme() { ), 'form' => array( 'render element' => 'element', - 'template' => 'form', ), 'textarea' => array( 'render element' => 'element', @@ -2557,7 +2643,6 @@ function drupal_common_theme() { ), 'container' => array( 'render element' => 'element', - 'template' => 'container', ), ); } diff --git a/core/includes/update.inc b/core/includes/update.inc index 0bca244..fc1e0af 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -147,6 +147,7 @@ function update_check_requirements($skip_warnings = FALSE) { // them if the caller has indicated they should be skipped. if ($severity == REQUIREMENT_ERROR || ($severity == REQUIREMENT_WARNING && !$skip_warnings)) { update_task_list('requirements'); + drupal_set_title('Requirements problem'); $status = array( '#theme' => 'status_report', '#requirements' => $requirements, @@ -156,7 +157,6 @@ function update_check_requirements($skip_warnings = FALSE) { drupal_add_http_header('Content-Type', 'text/html; charset=utf-8'); $maintenance_page = array( '#theme' => 'maintenance_page', - '#title' => 'Requirements problem', '#content' => $status_report, ); print drupal_render($maintenance_page); diff --git a/core/lib/Drupal.php b/core/lib/Drupal.php index a646096..988a40b 100644 --- a/core/lib/Drupal.php +++ b/core/lib/Drupal.php @@ -102,11 +102,9 @@ class Drupal { * Sets a new global container. * * @param \Symfony\Component\DependencyInjection\ContainerInterface $container - * A new container instance to replace the current. NULL may be passed by - * testing frameworks to ensure that the global state of a previous - * environment does not leak into a test. + * A new container instance to replace the current. */ - public static function setContainer(ContainerInterface $container = NULL) { + public static function setContainer(ContainerInterface $container) { static::$container = $container; } diff --git a/core/lib/Drupal/Component/Plugin/Derivative/DerivativeBase.php b/core/lib/Drupal/Component/Plugin/Derivative/DerivativeBase.php index 3adc150..2c5e2d2 100644 --- a/core/lib/Drupal/Component/Plugin/Derivative/DerivativeBase.php +++ b/core/lib/Drupal/Component/Plugin/Derivative/DerivativeBase.php @@ -27,7 +27,7 @@ /** * {@inheritdoc} */ - public function getDerivativeDefinition($derivative_id, $base_plugin_definition) { + public function getDerivativeDefinition($derivative_id, array $base_plugin_definition) { if (!empty($this->derivatives) && !empty($this->derivatives[$derivative_id])) { return $this->derivatives[$derivative_id]; } @@ -38,7 +38,7 @@ public function getDerivativeDefinition($derivative_id, $base_plugin_definition) /** * {@inheritdoc} */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { return $this->derivatives; } } diff --git a/core/lib/Drupal/Component/Plugin/Derivative/DerivativeInterface.php b/core/lib/Drupal/Component/Plugin/Derivative/DerivativeInterface.php index b32438f..bb07069 100644 --- a/core/lib/Drupal/Component/Plugin/Derivative/DerivativeInterface.php +++ b/core/lib/Drupal/Component/Plugin/Derivative/DerivativeInterface.php @@ -18,17 +18,16 @@ * @param string $derivative_id * The derivative id. The id must uniquely identify the derivative within a * given base plugin, but derivative ids can be reused across base plugins. - * @param mixed $base_plugin_definition - * The definition of the base plugin from which the derivative plugin - * is derived. It is maybe an entire object or just some array, depending - * on the discovery mechanism. + * @param array $base_plugin_definition + * The definition array of the base plugin from which the derivative plugin + * is derived. * * @return array * The full definition array of the derivative plugin, typically a merge of * $base_plugin_definition with extra derivative-specific information. NULL * if the derivative doesn't exist. */ - public function getDerivativeDefinition($derivative_id, $base_plugin_definition); + public function getDerivativeDefinition($derivative_id, array $base_plugin_definition); /** * Returns the definition of all derivatives of a base plugin. @@ -40,6 +39,6 @@ public function getDerivativeDefinition($derivative_id, $base_plugin_definition) * * @see getDerivativeDefinition() */ - public function getDerivativeDefinitions($base_plugin_definition); + public function getDerivativeDefinitions(array $base_plugin_definition); } diff --git a/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php b/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php index 4c8feb0..027c59a 100644 --- a/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php +++ b/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php @@ -155,17 +155,17 @@ protected function encodePluginId($base_plugin_id, $derivative_id) { * * @param string $base_plugin_id * The base plugin id of the plugin. - * @param mixed $base_definition + * @param array $base_definition * The base plugin definition to build derivatives. * * @return \Drupal\Component\Plugin\Derivative\DerivativeInterface|null - * A DerivativeInterface or NULL if none exists for the plugin. - * - * @throws \Drupal\Component\Plugin\Exception\InvalidDerivativeClassException - * Thrown if the 'derivative' class specified in the plugin definition does - * not implement \Drupal\Component\Plugin\Derivative\DerivativeInterface. ++ * A DerivativeInterface or NULL if none exists for the plugin. ++ * ++ * @throws \Drupal\Component\Plugin\Exception\InvalidDerivativeClassException ++ * Thrown if the 'derivative' class specified in the plugin definition does ++ * not implement \Drupal\Component\Plugin\Derivative\DerivativeInterface. */ - protected function getDerivativeFetcher($base_plugin_id, $base_definition) { + protected function getDerivativeFetcher($base_plugin_id, array $base_definition) { if (!isset($this->derivativeFetchers[$base_plugin_id])) { $this->derivativeFetchers[$base_plugin_id] = FALSE; $class = $this->getDerivativeClass($base_definition); @@ -191,7 +191,8 @@ protected function getDerivativeFetcher($base_plugin_id, $base_definition) { */ protected function getDerivativeClass($base_definition) { $class = NULL; - if ((is_array($base_definition) || ($base_definition = (array) $base_definition)) && (isset($base_definition['derivative']) && $class = $base_definition['derivative'])) { + if (isset($base_definition['derivative'])) { + $class = $base_definition['derivative']; if (!is_subclass_of($class, '\Drupal\Component\Plugin\Derivative\DerivativeInterface')) { throw new InvalidDerivativeClassException(sprintf('Plugin (%s) derivative class "%s" has to implement interface \Drupal\Component\Plugin\Derivative\DerivativeInterface', $base_definition['id'], $class)); } diff --git a/core/lib/Drupal/Component/Plugin/PluginBag.php b/core/lib/Drupal/Component/Plugin/PluginBag.php index 9631e22..977cab2 100644 --- a/core/lib/Drupal/Component/Plugin/PluginBag.php +++ b/core/lib/Drupal/Component/Plugin/PluginBag.php @@ -115,10 +115,8 @@ public function remove($instance_id) { * * @param string $id * The ID of the plugin instance to add. - * @param array|null $configuration - * (optional) The configuration used by this instance. Defaults to NULL. */ - public function addInstanceId($id, $configuration = NULL) { + public function addInstanceId($id) { if (!isset($this->instanceIDs[$id])) { $this->instanceIDs[$id] = $id; } @@ -135,10 +133,20 @@ public function getInstanceIds() { } /** + * Sets all instance IDs. + * + * @param array $instance_ids + * An associative array of instance IDs. + */ + public function setInstanceIds(array $instance_ids) { + $this->instanceIDs = $instance_ids; + } + + /** * Removes an instance ID. * * @param string $instance_id - * The ID of the plugin instance to remove. + * An image effect instance IDs. */ public function removeInstanceId($instance_id) { unset($this->instanceIDs[$instance_id]); diff --git a/core/lib/Drupal/Component/Utility/Xss.php b/core/lib/Drupal/Component/Utility/Xss.php index df96015..2797d31 100644 --- a/core/lib/Drupal/Component/Utility/Xss.php +++ b/core/lib/Drupal/Component/Utility/Xss.php @@ -70,6 +70,8 @@ public static function filter($string, $html_tags = array('a', 'em', 'strong', ' if (!Unicode::validateUtf8($string)) { return ''; } + // Store the text format. + static::split($html_tags, TRUE, $mode); // Remove NULL characters (ignored by some browsers). $string = str_replace(chr(0), '', $string); // Remove Netscape 4 JS entities. @@ -84,10 +86,7 @@ public static function filter($string, $html_tags = array('a', 'em', 'strong', ' $string = preg_replace('/&#[Xx]0*((?:[0-9A-Fa-f]{2})+;)/', '&#x\1', $string); // Named entities. $string = preg_replace('/&([A-Za-z][A-Za-z0-9]*;)/', '&\1', $string); - $html_tags = array_flip($html_tags); - $splitter = function ($matches) use ($html_tags, $mode) { - return static::split($matches[1], $html_tags, $mode); - }; + return preg_replace_callback('% ( <(?=[^a-zA-Z!/]) # a lone < @@ -97,7 +96,7 @@ public static function filter($string, $html_tags = array('a', 'em', 'strong', ' <[^>]*(>|$) # a string that starts with a <, up until the > or the end of the string | # or > # just a > - )%x', $splitter, $string); + )%x', 'static::split', $string); } /** @@ -124,20 +123,32 @@ public static function filterAdmin($string) { /** * Processes an HTML tag. * - * @param string $string - * The HTML tag to process. - * @param array $html_tags - * An array where the keys are the allowed tags and the values are not - * used. - * @param bool $split_mode - * Whether $html_tags is a list of allowed (if FILTER_MODE_WHITELIST) or + * @param array $matches + * An array with various meaning depending on the value of $store. + * If $store is TRUE then the array contains the allowed tags. + * If $store is FALSE then the array has one element, the HTML tag to process. + * @param bool $store + * Whether to store $matches. + * @param bool $mode + * (optional) Ignored when $store is FALSE, otherwise used to determine + * whether $matches is a list of allowed (if FILTER_MODE_WHITELIST) or * disallowed (if FILTER_MODE_BLACKLIST) HTML tags. * * @return string * If the element isn't allowed, an empty string. Otherwise, the cleaned up * version of the HTML element. */ - protected static function split($string, $html_tags, $split_mode) { + protected static function split($matches, $store = FALSE, $mode = Xss::FILTER_MODE_WHITELIST) { + static $html_tags, $split_mode; + + if ($store) { + $html_tags = array_flip($matches); + $split_mode = $mode; + return; + } + + $string = $matches[1]; + if (substr($string, 0, 1) != '<') { // We matched a lone ">" character. return '>'; diff --git a/core/lib/Drupal/Core/Ajax/AjaxSubscriber.php b/core/lib/Drupal/Core/Ajax/AjaxSubscriber.php index f298d88..595d64e 100644 --- a/core/lib/Drupal/Core/Ajax/AjaxSubscriber.php +++ b/core/lib/Drupal/Core/Ajax/AjaxSubscriber.php @@ -14,7 +14,7 @@ /** * Subscribes to the kernel request event to add the Ajax media type. * - * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event + * @param \Symfont\Component\HttpKernel\Event\GetResponseEvent $event * The event to process. */ class AjaxSubscriber implements EventSubscriberInterface { diff --git a/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php b/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php index 4b42bf7..3742843 100644 --- a/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php +++ b/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php @@ -124,7 +124,7 @@ public function setDialogTitle($title) { */ public function render() { // Add the library for handling the dialog in the response. - $this->drupalAttachLibrary('core/drupal.dialog.ajax'); + drupal_add_library('core', 'drupal.dialog.ajax'); // For consistency ensure the modal option is set to TRUE or FALSE. $this->dialogOptions['modal'] = isset($this->dialogOptions['modal']) && $this->dialogOptions['modal']; @@ -136,19 +136,4 @@ public function render() { 'dialogOptions' => $this->dialogOptions, ); } - - /** - * Wraps drupal_render. - * - * @param string $name - * The name of the library. - * - * @todo Remove once drupal_render is converted to autoloadable code. - * @see https://drupal.org/node/2171071 - */ - protected function drupalAttachLibrary($name) { - $attached['#attached']['library'][] = $name; - drupal_render($attached); - } - } diff --git a/core/lib/Drupal/Core/Annotation/Translation.php b/core/lib/Drupal/Core/Annotation/Translation.php index 5726878..ebb2655 100644 --- a/core/lib/Drupal/Core/Annotation/Translation.php +++ b/core/lib/Drupal/Core/Annotation/Translation.php @@ -24,11 +24,6 @@ * Remove spaces after @ in your actual plugin - these are put into this sample * code so that it is not recognized as annotation. * - * To provide replacement values for placeholders, use the "arguments" array: - * @code - * title = @ Translation("Bundle !title", arguments = {"!title" = "Foo"}), - * @endcode - * * It is also possible to provide a context with the text, similar to t(): * @code * title = @ Translation("Bundle", context = "Validation"), @@ -60,35 +55,20 @@ class Translation extends AnnotationBase { protected $translation; /** - * The translation manager. - * - * @var \Drupal\Core\StringTranslation\TranslationInterface - */ - protected $translationManager; - - /** - * Constructs a new class instance. + * Constructs a Translation object. * * Parses values passed into this class through the t() function in Drupal and * handles an optional context for the string. - * - * @param array $values - * Possible array keys: - * - value (required): the string that is to be translated. - * - arguments (optional): an array with placeholder replacements, keyed by - * placeholder. - * - context (optional): a string that describes the context of "value"; */ - public function __construct(array $values) { + public function __construct($values) { $string = $values['value']; - $arguments = isset($values['arguments']) ? $values['arguments'] : array(); $options = array(); if (!empty($values['context'])) { $options = array( 'context' => $values['context'], ); } - $this->translation = $this->getTranslationManager()->translate($string, $arguments, $options); + $this->translation = t($string, array(), $options); } /** @@ -98,18 +78,4 @@ public function get() { return $this->translation; } - /** - * Returns the translation manager. - * - * @return \Drupal\Core\StringTranslation\TranslationInterface - * The translation manager. - */ - protected function getTranslationManager() { - if (!$this->translationManager) { - $this->translationManager = \Drupal::translation(); - } - - return $this->translationManager; - } - } diff --git a/core/lib/Drupal/Core/Authentication/AuthenticationManager.php b/core/lib/Drupal/Core/Authentication/AuthenticationManager.php index 672516a..d3630c4 100644 --- a/core/lib/Drupal/Core/Authentication/AuthenticationManager.php +++ b/core/lib/Drupal/Core/Authentication/AuthenticationManager.php @@ -37,7 +37,7 @@ class AuthenticationManager implements AuthenticationProviderInterface, Authenti * * @var array */ - protected $providerOrders = array(); + protected $providerOrders; /** * Sorted list of registered providers. diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php index cafc026..e000200 100644 --- a/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -9,7 +9,9 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\String; +use Drupal\Core\Config\ConfigNameException; use Drupal\Core\Config\Schema\SchemaIncompleteException; +use Drupal\Core\DependencyInjection\DependencySerialization; use Drupal\Core\TypedData\PrimitiveInterface; use Drupal\Core\TypedData\Type\FloatInterface; use Drupal\Core\TypedData\Type\IntegerInterface; @@ -19,7 +21,20 @@ /** * Defines the default configuration object. */ -class Config extends StorableConfigBase { +class Config extends DependencySerialization { + + /** + * The maximum length of a configuration object name. + * + * Many filesystems (including HFS, NTFS, and ext4) have a maximum file name + * length of 255 characters. To ensure that no configuration objects + * incompatible with this limitation are created, we enforce a maximum name + * length of 250 characters (leaving 5 characters for the file extension). + * + * @see http://en.wikipedia.org/wiki/Comparison_of_file_systems + */ + const MAX_NAME_LENGTH = 250; + /** * An event dispatcher instance to use for configuration events. * @@ -30,11 +45,39 @@ class Config extends StorableConfigBase { /** * The language object used to override configuration data. * - * @var \Drupal\Core\Language\Language + * @var Drupal\Core\Language\Language */ protected $language; /** + * The name of the configuration object. + * + * @var string + */ + protected $name; + + /** + * Whether the configuration object is new or has been saved to the storage. + * + * @var bool + */ + protected $isNew = TRUE; + + /** + * The data of the configuration object. + * + * @var array + */ + protected $data = array(); + + /** + * The original data of the configuration object. + * + * @var array + */ + protected $originalData = array(); + + /** * The current runtime data. * * The configuration data from storage merged with language, module and @@ -59,11 +102,25 @@ class Config extends StorableConfigBase { protected $moduleOverrides; /** - * The current settings overrides. + * The storage used to load and save this configuration object. * - * @var array + * @var \Drupal\Core\Config\StorageInterface + */ + protected $storage; + + /** + * The config schema wrapper object for this configuration object. + * + * @var \Drupal\Core\Config\Schema\Element */ - protected $settingsOverrides; + protected $schemaWrapper; + + /** + * The typed config manager. + * + * @var \Drupal\Core\Config\TypedConfigManager + */ + protected $typedConfigManager; /** * Constructs a configuration object. @@ -89,19 +146,111 @@ public function __construct($name, StorageInterface $storage, EventDispatcherInt } /** - * {@inheritdoc} + * Initializes a configuration object with pre-loaded data. + * + * @param array $data + * Array of loaded data for this configuration object. + * + * @return \Drupal\Core\Config\Config + * The configuration object. */ public function initWithData(array $data) { - parent::initWithData($data); $this->settingsOverrides = array(); $this->languageOverrides = array(); $this->moduleOverrides = array(); - $this->setData($data); + $this->isNew = FALSE; + $this->replaceData($data); + $this->originalData = $this->data; return $this; } /** - * {@inheritdoc} + * Returns the name of this configuration object. + * + * @return string + * The name of the configuration object. + */ + public function getName() { + return $this->name; + } + + /** + * Sets the name of this configuration object. + * + * @param string $name + * The name of the configuration object. + * + * @return \Drupal\Core\Config\Config + * The configuration object. + */ + public function setName($name) { + $this->name = $name; + return $this; + } + + /** + * Validates the configuration object name. + * + * @param string $name + * The name of the configuration object. + * + * @throws \Drupal\Core\Config\ConfigNameException + * + * @see Config::MAX_NAME_LENGTH + */ + public static function validateName($name) { + // The name must be namespaced by owner. + if (strpos($name, '.') === FALSE) { + throw new ConfigNameException(format_string('Missing namespace in Config object name @name.', array( + '@name' => $name, + ))); + } + // The name must be shorter than Config::MAX_NAME_LENGTH characters. + if (strlen($name) > self::MAX_NAME_LENGTH) { + throw new ConfigNameException(format_string('Config object name @name exceeds maximum allowed length of @length characters.', array( + '@name' => $name, + '@length' => self::MAX_NAME_LENGTH, + ))); + } + + // The name must not contain any of the following characters: + // : ? * < > " ' / \ + if (preg_match('/[:?*<>"\'\/\\\\]/', $name)) { + throw new ConfigNameException(format_string('Invalid character in Config object name @name.', array( + '@name' => $name, + ))); + } + } + + /** + * Returns whether this configuration object is new. + * + * @return bool + * TRUE if this configuration object does not exist in storage. + */ + public function isNew() { + return $this->isNew; + } + + /** + * Gets data from this configuration object. + * + * @param string $key + * A string that maps to a key within the configuration data. + * For instance in the following configuration array: + * @code + * array( + * 'foo' => array( + * 'bar' => 'baz', + * ), + * ); + * @endcode + * A key of 'foo.bar' would return the string 'baz'. However, a key of 'foo' + * would return array('bar' => 'baz'). + * If no key is specified, then the entire data array is returned. + * + * @return mixed + * The data that was requested. */ public function get($key = '') { if (!isset($this->overriddenData)) { @@ -123,9 +272,33 @@ public function get($key = '') { } /** - * {@inheritdoc} + * Replaces the data of this configuration object. + * + * @param array $data + * The new configuration data. + * + * @return \Drupal\Core\Config\Config + * The configuration object. */ public function setData(array $data) { + $this->replaceData($data); + return $this; + } + + /** + * Replaces the data of this configuration object. + * + * This function is separate from setData() to avoid load() state tracking. + * A load() would destroy the replaced data (for example on import). Do not + * call set() when inside load(). + * + * @param array $data + * The new configuration data. + * + * @return \Drupal\Core\Config\Config + * The configuration object. + */ + protected function replaceData(array $data) { $this->data = $data; $this->resetOverriddenData(); return $this; @@ -218,25 +391,56 @@ protected function resetOverriddenData() { } /** - * {@inheritdoc} + * Sets a value in this configuration object. + * + * @param string $key + * Identifier to store value in configuration. + * @param mixed $value + * Value to associate with identifier. + * + * @return \Drupal\Core\Config\Config + * The configuration object. */ public function set($key, $value) { - parent::set($key, $value); + // The dot/period is a reserved character; it may appear between keys, but + // not within keys. + $parts = explode('.', $key); + if (count($parts) == 1) { + $this->data[$key] = $value; + } + else { + NestedArray::setValue($this->data, $parts, $value); + } $this->resetOverriddenData(); return $this; } /** - * {@inheritdoc} + * Unsets a value in this configuration object. + * + * @param string $key + * Name of the key whose value should be unset. + * + * @return \Drupal\Core\Config\Config + * The configuration object. */ public function clear($key) { - parent::clear($key); + $parts = explode('.', $key); + if (count($parts) == 1) { + unset($this->data[$key]); + } + else { + NestedArray::unsetValue($this->data, $parts); + } $this->resetOverriddenData(); return $this; } /** - * {@inheritdoc} + * Saves the configuration object. + * + * @return \Drupal\Core\Config\Config + * The configuration object. */ public function save() { // Validate the configuration object name before saving. @@ -297,7 +501,7 @@ public function getStorage() { */ public function merge(array $data_to_merge) { // Preserve integer keys so that configuration keys are not changed. - $this->setData(NestedArray::mergeDeepArray(array($this->data, $data_to_merge), TRUE)); + $this->replaceData(NestedArray::mergeDeepArray(array($this->data, $data_to_merge), TRUE)); return $this; } @@ -447,3 +651,4 @@ public function getOriginal($key = '', $apply_overrides = TRUE) { } } } + diff --git a/core/lib/Drupal/Core/Config/ConfigBase.php b/core/lib/Drupal/Core/Config/ConfigBase.php deleted file mode 100644 index 7d12d51..0000000 --- a/core/lib/Drupal/Core/Config/ConfigBase.php +++ /dev/null @@ -1,209 +0,0 @@ -name; - } - - /** - * Sets the name of this configuration object. - * - * @param string $name - * The name of the configuration object. - * - * @return $this - * The configuration object. - */ - public function setName($name) { - $this->name = $name; - return $this; - } - - /** - * Validates the configuration object name. - * - * @param string $name - * The name of the configuration object. - * - * @throws \Drupal\Core\Config\ConfigNameException - * - * @see Config::MAX_NAME_LENGTH - */ - public static function validateName($name) { - // The name must be namespaced by owner. - if (strpos($name, '.') === FALSE) { - throw new ConfigNameException(String::format('Missing namespace in Config object name @name.', array( - '@name' => $name, - ))); - } - // The name must be shorter than Config::MAX_NAME_LENGTH characters. - if (strlen($name) > self::MAX_NAME_LENGTH) { - throw new ConfigNameException(String::format('Config object name @name exceeds maximum allowed length of @length characters.', array( - '@name' => $name, - '@length' => self::MAX_NAME_LENGTH, - ))); - } - - // The name must not contain any of the following characters: - // : ? * < > " ' / \ - if (preg_match('/[:?*<>"\'\/\\\\]/', $name)) { - throw new ConfigNameException(String::format('Invalid character in Config object name @name.', array( - '@name' => $name, - ))); - } - } - - /** - * Gets data from this configuration object. - * - * @param string $key - * A string that maps to a key within the configuration data. - * For instance in the following configuration array: - * @code - * array( - * 'foo' => array( - * 'bar' => 'baz', - * ), - * ); - * @endcode - * A key of 'foo.bar' would return the string 'baz'. However, a key of 'foo' - * would return array('bar' => 'baz'). - * If no key is specified, then the entire data array is returned. - * - * @return mixed - * The data that was requested. - */ - public function get($key = '') { - if (empty($key)) { - return $this->data; - } - else { - $parts = explode('.', $key); - if (count($parts) == 1) { - return isset($this->data[$key]) ? $this->data[$key] : NULL; - } - else { - $value = NestedArray::getValue($this->data, $parts, $key_exists); - return $key_exists ? $value : NULL; - } - } - } - - /** - * Replaces the data of this configuration object. - * - * @param array $data - * The new configuration data. - * - * @return $this - * The configuration object. - */ - public function setData(array $data) { - $this->data = $data; - return $this; - } - - /** - * Sets a value in this configuration object. - * - * @param string $key - * Identifier to store value in configuration. - * @param mixed $value - * Value to associate with identifier. - * - * @return $this - * The configuration object. - */ - public function set($key, $value) { - // The dot/period is a reserved character; it may appear between keys, but - // not within keys. - $parts = explode('.', $key); - if (count($parts) == 1) { - $this->data[$key] = $value; - } - else { - NestedArray::setValue($this->data, $parts, $value); - } - return $this; - } - - /** - * Unsets a value in this configuration object. - * - * @param string $key - * Name of the key whose value should be unset. - * - * @return $this - * The configuration object. - */ - public function clear($key) { - $parts = explode('.', $key); - if (count($parts) == 1) { - unset($this->data[$key]); - } - else { - NestedArray::unsetValue($this->data, $parts); - } - return $this; - } - - /** - * Merges data into a configuration object. - * - * @param array $data_to_merge - * An array containing data to merge. - * - * @return $this - * The configuration object. - */ - public function merge(array $data_to_merge) { - return $this->setData(NestedArray::mergeDeepArray(array($this->data, $data_to_merge), TRUE)); - } -} diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index 5033244..87b43f7 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -7,10 +7,9 @@ namespace Drupal\Core\Config\Entity; -use Drupal\Component\Utility\String; use Drupal\Core\Entity\Entity; -use Drupal\Core\Config\ConfigDuplicateUUIDException; use Drupal\Core\Entity\EntityStorageControllerInterface; +use Drupal\Core\Config\ConfigDuplicateUUIDException; /** * Defines a base configuration entity class. @@ -126,8 +125,6 @@ public function set($property_name, $value) { } $this->{$property_name} = $value; - - return $this; } /** @@ -164,8 +161,6 @@ public function status() { */ public function setSyncing($syncing) { $this->isSyncing = $syncing; - - return $this; } /** @@ -179,7 +174,11 @@ public function isSyncing() { * {@inheritdoc} */ public function createDuplicate() { - $duplicate = parent::createDuplicate(); + $duplicate = clone $this; + $duplicate->set($this->getEntityType()->getKey('id'), NULL); + + // @todo Inject the UUID service into the Entity class once possible. + $duplicate->set('uuid', \Drupal::service('uuid')->generate()); // Prevent the new duplicate from being misinterpreted as a rename. $duplicate->setOriginalId(NULL); @@ -189,7 +188,7 @@ public function createDuplicate() { /** * Helper callback for uasort() to sort configuration entities by weight and label. */ - public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) { + public static function sort($a, $b) { $a_weight = isset($a->weight) ? $a->weight : 0; $b_weight = isset($b->weight) ? $b->weight : 0; if ($a_weight == $b_weight) { @@ -236,14 +235,14 @@ public function preSave(EntityStorageControllerInterface $storage_controller) { ->execute(); $matched_entity = reset($matching_entities); if (!empty($matched_entity) && ($matched_entity != $this->id())) { - throw new ConfigDuplicateUUIDException(String::format('Attempt to save a configuration entity %id with UUID %uuid when this UUID is already used for %matched', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%matched' => $matched_entity))); + throw new ConfigDuplicateUUIDException(format_string('Attempt to save a configuration entity %id with UUID %uuid when this UUID is already used for %matched', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%matched' => $matched_entity))); } if (!$this->isNew()) { $original = $storage_controller->loadUnchanged($this->id()); // Ensure that the UUID cannot be changed for an existing entity. if ($original && ($original->uuid() != $this->uuid())) { - throw new ConfigDuplicateUUIDException(String::format('Attempt to save a configuration entity %id with UUID %uuid when this entity already exists with UUID %original_uuid', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%original_uuid' => $original->uuid()))); + throw new ConfigDuplicateUUIDException(format_string('Attempt to save a configuration entity %id with UUID %uuid when this entity already exists with UUID %original_uuid', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%original_uuid' => $original->uuid()))); } } } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php index 1f1c715..5aa737d 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php @@ -28,21 +28,23 @@ public function getOriginalId(); * @param string $id * The new ID to set as original ID. * - * @return $this + * @return self */ public function setOriginalId($id); /** * Enables the configuration entity. * - * @return $this + * @return \Drupal\Core\Config\Entity\ConfigEntityInterface + * The configuration entity. */ public function enable(); /** * Disables the configuration entity. * - * @return $this + * @return \Drupal\Core\Config\Entity\ConfigEntityInterface + * The configuration entity. */ public function disable(); @@ -52,7 +54,8 @@ public function disable(); * @param bool $status * The status of the configuration entity. * - * @return $this + * @return \Drupal\Core\Config\Entity\ConfigEntityInterface + * The class instance that this method is called on. */ public function setStatus($status); @@ -61,8 +64,6 @@ public function setStatus($status); * * @param bool $status * The status of the sync flag. - * - * @return $this */ public function setSyncing($status); @@ -108,8 +109,6 @@ public function get($property_name); * The name of the property that should be set. * @param mixed $value * The value the property should be set to. - * - * @return $this */ public function set($property_name, $value); diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php index 9a61693..e8f8088 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php @@ -51,15 +51,6 @@ public function getConfigPrefix() { /** * {@inheritdoc} */ - public function getKeys() { - // Always add a default 'uuid' key. - return array('uuid' => 'uuid') + parent::getKeys(); - } - - - /** - * {@inheritdoc} - */ public function getBaseTable() { return FALSE; } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php index 8a26ec0..a70ad36 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php @@ -66,6 +66,13 @@ class ConfigStorageController extends EntityStorageControllerBase implements Con protected $configStorage; /** + * The entity query factory. + * + * @var \Drupal\Core\Entity\Query\QueryFactory + */ + protected $entityQueryFactory; + + /** * Constructs a ConfigStorageController object. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type @@ -74,10 +81,12 @@ class ConfigStorageController extends EntityStorageControllerBase implements Con * The config factory service. * @param \Drupal\Core\Config\StorageInterface $config_storage * The config storage service. + * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query_factory + * The entity query factory. * @param \Drupal\Component\Uuid\UuidInterface $uuid_service * The UUID service. */ - public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, StorageInterface $config_storage, UuidInterface $uuid_service) { + public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, StorageInterface $config_storage, QueryFactory $entity_query_factory, UuidInterface $uuid_service) { parent::__construct($entity_type); $this->idKey = $this->entityType->getKey('id'); @@ -85,6 +94,7 @@ public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInter $this->configFactory = $config_factory; $this->configStorage = $config_storage; + $this->entityQueryFactory = $entity_query_factory; $this->uuidService = $uuid_service; } @@ -96,6 +106,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI $entity_type, $container->get('config.factory'), $container->get('config.storage'), + $container->get('entity.query'), $container->get('uuid') ); } @@ -164,6 +175,13 @@ public function deleteRevision($revision_id) { /** * {@inheritdoc} */ + public function getQuery($conjunction = 'AND') { + return $this->entityQueryFactory->get($this->entityTypeId, $conjunction); + } + + /** + * {@inheritdoc} + */ public function getConfigPrefix() { return $this->entityType->getConfigPrefix() . '.'; } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageControllerInterface.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageControllerInterface.php index 4ffe876..114fa33 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageControllerInterface.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageControllerInterface.php @@ -31,6 +31,20 @@ public function importCreate($name, Config $new_config, Config $old_config); /** + * Returns an entity query instance. + * + * @param string $conjunction + * - AND: all of the conditions on the query need to match. + * - OR: at least one of the conditions on the query need to match. + * + * @return \Drupal\Core\Entity\Query\QueryInterface + * The query instance. + * + * @see \Drupal\Core\Entity\EntityStorageControllerInterface::getQueryServicename() + */ + public function getQuery($conjunction = 'AND'); + + /** * Updates configuration upon synchronizing configuration changes. * * This callback is invoked when configuration is synchronized between storages diff --git a/core/lib/Drupal/Core/Config/InstallStorage.php b/core/lib/Drupal/Core/Config/InstallStorage.php index eba7541..83f7322 100644 --- a/core/lib/Drupal/Core/Config/InstallStorage.php +++ b/core/lib/Drupal/Core/Config/InstallStorage.php @@ -12,13 +12,7 @@ /** * Storage controller used by the Drupal installer. * - * This storage performs a full filesystem scan to discover all available - * extensions and reads from all default config directories that exist. - * - * This special implementation MUST NOT be used anywhere else than the early - * installer environment. - * - * @see \Drupal\Core\DependencyInjection\InstallServiceProvider + * @see install_begin_request() */ class InstallStorage extends FileStorage { diff --git a/core/lib/Drupal/Core/Config/StorableConfigBase.php b/core/lib/Drupal/Core/Config/StorableConfigBase.php deleted file mode 100644 index 8b05f95..0000000 --- a/core/lib/Drupal/Core/Config/StorableConfigBase.php +++ /dev/null @@ -1,185 +0,0 @@ -isNew = FALSE; - $this->setData($data); - $this->originalData = $this->data; - return $this; - } - - /** - * Returns whether this configuration object is new. - * - * @return bool - * TRUE if this configuration object does not exist in storage. - */ - public function isNew() { - return $this->isNew; - } - - /** - * Retrieves the storage used to load and save this configuration object. - * - * @return \Drupal\Core\Config\StorageInterface - * The configuration storage object. - */ - public function getStorage() { - return $this->storage; - } - - /** - * Gets the schema wrapper for the whole configuration object. - * - * The schema wrapper is dependent on the configuration name and the whole - * data structure, so if the name or the data changes in any way, the wrapper - * should be reset. - * - * @return \Drupal\Core\Config\Schema\Element - */ - protected function getSchemaWrapper() { - if (!isset($this->schemaWrapper)) { - $definition = $this->typedConfigManager->getDefinition($this->name); - $this->schemaWrapper = $this->typedConfigManager->create($definition, $this->data); - } - return $this->schemaWrapper; - } - - /** - * Casts the value to correct data type using the configuration schema. - * - * @param string $key - * A string that maps to a key within the configuration data. - * @param string $value - * Value to associate with the key. - * - * @return mixed - * The value cast to the type indicated in the schema. - * - * @throws \Drupal\Core\Config\UnsupportedDataTypeConfigException - * Exception on unsupported/undefined data type deducted. - */ - protected function castValue($key, $value) { - if ($value === NULL) { - $value = NULL; - } - elseif (is_scalar($value)) { - try { - $element = $this->getSchemaWrapper()->get($key); - if ($element instanceof PrimitiveInterface) { - // Special handling for integers and floats since the configuration - // system is primarily concerned with saving values from the Form API - // we have to special case the meaning of an empty string for numeric - // types. In PHP this would be casted to a 0 but for the purposes of - // configuration we need to treat this as a NULL. - if ($value === '' && ($element instanceof IntegerInterface || $element instanceof FloatInterface)) { - $value = NULL; - } - else { - $value = $element->getCastedValue(); - } - } - else { - // Config only supports primitive data types. If the config schema - // does define a type $element will be an instance of - // \Drupal\Core\Config\Schema\Property. Convert it to string since it - // is the safest possible type. - $value = $element->getString(); - } - } - catch (SchemaIncompleteException $e) { - // @todo throw an exception due to an incomplete schema. - // Fix as part of https://drupal.org/node/2183983. - } - } - else { - // Throw exception on any non-scalar or non-array value. - if (!is_array($value)) { - throw new UnsupportedDataTypeConfigException(String::format('Invalid data type for config element @name:@key', array( - '@name' => $this->getName(), - '@key' => $key, - ))); - } - // Recurse into any nested keys. - foreach ($value as $nested_value_key => $nested_value) { - $value[$nested_value_key] = $this->castValue($key . '.' . $nested_value_key, $nested_value); - } - } - return $value; - } - -} diff --git a/core/lib/Drupal/Core/Controller/DialogController.php b/core/lib/Drupal/Core/Controller/DialogController.php index e86b9bd..5fda730 100644 --- a/core/lib/Drupal/Core/Controller/DialogController.php +++ b/core/lib/Drupal/Core/Controller/DialogController.php @@ -93,7 +93,14 @@ public function dialog(Request $request, $_content, $modal = FALSE) { } $content = drupal_render($page_content); - $title = $this->titleResolver->getTitle($request, $request->attributes->get(RouteObjectInterface::ROUTE_OBJECT)); + + // @todo Remove use of drupal_get_title() when + // http://drupal.org/node/1871596 is in. + if (!$title = $this->titleResolver->getTitle($request, $request->attributes->get(RouteObjectInterface::ROUTE_OBJECT))) { + // @todo Remove use of drupal_get_title() when + // http://drupal.org/node/1871596 is in. + $title = drupal_get_title(); + } $response = new AjaxResponse(); // Fetch any modal options passed in from data-dialog-options. if (!($options = $request->request->get('dialogOptions'))) { diff --git a/core/lib/Drupal/Core/Controller/HtmlControllerBase.php b/core/lib/Drupal/Core/Controller/HtmlControllerBase.php index 9cc7651..0204bc0 100644 --- a/core/lib/Drupal/Core/Controller/HtmlControllerBase.php +++ b/core/lib/Drupal/Core/Controller/HtmlControllerBase.php @@ -80,7 +80,7 @@ protected function createHtmlFragment($page_content, Request $request) { $fragment->setTitle($page_content['#title'], Title::FILTER_XSS_ADMIN); } else if ($route = $request->attributes->get(RouteObjectInterface::ROUTE_OBJECT)) { - $fragment->setTitle($this->titleResolver->getTitle($request, $route), Title::PASS_THROUGH); + $fragment->setTitle($this->titleResolver->getTitle($request, $route), PASS_THROUGH); } return $fragment; diff --git a/core/lib/Drupal/Core/CoreServiceProvider.php b/core/lib/Drupal/Core/CoreServiceProvider.php index 847960c..8f4f66c 100644 --- a/core/lib/Drupal/Core/CoreServiceProvider.php +++ b/core/lib/Drupal/Core/CoreServiceProvider.php @@ -51,6 +51,7 @@ public function register(ContainerBuilder $container) { // during a subrequest). $container->addScope(new Scope('request')); $this->registerTwig($container); + $this->registerModuleHandler($container); $this->registerUuid($container); // Add the compiler pass that lets service providers modify existing @@ -85,6 +86,27 @@ public function register(ContainerBuilder $container) { } /** + * Registers the module handler. + * + * As this is different during install, it needs to stay in PHP. + */ + protected function registerModuleHandler(ContainerBuilder $container) { + // The ModuleHandler manages enabled modules and provides the ability to + // invoke hooks in all enabled modules. + if ($container->getParameter('kernel.environment') == 'install') { + // During installation we use the non-cached version. + $container->register('module_handler', 'Drupal\Core\Extension\ModuleHandler') + ->addArgument('%container.modules%'); + } + else { + $container->register('module_handler', 'Drupal\Core\Extension\CachedModuleHandler') + ->addArgument('%container.modules%') + ->addArgument(new Reference('state')) + ->addArgument(new Reference('cache.bootstrap')); + } + } + + /** * Registers Twig services. * * This method is public and static so that it can be reused in the installer. @@ -103,6 +125,7 @@ public static function registerTwig(ContainerBuilder $container) { // When in the installer, twig_cache must be FALSE until we know the // files folder is writable. 'cache' => drupal_installation_attempted() ? FALSE : settings()->get('twig_cache', TRUE), + 'base_template_class' => 'Drupal\Core\Template\TwigTemplate', // @todo Remove in followup issue // @see http://drupal.org/node/1712444. 'autoescape' => FALSE, diff --git a/core/lib/Drupal/Core/Database/Query/Query.php b/core/lib/Drupal/Core/Database/Query/Query.php index 790ed5c..ad1f75e 100644 --- a/core/lib/Drupal/Core/Database/Query/Query.php +++ b/core/lib/Drupal/Core/Database/Query/Query.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\Core\Database\Query\Query. + * Definition of Drupal\Core\Database\Query\Query */ namespace Drupal\Core\Database\Query; @@ -106,9 +106,6 @@ public function __clone() { /** * Runs the query against the database. - * - * @return \Drupal\Core\Database\StatementInterface|null - * A prepared statement, or NULL if the query is not valid. */ abstract protected function execute(); @@ -118,7 +115,7 @@ public function __clone() { * The toString operation is how we compile a query object to a prepared * statement. * - * @return string + * @return * A prepared statement query string for this object. */ abstract public function __toString(); @@ -134,7 +131,7 @@ public function uniqueIdentifier() { * Gets the next placeholder value for this query object. * * @return int - * The next placeholder value. + * Next placeholder value. */ public function nextPlaceholder() { return $this->nextPlaceholder++; @@ -154,7 +151,8 @@ public function nextPlaceholder() { * @param $comment * The comment string to be inserted into the query. * - * @return $this + * @return \Drupal\Core\Database\Query\Query + * The called object. */ public function comment($comment) { $this->comments[] = $comment; @@ -173,7 +171,7 @@ public function comment($comment) { * $comments =& $query->getComments(); * @endcode * - * @return array + * @return * A reference to the comments array structure. */ public function &getComments() { diff --git a/core/lib/Drupal/Core/Database/Query/Select.php b/core/lib/Drupal/Core/Database/Query/Select.php index 54a3555..2498ed0 100644 --- a/core/lib/Drupal/Core/Database/Query/Select.php +++ b/core/lib/Drupal/Core/Database/Query/Select.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\Core\Database\Query\Select. + * Definition of Drupal\Core\Database\Query\Select */ namespace Drupal\Core\Database\Query; @@ -121,18 +121,6 @@ class Select extends Query implements SelectInterface { */ protected $forUpdate = FALSE; - /** - * Constructs a Select object. - * - * @param string $table - * The name of the table that is being queried. - * @param string $alias - * The alias for the table. - * @param \Drupal\Core\Database\Connection $connection - * Database connection object. - * @param array $options - * Array of query options. - */ public function __construct($table, $alias = NULL, Connection $connection, $options = array()) { $options['return'] = Database::RETURN_STATEMENT; parent::__construct($connection, $options); @@ -142,68 +130,45 @@ public function __construct($table, $alias = NULL, Connection $connection, $opti $this->addJoin(NULL, $table, $alias); } - /** - * {@inheritdoc} - */ + /* Implementations of Drupal\Core\Database\Query\AlterableInterface. */ + public function addTag($tag) { $this->alterTags[$tag] = 1; return $this; } - /** - * {@inheritdoc} - */ public function hasTag($tag) { return isset($this->alterTags[$tag]); } - /** - * {@inheritdoc} - */ public function hasAllTags() { return !(boolean)array_diff(func_get_args(), array_keys($this->alterTags)); } - /** - * {@inheritdoc} - */ public function hasAnyTag() { return (boolean)array_intersect(func_get_args(), array_keys($this->alterTags)); } - /** - * {@inheritdoc} - */ public function addMetaData($key, $object) { $this->alterMetaData[$key] = $object; return $this; } - /** - * {@inheritdoc} - */ public function getMetaData($key) { return isset($this->alterMetaData[$key]) ? $this->alterMetaData[$key] : NULL; } - /** - * {@inheritdoc} - */ + /* Implementations of Drupal\Core\Database\Query\ConditionInterface for the WHERE clause. */ + public function condition($field, $value = NULL, $operator = NULL) { $this->where->condition($field, $value, $operator); return $this; } - /** - * {@inheritdoc} - */ public function &conditions() { return $this->where->conditions(); } - /** - * {@inheritdoc} - */ public function arguments() { if (!$this->compiled()) { return NULL; @@ -236,49 +201,31 @@ public function arguments() { return $args; } - /** - * {@inheritdoc} - */ public function where($snippet, $args = array()) { $this->where->where($snippet, $args); return $this; } - /** - * {@inheritdoc} - */ public function isNull($field) { $this->where->isNull($field); return $this; } - /** - * {@inheritdoc} - */ public function isNotNull($field) { $this->where->isNotNull($field); return $this; } - /** - * {@inheritdoc} - */ public function exists(SelectInterface $select) { $this->where->exists($select); return $this; } - /** - * {@inheritdoc} - */ public function notExists(SelectInterface $select) { $this->where->notExists($select); return $this; } - /** - * {@inheritdoc} - */ public function compile(Connection $connection, PlaceholderInterface $queryPlaceholder) { $this->where->compile($connection, $queryPlaceholder); $this->having->compile($connection, $queryPlaceholder); @@ -296,9 +243,6 @@ public function compile(Connection $connection, PlaceholderInterface $queryPlace } } - /** - * {@inheritdoc} - */ public function compiled() { if (!$this->where->compiled() || !$this->having->compiled()) { return FALSE; @@ -322,68 +266,32 @@ public function compiled() { return TRUE; } - /** - * {@inheritdoc} - */ + /* Implementations of Drupal\Core\Database\Query\ConditionInterface for the HAVING clause. */ + public function havingCondition($field, $value = NULL, $operator = NULL) { $this->having->condition($field, $value, $operator); return $this; } - /** - * Gets a list of all conditions in the HAVING clause. - * - * This method returns by reference. That allows alter hooks to access the - * data structure directly and manipulate it before it gets compiled. - * - * @return array - * An array of conditions. - * - * @see \Drupal\Core\Database\Query\ConditionInterface::conditions() - */ public function &havingConditions() { return $this->having->conditions(); } - /** - * Gets a list of all values to insert into the HAVING clause. - * - * @return array - * An associative array of placeholders and values. - */ public function havingArguments() { return $this->having->arguments(); } - /** - * Adds an arbitrary HAVING clause to the query. - * - * @param $snippet - * A portion of a HAVING clause as a prepared statement. It must use named - * placeholders, not ? placeholders. - * @param $args - * (optional) An associative array of arguments. - * - * @return $this - */ public function having($snippet, $args = array()) { $this->having->where($snippet, $args); return $this; } - /** - * Compiles the HAVING clause for later retrieval. - * - * @param $connection - * The database connection for which to compile the clause. - */ public function havingCompile(Connection $connection) { - $this->having->compile($connection, $this); + return $this->having->compile($connection, $this); } - /** - * {@inheritdoc} - */ + /* Implementations of Drupal\Core\Database\Query\ExtendableInterface. */ + public function extend($extender_name) { $override_class = $extender_name . '_' . $this->connection->driver(); if (class_exists($override_class)) { @@ -392,61 +300,26 @@ public function extend($extender_name) { return new $extender_name($this, $this->connection); } - /** - * Sets a condition in the HAVING clause that the specified field be NULL. - * - * @param $field - * The name of the field to check. - * - * @return $this - */ public function havingIsNull($field) { $this->having->isNull($field); return $this; } - /** - * Sets a condition in the HAVING clause that the specified field be NOT NULL. - * - * @param $field - * The name of the field to check. - * - * @return $this - */ public function havingIsNotNull($field) { $this->having->isNotNull($field); return $this; } - /** - * Sets a HAVING condition that the specified subquery returns values. - * - * @param \Drupal\Core\Database\Query\SelectInterface $select - * The subquery that must contain results. - * - * @return $this - */ public function havingExists(SelectInterface $select) { $this->having->exists($select); return $this; } - /** - * Sets a HAVING condition that the specified subquery returns no values. - * - * @param \Drupal\Core\Database\Query\SelectInterface $select - * The subquery that must contain results. - * - * @return $this - */ public function havingNotExists(SelectInterface $select) { $this->having->notExists($select); return $this; } - /** - * {@inheritdoc} - */ public function forUpdate($set = TRUE) { if (isset($set)) { $this->forUpdate = $set; @@ -454,51 +327,32 @@ public function forUpdate($set = TRUE) { return $this; } - /** - * {@inheritdoc} - */ + /* Alter accessors to expose the query data to alter hooks. */ + public function &getFields() { return $this->fields; } - /** - * {@inheritdoc} - */ public function &getExpressions() { return $this->expressions; } - /** - * {@inheritdoc} - */ public function &getOrderBy() { return $this->order; } - /** - * {@inheritdoc} - */ public function &getGroupBy() { return $this->group; } - /** - * {@inheritdoc} - */ public function &getTables() { return $this->tables; } - /** - * {@inheritdoc} - */ public function &getUnion() { return $this->union; } - /** - * {@inheritdoc} - */ public function getArguments(PlaceholderInterface $queryPlaceholder = NULL) { if (!isset($queryPlaceholder)) { $queryPlaceholder = $this; @@ -508,14 +362,17 @@ public function getArguments(PlaceholderInterface $queryPlaceholder = NULL) { } /** - * {@inheritdoc} + * Indicates if preExecute() has already been called on that object. */ public function isPrepared() { return $this->prepared; } /** - * {@inheritdoc} + * Generic preparation and validation for a SELECT query. + * + * @return + * TRUE if the validation was successful, FALSE if not. */ public function preExecute(SelectInterface $query = NULL) { // If no query object is passed in, use $this. @@ -553,9 +410,6 @@ public function preExecute(SelectInterface $query = NULL) { return $this->prepared; } - /** - * {@inheritdoc} - */ public function execute() { // If validation fails, simply return NULL. // Note that validation routines in preExecute() may throw exceptions instead. @@ -567,17 +421,11 @@ public function execute() { return $this->connection->query((string) $this, $args, $this->queryOptions); } - /** - * {@inheritdoc} - */ public function distinct($distinct = TRUE) { $this->distinct = $distinct; return $this; } - /** - * {@inheritdoc} - */ public function addField($table_alias, $field, $alias = NULL) { // If no alias is specified, first try the field name itself. if (empty($alias)) { @@ -606,10 +454,8 @@ public function addField($table_alias, $field, $alias = NULL) { return $alias; } - /** - * {@inheritdoc} - */ public function fields($table_alias, array $fields = array()) { + if ($fields) { foreach ($fields as $field) { // We don't care what alias was assigned. @@ -624,9 +470,6 @@ public function fields($table_alias, array $fields = array()) { return $this; } - /** - * {@inheritdoc} - */ public function addExpression($expression, $alias = NULL, $arguments = array()) { if (empty($alias)) { $alias = 'expression'; @@ -648,38 +491,24 @@ public function addExpression($expression, $alias = NULL, $arguments = array()) return $alias; } - /** - * {@inheritdoc} - */ public function join($table, $alias = NULL, $condition = NULL, $arguments = array()) { return $this->addJoin('INNER', $table, $alias, $condition, $arguments); } - /** - * {@inheritdoc} - */ public function innerJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) { return $this->addJoin('INNER', $table, $alias, $condition, $arguments); } - /** - * {@inheritdoc} - */ public function leftJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) { return $this->addJoin('LEFT OUTER', $table, $alias, $condition, $arguments); } - /** - * {@inheritdoc} - */ public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) { return $this->addJoin('RIGHT OUTER', $table, $alias, $condition, $arguments); } - /** - * {@inheritdoc} - */ public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = array()) { + if (empty($alias)) { if ($table instanceof SelectInterface) { $alias = 'subquery'; @@ -711,9 +540,6 @@ public function addJoin($type, $table, $alias = NULL, $condition = NULL, $argume return $alias; } - /** - * {@inheritdoc} - */ public function orderBy($field, $direction = 'ASC') { // Only allow ASC and DESC, default to ASC. $direction = strtoupper($direction) == 'DESC' ? 'DESC' : 'ASC'; @@ -721,26 +547,17 @@ public function orderBy($field, $direction = 'ASC') { return $this; } - /** - * {@inheritdoc} - */ public function orderRandom() { $alias = $this->addExpression('RAND()', 'random_field'); $this->orderBy($alias); return $this; } - /** - * {@inheritdoc} - */ public function range($start = NULL, $length = NULL) { $this->range = func_num_args() ? array('start' => $start, 'length' => $length) : array(); return $this; } - /** - * {@inheritdoc} - */ public function union(SelectInterface $query, $type = '') { // Handle UNION aliasing. switch ($type) { @@ -763,16 +580,13 @@ public function union(SelectInterface $query, $type = '') { return $this; } - /** - * {@inheritdoc} - */ public function groupBy($field) { $this->group[$field] = $field; return $this; } /** - * {@inheritdoc} + * Implements SelectInterface::countQuery(). */ public function countQuery() { $count = $this->prepareCountQuery(); @@ -846,9 +660,6 @@ protected function prepareCountQuery() { return $count; } - /** - * {@inheritdoc} - */ public function __toString() { // For convenience, we compile the query ourselves if the caller forgot // to do it. This allows constructs like "(string) $query" to work. When @@ -968,9 +779,6 @@ public function __toString() { return $query; } - /** - * {@inheritdoc} - */ public function __clone() { // On cloning, also clone the dependent objects. However, we do not // want to clone the database connection object as that would duplicate the diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 4d57e65..a763164 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -9,7 +9,6 @@ use Drupal\Component\PhpStorage\PhpStorageFactory; use Drupal\Core\Config\BootstrapConfigStorageFactory; -use Drupal\Core\Config\NullStorage; use Drupal\Core\CoreServiceProvider; use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\DependencyInjection\ServiceProviderInterface; @@ -206,6 +205,7 @@ public function getContainer() { * {@inheritdoc} */ public function discoverServiceProviders() { + $this->configStorage = BootstrapConfigStorageFactory::get(); $serviceProviders = array( 'CoreServiceProvider' => new CoreServiceProvider(), ); @@ -217,7 +217,7 @@ public function discoverServiceProviders() { // Ensure we know what modules are enabled and that their namespaces are // registered. if (!isset($this->moduleList)) { - $module_list = $this->getConfigStorage()->read('system.module'); + $module_list = $this->configStorage->read('system.module'); $this->moduleList = isset($module_list['enabled']) ? $module_list['enabled'] : array(); } $module_filenames = $this->getModuleFileNames(); @@ -290,8 +290,10 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ * @param $module * The name of the module. * - * @return \Drupal\Core\Extension\Extension|bool - * Returns an Extension object if the module is found, FALSE otherwise. + * @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. */ protected function moduleData($module) { if (!$this->moduleData) { @@ -303,7 +305,7 @@ protected function moduleData($module) { // If a module is within a profile directory but specifies another // profile for testing, it needs to be found in the parent profile. - $settings = $this->getConfigStorage()->read('simpletest.settings'); + $settings = $this->configStorage->read('simpletest.settings'); $parent_profile = !empty($settings['parent_profile']) ? $settings['parent_profile'] : NULL; if ($parent_profile && !isset($profiles[$parent_profile])) { // In case both profile directories contain the same extension, the @@ -372,7 +374,8 @@ protected function initializeContainer() { $this->containerNeedsDumping = FALSE; $persist = $this->getServicesToPersist(); // The request service requires custom persisting logic, since it is also - // potentially scoped. + // potentially scoped. During Drupal installation, there is a request + // service without a request scope. $request_scope = FALSE; if (isset($this->container)) { if ($this->container->isScopeActive('request')) { @@ -522,11 +525,10 @@ protected function buildContainer() { // avoids the circular dependencies that would created by // \Drupal\language\LanguageServiceProvider::alter() and allows the default // language to not be English in the installer. + $system = BootstrapConfigStorageFactory::get()->read('system.site'); $default_language_values = Language::$defaultValues; - if ($system = $this->getConfigStorage()->read('system.site')) { - if ($default_language_values['id'] != $system['langcode']) { - $default_language_values = array('id' => $system['langcode'], 'default' => TRUE); - } + if ($default_language_values['id'] != $system['langcode']) { + $default_language_values = array('id' => $system['langcode'], 'default' => TRUE); } $container->setParameter('language.default_values', $default_language_values); @@ -646,25 +648,6 @@ protected function storage() { } /** - * Returns the active configuration storage to use during building the container. - * - * @return \Drupal\Core\Config\StorageInterface - */ - protected function getConfigStorage() { - if (!isset($this->configStorage)) { - // The active configuration storage may not exist yet; e.g., in the early - // installer. Catch the exception thrown by config_get_config_directory(). - try { - $this->configStorage = BootstrapConfigStorageFactory::get(); - } - catch (\Exception $e) { - $this->configStorage = new NullStorage(); - } - } - return $this->configStorage; - } - - /** * Returns the file name for each enabled module. */ protected function getModuleFileNames() { diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index ba016cb..82e5241 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -129,19 +129,12 @@ protected $isDefaultRevision = TRUE; /** - * The typed data manager. - * - * @var \Drupal\Core\TypedData\TypedDataManager - */ - protected $typedDataManager; - - /** * Overrides Entity::__construct(). */ public function __construct(array $values, $entity_type, $bundle = FALSE, $translations = array()) { $this->entityTypeId = $entity_type; $this->bundle = $bundle ? $bundle : $this->entityTypeId; - $this->languages = $this->languageList(Language::STATE_ALL); + $this->languages = language_list(Language::STATE_ALL); foreach ($values as $key => $value) { // If the key matches an existing property set the value to the property @@ -169,26 +162,6 @@ public function __construct(array $values, $entity_type, $bundle = FALSE, $trans } /** - * Wraps $this->languageList(). - */ - protected function languageList($flags = Language::STATE_CONFIGURABLE) { - return language_list($flags); - } - - /** - * Returns the typed data manager. - * - * @return \Drupal\Core\TypedData\TypedDataManager - */ - protected function typedDataManager() { - if (!$this->typedDataManager) { - $this->typedDataManager = \Drupal::typedDataManager(); - } - - return $this->typedDataManager; - } - - /** * {@inheritdoc} */ public function setNewRevision($value = TRUE) { @@ -224,7 +197,8 @@ public function getRevisionId() { * {@inheritdoc} */ public function isTranslatable() { - $bundles = $this->entityManager()->getBundleInfo($this->entityTypeId); + // @todo Inject the entity manager and retrieve bundle info from it. + $bundles = entity_get_bundles($this->entityTypeId); return !empty($bundles[$this->bundle()]['translatable']); } @@ -265,14 +239,15 @@ public function setValue($value, $notify = TRUE) { * {@inheritdoc} */ public function getString() { - return (string) $this->label(); + return $this->label(); } /** * {@inheritdoc} */ public function validate() { - return $this->typedDataManager()->getValidator()->validate($this); + // @todo: Add the typed data manager as proper dependency. + return \Drupal::typedDataManager()->getValidator()->validate($this); } /** @@ -358,7 +333,10 @@ public function __sleep() { $this->fieldDefinitions = NULL; $this->clearTranslationCache(); - return parent::__sleep(); + // Don't serialize the url generator. + $this->urlGenerator = NULL; + + return array_keys(get_object_vars($this)); } @@ -366,7 +344,6 @@ public function __sleep() { * Magic __wakeup() implementation. */ public function __wakeup() { - parent::__wakeup(); $this->init(); } @@ -416,7 +393,7 @@ public function get($property_name) { protected function getTranslatedField($name, $langcode) { if ($this->translations[$this->activeLangcode]['status'] == static::TRANSLATION_REMOVED) { $message = 'The entity object refers to a removed translation (@langcode) and cannot be manipulated.'; - throw new \InvalidArgumentException(String::format($message, array('@langcode' => $this->activeLangcode))); + throw new \InvalidArgumentException(format_string($message, array('@langcode' => $this->activeLangcode))); } // Populate $this->fields to speed-up further look-ups and to keep track of // fields objects, possibly holding changes to field values. @@ -549,13 +526,13 @@ public function isEmpty() { /** * {@inheritdoc} */ - public function access($operation, AccountInterface $account = NULL) { + public function access($operation = 'view', AccountInterface $account = NULL) { if ($operation == 'create') { - return $this->entityManager() + return \Drupal::entityManager() ->getAccessController($this->entityTypeId) ->createAccess($this->bundle(), $account); } - return $this->entityManager() + return \Drupal::entityManager() ->getAccessController($this->entityTypeId) ->access($this, $operation, $this->activeLangcode, $account); } @@ -567,7 +544,7 @@ public function language() { $language = NULL; if ($this->activeLangcode != Language::LANGCODE_DEFAULT) { if (!isset($this->languages[$this->activeLangcode])) { - $this->languages += $this->languageList(Language::STATE_ALL); + $this->languages += language_list(Language::STATE_ALL); } $language = $this->languages[$this->activeLangcode]; } @@ -617,7 +594,7 @@ public function onChange($name) { if ($name == 'langcode') { $this->setDefaultLangcode(); if (isset($this->translations[$this->defaultLangcode])) { - $message = String::format('A translation already exists for the specified language (@langcode).', array('@langcode' => $this->defaultLangcode)); + $message = format_string('A translation already exists for the specified language (@langcode).', array('@langcode' => $this->defaultLangcode)); throw new \InvalidArgumentException($message); } $this->updateFieldLangcodes($this->defaultLangcode); @@ -666,7 +643,7 @@ public function getTranslation($langcode) { if (empty($translation)) { $message = 'Invalid translation language (@langcode) specified.'; - throw new \InvalidArgumentException(String::format($message, array('@langcode' => $langcode))); + throw new \InvalidArgumentException(format_string($message, array('@langcode' => $langcode))); } return $translation; @@ -731,14 +708,14 @@ public function hasTranslation($langcode) { public function addTranslation($langcode, array $values = array()) { if (!isset($this->languages[$langcode]) || $this->hasTranslation($langcode)) { $message = 'Invalid translation language (@langcode) specified.'; - throw new \InvalidArgumentException(String::format($message, array('@langcode' => $langcode))); + throw new \InvalidArgumentException(format_string($message, array('@langcode' => $langcode))); } // Instantiate a new empty entity so default values will be populated in the // specified language. $entity_type = $this->getEntityType(); $default_values = array($entity_type->getKey('bundle') => $this->bundle, 'langcode' => $langcode); - $entity = $this->entityManager() + $entity = \Drupal::entityManager() ->getStorageController($this->getEntityTypeId()) ->create($default_values); @@ -776,7 +753,7 @@ public function removeTranslation($langcode) { } else { $message = 'The specified translation (@langcode) cannot be removed.'; - throw new \InvalidArgumentException(String::format($message, array('@langcode' => $langcode))); + throw new \InvalidArgumentException(format_string($message, array('@langcode' => $langcode))); } } @@ -918,7 +895,7 @@ public function __unset($name) { public function createDuplicate() { if ($this->translations[$this->activeLangcode]['status'] == static::TRANSLATION_REMOVED) { $message = 'The entity object refers to a removed translation (@langcode) and cannot be manipulated.'; - throw new \InvalidArgumentException(String::format($message, array('@langcode' => $this->activeLangcode))); + throw new \InvalidArgumentException(format_string($message, array('@langcode' => $this->activeLangcode))); } $duplicate = clone $this; @@ -927,7 +904,8 @@ public function createDuplicate() { // Check if the entity type supports UUIDs and generate a new one if so. if ($entity_type->hasKey('uuid')) { - $duplicate->{$entity_type->getKey('uuid')}->value = $this->uuidGenerator()->generate(); + // @todo Inject the UUID service into the Entity class once possible. + $duplicate->{$entity_type->getKey('uuid')}->value = \Drupal::service('uuid')->generate(); } // Check whether the entity type supports revisions and initialize it if so. @@ -975,8 +953,9 @@ public function __clone() { public function label() { $label = NULL; $entity_type = $this->getEntityType(); - if (($label_callback = $entity_type->getLabelCallback()) && is_callable($label_callback)) { - $label = call_user_func($label_callback, $this); + // @todo Convert to is_callable() and call_user_func(). + if (($label_callback = $entity_type->getLabelCallback()) && function_exists($label_callback)) { + $label = $label_callback($this); } elseif (($label_key = $entity_type->getKey('label')) && isset($this->{$label_key})) { $label = $this->{$label_key}->value; diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 8fd3a62..5d70510 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -7,14 +7,13 @@ namespace Drupal\Core\Entity; -use Drupal\Core\DependencyInjection\DependencySerialization; use Drupal\Core\Language\Language; use Drupal\Core\Session\AccountInterface; /** * Defines a base entity class. */ -abstract class Entity extends DependencySerialization implements EntityInterface { +abstract class Entity implements EntityInterface { /** * The language code of the entity's default language. @@ -24,20 +23,6 @@ public $langcode = Language::LANGCODE_NOT_SPECIFIED; /** - * The entity manager. - * - * @var \Drupal\Core\Entity\EntityManagerInterface - */ - protected $entityManager; - - /** - * The UUID generator. - * - * @var \Drupal\Component\Uuid\UuidInterface - */ - protected $uuidGenerator; - - /** * The entity type. * * @var string @@ -76,39 +61,6 @@ public function __construct(array $values, $entity_type) { } /** - * Wraps language_load(). - */ - protected function languageLoad($langcode) { - return language_load($langcode); - } - - /** - * Returns the entity manager. - * - * @return \Drupal\Core\Entity\EntityManagerInterface - */ - protected function entityManager() { - if (!$this->entityManager) { - $this->entityManager = \Drupal::entityManager(); - } - - return $this->entityManager; - } - - /** - * Returns the UUID generator. - * - * @return \Drupal\Component\Uuid\UuidInterface - */ - protected function uuidGenerator() { - if (!$this->uuidGenerator) { - $this->uuidGenerator = \Drupal::service('uuid'); - } - - return $this->uuidGenerator; - } - - /** * {@inheritdoc} */ public function id() { @@ -134,8 +86,6 @@ public function isNew() { */ public function enforceIsNew($value = TRUE) { $this->enforceIsNew = $value; - - return $this; } /** @@ -158,8 +108,9 @@ public function bundle() { public function label() { $label = NULL; $entity_type = $this->getEntityType(); - if (($label_callback = $entity_type->getLabelCallback()) && is_callable($label_callback)) { - $label = call_user_func($label_callback, $this); + // @todo Convert to is_callable() and call_user_func(). + if (($label_callback = $entity_type->getLabelCallback()) && function_exists($label_callback)) { + $label = $label_callback($this); } elseif (($label_key = $entity_type->getKey('label')) && isset($this->{$label_key})) { $label = $this->{$label_key}; @@ -187,7 +138,7 @@ public function urlInfo($rel = 'canonical') { $bundle = $this->bundle(); // A bundle-specific callback takes precedence over the generic one for // the entity type. - $bundles = $this->entityManager()->getBundleInfo($this->getEntityTypeId()); + $bundles = \Drupal::entityManager()->getBundleInfo($this->getEntityTypeId()); if (isset($bundles[$bundle]['uri_callback'])) { $uri_callback = $bundles[$bundle]['uri_callback']; } @@ -197,8 +148,9 @@ public function urlInfo($rel = 'canonical') { // Invoke the callback to get the URI. If there is no callback, use the // default URI format. - if (isset($uri_callback) && is_callable($uri_callback)) { - $uri = call_user_func($uri_callback, $this); + // @todo Convert to is_callable() and call_user_func(). + if (isset($uri_callback) && function_exists($uri_callback)) { + $uri = $uri_callback($this); } else { return array(); @@ -295,13 +247,13 @@ public function uriRelationships() { /** * {@inheritdoc} */ - public function access($operation, AccountInterface $account = NULL) { + public function access($operation = 'view', AccountInterface $account = NULL) { if ($operation == 'create') { - return $this->entityManager() + return \Drupal::entityManager() ->getAccessController($this->entityTypeId) ->createAccess($this->bundle(), $account); } - return $this->entityManager() + return \Drupal::entityManager() ->getAccessController($this->entityTypeId) ->access($this, $operation, Language::LANGCODE_DEFAULT, $account); } @@ -310,7 +262,7 @@ public function access($operation, AccountInterface $account = NULL) { * {@inheritdoc} */ public function language() { - $language = $this->languageLoad($this->langcode); + $language = language_load($this->langcode); if (!$language) { // Make sure we return a proper language object. $language = new Language(array('id' => Language::LANGCODE_NOT_SPECIFIED)); @@ -322,7 +274,7 @@ public function language() { * {@inheritdoc} */ public function save() { - return $this->entityManager()->getStorageController($this->entityTypeId)->save($this); + return \Drupal::entityManager()->getStorageController($this->entityTypeId)->save($this); } /** @@ -330,7 +282,7 @@ public function save() { */ public function delete() { if (!$this->isNew()) { - $this->entityManager()->getStorageController($this->entityTypeId)->delete(array($this->id() => $this)); + \Drupal::entityManager()->getStorageController($this->entityTypeId)->delete(array($this->id() => $this)); } } @@ -344,7 +296,8 @@ public function createDuplicate() { // Check if the entity type supports UUIDs and generate a new one if so. if ($entity_type->hasKey('uuid')) { - $duplicate->{$entity_type->getKey('uuid')} = $this->uuidGenerator()->generate(); + // @todo Inject the UUID service into the Entity class once possible. + $duplicate->{$entity_type->getKey('uuid')} = \Drupal::service('uuid')->generate(); } return $duplicate; } @@ -353,7 +306,7 @@ public function createDuplicate() { * {@inheritdoc} */ public function getEntityType() { - return $this->entityManager()->getDefinition($this->getEntityTypeId()); + return \Drupal::entityManager()->getDefinition($this->getEntityTypeId()); } /** @@ -391,7 +344,6 @@ public static function preDelete(EntityStorageControllerInterface $storage_contr * {@inheritdoc} */ public static function postDelete(EntityStorageControllerInterface $storage_controller, array $entities) { - /** @var self[] $entities */ foreach ($entities as $entity) { $entity->onSaveOrDelete(); } @@ -423,8 +375,8 @@ protected function onSaveOrDelete() { } foreach ($referenced_entities as $entity_type => $entities) { - if ($this->entityManager()->hasController($entity_type, 'view_builder')) { - $this->entityManager()->getViewBuilder($entity_type)->resetCache($entities); + if (\Drupal::entityManager()->hasController($entity_type, 'view_builder')) { + \Drupal::entityManager()->getViewBuilder($entity_type)->resetCache($entities); } } } @@ -442,4 +394,14 @@ protected function urlGenerator() { return $this->urlGenerator; } + /** + * {@inheritdoc} + */ + public function __sleep() { + // Don't serialize the url generator. + $this->urlGenerator = NULL; + + return array_keys(get_object_vars($this)); + } + } diff --git a/core/lib/Drupal/Core/Entity/EntityInterface.php b/core/lib/Drupal/Core/Entity/EntityInterface.php index 769a85e..057727b 100644 --- a/core/lib/Drupal/Core/Entity/EntityInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityInterface.php @@ -65,8 +65,6 @@ public function isNew(); * (optional) Whether the entity should be forced to be new. Defaults to * TRUE. * - * @return self - * * @see \Drupal\Core\Entity\EntityInterface::isNew() */ public function enforceIsNew($value = TRUE); diff --git a/core/lib/Drupal/Core/Entity/EntityListController.php b/core/lib/Drupal/Core/Entity/EntityListController.php index c6585be..0703f50 100644 --- a/core/lib/Drupal/Core/Entity/EntityListController.php +++ b/core/lib/Drupal/Core/Entity/EntityListController.php @@ -171,7 +171,7 @@ public function buildOperations(EntityInterface $entity) { */ public function render() { $build = array( - '#type' => 'table', + '#theme' => 'table', '#header' => $this->buildHeader(), '#title' => $this->getTitle(), '#rows' => array(), diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index c7c111c..5bfd687 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -370,7 +370,7 @@ public function getFieldDefinitions($entity_type_id, $bundle) { } else { // Rebuild the definitions and put it into the cache. - $bundle_field_definitions = $this->buildBundleFieldDefinitions($entity_type_id, $bundle, $base_field_definitions); + $bundle_field_definitions = $this->buildBuildFieldDefinitions($entity_type_id, $bundle, $base_field_definitions); $this->cache->set($cid, $bundle_field_definitions, Cache::PERMANENT, array('entity_types' => TRUE, 'entity_field_info' => TRUE)); } // Field definitions consist of the bundle specific overrides and the @@ -397,7 +397,7 @@ public function getFieldDefinitions($entity_type_id, $bundle) { * An array of bundle field definitions, keyed by field name. Does * not include base fields. */ - protected function buildBundleFieldDefinitions($entity_type_id, $bundle, array $base_field_definitions) { + protected function buildBuildFieldDefinitions($entity_type_id, $bundle, array $base_field_definitions) { $entity_type = $this->getDefinition($entity_type_id); $class = $entity_type->getClass(); diff --git a/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php b/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php index 7c39f19..5416935 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Entity; use Drupal\Core\Entity\Query\QueryInterface; use Drupal\Core\Extension\ModuleHandlerInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * A base entity storage controller class. @@ -195,17 +194,10 @@ protected function buildPropertyQuery(QueryInterface $entity_query, array $value */ public function loadByProperties(array $values = array()) { // Build a query to fetch the entity IDs. - $entity_query = $this->getQuery(); + $entity_query = \Drupal::entityQuery($this->entityTypeId); $this->buildPropertyQuery($entity_query, $values); $result = $entity_query->execute(); return $result ? $this->loadMultiple($result) : array(); } - /** - * {@inheritdoc} - */ - public function getQuery($conjunction = 'AND') { - return \Drupal::entityQuery($this->getEntityTypeId(), $conjunction); - } - } diff --git a/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php b/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php index 2658aa2..3da5abc 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php @@ -155,21 +155,6 @@ public function save(EntityInterface $entity); public function getQueryServicename(); /** - * Returns an entity query instance. - * - * @param string $conjunction - * (optional) The logical operator for the query, either: - * - AND: all of the conditions on the query need to match. - * - OR: at least one of the conditions on the query need to match. - * - * @return \Drupal\Core\Entity\Query\QueryInterface - * The query instance. - * - * @see \Drupal\Core\Entity\EntityStorageControllerInterface::getQueryServicename() - */ - public function getQuery($conjunction = 'AND'); - - /** * Returns the entity type ID. * * @return string diff --git a/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php b/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php index 5d01819..ec468b7 100644 --- a/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php +++ b/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php @@ -11,6 +11,7 @@ use Drupal\Core\Field\PrepareCacheInterface; use Drupal\field\FieldConfigInterface; use Drupal\field\FieldInstanceConfigInterface; +use Drupal\Core\Field\ConfigFieldItemListInterface; use Symfony\Component\DependencyInjection\ContainerInterface; abstract class FieldableEntityStorageControllerBase extends EntityStorageControllerBase implements FieldableEntityStorageControllerInterface { @@ -166,7 +167,7 @@ protected function loadFieldItems(array $entities) { foreach ($entity->getTranslationLanguages() as $langcode => $language) { $translation = $entity->getTranslation($langcode); foreach ($translation as $field_name => $items) { - if ($items->getFieldDefinition()->isConfigurable() && !$items->isEmpty()) { + if ($items instanceof ConfigFieldItemListInterface && !$items->isEmpty()) { foreach ($items as $delta => $item) { // If the field item needs to prepare the cache data, call the // corresponding method, otherwise use the values as cache diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php index 214a63a..f5a9aa4 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php +++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php @@ -63,7 +63,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) { /** * {@inheritdoc} */ - public function getDerivativeDefinition($derivative_id, $base_plugin_definition) { + public function getDerivativeDefinition($derivative_id, array $base_plugin_definition) { if (!empty($this->derivatives) && !empty($this->derivatives[$derivative_id])) { return $this->derivatives[$derivative_id]; } @@ -76,7 +76,7 @@ public function getDerivativeDefinition($derivative_id, $base_plugin_definition) /** * {@inheritdoc} */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { // Also keep the 'entity' defined as is. $this->derivatives[''] = $base_plugin_definition; // Add definitions for each entity type and bundle. diff --git a/core/lib/Drupal/Core/Entity/Query/QueryBase.php b/core/lib/Drupal/Core/Entity/Query/QueryBase.php index 05782dd..e98755a 100644 --- a/core/lib/Drupal/Core/Entity/Query/QueryBase.php +++ b/core/lib/Drupal/Core/Entity/Query/QueryBase.php @@ -210,7 +210,9 @@ public function range($start = NULL, $length = NULL) { * An object holding a group of conditions. */ protected function conditionGroupFactory($conjunction = 'AND') { - $class = static::getClass($this->namespaces, 'Condition'); + // As the factory classes hardwire QueryBase::getClass, it needs to be + // hardwired here too. + $class = QueryBase::getClass($this->namespaces, 'Condition'); return new $class($conjunction, $this, $this->namespaces); } diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Query.php b/core/lib/Drupal/Core/Entity/Query/Sql/Query.php index cf8eb39..407cef5 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/Query.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/Query.php @@ -311,7 +311,7 @@ public function __clone() { * The object that adds tables and fields to the SQL query object. */ public function getTables(SelectInterface $sql_query) { - $class = static::getClass($this->namespaces, 'Tables'); + $class = QueryBase::getClass($this->namespaces, 'Tables'); return new $class($sql_query); } diff --git a/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php index a2aa7d8..5bdf61c 100644 --- a/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php @@ -78,13 +78,13 @@ public function onException(GetResponseForExceptionEvent $event) { * {@inheritdoc} * * The priority for request must be higher than the highest event subscriber - * accessing the current user. + * accessing the global $user. * The priority for the response must be as low as possible allowing e.g the * Cookie provider to send all relevant session data to the user. */ public static function getSubscribedEvents() { // Priority must be higher than LanguageRequestSubscriber as LanguageManager - // access current user in case language module enabled. + // access global $user in case language module enabled. $events[KernelEvents::REQUEST][] = array('onKernelRequestAuthenticate', 300); $events[KernelEvents::RESPONSE][] = array('onRespond', 0); $events[KernelEvents::EXCEPTION][] = array('onException', 0); diff --git a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php index 93bfb42..39aad11 100644 --- a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php @@ -44,9 +44,9 @@ public function onKernelRequestMaintenance(GetResponseEvent $event) { if ($request->attributes->get('_maintenance') != MENU_SITE_ONLINE && !($response instanceof RedirectResponse)) { // Deliver the 503 page. drupal_maintenance_theme(); + drupal_set_title(t('Site under maintenance')); $maintenance_page = array( '#theme' => 'maintenance_page', - '#title' => t('Site under maintenance'), '#content' => filter_xss_admin( t(\Drupal::config('system.maintenance')->get('message'), array('@site' => \Drupal::config('system.site')->get('name'))) ), diff --git a/core/lib/Drupal/Core/Extension/Extension.php b/core/lib/Drupal/Core/Extension/Extension.php index 936151f..188350c 100644 --- a/core/lib/Drupal/Core/Extension/Extension.php +++ b/core/lib/Drupal/Core/Extension/Extension.php @@ -15,7 +15,7 @@ class Extension implements \Serializable { /** * The type of the extension (e.g., 'module'). * - * @todo Change to protected once external test dependencies are resolved. + * @todo Replace all uses of $type with getType() method. * * @var string */ @@ -31,7 +31,7 @@ class Extension implements \Serializable { /** * The internal name of the extension (e.g., 'node'). * - * @todo Remove this property once external test dependencies are resolved. + * @todo Replace all uses of $name with getName() method. * * @var string */ @@ -48,22 +48,23 @@ class Extension implements \Serializable { public $uri; /** - * Same as $uri. + * The filename of the main extension file (e.g., 'node.module'). * - * @todo Remove this property once external test dependencies are resolved. + * 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. * - * @var string - */ - public $filename; - - /** - * The filename of the main extension file (e.g., 'node.module'). + * @see _system_rebuild_module_data() + * @see \Drupal\Core\Extension\ThemeHandler::rebuildThemeData() * - * @todo Rename to $filename once external test dependencies are resolved. + * @todo Remove this property and do not require .module/.profile files. + * @see https://drupal.org/node/340723 * * @var string */ - protected $_filename; + public $filename; /** * An SplFileInfo instance for the extension's info file. @@ -88,11 +89,10 @@ class Extension implements \Serializable { public function __construct($type, $pathname, $filename) { $this->type = $type; $this->pathname = $pathname; - $this->_filename = $filename; // Set legacy public properties. - $this->name = $this->getName(); - $this->uri = $this->getPath() . '/' . $filename; - $this->filename = $this->uri; + $this->name = basename($pathname, '.info.yml'); + $this->filename = $filename; + $this->uri = dirname($pathname) . '/' . $filename; } /** @@ -177,9 +177,14 @@ public function serialize() { $data = array( 'type' => $this->type, '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 // system_list() are adding custom properties to the Extension object. $info = new \ReflectionObject($this); @@ -197,14 +202,14 @@ public function unserialize($data) { $data = unserialize($data); $this->type = $data['type']; $this->pathname = $data['pathname']; - $this->_filename = $data['_filename']; // Restore legacy public properties. // @todo Remove these properties and do not require .module/.profile files. // @see https://drupal.org/node/340723 - $this->name = $this->getName(); - $this->uri = $this->getPath() . '/' . $this->_filename; - $this->filename = $this->uri; + // @see Extension::$filename + $this->name = basename($data['pathname'], '.info.yml'); + $this->uri = dirname($data['pathname']) . '/' . $data['filename']; + $this->filename = $data['filename']; // @todo ThemeHandler::listInfo(), ThemeHandler::rebuildThemeData(), and // system_list() are adding custom properties to the Extension object. diff --git a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php index aba0c2f..2d35d00 100644 --- a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php +++ b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php @@ -278,14 +278,14 @@ protected function process(array $all_files) { // 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->getName()])) { + if (isset($files[$file->name])) { // 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->getName()] = $file; + $files[$file->name] = $file; } return $files; } @@ -366,12 +366,16 @@ protected function scanDirectory($dir, $include_tests) { $name = $fileinfo->getBasename('.info.yml'); $pathname = $dir_prefix . $fileinfo->getSubPathname(); - // Determine whether the extension has a main extension file. + // Supply main extension filename being used throughout Drupal. + // For themes, the filename is the info file itself. + if ($type == 'theme') { + $filename = $fileinfo->getFilename(); + } // For theme engines, the file extension is .engine. - if ($type == 'theme_engine') { + elseif ($type == 'theme_engine') { $filename = $name . '.engine'; } - // For profiles/modules/themes, it is the extension type. + // Otherwise, it is .module/.profile; i.e., the extension type. else { $filename = $name . '.' . $type; } diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php index 89cd73e..1dd6f21 100644 --- a/core/lib/Drupal/Core/Extension/ModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php @@ -145,11 +145,11 @@ public function setModuleList(array $module_list = array()) { */ public function buildModuleDependencies(array $modules) { foreach ($modules as $module) { - $graph[$module->getName()]['edges'] = array(); + $graph[$module->name]['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->getName()]['edges'][$dependency_data['name']] = $dependency_data; + $graph[$module->name]['edges'][$dependency_data['name']] = $dependency_data; } } } @@ -382,7 +382,7 @@ public function alter($type, &$data, &$context1 = NULL, &$context2 = NULL) { if (isset($theme)) { $theme_keys = array(); foreach ($base_theme_info as $base) { - $theme_keys[] = $base->getName(); + $theme_keys[] = $base->name; } $theme_keys[] = $theme; foreach ($theme_keys as $theme_key) { diff --git a/core/lib/Drupal/Core/Extension/ThemeHandler.php b/core/lib/Drupal/Core/Extension/ThemeHandler.php index 060d796..e2bf62e 100644 --- a/core/lib/Drupal/Core/Extension/ThemeHandler.php +++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php @@ -220,7 +220,7 @@ public function listInfo() { if (!isset($theme->status)) { $theme->status = 0; } - $this->list[$theme->getName()] = $theme; + $this->list[$theme->name] = $theme; } } return $this->list; @@ -271,6 +271,7 @@ public function rebuildThemeData() { $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 @@ -291,7 +292,7 @@ public function rebuildThemeData() { $engine = $theme->info['engine']; if (isset($engines[$engine])) { $theme->owner = $engines[$engine]->uri; - $theme->prefix = $engines[$engine]->getName(); + $theme->prefix = $engines[$engine]->name; } // Prefix stylesheets, scripts, and screenshot with theme path. diff --git a/core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php b/core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php index fc4a4c4..11f2246 100644 --- a/core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php +++ b/core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php @@ -74,13 +74,4 @@ class FieldFormatter extends Plugin { */ public $settings = array(); - /** - * An integer to determine the weight of this formatter relative to other - * formatter in the Field UI when selecting a formatter for a given field - * instance. - * - * @var int optional - */ - public $weight = NULL; - } diff --git a/core/lib/Drupal/Core/Field/ConfigFieldItemBase.php b/core/lib/Drupal/Core/Field/ConfigFieldItemBase.php new file mode 100644 index 0000000..4b65acf --- /dev/null +++ b/core/lib/Drupal/Core/Field/ConfigFieldItemBase.php @@ -0,0 +1,29 @@ +getFieldDefinition()->getCardinality(); + if ($cardinality != FieldDefinitionInterface::CARDINALITY_UNLIMITED) { + $constraints[] = \Drupal::typedDataManager() + ->getValidationConstraintManager() + ->create('Count', array( + 'max' => $cardinality, + 'maxMessage' => t('%name: this field cannot hold more than @count values.', array('%name' => $this->getFieldDefinition()->getLabel(), '@count' => $cardinality)), + )); + } + + return $constraints; + } + + /** + * {@inheritdoc} + */ + public function defaultValuesForm(array &$form, array &$form_state) { + if (empty($this->getFieldDefinition()->default_value_function)) { + // Place the input in a separate place in the submitted values tree. + $widget = $this->defaultValueWidget($form_state); + $element = array('#parents' => array('default_value_input')); + $element += $widget->form($this, $element, $form_state); + + return $element; + } + } + + /** + * {@inheritdoc} + */ + public function defaultValuesFormValidate(array $element, array &$form, array &$form_state) { + // Extract the submitted value, and validate it. + $widget = $this->defaultValueWidget($form_state); + $widget->extractFormValues($this, $element, $form_state); + $violations = $this->validate(); + + if (count($violations)) { + // Store reported errors in $form_state. + $field_name = $this->getFieldDefinition()->getName(); + $field_state = field_form_get_state($element['#parents'], $field_name, $form_state); + $field_state['constraint_violations'] = $violations; + field_form_set_state($element['#parents'], $field_name, $form_state, $field_state); + + // Assign reported errors to the correct form element. + $widget->flagErrors($this, $element, $form_state); + } + } + + /** + * {@inheritdoc} + */ + public function defaultValuesFormSubmit(array $element, array &$form, array &$form_state) { + // Extract the submitted value, and return it as an array. + $widget = $this->defaultValueWidget($form_state); + $widget->extractFormValues($this, $element, $form_state); + return $this->getValue(); + } + + /** + * Returns the widget object used in default value form. + * + * @param array $form_state + * The form state of the (entire) configuration form. + * + * @return \Drupal\Core\Field\WidgetInterface + * A Widget object. + */ + protected function defaultValueWidget(array &$form_state) { + if (!isset($form_state['default_value_widget'])) { + $entity = $this->getEntity(); + + // Force a non-required widget. + $this->getFieldDefinition()->required = FALSE; + $this->getFieldDefinition()->description = ''; + + // Use the widget currently configured for the 'default' form mode, or + // fallback to the default widget for the field type. + $entity_form_display = entity_get_form_display($entity->getEntityTypeId(), $entity->bundle(), 'default'); + $widget = $entity_form_display->getRenderer($this->getFieldDefinition()->getName()); + if (!$widget) { + $widget = \Drupal::service('plugin.manager.field.widget')->getInstance(array('field_definition' => $this->getFieldDefinition())); + } + + $form_state['default_value_widget'] = $widget; + } + + return $form_state['default_value_widget']; + } + +} diff --git a/core/lib/Drupal/Core/Field/ConfigFieldItemListInterface.php b/core/lib/Drupal/Core/Field/ConfigFieldItemListInterface.php new file mode 100644 index 0000000..b58f9fd --- /dev/null +++ b/core/lib/Drupal/Core/Field/ConfigFieldItemListInterface.php @@ -0,0 +1,64 @@ +definition['cardinality'] = $cardinality; - return $this; - } - - /** * {@inheritdoc} */ public function isMultiple() { diff --git a/core/lib/Drupal/Core/Field/FieldItemBase.php b/core/lib/Drupal/Core/Field/FieldItemBase.php index fce6089..03706d2 100644 --- a/core/lib/Drupal/Core/Field/FieldItemBase.php +++ b/core/lib/Drupal/Core/Field/FieldItemBase.php @@ -226,18 +226,4 @@ public function delete() { } */ public function deleteRevision() { } - /** - * {@inheritdoc} - */ - public function settingsForm(array $form, array &$form_state, $has_data) { - return array(); - } - - /** - * {@inheritdoc} - */ - public function instanceSettingsForm(array $form, array &$form_state) { - return array(); - } - } diff --git a/core/lib/Drupal/Core/Field/FieldItemInterface.php b/core/lib/Drupal/Core/Field/FieldItemInterface.php index ae7bf6c..93b65ed 100644 --- a/core/lib/Drupal/Core/Field/FieldItemInterface.php +++ b/core/lib/Drupal/Core/Field/FieldItemInterface.php @@ -212,44 +212,4 @@ public function delete(); */ public function deleteRevision(); - /** - * Returns a form for the field-level settings. - * - * Invoked from \Drupal\field_ui\Form\FieldEditForm to allow administrators to - * configure field-level settings. - * - * Field storage might reject field definition changes that affect the field - * storage schema if the field already has data. When the $has_data parameter - * is TRUE, the form should not allow changing the settings that take part in - * the schema() method. It is recommended to set #access to FALSE on the - * corresponding elements. - * - * @param array $form - * The form where the settings form is being included in. - * @param array $form_state - * The form state of the (entire) configuration form. - * @param bool $has_data - * TRUE if the field already has data, FALSE if not. - * - * @return - * The form definition for the field settings. - */ - public function settingsForm(array $form, array &$form_state, $has_data); - - /** - * Returns a form for the instance-level settings. - * - * Invoked from \Drupal\field_ui\Form\FieldInstanceEditForm to allow - * administrators to configure instance-level settings. - * - * @param array $form - * The form where the settings form is being included in. - * @param array $form_state - * The form state of the (entire) configuration form. - * - * @return array - * The form definition for the field instance settings. - */ - public function instanceSettingsForm(array $form, array &$form_state); - } diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php index a3e64b0..367acea 100644 --- a/core/lib/Drupal/Core/Field/FieldItemList.php +++ b/core/lib/Drupal/Core/Field/FieldItemList.php @@ -286,102 +286,4 @@ public function view($display_options = array()) { return $view_builder->viewField($this, $display_options); } - /** - * {@inheritdoc} - */ - public function getConstraints() { - $constraints = parent::getConstraints(); - // Check that the number of values doesn't exceed the field cardinality. For - // form submitted values, this can only happen with 'multiple value' - // widgets. - $cardinality = $this->getFieldDefinition()->getCardinality(); - if ($cardinality != FieldDefinitionInterface::CARDINALITY_UNLIMITED) { - $constraints[] = \Drupal::typedDataManager() - ->getValidationConstraintManager() - ->create('Count', array( - 'max' => $cardinality, - 'maxMessage' => t('%name: this field cannot hold more than @count values.', array('%name' => $this->getFieldDefinition()->getLabel(), '@count' => $cardinality)), - )); - } - - return $constraints; - } - - /** - * {@inheritdoc} - */ - public function defaultValuesForm(array &$form, array &$form_state) { - if (empty($this->getFieldDefinition()->default_value_function)) { - // Place the input in a separate place in the submitted values tree. - $widget = $this->defaultValueWidget($form_state); - - $element = array('#parents' => array('default_value_input')); - $element += $widget->form($this, $element, $form_state); - - return $element; - } - } - - /** - * {@inheritdoc} - */ - public function defaultValuesFormValidate(array $element, array &$form, array &$form_state) { - // Extract the submitted value, and validate it. - $widget = $this->defaultValueWidget($form_state); - $widget->extractFormValues($this, $element, $form_state); - $violations = $this->validate(); - - if (count($violations)) { - // Store reported errors in $form_state. - $field_name = $this->getFieldDefinition()->getName(); - $field_state = field_form_get_state($element['#parents'], $field_name, $form_state); - $field_state['constraint_violations'] = $violations; - field_form_set_state($element['#parents'], $field_name, $form_state, $field_state); - - // Assign reported errors to the correct form element. - $widget->flagErrors($this, $element, $form_state); - } - } - - /** - * {@inheritdoc} - */ - public function defaultValuesFormSubmit(array $element, array &$form, array &$form_state) { - // Extract the submitted value, and return it as an array. - $widget = $this->defaultValueWidget($form_state); - $widget->extractFormValues($this, $element, $form_state); - return $this->getValue(); - } - - /** - * Returns the widget object used in default value form. - * - * @param array $form_state - * The form state of the (entire) configuration form. - * - * @return \Drupal\Core\Field\WidgetInterface - * A Widget object. - */ - protected function defaultValueWidget(array &$form_state) { - if (!isset($form_state['default_value_widget'])) { - $entity = $this->getEntity(); - - // Force a non-required widget. - $this->getFieldDefinition()->required = FALSE; - $this->getFieldDefinition()->description = ''; - - // Use the widget currently configured for the 'default' form mode, or - // fallback to the default widget for the field type. - $entity_form_display = entity_get_form_display($entity->getEntityTypeId(), $entity->bundle(), 'default'); - $widget = $entity_form_display->getRenderer($this->getFieldDefinition()->getName()); - if (!$widget) { - $widget = \Drupal::service('plugin.manager.field.widget')->getInstance(array('field_definition' => $this->getFieldDefinition())); - } - - $form_state['default_value_widget'] = $widget; - } - - return $form_state['default_value_widget']; - } - } diff --git a/core/lib/Drupal/Core/Field/FieldItemListInterface.php b/core/lib/Drupal/Core/Field/FieldItemListInterface.php index 651f1e4..6be6bc3 100644 --- a/core/lib/Drupal/Core/Field/FieldItemListInterface.php +++ b/core/lib/Drupal/Core/Field/FieldItemListInterface.php @@ -179,53 +179,4 @@ public function deleteRevision(); */ public function view($display_options = array()); - /** - * Returns a form for the default value input. - * - * Invoked from \Drupal\field_ui\Form\FieldInstanceEditForm to allow - * administrators to configure instance-level default value. - * - * @param array $form - * The form where the settings form is being included in. - * @param array $form_state - * The form state of the (entire) configuration form. - * - * @return array - * The form definition for the field instance default value. - */ - public function defaultValuesForm(array &$form, array &$form_state); - - /** - * Validates the submitted default value. - * - * Invoked from \Drupal\field_ui\Form\FieldInstanceEditForm to allow - * administrators to configure instance-level default value. - * - * @param array $element - * The default value form element. - * @param array $form - * The form where the settings form is being included in. - * @param array $form_state - * The form state of the (entire) configuration form. - */ - public function defaultValuesFormValidate(array $element, array &$form, array &$form_state); - - /** - * Processes the submitted default value. - * - * Invoked from \Drupal\field_ui\Form\FieldInstanceEditForm to allow - * administrators to configure instance-level default value. - * - * @param array $element - * The default value form element. - * @param array $form - * The form where the settings form is being included in. - * @param array $form_state - * The form state of the (entire) configuration form. - * - * @return array - * The field instance default value. - */ - public function defaultValuesFormSubmit(array $element, array &$form, array &$form_state); - } diff --git a/core/lib/Drupal/Core/Field/FieldTypePluginManager.php b/core/lib/Drupal/Core/Field/FieldTypePluginManager.php index 3928525..f4bd317 100644 --- a/core/lib/Drupal/Core/Field/FieldTypePluginManager.php +++ b/core/lib/Drupal/Core/Field/FieldTypePluginManager.php @@ -50,7 +50,12 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac public function processDefinition(&$definition, $plugin_id) { parent::processDefinition($definition, $plugin_id); if (!isset($definition['list_class'])) { - $definition['list_class'] = '\Drupal\Core\Field\FieldItemList'; + if ($definition['configurable']) { + $definition['list_class'] = '\Drupal\Core\Field\ConfigFieldItemList'; + } + else { + $definition['list_class'] = '\Drupal\Core\Field\FieldItemList'; + } } } diff --git a/core/lib/Drupal/Core/Field/FormatterBase.php b/core/lib/Drupal/Core/Field/FormatterBase.php index 1b4287f..35bbf33 100644 --- a/core/lib/Drupal/Core/Field/FormatterBase.php +++ b/core/lib/Drupal/Core/Field/FormatterBase.php @@ -106,7 +106,7 @@ public function view(FieldItemListInterface $items) { } } - $addition = array_merge($info, $elements); + $addition[$field_name] = array_merge($info, $elements); } return $addition; diff --git a/core/lib/Drupal/Core/Field/FormatterPluginManager.php b/core/lib/Drupal/Core/Field/FormatterPluginManager.php index d81ff57..b825272 100644 --- a/core/lib/Drupal/Core/Field/FormatterPluginManager.php +++ b/core/lib/Drupal/Core/Field/FormatterPluginManager.php @@ -167,15 +167,13 @@ public function prepareConfiguration($field_type, array $configuration) { */ public function getOptions($field_type = NULL) { if (!isset($this->formatterOptions)) { - $options = array(); $field_types = $this->fieldTypeManager->getDefinitions(); - $formatter_types = $this->getDefinitions(); - uasort($formatter_types, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); - foreach ($formatter_types as $name => $formatter_type) { - foreach ($formatter_type['field_types'] as $formatter_field_type) { + $options = array(); + foreach ($this->getDefinitions() as $name => $formatter) { + foreach ($formatter['field_types'] as $formatter_field_type) { // Check that the field type exists. if (isset($field_types[$formatter_field_type])) { - $options[$formatter_field_type][$name] = $formatter_type['label']; + $options[$formatter_field_type][$name] = $formatter['label']; } } } diff --git a/core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php b/core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php index 09207f1..8d0ef20 100644 --- a/core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php +++ b/core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php @@ -63,7 +63,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) { /** * {@inheritdoc} */ - public function getDerivativeDefinition($derivative_id, $base_plugin_definition) { + public function getDerivativeDefinition($derivative_id, array $base_plugin_definition) { if (!isset($this->derivatives)) { $this->getDerivativeDefinitions($base_plugin_definition); } @@ -75,7 +75,7 @@ public function getDerivativeDefinition($derivative_id, $base_plugin_definition) /** * {@inheritdoc} */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { foreach ($this->fieldTypePluginManager->getDefinitions() as $plugin_id => $definition) { $definition['definition_class'] = '\Drupal\Core\Field\TypedData\FieldItemDataDefinition'; $definition['list_definition_class'] = '\Drupal\Core\Field\FieldDefinition'; diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php index 7c27fff..93fc622 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php @@ -18,9 +18,7 @@ * id = "email", * label = @Translation("E-mail"), * description = @Translation("An entity field containing an e-mail value."), - * configurable = FALSE, - * default_widget = "string", - * default_formatter = "string" + * configurable = FALSE * ) */ class EmailItem extends FieldItemBase { diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php index 2ef9971..5d09d90 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php @@ -21,9 +21,7 @@ * settings = { * "max_length" = "255" * }, - * configurable = FALSE, - * default_widget = "string", - * default_formatter = "string" + * configurable = FALSE * ) */ class StringItem extends FieldItemBase { @@ -62,12 +60,7 @@ public function getConstraints() { if ($max_length = $this->getSetting('max_length')) { $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager(); $constraints[] = $constraint_manager->create('ComplexData', array( - 'value' => array( - 'Length' => array( - 'max' => $max_length, - 'maxMessage' => t('%name: may not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length)), - ), - ), + 'value' => array('Length' => array('max' => $max_length)) )); } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringWidget.php deleted file mode 100644 index 8d13286..0000000 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringWidget.php +++ /dev/null @@ -1,82 +0,0 @@ - 'number', - '#title' => t('Size of textfield'), - '#default_value' => $this->getSetting('size'), - '#required' => TRUE, - '#min' => 1, - ); - $element['placeholder'] = array( - '#type' => 'textfield', - '#title' => t('Placeholder'), - '#default_value' => $this->getSetting('placeholder'), - '#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'), - ); - return $element; - } - - /** - * {@inheritdoc} - */ - public function settingsSummary() { - $summary = array(); - - $summary[] = t('Textfield size: !size', array('!size' => $this->getSetting('size'))); - $placeholder = $this->getSetting('placeholder'); - if (!empty($placeholder)) { - $summary[] = t('Placeholder: @placeholder', array('@placeholder' => $placeholder)); - } - - return $summary; - } - - /** - * {@inheritdoc} - */ - public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { - $element['value'] = $element + array( - '#type' => 'textfield', - '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL, - '#size' => $this->getSetting('size'), - '#placeholder' => $this->getSetting('placeholder'), - '#maxlength' => $this->getFieldSetting('max_length'), - '#attributes' => array('class' => array('text-full')), - ); - - return $element; - } - -} diff --git a/core/lib/Drupal/Core/Field/WidgetBase.php b/core/lib/Drupal/Core/Field/WidgetBase.php index 6432fb1..d770871 100644 --- a/core/lib/Drupal/Core/Field/WidgetBase.php +++ b/core/lib/Drupal/Core/Field/WidgetBase.php @@ -111,21 +111,25 @@ public function form(FieldItemListInterface $items, array &$form, array &$form_s // Most widgets need their internal structure preserved in submitted values. $elements += array('#tree' => TRUE); - return array( - // Aid in theming of widgets by rendering a classified container. - '#type' => 'container', - // Assign a different parent, to keep the main id for the widget itself. - '#parents' => array_merge($parents, array($field_name . '_wrapper')), - '#attributes' => array( - 'class' => array( - 'field-type-' . drupal_html_class($this->fieldDefinition->getType()), - 'field-name-' . drupal_html_class($field_name), - 'field-widget-' . drupal_html_class($this->getPluginId()), + $return = array( + $field_name => array( + // Aid in theming of widgets by rendering a classified container. + '#type' => 'container', + // Assign a different parent, to keep the main id for the widget itself. + '#parents' => array_merge($parents, array($field_name . '_wrapper')), + '#attributes' => array( + 'class' => array( + 'field-type-' . drupal_html_class($this->fieldDefinition->getType()), + 'field-name-' . drupal_html_class($field_name), + 'field-widget-' . drupal_html_class($this->getPluginId()), + ), ), + '#access' => $items->access('edit'), + 'widget' => $elements, ), - '#access' => $items->access('edit'), - 'widget' => $elements, ); + + return $return; } /** diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php index 1231689..26a1c3d 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -553,15 +553,6 @@ public function processForm($form_id, &$form, &$form_state) { if (isset($form['#token']) && $form['#token'] === FALSE) { unset($form['#token']); } - // Form values for programmed form submissions typically do not include a - // value for the submit button. But without a triggering element, a - // potentially existing #limit_validation_errors property on the primary - // submit button is not taken account. Therefore, check whether there is - // exactly one submit button in the form, and if so, automatically use it - // as triggering_element. - if ($form_state['programmed'] && !isset($form_state['triggering_element']) && count($form_state['buttons']) == 1) { - $form_state['triggering_element'] = reset($form_state['buttons']); - } $this->validateForm($form_id, $form, $form_state); // drupal_html_id() maintains a cache of element IDs it has seen, so it @@ -612,14 +603,10 @@ public function processForm($form_id, &$form, &$form_state) { // Set a flag to indicate the the form has been processed and executed. $form_state['executed'] = TRUE; - // If no response has been set, process the form redirect. - if (!isset($form_state['response']) && $redirect = $this->redirectForm($form_state)) { - $form_state['response'] = $redirect; - } - - // If there is a response was set, return it instead of continuing. - if (isset($form_state['response']) && $form_state['response'] instanceof Response) { - return $form_state['response']; + // Redirect the form based on values in $form_state. + $redirect = $this->redirectForm($form_state); + if (is_object($redirect)) { + return $redirect; } } diff --git a/core/lib/Drupal/Core/Form/FormBuilderInterface.php b/core/lib/Drupal/Core/Form/FormBuilderInterface.php index 0e318bb..9166f98 100644 --- a/core/lib/Drupal/Core/Form/FormBuilderInterface.php +++ b/core/lib/Drupal/Core/Form/FormBuilderInterface.php @@ -104,12 +104,6 @@ public function getForm($form_arg); * already set $form_state['rebuild'] to cause the form processing to * bypass submit handlers and rebuild the form instead, even if there are * no validation errors. - * - response: Used when a form needs to return some kind of a - * \Symfony\Component\HttpFoundation\Response object, e.g., a - * \Symfony\Component\HttpFoundation\BinaryFileResponse when triggering a - * file download. If you use the $form_state['redirect'] key, it will be - * used to build a \Symfony\Component\HttpFoundation\RedirectResponse and - * will populate this key. * - redirect: Used to redirect the form on submission. It may either be a * string containing the destination URL, or an array of arguments * compatible with url(). See url() for complete information. diff --git a/core/lib/Drupal/Core/Image/Image.php b/core/lib/Drupal/Core/Image/Image.php index f7a5cd7..136c81e 100644 --- a/core/lib/Drupal/Core/Image/Image.php +++ b/core/lib/Drupal/Core/Image/Image.php @@ -34,6 +34,13 @@ class Image implements ImageInterface { protected $toolkit; /** + * An image file handle. + * + * @var resource + */ + protected $resource; + + /** * Height, in pixels. * * @var int @@ -105,14 +112,6 @@ public function isSupported() { /** * {@inheritdoc} */ - public function isExisting() { - $this->processInfo(); - return $this->processed; - } - - /** - * {@inheritdoc} - */ public function getExtension() { $this->processInfo(); return $this->extension; @@ -177,6 +176,32 @@ public function getMimeType() { /** * {@inheritdoc} */ + public function setResource($resource) { + $this->resource = $resource; + return $this; + } + + /** + * {@inheritdoc} + */ + public function hasResource() { + return (bool) $this->resource; + } + + /** + * {@inheritdoc} + */ + public function getResource() { + if (!$this->hasResource()) { + $this->processInfo(); + $this->toolkit->load($this); + } + return $this->resource; + } + + /** + * {@inheritdoc} + */ public function setSource($source) { $this->source = $source; return $this; @@ -199,14 +224,6 @@ public function getToolkitId() { /** * {@inheritdoc} */ - public function getToolkit() { - $this->processInfo(); - return $this->toolkit; - } - - /** - * {@inheritdoc} - */ public function save($destination = NULL) { if (empty($destination)) { $destination = $this->getSource(); @@ -270,30 +287,22 @@ protected function processInfo() { * image toolkit. * * This is a temporary solution to keep patches reviewable. The __call() - * method will be replaced in https://drupal.org/node/2110499 with a new + * method will be replaced in https://drupal.org/node/2073759 with a new * interface method ImageInterface::apply(). An image operation will be * performed as in the next example: * @code * $image = new Image($path, $toolkit); * $image->apply('scale', array('width' => 50, 'height' => 100)); * @endcode - * Also in https://drupal.org/node/2110499 operation arguments sent to toolkit + * Also in https://drupal.org/node/2073759 operation arguments sent to toolkit * will be moved to a keyed array, unifying the interface of toolkit * operations. * - * @todo Drop this in https://drupal.org/node/2110499 in favor of new apply(). + * @todo Drop this in https://drupal.org/node/2073759 in favor of new apply(). */ public function __call($method, $arguments) { - // @todo Temporary to avoid that legacy GD setResource(), getResource(), - // hasResource() methods moved to GD toolkit in #2103621 get invoked - // from this class anyway through the magic __call. Will be removed - // through https://drupal.org/node/2110499, when call_user_func_array() - // will be replaced by $this->toolkit->apply($name, $this, $arguments). - if (in_array($method, array('setResource', 'getResource', 'hasResource'))) { - throw new \BadMethodCallException(); - } if (is_callable(array($this->toolkit, $method))) { - // @todo In https://drupal.org/node/2110499, call_user_func_array() will + // @todo In https://drupal.org/node/2073759, call_user_func_array() will // be replaced by $this->toolkit->apply($name, $this, $arguments). array_unshift($arguments, $this); return call_user_func_array(array($this->toolkit, $method), $arguments); diff --git a/core/lib/Drupal/Core/Image/ImageFactory.php b/core/lib/Drupal/Core/Image/ImageFactory.php index 0e031ec..27773d8 100644 --- a/core/lib/Drupal/Core/Image/ImageFactory.php +++ b/core/lib/Drupal/Core/Image/ImageFactory.php @@ -7,7 +7,7 @@ namespace Drupal\Core\Image; -use Drupal\Core\ImageToolkit\ImageToolkitManager; +use Drupal\Core\ImageToolkit\ImageToolkitInterface; /** * Provides a factory for image objects. @@ -15,40 +15,33 @@ class ImageFactory { /** - * The image toolkit plugin manager. + * The image toolkit to use for this factory. * - * @var \Drupal\Core\ImageToolkit\ImageToolkitManager + * @var \Drupal\Core\ImageToolkit\ImageToolkitInterface */ - protected $toolkitManager; - - /** - * The image toolkit ID to use for this factory. - * - * @var string - */ - protected $toolkitId; + protected $toolkit; /** * Constructs a new ImageFactory object. * - * @param \Drupal\Core\ImageToolkit\ImageToolkitManager $toolkit_manager - * The image toolkit plugin manager. + * @param \Drupal\Core\ImageToolkit\ImageToolkitInterface $toolkit + * The image toolkit to use for this image factory. */ - public function __construct(ImageToolkitManager $toolkit_manager) { - $this->toolkitManager = $toolkit_manager; + public function __construct(ImageToolkitInterface $toolkit) { + $this->toolkit = $toolkit; } /** - * Sets this factory image toolkit ID. + * Sets a custom image toolkit. * - * @param string $toolkit_id - * The image toolkit ID to use for this image factory. + * @param \Drupal\Core\ImageToolkit\ImageToolkitInterface $toolkit + * The image toolkit to use for this image factory. * * @return self * Returns this image. */ - public function setToolkitId($toolkit_id) { - $this->toolkitId = $toolkit_id; + public function setToolkit(ImageToolkitInterface $toolkit) { + $this->toolkit = $toolkit; return $this; } @@ -62,10 +55,7 @@ public function setToolkitId($toolkit_id) { * The new Image object. */ public function get($source) { - if (!$this->toolkitId) { - $this->toolkitId = $this->toolkitManager->getDefaultToolkitId(); - } - return new Image($source, $this->toolkitManager->createInstance($this->toolkitId)); + return new Image($source, $this->toolkit); } } diff --git a/core/lib/Drupal/Core/Image/ImageInterface.php b/core/lib/Drupal/Core/Image/ImageInterface.php index 151bef1..411d39a 100644 --- a/core/lib/Drupal/Core/Image/ImageInterface.php +++ b/core/lib/Drupal/Core/Image/ImageInterface.php @@ -21,14 +21,6 @@ public function isSupported(); /** - * Checks if the image is existing. - * - * @return bool - * TRUE if the image exists and is a valid image, FALSE otherwise. - */ - public function isExisting(); - - /** * Returns the extension of the image file. * * @return string @@ -98,6 +90,33 @@ public function getType(); public function getMimeType(); /** + * Sets the image file resource. + * + * @param resource $resource + * The image file handle. + * + * @return self + * Returns this image file. + */ + public function setResource($resource); + + /** + * Determines if this image file has a resource set. + * + * @return bool + * TRUE if this image file has a resource set, FALSE otherwise. + */ + public function hasResource(); + + /** + * Retrieves the image file resource. + * + * @return resource + * The image file handle. + */ + public function getResource(); + + /** * Sets the source path of the image file. * * @param string $source @@ -117,14 +136,6 @@ public function setSource($source); public function getSource(); /** - * Returns the image toolkit used for this image file. - * - * @return string - * The image toolkit. - */ - public function getToolkit(); - - /** * Returns the ID of the image toolkit used for this image file. * * @return string diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php index 61c6ece..a5f96f3 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php @@ -132,6 +132,17 @@ public function crop(ImageInterface $image, $x, $y, $width, $height); public function desaturate(ImageInterface $image); /** + * Creates an image resource from a file. + * + * @param \Drupal\Core\Image\ImageInterface $image + * An image object. The $image->resource value will populated by this call. + * + * @return bool + * TRUE or FALSE, based on success. + */ + public function load(ImageInterface $image); + + /** * Writes an image resource to a destination file. * * @param \Drupal\Core\Image\ImageInterface $image diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php index e503558..5ec45ea 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php @@ -48,12 +48,12 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac } /** - * Gets the default image toolkit ID. + * Gets the default image toolkit. * - * @return string|bool - * ID of the default toolkit, or FALSE on error. + * @return \Drupal\Core\ImageToolkit\ImageToolkitInterface + * Object of the default toolkit, or FALSE on error. */ - public function getDefaultToolkitId() { + public function getDefaultToolkit() { $toolkit_id = $this->configFactory->get('system.image')->get('toolkit'); $toolkits = $this->getAvailableToolkits(); @@ -64,20 +64,14 @@ public function getDefaultToolkitId() { $toolkit_id = key($toolkits); } - return $toolkit_id; - } - - /** - * Gets the default image toolkit. - * - * @return \Drupal\Core\ImageToolkit\ImageToolkitInterface - * Object of the default toolkit, or FALSE on error. - */ - public function getDefaultToolkit() { - if ($toolkit_id = $this->getDefaultToolkitId()) { - return $this->createInstance($toolkit_id); + if ($toolkit_id) { + $toolkit = $this->createInstance($toolkit_id); + } + else { + $toolkit = FALSE; } - return FALSE; + + return $toolkit; } /** diff --git a/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php b/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php deleted file mode 100644 index 3f16728..0000000 --- a/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php +++ /dev/null @@ -1,39 +0,0 @@ -stringTranslation = $string_translation; - - $title = $this->t('Drupal already installed'); - $message = $this->t('
    -
  • To start over, you must empty your existing database, delete your active configuration, and copy default.settings.php over settings.php.
  • -
  • To install to a different database, edit the appropriate settings.php file in the sites folder.
  • -
  • To locate your active configuration, view the appropriate settings.php file in the sites folder.
  • -
  • To upgrade an existing installation, proceed to the update script.
  • -
  • View your existing site.
  • -
', array( - '@base-url' => $GLOBALS['base_url'], - )); - parent::__construct($message, $title); - } - -} diff --git a/core/lib/Drupal/Core/Installer/Exception/InstallerException.php b/core/lib/Drupal/Core/Installer/Exception/InstallerException.php deleted file mode 100644 index e8c1ec3..0000000 --- a/core/lib/Drupal/Core/Installer/Exception/InstallerException.php +++ /dev/null @@ -1,64 +0,0 @@ -title = $title; - } - - /** - * Returns the exception page title. - * - * @return string - */ - public function getTitle() { - return $this->title; - } - - /** - * Translates a string using StringTranslation. - * - * @see \Drupal\Core\StringTranslation\TranslationInterface::translate() - */ - protected function t($string, array $args = array(), array $options = array()) { - return $this->stringTranslation->translate($string, $args, $options); - } - -} diff --git a/core/lib/Drupal/Core/Installer/Exception/NoProfilesException.php b/core/lib/Drupal/Core/Installer/Exception/NoProfilesException.php deleted file mode 100644 index cc8d596..0000000 --- a/core/lib/Drupal/Core/Installer/Exception/NoProfilesException.php +++ /dev/null @@ -1,31 +0,0 @@ -stringTranslation = $string_translation; - - $title = $this->t('No profiles available'); - $message = $this->t('We were unable to find any installation profiles. Installation profiles tell us what modules to enable and what schema to install in the database. A profile is necessary to continue with the installation process.'); - parent::__construct($message, $title); - } - -} diff --git a/core/lib/Drupal/Core/Installer/InstallerRouteBuilder.php b/core/lib/Drupal/Core/Installer/InstallerRouteBuilder.php deleted file mode 100644 index 6337e7f..0000000 --- a/core/lib/Drupal/Core/Installer/InstallerRouteBuilder.php +++ /dev/null @@ -1,28 +0,0 @@ -register('config.storage', 'Drupal\Core\Config\InstallStorage'); - - // Replace services with in-memory implementations. - foreach (array('bootstrap', 'config', 'cache', 'menu', 'page', 'path') as $bin) { - $container - ->register("cache.$bin", 'Drupal\Core\Cache\MemoryBackend') - ->addArgument($bin); - } - $container - ->register('keyvalue', 'Drupal\Core\KeyValueStore\KeyValueMemoryFactory'); - $container - ->register('keyvalue.expirable', 'Drupal\Core\KeyValueStore\KeyValueNullExpirableFactory'); - - // Replace services with no-op implementations. - $container - ->register('lock', 'Drupal\Core\Lock\NullLockBackend'); - $container - ->register('url_generator', 'Drupal\Core\Routing\NullGenerator'); - $container - ->register('router.dumper', 'Drupal\Core\Routing\NullMatcherDumper'); - - // Replace the route builder with an empty implementation. - // @todo Convert installer steps into routes; add an installer.routing.yml. - $definition = $container->getDefinition('router.builder'); - $definition->setClass('Drupal\Core\Installer\InstallerRouteBuilder'); - - // Remove dependencies on Drupal's default session handling. - $container->removeDefinition('authentication.cookie'); - } - - /** - * {@inheritdoc} - */ - public function alter(ContainerBuilder $container) { - // Disable configuration overrides. - // ConfigFactory would to try to load language overrides and InstallStorage - // throws an exception upon trying to load a non-existing file. - $container->get('config.factory')->setOverrideState(FALSE); - - // No service may persist when the early installer kernel is rebooted into - // the production environment. - // @todo The DrupalKernel reboot performed by drupal_install_system() is - // actually not a "regular" reboot (like ModuleHandler::install()), so - // services are not actually persisted. - foreach ($container->findTaggedServiceIds('persist') as $id => $tags) { - $definition = $container->getDefinition($id); - $definition->clearTag('persist'); - } - } - -} diff --git a/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php b/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php index 6e0c509..64aed01 100644 --- a/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php +++ b/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php @@ -74,6 +74,14 @@ public function render(HtmlFragment $fragment, $status_code = 200) { * The modified page object. */ public function preparePage(HtmlPage $page, &$page_array) { + // @todo Remove this one drupal_get_title() has been eliminated. + if (!$page->hasTitle()) { + $title = drupal_get_title(); + // drupal_set_title() already ensured security, so not letting the + // title pass through would cause double escaping. + $page->setTitle($title, PASS_THROUGH); + } + $page_array['#page'] = $page; // HTML element attributes. diff --git a/core/lib/Drupal/Core/Page/DefaultHtmlPageRenderer.php b/core/lib/Drupal/Core/Page/DefaultHtmlPageRenderer.php index 821d42d..63e0d9c 100644 --- a/core/lib/Drupal/Core/Page/DefaultHtmlPageRenderer.php +++ b/core/lib/Drupal/Core/Page/DefaultHtmlPageRenderer.php @@ -17,7 +17,7 @@ class DefaultHtmlPageRenderer implements HtmlPageRendererInterface { */ public function render(HtmlPage $page) { $render = array( - '#type' => 'html', + '#theme' => 'html', '#page_object' => $page, ); return drupal_render($render); diff --git a/core/lib/Drupal/Core/Page/HtmlFragment.php b/core/lib/Drupal/Core/Page/HtmlFragment.php index cf1ca4d..cc5cac5 100644 --- a/core/lib/Drupal/Core/Page/HtmlFragment.php +++ b/core/lib/Drupal/Core/Page/HtmlFragment.php @@ -103,8 +103,8 @@ public function getContent() { * Value to assign to the page title. * @param int $output * (optional) normally should be left as Title::CHECK_PLAIN. Only set to - * Title::PASS_THROUGH if you have already removed any possibly dangerous - * code from $title using a function like + * PASS_THROUGH if you have already removed any possibly dangerous code + * from $title using a function like * \Drupal\Component\Utility\String::checkPlain() or * \Drupal\Component\Utility\Xss::filterAdmin(). With this flag the string * will be passed through unchanged. diff --git a/core/lib/Drupal/Core/Plugin/DefaultPluginBag.php b/core/lib/Drupal/Core/Plugin/DefaultPluginBag.php index a6bb5c9..ff6d922 100644 --- a/core/lib/Drupal/Core/Plugin/DefaultPluginBag.php +++ b/core/lib/Drupal/Core/Plugin/DefaultPluginBag.php @@ -139,6 +139,15 @@ public function setConfiguration($configuration) { } /** + * {@inheritdoc} + */ + public function setInstanceIds(array $instance_ids) { + parent::setInstanceIds($instance_ids); + // Ensure the new order matches the original order. + $this->instanceIDs = $this->originalOrder = array_intersect_assoc($this->originalOrder, $this->instanceIDs); + } + + /** * Updates the configuration for a plugin instance. * * If there is no plugin instance yet, a new will be instantiated. Otherwise, @@ -160,19 +169,6 @@ public function setInstanceConfiguration($instance_id, array $configuration) { /** * {@inheritdoc} */ - public function addInstanceId($id, $configuration = NULL) { - parent::addInstanceId($id); - if ($configuration !== NULL) { - $this->setInstanceConfiguration($id, $configuration); - } - if (!isset($this->originalOrder[$id])) { - $this->originalOrder[$id] = $id; - } - } - - /** - * {@inheritdoc} - */ public function removeInstanceId($instance_id) { parent::removeInstanceId($instance_id); unset($this->originalOrder[$instance_id]); diff --git a/core/lib/Drupal/Core/Plugin/DefaultSinglePluginBag.php b/core/lib/Drupal/Core/Plugin/DefaultSinglePluginBag.php index 2108ce1..7b1c816 100644 --- a/core/lib/Drupal/Core/Plugin/DefaultSinglePluginBag.php +++ b/core/lib/Drupal/Core/Plugin/DefaultSinglePluginBag.php @@ -93,14 +93,4 @@ public function setConfiguration($configuration) { return $this; } - /** - * {@inheritdoc} - */ - public function addInstanceId($id, $configuration = NULL) { - parent::addInstanceId($id, $configuration); - if ($configuration !== NULL) { - $this->setConfiguration($configuration); - } - } - } diff --git a/core/lib/Drupal/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecorator.php b/core/lib/Drupal/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecorator.php index b01d1ac..eed640c 100644 --- a/core/lib/Drupal/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecorator.php +++ b/core/lib/Drupal/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecorator.php @@ -14,7 +14,7 @@ class ContainerDerivativeDiscoveryDecorator extends DerivativeDiscoveryDecorator /** * {@inheritdoc} */ - protected function getDerivativeFetcher($base_plugin_id, $base_definition) { + protected function getDerivativeFetcher($base_plugin_id, array $base_definition) { if (!isset($this->derivativeFetchers[$base_plugin_id])) { $this->derivativeFetchers[$base_plugin_id] = FALSE; $class = $this->getDerivativeClass($base_definition); diff --git a/core/lib/Drupal/Core/Routing/NullMatcherDumper.php b/core/lib/Drupal/Core/Routing/NullMatcherDumper.php deleted file mode 100644 index b214b38..0000000 --- a/core/lib/Drupal/Core/Routing/NullMatcherDumper.php +++ /dev/null @@ -1,63 +0,0 @@ -routes)) { - $this->routes = $routes; - } - else { - $this->routes->addCollection($routes); - } - } - - /** - * Dumps a set of routes to the router table in the database. - * - * Available options: - * - provider: The route grouping that is being dumped. All existing - * routes with this provider will be deleted on dump. - * - base_class: The base class name. - * - * @param array $options - * An array of options. - */ - public function dump(array $options = array()) { - // The dumper is reused for multiple providers, so reset the queued routes. - $this->routes = NULL; - } - - /** - * Gets the routes to match. - * - * @return \Symfony\Component\Routing\RouteCollection - * A RouteCollection instance representing all routes currently in the - * dumper. - */ - public function getRoutes() { - return $this->routes; - } - -} diff --git a/core/lib/Drupal/Core/Routing/RouteBuilder.php b/core/lib/Drupal/Core/Routing/RouteBuilder.php index 8df9f67..eebe414 100644 --- a/core/lib/Drupal/Core/Routing/RouteBuilder.php +++ b/core/lib/Drupal/Core/Routing/RouteBuilder.php @@ -103,7 +103,9 @@ public function rebuild() { return FALSE; } - foreach ($this->getRouteDefinitions() as $provider => $routes) { + $yaml_discovery = $this->getYamlDiscovery(); + + foreach ($yaml_discovery->findAll() as $provider => $routes) { $collection = new RouteCollection(); // The top-level 'routes_callback' is a list of methods in controller @@ -178,16 +180,16 @@ public function setRebuildNeeded() { } /** - * Retrieves all defined routes from .routing.yml files. + * Returns the YAML discovery for getting all the .routing.yml files. * - * @return array - * The defined routes, keyed by provider. + * @return \Drupal\Component\Discovery\YamlDiscovery + * The yaml discovery. */ - protected function getRouteDefinitions() { + protected function getYamlDiscovery() { if (!isset($this->yamlDiscovery)) { $this->yamlDiscovery = new YamlDiscovery('routing', $this->moduleHandler->getModuleDirectories()); } - return $this->yamlDiscovery->findAll(); + return $this->yamlDiscovery; } } diff --git a/core/lib/Drupal/Core/Template/TwigEnvironment.php b/core/lib/Drupal/Core/Template/TwigEnvironment.php index 06a8dcc..2bbf3c9 100644 --- a/core/lib/Drupal/Core/Template/TwigEnvironment.php +++ b/core/lib/Drupal/Core/Template/TwigEnvironment.php @@ -39,16 +39,13 @@ public function __construct(\Twig_LoaderInterface $loader = NULL, $options = arr $this->cache_object = \Drupal::cache(); // Set twig path namespace for themes and modules. - $namespaces = array(); - foreach ($module_handler->getModuleList() as $name => $filename) { - $namespaces[$name] = dirname($filename); - } - foreach ($theme_handler->listInfo() as $name => $extension) { - $namespaces[$name] = $extension->getPath(); + $namespaces = $module_handler->getModuleList(); + foreach ($theme_handler->listInfo() as $theme => $info) { + $namespaces[$theme] = $info->filename; } - foreach ($namespaces as $name => $path) { - $templatesDirectory = $path . '/templates'; + foreach ($namespaces as $name => $filename) { + $templatesDirectory = dirname($filename) . '/templates'; if (file_exists($templatesDirectory)) { $loader->addPath($templatesDirectory, $name); } diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php index 7efae71..9cd17b0 100644 --- a/core/lib/Drupal/Core/Template/TwigExtension.php +++ b/core/lib/Drupal/Core/Template/TwigExtension.php @@ -21,24 +21,25 @@ public function getFunctions() { // @todo re-add unset => twig_unset if this is really needed return array( // @todo Remove URL function once http://drupal.org/node/1778610 is resolved. - new \Twig_SimpleFunction('url', 'url'), - // This function will receive a renderable array, if an array is detected. - new \Twig_SimpleFunction('render_var', 'twig_render_var'), + 'url' => new \Twig_Function_Function('url'), + // These functions will receive a TwigReference object, if a render array is detected + 'hide' => new TwigReferenceFunction('twig_hide'), + 'render_var' => new TwigReferenceFunction('twig_render_var'), + 'show' => new TwigReferenceFunction('twig_show'), ); } public function getFilters() { return array( - new \Twig_SimpleFilter('t', 't'), - new \Twig_SimpleFilter('trans', 't'), + 't' => new \Twig_Filter_Function('t'), + 'trans' => new \Twig_Filter_Function('t'), // The "raw" filter is not detectable when parsing "trans" tags. To detect // which prefix must be used for translation (@, !, %), we must clone the // "raw" filter and give it identifiable names. These filters should only // be used in "trans" tags. // @see TwigNodeTrans::compileString() - new \Twig_SimpleFilter('passthrough', 'twig_raw_filter'), - new \Twig_SimpleFilter('placeholder', 'twig_raw_filter'), - new \Twig_SimpleFilter('without', 'twig_without'), + 'passthrough' => new \Twig_Filter_Function('twig_raw_filter'), + 'placeholder' => new \Twig_Filter_Function('twig_raw_filter'), ); } @@ -52,6 +53,8 @@ public function getNodeVisitors() { public function getTokenParsers() { return array( + new TwigFunctionTokenParser('hide'), + new TwigFunctionTokenParser('show'), new TwigTransTokenParser(), ); } diff --git a/core/lib/Drupal/Core/Template/TwigNodeExpressionNameReference.php b/core/lib/Drupal/Core/Template/TwigNodeExpressionNameReference.php new file mode 100644 index 0000000..c66d73f --- /dev/null +++ b/core/lib/Drupal/Core/Template/TwigNodeExpressionNameReference.php @@ -0,0 +1,29 @@ +getAttribute('name'); + $compiler + ->raw('$this->getContextReference($context, ') + ->string($name) + ->raw(')'); + } + +} diff --git a/core/lib/Drupal/Core/Template/TwigNodeVisitor.php b/core/lib/Drupal/Core/Template/TwigNodeVisitor.php index 64315fb..710faa0 100644 --- a/core/lib/Drupal/Core/Template/TwigNodeVisitor.php +++ b/core/lib/Drupal/Core/Template/TwigNodeVisitor.php @@ -19,9 +19,36 @@ class TwigNodeVisitor implements \Twig_NodeVisitorInterface { /** - * {@inheritdoc} + * TRUE when this node is a function getting arguments by reference. + * + * For example: 'hide' or 'render' are such functions. + * + * @var bool + */ + protected $isReference = FALSE; + + /** + * Implements Twig_NodeVisitorInterface::enterNode(). */ function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env) { + if ($node instanceof \Twig_Node_Expression_Function) { + $name = $node->getAttribute('name'); + $func = $env->getFunction($name); + + // Optimization: Do not support nested functions. + if ($this->isReference && $func instanceof \Twig_Function_Function) { + $this->isReference = FALSE; + } + if ($func instanceof TwigReferenceFunction) { + // We need to create a TwigReference + $this->isReference = TRUE; + } + } + if ($node instanceof \Twig_Node_Print) { + // Our injected render_var needs arguments passed by reference -- in case of render array + $this->isReference = TRUE; + } + return $node; } @@ -35,14 +62,26 @@ function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env) { */ function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env) { if ($node instanceof \Twig_Node_Print) { + $this->isReference = FALSE; + $class = get_class($node); - $line = $node->getLine(); return new $class( - new \Twig_Node_Expression_Function('render_var', new \Twig_Node(array($node->getNode('expr'))), $line), - $line + new \Twig_Node_Expression_Function('render_var', new \Twig_Node(array($node->getNode('expr'))), $node->getLine()), + $node->getLine() ); } + if ($this->isReference) { + if ($node instanceof \Twig_Node_Expression_Name) { + $name = $node->getAttribute('name'); + return new TwigNodeExpressionNameReference($name, $node->getLine()); + } + elseif ($node instanceof \Twig_Function_Function) { + // Do something! + $this->isReference = FALSE; + } + } + return $node; } diff --git a/core/lib/Drupal/Core/Template/TwigReference.php b/core/lib/Drupal/Core/Template/TwigReference.php new file mode 100644 index 0000000..0b8b506 --- /dev/null +++ b/core/lib/Drupal/Core/Template/TwigReference.php @@ -0,0 +1,131 @@ +setReference($variable); + * @endcode + * + * When a TwigReference is accessed via the offsetGet method the resulting + * reference is again wrapped within a TwigReference. Therefore references to + * render arrays within render arrays are also retained. + * + * To unwrap TwigReference objects the reference can be retrieved out of the + * object by calling the getReference() method like this: + * @code + * $variable = &$obj->getReference(); + * @endcode + * This allows render(), hide() and show() to access the original variable and + * change it. The process of unwrapping and passing by reference to this + * functions is done transparently by the TwigReferenceFunctions helper class. + * + * @see TwigReferenceFunction + * @see TwigReferenceFunctions + */ +class TwigReference extends \ArrayObject { + + /** + * Holds an internal reference to the original array. + * + * @var array + */ + protected $writableRef = array(); + + /** + * Constructs a \Drupal\Core\Template\TwigReference object. + * + * The argument to the constructor is ignored as it is not safe that this will + * always be a reference. + * + * To set a reference use: + * @code + * $obj = new TwigReference(); + * $obj->setReference($variable); + * @endcode + * + * @param $array + * The array parameter is ignored and not passed to the parent + */ + public function __construct($array = NULL) { + parent::__construct(); + } + + /** + * Sets a reference in the internal storage. + * + * @param $array + * The array to set as internal reference. + */ + public function setReference(&$array) { + $this->exchangeArray($array); + $this->writableRef = &$array; + } + + /** + * Gets a reference to the internal storage. + * + * Should be called like: + * @code + * $reference = &$obj->getReference(); + * @endcode + * + * @return + * Returns the stored internal reference. + */ + public function &getReference() { + return $this->writableRef; + } + + /** + * Sets offset in internal reference and internal storage to value. + * + * This is just for completeness, but should never be used, because + * twig cannot set properties and should not. + * + * @link http://php.net/manual/en/arrayaccess.offsetset.php + * @param mixed $offset + * The offset to assign the value to. + * @param mixed $value + * The value to set. + */ + public function offsetSet($offset, $value) { + $this->writableRef[$offset] = $value; + parent::offsetSet($offset, $value); + } + + /** + * Retrieves offset from internal reference. + * + * In case of a render array, it is wrapped again within a TwigReference + * object. + * + * @param mixed $offset + * The offset to retrieve. + * + * @return mixed + * Returns a TwigReference object wrapping the array if the retrieved offset + * is a complex array (i.e. not an attribute). Else it returns the retrived + * offset directly. + */ + public function offsetGet($offset) { + if (!is_array($this->writableRef[$offset]) || $offset[0] == '#') { + return $this->writableRef[$offset]; + } + + // Wrap the returned array in a new TwigReference. + $x = clone $this; // clone is faster than new + $x->setReference($this->writableRef[$offset]); + return $x; + } +} diff --git a/core/lib/Drupal/Core/Template/TwigReferenceFunction.php b/core/lib/Drupal/Core/Template/TwigReferenceFunction.php new file mode 100644 index 0000000..6ca4cbd --- /dev/null +++ b/core/lib/Drupal/Core/Template/TwigReferenceFunction.php @@ -0,0 +1,14 @@ +setReference($content); + * return $obj; + * } + * + * // [...] + * // Simplified, generated twig code + * $_content_ = getContextReference($content); + * + * Drupal\Core\Template\TwigReferenceFunctions::hide( + * getAttribute($_content_, 'links') + * ); + * @endcode + * A TwigReference object is passed to the __callStatic function of + * TwigReferenceFunctions. The method unwraps the TwigReference and calls the + * hide() method essentially with a reference to $content['links']. + * + * Therefore the hidden property is correctly set and a successive call to + * render() will not render the content twice. + * + * @see TwigReference + * @see TwigReferenceFunction + * @see TwigFactory + * + */ +class TwigReferenceFunctions { + + /** + * Magic function to call functions called from twig templates with a + * reference to the original variable. + * + * This checks if the array provided by value is containing a reference to + * the original version. If yes it replaces the argument with its reference. + * + * @param $name + * The name of the function to call. + * @param $arguments + * The arguments to process and pass to the called function. + * + * @return mixed + * Returns the output of the called function. + * + * @see TwigReference + */ + public static function __callStatic($name, $arguments) { + foreach ($arguments as $key => $val) { + if (is_object($val) && $val instanceof TwigReference) { + $arguments[$key] = &$val->getReference(); + } + } + + // Needed to pass by reference -- could also restrict to maximum one + // argument instead + $args = array(); + foreach ($arguments as $key => &$arg) { + $args[$key] = &$arg; + } + + return call_user_func_array($name, $args); + } +} diff --git a/core/lib/Drupal/Core/Template/TwigTemplate.php b/core/lib/Drupal/Core/Template/TwigTemplate.php new file mode 100644 index 0000000..cfa0e15 --- /dev/null +++ b/core/lib/Drupal/Core/Template/TwigTemplate.php @@ -0,0 +1,89 @@ + $item))); + trigger_error($msg->getMessage(), E_USER_WARNING); + return NULL; + } + + // Return item instead of its reference inside a loop. + // @todo 'hide' and 'show' are not supported inside a loop for now. + // This should be a non-issue as soon as this lands: + // @see http://drupal.org/node/1922304 + if (isset($context['_seq'])) { + return $context[$item]; + } + + // The first test also finds empty / null render arrays + if (!$context[$item] || isset($this->is_no_reference[$item])) { + return $context[$item]; + } + + if (isset($context['_references'][$item])) { + return $context['_references'][$item]; + } + + // @todo Check if this is a render array (existence of #theme?) + if ((!isset($this->is_reference[$item])) && ($context[$item] instanceof \TwigMarkup || !is_array($context[$item]))) { + $this->is_no_reference[$item] = TRUE; + return $context[$item]; + } + + if ($this->twig_reference == NULL) { + $this->twig_reference = new TwigReference(); + } + $ref = clone $this->twig_reference; // clone is _much_ faster than new + $ref->setReference($context[$item]); + + // Save that this is a reference + $context['_references'][$item] = $ref; + $this->is_reference[$item] = TRUE; + + return $ref; + } +} diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php index e84b33b..1d3cb22 100644 --- a/core/lib/Drupal/Core/Theme/Registry.php +++ b/core/lib/Drupal/Core/Theme/Registry.php @@ -154,7 +154,7 @@ protected function init($theme_name = NULL) { } // #2: The testing framework only cares for the global $theme variable at // this point. Cope with that. - if ($GLOBALS['theme'] != $GLOBALS['theme_info']->getName()) { + if ($GLOBALS['theme'] != $GLOBALS['theme_info']->name) { unset($this->runtimeRegistry); unset($this->registry); $this->initializeTheme(); @@ -207,7 +207,7 @@ public function get() { if (isset($this->registry)) { return $this->registry; } - if ($cache = $this->cache->get('theme_registry:' . $this->theme->getName())) { + if ($cache = $this->cache->get('theme_registry:' . $this->theme->name)) { $this->registry = $cache->data; } else { @@ -230,7 +230,7 @@ public function get() { */ public function getRuntime() { if (!isset($this->runtimeRegistry)) { - $this->runtimeRegistry = new ThemeRegistry('theme_registry:runtime:' . $this->theme->getName(), $this->cache, $this->lock, array('theme_registry' => TRUE), $this->moduleHandler->isLoaded()); + $this->runtimeRegistry = new ThemeRegistry('theme_registry:runtime:' . $this->theme->name, $this->cache, $this->lock, array('theme_registry' => TRUE), $this->moduleHandler->isLoaded()); } return $this->runtimeRegistry; } @@ -239,7 +239,7 @@ public function getRuntime() { * Persists the theme registry in the cache backend. */ protected function setCache() { - $this->cache->set('theme_registry:' . $this->theme->getName(), $this->registry, Cache::PERMANENT, array('theme_registry' => TRUE)); + $this->cache->set('theme_registry:' . $this->theme->name, $this->registry, Cache::PERMANENT, array('theme_registry' => TRUE)); } /** @@ -319,20 +319,20 @@ protected function build() { // Process each base theme. foreach ($this->baseThemes as $base) { // If the base theme uses a theme engine, process its hooks. - $base_path = $base->getPath(); + $base_path = dirname($base->filename); if ($this->engine) { - $this->processExtension($cache, $this->engine, 'base_theme_engine', $base->getName(), $base_path); + $this->processExtension($cache, $this->engine, 'base_theme_engine', $base->name, $base_path); } - $this->processExtension($cache, $base->getName(), 'base_theme', $base->getName(), $base_path); + $this->processExtension($cache, $base->name, 'base_theme', $base->name, $base_path); } // And then the same thing, but for the theme. if ($this->engine) { - $this->processExtension($cache, $this->engine, 'theme_engine', $this->theme->getName(), $this->theme->getPath()); + $this->processExtension($cache, $this->engine, 'theme_engine', $this->theme->name, dirname($this->theme->filename)); } // Finally, hooks provided by the theme itself. - $this->processExtension($cache, $this->theme->getName(), 'theme', $this->theme->getName(), $this->theme->getPath()); + $this->processExtension($cache, $this->theme->name, 'theme', $this->theme->name, dirname($this->theme->filename)); // Let modules alter the registry. $this->moduleHandler->alter('theme_registry', $cache); diff --git a/core/lib/Drupal/Core/Theme/ThemeSettings.php b/core/lib/Drupal/Core/Theme/ThemeSettings.php index 6749f01..d20b843 100644 --- a/core/lib/Drupal/Core/Theme/ThemeSettings.php +++ b/core/lib/Drupal/Core/Theme/ThemeSettings.php @@ -7,12 +7,12 @@ namespace Drupal\Core\Theme; -use Drupal\Core\Config\ConfigBase; +use Drupal\Component\Utility\NestedArray; /** * Defines the default theme settings object. */ -class ThemeSettings extends ConfigBase { +class ThemeSettings { /** * The theme of the theme settings object. @@ -22,13 +22,21 @@ class ThemeSettings extends ConfigBase { protected $theme; /** + * The data of the theme settings object. + * + * @var array + */ + protected $data; + + /** * Constructs a theme settings object. * - * @param string $theme + * @param string $name * The name of the theme settings object being constructed. */ public function __construct($theme) { $this->theme = $theme; + $this->data = array(); } /** @@ -40,4 +48,113 @@ public function __construct($theme) { public function getTheme() { return $this->theme; } + + /** + * Gets data from this theme settings object. + * + * @param string $key + * A string that maps to a key within the theme settings data. + * For instance in the following theme settings array: + * @code + * array( + * 'foo' => array( + * 'bar' => 'baz', + * ), + * ); + * @endcode + * A key of 'foo.bar' would return the string 'baz'. However, a key of 'foo' + * would return array('bar' => 'baz'). + * If no key is specified, then the entire data array is returned. + * + * + * @return mixed + * The data that was requested. + */ + public function get($key = '') { + if (empty($key)) { + return $this->data; + } + else { + $parts = explode('.', $key); + if (count($parts) == 1) { + return isset($this->data[$key]) ? $this->data[$key] : NULL; + } + else { + $value = NestedArray::getValue($this->data, $parts, $key_exists); + return $key_exists ? $value : NULL; + } + } + } + + /** + * Replaces the data of this theme settings object. + * + * @param array $data + * The new theme settings data. + * + * @return \Drupal\Core\Theme\ThemeSettings + * The theme settings object. + */ + public function setData(array $data) { + $this->data = $data; + return $this; + } + + /** + * Sets value in this theme settings object. + * + * @param string $key + * Identifier to store value in theme settings. + * @param string $value + * Value to associate with identifier. + * + * @return \Drupal\Core\Theme\ThemeSettings + * The theme settings object. + */ + public function set($key, $value) { + // The dot/period is a reserved character; it may appear between keys, but + // not within keys. + $parts = explode('.', $key); + if (count($parts) == 1) { + $this->data[$key] = $value; + } + else { + NestedArray::setValue($this->data, $parts, $value); + } + return $this; + } + + /** + * Unsets value in this theme settings object. + * + * @param string $key + * Name of the key whose value should be unset. + * + * @return \Drupal\Core\Theme\ThemeSettings + * The theme settings object. + */ + public function clear($key) { + $parts = explode('.', $key); + if (count($parts) == 1) { + unset($this->data[$key]); + } + else { + NestedArray::unsetValue($this->data, $parts); + } + return $this; + } + + /** + * Merges the data into this theme settings object. + * + * @param array $data + * Theme settings data to merge. + * + * @return \Drupal\Core\Theme\ThemeSettings + * The theme settings object. + */ + public function mergeData ($data) { + $this->data = NestedArray::mergeDeep($this->data, $data); + return $this; + } } diff --git a/core/lib/Drupal/Core/TypedData/ComplexDataInterface.php b/core/lib/Drupal/Core/TypedData/ComplexDataInterface.php index 581e79c..452b602 100644 --- a/core/lib/Drupal/Core/TypedData/ComplexDataInterface.php +++ b/core/lib/Drupal/Core/TypedData/ComplexDataInterface.php @@ -63,7 +63,7 @@ public function set($property_name, $value, $notify = TRUE); * @param bool $include_computed * If set to TRUE, computed properties are included. Defaults to FALSE. * - * @return \Drupal\Core\TypedData\TypedDataInterface[] + * @return array * An array of property objects implementing the TypedDataInterface, keyed * by property name. */ diff --git a/core/lib/Drupal/Core/Utility/ProjectInfo.php b/core/lib/Drupal/Core/Utility/ProjectInfo.php index 2a49c8c..e109c78 100644 --- a/core/lib/Drupal/Core/Utility/ProjectInfo.php +++ b/core/lib/Drupal/Core/Utility/ProjectInfo.php @@ -9,8 +9,6 @@ namespace Drupal\Core\Utility; -use Drupal\Core\Extension\Extension; - /** * Performs operations on drupal.org project data. */ @@ -96,7 +94,8 @@ function processInfoList(array &$projects, array $list, $project_type, $status, // 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'])) { - $file->info['_info_file_ctime'] = $file->getCTime(); + $info_filename = dirname($file->uri) . '/' . $file->name . '.info.yml'; + $file->info['_info_file_ctime'] = filectime($info_filename); } if (!isset($file->info['datestamp'])) { @@ -143,7 +142,7 @@ function processInfoList(array &$projects, array $list, $project_type, $status, // not bloat our RAM usage needlessly. 'info' => $this->filterProjectInfo($file->info, $additional_whitelist), 'datestamp' => $file->info['datestamp'], - 'includes' => array($file->getName() => $file->info['name']), + 'includes' => array($file->name => $file->info['name']), 'project_type' => $project_display_type, 'project_status' => $status, 'sub_themes' => $sub_themes, @@ -156,7 +155,7 @@ function processInfoList(array &$projects, array $list, $project_type, $status, // $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->getName()] = $file->info['name']; + $projects[$project_name]['includes'][$file->name] = $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)) { @@ -171,7 +170,7 @@ function processInfoList(array &$projects, array $list, $project_type, $status, // 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->getName()] = $file->info['name']; + $projects[$project_name]['disabled'][$file->name] = $file->info['name']; } } } @@ -185,12 +184,12 @@ function processInfoList(array &$projects, array $list, $project_type, $status, * @return string * The canonical project short name. */ - function getProjectName(Extension $file) { + function getProjectName($file) { $project_name = ''; if (isset($file->info['project'])) { $project_name = $file->info['project']; } - elseif (strpos($file->getPath(), 'core/modules') === 0) { + elseif (isset($file->filename) && (strpos($file->filename, 'core/modules') === 0)) { $project_name = 'drupal'; } return $project_name; diff --git a/core/lib/Drupal/Core/Utility/Title.php b/core/lib/Drupal/Core/Utility/Title.php index 40a3a91..b6380b6 100644 --- a/core/lib/Drupal/Core/Utility/Title.php +++ b/core/lib/Drupal/Core/Utility/Title.php @@ -22,9 +22,4 @@ class Title { */ const FILTER_XSS_ADMIN = 1; - /** - * For controller titles, text has already been sanitized. - */ - const PASS_THROUGH = -1; - } diff --git a/core/modules/action/lib/Drupal/action/Tests/BulkFormTest.php b/core/modules/action/lib/Drupal/action/Tests/BulkFormTest.php index d5dda7a..dde3914 100644 --- a/core/modules/action/lib/Drupal/action/Tests/BulkFormTest.php +++ b/core/modules/action/lib/Drupal/action/Tests/BulkFormTest.php @@ -8,7 +8,6 @@ namespace Drupal\action\Tests; use Drupal\simpletest\WebTestBase; -use Drupal\views\Views; /** * Tests the views bulk form test. @@ -97,7 +96,7 @@ public function testBulkForm() { $this->assertTrue($node->isPublished(), 'An unchecked node is still published.'); // Set up to include just the sticky actions. - $view = Views::getView('test_bulk_form'); + $view = views_get_view('test_bulk_form'); $display = &$view->storage->getDisplay('default'); $display['display_options']['fields']['node_bulk_form']['include_exclude'] = 'include'; $display['display_options']['fields']['node_bulk_form']['selected_actions']['node_make_sticky_action'] = 'node_make_sticky_action'; @@ -111,7 +110,7 @@ public function testBulkForm() { $this->assertOption('edit-action', 'node_make_unsticky_action'); // Set up to exclude the sticky actions. - $view = Views::getView('test_bulk_form'); + $view = views_get_view('test_bulk_form'); $display = &$view->storage->getDisplay('default'); $display['display_options']['fields']['node_bulk_form']['include_exclude'] = 'exclude'; $view->save(); @@ -126,7 +125,7 @@ public function testBulkForm() { $this->assertEqual('With selection', (string) $result[0]); // Setup up a different bulk form title. - $view = Views::getView('test_bulk_form'); + $view = views_get_view('test_bulk_form'); $display = &$view->storage->getDisplay('default'); $display['display_options']['fields']['node_bulk_form']['action_title'] = 'Test title'; $view->save(); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php b/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php index 5e89acf..f7313cc 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php @@ -174,7 +174,7 @@ public function adminOverview() { } $build['feeds'] = array( '#prefix' => '

' . $this->t('Feed overview') . '

', - '#type' => 'table', + '#theme' => 'table', '#header' => $header, '#rows' => $rows, '#empty' => $this->t('No feeds available. Add feed.', array('@link' => $this->urlGenerator()->generateFromPath('admin/config/services/aggregator/add/feed'))), diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php index 1ba376b..c1eda08 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php @@ -9,6 +9,7 @@ use Drupal\aggregator\FeedStorageControllerInterface; use Drupal\Component\Utility\UrlHelper; +use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Form\FormBase; use Symfony\Component\DependencyInjection\ContainerInterface; use Guzzle\Http\Exception\RequestException; @@ -21,6 +22,13 @@ class OpmlFeedAdd extends FormBase { /** + * The entity query factory object. + * + * @var \Drupal\Core\Entity\Query\QueryFactory + */ + protected $queryFactory; + + /** * The feed storage. * * @var \Drupal\aggregator\FeedStorageControllerInterface @@ -37,12 +45,15 @@ class OpmlFeedAdd extends FormBase { /** * Constructs a database object. * + * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory + * The entity query object. * @param \Drupal\aggregator\FeedStorageControllerInterface $feed_storage * The feed storage. * @param \Guzzle\Http\ClientInterface $http_client * The Guzzle HTTP client. */ - public function __construct(FeedStorageControllerInterface $feed_storage, ClientInterface $http_client) { + public function __construct(QueryFactory $query_factory, FeedStorageControllerInterface $feed_storage, ClientInterface $http_client) { + $this->queryFactory = $query_factory; $this->feedStorageController = $feed_storage; $this->httpClient = $http_client; } @@ -52,6 +63,7 @@ public function __construct(FeedStorageControllerInterface $feed_storage, Client */ public static function create(ContainerInterface $container) { return new static( + $container->get('entity.query'), $container->get('entity.manager')->getStorageController('aggregator_feed'), $container->get('http_default_client') ); @@ -152,7 +164,7 @@ public function submitForm(array &$form, array &$form_state) { } // Check for duplicate titles or URLs. - $query = $this->feedStorageController->getQuery(); + $query = $this->queryFactory->get('aggregator_feed'); $condition = $query->orConditionGroup() ->condition('title', $feed['title']) ->condition('url', $feed['url']); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/Views/IntegrationTest.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/Views/IntegrationTest.php index f129067..6fd1f93 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/Views/IntegrationTest.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/Views/IntegrationTest.php @@ -7,7 +7,6 @@ namespace Drupal\aggregator\Tests\Views; -use Drupal\views\Views; use Drupal\views\Tests\ViewTestData; use Drupal\views\Tests\ViewUnitTestBase; @@ -87,7 +86,7 @@ public function testAggregatorItemView() { $expected[] = $values; } - $view = Views::getView('test_aggregator_items'); + $view = views_get_view('test_aggregator_items'); $this->executeView($view); $column_map = array( diff --git a/core/modules/ban/lib/Drupal/ban/Form/BanAdmin.php b/core/modules/ban/lib/Drupal/ban/Form/BanAdmin.php index bfaeb7a..29ca186 100644 --- a/core/modules/ban/lib/Drupal/ban/Form/BanAdmin.php +++ b/core/modules/ban/lib/Drupal/ban/Form/BanAdmin.php @@ -90,7 +90,7 @@ public function buildForm(array $form, array &$form_state, $default_ip = '') { ); $form['ban_ip_banning_table'] = array( - '#type' => 'table', + '#theme' => 'table', '#header' => $header, '#rows' => $rows, '#empty' => $this->t('No blocked IP addresses available.'), diff --git a/core/modules/basic_auth/basic_auth.services.yml b/core/modules/basic_auth/basic_auth.services.yml index 4c7a449..13a6cb1 100644 --- a/core/modules/basic_auth/basic_auth.services.yml +++ b/core/modules/basic_auth/basic_auth.services.yml @@ -1,6 +1,6 @@ services: authentication.basic_auth: class: Drupal\basic_auth\Authentication\Provider\BasicAuth - arguments: ['@config.factory', '@user.auth'] + arguments: ['@config.factory'] tags: - { name: authentication_provider, priority: 100 } diff --git a/core/modules/basic_auth/lib/Drupal/basic_auth/Authentication/Provider/BasicAuth.php b/core/modules/basic_auth/lib/Drupal/basic_auth/Authentication/Provider/BasicAuth.php index 579d8a0..282b891 100644 --- a/core/modules/basic_auth/lib/Drupal/basic_auth/Authentication/Provider/BasicAuth.php +++ b/core/modules/basic_auth/lib/Drupal/basic_auth/Authentication/Provider/BasicAuth.php @@ -11,7 +11,6 @@ use Drupal\Core\Authentication\AuthenticationProviderInterface; use Drupal\Core\Config\Config; use Drupal\Core\Config\ConfigFactoryInterface; -use Drupal\user\UserAuthInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; @@ -30,21 +29,13 @@ class BasicAuth implements AuthenticationProviderInterface { protected $configFactory; /** - * The user auth service. - * - * @var \Drupal\user\UserAuthInterface - */ - protected $userAuth; - - /** * Constructs a HTTP basic authentication provider object. * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. */ - public function __construct(ConfigFactoryInterface $config_factory, UserAuthInterface $user_auth) { + public function __construct(ConfigFactoryInterface $config_factory) { $this->configFactory = $config_factory; - $this->userAuth = $user_auth; } /** @@ -62,7 +53,7 @@ public function applies(Request $request) { public function authenticate(Request $request) { $username = $request->headers->get('PHP_AUTH_USER'); $password = $request->headers->get('PHP_AUTH_PW'); - $uid = $this->userAuth->authenticate($username, $password); + $uid = user_authenticate($username, $password); if ($uid) { return user_load($uid); } diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 6f341ad..1bca18b 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -199,7 +199,7 @@ function _block_get_renderable_region($list = array()) { $settings = $block->get('settings'); if ($not_cacheable || in_array($settings['cache'], array(DRUPAL_NO_CACHE, DRUPAL_CACHE_CUSTOM))) { // Non-cached blocks get built immediately. - if ($block->access('view')) { + if ($block->access()) { $build[$key] = entity_view($block, 'block'); } } @@ -378,7 +378,7 @@ function block_load($entity_id) { function _block_get_renderable_block($element) { $block = $element['#block']; // Don't bother to build blocks that aren't accessible. - if ($element['#access'] = $block->access('view')) { + if ($element['#access'] = $block->access()) { $element += entity_view($block, 'block'); } return $element; diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlockType.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlockType.php index 59a4735..48bef95 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlockType.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlockType.php @@ -49,6 +49,13 @@ class CustomBlockType extends ConfigEntityBase implements CustomBlockTypeInterfa public $id; /** + * The custom block type UUID. + * + * @var string + */ + public $uuid; + + /** * The custom block type label. * * @var string diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php index f93b413..b2fa6b5 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php @@ -17,7 +17,7 @@ class CustomBlock extends DerivativeBase { /** * {@inheritdoc} */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { $custom_blocks = entity_load_multiple('custom_block'); foreach ($custom_blocks as $custom_block) { $this->derivatives[$custom_block->uuid()] = $base_plugin_definition; diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php index 4ce4c81..08bf090 100644 --- a/core/modules/block/lib/Drupal/block/BlockFormController.php +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php @@ -11,6 +11,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityFormController; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\language\ConfigurableLanguageManagerInterface; @@ -36,6 +37,13 @@ class BlockFormController extends EntityFormController { protected $storageController; /** + * The entity query factory. + * + * @var \Drupal\Core\Entity\Query\QueryFactory + */ + protected $entityQueryFactory; + + /** * The language manager. * * @var \Drupal\Core\Language\LanguageManagerInterface @@ -54,13 +62,16 @@ class BlockFormController extends EntityFormController { * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. + * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query_factory + * The entity query factory. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. */ - public function __construct(EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory) { + public function __construct(EntityManagerInterface $entity_manager, QueryFactory $entity_query_factory, LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory) { $this->storageController = $entity_manager->getStorageController('block'); + $this->entityQueryFactory = $entity_query_factory; $this->languageManager = $language_manager; $this->configFactory = $config_factory; } @@ -71,6 +82,7 @@ public function __construct(EntityManagerInterface $entity_manager, LanguageMana public static function create(ContainerInterface $container) { return new static( $container->get('entity.manager'), + $container->get('entity.query'), $container->get('language_manager'), $container->get('config.factory') ); @@ -361,7 +373,7 @@ public function getUniqueMachineName(BlockInterface $block) { $suggestion = $block->getPlugin()->getMachineNameSuggestion(); // Get all the blocks which starts with the suggested machine name. - $query = $this->storageController->getQuery(); + $query = $this->entityQueryFactory->get('block'); $query->condition('id', $suggestion, 'CONTAINS'); $block_ids = $query->execute(); diff --git a/core/modules/block/lib/Drupal/block/BlockListController.php b/core/modules/block/lib/Drupal/block/BlockListController.php index 65db261..413054c 100644 --- a/core/modules/block/lib/Drupal/block/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/BlockListController.php @@ -145,9 +145,9 @@ public function buildForm(array $form, array &$form_state) { } $entities = $this->load(); $form['#theme'] = array('block_list'); - $form['#attached']['library'][] = 'core/drupal.tableheader'; - $form['#attached']['library'][] = 'block/drupal.block'; - $form['#attached']['library'][] = 'block/drupal.block.admin'; + $form['#attached']['library'][] = array('core', 'drupal.tableheader'); + $form['#attached']['library'][] = array('block', 'drupal.block'); + $form['#attached']['library'][] = array('block', 'drupal.block.admin'); $form['#attributes']['class'][] = 'clearfix'; // Add a last region for disabled blocks. diff --git a/core/modules/block/lib/Drupal/block/Controller/BlockController.php b/core/modules/block/lib/Drupal/block/Controller/BlockController.php index ebd9bc9..f2ebb41 100644 --- a/core/modules/block/lib/Drupal/block/Controller/BlockController.php +++ b/core/modules/block/lib/Drupal/block/Controller/BlockController.php @@ -41,7 +41,7 @@ public function demo($theme) { ) ), 'library' => array( - 'block/drupal.block.admin', + array('block', 'drupal.block.admin'), ), ), ); diff --git a/core/modules/block/lib/Drupal/block/Entity/Block.php b/core/modules/block/lib/Drupal/block/Entity/Block.php index e44d028..c0d4de9 100644 --- a/core/modules/block/lib/Drupal/block/Entity/Block.php +++ b/core/modules/block/lib/Drupal/block/Entity/Block.php @@ -10,7 +10,6 @@ use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\block\BlockPluginBag; use Drupal\block\BlockInterface; -use Drupal\Core\Config\Entity\ConfigEntityInterface; use Drupal\Core\Config\Entity\EntityWithPluginBagInterface; /** @@ -50,6 +49,13 @@ class Block extends ConfigEntityBase implements BlockInterface, EntityWithPlugin public $id; /** + * The block UUID. + * + * @var string + */ + public $uuid; + + /** * The plugin instance settings. * * @var array @@ -149,7 +155,7 @@ public function getExportProperties() { /** * Sorts active blocks by weight; sorts inactive blocks by name. */ - public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) { + public static function sort($a, $b) { // Separate enabled from disabled. $status = $b->get('status') - $a->get('status'); if ($status) { diff --git a/core/modules/block/lib/Drupal/block/Plugin/Derivative/ThemeLocalTask.php b/core/modules/block/lib/Drupal/block/Plugin/Derivative/ThemeLocalTask.php index be4cad5..055ab48 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/Derivative/ThemeLocalTask.php +++ b/core/modules/block/lib/Drupal/block/Plugin/Derivative/ThemeLocalTask.php @@ -58,7 +58,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) { /** * {@inheritdoc} */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { $default_theme = $this->config->get('default'); foreach ($this->themeHandler->listInfo() as $theme_name => $theme) { diff --git a/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php b/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php index 8f2ddc0..3c9745f 100644 --- a/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php @@ -8,7 +8,6 @@ namespace Drupal\block\Tests\Views; use Drupal\Component\Utility\String; -use Drupal\views\Views; use Drupal\views\Tests\ViewTestBase; use Drupal\views\Tests\ViewTestData; use Drupal\Core\Template\Attribute; @@ -146,7 +145,7 @@ protected function testDeleteBlockDisplay() { // Remove the block display, so both block entities from the first view // should both disappear. - $view = Views::getView('test_view_block'); + $view = views_get_view('test_view_block'); $view->initDisplay(); $view->displayHandlers->remove('block_1'); $view->storage->save(); @@ -163,7 +162,7 @@ protected function testDeleteBlockDisplay() { // Remove the first block display of the second view and ensure the block // instance of the second block display still exists. - $view = Views::getView('test_view_block2'); + $view = views_get_view('test_view_block2'); $view->initDisplay(); $view->displayHandlers->remove('block_1'); $view->storage->save(); diff --git a/core/modules/block/templates/block-list.html.twig b/core/modules/block/templates/block-list.html.twig index 474c654..873d192 100644 --- a/core/modules/block/templates/block-list.html.twig +++ b/core/modules/block/templates/block-list.html.twig @@ -13,9 +13,10 @@ * @ingroup themeable */ #} +{% hide(form.place_blocks) %}
- {{ form|without('place_blocks') }} + {{ form }}
{{ form.place_blocks }} diff --git a/core/modules/block/tests/Drupal/block/Tests/BlockFormControllerTest.php b/core/modules/block/tests/Drupal/block/Tests/BlockFormControllerTest.php index aa54731..5d9f692 100644 --- a/core/modules/block/tests/Drupal/block/Tests/BlockFormControllerTest.php +++ b/core/modules/block/tests/Drupal/block/Tests/BlockFormControllerTest.php @@ -31,6 +31,7 @@ public static function getInfo() { * @see \Drupal\block\BlockFormController::getUniqueMachineName() */ public function testGetUniqueMachineName() { + $block_storage = $this->getMock('Drupal\Core\Config\Entity\ConfigStorageControllerInterface'); $blocks = array(); $blocks['test'] = $this->getBlockMockWithMachineName('test'); @@ -38,7 +39,9 @@ public function testGetUniqueMachineName() { $blocks['other_test_1'] = $this->getBlockMockWithMachineName('other_test'); $blocks['other_test_2'] = $this->getBlockMockWithMachineName('other_test'); - $query = $this->getMock('Drupal\Core\Entity\Query\QueryInterface'); + $query = $this->getMockBuilder('Drupal\Core\Entity\Query\QueryInterface') + ->disableOriginalConstructor() + ->getMock(); $query->expects($this->exactly(5)) ->method('condition') ->will($this->returnValue($query)); @@ -47,9 +50,12 @@ public function testGetUniqueMachineName() { ->method('execute') ->will($this->returnValue(array('test', 'other_test', 'other_test_1', 'other_test_2'))); - $block_storage = $this->getMock('Drupal\Core\Config\Entity\ConfigStorageControllerInterface'); - $block_storage->expects($this->exactly(5)) - ->method('getQuery') + $query_factory = $this->getMockBuilder('Drupal\Core\Entity\Query\QueryFactory') + ->disableOriginalConstructor() + ->getMock(); + $query_factory->expects($this->exactly(5)) + ->method('get') + ->with('block', 'AND') ->will($this->returnValue($query)); $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); @@ -62,7 +68,7 @@ public function testGetUniqueMachineName() { $config_factory = $this->getMock('Drupal\Core\Config\ConfigFactoryInterface'); - $block_form_controller = new BlockFormController($entity_manager, $language_manager, $config_factory); + $block_form_controller = new BlockFormController($entity_manager, $query_factory, $language_manager, $config_factory); // Ensure that the block with just one other instance gets the next available // name suggestion. diff --git a/core/modules/book/lib/Drupal/book/BookManager.php b/core/modules/book/lib/Drupal/book/BookManager.php index 7b4f3f0..594e713 100644 --- a/core/modules/book/lib/Drupal/book/BookManager.php +++ b/core/modules/book/lib/Drupal/book/BookManager.php @@ -175,7 +175,7 @@ public function addFormElements(array $form, array &$form_state, NodeInterface $ 'class' => array('book-outline-form'), ), '#attached' => array( - 'library' => array('book/drupal.book'), + 'library' => array(array('book', 'drupal.book')), ), '#tree' => TRUE, ); diff --git a/core/modules/book/lib/Drupal/book/Controller/BookController.php b/core/modules/book/lib/Drupal/book/Controller/BookController.php index dec592c..49a4947 100644 --- a/core/modules/book/lib/Drupal/book/Controller/BookController.php +++ b/core/modules/book/lib/Drupal/book/Controller/BookController.php @@ -89,7 +89,7 @@ public function adminOverview() { $rows[] = $row; } return array( - '#type' => 'table', + '#theme' => 'table', '#header' => $headers, '#rows' => $rows, '#empty' => t('No books available.'), diff --git a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php index 02c1945..08ae4b6 100644 --- a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php @@ -52,6 +52,13 @@ class Breakpoint extends ConfigEntityBase implements BreakpointInterface { public $id; /** + * The breakpoint UUID. + * + * @var string + */ + public $uuid; + + /** * The breakpoint name (machine name) as specified by theme or module. * * @var string diff --git a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php index 80f10e0..f3807af 100644 --- a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php @@ -34,6 +34,13 @@ class BreakpointGroup extends ConfigEntityBase implements BreakpointGroupInterfa public $id; /** + * The breakpoint group UUID. + * + * @var string + */ + public $uuid; + + /** * The breakpoint group machine name. * * @var string diff --git a/core/modules/ckeditor/ckeditor.module b/core/modules/ckeditor/ckeditor.module index 7000dbf..bf1a8ec 100644 --- a/core/modules/ckeditor/ckeditor.module +++ b/core/modules/ckeditor/ckeditor.module @@ -48,10 +48,17 @@ function ckeditor_theme() { * Implements hook_ckeditor_css_alter(). */ function ckeditor_ckeditor_css_alter(array &$css, Editor $editor) { + $filters = array(); + if (!empty($editor->format)) { + $filters = entity_load('filter_format', $editor->format) + ->filters() + ->getAll(); + } + // Add the filter caption CSS if the text format associated with this text // editor uses the filter_caption filter. This is used by the included // CKEditor DrupalImageCaption plugin. - if ($editor->getFilterFormat()->filters('filter_caption')->status) { + if (isset($filters['filter_caption']) && $filters['filter_caption']->status) { $css[] = drupal_get_path('module', 'filter') . '/css/filter.caption.css'; } } diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/DrupalImage.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/DrupalImage.php index 04469c9..8e5f0ab 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/DrupalImage.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/DrupalImage.php @@ -34,7 +34,7 @@ public function getFile() { */ public function getLibraries(Editor $editor) { return array( - 'core/drupal.ajax', + array('core', 'drupal.ajax'), ); } @@ -69,7 +69,7 @@ public function getButtons() { public function settingsForm(array $form, array &$form_state, Editor $editor) { form_load_include($form_state, 'inc', 'editor', 'editor.admin'); $form['image_upload'] = editor_image_upload_settings_form($editor); - $form['image_upload']['#attached']['library'][] = 'ckeditor/drupal.ckeditor.drupalimage.admin'; + $form['image_upload']['#attached']['library'][] = array('ckeditor', 'drupal.ckeditor.drupalimage.admin'); $form['image_upload']['#element_validate'][] = array($this, 'validateImageUploadSettings'); return $form; } diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/DrupalImageCaption.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/DrupalImageCaption.php index 17881ce..bdbb7bb 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/DrupalImageCaption.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/DrupalImageCaption.php @@ -42,7 +42,7 @@ public function getDependencies(Editor $editor) { */ public function getLibraries(Editor $editor) { return array( - 'ckeditor/drupal.ckeditor.drupalimagecaption-theme', + array('ckeditor', 'drupal.ckeditor.drupalimagecaption-theme'), ); } @@ -64,10 +64,17 @@ public function getConfig(Editor $editor) { * {@inheritdoc} */ function isEnabled(Editor $editor) { + $filters = array(); + if (!empty($editor->format)) { + $filters = entity_load('filter_format', $editor->format) + ->filters() + ->getAll(); + } + // Automatically enable this plugin if the text format associated with this // text editor uses the filter_caption filter and the DrupalImage button is // enabled. - if ($editor->getFilterFormat()->filters('filter_caption')->status) { + if (isset($filters['filter_caption']) && $filters['filter_caption']->status) { $enabled = FALSE; foreach ($editor->settings['toolbar']['rows'] as $row) { foreach ($row as $group) { diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/DrupalLink.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/DrupalLink.php index 8ce0c7a..91a513a 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/DrupalLink.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/DrupalLink.php @@ -33,7 +33,7 @@ public function getFile() { */ public function getLibraries(Editor $editor) { return array( - 'core/drupal.ajax', + array('core', 'drupal.ajax'), ); } diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/Internal.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/Internal.php index 1e6eb5f..c683e3e 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/Internal.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/Internal.php @@ -286,7 +286,7 @@ protected function generateFormatTagsSetting(Editor $editor) { */ protected function generateAllowedContentSetting(Editor $editor) { // When nothing is disallowed, set allowedContent to true. - $format = $editor->getFilterFormat(); + $format = entity_load('filter_format', $editor->format); $filter_types = $format->getFilterTypes(); if (!in_array(FilterInterface::TYPE_HTML_RESTRICTOR, $filter_types)) { return TRUE; diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/StylesCombo.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/StylesCombo.php index 9b6142d..aa23043 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/StylesCombo.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/StylesCombo.php @@ -79,7 +79,7 @@ public function settingsForm(array $form, array &$form_state, Editor $editor) { '#default_value' => $config['styles'], '#description' => t('A list of classes that will be provided in the "Styles" dropdown. Enter one class on each line in the format: element.class|Label. Example: h1.title|Title.
These styles should be available in your theme\'s CSS file.'), '#attached' => array( - 'library' => array('ckeditor/drupal.ckeditor.stylescombo.admin'), + 'library' => array(array('ckeditor', 'drupal.ckeditor.stylescombo.admin')), ), '#element_validate' => array( array($this, 'validateStylesValue'), diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php index 2777f67..c10d989 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php @@ -136,7 +136,7 @@ public function settingsForm(array $form, array &$form_state, EditorEntity $edit $form['toolbar'] = array( '#type' => 'container', '#attached' => array( - 'library' => array('ckeditor/drupal.ckeditor.admin'), + 'library' => array(array('ckeditor', 'drupal.ckeditor.admin')), 'js' => array( array( 'type' => 'setting', @@ -353,14 +353,16 @@ public function getLangcodes() { */ public function getLibraries(EditorEntity $editor) { $libraries = array( - 'ckeditor/drupal.ckeditor', + array('ckeditor', 'drupal.ckeditor'), ); // Get the required libraries for any enabled plugins. $enabled_plugins = array_keys($this->ckeditorPluginManager->getEnabledPluginFiles($editor)); foreach ($enabled_plugins as $plugin_id) { $plugin = $this->ckeditorPluginManager->createInstance($plugin_id); - $additional_libraries = array_diff($plugin->getLibraries($editor), $libraries); + $additional_libraries = array_udiff($plugin->getLibraries($editor), $libraries, function($a, $b) { + return $a[0] === $b[0] && $a[1] === $b[1] ? 0 : 1; + }); $libraries = array_merge($libraries, $additional_libraries); } diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorAdminTest.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorAdminTest.php index 4b2e086..f984160 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorAdminTest.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorAdminTest.php @@ -163,7 +163,6 @@ function testAdmin() { // Now enable the ckeditor_test module, which provides one configurable // CKEditor plugin — this should not affect the Editor config entity. \Drupal::moduleHandler()->install(array('ckeditor_test')); - $this->rebuildContainer(); $this->container->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions(); $this->drupalGet('admin/config/content/formats/manage/filtered_html'); $ultra_llama_mode_checkbox = $this->xpath('//input[@type="checkbox" and @name="editor[settings][plugins][llama_contextual_and_button][ultra_llama_mode]" and not(@checked)]'); diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorPluginManagerTest.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorPluginManagerTest.php index 40485ee..db1c6a4 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorPluginManagerTest.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorPluginManagerTest.php @@ -81,7 +81,6 @@ function testEnabledPlugins() { // variations of it, to cover all possible ways a plugin can be enabled) and // clear the editor manager's cache so it is picked up. $this->enableModules(array('ckeditor_test')); - $this->manager = $this->container->get('plugin.manager.ckeditor.plugin'); $this->manager->clearCachedDefinitions(); // Case 2: CKEditor plugins are available. diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php index 7a6f3cc..4f59069 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php @@ -127,9 +127,6 @@ function testGetJSSettings() { $format = entity_load('filter_format', 'filtered_html'); $format->filters('filter_html')->settings['allowed_html'] .= '
 

'; $format->save(); - // $editor is a Text Editor object that has a statically cached FilterFormat - // which is now outdated. Therefore, reload it. - $editor = entity_load('editor', $editor->id()); $expected_config['allowedContent']['pre'] = array('attributes' => TRUE, 'styles' => FALSE, 'classes' => TRUE); $expected_config['allowedContent']['h3'] = array('attributes' => TRUE, 'styles' => FALSE, 'classes' => TRUE); $expected_config['format_tags'] = 'p;h3;h4;h5;h6;pre'; @@ -138,9 +135,6 @@ function testGetJSSettings() { // Disable the filter_html filter: allow *all *tags. $format->setFilterConfig('filter_html', array('status' => 0)); $format->save(); - // $editor is a Text Editor object that has a statically cached FilterFormat - // which is now outdated. Therefore, reload it. - $editor = entity_load('editor', $editor->id()); $expected_config['allowedContent'] = TRUE; $expected_config['format_tags'] = 'p;h1;h2;h3;h4;h5;h6;pre'; $this->assertIdentical($expected_config, $this->ckeditor->getJSSettings($editor), 'Generated JS settings are correct for customized configuration.'); @@ -174,9 +168,6 @@ function testGetJSSettings() { ), )); $format->save(); - // $editor is a Text Editor object that has a statically cached FilterFormat - // which is now outdated. Therefore, reload it. - $editor = entity_load('editor', $editor->id()); $expected_config['allowedContent'] = array( 'p' => array( 'attributes' => TRUE, diff --git a/core/modules/color/color.module b/core/modules/color/color.module index 7809f5f..5fc1532 100644 --- a/core/modules/color/color.module +++ b/core/modules/color/color.module @@ -202,7 +202,7 @@ function color_scheme_form($complete_form, &$form_state, $theme) { '#default_value' => $scheme_name, '#attached' => array( 'library' => array( - 'color/drupal.color', + array('color', 'drupal.color'), ), // Add custom CSS. 'css' => array( diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 9af0246..4d9cc75 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -10,10 +10,9 @@ * book page, user etc. */ -use Drupal\comment\CommentInterface; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; -use Drupal\Core\Entity\EntityChangedInterface; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Entity\EntityChangedInterface; +use Drupal\comment\CommentInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\field\FieldInstanceConfigInterface; use Drupal\field\FieldConfigInterface; @@ -57,6 +56,21 @@ const COMMENT_FORM_BELOW = 1; /** + * Comments for this entity are hidden. + */ +const COMMENT_HIDDEN = 0; + +/** + * Comments for this entity are closed. + */ +const COMMENT_CLOSED = 1; + +/** + * Comments for this entity are open. + */ +const COMMENT_OPEN = 2; + +/** * The time cutoff for comments marked as read for entity types other node. * * Comments changed before this time are always marked as read. @@ -226,7 +240,7 @@ function comment_field_instance_config_create(FieldInstanceConfigInterface $inst } $instance->default_value += array(array()); $instance->default_value[0] += array( - 'status' => CommentItemInterface::OPEN, + 'status' => COMMENT_OPEN, 'cid' => 0, 'last_comment_timestamp' => 0, 'last_comment_name' => '', @@ -460,7 +474,7 @@ function comment_node_links_alter(array &$node_links, NodeInterface $node, array } } // Provide a link to new comment form. - if ($commenting_status == CommentItemInterface::OPEN) { + if ($commenting_status == COMMENT_OPEN) { $comment_form_location = $instance->getSetting('form_location'); if (user_access('post comments')) { $links['comment-add'] = array( @@ -491,7 +505,7 @@ function comment_node_links_alter(array &$node_links, NodeInterface $node, array else { // Node in other view modes: add a "post comment" link if the user is // allowed to post comments and if this node is allowing new comments. - if ($commenting_status == CommentItemInterface::OPEN) { + if ($commenting_status == COMMENT_OPEN) { $comment_form_location = $instance->getSetting('form_location'); if (user_access('post comments')) { // Show the "post comment" link if the form is on another page, or @@ -532,7 +546,7 @@ function comment_node_links_alter(array &$node_links, NodeInterface $node, array '#attributes' => array('class' => array('links', 'inline')), ); if ($view_mode == 'teaser' && \Drupal::moduleHandler()->moduleExists('history') && \Drupal::currentUser()->isAuthenticated()) { - $node_links['comment__' . $field_name]['#attached']['library'][] = 'comment/drupal.node-new-comments-link'; + $node_links['comment__' . $field_name]['#attached']['library'][] = array('comment', 'drupal.node-new-comments-link'); // Embed the metadata for the "X new comments" link (if any) on this node. $node_links['comment__' . $field_name]['#post_render_cache']['history_attach_timestamp'] = array( @@ -950,25 +964,17 @@ function comment_entity_insert(EntityInterface $entity) { * Implements hook_entity_predelete(). */ function comment_entity_predelete(EntityInterface $entity) { - // Entities can have non-numeric IDs, but {comment} and - // {comment_entity_statistics} tables have integer columns for entity ID, and - // PostgreSQL throws exceptions if you attempt query conditions with - // mismatched types. So, we need to verify that the ID is numeric (even for an - // entity type that has an integer ID, $entity->id() might be a string - // containing a number), and then cast it to an integer when querying. - if ($entity->getEntityType()->isFieldable() && is_numeric($entity->id())) { - $cids = db_select('comment', 'c') - ->fields('c', array('cid')) - ->condition('entity_id', (int) $entity->id()) - ->condition('entity_type', $entity->getEntityTypeId()) - ->execute() - ->fetchCol(); - entity_delete_multiple('comment', $cids); - db_delete('comment_entity_statistics') - ->condition('entity_id', (int) $entity->id()) - ->condition('entity_type', $entity->getEntityTypeId()) - ->execute(); - } + $cids = db_select('comment', 'c') + ->fields('c', array('cid')) + ->condition('entity_id', $entity->id()) + ->condition('entity_type', $entity->getEntityTypeId()) + ->execute() + ->fetchCol(); + entity_delete_multiple('comment', $cids); + db_delete('comment_entity_statistics') + ->condition('entity_id', $entity->id()) + ->condition('entity_type', $entity->getEntityTypeId()) + ->execute(); } /** @@ -1048,8 +1054,8 @@ function comment_node_search_result(EntityInterface $node) { } // Do not make a string if comments are hidden. $status = $node->get($field_name)->status; - if (\Drupal::currentUser()->hasPermission('access comments') && $status != CommentItemInterface::HIDDEN) { - if ($status == CommentItemInterface::OPEN) { + if (\Drupal::currentUser()->hasPermission('access comments') && $status != COMMENT_HIDDEN) { + if ($status == COMMENT_OPEN) { // At least one comment field is open. $open = TRUE; } @@ -1314,7 +1320,7 @@ function comment_preview(CommentInterface $comment, array &$form_state) { // the value back to its original state after the call to entity_view(). $field_name = $comment->getFieldName(); $original_status = $entity->get($field_name)->status; - $entity->get($field_name)->status = CommentItemInterface::HIDDEN; + $entity->get($field_name)->status = COMMENT_HIDDEN; $build = entity_view($entity, 'full'); $entity->get($field_name)->status = $original_status; } diff --git a/core/modules/comment/comment.tokens.inc b/core/modules/comment/comment.tokens.inc index b58230a..a4c9af1 100644 --- a/core/modules/comment/comment.tokens.inc +++ b/core/modules/comment/comment.tokens.inc @@ -142,6 +142,11 @@ function comment_tokens($type, $tokens, array $data = array(), array $options = $replacements[$original] = $sanitize ? check_plain($comment->getHostname()) : $comment->getHostname(); break; + case 'name': + $name = ($comment->getOwnerId() == 0) ? \Drupal::config('user.settings')->get('anonymous') : $comment->getAuthorName(); + $replacements[$original] = $sanitize ? filter_xss($name) : $name; + break; + case 'mail': $mail = $comment->getAuthorEmail(); $replacements[$original] = $sanitize ? check_plain($mail) : $mail; diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index ef7c7fd..a3daab6 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -7,7 +7,6 @@ namespace Drupal\comment; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\Component\Utility\String; use Drupal\Component\Utility\Unicode; use Drupal\Core\Cache\Cache; @@ -99,7 +98,7 @@ public function form(array $form, array &$form_state) { $is_admin = $comment->id() && $this->currentUser->hasPermission('administer comments'); if (!$this->currentUser->isAuthenticated() && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT) { - $form['#attached']['library'][] = 'core/jquery.cookie'; + $form['#attached']['library'][] = array('core', 'jquery.cookie'); $form['#attributes']['class'][] = 'user-info-from-cookie'; } @@ -381,7 +380,7 @@ public function save(array $form, array &$form_state) { $field_name = $comment->getFieldName(); $uri = $entity->urlInfo(); - if ($this->currentUser->hasPermission('post comments') && ($this->currentUser->hasPermission('administer comments') || $entity->{$field_name}->status == CommentItemInterface::OPEN)) { + if ($this->currentUser->hasPermission('post comments') && ($this->currentUser->hasPermission('administer comments') || $entity->{$field_name}->status == COMMENT_OPEN)) { // Save the anonymous user information to a cookie for reuse. if ($this->currentUser->isAnonymous()) { user_cookie_save(array_intersect_key($form_state['values'], array_flip(array('name', 'mail', 'homepage')))); diff --git a/core/modules/comment/lib/Drupal/comment/CommentManager.php b/core/modules/comment/lib/Drupal/comment/CommentManager.php index 6976e42..2102abe 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentManager.php +++ b/core/modules/comment/lib/Drupal/comment/CommentManager.php @@ -7,7 +7,6 @@ namespace Drupal\comment; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\Component\Utility\String; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityInterface; @@ -139,7 +138,7 @@ public function getAllFields() { /** * {@inheritdoc} */ - public function addDefaultField($entity_type, $bundle, $field_name = 'comment', $default_value = CommentItemInterface::OPEN) { + public function addDefaultField($entity_type, $bundle, $field_name = 'comment', $default_value = COMMENT_OPEN) { // Make sure the field doesn't already exist. if (!$this->fieldInfo->getField($entity_type, $field_name)) { // Add a default comment field for existing node comments. @@ -148,9 +147,6 @@ public function addDefaultField($entity_type, $bundle, $field_name = 'comment', 'name' => $field_name, 'type' => 'comment', 'translatable' => '0', - 'settings' => array( - 'description' => 'Default comment field', - ), )); // Create the field. $field->save(); diff --git a/core/modules/comment/lib/Drupal/comment/CommentManagerInterface.php b/core/modules/comment/lib/Drupal/comment/CommentManagerInterface.php index 723d173..b6024e9 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentManagerInterface.php +++ b/core/modules/comment/lib/Drupal/comment/CommentManagerInterface.php @@ -8,8 +8,6 @@ namespace Drupal\comment; use Drupal\Core\Entity\EntityInterface; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; - /** * Comment manager contains common functions to manage comment fields. */ @@ -61,11 +59,10 @@ public function getAllFields(); * @param string $field_name * (optional) Field name to use for the comment field. Defaults to 'comment'. * @param int $default_value - * (optional) Default value, one of CommentItemInterface::HIDDEN, - * CommentItemInterface::OPEN, CommentItemInterface::CLOSED. Defaults to - * CommentItemInterface::OPEN. + * (optional) Default value, one of COMMENT_HIDDEN, COMMENT_OPEN, + * COMMENT_CLOSED. Defaults to COMMENT_OPEN. */ - public function addDefaultField($entity_type, $bundle, $field_name = 'comment', $default_value = CommentItemInterface::OPEN); + public function addDefaultField($entity_type, $bundle, $field_name = 'comment', $default_value = COMMENT_OPEN); /** * Creates a comment_body field instance. diff --git a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php index bd93abb..967cca8 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php +++ b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php @@ -7,7 +7,6 @@ namespace Drupal\comment; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\Core\Access\CsrfTokenGenerator; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\EntityInterface; @@ -139,9 +138,9 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang if (!isset($entity->content['#attached'])) { $entity->content['#attached'] = array(); } - $entity->content['#attached']['library'][] = 'comment/drupal.comment-by-viewer'; + $entity->content['#attached']['library'][] = array('comment', 'drupal.comment-by-viewer'); if ($this->moduleHandler->moduleExists('history') && \Drupal::currentUser()->isAuthenticated()) { - $entity->content['#attached']['library'][] = 'comment/drupal.comment-new-indicator'; + $entity->content['#attached']['library'][] = array('comment', 'drupal.comment-new-indicator'); // Embed the metadata for the comment "new" indicators on this node. $entity->content['#post_render_cache']['history_attach_timestamp'] = array( @@ -210,7 +209,7 @@ protected static function buildLinks(CommentInterface $entity, EntityInterface $ $container = \Drupal::getContainer(); - if ($status == CommentItemInterface::OPEN) { + if ($status == COMMENT_OPEN) { if ($entity->access('delete')) { $links['comment-delete'] = array( 'title' => t('Delete'), diff --git a/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php b/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php index b0c7cbe..fc04bd8 100644 --- a/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php @@ -80,10 +80,6 @@ public function __construct(FieldInfo $field_info, CommentManagerInterface $comm public function overviewBundles() { $header = array( 'field_name' => $this->t('Field name'), - 'description' => array( - 'data' => $this->t('Description'), - 'class' => array(RESPONSIVE_PRIORITY_MEDIUM), - ), 'usage' => array( 'data' => $this->t('Used in'), 'class' => array(RESPONSIVE_PRIORITY_MEDIUM), @@ -122,7 +118,6 @@ public function overviewBundles() { ); $row['data']['field_name']['data'] = $field_info->get('locked') ? $this->t('@label (@field_name) (Locked)', $tokens) : $this->t('@label (@field_name)', $tokens); - $row['data']['description']['data'] = $field_info->getSetting('description'); $row['data']['usage']['data'] = array( '#theme' => 'item_list', '#items' => array(), @@ -174,7 +169,7 @@ public function overviewBundles() { } $build['overview'] = array( - '#type' => 'table', + '#theme' => 'table', '#header' => $header, '#rows' => $rows, '#empty' => $this->t('No comment forms available.'), diff --git a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php index 7a4115f..a302724 100644 --- a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php @@ -9,7 +9,6 @@ use Drupal\comment\CommentInterface; use Drupal\comment\CommentManagerInterface; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\field\FieldInfo; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Entity\EntityInterface; @@ -226,7 +225,7 @@ public function getReplyForm(Request $request, $entity_type, $entity_id, $field_ // The user is not just previewing a comment. if ($request->request->get('op') != $this->t('Preview')) { $status = $entity->{$field_name}->status; - if ($status != CommentItemInterface::OPEN) { + if ($status != COMMENT_OPEN) { drupal_set_message($this->t("This discussion is closed: you can't post new comments."), 'error'); return $this->redirect($uri['route_name'], $uri['route_parameters']); } @@ -253,7 +252,7 @@ public function getReplyForm(Request $request, $entity_type, $entity_id, $field_ elseif ($entity->access('view', $account)) { // We make sure the field value isn't set so we don't end up with a // redirect loop. - $entity->{$field_name}->status = CommentItemInterface::HIDDEN; + $entity->{$field_name}->status = COMMENT_HIDDEN; // Render array of the entity full view mode. $build['commented_entity'] = $this->entityManager()->getViewBuilder($entity->getEntityTypeId())->view($entity, 'full'); unset($build['commented_entity']['#cache']); diff --git a/core/modules/comment/lib/Drupal/comment/Form/CommentAdminOverview.php b/core/modules/comment/lib/Drupal/comment/Form/CommentAdminOverview.php index e2ce52a..5fed1db 100644 --- a/core/modules/comment/lib/Drupal/comment/Form/CommentAdminOverview.php +++ b/core/modules/comment/lib/Drupal/comment/Form/CommentAdminOverview.php @@ -13,6 +13,7 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Datetime\Date; use Drupal\Core\Entity\EntityManager; +use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -37,6 +38,13 @@ class CommentAdminOverview extends FormBase { protected $commentStorage; /** + * The entity query service. + * + * @var \Drupal\Core\Entity\Query\QueryFactory + */ + protected $entityQuery; + + /** * Date service object. * * @var \Drupal\Core\Datetime\Date @@ -57,14 +65,17 @@ class CommentAdminOverview extends FormBase { * The entity manager service. * @param \Drupal\comment\CommentStorageControllerInterface $comment_storage * The comment storage. + * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query + * The entity query service. * @param \Drupal\Core\Datetime\Date $date * The date service. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. */ - public function __construct(EntityManager $entity_manager, CommentStorageControllerInterface $comment_storage, Date $date, ModuleHandlerInterface $module_handler) { + public function __construct(EntityManager $entity_manager, CommentStorageControllerInterface $comment_storage, QueryFactory $entity_query, Date $date, ModuleHandlerInterface $module_handler) { $this->entityManager = $entity_manager; $this->commentStorage = $comment_storage; + $this->entityQuery = $entity_query; $this->date = $date; $this->moduleHandler = $module_handler; } @@ -76,6 +87,7 @@ public static function create(ContainerInterface $container) { return new static( $container->get('entity.manager'), $container->get('entity.manager')->getStorageController('comment'), + $container->get('entity.query'), $container->get('date'), $container->get('module_handler') ); @@ -155,7 +167,7 @@ public function buildForm(array $form, array &$form_state, $type = 'new') { ), 'operations' => $this->t('Operations'), ); - $cids = $this->commentStorage->getQuery() + $cids = $this->entityQuery->get('comment') ->condition('status', $status) ->tableSort($header) ->pager(50) diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php index bf4979b..a0b1ed9 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php @@ -8,7 +8,6 @@ namespace Drupal\comment\Plugin\Field\FieldFormatter; use Drupal\comment\CommentStorageControllerInterface; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\Core\Entity\EntityViewBuilderInterface; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Session\AccountInterface; @@ -116,7 +115,7 @@ public function viewElements(FieldItemListInterface $items) { $status = $items->status; - if ($status != CommentItemInterface::HIDDEN && empty($entity->in_preview) && + if ($status != COMMENT_HIDDEN && empty($entity->in_preview) && // Comments are added to the search results and search index by // comment_node_update_index() instead of by this formatter, so don't // return anything if the view mode is search_index or search_result. @@ -145,7 +144,7 @@ public function viewElements(FieldItemListInterface $items) { // Append comment form if the comments are open and the form is set to // display below the entity. Do not show the form for the print view mode. - if ($status == CommentItemInterface::OPEN && $comment_settings['form_location'] == COMMENT_FORM_BELOW && $this->viewMode != 'print') { + if ($status == COMMENT_OPEN && $comment_settings['form_location'] == COMMENT_FORM_BELOW && $this->viewMode != 'print') { // Only show the add comment form if the user has permission. if ($this->currentUser->hasPermission('post comments')) { // All users in the "anonymous" role can use the same form: it is fine diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php index 115bce2..b50bafc 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php @@ -9,7 +9,7 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\TypedData\DataDefinition; -use Drupal\Core\Field\FieldItemBase; +use Drupal\Core\Field\ConfigFieldItemBase; /** * Plugin implementation of the 'comment' field type. @@ -18,9 +18,6 @@ * id = "comment", * label = @Translation("Comments"), * description = @Translation("This field manages configuration and presentation of comments on an entity."), - * settings = { - * "description" = "", - * }, * instance_settings = { * "default_mode" = COMMENT_MODE_THREADED, * "per_page" = 50, @@ -33,7 +30,7 @@ * default_formatter = "comment_default" * ) */ -class CommentItem extends FieldItemBase implements CommentItemInterface { +class CommentItem extends ConfigFieldItemBase { /** * {@inheritdoc} @@ -102,7 +99,7 @@ public function instanceSettingsForm(array $form, array &$form_state) { 'class' => array('comment-instance-settings-form'), ), '#attached' => array( - 'library' => array('comment/drupal.comment'), + 'library' => array(array('comment', 'drupal.comment')), ), ); $element['comment']['default_mode'] = array( @@ -170,9 +167,8 @@ public function __get($name) { * {@inheritdoc} */ public function isEmpty() { - // There is always a value for this field, it is one of - // CommentItemInterface::OPEN, CommentItemInterface::CLOSED or - // CommentItemInterface::HIDDEN. + // There is always a value for this field, it is one of COMMENT_OPEN, + // COMMENT_CLOSED or COMMENT_HIDDEN. return FALSE; } @@ -199,19 +195,4 @@ public static function processSettingsElement($element) { return $element; } - /** - * {@inheritdoc} - */ - public function settingsForm(array $form, array &$form_state, $has_data) { - $element = array(); - - $element['description'] = array( - '#type' => 'textarea', - '#title' => t('Field description'), - '#description' => t('Describe this comment field. The text will be displayed on the Comments Forms page.'), - '#default_value' => $this->getSetting('description'), - ); - return $element; - } - } diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItemInterface.php b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItemInterface.php deleted file mode 100644 index f61d43d..0000000 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItemInterface.php +++ /dev/null @@ -1,30 +0,0 @@ - 'invisible', '#default_value' => $status, '#options' => array( - CommentItemInterface::OPEN => t('Open'), - CommentItemInterface::CLOSED => t('Closed'), - CommentItemInterface::HIDDEN => t('Hidden'), + COMMENT_OPEN => t('Open'), + COMMENT_CLOSED => t('Closed'), + COMMENT_HIDDEN => t('Hidden'), ), - CommentItemInterface::OPEN => array( + COMMENT_OPEN => array( '#description' => t('Users with the "Post comments" permission can post comments.'), ), - CommentItemInterface::CLOSED => array( + COMMENT_CLOSED => array( '#description' => t('Users cannot post comments, but existing comments will be displayed.'), ), - CommentItemInterface::HIDDEN => array( + COMMENT_HIDDEN => array( '#description' => t('Comments are hidden from view.'), ), ); @@ -59,9 +58,9 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen // sense, so don't even bother presenting it to the user unless this is the // default value widget on the field settings form. if ($element['#field_parents'] != array('default_value_input') && !$entity->get($field->getName())->comment_count) { - $element['status'][CommentItemInterface::HIDDEN]['#access'] = FALSE; + $element['status'][COMMENT_HIDDEN]['#access'] = FALSE; // Also adjust the description of the "closed" option. - $element['status'][CommentItemInterface::CLOSED]['#description'] = t('Users cannot post comments.'); + $element['status'][COMMENT_CLOSED]['#description'] = t('Users cannot post comments.'); } // If the advanced settings tabs-set is available (normally rendered in the // second column on wide-resolutions), place the field as a details element @@ -77,7 +76,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen 'class' => array('comment-' . drupal_html_class($element['#entity_type']) . '-settings-form'), ), '#attached' => array( - 'library' => array('comment/drupal.comment'), + 'library' => array('comment', 'drupal.comment'), ), ); } diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/NodeComment.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/NodeComment.php index e2d1b31..7d15279 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/NodeComment.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/NodeComment.php @@ -7,7 +7,6 @@ namespace Drupal\comment\Plugin\views\field; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; @@ -26,12 +25,12 @@ class NodeComment extends FieldPluginBase { public function render(ResultRow $values) { $value = $this->getValue($values); switch ($value) { - case CommentItemInterface::HIDDEN: + case COMMENT_HIDDEN: default: return t('Hidden'); - case CommentItemInterface::CLOSED: + case COMMENT_CLOSED: return t('Closed'); - case CommentItemInterface::OPEN: + case COMMENT_OPEN: return t('Open'); } } diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/filter/NodeComment.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/filter/NodeComment.php index 94e68ce..1f3e3ca 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/views/filter/NodeComment.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/filter/NodeComment.php @@ -7,7 +7,6 @@ namespace Drupal\comment\Plugin\views\filter; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\views\Plugin\views\filter\InOperator; /** @@ -21,9 +20,9 @@ class NodeComment extends InOperator { public function getValueOptions() { $this->value_options = array( - CommentItemInterface::HIDDEN => t('Hidden'), - CommentItemInterface::CLOSED => t('Closed'), - CommentItemInterface::OPEN => t('Open'), + COMMENT_HIDDEN => t('Hidden'), + COMMENT_CLOSED => t('Closed'), + COMMENT_OPEN => t('Open'), ); } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentAdminTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentAdminTest.php index 4f2f211..e631da2 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentAdminTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentAdminTest.php @@ -162,9 +162,6 @@ public function testCommentAdmin() { // Make sure titles visible. $this->assertText('Field name'); $this->assertText('Used in'); - $this->assertText('Description'); - // Make sure the description is present. - $this->assertText('Default comment field'); // Manage fields. $this->clickLink('Manage fields'); $this->assertResponse(200); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php index 86172a1..10c8f80 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php @@ -7,8 +7,6 @@ namespace Drupal\comment\Tests; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; - /** * Tests fields on comments. */ @@ -60,10 +58,10 @@ function testCommentDefaultFields() { $instances = $this->container->get('field.info')->getInstances('comment'); $this->assertTrue(isset($instances['node__comment']['comment_body']), format_string('The comment_body field is present for comments on type @type', array('@type' => $type_name))); - // Test adding a field that defaults to CommentItemInterface::CLOSED. - $this->container->get('comment.manager')->addDefaultField('node', 'test_node_type', 'who_likes_ponies', CommentItemInterface::CLOSED); + // Test adding a field that defaults to COMMENT_CLOSED. + $this->container->get('comment.manager')->addDefaultField('node', 'test_node_type', 'who_likes_ponies', COMMENT_CLOSED); $field = entity_load('field_instance_config', 'node.test_node_type.who_likes_ponies'); - $this->assertEqual($field->default_value[0]['status'], CommentItemInterface::CLOSED); + $this->assertEqual($field->default_value[0]['status'], COMMENT_CLOSED); } /** diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php index 42157e1..65c5f26 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php @@ -8,7 +8,6 @@ namespace Drupal\comment\Tests; use Drupal\comment\CommentInterface; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; /** * Tests the comment module administrative and end-user-facing interfaces. @@ -155,21 +154,21 @@ function testCommentInterface() { $this->assertText(t('The comment you are replying to does not exist.'), 'Replying to an unpublished comment'); // Attempt to post to node with comments disabled. - $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(array('status' => CommentItemInterface::HIDDEN)))); + $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(array('status' => COMMENT_HIDDEN)))); $this->assertTrue($this->node, 'Article node created.'); $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment'); $this->assertText('This discussion is closed', 'Posting to node with comments disabled'); $this->assertNoField('edit-comment', 'Comment body field found.'); // Attempt to post to node with read-only comments. - $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(array('status' => CommentItemInterface::CLOSED)))); + $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(array('status' => COMMENT_CLOSED)))); $this->assertTrue($this->node, 'Article node created.'); $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment'); $this->assertText('This discussion is closed', 'Posting to node with comments read-only'); $this->assertNoField('edit-comment', 'Comment body field found.'); // Attempt to post to node with comments enabled (check field names etc). - $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(array('status' => CommentItemInterface::OPEN)))); + $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(array('status' => COMMENT_OPEN)))); $this->assertTrue($this->node, 'Article node created.'); $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment'); $this->assertNoText('This discussion is closed', 'Posting to node with comments enabled'); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php index 56444a9..15a389c 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php @@ -7,7 +7,6 @@ namespace Drupal\comment\Tests; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\simpletest\WebTestBase; /** @@ -98,7 +97,7 @@ function testCommentLanguage() { 'title[0][value]' => $title, 'body[0][value]' => $this->randomName(), 'langcode' => $node_langcode, - 'comment[0][status]' => CommentItemInterface::OPEN, + 'comment[0][status]' => COMMENT_OPEN, ); $this->drupalPostForm("node/add/article", $edit, t('Save')); $node = $this->drupalGetNodeByTitle($title); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php index cf7af82..78f81f9 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php @@ -7,7 +7,6 @@ namespace Drupal\comment\Tests; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\Core\Language\Language; use Drupal\comment\CommentInterface; @@ -69,7 +68,7 @@ function testCommentLinks() { // test; there is only a difference between open and closed registration. 'user_register' => array(USER_REGISTER_VISITORS, USER_REGISTER_ADMINISTRATORS_ONLY), // @todo Complete test coverage for: - //'comments' => array(CommentItemInterface::OPEN, CommentItemInterface::CLOSED, CommentInterface::_HIDDEN), + //'comments' => array(COMMENT_OPEN, COMMENT_CLOSED, COMMENT_HIDDEN), //// COMMENT_ANONYMOUS_MUST_CONTACT is irrelevant for this test. //'contact ' => array(COMMENT_ANONYMOUS_MAY_CONTACT, COMMENT_ANONYMOUS_MAYNOT_CONTACT), ); @@ -96,8 +95,7 @@ function testCommentLinks() { * USER_REGISTER_VISITORS. * - contact: COMMENT_ANONYMOUS_MAY_CONTACT or * COMMENT_ANONYMOUS_MAYNOT_CONTACT. - * - comments: CommentItemInterface::OPEN, CommentItemInterface::CLOSED or - * CommentItemInterface::HIDDEN. + * - comments: COMMENT_OPEN, COMMENT_CLOSED, or COMMENT_HIDDEN. * - User permissions: * These are granted or revoked for the user, according to the * 'authenticated' flag above. Pass 0 or 1 as parameter values. See @@ -118,7 +116,7 @@ function setEnvironment(array $info) { 'form' => COMMENT_FORM_BELOW, 'user_register' => USER_REGISTER_VISITORS, 'contact' => COMMENT_ANONYMOUS_MAY_CONTACT, - 'comments' => CommentItemInterface::OPEN, + 'comments' => COMMENT_OPEN, 'access comments' => 0, 'post comments' => 0, // Enabled by default, because it's irrelevant for this test. @@ -193,9 +191,9 @@ function setEnvironment(array $info) { COMMENT_ANONYMOUS_MUST_CONTACT => 'required', ); $t_comments = array( - CommentItemInterface::OPEN => 'open', - CommentItemInterface::CLOSED => 'closed', - CommentItemInterface::HIDDEN => 'hidden', + COMMENT_OPEN => 'open', + COMMENT_CLOSED => 'closed', + COMMENT_HIDDEN => 'hidden', ); $verbose = $info; $verbose['form'] = $t_form[$info['form']]; diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php index d4af65e..82338b1 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php @@ -8,7 +8,6 @@ namespace Drupal\comment\Tests; use Drupal\comment\CommentInterface; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\simpletest\WebTestBase; use Drupal\Core\Entity\EntityInterface; @@ -343,7 +342,7 @@ function testCommentFunctionality() { $this->assertNoFieldChecked('edit-default-value-input-comment-0-status-1'); $this->assertFieldChecked('edit-default-value-input-comment-0-status-2'); // Test comment option change in field settings. - $edit = array('default_value_input[comment][0][status]' => CommentItemInterface::CLOSED); + $edit = array('default_value_input[comment][0][status]' => COMMENT_CLOSED); $this->drupalPostForm(NULL, $edit, t('Save settings')); $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment'); $this->assertNoFieldChecked('edit-default-value-input-comment-0-status-0'); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentRssTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentRssTest.php index c58ada7..b7d44c8 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentRssTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentRssTest.php @@ -7,8 +7,6 @@ namespace Drupal\comment\Tests; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; - /** * Tests for Comment module integration with RSS feeds. */ @@ -41,7 +39,7 @@ function testCommentRss() { $this->assertRaw($raw, 'Comments as part of RSS feed.'); // Hide comments from RSS feed and check presence. - $this->node->set('comment', CommentItemInterface::HIDDEN); + $this->node->set('comment', COMMENT_HIDDEN); $this->node->save(); $this->drupalGet('rss.xml'); $this->assertNoRaw($raw, 'Hidden comments is not a part of RSS feed.'); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php index ce52ee2..2e9226d 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php @@ -7,7 +7,6 @@ namespace Drupal\comment\Tests; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\content_translation\Tests\ContentTranslationUITest; /** @@ -103,7 +102,7 @@ protected function createEntity($values, $langcode, $node_bundle = 'node__commen $node = $this->drupalCreateNode(array( 'type' => $node_type, $field_name => array( - array('status' => CommentItemInterface::OPEN) + array('status' => COMMENT_OPEN) ), )); $values['entity_id'] = $node->id(); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentValidationTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentValidationTest.php index 56f8a54..020e1ab 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentValidationTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentValidationTest.php @@ -136,8 +136,7 @@ protected function assertLengthViolation(CommentInterface $comment, $field_name, $violations = $comment->validate(); $this->assertEqual(count($violations), 1, "Violation found when $field_name is too long."); $this->assertEqual($violations[0]->getPropertyPath(), "$field_name.0.value"); - $field_label = $comment->get($field_name)->getFieldDefinition()->getLabel(); - $this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', array('%name' => $field_label, '@max' => $length))); + $this->assertEqual($violations[0]->getMessage(), t('This value is too long. It should have %limit characters or less.', array('%limit' => $length))); } } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/Views/ArgumentUserUIDTest.php b/core/modules/comment/lib/Drupal/comment/Tests/Views/ArgumentUserUIDTest.php index 0903858..e59b8f0 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/Views/ArgumentUserUIDTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/Views/ArgumentUserUIDTest.php @@ -7,8 +7,6 @@ namespace Drupal\comment\Tests\Views; -use Drupal\views\Views; - /** * Tests the argument_comment_user_uid handler. */ @@ -30,7 +28,7 @@ public static function getInfo() { } function testCommentUserUIDTest() { - $view = Views::getView('test_comment_user_uid'); + $view = views_get_view('test_comment_user_uid'); $this->executeView($view, array($this->account->id())); $result_set = array( array( diff --git a/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php b/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php index 5b0e8e6..e7e699c 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php @@ -9,7 +9,6 @@ use Drupal\comment\CommentInterface; use Drupal\entity\DatabaseStorageController; -use Drupal\views\Views; use Drupal\views\Tests\ViewTestBase; class DefaultViewRecentComments extends ViewTestBase { @@ -114,7 +113,7 @@ public function setUp() { * Tests the block defined by the comments_recent view. */ public function testBlockDisplay() { - $view = Views::getView('comments_recent'); + $view = views_get_view('comments_recent'); $view->setDisplay('block_1'); $this->executeView($view); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/Views/FilterUserUIDTest.php b/core/modules/comment/lib/Drupal/comment/Tests/Views/FilterUserUIDTest.php index 95efc48..abe0e4e 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/Views/FilterUserUIDTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/Views/FilterUserUIDTest.php @@ -7,8 +7,6 @@ namespace Drupal\comment\Tests\Views; -use Drupal\views\Views; - /** * Tests the filter_comment_user_uid handler. * @@ -32,7 +30,7 @@ public static function getInfo() { } function testCommentUserUIDTest() { - $view = Views::getView('test_comment_user_uid'); + $view = views_get_view('test_comment_user_uid'); $view->setDisplay(); $view->removeHandler('default', 'argument', 'uid_touch'); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/Views/WizardTest.php b/core/modules/comment/lib/Drupal/comment/Tests/Views/WizardTest.php index 9a39f2f..764a51a 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/Views/WizardTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/Views/WizardTest.php @@ -7,7 +7,6 @@ namespace Drupal\comment\Tests\Views; -use Drupal\views\Views; use Drupal\views\Tests\Wizard\WizardTestBase; /** @@ -74,7 +73,7 @@ public function testCommentWizard() { $this->drupalPostForm(NULL, $view, t('Save and edit')); $this->assertUrl('admin/structure/views/view/' . $view['id'], array(), 'Make sure the view saving was successful and the browser got redirected to the edit page.'); - $view = Views::getView($view['id']); + $view = views_get_view($view['id']); $view->initHandlers(); $row = $view->display_handler->getOption('row'); $this->assertEqual($row['type'], 'entity:comment'); diff --git a/core/modules/comment/templates/comment.html.twig b/core/modules/comment/templates/comment.html.twig index 5fca73b..570448f 100644 --- a/core/modules/comment/templates/comment.html.twig +++ b/core/modules/comment/templates/comment.html.twig @@ -7,11 +7,8 @@ * - author: Comment author. Can be a link or plain text. * - content: The content-related items for the comment display. Use * {{ content }} to print them all, or print a subset such as - * {{ content.field_example }}. Use the following code to temporarily suppress - * the printing of a given child element: - * @code - * {{ content|without('field_example') }} - * @endcode + * {{ content.field_example }}. Use hide(content.field_example) to temporarily + * suppress the printing of a given element. * - created: Formatted date and time for when the comment was created. * Preprocess functions can reformat it by calling format_date() with the * desired parameters on the 'comment.created' variable. @@ -95,7 +92,9 @@ - {{ content|without('links') }} + {# We hide the links now so that we can render them later. #} + {% hide(content.links) %} + {{ content }} {% if signature %}
diff --git a/core/modules/config/lib/Drupal/config/Controller/ConfigController.php b/core/modules/config/lib/Drupal/config/Controller/ConfigController.php index 18f6287..ee5cd4a 100644 --- a/core/modules/config/lib/Drupal/config/Controller/ConfigController.php +++ b/core/modules/config/lib/Drupal/config/Controller/ConfigController.php @@ -115,7 +115,7 @@ public function diff($config_file) { $build['#attached']['css'][] = drupal_get_path('module', 'system') . '/css/system.diff.css'; $build['diff'] = array( - '#type' => 'table', + '#theme' => 'table', '#header' => array( array('data' => t('Old'), 'colspan' => '2'), array('data' => t('New'), 'colspan' => '2'), diff --git a/core/modules/config/lib/Drupal/config/Form/ConfigSync.php b/core/modules/config/lib/Drupal/config/Form/ConfigSync.php index c600001..64445fd 100644 --- a/core/modules/config/lib/Drupal/config/Form/ConfigSync.php +++ b/core/modules/config/lib/Drupal/config/Form/ConfigSync.php @@ -136,7 +136,7 @@ public function buildForm(array $form, array &$form_state) { $storage_comparer = new StorageComparer($this->sourceStorage, $this->targetStorage); if (empty($source_list) || !$storage_comparer->createChangelist()->hasChanges()) { $form['no_changes'] = array( - '#type' => 'table', + '#theme' => 'table', '#header' => array('Name', 'Operations'), '#rows' => array(), '#empty' => $this->t('There are no configuration changes.'), @@ -155,7 +155,7 @@ public function buildForm(array $form, array &$form_state) { } // Add the AJAX library to the form for dialog support. - $form['#attached']['library'][] = 'core/drupal.ajax'; + $form['#attached']['library'][] = array('core', 'drupal.ajax'); foreach ($storage_comparer->getChangelist() as $config_change_type => $config_files) { if (empty($config_files)) { @@ -182,7 +182,7 @@ public function buildForm(array $form, array &$form_state) { break; } $form[$config_change_type]['list'] = array( - '#type' => 'table', + '#theme' => 'table', '#header' => array('Name', 'Operations'), ); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php index 7ec5e86..55ded74 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php @@ -97,4 +97,14 @@ public function testStorageControllerMethods() { } } + /** + * Tests getOriginalId() and setOriginalId(). + */ + protected function testGetOriginalId() { + $entity = $this->storage->create(array()); + $id = $this->randomName(); + $this->assertIdentical(spl_object_hash($entity->setOriginalId($id)), spl_object_hash($entity)); + $this->assertIdentical($entity->getOriginalId(), $id); + } + } diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php index 89413d2..24be35e 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php @@ -52,11 +52,11 @@ function testImport() { // Create new config entity. $original_dynamic_data = array( 'id' => 'new', + 'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651', 'label' => 'New', 'weight' => 0, 'style' => '', 'status' => TRUE, - 'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651', 'langcode' => language_default()->id, 'protected_property' => '', ); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php index b597aa7..f23cdcb 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php @@ -163,11 +163,11 @@ function testNew() { // Create new config entity. $original_dynamic_data = array( 'id' => 'new', + 'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651', 'label' => 'New', 'weight' => 0, 'style' => '', 'status' => TRUE, - 'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651', 'langcode' => language_default()->id, 'protected_property' => '', ); diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/Entity/ConfigTest.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/Entity/ConfigTest.php index 8074ab3..1bb4deb 100644 --- a/core/modules/config/tests/config_test/lib/Drupal/config_test/Entity/ConfigTest.php +++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/Entity/ConfigTest.php @@ -9,7 +9,6 @@ use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\config_test\ConfigTestInterface; -use Drupal\Core\Config\Entity\ConfigEntityInterface; /** * Defines the ConfigTest configuration entity. @@ -50,6 +49,13 @@ class ConfigTest extends ConfigEntityBase implements ConfigTestInterface { public $id; /** + * The UUID for the configuration entity. + * + * @var string + */ + public $uuid; + + /** * The human-readable name of the configuration entity. * * @var string @@ -94,7 +100,7 @@ public function getExportProperties() { /** * Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::sort(). */ - public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) { + public static function sort($a, $b) { \Drupal::state()->set('config_entity_sort', TRUE); return parent::sort($a, $b); } diff --git a/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperManager.php b/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperManager.php index 1227382..0cbcba4 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperManager.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperManager.php @@ -72,7 +72,7 @@ public function __construct(CacheBackendInterface $cache_backend, LanguageManage $directories[$module] = dirname($filename); } foreach ($theme_handler->listInfo() as $theme) { - $directories[$theme->getName()] = $theme->getPath(); + $directories[$theme->name] = dirname($theme->filename); } // Check for files named MODULE.config_translation.yml and diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationEntityListController.php b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationEntityListController.php index c8c495b..8c09840 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationEntityListController.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationEntityListController.php @@ -58,7 +58,7 @@ public function render() { $build['table'] = $table; $build['table']['#attributes']['class'][] = 'config-translation-entity-list'; - $build['#attached']['library'][] = 'system/drupal.system.modules'; + $build['#attached']['library'][] = array('system', 'drupal.system.modules'); return $build; } diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationMapperList.php b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationMapperList.php index 14f9724..8b7f63f 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationMapperList.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationMapperList.php @@ -53,7 +53,7 @@ public static function create(ContainerInterface $container) { */ public function render() { $build = array( - '#type' => 'table', + '#theme' => 'table', '#header' => $this->buildHeader(), '#rows' => array(), ); diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationFormBase.php b/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationFormBase.php index 3c09ba4..8e966eb 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationFormBase.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationFormBase.php @@ -180,7 +180,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU $form_state['config_translation_language'] = $this->language; $form_state['config_translation_source_language'] = $this->sourceLanguage; - $form['#attached']['library'][] = 'config_translation/drupal.config_translation.admin'; + $form['#attached']['library'][] = array('config_translation', 'drupal.config_translation.admin'); $form['config_names'] = array( '#type' => 'container', @@ -251,16 +251,15 @@ public function submitForm(array &$form, array &$form_state) { * @param array|string $base_config_data * Configuration object of base language, a string when done traversing * the data building each sub-structure for the form. - * @param bool $open - * (optional) Whether or not the details element of the form should be open. - * Defaults to TRUE. + * @param bool $collapsed + * (optional) Flag to set collapsed state. Defaults to FALSE. * @param string|null $base_key * (optional) Base configuration key. Defaults to an empty string. * * @return array * An associative array containing the structure of the form. */ - protected function buildConfigForm(Element $schema, $config_data, $base_config_data, $open = TRUE, $base_key = '') { + protected function buildConfigForm(Element $schema, $config_data, $base_config_data, $collapsed = FALSE, $base_key = '') { $build = array(); foreach ($schema as $key => $element) { // Make the specific element key, "$base_key.$key". @@ -269,7 +268,7 @@ protected function buildConfigForm(Element $schema, $config_data, $base_config_d if ($element instanceof Element) { // Build sub-structure and include it with a wrapper in the form // if there are any translatable elements there. - $sub_build = $this->buildConfigForm($element, $config_data[$key], $base_config_data[$key], FALSE, $element_key); + $sub_build = $this->buildConfigForm($element, $config_data[$key], $base_config_data[$key], TRUE, $element_key); if (!empty($sub_build)) { // For some configuration elements the same element structure can // repeat multiple times, (like views displays, filters, etc.). @@ -294,7 +293,7 @@ protected function buildConfigForm(Element $schema, $config_data, $base_config_d $build[$key] = array( '#type' => 'details', '#title' => (!empty($title) ? (strip_tags($title) . ' ') : '') . $this->t($definition['label']), - '#open' => $open, + '#open' => !$collapsed, ) + $sub_build; } } diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Plugin/Derivative/ConfigTranslationContextualLinks.php b/core/modules/config_translation/lib/Drupal/config_translation/Plugin/Derivative/ConfigTranslationContextualLinks.php index f705d4e..0fac412 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Plugin/Derivative/ConfigTranslationContextualLinks.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Plugin/Derivative/ConfigTranslationContextualLinks.php @@ -47,7 +47,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) { /** * {@inheritdoc} */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { // Create contextual links for all mappers. $mappers = $this->mapperManager->getMappers(); foreach ($mappers as $plugin_id => $mapper) { diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Plugin/Derivative/ConfigTranslationLocalTasks.php b/core/modules/config_translation/lib/Drupal/config_translation/Plugin/Derivative/ConfigTranslationLocalTasks.php index 53077d6..20b9c79 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Plugin/Derivative/ConfigTranslationLocalTasks.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Plugin/Derivative/ConfigTranslationLocalTasks.php @@ -57,7 +57,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) { /** * {@inheritdoc} */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { $mappers = $this->mapperManager->getMappers(); foreach ($mappers as $plugin_id => $mapper) { /** @var \Drupal\config_translation\ConfigMapperInterface $mapper */ diff --git a/core/modules/contact/lib/Drupal/contact/Entity/Category.php b/core/modules/contact/lib/Drupal/contact/Entity/Category.php index a2fe218..b2f2460 100644 --- a/core/modules/contact/lib/Drupal/contact/Entity/Category.php +++ b/core/modules/contact/lib/Drupal/contact/Entity/Category.php @@ -49,6 +49,13 @@ class Category extends ConfigEntityBase implements CategoryInterface { public $id; /** + * The category UUID. + * + * @var string + */ + public $uuid; + + /** * The category label. * * @var string diff --git a/core/modules/contact/lib/Drupal/contact/MessageFormController.php b/core/modules/contact/lib/Drupal/contact/MessageFormController.php index 143225b..0678654 100644 --- a/core/modules/contact/lib/Drupal/contact/MessageFormController.php +++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php @@ -28,7 +28,7 @@ class MessageFormController extends ContentEntityFormController { * Overrides Drupal\Core\Entity\EntityFormController::form(). */ public function form(array $form, array &$form_state) { - $user = \Drupal::currentUser(); + global $user; $message = $this->entity; $form = parent::form($form, $form_state, $message); $form['#attributes']['class'][] = 'contact-form'; @@ -53,7 +53,7 @@ public function form(array $form, array &$form_state) { '#required' => TRUE, ); if ($user->isAnonymous()) { - $form['#attached']['library'][] = 'core/jquery.cookie'; + $form['#attached']['library'][] = array('core', 'jquery.cookie'); $form['#attributes']['class'][] = 'user-info-from-cookie'; } // Do not allow authenticated users to alter the name or e-mail values to @@ -139,7 +139,7 @@ public function preview(array $form, array &$form_state) { * Overrides Drupal\Core\Entity\EntityFormController::save(). */ public function save(array $form, array &$form_state) { - $user = \Drupal::currentUser(); + global $user; $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $message = $this->entity; diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc index ef0e4ca..13c81eb 100644 --- a/core/modules/content_translation/content_translation.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -43,7 +43,7 @@ function content_translation_field_sync_widget(FieldDefinitionInterface $field) '#default_value' => !empty($translation_sync) ? $translation_sync : $default, '#attached' => array( 'library' => array( - 'content_translation/drupal.content_translation.admin', + array('content_translation', 'drupal.content_translation.admin'), ), 'js' => array( array('data' => array('contentTranslationDependentOptions' => $settings), 'type' => 'setting'), @@ -71,7 +71,7 @@ function _content_translation_form_language_content_settings_form_alter(array &$ } $form['entity_types']['#default_value'] = $default; - $form['#attached']['library'][] = 'content_translation/drupal.content_translation.admin'; + $form['#attached']['library'][] = array('content_translation', 'drupal.content_translation.admin'); $form['#attached']['js'][] = array('data' => drupal_get_path('module', 'content_translation') . '/content_translation.admin.js', 'type' => 'file'); $dependent_options_settings = array(); diff --git a/core/modules/content_translation/content_translation.pages.inc b/core/modules/content_translation/content_translation.pages.inc index ac36ff7..bed50a0 100644 --- a/core/modules/content_translation/content_translation.pages.inc +++ b/core/modules/content_translation/content_translation.pages.inc @@ -136,7 +136,7 @@ function content_translation_overview(EntityInterface $entity) { $build['#entity'] = $entity; $build['content_translation_overview'] = array( - '#type' => 'table', + '#theme' => 'table', '#header' => $header, '#rows' => $rows, ); diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationContextualLinks.php b/core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationContextualLinks.php index f231aa3..24ebbee 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationContextualLinks.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationContextualLinks.php @@ -49,7 +49,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) { /** * {@inheritdoc} */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { // Create contextual links for translatable entity types. foreach ($this->contentTranslationManager->getSupportedEntityTypes() as $entity_type_id => $entity_type) { $this->derivatives[$entity_type_id]['title'] = t('Translate'); diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationLocalTasks.php b/core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationLocalTasks.php index 3fcfefe..adb3aa4 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationLocalTasks.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationLocalTasks.php @@ -57,7 +57,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) { /** * {@inheritdoc} */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { // Create tabs for all possible entity types. foreach ($this->contentTranslationManager->getSupportedEntityTypes() as $entity_type_id => $entity_type) { // Find the route name for the translation overview. diff --git a/core/modules/contextual/contextual.module b/core/modules/contextual/contextual.module index a432431..daaac1c 100644 --- a/core/modules/contextual/contextual.module +++ b/core/modules/contextual/contextual.module @@ -34,7 +34,7 @@ function contextual_toolbar() { ), '#attached' => array( 'library' => array( - 'contextual/drupal.contextual-toolbar', + array('contextual', 'drupal.contextual-toolbar'), ), ), ); @@ -56,7 +56,7 @@ function contextual_page_build(&$page) { return; } - $page['#attached']['library'][] = 'contextual/drupal.contextual-links'; + $page['#attached']['library'][] = array('contextual', 'drupal.contextual-links'); } /** @@ -104,7 +104,7 @@ function contextual_element_info() { '#attributes' => array('class' => array('contextual-links')), '#attached' => array( 'library' => array( - 'contextual/drupal.contextual-links', + array('contextual', 'drupal.contextual-links'), ), ), ); diff --git a/core/modules/contextual/js/contextual.js b/core/modules/contextual/js/contextual.js index b01b07f..a843a9a 100644 --- a/core/modules/contextual/js/contextual.js +++ b/core/modules/contextual/js/contextual.js @@ -41,7 +41,7 @@ * @param string html * The server-side rendered HTML for this contextual link. */ - function initContextual ($contextual, html) { + function initContextual($contextual, html) { var $region = $contextual.closest('.contextual-region'); var contextual = Drupal.contextual; @@ -101,7 +101,7 @@ * A contextual links placeholder DOM element, containing the actual * contextual links as rendered by the server. */ - function adjustIfNestedAndOverlapping ($contextual) { + function adjustIfNestedAndOverlapping($contextual) { var $contextuals = $contextual // @todo confirm that .closest() is not sufficient .parents('.contextual-region').eq(-1) @@ -156,17 +156,10 @@ }); // Update all contextual links placeholders whose HTML is cached. - var uncachedIDs = _.filter(ids, function initIfCached (contextualID) { + var uncachedIDs = _.filter(ids, function initIfCached(contextualID) { var html = storage.getItem('Drupal.contextual.' + contextualID); if (html !== null) { - // Initialize after the current executation cycle, to make the AJAX - // request for retrieving the uncached contextual links as soon as - // possible, but also to ensure that other Drupal behaviors have had the - // chance to set up an event listener on the Backbone collection - // Drupal.contextual.collection. - window.setTimeout(function () { - initContextual($context.find('[data-contextual-id="' + contextualID + '"]'), html); - }); + initContextual($context.find('[data-contextual-id="' + contextualID + '"]'), html); return false; } return true; diff --git a/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php b/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php index 754ffc0..1a235dc 100644 --- a/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php +++ b/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php @@ -116,20 +116,17 @@ public function viewElements(FieldItemListInterface $items) { } // Display the date using theme datetime. + // @todo How should RDFa attributes be added to this? $elements[$delta] = array( '#theme' => 'datetime', '#text' => $formatted_date, '#html' => FALSE, '#attributes' => array( 'datetime' => $iso_date, + 'property' => array('dc:date'), + 'datatype' => 'xsd:dateTime', ), ); - if (!empty($item->_attributes)) { - $elements[$delta]['#attributes'] += $item->_attributes; - // Unset field item attributes since they have been included in the - // formatter output and should not be rendered in the field template. - unset($item->_attributes); - } } return $elements; diff --git a/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldType/DateTimeFieldItemList.php b/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldType/DateTimeFieldItemList.php index 81fa6df..46a5625 100644 --- a/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldType/DateTimeFieldItemList.php +++ b/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldType/DateTimeFieldItemList.php @@ -8,12 +8,12 @@ namespace Drupal\datetime\Plugin\Field\FieldType; use Drupal\Core\Datetime\DrupalDateTime; -use Drupal\Core\Field\FieldItemList; +use Drupal\Core\Field\ConfigFieldItemList; /** * Represents a configurable entity datetime field. */ -class DateTimeFieldItemList extends FieldItemList { +class DateTimeFieldItemList extends ConfigFieldItemList { /** * Defines the default value as now. diff --git a/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldType/DateTimeItem.php b/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldType/DateTimeItem.php index 6119730..1e15fad 100644 --- a/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldType/DateTimeItem.php +++ b/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldType/DateTimeItem.php @@ -10,7 +10,7 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\PrepareCacheInterface; use Drupal\Core\TypedData\DataDefinition; -use Drupal\Core\Field\FieldItemBase; +use Drupal\Core\Field\ConfigFieldItemBase; /** * Plugin implementation of the 'datetime' field type. @@ -27,7 +27,7 @@ * list_class = "\Drupal\datetime\Plugin\Field\FieldType\DateTimeFieldItemList" * ) */ -class DateTimeItem extends FieldItemBase implements PrepareCacheInterface { +class DateTimeItem extends ConfigFieldItemBase implements PrepareCacheInterface { /** * Value for the 'datetime_type' setting: store only a date. diff --git a/core/modules/datetime/lib/Drupal/datetime/Tests/DateTimeFieldTest.php b/core/modules/datetime/lib/Drupal/datetime/Tests/DateTimeFieldTest.php index 76b4cb9..94ff1ae 100644 --- a/core/modules/datetime/lib/Drupal/datetime/Tests/DateTimeFieldTest.php +++ b/core/modules/datetime/lib/Drupal/datetime/Tests/DateTimeFieldTest.php @@ -323,7 +323,7 @@ function testDefaultValue() { // Check if default_date has been stored successfully. $config_entity = $this->container->get('config.factory')->get('field.instance.node.date_content.' . $field->name)->get(); - $this->assertEqual($config_entity['default_value'][0]['default_date'], 'now', 'Default value has been stored successfully'); + $this->assertEqual($config_entity['default_value'][0]['default_date'], 'now', 'Default value has been stored succesfully'); // Clean field_info cache in order to avoid stale cache values. field_info_cache_clear(); @@ -345,7 +345,7 @@ function testDefaultValue() { // Check if default_date has been stored successfully. $config_entity = $this->container->get('config.factory')->get('field.instance.node.date_content.' . $field->name)->get(); - $this->assertTrue(empty($config_entity['default_value']), 'Empty default value has been stored successfully'); + $this->assertTrue(empty($config_entity['default_value']), 'Empty default value has been stored succesfully'); // Clean field_info cache in order to avoid stale cache values. field_info_cache_clear(); diff --git a/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php b/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php index d891bfe..9728f35 100644 --- a/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php +++ b/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php @@ -205,7 +205,7 @@ public function overview() { } $build['dblog_table'] = array( - '#type' => 'table', + '#theme' => 'table', '#header' => $header, '#rows' => $rows, '#attributes' => array('id' => 'admin-dblog', 'class' => array('admin-dblog')), @@ -280,7 +280,7 @@ public function eventDetails($event_id) { ), ); $build['dblog_table'] = array( - '#type' => 'table', + '#theme' => 'table', '#rows' => $rows, '#attributes' => array('class' => array('dblog-event')), ); @@ -379,7 +379,7 @@ public function topLogMessages($type) { } $build['dblog_top_table'] = array( - '#type' => 'table', + '#theme' => 'table', '#header' => $header, '#rows' => $rows, '#empty' => $this->t('No log messages available.'), diff --git a/core/modules/dblog/lib/Drupal/dblog/Tests/Views/ViewsIntegrationTest.php b/core/modules/dblog/lib/Drupal/dblog/Tests/Views/ViewsIntegrationTest.php index 8b2987c..dce1106 100644 --- a/core/modules/dblog/lib/Drupal/dblog/Tests/Views/ViewsIntegrationTest.php +++ b/core/modules/dblog/lib/Drupal/dblog/Tests/Views/ViewsIntegrationTest.php @@ -9,7 +9,6 @@ use Drupal\Component\Utility\String; use Drupal\Component\Utility\Xss; -use Drupal\views\Views; use Drupal\views\Tests\ViewTestData; use Drupal\views\Tests\ViewUnitTestBase; @@ -88,7 +87,7 @@ public function testIntegration() { watchdog($entry['type'], $entry['message'], $entry['variables'], $entry['severity'], $entry['link']); } - $view = Views::getView('test_dblog'); + $view = views_get_view('test_dblog'); $this->executeView($view); $view->initStyle(); diff --git a/core/modules/edit/edit.module b/core/modules/edit/edit.module index 1aea385..5e090cd 100644 --- a/core/modules/edit/edit.module +++ b/core/modules/edit/edit.module @@ -42,7 +42,7 @@ function edit_page_build(&$page) { return; } - $page['#attached']['library'][] = 'edit/edit'; + $page['#attached']['library'][] = array('edit', 'edit'); } /** @@ -72,8 +72,8 @@ function edit_page_build(&$page) { * @todo Remove this in favor of the 'stylesheets-additional' property proposed * in https://drupal.org/node/1209958 */ -function edit_library_alter(array &$library, $name, $theme = NULL) { - if ($name == 'edit/edit') { +function edit_library_alter(array &$library, $extension, $name, $theme = NULL) { + if ($extension == 'edit' && $name == 'edit') { // Retrieve the admin theme. if (!isset($theme)) { $theme = Drupal::config('system.theme')->get('admin'); @@ -82,7 +82,7 @@ function edit_library_alter(array &$library, $name, $theme = NULL) { $info = system_get_info('theme', $theme); // Recurse to process base theme(s) first. if (isset($info['base theme'])) { - edit_library_alter($library, $name, $info['base theme']); + edit_library_alter($library, $extension, $name, $info['base theme']); } if (isset($info['edit_stylesheets']) && is_array($info['edit_stylesheets'])) { foreach ($info['edit_stylesheets'] as $path) { diff --git a/core/modules/edit/edit.services.yml b/core/modules/edit/edit.services.yml index 5bc1f17..be9946c 100644 --- a/core/modules/edit/edit.services.yml +++ b/core/modules/edit/edit.services.yml @@ -1,7 +1,7 @@ services: plugin.manager.edit.editor: class: Drupal\edit\Plugin\InPlaceEditorManager - parent: default_plugin_manager + arguments: ['@container.namespaces'] access_check.edit.entity_field: class: Drupal\edit\Access\EditEntityFieldAccessCheck arguments: ['@entity.manager'] diff --git a/core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditor/FormEditor.php b/core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditor/FormEditor.php index e3b9f3b..6130c33 100644 --- a/core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditor/FormEditor.php +++ b/core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditor/FormEditor.php @@ -32,7 +32,7 @@ public function isCompatible(FieldItemListInterface $items) { public function getAttachments() { return array( 'library' => array( - 'edit/edit.inPlaceEditor.form', + array('edit', 'edit.inPlaceEditor.form'), ), ); } diff --git a/core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditor/PlainTextEditor.php b/core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditor/PlainTextEditor.php index 21b37fa..cab8f0a 100644 --- a/core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditor/PlainTextEditor.php +++ b/core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditor/PlainTextEditor.php @@ -47,7 +47,7 @@ public function isCompatible(FieldItemListInterface $items) { public function getAttachments() { return array( 'library' => array( - 'edit/edit.inPlaceEditor.plainText', + array('edit', 'edit.inPlaceEditor.plainText'), ), ); } diff --git a/core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditorManager.php b/core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditorManager.php index 34c16dc..324c7a6 100644 --- a/core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditorManager.php +++ b/core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditorManager.php @@ -7,35 +7,32 @@ namespace Drupal\edit\Plugin; -use Drupal\Core\Cache\CacheBackendInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Language\LanguageManagerInterface; -use Drupal\Core\Plugin\DefaultPluginManager; +use Drupal\Component\Plugin\PluginManagerBase; +use Drupal\Component\Plugin\Discovery\ProcessDecorator; +use Drupal\Component\Plugin\Factory\DefaultFactory; +use Drupal\Core\Plugin\Discovery\AlterDecorator; +use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery; +use Drupal\Core\Plugin\Discovery\CacheDecorator; /** * Editor manager. * * The form editor must always be available. */ -class InPlaceEditorManager extends DefaultPluginManager { +class InPlaceEditorManager extends PluginManagerBase { /** - * Constructs a InPlaceEditorManager object. + * Overrides \Drupal\Component\Plugin\PluginManagerBase::__construct(). * * @param \Traversable $namespaces * An object that implements \Traversable which contains the root paths - * keyed by the corresponding namespace to look for plugin implementations. - * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend - * Cache backend instance to use. - * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager - * The language manager. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to invoke the alter hook with. + * keyed by the corresponding namespace to look for plugin implementations, */ - public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManagerInterface $language_manager, ModuleHandlerInterface $module_handler) { - parent::__construct('Plugin/InPlaceEditor', $namespaces, $module_handler, 'Drupal\edit\Annotation\InPlaceEditor'); - $this->alterInfo('edit_editor'); - $this->setCacheBackend($cache_backend, $language_manager, 'edit:editor'); + public function __construct(\Traversable $namespaces) { + $this->discovery = new AnnotatedClassDiscovery('Plugin/InPlaceEditor', $namespaces, 'Drupal\edit\Annotation\InPlaceEditor'); + $this->discovery = new AlterDecorator($this->discovery, 'edit_editor'); + $this->discovery = new CacheDecorator($this->discovery, 'edit:editor'); + $this->factory = new DefaultFactory($this->discovery); } } diff --git a/core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php b/core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php index d098761..4ac5fb7 100644 --- a/core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php +++ b/core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php @@ -111,8 +111,6 @@ public function testText() { public function testTextWysiwyg() { // Enable edit_test module so that the 'wysiwyg' editor becomes available. $this->enableModules(array('edit_test')); - $this->editorManager = $this->container->get('plugin.manager.edit.editor'); - $this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter')); $field_name = 'field_textarea'; $this->createFieldWithInstance( diff --git a/core/modules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php b/core/modules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php index af74f12..ef71da6 100644 --- a/core/modules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php +++ b/core/modules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php @@ -133,13 +133,6 @@ public function testEditorWithCustomMetadata() { // Enable edit_test module so that the WYSIWYG editor becomes available. $this->enableModules(array('edit_test')); - $this->editorManager = $this->container->get('plugin.manager.edit.editor'); - $this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter')); - $this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager); - - $this->editorManager = $this->container->get('plugin.manager.edit.editor'); - $this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter')); - $this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager); // Create a rich text field. $field_name = 'field_rich'; diff --git a/core/modules/edit/tests/modules/lib/Drupal/edit_test/Plugin/InPlaceEditor/WysiwygEditor.php b/core/modules/edit/tests/modules/lib/Drupal/edit_test/Plugin/InPlaceEditor/WysiwygEditor.php index 185ccb3..2955aac 100644 --- a/core/modules/edit/tests/modules/lib/Drupal/edit_test/Plugin/InPlaceEditor/WysiwygEditor.php +++ b/core/modules/edit/tests/modules/lib/Drupal/edit_test/Plugin/InPlaceEditor/WysiwygEditor.php @@ -55,7 +55,7 @@ public function getMetadata(FieldItemListInterface $items) { public function getAttachments() { return array( 'library' => array( - 'edit_test/not-existing-wysiwyg', + array('edit_test', 'not-existing-wysiwyg'), ), ); } diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index e3ff037..9266911 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -145,7 +145,7 @@ function editor_form_filter_format_form_alter(&$form, &$form_state) { '#id' => 'editor-settings-wrapper', '#attached' => array( 'library' => array( - 'editor/drupal.editor.admin', + array('editor', 'drupal.editor.admin'), ), ), ); @@ -297,7 +297,7 @@ function editor_pre_render_format($element) { } // Attach Text Editor module's (this module) library. - $element['#attached']['library'][] = 'editor/drupal.editor'; + $element['#attached']['library'][] = array('editor', 'drupal.editor'); // Attach attachments for all available editors. $manager = \Drupal::service('plugin.manager.editor'); diff --git a/core/modules/editor/lib/Drupal/editor/EditorInterface.php b/core/modules/editor/lib/Drupal/editor/EditorInterface.php index 2fab152..71897f9 100644 --- a/core/modules/editor/lib/Drupal/editor/EditorInterface.php +++ b/core/modules/editor/lib/Drupal/editor/EditorInterface.php @@ -10,15 +10,8 @@ use Drupal\Core\Config\Entity\ConfigEntityInterface; /** - * Provides an interface defining a text editor entity. + * Provides an interface defining a editor entity. */ interface EditorInterface extends ConfigEntityInterface { - /** - * Returns the filter format this text editor is associated with. - * - * @return \Drupal\filter\FilterFormatInterface - */ - public function getFilterFormat(); - } diff --git a/core/modules/editor/lib/Drupal/editor/Entity/Editor.php b/core/modules/editor/lib/Drupal/editor/Entity/Editor.php index c58d2fa..0053de4 100644 --- a/core/modules/editor/lib/Drupal/editor/Entity/Editor.php +++ b/core/modules/editor/lib/Drupal/editor/Entity/Editor.php @@ -15,7 +15,7 @@ * * @ConfigEntityType( * id = "editor", - * label = @Translation("Text Editor"), + * label = @Translation("Editor"), * entity_keys = { * "id" = "format" * } @@ -53,21 +53,14 @@ class Editor extends ConfigEntityBase implements EditorInterface { public $image_upload = array(); /** - * The filter format this text editor is associated with. - * - * @var \Drupal\filter\FilterFormatInterface - */ - protected $filterFormat; - - /** - * {@inheritdoc} + * Overrides Drupal\Core\Entity\Entity::id(). */ public function id() { return $this->format; } /** - * {@inheritdoc} + * Overrides Drupal\Core\Entity\Entity::__construct() */ public function __construct(array $values, $entity_type) { parent::__construct($values, $entity_type); @@ -82,14 +75,4 @@ public function __construct(array $values, $entity_type) { $this->settings += $default_settings; } - /** - * {@inheritdoc} - */ - public function getFilterFormat() { - if (!$this->filterFormat) { - $this->filterFormat = \Drupal::entityManager()->getStorageController('filter_format')->load($this->format); - } - return $this->filterFormat; - } - } diff --git a/core/modules/editor/lib/Drupal/editor/Form/EditorImageDialog.php b/core/modules/editor/lib/Drupal/editor/Form/EditorImageDialog.php index 9090e9e..b3512b5 100644 --- a/core/modules/editor/lib/Drupal/editor/Form/EditorImageDialog.php +++ b/core/modules/editor/lib/Drupal/editor/Form/EditorImageDialog.php @@ -41,7 +41,7 @@ public function buildForm(array $form, array &$form_state, FilterFormat $filter_ $image_element = $form_state['image_element']; $form['#tree'] = TRUE; - $form['#attached']['library'][] = 'editor/drupal.editor.dialog'; + $form['#attached']['library'][] = array('editor', 'drupal.editor.dialog'); $form['#prefix'] = '
'; $form['#suffix'] = '
'; diff --git a/core/modules/editor/lib/Drupal/editor/Form/EditorLinkDialog.php b/core/modules/editor/lib/Drupal/editor/Form/EditorLinkDialog.php index b0beb5b..0e76f79 100644 --- a/core/modules/editor/lib/Drupal/editor/Form/EditorLinkDialog.php +++ b/core/modules/editor/lib/Drupal/editor/Form/EditorLinkDialog.php @@ -38,7 +38,7 @@ public function buildForm(array $form, array &$form_state, FilterFormat $filter_ $input = isset($form_state['input']['editor_object']) ? $form_state['input']['editor_object'] : array(); $form['#tree'] = TRUE; - $form['#attached']['library'][] = 'editor/drupal.editor.dialog'; + $form['#attached']['library'][] = array('editor', 'drupal.editor.dialog'); $form['#prefix'] = ''; diff --git a/core/modules/editor/lib/Drupal/editor/Plugin/InPlaceEditor/Editor.php b/core/modules/editor/lib/Drupal/editor/Plugin/InPlaceEditor/Editor.php index 8520575..8752efb 100644 --- a/core/modules/editor/lib/Drupal/editor/Plugin/InPlaceEditor/Editor.php +++ b/core/modules/editor/lib/Drupal/editor/Plugin/InPlaceEditor/Editor.php @@ -88,7 +88,7 @@ public function getAttachments() { $attachments = $manager->getAttachments($formats); // Also include editor.module's formatted text editor. - $attachments['library'][] = 'editor/edit.inPlaceEditor.formattedText'; + $attachments['library'][] = array('editor', 'edit.inPlaceEditor.formattedText'); return $attachments; } diff --git a/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php b/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php index b0075d2..de4f1fc 100644 --- a/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php +++ b/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php @@ -124,8 +124,8 @@ protected function getSelectedEditor($entity_id, $field_name, $view_mode = 'defa * format compatibility. */ public function testEditorSelection() { - $this->editorManager = $this->container->get('plugin.manager.edit.editor'); - $this->editorSelector = $this->container->get('edit.editor.selector'); + $this->editorManager = new InPlaceEditorManager($this->container->get('container.namespaces')); + $this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter')); // Create an entity with values for this text field. $this->entity = entity_create('entity_test'); @@ -151,9 +151,9 @@ public function testEditorSelection() { * Tests (custom) metadata when the formatted text editor is used. */ public function testMetadata() { - $this->editorManager = $this->container->get('plugin.manager.edit.editor'); + $this->editorManager = new InPlaceEditorManager($this->container->get('container.namespaces')); $this->accessChecker = new MockEditEntityFieldAccessCheck(); - $this->editorSelector = $this->container->get('edit.editor.selector'); + $this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter')); $this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager); // Create an entity with values for the field. diff --git a/core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php b/core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php index 997d861..d97f989 100644 --- a/core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php +++ b/core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php @@ -78,7 +78,6 @@ public function testManager() { // Enable the Text Editor Test module, which has the Unicorn Editor and // clear the editor manager's cache so it is picked up. $this->enableModules(array('editor_test')); - $this->editorManager = $this->container->get('plugin.manager.editor'); $this->editorManager->clearCachedDefinitions(); // Case 2: a text editor available. @@ -95,7 +94,7 @@ public function testManager() { $this->assertIdentical(array(), $this->editorManager->getAttachments(array()), 'No attachments when one text editor is enabled and retrieving attachments for zero text formats.'); $expected = array( 'library' => array( - 0 => 'edit_test/unicorn', + 0 => array('edit_test', 'unicorn'), ), 'js' => array( 0 => array( diff --git a/core/modules/editor/tests/modules/lib/Drupal/editor_test/Plugin/Editor/UnicornEditor.php b/core/modules/editor/tests/modules/lib/Drupal/editor_test/Plugin/Editor/UnicornEditor.php index d5234df..53d565c 100644 --- a/core/modules/editor/tests/modules/lib/Drupal/editor_test/Plugin/Editor/UnicornEditor.php +++ b/core/modules/editor/tests/modules/lib/Drupal/editor_test/Plugin/Editor/UnicornEditor.php @@ -58,7 +58,7 @@ function getJSSettings(EditorEntity $editor) { */ public function getLibraries(EditorEntity $editor) { return array( - 'edit_test/unicorn', + array('edit_test', 'unicorn'), ); } diff --git a/core/modules/email/email.module b/core/modules/email/email.module index f15d84d..f74da6f 100644 --- a/core/modules/email/email.module +++ b/core/modules/email/email.module @@ -32,6 +32,23 @@ function email_help($path, $arg) { */ function email_field_info_alter(&$info) { $info['email']['configurable'] = TRUE; + $info['email']['class'] = '\Drupal\email\ConfigurableEmailItem'; + $info['email']['list_class'] = '\Drupal\Core\Field\ConfigFieldItemList'; $info['email']['default_widget'] = 'email_default'; + if (\Drupal::moduleHandler()->moduleExists('text')) { + $info['email']['default_formatter'] = 'text_plain'; + } + else { + $info['email']['default_formatter'] = 'email_mailto'; + } $info['email']['provider'] = 'email'; } + +/** + * Implements hook_field_formatter_info_alter(). + */ +function email_field_formatter_info_alter(&$info) { + if (isset($info['text_plain'])) { + $info['text_plain']['field_types'][] = 'email'; + } +} diff --git a/core/modules/email/lib/Drupal/email/ConfigurableEmailItem.php b/core/modules/email/lib/Drupal/email/ConfigurableEmailItem.php new file mode 100644 index 0000000..65e08da --- /dev/null +++ b/core/modules/email/lib/Drupal/email/ConfigurableEmailItem.php @@ -0,0 +1,36 @@ + $entity) { $items = $entity->get($field_name); - $build[$key][$field_name] = $formatter->view($items); + $build[$key] += $formatter->view($items); } } } diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php index 150b73b..93d132d 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php @@ -25,6 +25,13 @@ public $id; /** + * Unique UUID for the config entity. + * + * @var string + */ + public $uuid; + + /** * Entity type to be displayed. * * @var string diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php index d07030a..1541143 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeBase.php @@ -8,7 +8,6 @@ namespace Drupal\entity; use Drupal\Core\Config\Entity\ConfigEntityBase; -use Drupal\Core\Config\Entity\ConfigEntityInterface; /** * Base class for config entity types that hold settings for form and view modes. @@ -23,6 +22,13 @@ public $id; /** + * The UUID of the form or view mode. + * + * @var string + */ + public $uuid; + + /** * The human-readable name of the form or view mode. * * @var string @@ -61,9 +67,7 @@ /** * {@inheritdoc} */ - public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) { - /** @var \Drupal\entity\EntityDisplayModeInterface $a */ - /** @var \Drupal\entity\EntityDisplayModeInterface $b */ + public static function sort($a, $b) { // Sort by the type of entity the view mode is used for. $a_type = $a->getTargetType(); $b_type = $b->getTargetType(); diff --git a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeAddForm.php b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeAddForm.php index 49be44f..b1aa3af 100644 --- a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeAddForm.php +++ b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeAddForm.php @@ -27,8 +27,6 @@ class EntityDisplayModeAddForm extends EntityDisplayModeFormBase { public function buildForm(array $form, array &$form_state, $entity_type_id = NULL) { $this->targetEntityTypeId = $entity_type_id; $form = parent::buildForm($form, $form_state); - // Change replace_pattern to avoid undesired dots. - $form['id']['#machine_name']['replace_pattern'] = '[^a-z0-9_]+'; $definition = $this->entityManager->getDefinition($this->targetEntityTypeId); $form['#title'] = $this->t('Add new %label @entity-type', array('%label' => $definition->getLabel(), '@entity-type' => $this->entityType->getLowercaseLabel())); return $form; diff --git a/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayModeTest.php b/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayModeTest.php index 133b8c3..d8bae0a 100644 --- a/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayModeTest.php +++ b/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayModeTest.php @@ -48,16 +48,8 @@ public function testEntityViewModeUI() { $this->drupalGet('admin/structure/display-modes/view/add'); $this->assertNoLink(t('Test entity - revisions and data table'), 'An entity type with no view builder cannot have view modes.'); - // Test adding a view mode including dots in machine_name. - $this->clickLink(t('Test entity')); - $edit = array( - 'id' => strtolower($this->randomName()) . '.' . strtolower($this->randomName()), - 'label' => $this->randomString(), - ); - $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertRaw('The machine-readable name must contain only lowercase letters, numbers, and underscores.'); - // Test adding a view mode. + $this->clickLink(t('Test entity')); $edit = array( 'id' => strtolower($this->randomName()), 'label' => $this->randomString(), @@ -94,16 +86,8 @@ public function testEntityFormModeUI() { $this->drupalGet('admin/structure/display-modes/form/add'); $this->assertNoLink(t('Entity Test without label'), 'An entity type with no form controller cannot have form modes.'); - // Test adding a view mode including dots in machine_name. - $this->clickLink(t('Test entity')); - $edit = array( - 'id' => strtolower($this->randomName()) . '.' . strtolower($this->randomName()), - 'label' => $this->randomString(), - ); - $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertRaw('The machine-readable name must contain only lowercase letters, numbers, and underscores.'); - // Test adding a form mode. + $this->clickLink(t('Test entity')); $edit = array( 'id' => strtolower($this->randomName()), 'label' => $this->randomString(), diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/ConfigurableEntityReferenceItem.php b/core/modules/entity_reference/lib/Drupal/entity_reference/ConfigurableEntityReferenceItem.php index bcd52ad..b801c1e 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/ConfigurableEntityReferenceItem.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/ConfigurableEntityReferenceItem.php @@ -8,6 +8,7 @@ namespace Drupal\entity_reference; use Drupal\Component\Utility\String; +use Drupal\Core\Field\ConfigFieldItemInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem; use Drupal\Core\Session\AccountInterface; @@ -26,7 +27,7 @@ * * @see entity_reference_field_info_alter(). */ -class ConfigurableEntityReferenceItem extends EntityReferenceItem implements AllowedValuesInterface { +class ConfigurableEntityReferenceItem extends EntityReferenceItem implements ConfigFieldItemInterface, AllowedValuesInterface { /** * {@inheritdoc} diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Derivative/SelectionBase.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Derivative/SelectionBase.php index 79a8327..80ecc16 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Derivative/SelectionBase.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Derivative/SelectionBase.php @@ -16,7 +16,7 @@ class SelectionBase extends DerivativeBase { /** * {@inheritdoc} */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { $supported_entities = array( 'comment', 'file', diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldType/ConfigurableEntityReferenceFieldItemList.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldType/ConfigurableEntityReferenceFieldItemList.php index 3b95917..c4e0775 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldType/ConfigurableEntityReferenceFieldItemList.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldType/ConfigurableEntityReferenceFieldItemList.php @@ -7,12 +7,12 @@ namespace Drupal\entity_reference\Plugin\Field\FieldType; -use Drupal\Core\Field\FieldItemList; +use Drupal\Core\Field\ConfigFieldItemList; /** * Represents a configurable entity_reference entity field. */ -class ConfigurableEntityReferenceFieldItemList extends FieldItemList { +class ConfigurableEntityReferenceFieldItemList extends ConfigFieldItemList { /** * {@inheritdoc} diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php index 66849a7..3e045d5 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php @@ -71,6 +71,8 @@ public function settingsSummary() { * {@inheritdoc} */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { + global $user; + $entity = $items->getEntity(); // Prepare the autocomplete route parameters. @@ -94,7 +96,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen '#size' => $this->getSetting('size'), '#placeholder' => $this->getSetting('placeholder'), '#element_validate' => array(array($this, 'elementValidate')), - '#autocreate_uid' => ($entity instanceof EntityOwnerInterface) ? $entity->getOwnerId() : \Drupal::currentUser()->id(), + '#autocreate_uid' => ($entity instanceof EntityOwnerInterface) ? $entity->getOwnerId() : $user->id(), ); return array('target_id' => $element); diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/views/display/EntityReference.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/views/display/EntityReference.php index b759831..98db690 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/views/display/EntityReference.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/views/display/EntityReference.php @@ -13,7 +13,7 @@ * The plugin that handles an EntityReference display. * * "entity_reference_display" is a custom property, used with - * \Drupal\views\Views::getApplicableViews() to retrieve all views with a + * views_get_applicable_views() to retrieve all views with a * 'Entity Reference' display. * * @ingroup views_display_plugins diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php index fbd4461..43fd7ee 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php @@ -120,7 +120,7 @@ public function testSort() { // Test as a non-admin. $normal_user = $this->drupalCreateUser(array('access content')); - $this->container->set('current_user', $normal_user); + $GLOBALS['user'] = $normal_user; $handler = $this->container->get('plugin.manager.entity_reference.selection')->getSelectionHandler($instance); diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc index a2f6c7c..3898037 100644 --- a/core/modules/field/field.attach.inc +++ b/core/modules/field/field.attach.inc @@ -91,13 +91,20 @@ function field_invoke_method($method, $target_function, EntityInterface $entity, $target = call_user_func($target_function, $field_definition); if (method_exists($target, $method)) { - $field_name = $field_definition->getName(); - $items = $entity->get($field_name); + $items = $entity->get($field_definition->getName()); $items->filterEmptyItems(); $result = $target->$method($items, $a, $b); + if (isset($result)) { - $return[$field_name] = $result; + // For methods with array results, we merge results together. + // For methods with scalar results, we collect results in an array. + if (is_array($result)) { + $return = array_merge($return, $result); + } + else { + $return[] = $result; + } } } } diff --git a/core/modules/field/field.module b/core/modules/field/field.module index f0e280c..734eb7c 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -8,7 +8,6 @@ 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; @@ -158,11 +157,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, Extension $file, $type) { +function field_system_info_alter(&$info, $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->getName(), 'include_deleted' => TRUE)); + $fields = entity_load_multiple_by_properties('field_config', array('module' => $file->name, 'include_deleted' => TRUE)); if ($fields) { $info['required'] = TRUE; diff --git a/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php b/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php index 9e8adee..3388c95 100644 --- a/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php +++ b/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php @@ -66,6 +66,15 @@ class FieldConfig extends ConfigEntityBase implements FieldConfigInterface { public $name; /** + * The field UUID. + * + * This is assigned automatically when the field is created. + * + * @var string + */ + public $uuid; + + /** * The name of the entity type the field can be attached to. * * @var string diff --git a/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php b/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php index cd78415..e61896a 100644 --- a/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php +++ b/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php @@ -45,6 +45,15 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi public $id; /** + * The instance UUID. + * + * This is assigned automatically when the instance is created. + * + * @var string + */ + public $uuid; + + /** * The name of the field attached to the bundle by this instance. * * @var string diff --git a/core/modules/field/lib/Drupal/field/FieldConfigStorageController.php b/core/modules/field/lib/Drupal/field/FieldConfigStorageController.php index 7fb0866..f6d8759 100644 --- a/core/modules/field/lib/Drupal/field/FieldConfigStorageController.php +++ b/core/modules/field/lib/Drupal/field/FieldConfigStorageController.php @@ -54,6 +54,8 @@ class FieldConfigStorageController extends ConfigStorageController { * The config factory service. * @param \Drupal\Core\Config\StorageInterface $config_storage * The config storage service. + * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query_factory + * The entity query factory. * @param \Drupal\Component\Uuid\UuidInterface $uuid_service * The UUID service. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager @@ -63,8 +65,8 @@ class FieldConfigStorageController extends ConfigStorageController { * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state key value store. */ - public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, StorageInterface $config_storage, UuidInterface $uuid_service, EntityManagerInterface $entity_manager, ModuleHandler $module_handler, StateInterface $state) { - parent::__construct($entity_type, $config_factory, $config_storage, $uuid_service); + public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, StorageInterface $config_storage, QueryFactory $entity_query_factory, UuidInterface $uuid_service, EntityManagerInterface $entity_manager, ModuleHandler $module_handler, StateInterface $state) { + parent::__construct($entity_type, $config_factory, $config_storage, $entity_query_factory, $uuid_service); $this->entityManager = $entity_manager; $this->moduleHandler = $module_handler; $this->state = $state; @@ -78,6 +80,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI $entity_type, $container->get('config.factory'), $container->get('config.storage'), + $container->get('entity.query'), $container->get('uuid'), $container->get('entity.manager'), $container->get('module_handler'), diff --git a/core/modules/field/lib/Drupal/field/FieldInstanceConfigStorageController.php b/core/modules/field/lib/Drupal/field/FieldInstanceConfigStorageController.php index d18fbf3..1251b5e 100644 --- a/core/modules/field/lib/Drupal/field/FieldInstanceConfigStorageController.php +++ b/core/modules/field/lib/Drupal/field/FieldInstanceConfigStorageController.php @@ -52,6 +52,8 @@ class FieldInstanceConfigStorageController extends ConfigStorageController { * The config factory service. * @param \Drupal\Core\Config\StorageInterface $config_storage * The config storage service. + * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query_factory + * The entity query factory. * @param \Drupal\Component\Uuid\UuidInterface $uuid_service * The UUID service. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager @@ -59,8 +61,8 @@ class FieldInstanceConfigStorageController extends ConfigStorageController { * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state key value store. */ - public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, StorageInterface $config_storage, UuidInterface $uuid_service, EntityManagerInterface $entity_manager, StateInterface $state) { - parent::__construct($entity_type, $config_factory, $config_storage, $uuid_service); + public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, StorageInterface $config_storage, QueryFactory $entity_query_factory, UuidInterface $uuid_service, EntityManagerInterface $entity_manager, StateInterface $state) { + parent::__construct($entity_type, $config_factory, $config_storage, $entity_query_factory, $uuid_service); $this->entityManager = $entity_manager; $this->state = $state; } @@ -73,6 +75,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI $entity_type, $container->get('config.factory'), $container->get('config.storage'), + $container->get('entity.query'), $container->get('uuid'), $container->get('entity.manager'), $container->get('state') diff --git a/core/modules/field/lib/Drupal/field/Tests/Views/FieldUITest.php b/core/modules/field/lib/Drupal/field/Tests/Views/FieldUITest.php index 991fed1..07507fe 100644 --- a/core/modules/field/lib/Drupal/field/Tests/Views/FieldUITest.php +++ b/core/modules/field/lib/Drupal/field/Tests/Views/FieldUITest.php @@ -7,8 +7,6 @@ namespace Drupal\field\Tests\Views; -use Drupal\views\Views; - /** * Tests the UI of the field field handler. * @@ -75,7 +73,7 @@ public function testHandlerUI() { }, $result); // @todo Replace this sort by assertArray once it's in. sort($options, SORT_STRING); - $this->assertEqual($options, array('string', 'text_default', 'text_trimmed'), 'The text formatters for a simple text field appear as expected.'); + $this->assertEqual($options, array('text_default', 'text_plain', 'text_trimmed'), 'The text formatters for a simple text field appear as expected.'); $this->drupalPostForm(NULL, array('options[type]' => 'text_trimmed'), t('Apply')); @@ -89,7 +87,7 @@ public function testHandlerUI() { // Save the view and test whether the settings are saved. $this->drupalPostForm('admin/structure/views/view/test_view_fieldapi', array(), t('Save')); - $view = Views::getView('test_view_fieldapi'); + $view = views_get_view('test_view_fieldapi'); $view->initHandlers(); $this->assertEqual($view->field['field_name_0']->options['type'], 'text_trimmed'); $this->assertEqual($view->field['field_name_0']->options['settings']['trim_length'], $random_number); diff --git a/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php b/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php index 9a25836..b14d24d 100644 --- a/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php @@ -10,7 +10,6 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Language\Language; use Drupal\views\ViewExecutable; -use Drupal\views\Views; /** * Tests the field_field handler. @@ -111,7 +110,7 @@ public function testFieldRender() { } public function _testSimpleFieldRender() { - $view = Views::getView('test_view_fieldapi'); + $view = views_get_view('test_view_fieldapi'); $this->prepareView($view); $this->executeView($view); @@ -130,7 +129,7 @@ public function _testSimpleFieldRender() { * Tests that fields with formatters runs as expected. */ public function _testFormatterSimpleFieldRender() { - $view = Views::getView('test_view_fieldapi'); + $view = views_get_view('test_view_fieldapi'); $this->prepareView($view); $view->displayHandlers->get('default')->options['fields'][$this->fields[0]->getName()]['type'] = 'text_trimmed'; $view->displayHandlers->get('default')->options['fields'][$this->fields[0]->getName()]['settings'] = array( @@ -147,7 +146,7 @@ public function _testFormatterSimpleFieldRender() { } public function _testMultipleFieldRender() { - $view = Views::getView('test_view_fieldapi'); + $view = views_get_view('test_view_fieldapi'); $field_name = $this->fields[3]->getName(); // Test delta limit. diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php index 97beb5c..457c76f 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldDefaultFormatter.php @@ -22,8 +22,7 @@ * }, * settings = { * "test_formatter_setting" = "dummy test string" - * }, - * weight = 1 + * } * ) */ class TestFieldDefaultFormatter extends FormatterBase { diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldEmptyFormatter.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldEmptyFormatter.php index e624bf9..592a958 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldEmptyFormatter.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldEmptyFormatter.php @@ -21,8 +21,7 @@ * }, * settings = { * "test_empty_string" = "**EMPTY FIELD**" - * }, - * weight = -5 + * } * ) */ class TestFieldEmptyFormatter extends FormatterBase { diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldEmptySettingFormatter.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldEmptySettingFormatter.php index fa4d9a9..e825aa8 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldEmptySettingFormatter.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldEmptySettingFormatter.php @@ -21,8 +21,7 @@ * }, * settings = { * "field_empty_setting" = "" - * }, - * weight = -1 + * } * ) */ class TestFieldEmptySettingFormatter extends FormatterBase { diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php index 87d9553..588ad66 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldMultipleFormatter.php @@ -22,8 +22,7 @@ * }, * settings = { * "test_formatter_setting_multiple" = "dummy test string" - * }, - * weight = 5 + * } * ) */ class TestFieldMultipleFormatter extends FormatterBase { diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldNoSettingsFormatter.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldNoSettingsFormatter.php index 4ab58f1..1d3d150 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldNoSettingsFormatter.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldNoSettingsFormatter.php @@ -19,7 +19,6 @@ * field_types = { * "test_field", * }, - * weight = -10 * ) */ class TestFieldNoSettingsFormatter extends FormatterBase { diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php index 85b97f1..a8ff2a9 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldFormatter/TestFieldPrepareViewFormatter.php @@ -22,8 +22,7 @@ * }, * settings = { * "test_formatter_setting_additional" = "dummy test string" - * }, - * weight = 10 + * } * ) */ class TestFieldPrepareViewFormatter extends FormatterBase { diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/ShapeItem.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/ShapeItem.php index 348886a..63487c1 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/ShapeItem.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/ShapeItem.php @@ -9,7 +9,7 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\TypedData\DataDefinition; -use Drupal\Core\Field\FieldItemBase; +use Drupal\Core\Field\ConfigFieldItemBase; /** * Defines the 'shape_field' entity field item. @@ -25,7 +25,7 @@ * default_formatter = "field_test_default" * ) */ -class ShapeItem extends FieldItemBase { +class ShapeItem extends ConfigFieldItemBase { /** * {@inheritdoc} diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/TestItem.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/TestItem.php index 6c85daa..d2d769a 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/TestItem.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/TestItem.php @@ -10,7 +10,7 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\PrepareCacheInterface; use Drupal\Core\TypedData\DataDefinition; -use Drupal\Core\Field\FieldItemBase; +use Drupal\Core\Field\ConfigFieldItemBase; /** * Defines the 'test_field' entity field item. @@ -32,7 +32,7 @@ * default_formatter = "field_test_default" * ) */ -class TestItem extends FieldItemBase implements PrepareCacheInterface { +class TestItem extends ConfigFieldItemBase implements PrepareCacheInterface { /** * {@inheritdoc} diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldWidget/TestFieldWidget.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldWidget/TestFieldWidget.php index ae80042..bf6e093 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldWidget/TestFieldWidget.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldWidget/TestFieldWidget.php @@ -23,8 +23,7 @@ * }, * settings = { * "test_widget_setting" = "dummy test string" - * }, - * weight = -10 + * } * ) */ class TestFieldWidget extends WidgetBase { diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php index a16eb3f..be8fed9 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldWidget/TestFieldWidgetMultiple.php @@ -25,8 +25,7 @@ * settings = { * "test_widget_setting_multiple" = "dummy test string" * }, - * multiple_values = TRUE, - * weight = 10 + * multiple_values = TRUE * ) */ class TestFieldWidgetMultiple extends WidgetBase { diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index a08593a..4279bb3 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -237,7 +237,7 @@ function field_ui_view_mode_delete(EntityViewModeInterface $view_mode) { */ function theme_field_ui_table($variables) { $elements = $variables['elements']; - $table = array('#type' => 'table'); + $table = array('#theme' => 'table'); // Add table headers and attributes. foreach (array('#header', '#attributes') as $key) { diff --git a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php index 495a6e2..ecd41fd 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php @@ -63,7 +63,7 @@ public function __construct(EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager, PluginManagerBase $plugin_manager, ConfigFactoryInterface $config_factory) { parent::__construct($entity_manager); - $this->fieldTypes = $field_type_manager->getDefinitions(); + $this->fieldTypes = $field_type_manager->getConfigurableDefinitions(); $this->pluginManager = $plugin_manager; $this->configFactory = $config_factory; } @@ -236,7 +236,7 @@ public function buildForm(array $form, array &$form_state, $entity_type_id = NUL $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save')); - $form['#attached']['library'][] = 'field_ui/drupal.field_ui'; + $form['#attached']['library'][] = array('field_ui', 'drupal.field_ui'); return $form; } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Plugin/Derivative/FieldUiLocalTask.php b/core/modules/field_ui/lib/Drupal/field_ui/Plugin/Derivative/FieldUiLocalTask.php index b29144f..e80bd9d 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Plugin/Derivative/FieldUiLocalTask.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Plugin/Derivative/FieldUiLocalTask.php @@ -70,7 +70,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) { /** * {@inheritdoc} */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { $this->derivatives = array(); foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { @@ -123,13 +123,11 @@ public function getDerivativeDefinitions($base_plugin_definition) { 'title' => 'Default', 'route_name' => "field_ui.form_display_overview_$entity_type_id", 'parent_id' => "field_ui.fields:form_display_overview_$entity_type_id", - 'weight' => -1, ); $this->derivatives['field_display_default_' . $entity_type_id] = array( 'title' => 'Default', 'route_name' => "field_ui.display_overview_$entity_type_id", 'parent_id' => "field_ui.fields:display_overview_$entity_type_id", - 'weight' => -1, ); // One local task for each form mode. diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUIRouteTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUIRouteTest.php index ef7bbfa..b01112d 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUIRouteTest.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUIRouteTest.php @@ -79,7 +79,6 @@ public function testFieldUIRoutes() { $this->drupalGet('admin/config/people/accounts/form-display/register'); $this->assertTitle('Manage form display | Drupal'); $this->assertLocalTasks(); - $this->assert(count($this->xpath('//ul/li[1]/a[contains(text(), :text)]', array(':text' => 'Default'))) == 1, 'Default secondary tab is in first position.'); } /** diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php index 133b578..4a25ca6 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php @@ -51,28 +51,12 @@ function testFormatterUI() { $setting_name = key($default_settings); $setting_value = $display_options['settings'][$setting_name]; - // Display the "Manage display" screen and check that the expected formatter - // is selected. + // Display the "Manage display" screen and check that the expected formatter is + // selected. $this->drupalGet($manage_display); $this->assertFieldByName('fields[field_test][type]', $format, 'The expected formatter is selected.'); $this->assertText("$setting_name: $setting_value", 'The expected summary is displayed.'); - // Check whether formatter weights are respected. - $result = $this->xpath('//select[@id=:id]/option', array(':id' => 'edit-fields-field-test-type')); - $options = array_map(function($item) { - return (string) $item->attributes()->value[0]; - }, $result); - $expected_options = array ( - 'field_no_settings', - 'field_empty_test', - 'field_empty_setting', - 'field_test_default', - 'field_test_multiple', - 'field_test_with_prepare_view', - 'hidden', - ); - $this->assertEqual($options, $expected_options, 'The expected formatter ordering is respected.'); - // Change the formatter and check that the summary is updated. $edit = array('fields[field_test][type]' => 'field_test_multiple', 'refresh_rows' => 'field_test'); $this->drupalPostAjaxForm(NULL, $edit, array('op' => t('Refresh'))); @@ -155,18 +139,6 @@ public function testWidgetUI() { $this->assertFieldByName('fields[field_test][type]', $widget_type, 'The expected widget is selected.'); $this->assertText("$setting_name: $setting_value", 'The expected summary is displayed.'); - // Check whether widget weights are respected. - $result = $this->xpath('//select[@id=:id]/option', array(':id' => 'edit-fields-field-test-type')); - $options = array_map(function($item) { - return (string) $item->attributes()->value[0]; - }, $result); - $expected_options = array ( - 'test_field_widget', - 'test_field_widget_multiple', - 'hidden', - ); - $this->assertEqual($options, $expected_options, 'The expected widget ordering is respected.'); - // Change the widget and check that the summary is updated. $edit = array('fields[field_test][type]' => 'test_field_widget_multiple', 'refresh_rows' => 'field_test'); $this->drupalPostAjaxForm(NULL, $edit, array('op' => t('Refresh'))); diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc index a3c7140..ee80560 100644 --- a/core/modules/file/file.field.inc +++ b/core/modules/file/file.field.inc @@ -271,7 +271,7 @@ function theme_file_formatter_table($variables) { } $build = array( - '#type' => 'table', + '#theme' => 'table', '#header' => $header, '#rows' => $rows, ); diff --git a/core/modules/file/file.module b/core/modules/file/file.module index 67e5452..ed7592f 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -63,7 +63,7 @@ function file_element_info() { '#multiple' => FALSE, '#extended' => FALSE, '#attached' => array( - 'library' => array('file/drupal.file'), + 'library' => array(array('file','drupal.file')), ), ); return $types; @@ -406,7 +406,7 @@ function file_validate_is_image(File $file) { $image = \Drupal::service('image.factory')->get($file->getFileUri()); if (!$image->isSupported()) { - $toolkit = \Drupal::service('image.toolkit.manager')->getDefaultToolkit(); + $toolkit = \Drupal::service('image.toolkit'); $extensions = array(); foreach ($toolkit->supportedTypes() as $image_type) { $extensions[] = Unicode::strtoupper(image_type_to_extension($image_type)); @@ -453,7 +453,7 @@ function file_validate_image_resolution(File $file, $maximum_dimensions = 0, $mi if ($image->getWidth() > $width || $image->getHeight() > $height) { // Try to resize the image to fit the dimensions. $image = $image_factory->get($file->getFileUri()); - if ($image->isExisting()) { + if ($image->getResource()) { $image->scale($width, $height); $image->save(); $file->filesize = $image->getFileSize(); diff --git a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileFieldItemList.php b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileFieldItemList.php index a250229..5f77d0d 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileFieldItemList.php +++ b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileFieldItemList.php @@ -7,12 +7,12 @@ namespace Drupal\file\Plugin\Field\FieldType; -use Drupal\Core\Field\FieldItemList; +use Drupal\Core\Field\ConfigFieldItemList; /** * Represents a configurable entity file field. */ -class FileFieldItemList extends FieldItemList { +class FileFieldItemList extends ConfigFieldItemList { /** * {@inheritdoc} diff --git a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileItem.php b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileItem.php index d72ccad..81c4dff 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileItem.php +++ b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileItem.php @@ -10,6 +10,7 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem; use Drupal\Core\TypedData\DataDefinition; +use Drupal\Core\Field\ConfigFieldItemInterface; /** * Plugin implementation of the 'file' field type. @@ -35,7 +36,7 @@ * list_class = "\Drupal\file\Plugin\Field\FieldType\FileFieldItemList" * ) */ -class FileItem extends EntityReferenceItem { +class FileItem extends EntityReferenceItem implements ConfigFieldItemInterface { /** * {@inheritdoc} @@ -96,7 +97,7 @@ public static function propertyDefinitions(FieldDefinitionInterface $field_defin public function settingsForm(array $form, array &$form_state, $has_data) { $element = array(); - $element['#attached']['library'][] = 'file/drupal.file'; + $element['#attached']['library'][] = array('file', 'drupal.file'); $element['display_field'] = array( '#type' => 'checkbox', diff --git a/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php b/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php index c777691..b4c70c3 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileManagedTestBase.php @@ -161,11 +161,9 @@ function createFile($filepath = NULL, $contents = NULL, $scheme = NULL) { $file->status = 0; // Write the record directly rather than using the API so we don't invoke // the hooks. - $file = (array) $file; - $file['fid'] = db_insert('file_managed') - ->fields($file) - ->execute(); - return entity_create('file', $file); + $this->assertNotIdentical(drupal_write_record('file_managed', $file), FALSE, 'The file was added to the database.', 'Create test file'); + + return entity_create('file', (array) $file); } /** diff --git a/core/modules/file/lib/Drupal/file/Tests/SpaceUsedTest.php b/core/modules/file/lib/Drupal/file/Tests/SpaceUsedTest.php index 325990e..49e57f8 100644 --- a/core/modules/file/lib/Drupal/file/Tests/SpaceUsedTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/SpaceUsedTest.php @@ -24,19 +24,19 @@ function setUp() { // Create records for a couple of users with different sizes. $file = array('uid' => 2, 'uri' => 'public://example1.txt', 'filesize' => 50, 'status' => FILE_STATUS_PERMANENT); - db_insert('file_managed')->fields($file)->execute(); + drupal_write_record('file_managed', $file); $file = array('uid' => 2, 'uri' => 'public://example2.txt', 'filesize' => 20, 'status' => FILE_STATUS_PERMANENT); - db_insert('file_managed')->fields($file)->execute(); + drupal_write_record('file_managed', $file); $file = array('uid' => 3, 'uri' => 'public://example3.txt', 'filesize' => 100, 'status' => FILE_STATUS_PERMANENT); - db_insert('file_managed')->fields($file)->execute(); + drupal_write_record('file_managed', $file); $file = array('uid' => 3, 'uri' => 'public://example4.txt', 'filesize' => 200, 'status' => FILE_STATUS_PERMANENT); - db_insert('file_managed')->fields($file)->execute(); + drupal_write_record('file_managed', $file); // Now create some non-permanent files. $file = array('uid' => 2, 'uri' => 'public://example5.txt', 'filesize' => 1, 'status' => 0); - db_insert('file_managed')->fields($file)->execute(); + drupal_write_record('file_managed', $file); $file = array('uid' => 3, 'uri' => 'public://example6.txt', 'filesize' => 3, 'status' => 0); - db_insert('file_managed')->fields($file)->execute(); + drupal_write_record('file_managed', $file); } /** diff --git a/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php b/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php index f054602..8c45a76 100644 --- a/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php @@ -79,7 +79,7 @@ function testFileValidateImageResolution() { $this->assertEqual(count($errors), 1, 'Small images report an error.', 'File'); // Maximum size. - if ($this->container->has('image.toolkit.manager')) { + if ($this->container->has('image.toolkit')) { // Copy the image so that the original doesn't get resized. copy('core/misc/druplicon.png', 'temporary://druplicon.png'); $this->image->setFileUri('temporary://druplicon.png'); diff --git a/core/modules/file/lib/Drupal/file/Tests/Views/ExtensionViewsFieldTest.php b/core/modules/file/lib/Drupal/file/Tests/Views/ExtensionViewsFieldTest.php index 1218e05..9683c1f 100644 --- a/core/modules/file/lib/Drupal/file/Tests/Views/ExtensionViewsFieldTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/Views/ExtensionViewsFieldTest.php @@ -7,7 +7,6 @@ namespace Drupal\file\Tests\Views; -use Drupal\views\Views; use Drupal\views\Tests\ViewUnitTestBase; use Drupal\views\Tests\ViewTestData; @@ -72,7 +71,7 @@ protected function viewsData() { * Tests file extension views field handler extension_detect_tar option. */ public function testFileExtensionTarOption() { - $view = Views::getView('file_extension_view'); + $view = views_get_view('file_extension_view'); $view->setDisplay(); $this->executeView($view); diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index 1e858ad..2b09ea7 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -466,7 +466,7 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE, * The expanded element. */ function filter_process_format($element) { - $user = \Drupal::currentUser(); + global $user; // Ensure that children appear as subkeys of this element. $element['#tree'] = TRUE; @@ -501,7 +501,7 @@ function filter_process_format($element) { $element['value'] += element_info($element['#base_type']); // Turn original element into a text format wrapper. - $element['#attached']['library'][] = 'filter/drupal.filter'; + $element['#attached']['library'][] = array('filter', 'drupal.filter'); // Setup child container for the text format widget. $element['format'] = array( @@ -639,7 +639,9 @@ function filter_form_access_denied($element) { * - id: Filter ID. */ function _filter_tips($format_id, $long = FALSE) { - $formats = filter_formats(\Drupal::currentUser()); + global $user; + + $formats = filter_formats($user); $tips = array(); @@ -1144,5 +1146,5 @@ function filter_filter_secure_image_alter(&$image) { * Implements hook_page_build(). */ function filter_page_build(&$page) { - $page['#attached']['library'][] = 'filter/caption'; + $page['#attached']['library'][] = array('filter', 'caption'); } diff --git a/core/modules/filter/lib/Drupal/filter/Entity/FilterFormat.php b/core/modules/filter/lib/Drupal/filter/Entity/FilterFormat.php index 4e6febf..09e098f 100644 --- a/core/modules/filter/lib/Drupal/filter/Entity/FilterFormat.php +++ b/core/modules/filter/lib/Drupal/filter/Entity/FilterFormat.php @@ -69,6 +69,13 @@ class FilterFormat extends ConfigEntityBase implements FilterFormatInterface, En public $name; /** + * The UUID for this entity. + * + * @var string + */ + public $uuid; + + /** * Weight of this format in the text format selector. * * The first/lowest text format that is accessible for a user is used as diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatFormControllerBase.php b/core/modules/filter/lib/Drupal/filter/FilterFormatFormControllerBase.php index 973cbb7..6fa194c 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterFormatFormControllerBase.php +++ b/core/modules/filter/lib/Drupal/filter/FilterFormatFormControllerBase.php @@ -63,7 +63,7 @@ public function form(array $form, array &$form_state) { $is_fallback = ($format->id() == $this->configFactory->get('filter.settings')->get('fallback_format')); $form['#tree'] = TRUE; - $form['#attached']['library'][] = 'filter/drupal.filter.admin'; + $form['#attached']['library'][] = array('filter', 'drupal.filter.admin'); $form['name'] = array( '#type' => 'textfield', diff --git a/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtml.php b/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtml.php index f94037a..a7c73c4 100644 --- a/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtml.php +++ b/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtml.php @@ -38,7 +38,7 @@ public function settingsForm(array $form, array &$form_state) { '#description' => t('A list of HTML tags that can be used. JavaScript event attributes, JavaScript URLs, and CSS are always stripped.'), '#attached' => array( 'library' => array( - 'filter/drupal.filter.filter_html.admin', + array('filter', 'drupal.filter.filter_html.admin'), ), ), ); @@ -152,7 +152,7 @@ public function tips($long = FALSE) { } } $table = array( - '#type' => 'table', + '#theme' => 'table', '#header' => $header, '#rows' => $rows, ); @@ -177,7 +177,7 @@ public function tips($long = FALSE) { ); } $table = array( - '#type' => 'table', + '#theme' => 'table', '#header' => $header, '#rows' => $rows, ); diff --git a/core/modules/forum/forum.install b/core/modules/forum/forum.install index e9f012e..847dfee 100644 --- a/core/modules/forum/forum.install +++ b/core/modules/forum/forum.install @@ -5,6 +5,8 @@ * Install, update, and uninstall functions for the Forum module. */ +use Drupal\Core\Language\Language; + /** * Implements hook_install(). */ @@ -81,7 +83,7 @@ function forum_install() { 'include_deleted' => FALSE, )); if (empty($fields)) { - Drupal::service('comment.manager')->addDefaultField('node', 'forum', 'comment_forum'); + Drupal::service('comment.manager')->addDefaultField('node', 'forum', 'comment_forum', COMMENT_OPEN); } } diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index c728ad1..1a55bfe 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -5,7 +5,6 @@ * Provides discussion forums. */ -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Component\Utility\String; use Drupal\field\Field; @@ -75,7 +74,7 @@ function forum_theme() { return array( 'forums' => array( 'template' => 'forums', - 'variables' => array('forums' => array(), 'topics' => array(), 'topics_pager' => array(), 'parents' => NULL, 'term' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL, 'header' => array()), + 'variables' => array('forums' => array(), 'topics' => array(), 'topics_pager' => array(), 'parents' => NULL, 'term' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL), ), 'forum_list' => array( 'template' => 'forum-list', @@ -624,7 +623,7 @@ function template_preprocess_forums(&$variables) { } if ($variables['term'] && empty($variables['term']->forum_container->value) && !empty($variables['topics'])) { - $forum_topic_list_header = $variables['header']; + global $forum_topic_list_header; $table = array( '#theme' => 'table__forum_topic_list', @@ -806,7 +805,7 @@ function template_preprocess_forum_icon(&$variables) { $variables['icon_title'] = $variables['new_posts'] ? t('New comments') : t('Normal topic'); } - if ($variables['comment_mode'] == CommentItemInterface::CLOSED || $variables['comment_mode'] == CommentItemInterface::HIDDEN) { + if ($variables['comment_mode'] == COMMENT_CLOSED || $variables['comment_mode'] == COMMENT_HIDDEN) { $icon_status_class = 'closed'; $variables['icon_title'] = t('Closed topic'); } diff --git a/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php b/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php index c70d794..e982429 100644 --- a/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php +++ b/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php @@ -82,15 +82,12 @@ public function forumPage(TermInterface $taxonomy_term) { $taxonomy_term->parents = $this->forumManager->getParents($taxonomy_term->id()); if (empty($taxonomy_term->forum_container->value)) { - $build = $this->forumManager->getTopics($taxonomy_term->id(), $this->currentUser()); - $topics = $build['topics']; - $header = $build['header']; + $topics = $this->forumManager->getTopics($taxonomy_term->id()); } else { $topics = ''; - $header = array(); } - return $this->build($taxonomy_term->forums, $taxonomy_term, $topics, $taxonomy_term->parents, $header); + return $this->build($taxonomy_term->forums, $taxonomy_term, $topics, $taxonomy_term->parents); } /** @@ -125,25 +122,22 @@ public function forumIndex() { * The topics of this forum. * @param array $parents * The parent forums in relation this forum. - * @param array $header - * Array of header cells. * * @return array * A render array. */ - protected function build($forums, TermInterface $term, $topics = array(), $parents = array(), $header = array()) { + protected function build($forums, TermInterface $term, $topics = array(), $parents = array()) { $config = $this->config('forum.settings'); $build = array( '#theme' => 'forums', '#forums' => $forums, '#topics' => $topics, '#parents' => $parents, - '#header' => $header, '#term' => $term, '#sortby' => $config->get('topics.order'), '#forums_per_page' => $config->get('topics.page_limit'), ); - $build['#attached']['library'][] = 'forum/forum.index'; + $build['#attached']['library'][] = array('forum', 'forum.index'); if (empty($term->forum_container->value)) { $build['#attached']['drupal_add_feed'][] = array('taxonomy/term/' . $term->id() . '/feed', 'RSS - ' . $term->label()); } diff --git a/core/modules/forum/lib/Drupal/forum/ForumManager.php b/core/modules/forum/lib/Drupal/forum/ForumManager.php index fc3f933..bcc7372 100644 --- a/core/modules/forum/lib/Drupal/forum/ForumManager.php +++ b/core/modules/forum/lib/Drupal/forum/ForumManager.php @@ -9,9 +9,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Database\Connection; -use Drupal\Core\DependencyInjection\DependencySerialization; use Drupal\Core\Entity\EntityManagerInterface; -use Drupal\Core\Session\AccountInterface; use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\comment\CommentInterface; use Drupal\field\FieldInfo; @@ -20,7 +18,7 @@ /** * Provides forum manager service. */ -class ForumManager extends DependencySerialization implements ForumManagerInterface { +class ForumManager implements ForumManagerInterface { /** * Forum sort order, newest first. @@ -137,21 +135,24 @@ public function __construct(ConfigFactoryInterface $config_factory, EntityManage /** * {@inheritdoc} */ - public function getTopics($tid, AccountInterface $account) { + public function getTopics($tid) { $config = $this->configFactory->get('forum.settings'); $forum_per_page = $config->get('topics.page_limit'); $sortby = $config->get('topics.order'); - $header = array( + global $forum_topic_list_header; + $user = \Drupal::currentUser(); + + $forum_topic_list_header = array( array('data' => $this->t('Topic'), 'field' => 'f.title'), array('data' => $this->t('Replies'), 'field' => 'f.comment_count'), array('data' => $this->t('Last reply'), 'field' => 'f.last_comment_timestamp'), ); $order = $this->getTopicOrder($sortby); - for ($i = 0; $i < count($header); $i++) { - if ($header[$i]['field'] == $order['field']) { - $header[$i]['sort'] = $order['sort']; + for ($i = 0; $i < count($forum_topic_list_header); $i++) { + if ($forum_topic_list_header[$i]['field'] == $order['field']) { + $forum_topic_list_header[$i]['sort'] = $order['sort']; } } @@ -164,7 +165,7 @@ public function getTopics($tid, AccountInterface $account) { ->addTag('node_access') ->addMetaData('base_table', 'forum_index') ->orderBy('f.sticky', 'DESC') - ->orderByHeader($header) + ->orderByHeader($forum_topic_list_header) ->limit($forum_per_page); $count_query = $this->connection->select('forum_index', 'f'); @@ -206,7 +207,7 @@ public function getTopics($tid, AccountInterface $account) { $query ->orderBy('f.sticky', 'DESC') - ->orderByHeader($header) + ->orderByHeader($forum_topic_list_header) ->condition('n.nid', $nids) // @todo This should be actually filtering on the desired node language // and just fall back to the default language. @@ -230,14 +231,14 @@ public function getTopics($tid, AccountInterface $account) { $topics = array(); $first_new_found = FALSE; foreach ($result as $topic) { - if ($account->isAuthenticated()) { + if ($user->isAuthenticated()) { // A forum is new if the topic is new, or if there are new comments since // the user's last visit. if ($topic->forum_tid != $tid) { $topic->new = 0; } else { - $history = $this->lastVisit($topic->id(), $account); + $history = $this->lastVisit($topic->id()); $topic->new_replies = $this->numberNew($topic->id(), $history); $topic->new = $topic->new_replies || ($topic->last_comment_timestamp > $history); } @@ -265,7 +266,7 @@ public function getTopics($tid, AccountInterface $account) { $topics[$topic->id()] = $topic; } - return array('topics' => $topics, 'header' => $header); + return $topics; } @@ -321,18 +322,18 @@ protected function numberNew($nid, $timestamp) { * * @param int $nid * The node ID. - * @param \Drupal\Core\Session\AccountInterface $account - * Account to fetch last time for. * * @return int * The timestamp when the user last viewed this node, if the user has * previously viewed the node; otherwise HISTORY_READ_LIMIT. */ - protected function lastVisit($nid, AccountInterface $account) { + protected function lastVisit($nid) { + $user = \Drupal::currentUser(); + if (empty($this->history[$nid])) { $result = $this->connection->select('history', 'h') ->fields('h', array('nid', 'timestamp')) - ->condition('uid', $account->id()) + ->condition('uid', $user->id()) ->execute(); foreach ($result as $t) { $this->history[$t->nid] = $t->timestamp > HISTORY_READ_LIMIT ? $t->timestamp : HISTORY_READ_LIMIT; @@ -473,7 +474,7 @@ public function resetCache() { // Reset the index. $this->index = NULL; // Reset history. - $this->history = array(); + $this->history = NULL; } /** @@ -559,27 +560,4 @@ protected function t($string, array $args = array(), array $options = array()) { return $this->translationManager->translate($string, $args, $options); } - /** - * {@inheritdoc} - */ - public function __sleep() { - $vars = parent::__sleep(); - // Do not serialize static cache. - unset($vars['history'], $vars['index'], $vars['lastPostData'], $vars['forumChildren'], $vars['forumStatistics']); - return $vars; - } - - /** - * {@inheritdoc} - */ - public function __wakeup() { - parent::__wakeup(); - // Initialize static cache. - $this->history = array(); - $this->lastPostData = array(); - $this->forumChildren = array(); - $this->forumStatistics = array(); - $this->index = NULL; - } - } diff --git a/core/modules/forum/lib/Drupal/forum/ForumManagerInterface.php b/core/modules/forum/lib/Drupal/forum/ForumManagerInterface.php index dda352c..b8896ce 100644 --- a/core/modules/forum/lib/Drupal/forum/ForumManagerInterface.php +++ b/core/modules/forum/lib/Drupal/forum/ForumManagerInterface.php @@ -7,7 +7,6 @@ namespace Drupal\forum; -use Drupal\Core\Session\AccountInterface; use Drupal\node\NodeInterface; /** @@ -20,13 +19,11 @@ * * @param int $tid * Term ID. - * @param \Drupal\Core\Session\AccountInterface $account - * Account to fetch topics for. * * @return array - * Array with keys 'topics' and 'header'. + * Array of topics. */ - public function getTopics($tid, AccountInterface $account); + public function getTopics($tid); /** * Utility method to fetch the child forums for a given forum. diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php index c9bbcff..fed1353 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php @@ -8,7 +8,6 @@ namespace Drupal\forum\Tests; use Drupal\comment\CommentInterface; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\simpletest\WebTestBase; /** @@ -76,7 +75,7 @@ function testForumUninstallWithField() { // We want to test the handling of removing the forum comment field, so we // ensure there is at least one other comment field attached to a node type // so that comment_entity_load() runs for nodes. - \Drupal::service('comment.manager')->addDefaultField('node', 'forum', 'another_comment_field', CommentItemInterface::OPEN); + \Drupal::service('comment.manager')->addDefaultField('node', 'forum', 'another_comment_field', COMMENT_OPEN); $this->drupalGet('node/' . $node->nid->value); $this->assertResponse(200); diff --git a/core/modules/forum/lib/Drupal/forum/Tests/Views/ForumIntegrationTest.php b/core/modules/forum/lib/Drupal/forum/Tests/Views/ForumIntegrationTest.php index a5b2a75..b7fe19d 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/Views/ForumIntegrationTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/Views/ForumIntegrationTest.php @@ -7,7 +7,6 @@ namespace Drupal\forum\Tests\Views; -use Drupal\views\Views; use Drupal\views\Tests\ViewTestBase; use Drupal\views\Tests\ViewTestData; @@ -75,7 +74,7 @@ public function testForumIntegration() { } } - $view = Views::getView('test_forum_index'); + $view = views_get_view('test_forum_index'); $this->executeView($view); $expected_result = array(); diff --git a/core/modules/hal/lib/Drupal/hal/Normalizer/EntityNormalizer.php b/core/modules/hal/lib/Drupal/hal/Normalizer/EntityNormalizer.php index 8fbcffc..1f90663 100644 --- a/core/modules/hal/lib/Drupal/hal/Normalizer/EntityNormalizer.php +++ b/core/modules/hal/lib/Drupal/hal/Normalizer/EntityNormalizer.php @@ -110,8 +110,6 @@ public function denormalize($data, $class, $format = NULL, array $context = arra // Figure out the language to use. if (isset($data['langcode'])) { $langcode = $data['langcode'][0]['value']; - // Remove the langcode so it does not get iterated over below. - unset($data['langcode']); } elseif (\Drupal::moduleHandler()->moduleExists('language')) { $langcode = language_get_default_langcode($typed_data_ids['entity_type'], $typed_data_ids['bundle']); diff --git a/core/modules/history/history.module b/core/modules/history/history.module index 35e3aa1..5ad835e 100644 --- a/core/modules/history/history.module +++ b/core/modules/history/history.module @@ -145,7 +145,7 @@ function history_node_view_alter(&$build, EntityInterface $node, EntityViewDispl ), ), 'library' => array( - 'history/drupal.history', + array('history', 'drupal.history'), ), ); } diff --git a/core/modules/history/lib/Drupal/history/Tests/Views/HistoryTimestampTest.php b/core/modules/history/lib/Drupal/history/Tests/Views/HistoryTimestampTest.php index fe0c1cb..182174c 100644 --- a/core/modules/history/lib/Drupal/history/Tests/Views/HistoryTimestampTest.php +++ b/core/modules/history/lib/Drupal/history/Tests/Views/HistoryTimestampTest.php @@ -7,7 +7,6 @@ namespace Drupal\history\Tests\Views; -use Drupal\views\Views; use Drupal\views\Tests\ViewTestBase; /** @@ -72,7 +71,7 @@ public function testHandlers() { ); // Test the history field. - $view = Views::getView('test_history'); + $view = views_get_view('test_history'); $view->setDisplay('page_1'); $this->executeView($view); $this->assertEqual(count($view->result), 2); @@ -82,7 +81,7 @@ public function testHandlers() { $this->assertEqual(count($result), 1, 'Just one node is marked as new'); // Test the history filter. - $view = Views::getView('test_history'); + $view = views_get_view('test_history'); $view->setDisplay('page_2'); $this->executeView($view); $this->assertEqual(count($view->result), 1); diff --git a/core/modules/image/image.admin.inc b/core/modules/image/image.admin.inc index 1f43cf8..a883bc2 100644 --- a/core/modules/image/image.admin.inc +++ b/core/modules/image/image.admin.inc @@ -192,7 +192,7 @@ function theme_image_anchor($variables) { } $table = array( - '#type' => 'table', + '#theme' => 'table', '#header' => array(), '#rows' => $rows, '#attributes' => array('class' => array('image-anchor')), diff --git a/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php b/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php index 1b3c8db..ab7480b 100644 --- a/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php +++ b/core/modules/image/lib/Drupal/image/Entity/ImageStyle.php @@ -69,6 +69,13 @@ class ImageStyle extends ConfigEntityBase implements ImageStyleInterface, Entity public $label; /** + * The UUID for this entity. + * + * @var string + */ + public $uuid; + + /** * The array of image effects for this image style. * * @var array @@ -278,7 +285,7 @@ public function createDerivative($original_uri, $derivative_uri) { } $image = \Drupal::service('image.factory')->get($original_uri); - if (!$image->isExisting()) { + if (!$image->getResource()) { return FALSE; } diff --git a/core/modules/image/lib/Drupal/image/ImageEffectBag.php b/core/modules/image/lib/Drupal/image/ImageEffectBag.php index ad9f485..2dc76a3 100644 --- a/core/modules/image/lib/Drupal/image/ImageEffectBag.php +++ b/core/modules/image/lib/Drupal/image/ImageEffectBag.php @@ -42,7 +42,8 @@ public function updateConfiguration(array $configuration) { $configuration['uuid'] = $uuid_generator->generate(); } $instance_id = $configuration['uuid']; - $this->addInstanceId($instance_id, $configuration); + $this->setInstanceConfiguration($instance_id, $configuration); + $this->addInstanceId($instance_id); return $instance_id; } diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc index b506136..8fefe3d 100644 --- a/core/modules/language/language.admin.inc +++ b/core/modules/language/language.admin.inc @@ -140,7 +140,7 @@ function theme_language_negotiation_configure_browser_form_table($variables) { ); $table = array( - '#type' => 'table', + '#theme' => 'table', '#header' => $header, '#rows' => $rows, '#attributes' => array('id' => 'lang-neg-browser'), @@ -292,7 +292,7 @@ function template_preprocess_language_content_settings_table(&$variables) { '#title' => $element['#title'], '#header' => $header, '#rows' => $rows, - '#type' => 'table', + '#theme' => 'table', ); } diff --git a/core/modules/language/language.install b/core/modules/language/language.install new file mode 100644 index 0000000..27541ca --- /dev/null +++ b/core/modules/language/language.install @@ -0,0 +1,15 @@ + $labels, '#attached' => array( 'library' => array( - 'language/drupal.language.admin', + array('language', 'drupal.language.admin'), ), ), ); diff --git a/core/modules/language/lib/Drupal/language/Form/NegotiationConfigureForm.php b/core/modules/language/lib/Drupal/language/Form/NegotiationConfigureForm.php index 06383ee..93eaffb 100644 --- a/core/modules/language/lib/Drupal/language/Form/NegotiationConfigureForm.php +++ b/core/modules/language/lib/Drupal/language/Form/NegotiationConfigureForm.php @@ -206,7 +206,7 @@ protected function configureFormTable(array &$form, $type) { '#attributes' => array('class' => array('language-customization-checkbox')), '#attached' => array( 'library' => array( - 'language/language.admin' + array('language', 'language.admin') ), ), ); diff --git a/core/modules/language/lib/Drupal/language/Plugin/Derivative/LanguageBlock.php b/core/modules/language/lib/Drupal/language/Plugin/Derivative/LanguageBlock.php index 88c0736..acf276f 100644 --- a/core/modules/language/lib/Drupal/language/Plugin/Derivative/LanguageBlock.php +++ b/core/modules/language/lib/Drupal/language/Plugin/Derivative/LanguageBlock.php @@ -18,7 +18,7 @@ class LanguageBlock extends DerivativeBase { /** * {@inheritdoc} */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { $language_manager = \Drupal::languageManager(); if ($language_manager instanceof ConfigurableLanguageManagerInterface) { diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php index f734210..938f515 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php @@ -33,6 +33,9 @@ public static function getInfo() { * @see \Drupal\Core\Language\Language */ function testDependencyInjectedNewLanguage() { + // Initialize the language system. + drupal_language_initialize(); + $expected = $this->languageManager->getDefaultLanguage(); $result = $this->languageManager->getCurrentLanguage(); foreach ($expected as $property => $value) { diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php index 863a41d..799795e 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php @@ -62,6 +62,9 @@ function setUp() { // Set language detection to URL. $edit = array('language_interface[enabled][language-url]' => TRUE); $this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings')); + + // Force languages to be initialized. + drupal_language_initialize(); } /** diff --git a/core/modules/language/lib/Drupal/language/Tests/Views/ArgumentLanguageTest.php b/core/modules/language/lib/Drupal/language/Tests/Views/ArgumentLanguageTest.php index f25b251..9469d36 100644 --- a/core/modules/language/lib/Drupal/language/Tests/Views/ArgumentLanguageTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/Views/ArgumentLanguageTest.php @@ -8,7 +8,6 @@ namespace Drupal\language\Tests\Views; use Drupal\Core\Language\Language; -use Drupal\views\Views; /** * Tests the argument language handler. @@ -36,7 +35,7 @@ public static function getInfo() { * Tests the language argument. */ public function testArgument() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); foreach (array('en' => 'John', 'xx-lolspeak' => 'George') as $langcode => $name) { $view->setDisplay(); $view->displayHandlers->get('default')->overrideOption('arguments', array( diff --git a/core/modules/language/lib/Drupal/language/Tests/Views/FieldLanguageTest.php b/core/modules/language/lib/Drupal/language/Tests/Views/FieldLanguageTest.php index 13b5135..7a831c6 100644 --- a/core/modules/language/lib/Drupal/language/Tests/Views/FieldLanguageTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/Views/FieldLanguageTest.php @@ -8,7 +8,6 @@ namespace Drupal\language\Tests\Views; use Drupal\Core\Language\Language; -use Drupal\views\Views; /** * Tests the field language handler. @@ -36,7 +35,7 @@ public static function getInfo() { * Tests the language field. */ public function testField() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); $view->displayHandlers->get('default')->overrideOption('fields', array( 'langcode' => array( diff --git a/core/modules/language/lib/Drupal/language/Tests/Views/FilterLanguageTest.php b/core/modules/language/lib/Drupal/language/Tests/Views/FilterLanguageTest.php index 87717f6..5387978 100644 --- a/core/modules/language/lib/Drupal/language/Tests/Views/FilterLanguageTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/Views/FilterLanguageTest.php @@ -8,7 +8,6 @@ namespace Drupal\language\Tests\Views; use Drupal\Core\Language\Language; -use Drupal\views\Views; /** * Tests the filter language handler. @@ -36,7 +35,7 @@ public static function getInfo() { * Tests the language filter. */ public function testFilter() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); foreach (array('en' => 'John', 'xx-lolspeak' => 'George') as $langcode => $name) { $view->setDisplay(); $view->displayHandlers->get('default')->overrideOption('filters', array( diff --git a/core/modules/link/lib/Drupal/link/Plugin/Field/FieldType/LinkItem.php b/core/modules/link/lib/Drupal/link/Plugin/Field/FieldType/LinkItem.php index e9aff29..17853c3 100644 --- a/core/modules/link/lib/Drupal/link/Plugin/Field/FieldType/LinkItem.php +++ b/core/modules/link/lib/Drupal/link/Plugin/Field/FieldType/LinkItem.php @@ -2,12 +2,12 @@ /** * @file - * Contains \Drupal\link\Plugin\Field\FieldType\LinkItem. + * Contains \Drupal\email\Plugin\Field\FieldType\LinkItem. */ namespace Drupal\link\Plugin\Field\FieldType; -use Drupal\Core\Field\FieldItemBase; +use Drupal\Core\Field\ConfigFieldItemBase; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\TypedData\MapDataDefinition; @@ -26,7 +26,7 @@ * default_formatter = "link" * ) */ -class LinkItem extends FieldItemBase { +class LinkItem extends ConfigFieldItemBase { /** * {@inheritdoc} diff --git a/core/modules/locale/lib/Drupal/locale/Form/ExportForm.php b/core/modules/locale/lib/Drupal/locale/Form/ExportForm.php deleted file mode 100644 index 433c8c9..0000000 --- a/core/modules/locale/lib/Drupal/locale/Form/ExportForm.php +++ /dev/null @@ -1,178 +0,0 @@ -languageManager = $language_manager; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('language_manager') - ); - } - - /** - * {@inheritdoc} - */ - public function getFormID() { - return 'locale_translate_export_form'; - } - - /** - * {@inheritdoc} - */ - public function buildForm(array $form, array &$form_state) { - $languages = $this->languageManager->getLanguages(); - $language_options = array(); - foreach ($languages as $langcode => $language) { - if ($langcode != 'en' || locale_translate_english()) { - $language_options[$langcode] = $language->name; - } - } - $language_default = $this->languageManager->getDefaultLanguage(); - - if (empty($language_options)) { - $form['langcode'] = array( - '#type' => 'value', - '#value' => Language::LANGCODE_SYSTEM, - ); - $form['langcode_text'] = array( - '#type' => 'item', - '#title' => $this->t('Language'), - '#markup' => $this->t('No language available. The export will only contain source strings.'), - ); - } - else { - $form['langcode'] = array( - '#type' => 'select', - '#title' => $this->t('Language'), - '#options' => $language_options, - '#default_value' => $language_default->id, - '#empty_option' => $this->t('Source text only, no translations'), - '#empty_value' => Language::LANGCODE_SYSTEM, - ); - $form['content_options'] = array( - '#type' => 'details', - '#title' => $this->t('Export options'), - '#collapsed' => TRUE, - '#tree' => TRUE, - '#states' => array( - 'invisible' => array( - ':input[name="langcode"]' => array('value' => Language::LANGCODE_SYSTEM), - ), - ), - ); - $form['content_options']['not_customized'] = array( - '#type' => 'checkbox', - '#title' => $this->t('Include non-customized translations'), - '#default_value' => TRUE, - ); - $form['content_options']['customized'] = array( - '#type' => 'checkbox', - '#title' => $this->t('Include customized translations'), - '#default_value' => TRUE, - ); - $form['content_options']['not_translated'] = array( - '#type' => 'checkbox', - '#title' => $this->t('Include untranslated text'), - '#default_value' => TRUE, - ); - } - - $form['actions'] = array( - '#type' => 'actions' - ); - $form['actions']['submit'] = array( - '#type' => 'submit', - '#value' => $this->t('Export') - ); - return $form; - } - - /** - * {@inheritdoc} - */ - public function submitForm(array &$form, array &$form_state) { - // If template is required, language code is not given. - if ($form_state['values']['langcode'] != Language::LANGCODE_SYSTEM) { - $language = $this->languageManager->getLanguage($form_state['values']['langcode']); - } - else { - $language = NULL; - } - $content_options = isset($form_state['values']['content_options']) ? $form_state['values']['content_options'] : array(); - $reader = new PoDatabaseReader(); - $languageName = ''; - if ($language != NULL) { - $reader->setLangcode($language->id); - $reader->setOptions($content_options); - $languages = $this->languageManager->getLanguages(); - $languageName = isset($languages[$language->id]) ? $languages[$language->id]->name : ''; - $filename = $language->id .'.po'; - } - else { - // Template required. - $filename = 'drupal.pot'; - } - - $item = $reader->readItem(); - if (!empty($item)) { - $uri = tempnam('temporary://', 'po_'); - $header = $reader->getHeader(); - $header->setProjectName($this->config('system.site')->get('name')); - $header->setLanguageName($languageName); - - $writer = new PoStreamWriter; - $writer->setUri($uri); - $writer->setHeader($header); - - $writer->open(); - $writer->writeItem($item); - $writer->writeItems($reader); - $writer->close(); - - $response = new BinaryFileResponse($uri); - $response->setContentDisposition('attachment', $filename); - $form_state['response'] = $response; - } - else { - drupal_set_message($this->t('Nothing to export.')); - } - } - -} diff --git a/core/modules/locale/lib/Drupal/locale/Form/LocaleForm.php b/core/modules/locale/lib/Drupal/locale/Form/LocaleForm.php index aaa0bfa..c06a4aa 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/LocaleForm.php +++ b/core/modules/locale/lib/Drupal/locale/Form/LocaleForm.php @@ -22,6 +22,16 @@ public function import() { } /** + * Wraps locale_translate_export_form(). + * + * @todo Remove locale_translate_export_form(). + */ + public function export() { + module_load_include('bulk.inc', 'locale'); + return drupal_get_form('locale_translate_export_form'); + } + + /** * Wraps locale_translation_status_form(). * * @todo Remove locale_translation_status_form(). diff --git a/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php b/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php index fb41d01..d6e4b09 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php +++ b/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php @@ -34,7 +34,11 @@ public function buildForm(array $form, array &$form_state) { $langname = isset($langcode) ? $languages[$langcode]->name : "- None -"; - $form['#attached']['library'][] = 'locale/drupal.locale.admin'; + $path = drupal_get_path('module', 'locale'); + $form['#attached']['css'] = array( + $path . '/css/locale.admin.css', + ); + $form['#attached']['library'][] = array('locale', 'drupal.locale.admin'); $form['langcode'] = array( '#type' => 'value', diff --git a/core/modules/locale/lib/Drupal/locale/Form/TranslateFilterForm.php b/core/modules/locale/lib/Drupal/locale/Form/TranslateFilterForm.php index 213935a..2fd6ad6 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/TranslateFilterForm.php +++ b/core/modules/locale/lib/Drupal/locale/Form/TranslateFilterForm.php @@ -26,7 +26,9 @@ public function buildForm(array $form, array &$form_state) { $filters = $this->translateFilters(); $filter_values = $this->translateFilterValues(); - $form['#attached']['library'][] = 'locale/drupal.locale.admin'; + $form['#attached']['css'] = array( + drupal_get_path('module', 'locale') . '/css/locale.admin.css', + ); $form['filters'] = array( '#type' => 'details', diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleExportTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleExportTest.php index c0ceb05..d77fdc2 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleExportTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleExportTest.php @@ -121,9 +121,9 @@ function testExportTranslation() { * Test exportation of translation template file. */ function testExportTranslationTemplateFile() { - // Load an admin page with JavaScript so _drupal_add_library() fires at - // least once and _locale_parse_js_file() gets to run at least once so that - // the locales_source table gets populated with something. + // Load an admin page with JavaScript so drupal_add_library() fires at least + // once and _locale_parse_js_file() gets to run at least once so that the + // locales_source table gets populated with something. $this->drupalGet('admin/config/regional/language'); // Get the translation template file. $this->drupalPostForm('admin/config/regional/translate/export', array(), t('Export')); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleLibraryInfoAlterTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleLibraryInfoAlterTest.php index 1bf1373..2a51216 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleLibraryInfoAlterTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleLibraryInfoAlterTest.php @@ -36,8 +36,7 @@ public static function getInfo() { * @see locale_library_info_alter() */ public function testLibraryInfoAlter() { - $attached['#attached']['library'][] = 'core/jquery.ui.datepicker'; - drupal_render($attached); + drupal_add_library('core', 'jquery.ui.datepicker'); $scripts = drupal_get_js(); $this->assertTrue(strpos($scripts, 'locale.datepicker.js'), 'locale.datepicker.js added to scripts.'); } diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateBase.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateBase.php index 2e29d98..8ae5a8e 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateBase.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateBase.php @@ -270,8 +270,8 @@ protected function setCurrentTranslations() { 'version' => '', ); foreach ($data as $file) { - $file = array_merge($default, $file); - db_insert('locale_file')->fields($file)->execute(); + $file = (object) array_merge($default, $file); + drupal_write_record('locale_file', $file); } } diff --git a/core/modules/locale/locale.bulk.inc b/core/modules/locale/locale.bulk.inc index 5f72ad8..96cf924 100644 --- a/core/modules/locale/locale.bulk.inc +++ b/core/modules/locale/locale.bulk.inc @@ -5,8 +5,11 @@ * Mass import-export and batch import functionality for Gettext .po files. */ +use Drupal\Component\Gettext\PoStreamWriter; use Drupal\locale\Gettext; +use Drupal\locale\PoDatabaseReader; use Drupal\Core\Language\Language; +use Symfony\Component\HttpFoundation\BinaryFileResponse; use Drupal\file\FileInterface; /** @@ -146,6 +149,135 @@ function locale_translate_import_form_submit($form, &$form_state) { } /** + * Form constructor for the Gettext translation files export form. + * + * @see locale_translate_export_form_submit() + * @ingroup forms + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\locale\Form\LocaleForm::export(). + */ +function locale_translate_export_form($form, &$form_state) { + $languages = language_list(); + $language_options = array(); + foreach ($languages as $langcode => $language) { + if ($langcode != 'en' || locale_translate_english()) { + $language_options[$langcode] = $language->name; + } + } + $language_default = language_default(); + + if (empty($language_options)) { + $form['langcode'] = array( + '#type' => 'value', + '#value' => Language::LANGCODE_SYSTEM, + ); + $form['langcode_text'] = array( + '#type' => 'item', + '#title' => t('Language'), + '#markup' => t('No language available. The export will only contain source strings.'), + ); + } + else { + $form['langcode'] = array( + '#type' => 'select', + '#title' => t('Language'), + '#options' => $language_options, + '#default_value' => $language_default->id, + '#empty_option' => t('Source text only, no translations'), + '#empty_value' => Language::LANGCODE_SYSTEM, + ); + $form['content_options'] = array( + '#type' => 'details', + '#title' => t('Export options'), + '#tree' => TRUE, + '#states' => array( + 'invisible' => array( + ':input[name="langcode"]' => array('value' => Language::LANGCODE_SYSTEM), + ), + ), + ); + $form['content_options']['not_customized'] = array( + '#type' => 'checkbox', + '#title' => t('Include non-customized translations'), + '#default_value' => TRUE, + ); + $form['content_options']['customized'] = array( + '#type' => 'checkbox', + '#title' => t('Include customized translations'), + '#default_value' => TRUE, + ); + $form['content_options']['not_translated'] = array( + '#type' => 'checkbox', + '#title' => t('Include untranslated text'), + '#default_value' => TRUE, + ); + } + + $form['actions'] = array( + '#type' => 'actions' + ); + $form['actions']['submit'] = array( + '#type' => 'submit', + '#value' => t('Export') + ); + return $form; +} + +/** + * Form submission handler for locale_translate_export_form(). + */ +function locale_translate_export_form_submit($form, &$form_state) { + // If template is required, language code is not given. + if ($form_state['values']['langcode'] != Language::LANGCODE_SYSTEM) { + $language = language_load($form_state['values']['langcode']); + } + else { + $language = NULL; + } + $content_options = isset($form_state['values']['content_options']) ? $form_state['values']['content_options'] : array(); + $reader = new PoDatabaseReader(); + $languageName = ''; + if ($language != NULL) { + $reader->setLangcode($language->id); + $reader->setOptions($content_options); + $languages = language_list(); + $languageName = isset($languages[$language->id]) ? $languages[$language->id]->name : ''; + $filename = $language->id .'.po'; + } + else { + // Template required. + $filename = 'drupal.pot'; + } + + $item = $reader->readItem(); + if (!empty($item)) { + $uri = tempnam('temporary://', 'po_'); + $header = $reader->getHeader(); + $header->setProjectName(\Drupal::config('system.site')->get('name')); + $header->setLanguageName($languageName); + + $writer = new PoStreamWriter; + $writer->setUri($uri); + $writer->setHeader($header); + + $writer->open(); + $writer->writeItem($item); + $writer->writeItems($reader); + $writer->close(); + + $response = new BinaryFileResponse($uri); + $response->setContentDisposition('attachment', $filename); + // @todo remove lines below once converted to new routing system. + $response->prepare(\Drupal::request()) + ->send(); + } + else { + drupal_set_message('Nothing to export.'); + } +} + +/** * Prepare a batch to import all translations. * * @param array $options diff --git a/core/modules/locale/locale.libraries.yml b/core/modules/locale/locale.libraries.yml index 69efb02..230f182 100644 --- a/core/modules/locale/locale.libraries.yml +++ b/core/modules/locale/locale.libraries.yml @@ -2,9 +2,6 @@ drupal.locale.admin: version: VERSION js: locale.admin.js: {} - css: - component: - css/locale.admin.css: {} dependencies: - core/jquery - core/drupal diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 324be33..7c3f570 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -638,11 +638,11 @@ function locale_js_translate(array $files = array()) { * * Provides the language support for the jQuery UI Date Picker. */ -function locale_library_alter(array &$library, $name) { - if ($name == 'core/jquery.ui.datepicker') { +function locale_library_alter(array &$library, $module, $name) { + if ($module == 'core' && $name == 'jquery.ui.datepicker') { // locale.datepicker.js should be added in the JS_LIBRARY group, so that // the behavior executes early. JS_LIBRARY is the default. - $library['dependencies'][] = 'locale/drupal.locale.datepicker'; + $library['dependencies'][] = array('locale', 'drupal.locale.datepicker'); $language_interface = \Drupal::languageManager()->getCurrentLanguage(); $settings['jquery']['ui']['datepicker'] = array( @@ -866,23 +866,22 @@ function locale_translation_get_file_history() { * * @return integer * FALSE on failure. Otherwise SAVED_NEW or SAVED_UPDATED. + * + * @see drupal_write_record() */ function locale_translation_update_file_history($file) { - $status = db_merge('locale_file') - ->key(array( - 'project' => $file->project, - 'langcode' => $file->langcode, - )) - ->fields(array( - 'version' => $file->version, - 'timestamp' => $file->timestamp, - 'last_checked' => $file->last_checked, - )) - ->execute(); + // Update or write new record. + if (db_query("SELECT project FROM {locale_file} WHERE project = :project AND langcode = :langcode", array(':project' => $file->project, ':langcode' => $file->langcode))->fetchField()) { + $update = array('project', 'langcode'); + } + else { + $update = array(); + } + $result = drupal_write_record('locale_file', $file, $update); // The file history has changed, flush the static cache now. // @todo Can we make this more fine grained? drupal_static_reset('locale_translation_get_file_history'); - return $status; + return $result; } /** diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc index 7ab9ce0..98f4db9 100644 --- a/core/modules/locale/locale.pages.inc +++ b/core/modules/locale/locale.pages.inc @@ -161,7 +161,8 @@ function locale_translation_status_form($form, &$form_state) { '#after_build' => array('locale_translation_language_table'), ); - $form['#attached']['library'][] = 'locale/drupal.locale.admin'; + $form['#attached']['library'][] = array('locale', 'drupal.locale.admin'); + $form['#attached']['css'] = array(drupal_get_path('module', 'locale') . '/css/locale.admin.css'); $form['actions'] = array('#type' => 'actions'); if ($languages_update) { @@ -297,7 +298,7 @@ function theme_locale_translate_edit_form_strings($variables) { ); } $table = array( - '#type' => 'table', + '#theme' => 'table', '#header' => $header, '#rows' => $rows, '#empty' => t('No strings available.'), diff --git a/core/modules/locale/locale.routing.yml b/core/modules/locale/locale.routing.yml index 6658dad..190ddf7 100644 --- a/core/modules/locale/locale.routing.yml +++ b/core/modules/locale/locale.routing.yml @@ -32,7 +32,7 @@ locale.translate_import: locale.translate_export: path: '/admin/config/regional/translate/export' defaults: - _form: '\Drupal\locale\Form\ExportForm' + _content: '\Drupal\locale\Form\LocaleForm::export' _title: 'Export' requirements: _permission: 'translate interface' diff --git a/core/modules/locale/tests/modules/locale_test/locale_test.module b/core/modules/locale/tests/modules/locale_test/locale_test.module index 4db96b8..89616a5 100644 --- a/core/modules/locale/tests/modules/locale_test/locale_test.module +++ b/core/modules/locale/tests/modules/locale_test/locale_test.module @@ -4,8 +4,6 @@ * @file * Simulate a custom module with a local po file. */ - -use Drupal\Core\Extension\Extension; use Drupal\Core\StreamWrapper\PublicStream; /** @@ -14,13 +12,13 @@ * 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, Extension $file, $type) { +function locale_test_system_info_alter(&$info, $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->getName() == 'locale_test' || $file->getName() == 'locale_test_translate') { + if ($file->name == 'locale_test' || $file->name == 'locale_test_translate') { // Don't hide the module. $info['hidden'] = FALSE; } diff --git a/core/modules/locale/tests/modules/locale_test_translate/locale_test_translate.module b/core/modules/locale/tests/modules/locale_test_translate/locale_test_translate.module index e55d4dc..498099f 100644 --- a/core/modules/locale/tests/modules/locale_test_translate/locale_test_translate.module +++ b/core/modules/locale/tests/modules/locale_test_translate/locale_test_translate.module @@ -5,8 +5,6 @@ * Simulates a custom module with a local po file. */ -use Drupal\Core\Extension\Extension; - /** * Implements hook_system_info_alter(). * @@ -14,8 +12,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, Extension $file, $type) { - if ($file->getName() == 'locale_test_translate') { +function locale_test_translate_system_info_alter(&$info, $file, $type) { + if ($file->name == 'locale_test_translate') { // Don't hide the module. $info['hidden'] = FALSE; } diff --git a/core/modules/menu/menu.module b/core/modules/menu/menu.module index 660e1df..8eb1d34 100644 --- a/core/modules/menu/menu.module +++ b/core/modules/menu/menu.module @@ -477,7 +477,7 @@ function menu_form_node_form_alter(&$form, $form_state) { '#open' => !empty($link['link_title']), '#group' => 'advanced', '#attached' => array( - 'library' => array('menu/drupal.menu'), + 'library' => array(array('menu', 'drupal.menu')), ), '#tree' => TRUE, '#weight' => -2, @@ -594,7 +594,7 @@ function menu_form_node_type_form_alter(&$form, $form_state) { '#type' => 'details', '#title' => t('Menu settings'), '#attached' => array( - 'library' => array('menu/drupal.menu.admin'), + 'library' => array(array('menu', 'drupal.menu.admin')), ), '#group' => 'additional_settings', ); diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php index 51a7241..ee9d0b8 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php @@ -166,7 +166,7 @@ public function updateParentalStatus(EntityInterface $entity, $exclude = FALSE) // If plid == 0, there is nothing to update. if ($entity->plid) { // Check if at least one visible child exists in the table. - $query = $this->getQuery(); + $query = \Drupal::entityQuery($this->entityTypeId); $query ->condition('menu_name', $entity->menu_name) ->condition('hidden', 0) @@ -259,7 +259,7 @@ public function moveChildren(EntityInterface $entity) { * {@inheritdoc} */ public function countMenuLinks($menu_name) { - $query = $this->getQuery(); + $query = \Drupal::entityQuery($this->entityTypeId); $query ->condition('menu_name', $menu_name) ->count(); @@ -275,7 +275,7 @@ public function getParentFromHierarchy(EntityInterface $entity) { $parent = FALSE; $parent_path = substr($parent_path, 0, strrpos($parent_path, '/')); - $query = $this->getQuery(); + $query = \Drupal::entityQuery($this->entityTypeId); $query ->condition('mlid', $entity->id(), '<>') ->condition('module', 'system') diff --git a/core/modules/menu_link/menu_link.api.php b/core/modules/menu_link/menu_link.api.php index cf8ee6d..2541eb5 100644 --- a/core/modules/menu_link/menu_link.api.php +++ b/core/modules/menu_link/menu_link.api.php @@ -111,7 +111,7 @@ function hook_menu_link_insert(\Drupal\menu_link\Entity\MenuLink $menu_link) { $record['mlid'] = $menu_link->id(); $record['menu_name'] = $menu_link->menu_name; $record['status'] = 0; - db_insert('menu_example')->fields($record)->execute(); + drupal_write_record('menu_example', $record); } /** diff --git a/core/modules/migrate/lib/Drupal/migrate/Entity/Migration.php b/core/modules/migrate/lib/Drupal/migrate/Entity/Migration.php index 587c888..3967aec 100644 --- a/core/modules/migrate/lib/Drupal/migrate/Entity/Migration.php +++ b/core/modules/migrate/lib/Drupal/migrate/Entity/Migration.php @@ -46,6 +46,15 @@ class Migration extends ConfigEntityBase implements MigrationInterface { public $id; /** + * The migration UUID. + * + * This is assigned automatically when the migration is created. + * + * @var string + */ + public $uuid; + + /** * The human-readable label for the migration. * * @var string diff --git a/core/modules/node/lib/Drupal/node/Entity/Node.php b/core/modules/node/lib/Drupal/node/Entity/Node.php index 1774c75..62f697f 100644 --- a/core/modules/node/lib/Drupal/node/Entity/Node.php +++ b/core/modules/node/lib/Drupal/node/Entity/Node.php @@ -378,7 +378,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setLabel(t('Language code')) ->setDescription(t('The node language code.')); - $fields['title'] = FieldDefinition::create('string') + $fields['title'] = FieldDefinition::create('text') ->setLabel(t('Title')) ->setDescription(t('The title of this node, always treated as non-markup plain text.')) ->setRequired(TRUE) @@ -386,14 +386,15 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setSettings(array( 'default_value' => '', 'max_length' => 255, + 'text_processing' => 0, )) ->setDisplayOptions('view', array( 'label' => 'hidden', - 'type' => 'string', + 'type' => 'text_default', 'weight' => -5, )) ->setDisplayOptions('form', array( - 'type' => 'string', + 'type' => 'text_textfield', 'weight' => -5, )) ->setDisplayConfigurable('form', TRUE); diff --git a/core/modules/node/lib/Drupal/node/Entity/NodeType.php b/core/modules/node/lib/Drupal/node/Entity/NodeType.php index d7fd3b0..d8e413b 100644 --- a/core/modules/node/lib/Drupal/node/Entity/NodeType.php +++ b/core/modules/node/lib/Drupal/node/Entity/NodeType.php @@ -54,6 +54,13 @@ class NodeType extends ConfigEntityBase implements NodeTypeInterface { public $type; /** + * The UUID of the node type. + * + * @var string + */ + public $uuid; + + /** * The human-readable name of the node type. * * @var string diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php index d562e51..24fa5b9 100644 --- a/core/modules/node/lib/Drupal/node/NodeFormController.php +++ b/core/modules/node/lib/Drupal/node/NodeFormController.php @@ -114,7 +114,7 @@ public function form(array $form, array &$form_state) { 'class' => array('node-form-revision-information'), ), '#attached' => array( - 'library' => array('node/drupal.node'), + 'js' => array(drupal_get_path('module', 'node') . '/node.js'), ), '#weight' => 20, '#optional' => TRUE, @@ -152,8 +152,8 @@ public function form(array $form, array &$form_state) { 'class' => array('node-form-author'), ), '#attached' => array( - 'library' => array('node/drupal.node'), 'js' => array( + drupal_get_path('module', 'node') . '/node.js', array( 'type' => 'setting', 'data' => array('anonymous' => $user_config->get('anonymous')), @@ -194,7 +194,7 @@ public function form(array $form, array &$form_state) { 'class' => array('node-form-options'), ), '#attached' => array( - 'library' => array('node/drupal.node'), + 'js' => array(drupal_get_path('module', 'node') . '/node.js'), ), '#weight' => 95, '#optional' => TRUE, diff --git a/core/modules/node/lib/Drupal/node/NodeTypeFormController.php b/core/modules/node/lib/Drupal/node/NodeTypeFormController.php index 7d6bd72..350e46d 100644 --- a/core/modules/node/lib/Drupal/node/NodeTypeFormController.php +++ b/core/modules/node/lib/Drupal/node/NodeTypeFormController.php @@ -66,7 +66,7 @@ public function form(array $form, array &$form_state) { $form['additional_settings'] = array( '#type' => 'vertical_tabs', '#attached' => array( - 'library' => array('node/drupal.content_types'), + 'library' => array(array('node', 'drupal.content_types')), ), ); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php index ad80d73..6a6bce7 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php @@ -144,7 +144,7 @@ function testNodeQueryAlterOverride() { 'grant_update' => 0, 'grant_delete' => 0, ); - db_insert('node_access')->fields($record)->execute(); + drupal_write_record('node_access', $record); // Test that the noAccessUser still doesn't have the 'view' // privilege after adding the node_access record. diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeValidationTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeValidationTest.php index e71d75b..7b0a0a0 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeValidationTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeValidationTest.php @@ -54,7 +54,7 @@ public function testValidation() { $violations = $node->validate(); $this->assertEqual(count($violations), 1, 'Violation found when title is too long.'); $this->assertEqual($violations[0]->getPropertyPath(), 'title.0.value'); - $this->assertEqual($violations[0]->getMessage(), 'Title: may not be longer than 255 characters.'); + $this->assertEqual($violations[0]->getMessage(), 'Title: the text may not be longer than 255 characters.'); $node->set('title', NULL); $violations = $node->validate(); diff --git a/core/modules/node/lib/Drupal/node/Tests/Views/FieldTypeTest.php b/core/modules/node/lib/Drupal/node/Tests/Views/FieldTypeTest.php index e8f1e2c..17bcea5 100644 --- a/core/modules/node/lib/Drupal/node/Tests/Views/FieldTypeTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/Views/FieldTypeTest.php @@ -7,8 +7,6 @@ namespace Drupal\node\Tests\Views; -use Drupal\views\Views; - /** * Tests the Drupal\node\Plugin\views\field\Type handler. */ @@ -40,7 +38,7 @@ public function testFieldType() { 'node_field_data_type' => 'node_field_data_type', ); - $view = Views::getView('test_field_type'); + $view = views_get_view('test_field_type'); $this->executeView($view); $this->assertIdenticalResultset($view, $expected_result, $column_map, 'The correct node type was displayed.'); } diff --git a/core/modules/node/lib/Drupal/node/Tests/Views/FilterUidRevisionTest.php b/core/modules/node/lib/Drupal/node/Tests/Views/FilterUidRevisionTest.php index 1e38fb4..a1cf0f2 100644 --- a/core/modules/node/lib/Drupal/node/Tests/Views/FilterUidRevisionTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/Views/FilterUidRevisionTest.php @@ -7,8 +7,6 @@ namespace Drupal\node\Tests\Views; -use Drupal\views\Views; - /** * Tests the node_uid_revision handler. */ @@ -55,7 +53,7 @@ public function testFilter() { // or the main node. $this->drupalCreateNode(array('uid' => $no_author->id())); - $view = Views::getView('test_filter_node_uid_revision'); + $view = views_get_view('test_filter_node_uid_revision'); $view->initHandlers(); $view->filter['uid_revision']->value = array($author->id()); diff --git a/core/modules/node/lib/Drupal/node/Tests/Views/FrontPageTest.php b/core/modules/node/lib/Drupal/node/Tests/Views/FrontPageTest.php index 7867334..63c101f 100644 --- a/core/modules/node/lib/Drupal/node/Tests/Views/FrontPageTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/Views/FrontPageTest.php @@ -9,7 +9,6 @@ use Drupal\views\Tests\ViewTestBase; use Drupal\views\ViewExecutable; -use Drupal\views\Views; /** * Tests the default frontpage provided by views. @@ -54,7 +53,7 @@ public function testFrontPage() { ->set('name', $site_name) ->save(); - $view = Views::getView('frontpage'); + $view = views_get_view('frontpage'); $view->setDisplay('page_1'); $this->executeView($view); $view->preview(); diff --git a/core/modules/node/lib/Drupal/node/Tests/Views/RevisionRelationships.php b/core/modules/node/lib/Drupal/node/Tests/Views/RevisionRelationships.php index 4968048..8a31ceb 100644 --- a/core/modules/node/lib/Drupal/node/Tests/Views/RevisionRelationships.php +++ b/core/modules/node/lib/Drupal/node/Tests/Views/RevisionRelationships.php @@ -6,7 +6,6 @@ */ namespace Drupal\node\Tests\Views; -use Drupal\views\Views; use Drupal\views\Tests\ViewTestBase; use Drupal\views\Tests\ViewTestData; @@ -59,7 +58,7 @@ public function testNodeRevisionRelationship() { ); // Here should be two rows. - $view_nid = Views::getView('test_node_revision_nid'); + $view_nid = views_get_view('test_node_revision_nid'); $this->executeView($view_nid, array($node->id())); $resultset_nid = array( array( @@ -76,7 +75,7 @@ public function testNodeRevisionRelationship() { $this->assertIdenticalResultset($view_nid, $resultset_nid, $column_map); // There should be only one row with active revision 2. - $view_vid = Views::getView('test_node_revision_vid'); + $view_vid = views_get_view('test_node_revision_vid'); $this->executeView($view_vid, array($node->id())); $resultset_vid = array( array( diff --git a/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php b/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php index a44a369..33b8ba7 100644 --- a/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php @@ -6,9 +6,7 @@ */ namespace Drupal\node\Tests\Views; - use Drupal\Core\Language\Language; -use Drupal\views\Views; /** * Tests the node row plugin. @@ -111,7 +109,7 @@ public function drupalCreateComment(array $settings = array()) { * Tests the node row plugin. */ public function testRowPlugin() { - $view = Views::getView('test_node_row_plugin'); + $view = views_get_view('test_node_row_plugin'); $view->initDisplay(); $view->setDisplay('page_1'); $view->initStyle(); diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php index 844e1a3..20f6257 100644 --- a/core/modules/node/node.api.php +++ b/core/modules/node/node.api.php @@ -150,7 +150,7 @@ * 'grant_update' => 0, * 'grant_delete' => 0, * ); - * db_insert('node_access')->fields($record)->execute(); + * drupal_write_record('node_access', $record); * @endcode * And then in its hook_node_grants() implementation, it would need to return: * @code diff --git a/core/modules/node/node.module b/core/modules/node/node.module index c97851e..74dc548 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -898,7 +898,7 @@ function theme_node_search_admin($variables) { $rows[] = $row; } $table = array( - '#type' => 'table', + '#theme' => 'table', '#header' => $header, '#rows' => $rows, ); diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc index fe5b0c1..e751bc2 100644 --- a/core/modules/node/node.pages.inc +++ b/core/modules/node/node.pages.inc @@ -84,7 +84,7 @@ function template_preprocess_node_preview(&$variables) { // Render trimmed teaser version of the post. $node_teaser = node_view($node, 'teaser'); - $node_teaser['#attached']['library'][] = 'node/drupal.node.preview'; + $node_teaser['#attached']['library'][] = array('node', 'drupal.node.preview'); $variables['teaser'] = $node_teaser; // Render full version of the post. $node_full = node_view($node, 'full'); @@ -175,7 +175,7 @@ function node_revision_overview($node) { } $build['node_revisions_table'] = array( - '#type' => 'table', + '#theme' => 'table', '#rows' => $rows, '#header' => $header, '#attached' => array ( diff --git a/core/modules/node/templates/node-edit-form.html.twig b/core/modules/node/templates/node-edit-form.html.twig index c208cf5..eee9ecc 100644 --- a/core/modules/node/templates/node-edit-form.html.twig +++ b/core/modules/node/templates/node-edit-form.html.twig @@ -15,9 +15,11 @@ * @ingroup themeable */ #} +{% hide(form.advanced) %} +{% hide(form.actions) %}
- {{ form|without('advanced', 'actions') }} + {{ form }}
{{ form.advanced }} diff --git a/core/modules/node/templates/node.html.twig b/core/modules/node/templates/node.html.twig index 5bf5ad9..1f8c823 100644 --- a/core/modules/node/templates/node.html.twig +++ b/core/modules/node/templates/node.html.twig @@ -18,8 +18,8 @@ * - label: The title of the node. * - content: All node items. Use {{ content }} to print them all, * or print a subset such as {{ content.field_example }}. Use - * {{ content|without('field_example') %} to temporarily suppress the printing - * of a given child element. + * {% hide(content.field_example) %} to temporarily suppress the printing + * of a given element. * - user_picture: The node author's picture from user-picture.html.twig. * - date: Formatted creation date. Preprocess functions can reformat it by * calling format_date() with the desired parameters on @@ -93,7 +93,9 @@ {% endif %} - {{ content|without('links') }} + {# We hide links now so that we can render them later. #} + {% hide(content.links) %} + {{ content }}
{{ content.links }} diff --git a/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_node_row_plugin.yml b/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_node_row_plugin.yml index 4efc395..84b9a57 100644 --- a/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_node_row_plugin.yml +++ b/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_node_row_plugin.yml @@ -42,14 +42,14 @@ display: display_plugin: default display_title: Master id: default - position: 0 + position: { } page_1: display_options: path: test-node-row-plugin display_plugin: page display_title: Page id: page_1 - position: 0 + position: { } label: test_node_row_plugin langcode: en module: views diff --git a/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/NumberItemBase.php b/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/NumberItemBase.php index a238861..c8f29b8 100644 --- a/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/NumberItemBase.php +++ b/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/NumberItemBase.php @@ -7,12 +7,12 @@ namespace Drupal\number\Plugin\Field\FieldType; -use Drupal\Core\Field\FieldItemBase; +use Drupal\Core\Field\ConfigFieldItemBase; /** * Base class for 'number' configurable field types. */ -abstract class NumberItemBase extends FieldItemBase { +abstract class NumberItemBase extends ConfigFieldItemBase { /** * {@inheritdoc} diff --git a/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php b/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php index 2f5552b..a0f0a0e 100644 --- a/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php +++ b/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php @@ -150,195 +150,45 @@ function testNumberDecimalField() { * Test number_integer field. */ function testNumberIntegerField() { - $minimum = rand(-4000, -2000); - $maximum = rand(2000, 4000); - - // Create a field with settings to validate. - $field_name = drupal_strtolower($this->randomName()); - entity_create('field_config', array( - 'name' => $field_name, - 'entity_type' => 'entity_test', - 'type' => 'number_integer', - ))->save(); - - entity_create('field_instance_config', array( - 'field_name' => $field_name, - 'entity_type' => 'entity_test', - 'bundle' => 'entity_test', - 'settings' => array( - 'min' => $minimum, 'max' => $maximum, - ) - ))->save(); - - entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($field_name, array( - 'type' => 'number', - 'settings' => array( - 'placeholder' => '4' - ), - )) - ->save(); - entity_get_display('entity_test', 'entity_test', 'default') - ->setComponent($field_name, array( - 'type' => 'number_integer', - )) - ->save(); - - // Display creation form. - $this->drupalGet('entity_test/add'); - $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed'); - $this->assertRaw('placeholder="4"'); - - // Submit a valid integer - $value = rand($minimum, $maximum); + // Display the "Add content type" form. + $this->drupalGet('admin/structure/types/add'); + + // Add a content type. + $name = $this->randomName(); + $type = drupal_strtolower($name); + $edit = array('name' => $name, 'type' => $type); + $this->drupalPostForm(NULL, $edit, t('Save and manage fields')); + + // Add an integer field to the newly-created type. + $label = $this->randomName(); + $field_name = drupal_strtolower($label); $edit = array( - 'user_id' => 1, - 'name' => $this->randomName(), - "{$field_name}[0][value]" => $value, + 'fields[_add_new_field][label]'=> $label, + 'fields[_add_new_field][field_name]' => $field_name, + 'fields[_add_new_field][type]' => 'number_integer', ); $this->drupalPostForm(NULL, $edit, t('Save')); - preg_match('|entity_test/manage/(\d+)|', $this->url, $match); - $id = $match[1]; - $this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created'); - // Try to set a value below the minimum value - $this->drupalGet('entity_test/add'); + // Add prefix and suffix for the newly-created field. + $prefix = $this->randomName(); + $suffix = $this->randomName(); $edit = array( - 'user_id' => 1, - 'name' => $this->randomName(), - "{$field_name}[0][value]" => $minimum - 1, + 'instance[settings][prefix]' => $prefix, + 'instance[settings][suffix]' => $suffix, ); - $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertRaw(t('%name must be higher than or equal to %minimum.', array('%name' => $field_name, '%minimum' => $minimum)), 'Correctly failed to save integer value less than minimum allowed value.'); + $this->drupalPostForm("admin/structure/types/manage/$type/fields/node.$type.field_$field_name", $edit, t('Save settings')); - // Try to set a decimal value - $this->drupalGet('entity_test/add'); + // Set the formatter to "unformatted" and to "number_integer", and just + // check that the settings summary does not generate warnings. + $this->drupalGet("admin/structure/types/manage/$type/display"); $edit = array( - 'user_id' => 1, - 'name' => $this->randomName(), - "{$field_name}[0][value]" => 1.5, + "fields[field_$field_name][type]" => 'number_unformatted', ); $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertRaw(t('%name is not a valid number.', array('%name' => $field_name)), 'Correctly failed to save decimal value to integer field.'); - - // Try to set a value above the maximum value - $this->drupalGet('entity_test/add'); $edit = array( - 'user_id' => 1, - 'name' => $this->randomName(), - "{$field_name}[0][value]" => $maximum + 1, + "fields[field_$field_name][type]" => 'number_integer', ); $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertRaw(t('%name must be lower than or equal to %maximum.', array('%name' => $field_name, '%maximum' => $maximum)), 'Correctly failed to save integer value greater than maximum allowed value.'); - - // Test with valid entries. - $valid_entries = array( - '-1234', - '0', - '1234', - ); - - foreach ($valid_entries as $valid_entry) { - $this->drupalGet('entity_test/add'); - $edit = array( - 'user_id' => 1, - 'name' => $this->randomName(), - "{$field_name}[0][value]" => $valid_entry, - ); - $this->drupalPostForm(NULL, $edit, t('Save')); - preg_match('|entity_test/manage/(\d+)|', $this->url, $match); - $id = $match[1]; - $this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created'); - $this->assertRaw($valid_entry, 'Value is displayed.'); - } - } - - /** - * Test number_float field. - */ - function testNumberFloatField() { - // Create a field with settings to validate. - $field_name = drupal_strtolower($this->randomName()); - entity_create('field_config', array( - 'name' => $field_name, - 'entity_type' => 'entity_test', - 'type' => 'number_float', - ))->save(); - - entity_create('field_instance_config', array( - 'field_name' => $field_name, - 'entity_type' => 'entity_test', - 'bundle' => 'entity_test', - ))->save(); - - entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($field_name, array( - 'type' => 'number', - 'settings' => array( - 'placeholder' => '0.00' - ), - )) - ->save(); - - entity_get_display('entity_test', 'entity_test', 'default') - ->setComponent($field_name, array( - 'type' => 'number_decimal', - )) - ->save(); - - // Display creation form. - $this->drupalGet('entity_test/add'); - $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed'); - $this->assertRaw('placeholder="0.00"'); - - // Submit a signed decimal value within the allowed precision and scale. - $value = '-1234.5678'; - $edit = array( - 'user_id' => 1, - 'name' => $this->randomName(), - "{$field_name}[0][value]" => $value, - ); - $this->drupalPostForm(NULL, $edit, t('Save')); - preg_match('|entity_test/manage/(\d+)|', $this->url, $match); - $id = $match[1]; - $this->assertText(t('entity_test @id has been created.', array('@id' => $id)), 'Entity was created'); - $this->assertRaw(round($value, 2), 'Value is displayed.'); - - // Try to create entries with more than one decimal separator; assert fail. - $wrong_entries = array( - '3.14.159', - '0..45469', - '..4589', - '6.459.52', - '6.3..25', - ); - - foreach ($wrong_entries as $wrong_entry) { - $this->drupalGet('entity_test/add'); - $edit = array( - "{$field_name}[0][value]" => $wrong_entry, - ); - $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertRaw(t('%name must be a number.', array('%name' => $field_name)), 'Correctly failed to save float value with more than one decimal point.'); - } - - // Try to create entries with minus sign not in the first position. - $wrong_entries = array( - '3-3', - '4-', - '1.3-', - '1.2-4', - '-10-10', - ); - - foreach ($wrong_entries as $wrong_entry) { - $this->drupalGet('entity_test/add'); - $edit = array( - "{$field_name}[0][value]" => $wrong_entry, - ); - $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertRaw(t('%name must be a number.', array('%name' => $field_name)), 'Correctly failed to save float value with minus sign in the wrong position.'); - } } /** diff --git a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListItemBase.php b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListItemBase.php index de95075..6e7416b 100644 --- a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListItemBase.php +++ b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListItemBase.php @@ -8,14 +8,14 @@ namespace Drupal\options\Plugin\Field\FieldType; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Field\FieldItemBase; +use Drupal\Core\Field\ConfigFieldItemBase; use Drupal\Core\Session\AccountInterface; use Drupal\Core\TypedData\AllowedValuesInterface; /** * Plugin base class inherited by the options field types. */ -abstract class ListItemBase extends FieldItemBase implements AllowedValuesInterface { +abstract class ListItemBase extends ConfigFieldItemBase implements AllowedValuesInterface { /** * {@inheritdoc} diff --git a/core/modules/path/path.admin.inc b/core/modules/path/path.admin.inc index d22fe66..a2b2072 100644 --- a/core/modules/path/path.admin.inc +++ b/core/modules/path/path.admin.inc @@ -89,7 +89,7 @@ function path_admin_overview($keys = NULL) { } $build['path_table'] = array( - '#type' => 'table', + '#theme' => 'table', '#header' => $header, '#rows' => $rows, '#empty' => t('No URL aliases available. Add URL alias.', array('@link' => url('admin/config/search/path/add'))), diff --git a/core/modules/path/path.module b/core/modules/path/path.module index 704f9a2..20d9fae 100644 --- a/core/modules/path/path.module +++ b/core/modules/path/path.module @@ -104,7 +104,7 @@ function path_form_node_form_alter(&$form, $form_state) { 'class' => array('path-form'), ), '#attached' => array( - 'library' => array('path/drupal.path'), + 'library' => array(array('path', 'drupal.path')), ), '#access' => $account->hasPermission('create url aliases') || $account->hasPermission('administer url aliases'), '#weight' => 30, diff --git a/core/modules/picture/lib/Drupal/picture/Entity/PictureMapping.php b/core/modules/picture/lib/Drupal/picture/Entity/PictureMapping.php index aa8b332..ba1351d 100644 --- a/core/modules/picture/lib/Drupal/picture/Entity/PictureMapping.php +++ b/core/modules/picture/lib/Drupal/picture/Entity/PictureMapping.php @@ -48,6 +48,13 @@ class PictureMapping extends ConfigEntityBase implements PictureMappingInterface public $id; /** + * The picture UUID. + * + * @var string + */ + public $uuid; + + /** * The picture label. * * @var string diff --git a/core/modules/picture/lib/Drupal/picture/Plugin/Field/FieldFormatter/PictureFormatter.php b/core/modules/picture/lib/Drupal/picture/Plugin/Field/FieldFormatter/PictureFormatter.php index a6d3b9c..403cf52 100644 --- a/core/modules/picture/lib/Drupal/picture/Plugin/Field/FieldFormatter/PictureFormatter.php +++ b/core/modules/picture/lib/Drupal/picture/Plugin/Field/FieldFormatter/PictureFormatter.php @@ -172,7 +172,7 @@ public function viewElements(FieldItemListInterface $items) { $elements[$delta] = array( '#theme' => 'picture_formatter', '#attached' => array('library' => array( - 'core/picturefill', + array('core', 'picturefill'), )), '#item' => $item, '#image_style' => $fallback_image_style, diff --git a/core/modules/rdf/lib/Drupal/rdf/Entity/RdfMapping.php b/core/modules/rdf/lib/Drupal/rdf/Entity/RdfMapping.php index 2256dd4..1916320 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Entity/RdfMapping.php +++ b/core/modules/rdf/lib/Drupal/rdf/Entity/RdfMapping.php @@ -33,6 +33,13 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface { public $id; /** + * UUID for the config entity. + * + * @var string + */ + public $uuid; + + /** * Entity type to be mapped. * * @var string diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/Field/DateTimeFieldRdfaTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/Field/DateTimeFieldRdfaTest.php deleted file mode 100644 index d859f25..0000000 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/Field/DateTimeFieldRdfaTest.php +++ /dev/null @@ -1,63 +0,0 @@ - 'Field formatter: datetime', - 'description' => 'Tests RDFa output by datetime field formatters.', - 'group' => 'RDF', - ); - } - - public function setUp() { - parent::setUp(); - - $this->createTestField(); - - // Add the mapping. - $mapping = rdf_get_mapping('entity_test', 'entity_test'); - $mapping->setFieldMapping($this->fieldName, array( - 'properties' => array('schema:dateCreated'), - ))->save(); - - // Set up test entity. - $this->entity = entity_create('entity_test', array()); - $this->entity->{$this->fieldName}->value = $this->testValue; - } - - /** - * Tests the default formatter. - */ - public function testDefaultFormatter() { - $this->assertFormatterRdfa('datetime_default', 'http://schema.org/dateCreated', $this->testValue . 'Z', 'literal', 'http://www.w3.org/2001/XMLSchema#dateTime'); - } -} diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/Field/FieldRdfaTestBase.php b/core/modules/rdf/lib/Drupal/rdf/Tests/Field/FieldRdfaTestBase.php index 5afeeab..9a9dec2 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/Field/FieldRdfaTestBase.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/Field/FieldRdfaTestBase.php @@ -66,10 +66,8 @@ public function setUp() { * The expected value of the property. * @param string $object_type * The object's type, either 'uri' or 'literal'. - * @param string $datatype - * The data type of the property. */ - protected function assertFormatterRdfa($formatter, $property, $value, $object_type = 'literal', $datatype = '') { + protected function assertFormatterRdfa($formatter, $property, $value, $object_type = 'literal') { // The field formatter will be rendered inside the entity. Set the field // formatter in the entity display options before rendering the entity. entity_get_display('entity_test', 'entity_test', 'default') @@ -78,13 +76,11 @@ protected function assertFormatterRdfa($formatter, $property, $value, $object_ty $build = entity_view($this->entity, 'default'); $output = drupal_render($build); $graph = new \EasyRdf_Graph($this->uri, $output, 'rdfa'); + $expected_value = array( 'type' => $object_type, 'value' => $value, ); - if ($datatype) { - $expected_value['datatype'] = $datatype; - } $this->assertTrue($graph->hasProperty($this->uri, $property, $expected_value), "Formatter $formatter exposes data correctly for {$this->fieldType} fields."); } diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/Field/TextFieldRdfaTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/Field/TextFieldRdfaTest.php index d10318c..b350b95 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/Field/TextFieldRdfaTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/Field/TextFieldRdfaTest.php @@ -73,7 +73,7 @@ public function testDefaultFormatter() { * Tests the plain formatter. */ public function testPlainFormatter() { - $this->assertFormatterRdfa('string', 'http://schema.org/text', $this->testValue); + $this->assertFormatterRdfa('text_plain', 'http://schema.org/text', $this->testValue); } /** diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/Derivative/EntityDerivative.php b/core/modules/rest/lib/Drupal/rest/Plugin/Derivative/EntityDerivative.php index f77d5e3..2b3cf22 100644 --- a/core/modules/rest/lib/Drupal/rest/Plugin/Derivative/EntityDerivative.php +++ b/core/modules/rest/lib/Drupal/rest/Plugin/Derivative/EntityDerivative.php @@ -52,7 +52,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) { /** * Implements DerivativeInterface::getDerivativeDefinition(). */ - public function getDerivativeDefinition($derivative_id, $base_plugin_definition) { + public function getDerivativeDefinition($derivative_id, array $base_plugin_definition) { if (!isset($this->derivatives)) { $this->getDerivativeDefinitions($base_plugin_definition); } @@ -64,7 +64,7 @@ public function getDerivativeDefinition($derivative_id, $base_plugin_definition) /** * Implements DerivativeInterface::getDerivativeDefinitions(). */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { if (!isset($this->derivatives)) { // Add in the default plugin configuration and the resource type. foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { diff --git a/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php b/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php index 4c4f6bc..749337c 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\rest\test\CreateTest. + * Definition of Drupal\rest\test\CreateTest. */ namespace Drupal\rest\Tests; @@ -106,7 +106,7 @@ public function testCreate() { $response = $this->httpRequest('entity/' . $entity_type, 'POST', $invalid_serialized, $this->defaultMimeType); $this->assertResponse(422); $error = drupal_json_decode($response); - $this->assertEqual($error['error'], "Unprocessable Entity: validation failed.\nuuid.0.value: UUID: may not be longer than 128 characters.\n"); + $this->assertEqual($error['error'], "Unprocessable Entity: validation failed.\nuuid.0.value: This value is too long. It should have 128 characters or less.\n"); // Try to create an entity without proper permissions. $this->drupalLogout(); @@ -125,5 +125,4 @@ public function testCreate() { // @todo Add a security test. It should not be possible for example to // create a test entity on a node resource route. } - } diff --git a/core/modules/rest/lib/Drupal/rest/Tests/NodeTest.php b/core/modules/rest/lib/Drupal/rest/Tests/NodeTest.php index c4a1704..86df206 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/NodeTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/NodeTest.php @@ -17,11 +17,9 @@ class NodeTest extends RESTTestBase { /** * Modules to enable. * - * Ensure that the node resource works with comment module enabled. - * * @var array */ - public static $modules = array('hal', 'rest', 'comment'); + public static $modules = array('hal', 'rest'); public static function getInfo() { return array( @@ -51,6 +49,8 @@ protected function enableNodeConfiguration($method, $operation) { * Performs various tests on nodes and their REST API. */ public function testNodes() { + // Tests that the node resource works with comment module enabled. + $this->container->get('module_handler')->install(array('comment')); $this->enableNodeConfiguration('GET', 'view'); $node = $this->entityCreate('node'); diff --git a/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php b/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php index 598401b..9f8d413 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\rest\test\UpdateTest. + * Contains Drupal\rest\test\UpdateTest. */ namespace Drupal\rest\Tests; @@ -149,7 +149,7 @@ public function testPatchUpdate() { $response = $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PATCH', $invalid_serialized, $this->defaultMimeType); $this->assertResponse(422); $error = drupal_json_decode($response); - $this->assertEqual($error['error'], "Unprocessable Entity: validation failed.\nuuid.0.value: UUID: may not be longer than 128 characters.\n"); + $this->assertEqual($error['error'], "Unprocessable Entity: validation failed.\nuuid.0.value: This value is too long. It should have 128 characters or less.\n"); // Try to update an entity without proper permissions. $this->drupalLogout(); @@ -162,5 +162,4 @@ public function testPatchUpdate() { $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'PATCH', $serialized, $this->defaultMimeType); $this->assertResponse(404); } - } diff --git a/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php b/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php index 2a72be5..5903780 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php @@ -7,7 +7,6 @@ namespace Drupal\rest\Tests\Views; -use Drupal\views\Views; use Drupal\views\Tests\Plugin\PluginTestBase; use Drupal\views\Tests\ViewTestData; @@ -68,7 +67,7 @@ protected function setUp() { */ public function testSerializerResponses() { // Test the serialize callback. - $view = Views::getView('test_serializer_display_field'); + $view = views_get_view('test_serializer_display_field'); $view->initDisplay(); $this->executeView($view); @@ -105,7 +104,7 @@ public function testSerializerResponses() { // Test the entity rows. - $view = Views::getView('test_serializer_display_entity'); + $view = views_get_view('test_serializer_display_entity'); $view->initDisplay(); $this->executeView($view); @@ -187,7 +186,7 @@ public function testUIFieldAlias() { $this->drupalPostForm($row_options, array('row_options[field_options][name][alias]' => ''), t('Apply')); $this->drupalPostForm(NULL, array(), t('Save')); - $view = Views::getView('test_serializer_display_field'); + $view = views_get_view('test_serializer_display_field'); $view->setDisplay('rest_export_1'); $this->executeView($view); @@ -222,7 +221,7 @@ public function testUIFieldAlias() { $this->drupalPostForm(NULL, array(), t('Save')); - $view = Views::getView('test_serializer_display_field'); + $view = views_get_view('test_serializer_display_field'); $view->setDisplay('rest_export_1'); $this->executeView($view); @@ -254,7 +253,7 @@ public function testFieldRawOutput() { $this->drupalPostForm($row_options, array('row_options[field_options][created][raw_output]' => '1'), t('Apply')); $this->drupalPostForm(NULL, array(), t('Save')); - $view = Views::getView('test_serializer_display_field'); + $view = views_get_view('test_serializer_display_field'); $view->setDisplay('rest_export_1'); $this->executeView($view); @@ -268,7 +267,7 @@ public function testFieldRawOutput() { * Tests the preview output for json output. */ public function testPreview() { - $view = Views::getView('test_serializer_display_entity'); + $view = views_get_view('test_serializer_display_entity'); $view->setDisplay('rest_export_1'); $this->executeView($view); diff --git a/core/modules/search/lib/Drupal/search/Entity/SearchPage.php b/core/modules/search/lib/Drupal/search/Entity/SearchPage.php index 947c878..b992a76 100644 --- a/core/modules/search/lib/Drupal/search/Entity/SearchPage.php +++ b/core/modules/search/lib/Drupal/search/Entity/SearchPage.php @@ -8,7 +8,6 @@ namespace Drupal\search\Entity; use Drupal\Core\Config\Entity\ConfigEntityBase; -use Drupal\Core\Config\Entity\ConfigEntityInterface; use Drupal\Core\Config\Entity\EntityWithPluginBagInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Component\Plugin\ConfigurablePluginInterface; @@ -67,6 +66,13 @@ class SearchPage extends ConfigEntityBase implements SearchPageInterface, Entity public $label; /** + * The UUID of the search page entity. + * + * @var string + */ + public $uuid; + + /** * The configuration of the search page entity. * * @var array @@ -214,7 +220,7 @@ public static function postDelete(EntityStorageControllerInterface $storage_cont /** * {@inheritdoc} */ - public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) { + public static function sort($a, $b) { /** @var $a \Drupal\search\SearchPageInterface */ /** @var $b \Drupal\search\SearchPageInterface */ $a_status = (int) $a->status(); diff --git a/core/modules/search/lib/Drupal/search/Plugin/Derivative/SearchLocalTask.php b/core/modules/search/lib/Drupal/search/Plugin/Derivative/SearchLocalTask.php index 543c190..2024478 100644 --- a/core/modules/search/lib/Drupal/search/Plugin/Derivative/SearchLocalTask.php +++ b/core/modules/search/lib/Drupal/search/Plugin/Derivative/SearchLocalTask.php @@ -46,7 +46,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) { /** * {@inheritdoc} */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { $this->derivatives = array(); if ($default = $this->searchPageRepository->getDefaultSearchPage()) { diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php index 5f77bd0..cb07d81 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php @@ -7,8 +7,6 @@ namespace Drupal\search\Tests; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; - /** * Tests that comment count display toggles properly on comment status of node * @@ -91,9 +89,9 @@ function testSearchCommentCountToggle() { $this->assertText(t('1 comment'), 'Non-empty comment count displays for nodes with comment status set to Open'); // Test comment count display for nodes with comment status set to Closed - $this->searchable_nodes['0 comments']->set('comment', CommentItemInterface::CLOSED); + $this->searchable_nodes['0 comments']->set('comment', COMMENT_CLOSED); $this->searchable_nodes['0 comments']->save(); - $this->searchable_nodes['1 comment']->set('comment', CommentItemInterface::CLOSED); + $this->searchable_nodes['1 comment']->set('comment', COMMENT_CLOSED); $this->searchable_nodes['1 comment']->save(); $this->drupalPostForm('', $edit, t('Search')); @@ -101,9 +99,9 @@ function testSearchCommentCountToggle() { $this->assertText(t('1 comment'), 'Non-empty comment count displays for nodes with comment status set to Closed'); // Test comment count display for nodes with comment status set to Hidden - $this->searchable_nodes['0 comments']->set('comment', CommentItemInterface::HIDDEN); + $this->searchable_nodes['0 comments']->set('comment', COMMENT_HIDDEN); $this->searchable_nodes['0 comments']->save(); - $this->searchable_nodes['1 comment']->set('comment', CommentItemInterface::HIDDEN); + $this->searchable_nodes['1 comment']->set('comment', COMMENT_HIDDEN); $this->searchable_nodes['1 comment']->save(); $this->drupalPostForm('', $edit, t('Search')); diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php index b470ae6..e3977cb 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php @@ -7,7 +7,6 @@ namespace Drupal\search\Tests; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\field\Field; /** @@ -115,7 +114,7 @@ function testSearchResultsComment() { // Hide comments. $this->drupalLogin($this->admin_user); - $node->set('comment', CommentItemInterface::HIDDEN); + $node->set('comment', COMMENT_HIDDEN); $node->save(); // Invoke search index update. diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php index 5d16f80..25b8ff2 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php @@ -7,8 +7,6 @@ namespace Drupal\search\Tests; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; - /** * Indexes content and tests ranking factors. */ @@ -58,7 +56,7 @@ public function testRankings() { $settings = array( 'type' => 'page', 'comment' => array(array( - 'status' => CommentItemInterface::HIDDEN, + 'status' => COMMENT_HIDDEN, )), 'title' => 'Drupal rocks', 'body' => array(array('value' => "Drupal's search rocks")), @@ -77,7 +75,7 @@ public function testRankings() { $settings['created'] = REQUEST_TIME + 3600; break; case 'comments': - $settings['comment'][0]['status'] = CommentItemInterface::OPEN; + $settings['comment'][0]['status'] = COMMENT_OPEN; break; } } diff --git a/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php b/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php index 865704d..c6c7636 100644 --- a/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php +++ b/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php @@ -58,7 +58,7 @@ protected function setUp() { // Create a test entity to serialize. $this->values = array( 'name' => $this->randomName(), - 'user_id' => \Drupal::currentUser()->id(), + 'user_id' => $GLOBALS['user']->id(), 'field_test_text' => array( 'value' => $this->randomName(), 'format' => 'full_html', diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Entity/Shortcut.php b/core/modules/shortcut/lib/Drupal/shortcut/Entity/Shortcut.php index 56d4839..2ba7625 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Entity/Shortcut.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Entity/Shortcut.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\shortcut\Entity\Shortcut. + * Contains \Drupal\shortcut\Plugin\Core\Entity\Shortcut. */ namespace Drupal\shortcut\Entity; @@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\FieldDefinition; +use Drupal\Core\Routing\UrlMatcher; use Drupal\Core\Url; use Drupal\shortcut\ShortcutInterface; @@ -20,6 +21,7 @@ * @ContentEntityType( * id = "shortcut", * label = @Translation("Shortcut link"), + * module = "shortcut", * controllers = { * "access" = "Drupal\shortcut\ShortcutAccessController", * "form" = { diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Entity/ShortcutSet.php b/core/modules/shortcut/lib/Drupal/shortcut/Entity/ShortcutSet.php index fea529b..ce52aca 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Entity/ShortcutSet.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Entity/ShortcutSet.php @@ -9,10 +9,11 @@ use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\Core\Entity\EntityStorageControllerInterface; +use Drupal\shortcut\ShortcutInterface; use Drupal\shortcut\ShortcutSetInterface; /** - * Defines the Shortcut set configuration entity. + * Defines the Shortcut configuration entity. * * @ConfigEntityType( * id = "shortcut_set", @@ -51,6 +52,13 @@ class ShortcutSet extends ConfigEntityBase implements ShortcutSetInterface { public $id; /** + * The UUID for the configuration entity. + * + * @var string + */ + public $uuid; + + /** * The human-readable name of the configuration entity. * * @var string diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/SetCustomize.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/SetCustomize.php index 37f2041..e57770d 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Form/SetCustomize.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Form/SetCustomize.php @@ -17,11 +17,30 @@ class SetCustomize extends EntityFormController { /** - * The entity being used by this form. + * The shortcut storage controller. * - * @var \Drupal\shortcut\ShortcutSetInterface + * @var \Drupal\Core\Entity\EntityStorageControllerInterface */ - protected $entity; + protected $storageController; + + /** + * Constructs a SetCustomize object. + * + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * The entity manager. + */ + public function __construct(EntityManagerInterface $entity_manager) { + $this->storageController = $entity_manager->getStorageController('shortcut'); + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('entity.manager') + ); + } /** * {@inheritdoc} @@ -47,7 +66,8 @@ public function form(array $form, array &$form_state) { ), ); - foreach ($this->entity->getShortcuts() as $shortcut) { + $shortcuts = $this->storageController->loadByProperties(array('shortcut_set' => $this->entity->id())); + foreach ($shortcuts as $shortcut) { $id = $shortcut->id(); $form['shortcuts']['links'][$id]['#attributes']['class'][] = 'draggable'; $form['shortcuts']['links'][$id]['name']['#markup'] = l($shortcut->getTitle(), $shortcut->path->value); @@ -99,7 +119,8 @@ protected function actions(array $form, array &$form_state) { * {@inheritdoc} */ public function save(array $form, array &$form_state) { - foreach ($this->entity->getShortcuts() as $shortcut) { + $shortcuts = $this->storageController->loadByProperties(array('shortcut_set' => $this->entity->id())); + foreach ($shortcuts as $shortcut) { $shortcut->setWeight($form_state['values']['shortcuts']['links'][$shortcut->id()]['weight']); $shortcut->save(); } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutFormController.php b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutFormController.php index c0053f8..56f1487 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutFormController.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutFormController.php @@ -8,7 +8,13 @@ namespace Drupal\shortcut; use Drupal\Core\Entity\ContentEntityFormController; +use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\Query\QueryFactory; +use Drupal\Core\Form\FormBuilderInterface; use Drupal\Core\Language\Language; +use Drupal\Core\Path\AliasManagerInterface; +use Drupal\Core\Routing\UrlGeneratorInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Form controller for the shortcut entity forms. @@ -16,22 +22,68 @@ class ShortcutFormController extends ContentEntityFormController { /** - * The entity being used by this form. + * The path alias manager. * - * @var \Drupal\shortcut\ShortcutInterface + * @var \Drupal\Core\Path\AliasManagerInterface */ - protected $entity; + protected $aliasManager; + + /** + * The URL generator. + * + * @var \Drupal\Core\Routing\UrlGeneratorInterface + */ + protected $urlGenerator; + + /** + * The form builder. + * + * @var \Drupal\Core\Form\FormBuilderInterface + */ + protected $formBuilder; + + /** + * Constructs a new action form. + * + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * The entity manager. + * @param \Drupal\Core\Path\AliasManagerInterface $alias_manager + * The path alias manager. + * @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator + * The URL generator. + * @param \Drupal\Core\Form\FormBuilderInterface $form_builder + * The form builder. + */ + public function __construct(EntityManagerInterface $entity_manager, AliasManagerInterface $alias_manager, UrlGeneratorInterface $url_generator, FormBuilderInterface $form_builder) { + $this->entityManager = $entity_manager; + $this->aliasManager = $alias_manager; + $this->urlGenerator = $url_generator; + $this->formBuilder = $form_builder; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('entity.manager'), + $container->get('path.alias_manager'), + $container->get('url_generator'), + $container->get('form_builder') + ); + } /** * {@inheritdoc} */ public function form(array $form, array &$form_state) { $form = parent::form($form, $form_state); + $entity = $this->entity; $form['title'] = array( '#type' => 'textfield', '#title' => t('Name'), - '#default_value' => $this->entity->getTitle(), + '#default_value' => $entity->getTitle(), '#size' => 40, '#maxlength' => 255, '#required' => TRUE, @@ -43,28 +95,28 @@ public function form(array $form, array &$form_state) { '#title' => t('Path'), '#size' => 40, '#maxlength' => 255, - '#field_prefix' => $this->url('', array(), array('absolute' => TRUE)), - '#default_value' => $this->entity->path->value, + '#field_prefix' => $this->urlGenerator->generateFromRoute('', array(), array('absolute' => TRUE)), + '#default_value' => $entity->path->value, ); $form['langcode'] = array( '#title' => t('Language'), '#type' => 'language_select', - '#default_value' => $this->entity->getUntranslated()->language()->id, + '#default_value' => $entity->getUntranslated()->language()->id, '#languages' => Language::STATE_ALL, ); $form['shortcut_set'] = array( '#type' => 'value', - '#value' => $this->entity->bundle(), + '#value' => $entity->bundle(), ); $form['route_name'] = array( '#type' => 'value', - '#value' => $this->entity->getRouteName(), + '#value' => $entity->getRouteName(), ); $form['route_parameters'] = array( '#type' => 'value', - '#value' => $this->entity->getRouteParams(), + '#value' => $entity->getRouteParams(), ); return $form; @@ -88,7 +140,7 @@ public function buildEntity(array $form, array &$form_state) { */ public function validate(array $form, array &$form_state) { if (!shortcut_valid_link($form_state['values']['path'])) { - $this->setFormError('path', $form_state, $this->t('The shortcut must correspond to a valid path on the site.')); + $this->formBuilder->setErrorByName('path', $form_state, $this->t('The shortcut must correspond to a valid path on the site.')); } parent::validate($form, $form_state); diff --git a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutInterface.php b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutInterface.php index 9a6bb98..7c44cba 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutInterface.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutInterface.php @@ -44,7 +44,7 @@ public function getWeight(); /** * Sets the weight among shortcuts with the same depth. * - * @param int $weight + *·@param int $weight * The shortcut weight. * * @return \Drupal\shortcut\ShortcutInterface diff --git a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetInterface.php b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetInterface.php index 21cc4f3..4289f78 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetInterface.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetInterface.php @@ -10,7 +10,7 @@ use Drupal\Core\Config\Entity\ConfigEntityInterface; /** - * Provides an interface defining a shortcut set entity. + * Provides an interface defining a shortcut entity. */ interface ShortcutSetInterface extends ConfigEntityInterface { diff --git a/core/modules/shortcut/shortcut.admin.inc b/core/modules/shortcut/shortcut.admin.inc index 3408d83..8e8b721 100644 --- a/core/modules/shortcut/shortcut.admin.inc +++ b/core/modules/shortcut/shortcut.admin.inc @@ -92,7 +92,7 @@ function shortcut_set_switch($form, &$form_state, $account = NULL) { } $form['#attached'] = array( - 'library' => array('shortcut/drupal.shortcut.admin'), + 'library' => array(array('shortcut', 'drupal.shortcut.admin')), ); $form['actions'] = array('#type' => 'actions'); diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module index ba0b04a..a97b447 100644 --- a/core/modules/shortcut/shortcut.module +++ b/core/modules/shortcut/shortcut.module @@ -412,7 +412,7 @@ function shortcut_preprocess_page(&$variables) { $variables['title_suffix']['add_or_remove_shortcut'] = array( '#attached' => array( 'library' => array( - 'shortcut/drupal.shortcut', + array('shortcut', 'drupal.shortcut'), ), ), '#prefix' => ' - {% endfor %} -
diff --git a/core/modules/system/tests/modules/common_test/common_test.module b/core/modules/system/tests/modules/common_test/common_test.module index 1a081df..c156c07 100644 --- a/core/modules/system/tests/modules/common_test/common_test.module +++ b/core/modules/system/tests/modules/common_test/common_test.module @@ -145,7 +145,7 @@ function common_test_library_info_alter(&$libraries, $module) { // Change the version of Farbtastic to 0.0. $libraries['jquery.farbtastic']['version'] = '0.0'; // Make Farbtastic depend on jQuery Form to test library dependencies. - $libraries['jquery.farbtastic']['dependencies'][] = 'core/jquery.form'; + $libraries['jquery.farbtastic']['dependencies'][] = array('core', 'jquery.form'); } } diff --git a/core/modules/system/tests/modules/common_test/lib/Drupal/common_test/Controller/CommonTestController.php b/core/modules/system/tests/modules/common_test/lib/Drupal/common_test/Controller/CommonTestController.php index 32bc04f..294adca 100644 --- a/core/modules/system/tests/modules/common_test/lib/Drupal/common_test/Controller/CommonTestController.php +++ b/core/modules/system/tests/modules/common_test/lib/Drupal/common_test/Controller/CommonTestController.php @@ -67,7 +67,7 @@ public function jsAndCssQuerystring() { $attached = array( '#attached' => array( 'library' => array( - 'node/drupal.node', + array('node', 'drupal.node'), ), 'css' => array( drupal_get_path('module', 'node') . '/css/node.admin.css' => array(), diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module index d7a08fc..bfc73b5 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -318,6 +318,19 @@ function entity_test_entity_test_insert($entity) { } /** + * Entity label callback. + * + * @param $entity + * The entity object. + * + * @return + * The label of the entity prefixed with "label callback". + */ +function entity_test_label_callback($entity) { + return 'label callback ' . $entity->name->value; +} + +/** * Implements hook_entity_field_access(). * * @see \Drupal\system\Tests\Entity\FieldAccessTest::testFieldAccess() diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Derivative/EntityTestLocalTasks.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Derivative/EntityTestLocalTasks.php index 8188ea4..b9bbefb 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Derivative/EntityTestLocalTasks.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Derivative/EntityTestLocalTasks.php @@ -17,7 +17,7 @@ class EntityTestLocalTasks extends DerivativeBase { /** * {@inheritdoc} */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { $this->derivatives = array(); $types = entity_test_entity_types(); diff --git a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php index d85d813..5d62a82 100644 --- a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php +++ b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php @@ -63,26 +63,15 @@ public function getInfo(ImageInterface $image) { ); } - if ($details) { - $this->load($image->getSource(), $details); - } return $details; } /** - * Creates a resource from a file. - * - * @param string $source - * String specifying the path of the image file. - * @param array $details - * An array of image details. - * - * @return bool - * TRUE or FALSE, based on success. + * {@inheritdoc} */ - protected function load($source, array $details) { - $this->logCall('load', array($source, $details)); - return TRUE; + public function load(ImageInterface $image) { + $this->logCall('load', array($image)); + return $image; } /** diff --git a/core/modules/system/tests/modules/menu_test/lib/Drupal/menu_test/Plugin/Derivative/LocalTaskTest.php b/core/modules/system/tests/modules/menu_test/lib/Drupal/menu_test/Plugin/Derivative/LocalTaskTest.php index 29314ef..807c78d 100644 --- a/core/modules/system/tests/modules/menu_test/lib/Drupal/menu_test/Plugin/Derivative/LocalTaskTest.php +++ b/core/modules/system/tests/modules/menu_test/lib/Drupal/menu_test/Plugin/Derivative/LocalTaskTest.php @@ -13,7 +13,7 @@ class LocalTaskTest extends DerivativeBase { /** * {@inheritdoc} */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { $weight = $base_plugin_definition['weight']; foreach (array('derive1' => 'Derive 1', 'derive2' => 'Derive 2') as $key => $title) { $this->derivatives[$key] = $base_plugin_definition; diff --git a/core/modules/system/tests/modules/module_test/module_test.install b/core/modules/system/tests/modules/module_test/module_test.install index 53dfa33..f3b274a 100644 --- a/core/modules/system/tests/modules/module_test/module_test.install +++ b/core/modules/system/tests/modules/module_test/module_test.install @@ -28,10 +28,6 @@ function module_test_schema() { * Implements hook_install(). */ function module_test_install() { - $schema = drupal_get_schema('module_test'); - db_insert('module_test') - ->fields(array( - 'data' => $schema['fields']['data']['type'], - )) - ->execute(); + $record = array('data' => 'Data inserted in hook_install()'); + drupal_write_record('module_test', $record); } diff --git a/core/modules/system/tests/modules/module_test/module_test.module b/core/modules/system/tests/modules/module_test/module_test.module index 0968c68..b1372c0 100644 --- a/core/modules/system/tests/modules/module_test/module_test.module +++ b/core/modules/system/tests/modules/module_test/module_test.module @@ -1,7 +1,5 @@ get('module_test.dependency') == 'missing dependency') { - if ($file->getName() == 'forum') { + if ($file->name == 'forum') { // Make forum module depend on ban. $info['dependencies'][] = 'ban'; } - elseif ($file->getName() == 'ban') { + elseif ($file->name == 'ban') { // Make ban depend on a made-up module. $info['dependencies'][] = 'foo'; } } elseif (\Drupal::state()->get('module_test.dependency') == 'dependency') { - if ($file->getName() == 'forum') { + if ($file->name == 'forum') { // Make the forum module depend on ban. $info['dependencies'][] = 'ban'; } - elseif ($file->getName() == 'ban') { + elseif ($file->name == 'ban') { // Make ban depend on xmlrpc module. $info['dependencies'][] = 'xmlrpc'; } } elseif (\Drupal::state()->get('module_test.dependency') == 'version dependency') { - if ($file->getName() == 'forum') { + if ($file->name == 'forum') { // Make the forum module depend on ban. $info['dependencies'][] = 'ban'; } - elseif ($file->getName() == 'ban') { + elseif ($file->name == 'ban') { // Make ban depend on a specific version of xmlrpc module. $info['dependencies'][] = 'xmlrpc (1.x)'; } - elseif ($file->getName() == 'xmlrpc') { + elseif ($file->name == 'xmlrpc') { // Set xmlrpc module to a version compatible with the above. $info['version'] = '8.x-1.0'; } } - if ($file->getName() == 'seven' && $type == 'theme') { + if ($file->name == 'seven' && $type == 'theme') { $info['regions']['test_region'] = t('Test region'); } - if ($file->getName() == 'module_test' && \Drupal::state()->get('module_test.hook_system_info_alter')) { + if ($file->name == 'module_test' && \Drupal::state()->get('module_test.hook_system_info_alter')) { $info['required'] = TRUE; $info['explanation'] = 'Testing hook_system_info_alter()'; } diff --git a/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php b/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php index 1a33551..dea1f29 100644 --- a/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php +++ b/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php @@ -19,7 +19,7 @@ class MockLayoutBlockDeriver implements DerivativeInterface { /** * Implements Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinition(). */ - public function getDerivativeDefinition($derivative_id, $base_plugin_definition) { + public function getDerivativeDefinition($derivative_id, array $base_plugin_definition) { $derivatives = $this->getDerivativeDefinitions($base_plugin_definition); if (isset($derivatives[$derivative_id])) { return $derivatives[$derivative_id]; @@ -29,7 +29,7 @@ public function getDerivativeDefinition($derivative_id, $base_plugin_definition) /** * Implements Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinitions(). */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { // This isn't strictly necessary, but it helps reduce clutter in // DerivativePluginTest::testDerivativeDecorator()'s $expected variable. // Since derivative definitions don't need further deriving, we remove this diff --git a/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/plugin_test/mock_block/MockMenuBlockDeriver.php b/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/plugin_test/mock_block/MockMenuBlockDeriver.php index aaa1d1c..35e7bca 100644 --- a/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/plugin_test/mock_block/MockMenuBlockDeriver.php +++ b/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/plugin_test/mock_block/MockMenuBlockDeriver.php @@ -19,7 +19,7 @@ class MockMenuBlockDeriver implements DerivativeInterface { /** * Implements Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinition(). */ - public function getDerivativeDefinition($derivative_id, $base_plugin_definition) { + public function getDerivativeDefinition($derivative_id, array $base_plugin_definition) { $derivatives = $this->getDerivativeDefinitions($base_plugin_definition); if (isset($derivatives[$derivative_id])) { return $derivatives[$derivative_id]; @@ -29,7 +29,7 @@ public function getDerivativeDefinition($derivative_id, $base_plugin_definition) /** * Implements Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinitions(). */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { // This isn't strictly necessary, but it helps reduce clutter in // DerivativePluginTest::testDerivativeDecorator()'s $expected variable. // Since derivative definitions don't need further deriving, we remove this diff --git a/core/modules/system/tests/modules/system_test/system_test.module b/core/modules/system/tests/modules/system_test/system_test.module index 4d3601b..b109341 100644 --- a/core/modules/system/tests/modules/system_test/system_test.module +++ b/core/modules/system/tests/modules/system_test/system_test.module @@ -1,6 +1,5 @@ get('system_test.dependencies')) || $test) { - if ($file->getName() == 'module_test') { + if ($file->name == 'module_test') { $info['hidden'] = FALSE; $info['dependencies'][] = array_shift($dependencies); \Drupal::state()->set('system_test.dependencies', $dependencies); $test = TRUE; } - if ($file->getName() == 'common_test') { + if ($file->name == 'common_test') { $info['hidden'] = FALSE; $info['version'] = '8.x-2.4-beta3'; } } // Make the system_dependencies_test visible by default. - if ($file->getName() == 'system_dependencies_test') { + if ($file->name == 'system_dependencies_test') { $info['hidden'] = FALSE; } - if (in_array($file->getName(), array( + if (in_array($file->name, array( 'system_incompatible_module_version_dependencies_test', 'system_incompatible_core_version_dependencies_test', 'system_incompatible_module_version_test', @@ -67,7 +66,7 @@ function system_test_system_info_alter(&$info, Extension $file, $type) { ))) { $info['hidden'] = FALSE; } - if ($file->getName() == 'requirements1_test' || $file->getName() == 'requirements2_test') { + if ($file->name == 'requirements1_test' || $file->name == 'requirements2_test') { $info['hidden'] = FALSE; } } diff --git a/core/modules/system/tests/modules/theme_page_test/theme_page_test.module b/core/modules/system/tests/modules/theme_page_test/theme_page_test.module index 7373fab..1180d64 100644 --- a/core/modules/system/tests/modules/theme_page_test/theme_page_test.module +++ b/core/modules/system/tests/modules/theme_page_test/theme_page_test.module @@ -1,11 +1,9 @@ 'twig_theme_test_filter', - '#quote' => array( - 'content' => array('#markup' => 'You can only find truth with logic if you have already found truth without it.'), - 'author' => array('#markup' => 'Gilbert Keith Chesterton'), - 'date' => array('#markup' => '1874-1936'), - ), - ); - } - } - diff --git a/core/modules/system/tests/modules/twig_theme_test/templates/twig_theme_test.filter.html.twig b/core/modules/system/tests/modules/twig_theme_test/templates/twig_theme_test.filter.html.twig deleted file mode 100644 index ce4c405..0000000 --- a/core/modules/system/tests/modules/twig_theme_test/templates/twig_theme_test.filter.html.twig +++ /dev/null @@ -1,14 +0,0 @@ -
No author: {{ quote|without('author') }}.
-
Complete quote after without: {{ quote }}.
-
Only author: {{ quote.author }}.
-
No author or date: {{ quote|without('date', 'author') }}.
-
Only date: {{ quote.date }}.
-
Complete quote again for good measure: {{ quote }}.
-
Marked-up: -
-

{{ quote.content }}

- -
-
diff --git a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module index e47b30c..6edb6f6 100644 --- a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module +++ b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module @@ -4,10 +4,6 @@ * Implements hook_theme(). */ function twig_theme_test_theme($existing, $type, $theme, $path) { - $items['twig_theme_test_filter'] = array( - 'variables' => array('quote' => array()), - 'template' => 'twig_theme_test.filter', - ); $items['twig_theme_test_php_variables'] = array( 'template' => 'twig_theme_test.php_variables', ); diff --git a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.routing.yml b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.routing.yml index c187bc2..96befd4 100644 --- a/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.routing.yml +++ b/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.routing.yml @@ -11,10 +11,3 @@ twig_theme_test.trans: _content: '\Drupal\twig_theme_test\TwigThemeTestController::transBlockRender' requirements: _access: 'TRUE' - -twig_theme_test.filter: - path: '/twig-theme-test/filter' - defaults: - _content: '\Drupal\twig_theme_test\TwigThemeTestController::testFilterRender' - requirements: - _access: 'TRUE' diff --git a/core/modules/system/theme.api.php b/core/modules/system/theme.api.php index c86b161..931707b 100644 --- a/core/modules/system/theme.api.php +++ b/core/modules/system/theme.api.php @@ -9,104 +9,74 @@ * layer. Each theme can take control over most of Drupal's output, and * has complete control over the CSS. * - * The theme layer is utilized by specifying theme implementations in a - * renderable array. The names of the keys in a renderable array - * determine how the information in the array is converted to themed output. - * - * To invoke a theme implementation on a renderable array, define a key named - * '#theme' and assign it a string value that is the name of a theme hook. Any - * variables that the theme hook requires may be supplied as additional keys -- - * prepended with a '#' character -- in the renderable array. + * Inside Drupal, the theme layer is utilized by the use of the _theme() + * function, which is passed the name of a component (the theme hook) + * and an array of variables. For example, + * _theme('table', array('header' => $header, 'rows' => $rows)); + * Additionally, the _theme() function can take an array of theme + * hooks, which can be used to provide 'fallback' implementations to + * allow for more specific control of output. For example, the function: + * _theme(array('table__foo', 'table'), $variables) would look to see if + * 'table__foo' is registered anywhere; if it is not, it would 'fall back' + * to the generic 'table' implementation. This can be used to attach specific + * theme functions to named objects, allowing the themer more control over + * specific types of output. + * + * Calling the _theme() function directly is highly discouraged. Building a + * renderable array is preferred. For example, rather than calling + * _theme('table', array()) in-place, one can assemble a renderable array as + * follows: * * @code - * $item_list = array( - * '#theme' => 'item_list', - * '#items' => $links, - * '#title' => t('Next steps'), + * $table = array( + * '#type' => 'table', + * '#header' => '', + * '#rows' => array(), * ); - * - * return $item_list; * @endcode * - * Do not call _theme() directly; instead, build and return a renderable array. - * If necessary, the array may be rendered to a string in-place - * by calling drupal_render(). + * Note that a table is defined as a type as well as a theme function. Building + * it as a type is preferred. The $table array can simply be passed along as + * a renderable array in a page build process. If necessary, the array may be + * rendered to a string by calling drupal_render(). * * @code - * $output = drupal_render($item_list); + * $output = drupal_render($table); * @endcode * - * @section sec_theme_hooks Theme Hooks - * Modules register theme hooks within a hook_theme()implementation and provide - * a default implementation via a function named theme_HOOK(). For instance, to - * theme a taxonomy term, the theme hook name is 'taxonomy_term'. If theming is - * handled via a function then the corresponding function name is - * theme_taxonomy_term(). If theming is handled via a template then the file - * should be named according to the value of the 'template' key registered with - * the theme hook (see hook_theme() for details). Default templates are - * implemented with the Twig rendering engine and are named the same as the - * theme hook, with underscores changed to hyphens, so for the 'taxonomy_term' - * theme hook, the default template is 'taxonomy-term.html.twig'. - * - * @subsection sub_overriding_theme_hooks Overriding Theme Hooks - * Themes may register new theme hooks within a hook_theme() - * implementation, but it is more common for themes to override default - * implementations provided by modules than to register entirely new theme - * hooks. Themes can override a default implementation by implementing a - * function named THEME_HOOK() (for example, the 'bartik' theme overrides the - * default implementation of the 'menu_tree' theme hook by implementing a - * bartik_menu_tree() function), or by adding a template file within its folder - * structure that follows the template naming structure used by the theme's - * rendering engine. For example, since the Bartik theme uses the Twig rendering - * engine, it overrides the default implementation of the 'page' theme hook by - * containing a 'page.html.twig' file within its folder structure. - * - * @subsection sub_preprocess_templates Preprocessing for Template Files - * If the implementation is a template file, several functions are called before - * the template file is invoked to modify the $variables array. These make up - * the "preprocessing" phase, and are executed (if they exist), in the following - * order (note that in the following list, HOOK indicates the theme hook name, - * MODULE indicates a module name, THEME indicates a theme name, and ENGINE - * indicates a theme engine name): - * - template_preprocess(&$variables, $hook): Creates a default set of variables - * for all theme hooks with template implementations. - * - template_preprocess_HOOK(&$variables): Should be implemented by the module - * that registers the theme hook, to set up default variables. - * - MODULE_preprocess(&$variables, $hook): hook_preprocess() is invoked on all - * implementing modules. - * - MODULE_preprocess_HOOK(&$variables): hook_preprocess_HOOK() is invoked on - * all implementing modules, so that modules that didn't define the theme hook - * can alter the variables. - * - ENGINE_engine_preprocess(&$variables, $hook): Allows the theme engine to - * set necessary variables for all theme hooks with template implementations. - * - ENGINE_engine_preprocess_HOOK(&$variables): Allows the theme engine to set - * necessary variables for the particular theme hook. - * - THEME_preprocess(&$variables, $hook): Allows the theme to set necessary - * variables for all theme hooks with template implementations. - * - THEME_preprocess_HOOK(&$variables): Allows the theme to set necessary - * variables specific to the particular theme hook. - * - * @subsection sub_preprocess_theme_funcs Preprocessing for Theme Functions - * If the theming implementation is a function, only the theme-hook-specific - * preprocess functions (the ones ending in _HOOK) are called from the list - * above. This is because theme hooks with function implementations need to be - * fast, and calling the non-theme-hook-specific preprocess functions for them - * would incur a noticeable performance penalty. - * - * @subsection sub_alternate_suggestions Suggesting Alternate Hooks - * Alternate hooks can be suggested by implementing the hook-specific - * hook_theme_suggestions_HOOK_alter() or the generic - * hook_theme_suggestions_alter(). These alter hooks are used to manipulate an - * array of suggested alternate theme hooks to use, in reverse order of - * priority. _theme() will use the highest priority implementation that exists. - * If none exists, _theme() will use the implementation for the theme hook it - * was called with. These suggestions are similar to and are used for similar - * reasons as assigning an array of theme hooks to the #theme property of a - * renderable array. The difference is whether the suggestions are determined - * when _theme() is called or through altering the suggestions via the - * suggestion alter hooks. - * - * @see drupal_render() + * As of Drupal 6, every theme hook is required to be registered by the + * module that owns it, so that Drupal can tell what to do with it and + * to make it simple for themes to identify and override the behavior + * for these calls. + * + * The theme hooks are registered via hook_theme(), which returns an + * array of arrays with information about the hook. It describes the + * arguments the function or template will need, and provides + * defaults for the template in case they are not filled in. If the default + * implementation is a function, by convention it is named theme_HOOK(). + * + * Each module should provide a default implementation for theme_hooks that + * it registers. This implementation may be either a function or a template; + * if it is a function it must be specified via hook_theme(). By convention, + * default implementations of theme hooks are named theme_HOOK. Default + * template implementations are stored in the module directory. + * + * Drupal's default template renderer is Twig. Drupal's theme engines can + * provide alternate template engines, such as XTemplate, Smarty and PHPTal. + * + * In order to create theme-specific implementations of these hooks, themes can + * implement their own version of theme hooks, either as functions or templates. + * These implementations will be used instead of the default implementation. If + * using a pure .theme without an engine, the .theme is required to implement + * its own version of hook_theme() to tell Drupal what it is implementing; + * themes utilizing an engine will have their well-named theming functions + * automatically registered for them. While this can vary based upon the theme + * engine, the standard is that theme functions should be named THEMENAME_HOOK. + * For example, for Drupal's default theme (Bartik) to implement the 'table' + * hook, the theme function should be called bartik_table(). + * + * The theme system is described and defined in theme.inc. + * * @see _theme() * @see hook_theme() * @see hooks diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Vocabulary.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Vocabulary.php index ee3d8f3..c9bf8b6 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Vocabulary.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Vocabulary.php @@ -54,6 +54,13 @@ class Vocabulary extends ConfigEntityBase implements VocabularyInterface { public $vid; /** + * The vocabulary UUID. + * + * @var string + */ + public $uuid; + + /** * Name of the vocabulary. * * @var string diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/OverviewTerms.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/OverviewTerms.php index 29868ab..8e5bcce 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/OverviewTerms.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/OverviewTerms.php @@ -318,7 +318,7 @@ public function buildForm(array $form, array &$form_state, VocabularyInterface $ 'group' => 'term-depth', 'hidden' => FALSE, ); - $form['terms']['#attached']['library'][] = 'taxonomy/drupal.taxonomy'; + $form['terms']['#attached']['library'][] = array('taxonomy', 'drupal.taxonomy'); $form['terms']['#attached']['js'][] = array( 'data' => array('taxonomy' => array('backStep' => $back_step, 'forwardStep' => $forward_step)), 'type' => 'setting', diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceFieldItemList.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceFieldItemList.php index e5cb463..42f6ee8 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceFieldItemList.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceFieldItemList.php @@ -7,12 +7,12 @@ namespace Drupal\taxonomy\Plugin\Field\FieldType; -use Drupal\Core\Field\FieldItemList; +use Drupal\Core\Field\ConfigFieldItemList; /** * Represents a configurable taxonomy_term_reference entity field item list. */ -class TaxonomyTermReferenceFieldItemList extends FieldItemList { +class TaxonomyTermReferenceFieldItemList extends ConfigFieldItemList { /** * {@inheritdoc} diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceItem.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceItem.php index c7e679b..db80f4b 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceItem.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceItem.php @@ -7,6 +7,7 @@ namespace Drupal\taxonomy\Plugin\Field\FieldType; +use Drupal\Core\Field\ConfigFieldItemInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem; use Drupal\Core\Session\AccountInterface; @@ -35,7 +36,7 @@ * list_class = "\Drupal\taxonomy\Plugin\Field\FieldType\TaxonomyTermReferenceFieldItemList" * ) */ -class TaxonomyTermReferenceItem extends EntityReferenceItem implements AllowedValuesInterface { +class TaxonomyTermReferenceItem extends EntityReferenceItem implements ConfigFieldItemInterface, AllowedValuesInterface { /** * {@inheritdoc} diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermValidationTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermValidationTest.php index 009d871..e36668f 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermValidationTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermValidationTest.php @@ -56,8 +56,7 @@ public function testValidation() { $violations = $term->validate(); $this->assertEqual(count($violations), 1, 'Violation found when name is too long.'); $this->assertEqual($violations[0]->getPropertyPath(), 'name.0.value'); - $field_label = $term->get('name')->getFieldDefinition()->getLabel(); - $this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', array('%name' => $field_label, '@max' => 255))); + $this->assertEqual($violations[0]->getMessage(), t('This value is too long. It should have %limit characters or less.', array('%limit' => 255))); $term->set('name', NULL); $violations = $term->validate(); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/RelationshipNodeTermDataTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/RelationshipNodeTermDataTest.php index 2d891b7..b3f5af2 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/RelationshipNodeTermDataTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/RelationshipNodeTermDataTest.php @@ -7,8 +7,6 @@ namespace Drupal\taxonomy\Tests\Views; -use Drupal\views\Views; - /** * Tests the node_term_data relationship handler. */ @@ -30,7 +28,7 @@ public static function getInfo() { } function testViewsHandlerRelationshipNodeTermData() { - $view = Views::getView('test_taxonomy_node_term_data'); + $view = views_get_view('test_taxonomy_node_term_data'); $this->executeView($view, array($this->term1->id(), $this->term2->id())); $resultset = array( array( diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/RelationshipRepresentativeNode.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/RelationshipRepresentativeNode.php index 1d754f0..bb22fda 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/RelationshipRepresentativeNode.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/RelationshipRepresentativeNode.php @@ -7,8 +7,6 @@ namespace Drupal\taxonomy\Tests\Views; -use Drupal\views\Views; - /** * Tests the representative node relationship for terms. */ @@ -33,7 +31,7 @@ public static function getInfo() { * Tests the relationship. */ public function testRelationship() { - $view = Views::getView('test_groupwise_term'); + $view = views_get_view('test_groupwise_term'); $this->executeView($view); $map = array('node_taxonomy_term_data_nid' => 'nid', 'tid' => 'tid'); $expected_result = array( diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php index b624351..7246970 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php @@ -20,12 +20,7 @@ class VocabularyFormController extends EntityFormController { */ public function form(array $form, array &$form_state) { $vocabulary = $this->entity; - if ($vocabulary->isNew()) { - $form['#title'] = $this->t('Add vocabulary'); - } - else { - $form['#title'] = $this->t('Edit vocabulary'); - } + $form['#title'] = $this->t('Edit vocabulary'); $form['name'] = array( '#type' => 'textfield', diff --git a/core/modules/taxonomy/templates/taxonomy-term.html.twig b/core/modules/taxonomy/templates/taxonomy-term.html.twig index 2ecc713..a3986fa 100644 --- a/core/modules/taxonomy/templates/taxonomy-term.html.twig +++ b/core/modules/taxonomy/templates/taxonomy-term.html.twig @@ -8,10 +8,10 @@ * - name: Name of the current term. * - content: Items for the content of the term (fields and description). * Use 'content' to print them all, or print a subset such as - * 'content.description'. Use the following code to exclude the - * printing of a given child element: + * 'content.description'. Use the following code to temporarily suppress the + * printing of a given element: * @code - * {{ content|without('description') }} + * {% hide(content.description) %} * @endcode * - attributes: HTML attributes for the wrapper. The 'class' attribute * contains the following classes by default: diff --git a/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_groupwise_term.yml b/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_groupwise_term.yml index 5fd37bc..2dc1c2b 100644 --- a/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_groupwise_term.yml +++ b/core/modules/taxonomy/tests/modules/taxonomy_test_views/test_views/views.view.test_groupwise_term.yml @@ -65,7 +65,7 @@ display: display_plugin: default display_title: Master id: default - position: 0 + position: { } label: test_groupwise langcode: und module: views diff --git a/core/modules/telephone/lib/Drupal/telephone/Plugin/Field/FieldType/TelephoneItem.php b/core/modules/telephone/lib/Drupal/telephone/Plugin/Field/FieldType/TelephoneItem.php index 6be9dff..e710ded 100644 --- a/core/modules/telephone/lib/Drupal/telephone/Plugin/Field/FieldType/TelephoneItem.php +++ b/core/modules/telephone/lib/Drupal/telephone/Plugin/Field/FieldType/TelephoneItem.php @@ -7,7 +7,7 @@ namespace Drupal\telephone\Plugin\Field\FieldType; -use Drupal\Core\Field\FieldItemBase; +use Drupal\Core\Field\ConfigFieldItemBase; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\TypedData\DataDefinition; @@ -19,10 +19,10 @@ * label = @Translation("Telephone number"), * description = @Translation("This field stores a telephone number in the database."), * default_widget = "telephone_default", - * default_formatter = "string" + * default_formatter = "telephone_link" * ) */ -class TelephoneItem extends FieldItemBase { +class TelephoneItem extends ConfigFieldItemBase { /** * {@inheritdoc} diff --git a/core/modules/telephone/telephone.module b/core/modules/telephone/telephone.module index eee9213..23099a9 100644 --- a/core/modules/telephone/telephone.module +++ b/core/modules/telephone/telephone.module @@ -26,8 +26,20 @@ function telephone_help($path, $arg) { } /** + * Implements hook_field_info_alter(). + */ +function telephone_field_info_alter(&$info) { + if (\Drupal::moduleHandler()->moduleExists('text')) { + $info['telephone']['default_formatter'] = 'text_plain'; + } +} + + +/** * Implements hook_field_formatter_info_alter(). */ function telephone_field_formatter_info_alter(&$info) { - $info['string']['field_types'][] = 'telephone'; + if (isset($info['text_plain'])) { + $info['text_plain']['field_types'][] = 'telephone'; + } } diff --git a/core/modules/text/config/schema/text.schema.yml b/core/modules/text/config/schema/text.schema.yml index dc54670..d377366 100644 --- a/core/modules/text/config/schema/text.schema.yml +++ b/core/modules/text/config/schema/text.schema.yml @@ -110,6 +110,16 @@ entity_view_display.field.text_default: sequence: - type: string +entity_view_display.field.text_plain: + type: entity_field_view_display_base + label: 'Plain text display format settings' + mapping: + settings: + type: sequence + label: 'Settings' + sequence: + - type: string + entity_view_display.field.text_summary_or_trimmed: type: entity_field_view_display_base label: 'Summary or trimmed text display format settings' diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldFormatter/TextPlainFormatter.php similarity index 59% rename from core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php rename to core/modules/text/lib/Drupal/text/Plugin/Field/FieldFormatter/TextPlainFormatter.php index d5e0c17..6c15bf5 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php +++ b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldFormatter/TextPlainFormatter.php @@ -2,31 +2,31 @@ /** * @file - * Contains \Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter. + * Contains \Drupal\text\Plugin\field\formatter\TextPlainFormatter. */ -namespace Drupal\Core\Field\Plugin\Field\FieldFormatter; +namespace Drupal\text\Plugin\Field\FieldFormatter; -use Drupal\Component\Utility\String; use Drupal\Core\Field\FormatterBase; use Drupal\Core\Field\FieldItemListInterface; /** - * Plugin implementation of the 'string' formatter. + * Plugin implementation of the 'text_plain' formatter. * * @FieldFormatter( - * id = "string", + * id = "text_plain", * label = @Translation("Plain text"), * field_types = { - * "string", - * "email" + * "text", + * "text_long", + * "text_with_summary" * }, * edit = { * "editor" = "plain_text" * } * ) */ -class StringFormatter extends FormatterBase { +class TextPlainFormatter extends FormatterBase { /** * {@inheritdoc} @@ -37,7 +37,7 @@ public function viewElements(FieldItemListInterface $items) { foreach ($items as $delta => $item) { // The text value has no text format assigned to it, so the user input // should equal the output, including newlines. - $elements[$delta] = array('#markup' => nl2br(String::checkPlain($item->value))); + $elements[$delta] = array('#markup' => nl2br(check_plain($item->value))); } return $elements; diff --git a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItemBase.php b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItemBase.php index 0c85997..9cac637 100644 --- a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItemBase.php +++ b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItemBase.php @@ -7,7 +7,7 @@ namespace Drupal\text\Plugin\Field\FieldType; -use Drupal\Core\Field\FieldItemBase; +use Drupal\Core\Field\ConfigFieldItemBase; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\PrepareCacheInterface; use Drupal\Core\TypedData\DataDefinition; @@ -15,7 +15,7 @@ /** * Base class for 'text' configurable field types. */ -abstract class TextItemBase extends FieldItemBase implements PrepareCacheInterface { +abstract class TextItemBase extends ConfigFieldItemBase implements PrepareCacheInterface { /** * {@inheritdoc} diff --git a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldWidget/TextareaWithSummaryWidget.php b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldWidget/TextareaWithSummaryWidget.php index 4775b86..2490ed2 100644 --- a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldWidget/TextareaWithSummaryWidget.php +++ b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldWidget/TextareaWithSummaryWidget.php @@ -69,7 +69,7 @@ function formElement(FieldItemListInterface $items, $delta, array $element, arra '#rows' => $this->getSetting('summary_rows'), '#description' => t('Leave blank to use trimmed value of full text as the summary.'), '#attached' => array( - 'library' => array('text/drupal.text'), + 'library' => array(array('text', 'drupal.text')), ), '#attributes' => array('class' => array('text-summary')), '#prefix' => '
', diff --git a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldWidget/TextfieldWidget.php b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldWidget/TextfieldWidget.php index 35f6957..b35e633 100644 --- a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldWidget/TextfieldWidget.php +++ b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldWidget/TextfieldWidget.php @@ -8,7 +8,7 @@ namespace Drupal\text\Plugin\Field\FieldWidget; use Drupal\Core\Field\FieldItemListInterface; -use Drupal\Core\Field\Plugin\Field\FieldWidget\StringWidget; +use Drupal\Core\Field\WidgetBase; use Symfony\Component\Validator\ConstraintViolationInterface; /** @@ -18,8 +18,7 @@ * id = "text_textfield", * label = @Translation("Text field"), * field_types = { - * "text", - * "string" + * "text" * }, * settings = { * "size" = "60", @@ -27,22 +26,67 @@ * } * ) */ -class TextfieldWidget extends StringWidget { +class TextfieldWidget extends WidgetBase { + + /** + * {@inheritdoc} + */ + public function settingsForm(array $form, array &$form_state) { + $element['size'] = array( + '#type' => 'number', + '#title' => t('Size of textfield'), + '#default_value' => $this->getSetting('size'), + '#required' => TRUE, + '#min' => 1, + ); + $element['placeholder'] = array( + '#type' => 'textfield', + '#title' => t('Placeholder'), + '#default_value' => $this->getSetting('placeholder'), + '#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'), + ); + return $element; + } + + /** + * {@inheritdoc} + */ + public function settingsSummary() { + $summary = array(); + + $summary[] = t('Textfield size: !size', array('!size' => $this->getSetting('size'))); + $placeholder = $this->getSetting('placeholder'); + if (!empty($placeholder)) { + $summary[] = t('Placeholder: @placeholder', array('@placeholder' => $placeholder)); + } + + return $summary; + } /** * {@inheritdoc} */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { - $main_widget = parent::formElement($items, $delta, $element, $form, $form_state); + $main_widget = $element + array( + '#type' => 'textfield', + '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL, + '#size' => $this->getSetting('size'), + '#placeholder' => $this->getSetting('placeholder'), + '#maxlength' => $this->getFieldSetting('max_length'), + '#attributes' => array('class' => array('text-full')), + ); if ($this->getFieldSetting('text_processing')) { - $element = $main_widget['value']; + $element = $main_widget; $element['#type'] = 'text_format'; $element['#format'] = isset($items[$delta]->format) ? $items[$delta]->format : NULL; - $element['#base_type'] = $main_widget['value']['#type']; - return $element; + $element['#base_type'] = $main_widget['#type']; + } + else { + $element['value'] = $main_widget; } - return $main_widget; + + return $element; } /** diff --git a/core/modules/text/lib/Drupal/text/TextProcessed.php b/core/modules/text/lib/Drupal/text/TextProcessed.php index 5d99de3..d07a196 100644 --- a/core/modules/text/lib/Drupal/text/TextProcessed.php +++ b/core/modules/text/lib/Drupal/text/TextProcessed.php @@ -2,12 +2,11 @@ /** * @file - * Contains \Drupal\text\TextProcessed. + * Definition of Drupal\text\TextProcessed. */ namespace Drupal\text; -use Drupal\Component\Utility\String; use Drupal\Core\TypedData\DataDefinitionInterface; use Drupal\Core\TypedData\TypedDataInterface; use Drupal\Core\TypedData\TypedData; @@ -58,8 +57,8 @@ public function getValue($langcode = NULL) { } else { // Escape all HTML and retain newlines. - // @see \Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter - $this->processed = nl2br(String::checkPlain($text)); + // @see \Drupal\text\Plugin\field\formatter\TextPlainFormatter + $this->processed = nl2br(check_plain($text)); } return $this->processed; } diff --git a/core/modules/text/text.module b/core/modules/text/text.module index 339d9da..b1672de 100644 --- a/core/modules/text/text.module +++ b/core/modules/text/text.module @@ -170,12 +170,3 @@ function text_filter_format_update($format) { function text_filter_format_disable($format) { field_cache_clear(); } - -/** - * Implements hook_field_formatter_info_alter(). - */ -function text_field_formatter_info_alter(&$info) { - $info['string']['field_types'][] = 'text'; - $info['string']['field_types'][] = 'text_with_summary'; - $info['string']['field_types'][] = 'text_long'; -} diff --git a/core/modules/toolbar/js/escapeAdmin.js b/core/modules/toolbar/js/escapeAdmin.js index 554d6a7..5467420 100644 --- a/core/modules/toolbar/js/escapeAdmin.js +++ b/core/modules/toolbar/js/escapeAdmin.js @@ -16,7 +16,7 @@ // there is not need to save the current path because the page is loaded within // an existing "workflow". if (!pathInfo.currentPathIsAdmin && !/destination=/.test(windowLocation.search)) { - sessionStorage.setItem('escapeAdminPath', windowLocation); + sessionStorage.setItem('escapeAdminPath', windowLocation.pathname.substring(pathInfo.basePath.length) + windowLocation.search); } /** @@ -30,7 +30,7 @@ var $toolbarEscape = $('[data-toolbar-escape-admin]').once('escapeAdmin'); if ($toolbarEscape.length) { if (pathInfo.currentPathIsAdmin && escapeAdminPath !== null) { - $toolbarEscape.attr('href', escapeAdminPath); + $toolbarEscape.attr('href', Drupal.url(escapeAdminPath)); $toolbarEscape.closest('.toolbar-tab').removeClass('hidden'); } } diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module index dc06282..7217986 100644 --- a/core/modules/toolbar/toolbar.module +++ b/core/modules/toolbar/toolbar.module @@ -68,7 +68,7 @@ function toolbar_element_info() { '#theme' => 'toolbar', '#attached' => array( 'library' => array( - 'toolbar/toolbar', + array('toolbar', 'toolbar'), ), ), // Metadata for the toolbar wrapping element. @@ -346,7 +346,7 @@ function toolbar_toolbar() { ), '#attached' => array( 'library' => array( - 'toolbar/toolbar.escapeAdmin', + array('toolbar', 'toolbar.escapeAdmin'), ), ), '#weight' => -20, diff --git a/core/modules/tour/lib/Drupal/tour/TourViewBuilder.php b/core/modules/tour/lib/Drupal/tour/TourViewBuilder.php index 4f3006e..9d09cfd 100644 --- a/core/modules/tour/lib/Drupal/tour/TourViewBuilder.php +++ b/core/modules/tour/lib/Drupal/tour/TourViewBuilder.php @@ -68,7 +68,7 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la } // If at least one tour was built, attach the tour library. if ($build) { - $build['#attached']['library'][] = 'tour/tour'; + $build['#attached']['library'][] = array('tour', 'tour'); } return $build; } diff --git a/core/modules/tour/tour.module b/core/modules/tour/tour.module index 610c025..d23c6e2 100644 --- a/core/modules/tour/tour.module +++ b/core/modules/tour/tour.module @@ -65,7 +65,7 @@ function tour_toolbar() { ), '#attached' => array( 'library' => array( - 'tour/tour', + array('tour', 'tour'), ), ), ); diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php index 207becc..57828bf 100644 --- a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php +++ b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php @@ -7,7 +7,6 @@ namespace Drupal\tracker\Tests; -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\simpletest\WebTestBase; /** @@ -33,7 +32,7 @@ public static function getInfo() { public function setUp() { parent::setUp(); node_access_rebuild(); - $this->container->get('comment.manager')->addDefaultField('node', 'page', 'comment', CommentItemInterface::OPEN); + $this->container->get('comment.manager')->addDefaultField('node', 'page', 'comment', COMMENT_OPEN); \Drupal::state()->set('node_access_test.private', TRUE); } diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerUserUidTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerUserUidTest.php index c50baee..b5c83bf 100644 --- a/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerUserUidTest.php +++ b/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerUserUidTest.php @@ -7,8 +7,6 @@ namespace Drupal\tracker\Tests\Views; -use Drupal\views\Views; - /** * Tests the tracker user uid handlers. */ @@ -45,7 +43,7 @@ public function testUserUid() { ) ); - $view = Views::getView('test_tracker_user_uid'); + $view = views_get_view('test_tracker_user_uid'); $this->executeView($view); // We should have no results as the filter is set for uid 0. diff --git a/core/modules/tracker/tracker.pages.inc b/core/modules/tracker/tracker.pages.inc index 8922672..e94c163 100644 --- a/core/modules/tracker/tracker.pages.inc +++ b/core/modules/tracker/tracker.pages.inc @@ -139,7 +139,7 @@ function tracker_page($account = NULL) { $page['tracker'] = array( '#rows' => $rows, '#header' => array(t('Type'), t('Title'), t('Author'), t('Replies'), t('Last updated')), - '#type' => 'table', + '#theme' => 'table', '#empty' => t('No content available.'), ); $page['pager'] = array( diff --git a/core/modules/update/tests/modules/update_test/update_test.module b/core/modules/update/tests/modules/update_test/update_test.module index 536d330..ed5e008 100644 --- a/core/modules/update/tests/modules/update_test/update_test.module +++ b/core/modules/update/tests/modules/update_test/update_test.module @@ -1,6 +1,5 @@ name) and the subarrays contain settings * just for that module or theme. */ -function update_test_system_info_alter(&$info, Extension $file) { +function update_test_system_info_alter(&$info, $file) { $setting = \Drupal::config('update_test.settings')->get('system_info'); - foreach (array('#all', $file->getName()) as $id) { + foreach (array('#all', $file->name) as $id) { if (!empty($setting[$id])) { foreach ($setting[$id] as $key => $value) { $info[$key] = $value; diff --git a/core/modules/update/update.manager.inc b/core/modules/update/update.manager.inc index f5c1d8a..b0d0483 100644 --- a/core/modules/update/update.manager.inc +++ b/core/modules/update/update.manager.inc @@ -82,7 +82,7 @@ function update_manager_update_form($form, $form_state = array(), $context) { return $form; } - $form['#attached']['library'][] = 'update/drupal.update.admin'; + $form['#attached']['library'][] = array('update', 'drupal.update.admin'); // This will be a nested array. The first key is the kind of project, which // can be either 'enabled', 'disabled', 'manual' (projects which require @@ -267,7 +267,7 @@ function update_manager_update_form($form, $form_state = array(), $context) { $prefix = '

' . t('Manual updates required') . '

'; $prefix .= '

' . t('Updates of Drupal core are not supported at this time.') . '

'; $form['manual_updates'] = array( - '#type' => 'table', + '#theme' => 'table', '#header' => $headers, '#rows' => $projects['manual'], '#prefix' => $prefix, diff --git a/core/modules/update/update.report.inc b/core/modules/update/update.report.inc index bf3a6d2..51da7dd 100644 --- a/core/modules/update/update.report.inc +++ b/core/modules/update/update.report.inc @@ -283,7 +283,7 @@ function theme_update_report($variables) { ksort($rows[$type_name]); $output .= "\n

" . $type_label . "

\n"; $table = array( - '#type' => 'table', + '#theme' => 'table', '#header' => $header, '#rows' => $rows[$type_name], '#attributes' => array( @@ -297,7 +297,7 @@ function theme_update_report($variables) { $assets = array( '#attached' => array( 'library' => array( - 'update/drupal.update.admin', + array('update', 'drupal.update.admin'), ), ) ); diff --git a/core/modules/user/config/views.view.user_admin_people.yml b/core/modules/user/config/views.view.user_admin_people.yml index 849697a..86f49be 100644 --- a/core/modules/user/config/views.view.user_admin_people.yml +++ b/core/modules/user/config/views.view.user_admin_people.yml @@ -561,7 +561,6 @@ display: empty_zero: false hide_alter_empty: true text: Translate - optional: true plugin_id: content_translation_link provider: content_translation dropbutton: diff --git a/core/modules/user/lib/Drupal/user/AccountFormController.php b/core/modules/user/lib/Drupal/user/AccountFormController.php index ed4cc07..915e71f 100644 --- a/core/modules/user/lib/Drupal/user/AccountFormController.php +++ b/core/modules/user/lib/Drupal/user/AccountFormController.php @@ -349,7 +349,7 @@ public function validate(array $form, array &$form_state) { if ($mail_taken) { // Format error message dependent on whether the user is logged in or not. - if (\Drupal::currentUser()->isAuthenticated()) { + if ($GLOBALS['user']->isAuthenticated()) { $this->setFormError('mail', $form_state, $this->t('The e-mail address %email is already taken.', array('%email' => $mail))); } else { diff --git a/core/modules/user/lib/Drupal/user/Entity/Role.php b/core/modules/user/lib/Drupal/user/Entity/Role.php index 2a025d9..49152e3 100644 --- a/core/modules/user/lib/Drupal/user/Entity/Role.php +++ b/core/modules/user/lib/Drupal/user/Entity/Role.php @@ -51,6 +51,13 @@ class Role extends ConfigEntityBase implements RoleInterface { public $id; /** + * The UUID of this role. + * + * @var string + */ + public $uuid; + + /** * The human-readable label of this role. * * @var string diff --git a/core/modules/user/lib/Drupal/user/Entity/User.php b/core/modules/user/lib/Drupal/user/Entity/User.php index d5ecd06..b38ea07 100644 --- a/core/modules/user/lib/Drupal/user/Entity/User.php +++ b/core/modules/user/lib/Drupal/user/Entity/User.php @@ -12,7 +12,6 @@ use Drupal\Core\Entity\EntityMalformedException; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\FieldDefinition; -use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\user\UserInterface; /** @@ -123,7 +122,7 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $ // user and recreate the current one. if ($this->pass->value != $this->original->pass->value) { drupal_session_destroy_uid($this->id()); - if ($this->id() == \Drupal::currentUser()->id()) { + if ($this->id() == $GLOBALS['user']->id()) { drupal_session_regenerate(); } } @@ -515,7 +514,6 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { // https://drupal.org/node/2044859. $fields['roles'] = FieldDefinition::create('string') ->setLabel(t('Roles')) - ->setCardinality(FieldDefinitionInterface::CARDINALITY_UNLIMITED) ->setDescription(t('The roles the user has.')); return $fields; diff --git a/core/modules/user/lib/Drupal/user/Form/UserLoginForm.php b/core/modules/user/lib/Drupal/user/Form/UserLoginForm.php index dcc6845..46744a4 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserLoginForm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserLoginForm.php @@ -9,7 +9,6 @@ use Drupal\Core\Flood\FloodInterface; use Drupal\Core\Form\FormBase; -use Drupal\user\UserAuthInterface; use Drupal\user\UserStorageControllerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -33,26 +32,16 @@ class UserLoginForm extends FormBase { protected $userStorage; /** - * The user authentication object. - * - * @var \Drupal\user\UserAuthInterface - */ - protected $userAuth; - - /** * Constructs a new UserLoginForm. * * @param \Drupal\Core\Flood\FloodInterface $flood * The flood service. * @param \Drupal\user\UserStorageControllerInterface $user_storage * The user storage controller. - * @param \Drupal\user\UserAuthInterface $user_auth - * The user authentication object. */ - public function __construct(FloodInterface $flood, UserStorageControllerInterface $user_storage, UserAuthInterface $user_auth) { + public function __construct(FloodInterface $flood, UserStorageControllerInterface $user_storage) { $this->flood = $flood; $this->userStorage = $user_storage; - $this->userAuth = $user_auth; } /** @@ -61,8 +50,7 @@ public function __construct(FloodInterface $flood, UserStorageControllerInterfac public static function create(ContainerInterface $container) { return new static( $container->get('flood'), - $container->get('entity.manager')->getStorageController('user'), - $container->get('user.auth') + $container->get('entity.manager')->getStorageController('user') ); } @@ -177,7 +165,7 @@ public function validateAuthentication(array &$form, array &$form_state) { } // We are not limited by flood control, so try to authenticate. // Set $form_state['uid'] as a flag for self::validateFinal(). - $form_state['uid'] = $this->userAuth->authenticate($form_state['values']['name'], $password); + $form_state['uid'] = user_authenticate($form_state['values']['name'], $password); } } diff --git a/core/modules/user/lib/Drupal/user/Form/UserPermissionsForm.php b/core/modules/user/lib/Drupal/user/Form/UserPermissionsForm.php index a1586a6..82d3829 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserPermissionsForm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserPermissionsForm.php @@ -174,7 +174,7 @@ public function buildForm(array $form, array &$form_state) { $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save permissions')); - $form['#attached']['library'][] = 'user/drupal.user.permissions'; + $form['#attached']['library'][] = array('user', 'drupal.user.permissions'); return $form; } diff --git a/core/modules/user/lib/Drupal/user/Plugin/Action/CancelUser.php b/core/modules/user/lib/Drupal/user/Plugin/Action/CancelUser.php index 75fa5f5..b404ba0 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/Action/CancelUser.php +++ b/core/modules/user/lib/Drupal/user/Plugin/Action/CancelUser.php @@ -60,7 +60,7 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function executeMultiple(array $entities) { - $this->tempStoreFactory->get('user_user_operations_cancel')->set(\Drupal::currentUser()->id(), $entities); + $this->tempStoreFactory->get('user_user_operations_cancel')->set($GLOBALS['user']->id(), $entities); } /** diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/CurrentUser.php b/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/CurrentUser.php index f1d987b..e763bae 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/CurrentUser.php +++ b/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/CurrentUser.php @@ -10,7 +10,7 @@ use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase; /** - * Default argument plugin to extract the current user + * Default argument plugin to extract the global $user * * This plugin actually has no options so it odes not need to do a great deal. * @@ -22,7 +22,8 @@ class CurrentUser extends ArgumentDefaultPluginBase { public function getArgument() { - return \Drupal::currentUser()->id(); + global $user; + return $user->id(); } } diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/argument_validator/User.php b/core/modules/user/lib/Drupal/user/Plugin/views/argument_validator/User.php index d7c3701..d385236 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/views/argument_validator/User.php +++ b/core/modules/user/lib/Drupal/user/Plugin/views/argument_validator/User.php @@ -109,21 +109,21 @@ public function validateArgument($argument) { // However, is_integer() will always fail, since $argument is a string. if (is_numeric($argument) && $argument == (int)$argument) { if ($type == 'uid' || $type == 'either') { - if ($argument == \Drupal::currentUser()->id()) { + if ($argument == $GLOBALS['user']->id()) { // If you assign an object to a variable in PHP, the variable // automatically acts as a reference, not a copy, so we use // clone to ensure that we don't actually mess with the - // real current user object. - $account = clone \Drupal::currentUser(); + // real global $user object. + $account = clone $GLOBALS['user']; } $condition = 'uid'; } } else { if ($type == 'name' || $type == 'either') { - $name = \Drupal::currentUser()->getUserName() ?: \Drupal::config('user.settings')->get('anonymous'); + $name = $GLOBALS['user']->getUserName() ?: \Drupal::config('user.settings')->get('anonymous'); if ($argument == $name) { - $account = clone \Drupal::currentUser(); + $account = clone $GLOBALS['user']; } $condition = 'name'; } diff --git a/core/modules/user/lib/Drupal/user/RegisterFormController.php b/core/modules/user/lib/Drupal/user/RegisterFormController.php index 89c91a0..c9f1f1d 100644 --- a/core/modules/user/lib/Drupal/user/RegisterFormController.php +++ b/core/modules/user/lib/Drupal/user/RegisterFormController.php @@ -41,10 +41,10 @@ public function form(array $form, array &$form_state) { // If we aren't admin but already logged on, go to the user page instead. if (!$admin && $user->isAuthenticated()) { - return new RedirectResponse(url('user/' . \Drupal::currentUser()->id(), array('absolute' => TRUE))); + return new RedirectResponse(url('user/' . $user->id(), array('absolute' => TRUE))); } - $form['#attached']['library'][] = 'core/jquery.cookie'; + $form['#attached']['library'][] = array('core', 'jquery.cookie'); $form['#attributes']['class'][] = 'user-info-from-cookie'; // Start with the default user account fields. diff --git a/core/modules/user/lib/Drupal/user/TempStore.php b/core/modules/user/lib/Drupal/user/TempStore.php index 458bf5c..dd6451c 100644 --- a/core/modules/user/lib/Drupal/user/TempStore.php +++ b/core/modules/user/lib/Drupal/user/TempStore.php @@ -7,7 +7,6 @@ namespace Drupal\user; -use Drupal\Component\Utility\String; use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface; use Drupal\Core\Lock\LockBackendInterface; @@ -35,6 +34,9 @@ * editing certain data, or even to restrict other users from editing it at * the same time. It is the responsibility of the implementation to decide * when and whether one owner can use or update another owner's data. + * + * @todo We could add getIfOwner() or setIfOwner() methods to make this more + * explicit. */ class TempStore { @@ -83,7 +85,7 @@ class TempStore { * @param mixed $owner * The owner key to store along with the data (e.g. a user or session ID). */ - public function __construct(KeyValueStoreExpirableInterface $storage, LockBackendInterface $lockBackend, $owner) { + function __construct(KeyValueStoreExpirableInterface $storage, LockBackendInterface $lockBackend, $owner) { $this->storage = $storage; $this->lockBackend = $lockBackend; $this->owner = $owner; @@ -98,30 +100,13 @@ public function __construct(KeyValueStoreExpirableInterface $storage, LockBacken * @return mixed * The data associated with the key, or NULL if the key does not exist. */ - public function get($key) { + function get($key) { if ($object = $this->storage->get($key)) { return $object->data; } } /** - * Retrieves a value from this TempStore for a given key. - * - * Only returns the value if the value is owned by $this->owner. - * - * @param string $key - * The key of the data to retrieve. - * - * @return mixed - * The data associated with the key, or NULL if the key does not exist. - */ - public function getIfOwner($key) { - if (($object = $this->storage->get($key)) && ($object->owner == $this->owner)) { - return $object->data; - } - } - - /** * Stores a particular key/value pair only if the key doesn't already exist. * * @param string $key @@ -132,7 +117,7 @@ public function getIfOwner($key) { * @return bool * TRUE if the data was set, or FALSE if it already existed. */ - public function setIfNotExists($key, $value) { + function setIfNotExists($key, $value) { $value = (object) array( 'owner' => $this->owner, 'data' => $value, @@ -144,46 +129,18 @@ public function setIfNotExists($key, $value) { /** * Stores a particular key/value pair in this TempStore. * - * Only stores the given key/value pair if it does not exist yet or is owned - * by $this->owner. - * - * @param string $key - * The key of the data to store. - * @param mixed $value - * The data to store. - * - * @return bool - * TRUE if the data was set, or FALSE if it already exists and is not owned - * by $this->user. - */ - public function setIfOwner($key, $value) { - if ($this->setIfNotExists($key, $value)) { - return TRUE; - } - - if (($object = $this->storage->get($key)) && ($object->owner == $this->owner)) { - $this->set($key, $value); - return TRUE; - } - - return FALSE; - } - - /** - * Stores a particular key/value pair in this TempStore. - * * @param string $key * The key of the data to store. * @param mixed $value * The data to store. */ - public function set($key, $value) { + function set($key, $value) { if (!$this->lockBackend->acquire($key)) { $this->lockBackend->wait($key); if (!$this->lockBackend->acquire($key)) { - throw new TempStoreException(String::format("Couldn't acquire lock to update item %key in %collection temporary storage.", array( + throw new TempStoreException(format_string("Couldn't acquire lock to update item %key in %collection temporary storage.", array( '%key' => $key, - '%collection' => $this->storage->getCollectionName(), + '%collection' => $this->storage->collection, ))); } } @@ -207,7 +164,7 @@ public function set($key, $value) { * An object with the owner and updated time if the key has a value, or * NULL otherwise. */ - public function getMetadata($key) { + function getMetadata($key) { // Fetch the key/value pair and its metadata. $object = $this->storage->get($key); if ($object) { @@ -223,13 +180,13 @@ public function getMetadata($key) { * @param string $key * The key of the data to delete. */ - public function delete($key) { + function delete($key) { if (!$this->lockBackend->acquire($key)) { $this->lockBackend->wait($key); if (!$this->lockBackend->acquire($key)) { - throw new TempStoreException(String::format("Couldn't acquire lock to delete item %key from %collection temporary storage.", array( + throw new TempStoreException(format_string("Couldn't acquire lock to delete item %key from %collection temporary storage.", array( '%key' => $key, - '%collection' => $this->storage->getCollectionName(), + '%collection' => $this->storage->collection, ))); } } @@ -237,28 +194,4 @@ public function delete($key) { $this->lockBackend->release($key); } - /** - * Deletes data from the store for a given key and releases the lock on it. - * - * Only delete the given key if it is owned by $this->owner. - * - * @param string $key - * The key of the data to delete. - * - * @return bool - * TRUE if the object was deleted or does not exist, FALSE if it exists but - * is not owned by $this->owner. - */ - public function deleteIfOwner($key) { - if (!$object = $this->storage->get($key)) { - return TRUE; - } - elseif ($object->owner == $this->owner) { - $this->delete($key); - return TRUE; - } - - return FALSE; - } - } diff --git a/core/modules/user/lib/Drupal/user/TempStoreFactory.php b/core/modules/user/lib/Drupal/user/TempStoreFactory.php index 28d4147..45f421e 100644 --- a/core/modules/user/lib/Drupal/user/TempStoreFactory.php +++ b/core/modules/user/lib/Drupal/user/TempStoreFactory.php @@ -61,7 +61,7 @@ function get($collection, $owner = NULL) { // Use the currently authenticated user ID or the active user ID unless // the owner is overridden. if (!isset($owner)) { - $owner = \Drupal::currentUser()->id() ?: session_id(); + $owner = $GLOBALS['user']->id() ?: session_id(); } // Store the data for this collection in the database. diff --git a/core/modules/user/lib/Drupal/user/Tests/TempStoreDatabaseTest.php b/core/modules/user/lib/Drupal/user/Tests/TempStoreDatabaseTest.php index 0437837..28edf55 100644 --- a/core/modules/user/lib/Drupal/user/Tests/TempStoreDatabaseTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/TempStoreDatabaseTest.php @@ -123,12 +123,6 @@ public function testUserTempStore() { $this->assertIdenticalObject($this->objects[2], $stores[0]->get($key)); // The object is the same when another user loads it. $this->assertIdenticalObject($this->objects[2], $stores[1]->get($key)); - - // This user should be allowed to get, update, delete. - $this->assertTrue($stores[0]->getIfOwner($key) instanceof \stdClass); - $this->assertTrue($stores[0]->setIfOwner($key, $this->objects[1])); - $this->assertTrue($stores[0]->deleteIfOwner($key)); - // Another user can update the object and become the owner. $stores[1]->set($key, $this->objects[3]); $this->assertIdenticalObject($this->objects[3], $stores[0]->get($key)); @@ -140,11 +134,6 @@ public function testUserTempStore() { $metadata = $stores[0]->getMetadata($key); $this->assertEqual($users[1], $metadata->owner); - // The first user should no longer be allowed to get, update, delete. - $this->assertNull($stores[0]->getIfOwner($key)); - $this->assertFalse($stores[0]->setIfOwner($key, $this->objects[1])); - $this->assertFalse($stores[0]->deleteIfOwner($key)); - // Now manually expire the item (this is not exposed by the API) and then // assert it is no longer accessible. db_update('key_value_expire') diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php index 991ac35..d16b4e2 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php @@ -57,7 +57,7 @@ function testUserTokenReplacement() { $this->drupalLogin($user2); $account = user_load($user1->id()); - $global_account = user_load(\Drupal::currentUser()->id()); + $global_account = user_load($GLOBALS['user']->id()); // Generate and test sanitized tokens. $tests = array(); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserValidationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserValidationTest.php index 7beec6a..754a08f 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserValidationTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserValidationTest.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\user\Tests\UserValidationTest. + * Definition of Drupal\user\Tests\UserValidationTest. */ namespace Drupal\user\Tests; @@ -142,14 +142,7 @@ function testValidation() { $this->assertEqual($violations[0]->getPropertyPath(), 'init.0.value'); $this->assertEqual($violations[0]->getMessage(), t('This value is not a valid email address.')); - // Test cardinality of user roles. - $user = entity_create('user', array( - 'name' => 'role_test', - 'roles' => array('role1', 'role2'), - )); - $violations = $user->validate(); - $this->assertEqual(count($violations), 0); - // @todo Test user role validation once https://drupal.org/node/2044859 got + // @todo Test user role validation once https://drupal.org/node/2015701 got // committed. } @@ -167,8 +160,6 @@ protected function assertLengthViolation(EntityInterface $entity, $field_name, $ $violations = $entity->validate(); $this->assertEqual(count($violations), 1, "Violation found when $field_name is too long."); $this->assertEqual($violations[0]->getPropertyPath(), "$field_name.0.value"); - $field_label = $entity->get($field_name)->getFieldDefinition()->getLabel(); - $this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', array('%name' => $field_label, '@max' => $length))); + $this->assertEqual($violations[0]->getMessage(), t('This value is too long. It should have %limit characters or less.', array('%limit' => $length))); } - } diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/AccessPermissionTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/AccessPermissionTest.php index dcccacc..aaf5a93 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/AccessPermissionTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/AccessPermissionTest.php @@ -8,7 +8,6 @@ namespace Drupal\user\Tests\Views; use Drupal\user\Plugin\views\access\Permission; -use Drupal\views\Views; /** * Tests views perm access plugin. @@ -36,7 +35,7 @@ public static function getInfo() { * Tests perm access plugin. */ function testAccessPerm() { - $view = Views::getView('test_access_perm'); + $view = views_get_view('test_access_perm'); $view->setDisplay(); $access_plugin = $view->display_handler->getPlugin('access'); diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/ArgumentDefaultTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/ArgumentDefaultTest.php index 8323de1..654d1d7 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/ArgumentDefaultTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/ArgumentDefaultTest.php @@ -7,8 +7,6 @@ namespace Drupal\user\Tests\Views; -use Drupal\views\Views; - /** * Tests views user argument default plugin. */ @@ -40,7 +38,7 @@ public function test_plugin_argument_default_current_user() { drupal_save_session(FALSE); $user = $account; - $view = Views::getView('test_plugin_argument_default_current_user'); + $view = views_get_view('test_plugin_argument_default_current_user'); $view->initHandlers(); $this->assertEqual($view->argument['null']->getDefaultArgument(), $account->id(), 'Uid of the current user is used.'); diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/ArgumentValidateTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/ArgumentValidateTest.php index 332645c..418b826 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/ArgumentValidateTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/ArgumentValidateTest.php @@ -7,8 +7,6 @@ namespace Drupal\user\Tests\Views; -use Drupal\views\Views; - /** * Tests views user argument validator plugin. */ @@ -85,7 +83,7 @@ function testArgumentValidateUserEither() { } function view_argument_validate_user($argtype) { - $view = Views::getView('test_view_argument_validate_user'); + $view = views_get_view('test_view_argument_validate_user'); $view->setDisplay(); $view->displayHandlers->get('default')->options['arguments']['null']['validate_options']['type'] = $argtype; $view->preExecute(); diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/BulkFormTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/BulkFormTest.php index f3dfca4..af8e58d 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/BulkFormTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/BulkFormTest.php @@ -7,8 +7,6 @@ namespace Drupal\user\Tests\Views; -use Drupal\views\Views; - /** * Tests the views bulk form test. * @@ -83,7 +81,7 @@ public function testBulkForm() { $this->assertNoRaw($account->label(), 'The user is not found in the table.'); // Remove the user status filter from the view. - $view = Views::getView('test_user_bulk_form'); + $view = views_get_view('test_user_bulk_form'); $view->removeHandler('default', 'filter', 'status'); $view->storage->save(); diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerArgumentUserUidTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerArgumentUserUidTest.php index a52c5e3..2c44bd8 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerArgumentUserUidTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerArgumentUserUidTest.php @@ -7,8 +7,6 @@ namespace Drupal\user\Tests\Views; -use Drupal\views\Views; - /** * Tests views user uid argument handler. */ @@ -33,7 +31,7 @@ public static function getInfo() { * Tests the generated title of an user: uid argument. */ public function testArgumentTitle() { - $view = Views::getView('test_user_uid_argument'); + $view = views_get_view('test_user_uid_argument'); // Tests an invalid user uid. $this->executeView($view, array(rand(1000, 10000))); diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFieldPermissionTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFieldPermissionTest.php index 6f78d22..70e772a 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFieldPermissionTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFieldPermissionTest.php @@ -7,7 +7,6 @@ namespace Drupal\user\Tests\Views; -use Drupal\views\Views; use Drupal\views\Tests\ViewTestData; use Drupal\views\Tests\ViewUnitTestBase; @@ -39,7 +38,7 @@ public static function getInfo() { public function testFieldPermission() { $this->setupPermissionTestData(); - $view = Views::getView('test_field_permission'); + $view = views_get_view('test_field_permission'); $this->executeView($view); $view->initStyle(); $view->render(); diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFieldRoleTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFieldRoleTest.php index b9b9791..b85b61a 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFieldRoleTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFieldRoleTest.php @@ -7,8 +7,6 @@ namespace Drupal\user\Tests\Views; -use Drupal\views\Views; - /** * Tests the role field handler. * @@ -48,7 +46,7 @@ public function testRole() { $user->addRole($rolename_b); $user->save(); - $view = Views::getView('test_views_handler_field_role'); + $view = views_get_view('test_views_handler_field_role'); $this->executeView($view); $view->row_index = 0; // The role field is populated during preRender. diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFieldUserNameTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFieldUserNameTest.php index 4b1e9f9..1ec2c8b 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFieldUserNameTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFieldUserNameTest.php @@ -7,8 +7,6 @@ namespace Drupal\user\Tests\Views; -use Drupal\views\Views; - /** * Tests the field username handler. * @@ -34,7 +32,7 @@ public static function getInfo() { public function testUserName() { $this->drupalLogin($this->drupalCreateUser(array('access user profiles'))); - $view = Views::getView('test_views_handler_field_user_name'); + $view = views_get_view('test_views_handler_field_user_name'); $this->executeView($view); $view->row_index = 0; diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterPermissionTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterPermissionTest.php index 970ea70..ed67b16 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterPermissionTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterPermissionTest.php @@ -9,7 +9,6 @@ use Drupal\Component\Utility\String; use Drupal\user\Tests\Views\UserUnitTestBase; -use Drupal\views\Views; /** * Tests the permissions filter handler. @@ -45,7 +44,7 @@ public function testFilterPermission() { $this->setupPermissionTestData(); $column_map = array('uid' => 'uid'); - $view = Views::getView('test_filter_permission'); + $view = views_get_view('test_filter_permission'); // Filter by a non existing permission. $view->initHandlers(); diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterUserNameTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterUserNameTest.php index a498d37..f4eefdd 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterUserNameTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterUserNameTest.php @@ -7,7 +7,6 @@ namespace Drupal\user\Tests\Views; -use Drupal\views\Views; use Drupal\views\Tests\ViewTestBase; use Drupal\views\Tests\ViewTestData; @@ -83,7 +82,7 @@ protected function setUp() { * Tests just using the filter. */ public function testUserNameApi() { - $view = Views::getView('test_user_name'); + $view = views_get_view('test_user_name'); $view->initHandlers(); $view->filter['uid']->value = array($this->accounts[0]->id()); diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/RelationshipRepresentativeNode.php b/core/modules/user/lib/Drupal/user/Tests/Views/RelationshipRepresentativeNode.php index 886c1ff..7cd9b04 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/RelationshipRepresentativeNode.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/RelationshipRepresentativeNode.php @@ -7,8 +7,6 @@ namespace Drupal\user\Tests\Views; -use Drupal\views\Views; - /** * Tests the representative node relationship for users. */ @@ -33,7 +31,7 @@ public static function getInfo() { * Tests the relationship. */ public function testRelationship() { - $view = Views::getView('test_groupwise_user'); + $view = views_get_view('test_groupwise_user'); $this->executeView($view); $map = array('node_users_nid' => 'nid', 'uid' => 'uid'); $expected_result = array( diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/UserDataTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/UserDataTest.php index 7813dd7..6c27bf9 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/UserDataTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/UserDataTest.php @@ -7,8 +7,6 @@ namespace Drupal\user\Tests\Views; -use Drupal\views\Views; - /** * Tests the user data service field handler. * @@ -47,7 +45,7 @@ public function testDataField() { $random_value = $this->randomName(); $this->userData->set('views_test_config', $this->users[0]->id(), 'test_value_name', $random_value); - $view = Views::getView('test_user_data'); + $view = views_get_view('test_user_data'); $this->executeView($view); $output = $view->field['data']->render($view->result[0]); diff --git a/core/modules/user/lib/Drupal/user/UserAuth.php b/core/modules/user/lib/Drupal/user/UserAuth.php deleted file mode 100644 index 3ce2683..0000000 --- a/core/modules/user/lib/Drupal/user/UserAuth.php +++ /dev/null @@ -1,72 +0,0 @@ -storage = $entity_manager->getStorageController('user'); - $this->passwordChecker = $password_checker; - } - - /** - * {@inheritdoc} - */ - public function authenticate($username, $password) { - $uid = FALSE; - - if (!empty($username) && !empty($password)) { - $account_search = $this->storage->loadByProperties(array('name' => $username)); - - if ($account = reset($account_search)) { - if ($this->passwordChecker->check($password, $account)) { - // Successful authentication. - $uid = $account->id(); - - // Update user to new password scheme if needed. - if ($this->passwordChecker->userNeedsNewHash($account)) { - $account->setPassword($password); - $account->save(); - } - } - } - } - - return $uid; - } - -} diff --git a/core/modules/user/lib/Drupal/user/UserAuthInterface.php b/core/modules/user/lib/Drupal/user/UserAuthInterface.php deleted file mode 100644 index 1044ec1..0000000 --- a/core/modules/user/lib/Drupal/user/UserAuthInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - 'TempStore', - 'description' => 'Unit tests the Drupal\user\TempStore class.', - 'group' => 'User', - ); - } - - /** - * {@inheritdoc} - */ - protected function setUp() { - parent::setUp(); - - $this->keyValue = $this->getMock('Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface'); - $this->lock = $this->getMock('Drupal\Core\Lock\LockBackendInterface'); - - $this->tempStore = new TempStore($this->keyValue, $this->lock, $this->owner); - - $this->ownObject = (object) array( - 'data' => 'test_data', - 'owner' => $this->owner, - 'updated' => REQUEST_TIME, - ); - - // Clone the object but change the owner. - $this->otherObject = clone $this->ownObject; - $this->otherObject->owner = 2; - } - - /** - * @covers ::get() - */ - public function testGet() { - $this->keyValue->expects($this->at(0)) - ->method('get') - ->with('test_2') - ->will($this->returnValue(FALSE)); - $this->keyValue->expects($this->at(1)) - ->method('get') - ->with('test') - ->will($this->returnValue($this->ownObject)); - - $this->assertNull($this->tempStore->get('test_2')); - $this->assertSame($this->ownObject->data, $this->tempStore->get('test')); - } - - /** - * Tests the getIfOwner() method. - * - * @covers ::getIfOwner() - */ - public function testGetIfOwner() { - $this->keyValue->expects($this->at(0)) - ->method('get') - ->with('test_2') - ->will($this->returnValue(FALSE)); - $this->keyValue->expects($this->at(1)) - ->method('get') - ->with('test') - ->will($this->returnValue($this->ownObject)); - $this->keyValue->expects($this->at(2)) - ->method('get') - ->with('test') - ->will($this->returnValue($this->otherObject)); - - $this->assertNull($this->tempStore->getIfOwner('test_2')); - $this->assertSame($this->ownObject->data, $this->tempStore->getIfOwner('test')); - $this->assertNull($this->tempStore->getIfOwner('test')); - } - - /** - * Tests the set() method with no lock available. - * - * @covers ::set() - * @expectedException \Drupal\user\TempStoreException - */ - public function testSetWithNoLockAvailable() { - $this->lock->expects($this->at(0)) - ->method('acquire') - ->with('test') - ->will($this->returnValue(FALSE)); - $this->lock->expects($this->at(1)) - ->method('wait') - ->with('test'); - $this->lock->expects($this->at(2)) - ->method('acquire') - ->with('test') - ->will($this->returnValue(FALSE)); - - $this->keyValue->expects($this->once()) - ->method('getCollectionName'); - - $this->tempStore->set('test', 'value'); - } - - /** - * Tests a successful set() call. - * - * @covers ::set() - */ - public function testSet() { - $this->lock->expects($this->once()) - ->method('acquire') - ->with('test') - ->will($this->returnValue(TRUE)); - $this->lock->expects($this->never()) - ->method('wait'); - $this->lock->expects($this->once()) - ->method('release') - ->with('test'); - - $this->keyValue->expects($this->once()) - ->method('setWithExpire') - ->with('test', $this->ownObject, 604800); - - $this->tempStore->set('test', 'test_data'); - } - - /** - * Tests the setIfNotExists() methods. - * - * @covers ::setIfNotExists() - */ - public function testSetIfNotExists() { - $this->keyValue->expects($this->once()) - ->method('setWithExpireIfNotExists') - ->with('test', $this->ownObject, 604800) - ->will($this->returnValue(TRUE)); - - $this->assertTrue($this->tempStore->setIfNotExists('test', 'test_data')); - } - - /** - * Tests the setIfOwner() method when no key exists. - * - * @covers ::setIfOwner() - */ - public function testSetIfOwnerWhenNotExists() { - $this->keyValue->expects($this->once()) - ->method('setWithExpireIfNotExists') - ->will($this->returnValue(TRUE)); - - $this->assertTrue($this->tempStore->setIfOwner('test', 'test_data')); - } - - /** - * Tests the setIfOwner() method when a key already exists but no object. - * - * @covers ::setIfOwner() - */ - public function testSetIfOwnerNoObject() { - $this->keyValue->expects($this->once()) - ->method('setWithExpireIfNotExists') - ->will($this->returnValue(FALSE)); - - $this->keyValue->expects($this->once()) - ->method('get') - ->with('test') - ->will($this->returnValue(FALSE)); - - $this->assertFalse($this->tempStore->setIfOwner('test', 'test_data')); - } - - /** - * Tests the setIfOwner() method with matching and non matching owners. - * - * @covers ::setIfOwner() - */ - public function testSetIfOwner() { - $this->lock->expects($this->once()) - ->method('acquire') - ->with('test') - ->will($this->returnValue(TRUE)); - - $this->keyValue->expects($this->exactly(2)) - ->method('setWithExpireIfNotExists') - ->will($this->returnValue(FALSE)); - - $this->keyValue->expects($this->exactly(2)) - ->method('get') - ->with('test') - ->will($this->onConsecutiveCalls($this->ownObject, $this->otherObject)); - - $this->assertTrue($this->tempStore->setIfOwner('test', 'test_data')); - $this->assertFalse($this->tempStore->setIfOwner('test', 'test_data')); - } - - /** - * Tests the getMetadata() method. - * - * @covers ::getMetadata() - */ - public function testGetMetadata() { - $this->keyValue->expects($this->at(0)) - ->method('get') - ->with('test') - ->will($this->returnValue($this->ownObject)); - - $this->keyValue->expects($this->at(1)) - ->method('get') - ->with('test') - ->will($this->returnValue(FALSE)); - - $metadata = $this->tempStore->getMetadata('test'); - $this->assertObjectHasAttribute('owner', $metadata); - // Data should get removed. - $this->assertObjectNotHasAttribute('data', $metadata); - - $this->assertNull($this->tempStore->getMetadata('test')); - } - - /** - * Tests the delete() method. - * - * @covers ::delete() - */ - public function testDelete() { - $this->lock->expects($this->once()) - ->method('acquire') - ->with('test') - ->will($this->returnValue(TRUE)); - $this->lock->expects($this->never()) - ->method('wait'); - $this->lock->expects($this->once()) - ->method('release') - ->with('test'); - - $this->keyValue->expects($this->once()) - ->method('delete') - ->with('test'); - - $this->tempStore->delete('test'); - } - - /** - * Tests the delete() method with no lock available. - * - * @covers ::delete() - * @expectedException \Drupal\user\TempStoreException - */ - public function testDeleteWithNoLockAvailable() { - $this->lock->expects($this->at(0)) - ->method('acquire') - ->with('test') - ->will($this->returnValue(FALSE)); - $this->lock->expects($this->at(1)) - ->method('wait') - ->with('test'); - $this->lock->expects($this->at(2)) - ->method('acquire') - ->with('test') - ->will($this->returnValue(FALSE)); - - $this->keyValue->expects($this->once()) - ->method('getCollectionName'); - - $this->tempStore->delete('test'); - } - - /** - * Tests the deleteIfOwner() method. - * - * @covers ::deleteIfOwner() - */ - public function testDeleteIfOwner() { - $this->lock->expects($this->once()) - ->method('acquire') - ->with('test_2') - ->will($this->returnValue(TRUE)); - - $this->keyValue->expects($this->at(0)) - ->method('get') - ->with('test_1') - ->will($this->returnValue(FALSE)); - $this->keyValue->expects($this->at(1)) - ->method('get') - ->with('test_2') - ->will($this->returnValue($this->ownObject)); - $this->keyValue->expects($this->at(2)) - ->method('delete') - ->with('test_2'); - $this->keyValue->expects($this->at(3)) - ->method('get') - ->with('test_3') - ->will($this->returnValue($this->otherObject)); - - $this->assertTrue($this->tempStore->deleteIfOwner('test_1')); - $this->assertTrue($this->tempStore->deleteIfOwner('test_2')); - $this->assertFalse($this->tempStore->deleteIfOwner('test_3')); - } - -} - diff --git a/core/modules/user/tests/Drupal/user/Tests/UserAuthTest.php b/core/modules/user/tests/Drupal/user/Tests/UserAuthTest.php deleted file mode 100644 index c658e60..0000000 --- a/core/modules/user/tests/Drupal/user/Tests/UserAuthTest.php +++ /dev/null @@ -1,215 +0,0 @@ - 'User auth service', - 'description' => 'Tests the user auth service', - 'group' => 'User', - ); - } - - /** - * {@inheritdoc} - */ - public function setUp() { - $this->userStorage = $this->getMock('Drupal\Core\Entity\EntityStorageControllerInterface'); - - $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); - // Getting the user storage controller should only happen once per test. - $entity_manager->expects($this->once()) - ->method('getStorageController') - ->with('user') - ->will($this->returnValue($this->userStorage)); - - $this->passwordService = $this->getMock('Drupal\Core\Password\PasswordInterface'); - - $this->testUser = $this->getMockBuilder('Drupal\user\Entity\User') - ->disableOriginalConstructor() - ->setMethods(array('id', 'setPassword', 'save')) - ->getMock(); - - $this->userAuth = new UserAuth($entity_manager, $this->passwordService); - } - - /** - * Tests failing authentication with missing credential parameters. - * - * @covers ::authenticate() - * - * @dataProvider providerTestAuthenticateWithMissingCredentials - */ - public function testAuthenticateWithMissingCredentials($username, $password) { - $this->userStorage->expects($this->never()) - ->method('loadByProperties'); - - $this->assertFalse($this->userAuth->authenticate($username, $password)); - } - - /** - * Data provider for testAuthenticateWithMissingCredentials(). - * - * @return array - */ - public function providerTestAuthenticateWithMissingCredentials() { - return array( - array(NULL, NULL), - array(NULL, ''), - array('', NULL), - array('', ''), - ); - } - - /** - * Tests the authenticate method with no account returned. - * - * @covers ::authenticate() - */ - public function testAuthenticateWithNoAccountReturned() { - $this->userStorage->expects($this->once()) - ->method('loadByProperties') - ->with(array('name' => $this->username)) - ->will($this->returnValue(array())); - - $this->assertFalse($this->userAuth->authenticate($this->username, $this->password)); - } - - /** - * Tests the authenticate method with an incorrect password. - * - * @covers ::authenticate() - */ - public function testAuthenticateWithIncorrectPassword() { - $this->userStorage->expects($this->once()) - ->method('loadByProperties') - ->with(array('name' => $this->username)) - ->will($this->returnValue(array($this->testUser))); - - $this->passwordService->expects($this->once()) - ->method('check') - ->with($this->password, $this->testUser) - ->will($this->returnValue(FALSE)); - - $this->assertFalse($this->userAuth->authenticate($this->username, $this->password)); - } - - /** - * Tests the authenticate method with a correct password. - * - * @covers ::authenticate() - */ - public function testAuthenticateWithCorrectPassword() { - $this->testUser->expects($this->once()) - ->method('id') - ->will($this->returnValue(1)); - - $this->userStorage->expects($this->once()) - ->method('loadByProperties') - ->with(array('name' => $this->username)) - ->will($this->returnValue(array($this->testUser))); - - $this->passwordService->expects($this->once()) - ->method('check') - ->with($this->password, $this->testUser) - ->will($this->returnValue(TRUE)); - - $this->assertsame(1, $this->userAuth->authenticate($this->username, $this->password)); - } - - /** - * Tests the authenticate method with a correct password and new password hash. - * - * @covers ::authenticate() - */ - public function testAuthenticateWithCorrectPasswordAndNewPasswordHash() { - $this->testUser->expects($this->once()) - ->method('id') - ->will($this->returnValue(1)); - $this->testUser->expects($this->once()) - ->method('setPassword') - ->with($this->password); - $this->testUser->expects($this->once()) - ->method('save'); - - $this->userStorage->expects($this->once()) - ->method('loadByProperties') - ->with(array('name' => $this->username)) - ->will($this->returnValue(array($this->testUser))); - - $this->passwordService->expects($this->once()) - ->method('check') - ->with($this->password, $this->testUser) - ->will($this->returnValue(TRUE)); - $this->passwordService->expects($this->once()) - ->method('userNeedsNewHash') - ->with($this->testUser) - ->will($this->returnValue(TRUE)); - - $this->assertsame(1, $this->userAuth->authenticate($this->username, $this->password)); - } - -} diff --git a/core/modules/user/tests/modules/user_test_views/test_views/views.view.test_groupwise_user.yml b/core/modules/user/tests/modules/user_test_views/test_views/views.view.test_groupwise_user.yml index 4dc494a..b0a6665 100644 --- a/core/modules/user/tests/modules/user_test_views/test_views/views.view.test_groupwise_user.yml +++ b/core/modules/user/tests/modules/user_test_views/test_views/views.view.test_groupwise_user.yml @@ -77,7 +77,7 @@ display: display_plugin: default display_title: Master id: default - position: 0 + position: { } label: test_groupwise_user langcode: und module: views diff --git a/core/modules/user/user.module b/core/modules/user/user.module index ab9a163..a944b30 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -796,12 +796,26 @@ function user_admin_paths() { * A plain-text password, such as trimmed text from form values. * @return * The user's uid on success, or FALSE on failure to authenticate. - * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. - * Use \Drupal\user\UserAuth::authenticate() instead. */ function user_authenticate($name, $password) { - return \Drupal::service('user.auth')->authenticate($name, $password); + $uid = FALSE; + if (!empty($name) && !empty($password)) { + $account = user_load_by_name($name); + if ($account) { + $password_hasher = \Drupal::service('password'); + if ($password_hasher->check($password, $account)) { + // Successful authentication. + $uid = $account->id(); + + // Update user to new password scheme if needed. + if ($password_hasher->userNeedsNewHash($account)) { + $account->setPassword($password); + $account->save(); + } + } + } + } + return $uid; } /** @@ -949,6 +963,8 @@ function user_pass_rehash($password, $timestamp, $login) { * @see _user_cancel() */ function user_cancel($edit, $uid, $method) { + global $user; + $account = user_load($uid); if (!$account) { @@ -981,7 +997,7 @@ function user_cancel($edit, $uid, $method) { ); // After cancelling account, ensure that user is logged out. - if ($account->id() == \Drupal::currentUser()->id()) { + if ($account->id() == $user->id()) { // Batch API stores data in the session, so use the finished operation to // manipulate the current user's session id. $batch['finished'] = '_user_cancel_session_regenerate'; @@ -1558,6 +1574,8 @@ function user_form_process_password_confirm($element) { ); if (\Drupal::config('user.settings')->get('password_strength')) { + + global $user; $password_settings['showStrengthIndicator'] = TRUE; $password_settings += array( 'strengthTitle' => t('Password strength:'), @@ -1572,7 +1590,7 @@ function user_form_process_password_confirm($element) { 'fair' => t('Fair'), 'good' => t('Good'), 'strong' => t('Strong'), - 'username' => \Drupal::currentUser()->getUsername(), + 'username' => $user->getUsername(), ); } @@ -1580,7 +1598,7 @@ function user_form_process_password_confirm($element) { 'password' => $password_settings, ); - $element['#attached']['library'][] = 'user/drupal.user'; + $element['#attached']['library'][] = array('user', 'drupal.user'); // Ensure settings are only added once per page. static $already_added = FALSE; if (!$already_added) { @@ -1658,7 +1676,7 @@ function user_file_download_access($field, EntityInterface $entity, File $file) * Implements hook_toolbar(). */ function user_toolbar() { - $user = \Drupal::currentUser(); + global $user; // Add logout & user account links or login link. if ($user->isAuthenticated()) { @@ -1720,7 +1738,7 @@ function user_toolbar() { '#weight' => 100, '#attached' => array( 'library' => array( - 'user/drupal.user.icons', + array('user', 'drupal.user.icons'), ), ), ); @@ -1732,7 +1750,7 @@ function user_toolbar() { * Logs the current user out. */ function user_logout() { - $user = \Drupal::currentUser(); + global $user; watchdog('user', 'Session closed for %name.', array('%name' => $user->getUsername())); diff --git a/core/modules/user/user.services.yml b/core/modules/user/user.services.yml index 36d1e79..23d8706 100644 --- a/core/modules/user/user.services.yml +++ b/core/modules/user/user.services.yml @@ -33,6 +33,3 @@ services: user.permissions_hash: class: Drupal\user\PermissionsHash arguments: ['@private_key', '@cache.cache'] - user.auth: - class: Drupal\user\UserAuth - arguments: ['@entity.manager', '@password'] diff --git a/core/modules/user/user.tokens.inc b/core/modules/user/user.tokens.inc index e3c22f2..5412a38 100644 --- a/core/modules/user/user.tokens.inc +++ b/core/modules/user/user.tokens.inc @@ -125,7 +125,7 @@ function user_tokens($type, $tokens, array $data = array(), array $options = arr } if ($type == 'current-user') { - $account = user_load(\Drupal::currentUser()->id()); + $account = user_load($GLOBALS['user']->id()); $replacements += $token_service->generate('user', $tokens, array('user' => $account), $options); } diff --git a/core/modules/user/user.views_execution.inc b/core/modules/user/user.views_execution.inc index c9a3f1d..622cdbf 100644 --- a/core/modules/user/user.views_execution.inc +++ b/core/modules/user/user.views_execution.inc @@ -13,5 +13,6 @@ * Allow replacement of current userid so we can cache these queries. */ function user_views_query_substitutions(ViewExecutable $view) { - return array('***CURRENT_USER***' => \Drupal::currentUser()->id()); + global $user; + return array('***CURRENT_USER***' => $user->id()); } diff --git a/core/modules/views/lib/Drupal/views/Controller/ViewAjaxController.php b/core/modules/views/lib/Drupal/views/Controller/ViewAjaxController.php index cd38199..8df3017 100644 --- a/core/modules/views/lib/Drupal/views/Controller/ViewAjaxController.php +++ b/core/modules/views/lib/Drupal/views/Controller/ViewAjaxController.php @@ -131,7 +131,7 @@ public function ajaxView(Request $request) { $view->dom_id = $dom_id; $preview = $view->preview($display_id, $args); - $response->addCommand(new ReplaceCommand(".view-dom-id-$dom_id", $this->drupalRender($preview))); + $response->addCommand(new ReplaceCommand(".view-dom-id-$dom_id", drupal_render($preview))); return $response; } else { @@ -143,20 +143,4 @@ public function ajaxView(Request $request) { } } - /** - * Wraps drupal_render. - * - * @param array $elements - * The structured array describing the data to be rendered. - * - * @return string - * The rendered HTML. - * - * @todo Remove once drupal_render is converted to autoloadable code. - * @see https://drupal.org/node/2171071 - */ - protected function drupalRender(array $elements) { - return drupal_render($elements); - } - } diff --git a/core/modules/views/lib/Drupal/views/Entity/View.php b/core/modules/views/lib/Drupal/views/Entity/View.php index 8eea4c1..62e5536 100644 --- a/core/modules/views/lib/Drupal/views/Entity/View.php +++ b/core/modules/views/lib/Drupal/views/Entity/View.php @@ -96,6 +96,13 @@ class View extends ConfigEntityBase implements ViewStorageInterface { protected $base_field = 'nid'; /** + * The UUID for this entity. + * + * @var string + */ + public $uuid = NULL; + + /** * Stores a reference to the executable version of this view. * * @var \Drupal\views\ViewExecutable diff --git a/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php b/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php index 1fdfcf0..94b3ff4 100644 --- a/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php +++ b/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php @@ -14,7 +14,6 @@ use Drupal\Core\Routing\RoutingEvents; use Drupal\views\Plugin\views\display\DisplayRouterInterface; use Drupal\views\ViewExecutable; -use Drupal\views\Views; use Symfony\Component\Routing\RouteCollection; use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; use Symfony\Component\HttpKernel\KernelEvents; @@ -188,10 +187,10 @@ public function routeRebuildFinished() { /** * Returns all views/display combinations with routes. * - * @see \Drupal\views\Views::getApplicableViews() + * @see views_get_applicable_views() */ protected function getApplicableViews() { - return Views::getApplicableViews('uses_route'); + return views_get_applicable_views('uses_route'); } } diff --git a/core/modules/views/lib/Drupal/views/Plugin/Derivative/DefaultWizardDeriver.php b/core/modules/views/lib/Drupal/views/Plugin/Derivative/DefaultWizardDeriver.php index 211d8be..a46bbd8 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Derivative/DefaultWizardDeriver.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Derivative/DefaultWizardDeriver.php @@ -19,7 +19,7 @@ class DefaultWizardDeriver extends DerivativeBase { /** * {@inheritdoc} */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { $views_data = Views::viewsData(); $base_tables = array_keys($views_data->fetchBaseTables()); $this->derivatives = array(); diff --git a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php index a7fb041..30d242a 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php @@ -65,7 +65,7 @@ public function __construct($base_plugin_id, EntityStorageControllerInterface $v /** * Implements \Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinition(). */ - public function getDerivativeDefinition($derivative_id, $base_plugin_definition) { + public function getDerivativeDefinition($derivative_id, array $base_plugin_definition) { if (!empty($this->derivatives) && !empty($this->derivatives[$derivative_id])) { return $this->derivatives[$derivative_id]; } @@ -76,7 +76,7 @@ public function getDerivativeDefinition($derivative_id, $base_plugin_definition) /** * Implements \Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinitions(). */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { // Check all Views for block displays. foreach ($this->viewStorageController->loadMultiple() as $view) { // Do not return results for disabled views. diff --git a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsEntityArgumentValidator.php b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsEntityArgumentValidator.php index 9800e32..eb2f383 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsEntityArgumentValidator.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsEntityArgumentValidator.php @@ -79,7 +79,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) { /** * {@inheritdoc} */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { $entity_types = $this->entityManager->getDefinitions(); $this->derivatives = array(); foreach ($entity_types as $entity_type_id => $entity_type) { diff --git a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsEntityRow.php b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsEntityRow.php index 4376fc3..c82a88b 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsEntityRow.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsEntityRow.php @@ -79,7 +79,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) { /** * {@inheritdoc} */ - public function getDerivativeDefinition($derivative_id, $base_plugin_definition) { + public function getDerivativeDefinition($derivative_id, array $base_plugin_definition) { if (!empty($this->derivatives) && !empty($this->derivatives[$derivative_id])) { return $this->derivatives[$derivative_id]; } @@ -90,7 +90,7 @@ public function getDerivativeDefinition($derivative_id, $base_plugin_definition) /** * {@inheritdoc} */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { // Just add support for entity types which have a views integration. if (($base_table = $entity_type->getBaseTable()) && $this->viewsData->get($base_table) && $this->entityManager->hasController($entity_type_id, 'view_builder')) { diff --git a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php index 0423bb5..96bdd4c 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php @@ -65,7 +65,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) { /** * Implements \Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinition(). */ - public function getDerivativeDefinition($derivative_id, $base_plugin_definition) { + public function getDerivativeDefinition($derivative_id, array $base_plugin_definition) { if (!empty($this->derivatives) && !empty($this->derivatives[$derivative_id])) { return $this->derivatives[$derivative_id]; } @@ -76,7 +76,7 @@ public function getDerivativeDefinition($derivative_id, $base_plugin_definition) /** * Implements \Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinitions(). */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { // Check all Views for displays with an exposed filter block. foreach ($this->viewStorageController->loadMultiple() as $view) { // Do not return results for disabled views. diff --git a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsLocalTask.php b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsLocalTask.php index b38c4a4..dd346c9 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsLocalTask.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsLocalTask.php @@ -59,7 +59,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) { /** * {@inheritdoc} */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { $this->derivatives = array(); $view_route_names = $this->state->get('views.view_route_names'); diff --git a/core/modules/views/lib/Drupal/views/Plugin/Discovery/ViewsHandlerDiscovery.php b/core/modules/views/lib/Drupal/views/Plugin/Discovery/ViewsHandlerDiscovery.php new file mode 100644 index 0000000..09f5255 --- /dev/null +++ b/core/modules/views/lib/Drupal/views/Plugin/Discovery/ViewsHandlerDiscovery.php @@ -0,0 +1,50 @@ +type = $type; + parent::__construct("Plugin/views/$type", $root_namespaces, 'Drupal\Component\Annotation\PluginID'); + } + + /** + * {@inheritdoc} + */ + public function getDefinitions() { + // Add the plugin_type to the definition. + $definitions = parent::getDefinitions(); + foreach ($definitions as $key => $definition) { + $definitions[$key]['plugin_type'] = $this->type; + } + return $definitions; + } + +} diff --git a/core/modules/views/lib/Drupal/views/Plugin/ViewsHandlerManager.php b/core/modules/views/lib/Drupal/views/Plugin/ViewsHandlerManager.php index 2fc3252..0a1fb76 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/ViewsHandlerManager.php +++ b/core/modules/views/lib/Drupal/views/Plugin/ViewsHandlerManager.php @@ -8,16 +8,16 @@ namespace Drupal\views\Plugin; use Drupal\Component\Plugin\Exception\PluginException; -use Drupal\Core\Cache\CacheBackendInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Language\LanguageManagerInterface; -use Drupal\Core\Plugin\DefaultPluginManager; +use Drupal\Component\Plugin\PluginManagerBase; +use Drupal\Core\Plugin\Factory\ContainerFactory; +use Drupal\Core\Plugin\Discovery\CacheDecorator; +use Drupal\views\Plugin\Discovery\ViewsHandlerDiscovery; use Drupal\views\ViewsData; /** * Plugin type manager for all views handlers. */ -class ViewsHandlerManager extends DefaultPluginManager { +class ViewsHandlerManager extends PluginManagerBase { /** * The views data cache. @@ -45,25 +45,18 @@ class ViewsHandlerManager extends DefaultPluginManager { * keyed by the corresponding namespace to look for plugin implementations, * @param \Drupal\views\ViewsData $views_data * The views data cache. - * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend - * Cache backend instance to use. - * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager - * The language manager. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to invoke the alter hook with. */ - public function __construct($handler_type, \Traversable $namespaces, ViewsData $views_data, CacheBackendInterface $cache_backend, LanguageManagerInterface $language_manager, ModuleHandlerInterface $module_handler) { - parent::__construct("Plugin/views/$handler_type", $namespaces, $module_handler, 'Drupal\Component\Annotation\PluginID'); + public function __construct($handler_type, \Traversable $namespaces, ViewsData $views_data) { + $this->discovery = new ViewsHandlerDiscovery($handler_type, $namespaces); + $this->discovery = new CacheDecorator($this->discovery, "views:$handler_type", 'views_info'); - $this->setCacheBackend($cache_backend, $language_manager, "views:$handler_type"); + $this->factory = new ContainerFactory($this); $this->viewsData = $views_data; $this->handlerType = $handler_type; - $this->defaults = array( - 'plugin_type' => $handler_type, - ); } + /** * Fetches a handler from the data cache. * diff --git a/core/modules/views/lib/Drupal/views/Plugin/entity_reference/selection/ViewsSelection.php b/core/modules/views/lib/Drupal/views/Plugin/entity_reference/selection/ViewsSelection.php index aa84db2..05e97d9 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/entity_reference/selection/ViewsSelection.php +++ b/core/modules/views/lib/Drupal/views/Plugin/entity_reference/selection/ViewsSelection.php @@ -11,7 +11,6 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\entity_reference\Plugin\Type\Selection\SelectionInterface; -use Drupal\views\Views; /** * Plugin implementation of the 'selection' entity_reference. @@ -60,7 +59,7 @@ public function __construct(FieldDefinitionInterface $field_definition, EntityIn public static function settingsForm(FieldDefinitionInterface $field_definition) { $selection_handler_settings = $field_definition->getSetting('handler_settings') ?: array(); $view_settings = !empty($selection_handler_settings['view']) ? $selection_handler_settings['view'] : array(); - $displays = Views::getApplicableViews('entity_reference_display'); + $displays = views_get_applicable_views('entity_reference_display'); // Filter views that list the entity type we want, and group the separate // displays by view. $entity_type = \Drupal::entityManager()->getDefinition($field_definition->getSetting('target_type')); @@ -135,7 +134,7 @@ protected function initializeView($match = NULL, $match_operator = 'CONTAINS', $ $display_name = $handler_settings['view']['display_name']; // Check that the view is valid and the display still exists. - $this->view = Views::getView($view_name); + $this->view = views_get_view($view_name); if (!$this->view || !$this->view->access($display_name)) { drupal_set_message(t('The reference view %view_name used in the %field_name field cannot be found.', array('%view_name' => $view_name, '%field_name' => $this->fieldDefinition->getLabel())), 'warning'); return FALSE; diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/BrokenHandlerTrait.php b/core/modules/views/lib/Drupal/views/Plugin/views/BrokenHandlerTrait.php deleted file mode 100644 index e1623f7..0000000 --- a/core/modules/views/lib/Drupal/views/Plugin/views/BrokenHandlerTrait.php +++ /dev/null @@ -1,103 +0,0 @@ - $this->definition['original_configuration']['provider'], - ); - return $this->isOptional() ? t('Optional handler is missing (Module: @module) …', $args) : t('Broken/missing handler (Module: @module) …', $args); - } - - /** - * The option definition for this handler. - * - * @see \Drupal\views\Plugin\views\PluginBase::defineOptions(). - */ - public function defineOptions() { - return array(); - } - - /** - * Ensure the main table for this handler is in the query. This is used - * a lot. - * - * @see \Drupal\views\Plugin\views\HandlerBase::ensureMyTable(). - */ - public function ensureMyTable() { - // No table to ensure. - } - - /** - * Modify the views query. - */ - public function query($group_by = FALSE) { - /* No query to run */ - } - - /** - * Provides a form to edit options for this plugin. - * - * @see \Drupal\views\Plugin\views\PluginBase::defineOptions(). - */ - public function buildOptionsForm(&$form, &$form_state) { - if ($this->isOptional()) { - $description_top = t('The handler for this item is optional. The following details are available:'); - } - else { - $description_top = t('The handler for this item is broken or missing. The following details are available:'); - } - - $items = array( - t('Module: @module', array('@module' => $this->definition['original_configuration']['provider'])), - t('Table: @table', array('@table' => $this->definition['original_configuration']['table'])), - t('Field: @field', array('@field' => $this->definition['original_configuration']['field'])), - ); - - $description_bottom = t('Enabling the appropriate module will may solve this issue. Otherwise, check to see if there is a module update available.'); - - $form['description'] = array( - '#type' => 'container', - '#attributes' => array( - 'class' => array('form-item', 'description'), - ), - 'description_top' => array( - '#markup' => '

' . $description_top . '

', - ), - 'detail_list' => array( - '#theme' => 'item_list', - '#items' => $items, - ), - 'description_bottom' => array( - '#markup' => '

' . $description_bottom . '

', - ), - ); - } - - /** - * Determines if the handler is considered 'broken'. - * - * This means it's a placeholder used when a handler can't be found. - * - * @see \Drupal\views\Plugin\views\HandlerBase::broken(). - */ - public function broken() { - return TRUE; - } - -} diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/area/Broken.php b/core/modules/views/lib/Drupal/views/Plugin/views/area/Broken.php index 6a0967c..dff668b 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/area/Broken.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/area/Broken.php @@ -7,8 +7,6 @@ namespace Drupal\views\Plugin\views\area; -use Drupal\views\Plugin\views\BrokenHandlerTrait; - /** * A special handler to take the place of missing or broken handlers. * @@ -17,7 +15,30 @@ * @PluginID("broken") */ class Broken extends AreaPluginBase { - use BrokenHandlerTrait; + + /** + * {@inheritdoc} + */ + public function adminLabel($short = FALSE) { + $args = array( + '@module' => $this->definition['original_configuration']['provider'], + ); + return $this->isOptional() ? t('Optional handler is missing (Module: @module) …', $args) : t('Broken/missing handler (Module: @module) …', $args); + } + + /** + * {@inheritdoc} + */ + public function defineOptions() { + return array(); + } + + /** + * {@inheritdoc} + */ + public function ensureMyTable() { + // No table to ensure. + } /** * {@inheritdoc} @@ -27,4 +48,48 @@ public function render($empty = FALSE) { return array(); } + /** + * {@inheritdoc} + */ + public function buildOptionsForm(&$form, &$form_state) { + if ($this->isOptional()) { + $description_top = t('The handler for this item is optional. The following details are available:'); + } + else { + $description_top = t('The handler for this item is broken or missing. The following details are available:'); + } + + $items = array( + t('Module: @module', array('@module' => $this->definition['original_configuration']['provider'])), + t('Table: @table', array('@table' => $this->definition['original_configuration']['table'])), + t('Field: @field', array('@field' => $this->definition['original_configuration']['field'])), + ); + + $description_bottom = t('Enabling the appropriate module will may solve this issue. Otherwise, check to see if there is a module update available.'); + + $form['description'] = array( + '#type' => 'container', + '#attributes' => array( + 'class' => array('form-item', 'description'), + ), + 'description_top' => array( + '#markup' => '

' . $description_top . '

', + ), + 'detail_list' => array( + '#theme' => 'item_list', + '#items' => $items, + ), + 'description_bottom' => array( + '#markup' => '

' . $description_bottom . '

', + ), + ); + } + + /** + * {@inheritdoc} + */ + public function broken() { + return TRUE; + } + } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/area/Title.php b/core/modules/views/lib/Drupal/views/Plugin/views/area/Title.php index bbc26ec..66f3495 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/area/Title.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/area/Title.php @@ -7,8 +7,6 @@ namespace Drupal\views\Plugin\views\area; -use \Drupal\Core\Utility\Title as UtilityTitle; - /** * Views area title override handler. * @@ -53,7 +51,7 @@ public function preRender(array $results) { // If a title is provided, process it. if (!empty($this->options['title'])) { $value = $this->globalTokenReplace($this->options['title']); - $this->view->setTitle($this->sanitizeValue($value, 'xss_admin'), UtilityTitle::PASS_THROUGH); + $this->view->setTitle($this->sanitizeValue($value, 'xss_admin'), PASS_THROUGH); } } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/area/View.php b/core/modules/views/lib/Drupal/views/Plugin/views/area/View.php index 9e11d4d..6fcf820 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/area/View.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/area/View.php @@ -8,7 +8,6 @@ namespace Drupal\views\Plugin\views\area; use Drupal\Core\Entity\EntityStorageControllerInterface; -use Drupal\views\Views; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -84,7 +83,7 @@ public function buildOptionsForm(&$form, &$form_state) { $view_display = $this->view->storage->id() . ':' . $this->view->current_display; $options = array('' => t('-Select-')); - $options += Views::getViewsAsOptions(FALSE, 'all', $view_display, FALSE, TRUE); + $options += views_get_views_as_options(FALSE, 'all', $view_display, FALSE, TRUE); $form['view_to_insert'] = array( '#type' => 'select', '#title' => t('View to insert'), diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/argument/Broken.php b/core/modules/views/lib/Drupal/views/Plugin/views/argument/Broken.php index f9f90ac..9e82624 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/argument/Broken.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/argument/Broken.php @@ -7,8 +7,6 @@ namespace Drupal\views\Plugin\views\argument; -use Drupal\views\Plugin\views\BrokenHandlerTrait; - /** * A special handler to take the place of missing or broken handlers. * @@ -17,6 +15,58 @@ * @PluginID("broken") */ class Broken extends ArgumentPluginBase { - use BrokenHandlerTrait; + + public function adminLabel($short = FALSE) { + $args = array( + '@module' => $this->definition['original_configuration']['provider'], + ); + return $this->isOptional() ? t('Optional handler is missing (Module: @module) …', $args) : t('Broken/missing handler (Module: @module) …', $args); + } + + public function defineOptions() { return array(); } + public function ensureMyTable() { /* No table to ensure! */ } + public function query($group_by = FALSE) { /* No query to run */ } + + /** + * {@inheritdoc} + */ + public function buildOptionsForm(&$form, &$form_state) { + if ($this->isOptional()) { + $description_top = t('The handler for this item is optional. The following details are available:'); + } + else { + $description_top = t('The handler for this item is broken or missing. The following details are available:'); + } + + $items = array( + t('Module: @module', array('@module' => $this->definition['original_configuration']['provider'])), + t('Table: @table', array('@table' => $this->definition['original_configuration']['table'])), + t('Field: @field', array('@field' => $this->definition['original_configuration']['field'])), + ); + + $description_bottom = t('Enabling the appropriate module will may solve this issue. Otherwise, check to see if there is a module update available.'); + + $form['description'] = array( + '#type' => 'container', + '#attributes' => array( + 'class' => array('form-item', 'description'), + ), + 'description_top' => array( + '#markup' => '

' . $description_top . '

', + ), + 'detail_list' => array( + '#theme' => 'item_list', + '#items' => $items, + ), + 'description_bottom' => array( + '#markup' => '

' . $description_bottom . '

', + ), + ); + } + + /** + * Determine if the handler is considered 'broken' + */ + public function broken() { return TRUE; } } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php index bc99b02..db9eff1 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php @@ -1516,7 +1516,7 @@ public function buildOptionsForm(&$form, &$form_state) { '#title' => t('Access'), '#title_display' => 'invisible', '#type' => 'radios', - '#options' => Views::fetchPluginNames('access', $this->getType(), array($this->view->storage->get('base_table'))), + '#options' => views_fetch_plugin_names('access', $this->getType(), array($this->view->storage->get('base_table'))), '#default_value' => $access['type'], ); @@ -1553,7 +1553,7 @@ public function buildOptionsForm(&$form, &$form_state) { '#title' => t('Caching'), '#title_display' => 'invisible', '#type' => 'radios', - '#options' => Views::fetchPluginNames('cache', $this->getType(), array($this->view->storage->get('base_table'))), + '#options' => views_fetch_plugin_names('cache', $this->getType(), array($this->view->storage->get('base_table'))), '#default_value' => $cache['type'], ); @@ -1647,7 +1647,7 @@ public function buildOptionsForm(&$form, &$form_state) { '#title' => t('Style'), '#title_display' => 'invisible', '#type' => 'radios', - '#options' => Views::fetchPluginNames('style', $this->getType(), array($this->view->storage->get('base_table'))), + '#options' => views_fetch_plugin_names('style', $this->getType(), array($this->view->storage->get('base_table'))), '#default_value' => $style_plugin->definition['id'], '#description' => t('If the style you choose has settings, be sure to click the settings button that will appear next to it in the View summary.'), ); @@ -1696,7 +1696,7 @@ public function buildOptionsForm(&$form, &$form_state) { '#title' => t('Row'), '#title_display' => 'invisible', '#type' => 'radios', - '#options' => Views::fetchPluginNames('row', $this->getType(), array($this->view->storage->get('base_table'))), + '#options' => views_fetch_plugin_names('row', $this->getType(), array($this->view->storage->get('base_table'))), '#default_value' => $row_plugin_instance->definition['id'], ); @@ -1790,7 +1790,7 @@ public function buildOptionsForm(&$form, &$form_state) { '#title' => t('Exposed form'), '#title_display' => 'invisible', '#type' => 'radios', - '#options' => Views::fetchPluginNames('exposed_form', $this->getType(), array($this->view->storage->get('base_table'))), + '#options' => views_fetch_plugin_names('exposed_form', $this->getType(), array($this->view->storage->get('base_table'))), '#default_value' => $exposed_form['type'], ); @@ -1826,7 +1826,7 @@ public function buildOptionsForm(&$form, &$form_state) { '#title' => t('Pager'), '#title_display' => 'invisible', '#type' => 'radios', - '#options' => Views::fetchPluginNames('pager', !$this->usesPager() ? 'basic' : NULL, array($this->view->storage->get('base_table'))), + '#options' => views_fetch_plugin_names('pager', !$this->usesPager() ? 'basic' : NULL, array($this->view->storage->get('base_table'))), '#default_value' => $pager['type'], ); @@ -2233,7 +2233,7 @@ function preview() { * @return string * The required display type. Defaults to 'normal'. * - * @see \Drupal\views\Views::fetchPluginNames() + * @see views_fetch_plugin_names() */ protected function getType() { return 'normal'; diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/Feed.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/Feed.php index ed7a571..d50e976 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/Feed.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/Feed.php @@ -9,7 +9,6 @@ use Drupal\Component\Utility\String; use Drupal\views\ViewExecutable; -use Drupal\views\Views; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -51,7 +50,7 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio // Set the default row style. Ideally this would be part of the option // definition, but in this case it's dependent on the view's base table, // which we don't know until init(). - $row_plugins = Views::fetchPluginNames('row', $this->getType(), array($view->storage->get('base_table'))); + $row_plugins = views_fetch_plugin_names('row', $this->getType(), array($view->storage->get('base_table'))); $default_row_plugin = key($row_plugins); if (empty($this->options['row']['type'])) { $this->options['row']['type'] = $default_row_plugin; diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/field/Broken.php b/core/modules/views/lib/Drupal/views/Plugin/views/field/Broken.php index c76431e..062927f 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/field/Broken.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/field/Broken.php @@ -7,8 +7,6 @@ namespace Drupal\views\Plugin\views\field; -use Drupal\views\Plugin\views\BrokenHandlerTrait; - /** * A special handler to take the place of missing or broken handlers. * @@ -17,6 +15,58 @@ * @PluginID("broken") */ class Broken extends FieldPluginBase { - use BrokenHandlerTrait; + + public function adminLabel($short = FALSE) { + $args = array( + '@module' => $this->definition['original_configuration']['provider'], + ); + return $this->isOptional() ? t('Optional handler is missing (Module: @module) …', $args) : t('Broken/missing handler (Module: @module) …', $args); + } + + public function defineOptions() { return array(); } + public function ensureMyTable() { /* No table to ensure! */ } + public function query($group_by = FALSE) { /* No query to run */ } + + /** + * {@inheritdoc} + */ + public function buildOptionsForm(&$form, &$form_state) { + if ($this->isOptional()) { + $description_top = t('The handler for this item is optional. The following details are available:'); + } + else { + $description_top = t('The handler for this item is broken or missing. The following details are available:'); + } + + $items = array( + t('Module: @module', array('@module' => $this->definition['original_configuration']['provider'])), + t('Table: @table', array('@table' => $this->definition['original_configuration']['table'])), + t('Field: @field', array('@field' => $this->definition['original_configuration']['field'])), + ); + + $description_bottom = t('Enabling the appropriate module will may solve this issue. Otherwise, check to see if there is a module update available.'); + + $form['description'] = array( + '#type' => 'container', + '#attributes' => array( + 'class' => array('form-item', 'description'), + ), + 'description_top' => array( + '#markup' => '

' . $description_top . '

', + ), + 'detail_list' => array( + '#theme' => 'item_list', + '#items' => $items, + ), + 'description_bottom' => array( + '#markup' => '

' . $description_bottom . '

', + ), + ); + } + + /** + * Determine if the handler is considered 'broken' + */ + public function broken() { return TRUE; } } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/filter/Broken.php b/core/modules/views/lib/Drupal/views/Plugin/views/filter/Broken.php index 2a4abcf..e4b1333 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/filter/Broken.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/filter/Broken.php @@ -7,7 +7,6 @@ namespace Drupal\views\Plugin\views\filter; -use Drupal\views\Plugin\views\BrokenHandlerTrait; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ViewExecutable; @@ -19,12 +18,64 @@ * @PluginID("broken") */ class Broken extends FilterPluginBase { - use BrokenHandlerTrait; /** - * {@inheritdoc} + * Overrides \Drupal\views\Plugin\views\filter\FilterPluginBase::init(). */ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) { } + public function adminLabel($short = FALSE) { + $args = array( + '@module' => $this->definition['original_configuration']['provider'], + ); + return $this->isOptional() ? t('Optional handler is missing (Module: @module) …', $args) : t('Broken/missing handler (Module: @module) …', $args); + } + + public function defineOptions() { return array(); } + public function ensureMyTable() { /* No table to ensure! */ } + public function query($group_by = FALSE) { /* No query to run */ } + + /** + * {@inheritdoc} + */ + public function buildOptionsForm(&$form, &$form_state) { + if ($this->isOptional()) { + $description_top = t('The handler for this item is optional. The following details are available:'); + } + else { + $description_top = t('The handler for this item is broken or missing. The following details are available:'); + } + + $items = array( + t('Module: @module', array('@module' => $this->definition['original_configuration']['provider'])), + t('Table: @table', array('@table' => $this->definition['original_configuration']['table'])), + t('Field: @field', array('@field' => $this->definition['original_configuration']['field'])), + ); + + $description_bottom = t('Enabling the appropriate module will may solve this issue. Otherwise, check to see if there is a module update available.'); + + $form['description'] = array( + '#type' => 'container', + '#attributes' => array( + 'class' => array('form-item', 'description'), + ), + 'description_top' => array( + '#markup' => '

' . $description_top . '

', + ), + 'detail_list' => array( + '#theme' => 'item_list', + '#items' => $items, + ), + 'description_bottom' => array( + '#markup' => '

' . $description_bottom . '

', + ), + ); + } + + /** + * Determine if the handler is considered 'broken' + */ + public function broken() { return TRUE; } + } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/relationship/Broken.php b/core/modules/views/lib/Drupal/views/Plugin/views/relationship/Broken.php index 16ee48c..19d49c7 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/relationship/Broken.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/relationship/Broken.php @@ -7,8 +7,6 @@ namespace Drupal\views\Plugin\views\relationship; -use Drupal\views\Plugin\views\BrokenHandlerTrait; - /** * A special handler to take the place of missing or broken handlers. * @@ -17,6 +15,80 @@ * @PluginID("broken") */ class Broken extends RelationshipPluginBase { - use BrokenHandlerTrait; + + /** + * {@inheritdoc} + */ + public function adminLabel($short = FALSE) { + $args = array( + '@module' => $this->definition['original_configuration']['provider'], + ); + return $this->isOptional() ? t('Optional handler is missing (Module: @module) …', $args) : t('Broken/missing handler (Module: @module) …', $args); + } + + /** + * {@inheritdoc} + */ + protected function defineOptions() { + return array(); + } + + /** + * {@inheritdoc} + */ + public function ensureMyTable() { + // No table to ensure. + } + + /** + * {@inheritdoc} + */ + public function query() { + // No query to run. + } + + /** + * {@inheritdoc} + */ + public function buildOptionsForm(&$form, &$form_state) { + if ($this->isOptional()) { + $description_top = t('The handler for this item is optional. The following details are available:'); + } + else { + $description_top = t('The handler for this item is broken or missing. The following details are available:'); + } + + $items = array( + t('Module: @module', array('@module' => $this->definition['original_configuration']['provider'])), + t('Table: @table', array('@table' => $this->definition['original_configuration']['table'])), + t('Field: @field', array('@field' => $this->definition['original_configuration']['field'])), + ); + + $description_bottom = t('Enabling the appropriate module will may solve this issue. Otherwise, check to see if there is a module update available.'); + + $form['description'] = array( + '#type' => 'container', + '#attributes' => array( + 'class' => array('form-item', 'description'), + ), + 'description_top' => array( + '#markup' => '

' . $description_top . '

', + ), + 'detail_list' => array( + '#theme' => 'item_list', + '#items' => $items, + ), + 'description_bottom' => array( + '#markup' => '

' . $description_bottom . '

', + ), + ); + } + + /** + * {@inheritdoc} + */ + public function broken() { + return TRUE; + } } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/relationship/GroupwiseMax.php b/core/modules/views/lib/Drupal/views/Plugin/views/relationship/GroupwiseMax.php index 44be0ae..4355a61 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/relationship/GroupwiseMax.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/relationship/GroupwiseMax.php @@ -121,7 +121,7 @@ public function buildOptionsForm(&$form, &$form_state) { // WIP: This stuff doens't work yet: namespacing issues. // A list of suitable views to pick one as the subview. $views = array('' => '- None -'); - $all_views = Views::getAllViews(); + $all_views = views_get_all_views(); foreach ($all_views as $view) { // Only get views that are suitable: // - base must the base that our relationship joins towards @@ -189,7 +189,7 @@ public function submitOptionsForm(&$form, &$form_state) { protected function leftQuery($options) { // Either load another view, or create one on the fly. if ($options['subquery_view']) { - $temp_view = Views::getView($options['subquery_view']); + $temp_view = views_get_view($options['subquery_view']); // Remove all fields from default display unset($temp_view->display['default']['display_options']['fields']); } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/sort/Broken.php b/core/modules/views/lib/Drupal/views/Plugin/views/sort/Broken.php index a702625..234ee57 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/sort/Broken.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/sort/Broken.php @@ -7,8 +7,6 @@ namespace Drupal\views\Plugin\views\sort; -use Drupal\views\Plugin\views\BrokenHandlerTrait; - /** * A special handler to take the place of missing or broken handlers. * @@ -17,6 +15,58 @@ * @PluginID("broken") */ class Broken extends SortPluginBase { - use BrokenHandlerTrait; + + public function adminLabel($short = FALSE) { + $args = array( + '@module' => $this->definition['original_configuration']['provider'], + ); + return $this->isOptional() ? t('Optional handler is missing (Module: @module) …', $args) : t('Broken/missing handler (Module: @module) …', $args); + } + + public function defineOptions() { return array(); } + public function ensureMyTable() { /* No table to ensure! */ } + public function query($group_by = FALSE) { /* No query to run */ } + + /** + * {@inheritdoc} + */ + public function buildOptionsForm(&$form, &$form_state) { + if ($this->isOptional()) { + $description_top = t('The handler for this item is optional. The following details are available:'); + } + else { + $description_top = t('The handler for this item is broken or missing. The following details are available:'); + } + + $items = array( + t('Module: @module', array('@module' => $this->definition['original_configuration']['provider'])), + t('Table: @table', array('@table' => $this->definition['original_configuration']['table'])), + t('Field: @field', array('@field' => $this->definition['original_configuration']['field'])), + ); + + $description_bottom = t('Enabling the appropriate module will may solve this issue. Otherwise, check to see if there is a module update available.'); + + $form['description'] = array( + '#type' => 'container', + '#attributes' => array( + 'class' => array('form-item', 'description'), + ), + 'description_top' => array( + '#markup' => '

' . $description_top . '

', + ), + 'detail_list' => array( + '#theme' => 'item_list', + '#items' => $items, + ), + 'description_bottom' => array( + '#markup' => '

' . $description_bottom . '

', + ), + ); + } + + /** + * Determine if the handler is considered 'broken' + */ + public function broken() { return TRUE; } } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php index b7a8bdf..7416f10 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php @@ -201,8 +201,8 @@ public function getSorts() { * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { - $style_options = Views::fetchPluginNames('style', 'normal', array($this->base_table)); - $feed_row_options = Views::fetchPluginNames('row', 'feed', array($this->base_table)); + $style_options = views_fetch_plugin_names('style', 'normal', array($this->base_table)); + $feed_row_options = views_fetch_plugin_names('row', 'feed', array($this->base_table)); $path_prefix = url(NULL, array('absolute' => TRUE)); // Add filters and sorts which apply to the view as a whole. @@ -548,7 +548,7 @@ protected function buildFormStyle(array &$form, array &$form_state, $type) { */ protected function rowStyleOptions() { // Get all available row plugins by default. - $options = Views::fetchPluginNames('row', 'normal', array($this->base_table)); + $options = views_fetch_plugin_names('row', 'normal', array($this->base_table)); return $options; } diff --git a/core/modules/views/lib/Drupal/views/Tests/BasicTest.php b/core/modules/views/lib/Drupal/views/Tests/BasicTest.php index 719e752..aef6a50 100644 --- a/core/modules/views/lib/Drupal/views/Tests/BasicTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/BasicTest.php @@ -7,8 +7,6 @@ namespace Drupal\views\Tests; -use Drupal\views\Views; - /** * Basic test class for Views query builder tests. */ @@ -33,7 +31,7 @@ public static function getInfo() { * Tests a trivial result set. */ public function testSimpleResultSet() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Execute the view. @@ -51,7 +49,7 @@ public function testSimpleResultSet() { * Tests filtering of the result set. */ public function testSimpleFiltering() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Add a filter. @@ -111,7 +109,7 @@ public function testSimpleFiltering() { */ public function testSimpleArgument() { // Execute with a view - $view = Views::getView('test_simple_argument'); + $view = views_get_view('test_simple_argument'); $view->setArguments(array(27)); $this->executeView($view); @@ -132,7 +130,7 @@ public function testSimpleArgument() { )); // Test "show all" if no argument is present. - $view = Views::getView('test_simple_argument'); + $view = views_get_view('test_simple_argument'); $this->executeView($view); // Build the expected result. diff --git a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php index 208b888..81e692f 100644 --- a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php @@ -11,7 +11,6 @@ use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; use Drupal\views\ViewExecutable; -use Drupal\views\Views; /** * Tests for views default views. @@ -190,7 +189,7 @@ public function testArchiveView() { ); $this->drupalCreateNode($node); - $view = Views::getView('archive'); + $view = views_get_view('archive'); $view->setDisplay('page_1'); $this->executeView($view); $columns = array('nid', 'created_year_month', 'num_records'); diff --git a/core/modules/views/lib/Drupal/views/Tests/Entity/FieldEntityTest.php b/core/modules/views/lib/Drupal/views/Tests/Entity/FieldEntityTest.php index d828383..95e661e 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Entity/FieldEntityTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Entity/FieldEntityTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Entity; use Drupal\views\Tests\ViewTestBase; -use Drupal\views\Views; /** * Tests the field plugin base integration with the entity system. @@ -60,7 +59,7 @@ public function testGetEntity() { )); $comment->save(); - $view = Views::getView('test_field_get_entity'); + $view = views_get_view('test_field_get_entity'); $this->executeView($view); $row = $view->result[0]; diff --git a/core/modules/views/lib/Drupal/views/Tests/Entity/FilterEntityBundleTest.php b/core/modules/views/lib/Drupal/views/Tests/Entity/FilterEntityBundleTest.php index d950a6a..0d7ee5d 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Entity/FilterEntityBundleTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Entity/FilterEntityBundleTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Entity; use Drupal\views\Tests\ViewTestBase; -use Drupal\views\Views; /** * Tests the EntityType generic filter handler. @@ -75,7 +74,7 @@ public function setUp() { * Tests the generic bundle filter. */ public function testFilterEntity() { - $view = Views::getView('test_entity_type_filter'); + $view = views_get_view('test_entity_type_filter'); $this->executeView($view); // Test we have all the results, with all types selected. diff --git a/core/modules/views/lib/Drupal/views/Tests/GlossaryTest.php b/core/modules/views/lib/Drupal/views/Tests/GlossaryTest.php index 739f2a6..07b507b 100644 --- a/core/modules/views/lib/Drupal/views/Tests/GlossaryTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/GlossaryTest.php @@ -6,9 +6,7 @@ */ namespace Drupal\views\Tests; - use Drupal\Component\Utility\Unicode; -use Drupal\views\Views; /** * Tests glossary view ( summary of arguments ). @@ -56,7 +54,7 @@ public function testGlossaryView() { } // Execute glossary view - $view = Views::getView('glossary'); + $view = views_get_view('glossary'); $view->setDisplay('attachment_1'); $view->executeDisplay('attachment_1'); diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php index 81374f7..ab4a6b5 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php @@ -89,7 +89,7 @@ public function testEntityArea() { \Drupal::state()->set('entity_test_entity_access.view.' . $entity_test->id(), $i != 2); } - $view = Views::getView('test_entity_area'); + $view = views_get_view('test_entity_area'); $preview = $view->preview('default', array($entities[1]->id())); $this->drupalSetContent(drupal_render($preview)); @@ -102,7 +102,7 @@ public function testEntityArea() { $this->assertTrue(strpos(trim((string) $result[0]), 'full') !== FALSE, 'The rendered entity appeared in the right view mode.'); // Change the view mode of the area handler. - $view = Views::getView('test_entity_area'); + $view = views_get_view('test_entity_area'); $item = $view->getHandler('default', 'header', 'entity_entity_test'); $item['view_mode'] = 'test'; $view->setHandler('default', 'header', 'entity_entity_test', $item); diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaHTTPStatusCodeTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaHTTPStatusCodeTest.php index b39c9d0..b2f5c08 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaHTTPStatusCodeTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaHTTPStatusCodeTest.php @@ -7,8 +7,6 @@ namespace Drupal\views\Tests\Handler; -use Drupal\views\Views; - /** * Tests the http_status_code area handler. * @@ -46,7 +44,7 @@ public function testHTTPStatusCodeHandler() { $this->assertResponse(200); // Change the HTTP status code to 418. - $view = Views::getView('test_http_status_code'); + $view = views_get_view('test_http_status_code'); $display = &$view->storage->getDisplay('default'); $display['display_options']['empty']['http_status_code']['status_code'] = 418; $view->save(); diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTest.php index 2fae9d3..e7007de 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTest.php @@ -7,8 +7,6 @@ namespace Drupal\views\Tests\Handler; -use Drupal\views\Views; - /** * Tests the abstract area handler. * @@ -94,7 +92,7 @@ public function testUI() { * Tests the rendering of an area. */ public function testRenderArea() { - $view = Views::getView('test_example_area'); + $view = views_get_view('test_example_area'); $view->initHandlers(); // Insert a random string to the test area plugin and see whether it is @@ -126,7 +124,7 @@ public function testRenderAreaToken() { $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration')); $this->drupalLogin($admin_user); - $view = Views::getView('test_example_area'); + $view = views_get_view('test_example_area'); $view->initHandlers(); $this->drupalGet('admin/structure/views/nojs/handler/test_example_area/default/empty/test_example'); @@ -161,7 +159,7 @@ public function testRenderAreaToken() { * Tests overriding the view title using the area title handler. */ public function testTitleArea() { - $view = Views::getView('frontpage'); + $view = views_get_view('frontpage'); $view->initDisplay('page_1'); // Add the title area handler to the empty area. diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTextTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTextTest.php index 2ac78f8..82127e8 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTextTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTextTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests the text area handler. @@ -42,7 +41,7 @@ protected function setUp() { } public function testAreaText() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // add a text header diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTitleTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTitleTest.php index 367e980..38399d7 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTitleTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaTitleTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests the title area handler. @@ -36,7 +35,7 @@ public static function getInfo() { * Tests the title area handler. */ public function testTitleText() { - $view = Views::getView('test_area_title'); + $view = views_get_view('test_area_title'); $view->setDisplay('default'); $this->executeView($view); diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/ArgumentDateTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/ArgumentDateTest.php index 6c1ae6e..c5dac2e 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/ArgumentDateTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/ArgumentDateTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests the core date argument handlers. @@ -69,7 +68,7 @@ public function viewsData() { * @see \Drupal\node\Plugin\views\argument\CreatedFullDate */ public function testCreatedFullDateHandler() { - $view = Views::getView('test_argument_date'); + $view = views_get_view('test_argument_date'); $view->setDisplay('default'); $this->executeView($view, array('20000102')); $expected = array(); @@ -100,7 +99,7 @@ public function testCreatedFullDateHandler() { * @see \Drupal\node\Plugin\views\argument\CreatedDay */ public function testDayHandler() { - $view = Views::getView('test_argument_date'); + $view = views_get_view('test_argument_date'); $view->setDisplay('embed_1'); $this->executeView($view, array('02')); $expected = array(); @@ -130,7 +129,7 @@ public function testDayHandler() { * @see \Drupal\node\Plugin\views\argument\CreatedMonth */ public function testMonthHandler() { - $view = Views::getView('test_argument_date'); + $view = views_get_view('test_argument_date'); $view->setDisplay('embed_2'); $this->executeView($view, array('01')); $expected = array(); @@ -169,7 +168,7 @@ public function testWeekHandler() { ->condition('id', 5) ->execute(); - $view = Views::getView('test_argument_date'); + $view = views_get_view('test_argument_date'); $view->setDisplay('embed_3'); // The first jan 2000 was still in the last week of the previous year. $this->executeView($view, array(52)); @@ -221,7 +220,7 @@ public function testYearHandler() { ->condition('id', 5) ->execute(); - $view = Views::getView('test_argument_date'); + $view = views_get_view('test_argument_date'); $view->setDisplay('embed_4'); $this->executeView($view, array('2000')); $expected = array(); @@ -272,7 +271,7 @@ public function testYearMonthHandler() { ->condition('id', 5) ->execute(); - $view = Views::getView('test_argument_date'); + $view = views_get_view('test_argument_date'); $view->setDisplay('embed_5'); $this->executeView($view, array('200001')); $expected = array(); diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/ArgumentNullTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/ArgumentNullTest.php index 3c5930a..b9bedbe 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/ArgumentNullTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/ArgumentNullTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests the core Drupal\views\Plugin\views\argument\Null handler. @@ -39,7 +38,7 @@ function viewsData() { public function testAreaText() { // Test validation - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Add a null argument. diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/ArgumentStringTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/ArgumentStringTest.php index 4f2a7bc..3119adb 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/ArgumentStringTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/ArgumentStringTest.php @@ -7,8 +7,6 @@ namespace Drupal\views\Tests\Handler; -use Drupal\views\Views; - /** * Tests the core Drupal\views\Plugin\views\argument\String handler. */ @@ -51,7 +49,7 @@ function testGlossary() { } } - $view = Views::getView('test_glossary'); + $view = views_get_view('test_glossary'); $this->executeView($view); $count_field = 'nid'; diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldBooleanTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldBooleanTest.php index 482980d..d81d5c9 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldBooleanTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldBooleanTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests the core Drupal\views\Plugin\views\field\Boolean handler. @@ -45,7 +44,7 @@ function viewsData() { } public function testFieldBoolean() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); $view->displayHandlers->get('default')->overrideOption('fields', array( diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldCounterTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldCounterTest.php index 3d12d42..8773248 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldCounterTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldCounterTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests the Drupal\views\Plugin\views\field\Counter handler. @@ -38,7 +37,7 @@ public static function getInfo() { } function testSimple() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); $view->displayHandlers->get('default')->overrideOption('fields', array( 'counter' => array( diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldCustomTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldCustomTest.php index a761ce2..8f70f48 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldCustomTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldCustomTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests the core Drupal\views\Plugin\views\field\Custom handler. @@ -37,7 +36,7 @@ function viewsData() { } public function testFieldCustom() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Alter the text of the field to a random string. diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldDateTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldDateTest.php index 54cdc02..cfa1270 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldDateTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldDateTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests the core Drupal\views\Plugin\views\field\Date handler. @@ -37,7 +36,7 @@ function viewsData() { } public function testFieldDate() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); $view->displayHandlers->get('default')->overrideOption('fields', array( diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldFileSizeTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldFileSizeTest.php index e1e317d..1f2304d 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldFileSizeTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldFileSizeTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests the core Drupal\views\Plugin\views\field\FileSize handler. @@ -50,7 +49,7 @@ function viewsData() { } public function testFieldFileSize() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); $view->displayHandlers->get('default')->overrideOption('fields', array( diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldUnitTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldUnitTest.php index e7f780c..6ad3b19 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldUnitTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldUnitTest.php @@ -9,7 +9,6 @@ use Drupal\views\Tests\ViewUnitTestBase; use Drupal\views\Plugin\views\field\FieldPluginBase; -use Drupal\views\Views; /** * Tests the generic field handler. @@ -54,7 +53,7 @@ protected function viewsData() { * Tests that the render function is called. */ public function testRender() { - $view = Views::getView('test_field_tokens'); + $view = views_get_view('test_field_tokens'); $this->executeView($view); $random_text = $this->randomName(); @@ -67,7 +66,7 @@ public function testRender() { */ public function testQuery() { // Tests adding additional fields to the query. - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->initHandlers(); $id_field = $view->field['id']; @@ -143,7 +142,7 @@ protected function assertNotSubString($haystack, $needle, $message = '', $group * Tests general rewriting of the output. */ public function testRewrite() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->initHandlers(); $this->executeView($view); $row = $view->result[0]; @@ -163,7 +162,7 @@ public function testRewrite() { * Tests the field tokens, row level and field level. */ public function testFieldTokens() { - $view = Views::getView('test_field_tokens'); + $view = views_get_view('test_field_tokens'); $this->executeView($view); $name_field_0 = $view->field['name']; $name_field_1 = $view->field['name_1']; @@ -208,7 +207,7 @@ public function testFieldTokens() { * Tests the exclude setting. */ public function testExclude() { - $view = Views::getView('test_field_output'); + $view = views_get_view('test_field_output'); $view->initHandlers(); // Hide the field and see whether it's rendered. $view->field['name']->options['exclude'] = TRUE; @@ -243,7 +242,7 @@ function testEmpty() { * This tests alters the result to get easier and less coupled results. */ function _testHideIfEmpty() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->initDisplay(); $this->executeView($view); @@ -461,7 +460,7 @@ function _testHideIfEmpty() { * Tests the usage of the empty text. */ function _testEmptyText() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->initDisplay(); $this->executeView($view); @@ -498,7 +497,7 @@ function _testEmptyText() { * Tests views_handler_field::isValueEmpty(). */ function testIsValueEmpty() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->initHandlers(); $field = $view->field['name']; diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldUrlTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldUrlTest.php index 5e89599..b2f2118 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldUrlTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldUrlTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests the core Drupal\views\Plugin\views\field\Url handler. @@ -44,7 +43,7 @@ function viewsData() { } public function testFieldUrl() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); $view->displayHandlers->get('default')->overrideOption('fields', array( diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldWebTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldWebTest.php index dc9e3e8..7bf0e89 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldWebTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldWebTest.php @@ -7,8 +7,6 @@ namespace Drupal\views\Tests\Handler; -use Drupal\views\Views; - /** * Tests fields from within a UI. * @@ -177,7 +175,7 @@ protected function xpathContent($content, $xpath, array $arguments = array()) { * Tests rewriting the output to a link. */ public function testAlterUrl() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); $view->initHandlers(); $this->executeView($view); @@ -325,7 +323,7 @@ public function testAlterUrl() { * Tests the field/label/wrapper classes. */ public function testFieldClasses() { - $view = Views::getView('test_field_classes'); + $view = views_get_view('test_field_classes'); $view->initHandlers(); // Tests whether the default field classes are added. @@ -432,7 +430,7 @@ public function testFieldClasses() { * Tests trimming/read-more/ellipses. */ public function testTextRendering() { - $view = Views::getView('test_field_output'); + $view = views_get_view('test_field_output'); $view->initHandlers(); $name_field = $view->field['name']; diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldXssTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldXssTest.php index 5eb8911..dac9b56 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldXssTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldXssTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests the core Drupal\views\Plugin\views\field\Xss handler. @@ -51,7 +50,7 @@ function viewsData() { } public function testFieldXss() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); $view->displayHandlers->get('default')->overrideOption('fields', array( diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterBooleanOperatorTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterBooleanOperatorTest.php index b512a07..a9ff2cf 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterBooleanOperatorTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterBooleanOperatorTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests the BooleanOperator filter handler. @@ -53,7 +52,7 @@ protected function setUp() { * Tests the BooleanOperator filter. */ public function testFilterBooleanOperator() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Add a the status boolean filter. @@ -104,7 +103,7 @@ public function testFilterBooleanOperator() { */ public function testFilterGroupedExposed() { $filters = $this->getGroupedExposedFilters(); - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setExposedInput(array('status' => 1)); $view->setDisplay(); diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterCombineTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterCombineTest.php index f18b912..e49acdb 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterCombineTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterCombineTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests the combine filter handler. @@ -36,7 +35,7 @@ public static function getInfo() { } public function testFilterCombineContains() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); $fields = $view->displayHandlers->get('default')->getOption('fields'); diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterDateTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterDateTest.php index 5665e96..cd94718 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterDateTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterDateTest.php @@ -7,8 +7,6 @@ namespace Drupal\views\Tests\Handler; -use Drupal\views\Views; - /** * Tests the core Drupal\views\Plugin\views\filter\Date handler. */ @@ -63,7 +61,7 @@ protected function testDateFilter() { * Test the general offset functionality. */ protected function _testOffset() { - $view = Views::getView('test_filter_date_between'); + $view = views_get_view('test_filter_date_between'); // Test offset for simple operator. $view->initHandlers(); @@ -94,7 +92,7 @@ protected function _testOffset() { * Tests the filter operator between/not between. */ protected function _testBetween() { - $view = Views::getView('test_filter_date_between'); + $view = views_get_view('test_filter_date_between'); // Test between with min and max. $view->initHandlers(); diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterEqualityTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterEqualityTest.php index bbc0758..f239773 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterEqualityTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterEqualityTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests the core Drupal\views\Plugin\views\filter\Equality handler. @@ -49,7 +48,7 @@ function viewsData() { } function testEqual() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the filtering @@ -75,7 +74,7 @@ function testEqual() { public function testEqualGroupedExposed() { $filters = $this->getGroupedExposedFilters(); - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->newDisplay('page', 'Page', 'page_1'); // Filter: Name, Operator: =, Value: Ringo @@ -93,7 +92,7 @@ public function testEqualGroupedExposed() { } function testNotEqual() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the filtering @@ -128,7 +127,7 @@ function testNotEqual() { public function testEqualGroupedNotExposed() { $filters = $this->getGroupedExposedFilters(); - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->newDisplay('page', 'Page', 'page_1'); // Filter: Name, Operator: !=, Value: Ringo diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterInOperatorTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterInOperatorTest.php index 4328154..7c710e3 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterInOperatorTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterInOperatorTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests the core Drupal\views\Plugin\views\filter\InOperator handler. @@ -50,7 +49,7 @@ function viewsData() { } public function testFilterInOperatorSimple() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Add a in_operator ordering. @@ -117,7 +116,7 @@ public function testFilterInOperatorSimple() { public function testFilterInOperatorGroupedExposedSimple() { $filters = $this->getGroupedExposedFilters(); - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); // Filter: Age, Operator: in, Value: 26, 30 $filters['age']['group_info']['default_group'] = 1; @@ -143,7 +142,7 @@ public function testFilterInOperatorGroupedExposedSimple() { public function testFilterNotInOperatorGroupedExposedSimple() { $filters = $this->getGroupedExposedFilters(); - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); // Filter: Age, Operator: in, Value: 26, 30 $filters['age']['group_info']['default_group'] = 2; diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterNumericTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterNumericTest.php index 8b70f44..ae18750 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterNumericTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterNumericTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests the numeric filter handler. @@ -52,7 +51,7 @@ function viewsData() { } public function testFilterNumericSimple() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the filtering @@ -79,7 +78,7 @@ public function testFilterNumericSimple() { public function testFilterNumericExposedGroupedSimple() { $filters = $this->getGroupedExposedFilters(); - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->newDisplay('page', 'Page', 'page_1'); // Filter: Age, Operator: =, Value: 28 @@ -98,7 +97,7 @@ public function testFilterNumericExposedGroupedSimple() { } public function testFilterNumericBetween() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the filtering @@ -172,7 +171,7 @@ public function testFilterNumericBetween() { public function testFilterNumericExposedGroupedBetween() { $filters = $this->getGroupedExposedFilters(); - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->newDisplay('page', 'Page', 'page_1'); // Filter: Age, Operator: between, Value: 26 and 29 @@ -200,7 +199,7 @@ public function testFilterNumericExposedGroupedBetween() { public function testFilterNumericExposedGroupedNotBetween() { $filters = $this->getGroupedExposedFilters(); - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->newDisplay('page', 'Page', 'page_1'); // Filter: Age, Operator: between, Value: 26 and 29 @@ -227,7 +226,7 @@ public function testFilterNumericExposedGroupedNotBetween() { } public function testFilterNumericEmpty() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the filtering @@ -288,7 +287,7 @@ public function testFilterNumericEmpty() { public function testFilterNumericExposedGroupedEmpty() { $filters = $this->getGroupedExposedFilters(); - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->newDisplay('page', 'Page', 'page_1'); // Filter: Age, Operator: empty, Value: @@ -304,7 +303,7 @@ public function testFilterNumericExposedGroupedEmpty() { public function testFilterNumericExposedGroupedNotEmpty() { $filters = $this->getGroupedExposedFilters(); - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->newDisplay('page', 'Page', 'page_1'); // Filter: Age, Operator: empty, Value: @@ -339,7 +338,7 @@ public function testFilterNumericExposedGroupedNotEmpty() { } public function testAllowEmpty() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); $view->displayHandlers->get('default')->overrideOption('filters', array( diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterStringTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterStringTest.php index a0c0dc0..8d7e1f5 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/FilterStringTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FilterStringTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests the core Drupal\views\Plugin\views\filter\String handler. @@ -83,7 +82,7 @@ protected function dataSet() { * @return view */ protected function getBasicPageView() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); // In order to test exposed filters, we have to disable // the exposed forms cache. @@ -94,7 +93,7 @@ protected function getBasicPageView() { } function testFilterStringEqual() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the filtering @@ -139,7 +138,7 @@ function testFilterStringGroupedExposedEqual() { } function testFilterStringNotEqual() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the filtering @@ -203,7 +202,7 @@ function testFilterStringGroupedExposedNotEqual() { } function testFilterStringContains() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the filtering @@ -250,7 +249,7 @@ function testFilterStringGroupedExposedContains() { function testFilterStringWord() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the filtering @@ -277,7 +276,7 @@ function testFilterStringWord() { $this->assertIdenticalResultset($view, $resultset, $this->column_map); $view->destroy(); - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the filtering @@ -343,7 +342,7 @@ function testFilterStringGroupedExposedWord() { } function testFilterStringStarts() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the filtering @@ -387,7 +386,7 @@ function testFilterStringGroupedExposedStarts() { } function testFilterStringNotStarts() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the filtering @@ -445,7 +444,7 @@ function testFilterStringGroupedExposedNotStarts() { } function testFilterStringEnds() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the filtering @@ -495,7 +494,7 @@ function testFilterStringGroupedExposedEnds() { } function testFilterStringNotEnds() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the filtering @@ -547,7 +546,7 @@ function testFilterStringGroupedExposedNotEnds() { } function testFilterStringNot() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the filtering @@ -601,7 +600,7 @@ function testFilterStringGroupedExposedNot() { } function testFilterStringShorter() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the filtering @@ -650,7 +649,7 @@ function testFilterStringGroupedExposedShorter() { } function testFilterStringLonger() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the filtering @@ -694,7 +693,7 @@ function testFilterStringGroupedExposedLonger() { function testFilterStringEmpty() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the filtering diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerAliasTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerAliasTest.php index caec4c7..a120aad 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerAliasTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerAliasTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests abstract handlers of views. @@ -52,7 +51,7 @@ protected function viewsData() { } public function testPluginAliases() { - $view = Views::getView('test_filter'); + $view = views_get_view('test_filter'); $view->initDisplay(); // Change the filtering. @@ -79,7 +78,7 @@ public function testPluginAliases() { $this->assertIdentical($filter->realField, 'name'); // Test an existing user uid field. - $view = Views::getView('test_alias'); + $view = views_get_view('test_alias'); $view->initDisplay(); $this->executeView($view); diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerTest.php index fc5eeed..c719fce 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerTest.php @@ -194,7 +194,7 @@ function testBreakPhrase() { public function testHandlerWeights() { $handler_types = array('fields', 'filters', 'sorts'); - $view = Views::getView('test_view_handler_weight'); + $view = views_get_view('test_view_handler_weight'); $view->initDisplay(); // Store the order of handlers before saving the view. @@ -205,7 +205,7 @@ public function testHandlerWeights() { // Save the view and see if our filters are in the same order. $view->save(); - $view = views::getView('test_view_handler_weight'); + $view = views_get_view('test_view_handler_weight'); $view->initDisplay(); foreach ($handler_types as $type) { @@ -278,7 +278,7 @@ public function testRelationshipUI() { * Tests the relationship method on the base class. */ public function testSetRelationship() { - $view = Views::getView('test_handler_relationships'); + $view = views_get_view('test_handler_relationships'); $view->setDisplay(); // Setup a broken relationship. $view->addHandler('default', 'relationship', $this->randomName(), $this->randomName(), array(), 'broken_relationship'); @@ -317,7 +317,7 @@ public function testSetRelationship() { * @see \Drupal\views\Plugin\views\HandlerBase::placeholder() */ public function testPlaceholder() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->initHandlers(); $view->initQuery(); @@ -349,7 +349,7 @@ public function testPlaceholder() { * @see views_test_data_handler_test_access_callback */ public function testAccess() { - $view = Views::getView('test_handler_test_access'); + $view = views_get_view('test_handler_test_access'); $views_data = $this->viewsData(); $views_data = $views_data['views_test_data']; diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/RelationshipTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/RelationshipTest.php index 65621c9..a5c295c 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/RelationshipTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/RelationshipTest.php @@ -7,7 +7,6 @@ namespace Drupal\views\Tests\Handler; -use Drupal\views\Views; use Drupal\views\Tests\ViewUnitTestBase; use Drupal\views\Tests\Plugin\RelationshipJoinTestBase; @@ -51,7 +50,7 @@ public function testRelationshipQuery() { db_query("UPDATE {views_test_data} SET uid = 1 WHERE id = 1"); db_query("UPDATE {views_test_data} SET uid = 2 WHERE id <> 1"); - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); $view->displayHandlers->get('default')->overrideOption('relationships', array( diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/SortDateTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/SortDateTest.php index 1829773..813701e 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/SortDateTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/SortDateTest.php @@ -9,7 +9,6 @@ use Drupal\Component\Utility\String; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests for core Drupal\views\Plugin\views\sort\Date handler. @@ -159,7 +158,7 @@ protected function expectedResultSet($granularity, $reverse = TRUE) { public function testDateOrdering() { foreach (array('second', 'minute', 'hour', 'day', 'month', 'year') as $granularity) { foreach (array(FALSE, TRUE) as $reverse) { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the fields. diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/SortRandomTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/SortRandomTest.php index 2de7b49..c7745b5 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/SortRandomTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/SortRandomTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests for core Drupal\views\Plugin\views\sort\Random handler. @@ -51,7 +50,7 @@ protected function dataSet() { * Return a basic view with random ordering. */ protected function getBasicRandomView() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Add a random ordering. @@ -73,7 +72,7 @@ protected function getBasicRandomView() { */ public function testRandomOrdering() { // Execute a basic view first. - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $this->executeView($view); // Verify the result. diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/SortTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/SortTest.php index 8f33acc..b7012ae 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/SortTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/SortTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Handler; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests for core Drupal\views\Plugin\views\sort\SortPluginBase handler. @@ -34,7 +33,7 @@ public static function getInfo() { * Tests numeric ordering of the result set. */ public function testNumericOrdering() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the ordering @@ -87,7 +86,7 @@ public function testNumericOrdering() { * Tests string ordering of the result set. */ public function testStringOrdering() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Change the ordering diff --git a/core/modules/views/lib/Drupal/views/Tests/ModuleTest.php b/core/modules/views/lib/Drupal/views/Tests/ModuleTest.php index 79bce4b..8c31874 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ModuleTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/ModuleTest.php @@ -11,7 +11,6 @@ * Tests basic functions from the Views module. */ use Drupal\views\Plugin\views\filter\Standard; -use Drupal\views\Views; use Drupal\Component\Utility\String; class ModuleTest extends ViewUnitTestBase { @@ -164,46 +163,46 @@ public function testLoadFunctions() { // We can store this now, as we have enabled/disabled above. $all_views = $controller->loadMultiple(); - // Test Views::getAllViews(). - $this->assertIdentical(array_keys($all_views), array_keys(Views::getAllViews()), 'Views::getAllViews works as expected.'); + // Test views_get_all_views(). + $this->assertIdentical(array_keys($all_views), array_keys(views_get_all_views()), 'views_get_all_views works as expected.'); - // Test Views::getEnabledViews(). + // Test views_get_enabled_views(). $expected_enabled = array_filter($all_views, function($view) { return views_view_is_enabled($view); }); - $this->assertIdentical(array_keys($expected_enabled), array_keys(Views::getEnabledViews()), 'Expected enabled views returned.'); + $this->assertIdentical(array_keys($expected_enabled), array_keys(views_get_enabled_views()), 'Expected enabled views returned.'); - // Test Views::getDisabledViews(). + // Test views_get_disabled_views(). $expected_disabled = array_filter($all_views, function($view) { return views_view_is_disabled($view); }); - $this->assertIdentical(array_keys($expected_disabled), array_keys(Views::getDisabledViews()), 'Expected disabled views returned.'); + $this->assertIdentical(array_keys($expected_disabled), array_keys(views_get_disabled_views()), 'Expected disabled views returned.'); - // Test Views::getViewsAsOptions(). + // Test views_get_views_as_options(). // Test the $views_only parameter. - $this->assertIdentical(array_keys($all_views), array_keys(Views::getViewsAsOptions(TRUE)), 'Expected option keys for all views were returned.'); + $this->assertIdentical(array_keys($all_views), array_keys(views_get_views_as_options(TRUE)), 'Expected option keys for all views were returned.'); $expected_options = array(); foreach ($all_views as $id => $view) { $expected_options[$id] = $view->label(); } - $this->assertIdentical($expected_options, Views::getViewsAsOptions(TRUE), 'Expected options array was returned.'); + $this->assertIdentical($expected_options, views_get_views_as_options(TRUE), 'Expected options array was returned.'); // Test the default. - $this->assertIdentical($this->formatViewOptions($all_views), Views::getViewsAsOptions(), 'Expected options array for all views was returned.'); + $this->assertIdentical($this->formatViewOptions($all_views), views_get_views_as_options(), 'Expected options array for all views was returned.'); // Test enabled views. - $this->assertIdentical($this->formatViewOptions($expected_enabled), Views::getViewsAsOptions(FALSE, 'enabled'), 'Expected enabled options array was returned.'); + $this->assertIdentical($this->formatViewOptions($expected_enabled), views_get_views_as_options(FALSE, 'enabled'), 'Expected enabled options array was returned.'); // Test disabled views. - $this->assertIdentical($this->formatViewOptions($expected_disabled), Views::getViewsAsOptions(FALSE, 'disabled'), 'Expected disabled options array was returned.'); + $this->assertIdentical($this->formatViewOptions($expected_disabled), views_get_views_as_options(FALSE, 'disabled'), 'Expected disabled options array was returned.'); // Test the sort parameter. $all_views_sorted = $all_views; ksort($all_views_sorted); - $this->assertIdentical(array_keys($all_views_sorted), array_keys(Views::getViewsAsOptions(TRUE, 'all', NULL, FALSE, TRUE)), 'All view id keys returned in expected sort order'); + $this->assertIdentical(array_keys($all_views_sorted), array_keys(views_get_views_as_options(TRUE, 'all', NULL, FALSE, TRUE)), 'All view id keys returned in expected sort order'); // Test $exclude_view parameter. - $this->assertFalse(array_key_exists('archive', Views::getViewsAsOptions(TRUE, 'all', 'archive')), 'View excluded from options based on name'); - $this->assertFalse(array_key_exists('archive:default', Views::getViewsAsOptions(FALSE, 'all', 'archive:default')), 'View display excluded from options based on name'); - $this->assertFalse(array_key_exists('archive', Views::getViewsAsOptions(TRUE, 'all', $archive->getExecutable())), 'View excluded from options based on object'); + $this->assertFalse(array_key_exists('archive', views_get_views_as_options(TRUE, 'all', 'archive')), 'View excluded from options based on name'); + $this->assertFalse(array_key_exists('archive:default', views_get_views_as_options(FALSE, 'all', 'archive:default')), 'View display excluded from options based on name'); + $this->assertFalse(array_key_exists('archive', views_get_views_as_options(TRUE, 'all', $archive->getExecutable())), 'View excluded from options based on object'); // Test the $opt_group parameter. $expected_opt_groups = array(); @@ -212,14 +211,14 @@ public function testLoadFunctions() { $expected_opt_groups[$view->id()][$view->id() . ':' . $display['id']] = t('@view : @display', array('@view' => $view->id(), '@display' => $display['id'])); } } - $this->assertIdentical($expected_opt_groups, Views::getViewsAsOptions(FALSE, 'all', NULL, TRUE), 'Expected option array for an option group returned.'); + $this->assertIdentical($expected_opt_groups, views_get_views_as_options(FALSE, 'all', NULL, TRUE), 'Expected option array for an option group returned.'); } /** * Tests view enable and disable procedural wrapper functions. */ function testStatusFunctions() { - $view = Views::getView('test_view_status')->storage; + $view = views_get_view('test_view_status')->storage; $this->assertFalse($view->status(), 'The view status is disabled.'); @@ -233,11 +232,11 @@ function testStatusFunctions() { } /** - * Tests the \Drupal\views\Views::fetchPluginNames() method. + * Tests the views_fetch_plugin_names() function. */ public function testViewsFetchPluginNames() { // All style plugins should be returned, as we have not specified a type. - $plugins = Views::fetchPluginNames('style'); + $plugins = views_fetch_plugin_names('style'); $definitions = $this->container->get('plugin.manager.views.style')->getDefinitions(); $expected = array(); foreach ($definitions as $id =>$definition) { @@ -248,19 +247,19 @@ public function testViewsFetchPluginNames() { // Test using the 'test' style plugin type only returns the test_style and // mapping_test plugins. - $plugins = Views::fetchPluginNames('style', 'test'); + $plugins = views_fetch_plugin_names('style', 'test'); $this->assertIdentical(array_keys($plugins), array('mapping_test', 'test_style', 'test_template_style')); // Test a non existent style plugin type returns no plugins. - $plugins = Views::fetchPluginNames('style', $this->randomString()); + $plugins = views_fetch_plugin_names('style', $this->randomString()); $this->assertIdentical($plugins, array()); } /** - * Tests the \Drupal\views\Views::pluginList() method. + * Tests the views_plugin_list() function. */ public function testViewsPluginList() { - $plugin_list = Views::pluginList(); + $plugin_list = views_plugin_list(); // Only plugins used by 'test_view' should be in the plugin list. foreach (array('display:default', 'pager:none') as $key) { list($plugin_type, $plugin_id) = explode(':', $key); diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/AccessTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/AccessTest.php index eaff047..ca6c8ec 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/AccessTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/AccessTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Plugin; use Drupal\views\Tests\ViewTestData; -use Drupal\views\Views; /** * Basic test for pluggable access. @@ -63,7 +62,7 @@ protected function setUp() { * Tests none access plugin. */ function testAccessNone() { - $view = Views::getView('test_access_none'); + $view = views_get_view('test_access_none'); $view->setDisplay(); $this->assertTrue($view->display_handler->access($this->admin_user), 'Admin-Account should be able to access the view everytime'); @@ -81,7 +80,7 @@ function testAccessNone() { * @see \Drupal\views_test\Plugin\views\access\StaticTest */ function testStaticAccessPlugin() { - $view = Views::getView('test_access_static'); + $view = views_get_view('test_access_static'); $view->setDisplay(); $access_plugin = $view->display_handler->getPlugin('access'); diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/ArgumentDefaultTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/ArgumentDefaultTest.php index 6f50fa3..d849320 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/ArgumentDefaultTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/ArgumentDefaultTest.php @@ -7,7 +7,6 @@ namespace Drupal\views\Tests\Plugin; -use Drupal\views\Views; use Drupal\views_test_data\Plugin\views\argument_default\ArgumentDefaultTest as ArgumentDefaultTestPlugin; @@ -50,7 +49,7 @@ protected function setUp() { * @see \Drupal\views_test_data\Plugin\views\argument_default\ArgumentDefaultTest */ public function testArgumentDefaultPlugin() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); // Add a new argument and set the test plugin for the argument_default. $options = array( @@ -112,7 +111,7 @@ function testArgumentDefaultNoOptions() { */ function testArgumentDefaultFixed() { $random = $this->randomName(); - $view = Views::getView('test_argument_default_fixed'); + $view = views_get_view('test_argument_default_fixed'); $view->setDisplay(); $options = $view->display_handler->getOption('arguments'); $options['null']['default_argument_options']['argument'] = $random; diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/ArgumentValidatorTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/ArgumentValidatorTest.php index 2035cce..8544990 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/ArgumentValidatorTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/ArgumentValidatorTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Plugin; use Drupal\views\Tests\ViewUnitTestBase; -use Drupal\views\Views; /** * Tests Views argument validators. @@ -31,7 +30,7 @@ public static function getInfo() { } function testArgumentValidateNumeric() { - $view = Views::getView('test_view_argument_validate_numeric'); + $view = views_get_view('test_view_argument_validate_numeric'); $view->initHandlers(); $this->assertFalse($view->argument['null']->validateArgument($this->randomString())); // Reset safed argument validation. diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/CacheTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/CacheTest.php index ce67988..dca282f 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/CacheTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/CacheTest.php @@ -7,7 +7,6 @@ namespace Drupal\views\Tests\Plugin; -use Drupal\views\Views; use Drupal\views\ViewExecutable; /** @@ -45,7 +44,7 @@ protected function setUp() { */ public function testTimeCaching() { // Create a basic result which just 2 results. - $view = Views::getView('test_cache'); + $view = views_get_view('test_cache'); $view->setDisplay(); $view->display_handler->overrideOption('cache', array( 'type' => 'time', @@ -65,10 +64,10 @@ public function testTimeCaching() { 'age' => 29, 'job' => 'Banjo', ); - db_insert('views_test_data')->fields($record)->execute(); + drupal_write_record('views_test_data', $record); // The Result should be the same as before, because of the caching. - $view = Views::getView('test_cache'); + $view = views_get_view('test_cache'); $view->setDisplay(); $view->display_handler->overrideOption('cache', array( 'type' => 'time', @@ -90,7 +89,7 @@ public function testTimeCaching() { */ function testNoneCaching() { // Create a basic result which just 2 results. - $view = Views::getView('test_cache'); + $view = views_get_view('test_cache'); $view->setDisplay(); $view->display_handler->overrideOption('cache', array( 'type' => 'none', @@ -107,10 +106,11 @@ function testNoneCaching() { 'age' => 29, 'job' => 'Banjo', ); - db_insert('views_test_data')->fields($record)->execute(); + + drupal_write_record('views_test_data', $record); // The Result changes, because the view is not cached. - $view = Views::getView('test_cache'); + $view = views_get_view('test_cache'); $view->setDisplay(); $view->display_handler->overrideOption('cache', array( 'type' => 'none', @@ -129,7 +129,7 @@ function testHeaderStorage() { // Create a view with output caching enabled. // Some hook_views_pre_render in views_test_data.module adds the test css/js file. // so they should be added to the css/js storage. - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); $view->storage->set('id', 'test_cache_header_storage'); $view->display_handler->overrideOption('cache', array( diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayExtenderTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayExtenderTest.php index e646b0a..40114264 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayExtenderTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayExtenderTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Plugin; use Drupal\views\Tests\Plugin\PluginTestBase; -use Drupal\views\Views; /** * Tests the display extender plugins. @@ -43,9 +42,9 @@ protected function setUp() { */ public function testDisplayExtenders() { \Drupal::config('views.settings')->set('display_extenders', array('display_extender_test'))->save(); - $this->assertEqual(count(Views::getEnabledDisplayExtenders()), 1, 'Make sure that there is only one enabled display extender.'); + $this->assertEqual(count(views_get_enabled_display_extenders()), 1, 'Make sure that there is only one enabled display extender.'); - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->initDisplay(); $this->assertEqual(count($view->display_handler->extender), 1, 'Make sure that only one extender is initialized.'); diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayPageTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayPageTest.php index a7d4418..48ad3f2 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayPageTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayPageTest.php @@ -7,7 +7,6 @@ namespace Drupal\views\Tests\Plugin; -use Drupal\views\Views; use Drupal\views\Tests\ViewUnitTestBase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\HttpKernelInterface; @@ -79,7 +78,7 @@ public function testPageResponses() { \Drupal::getContainer()->set('request', $subrequest); // Test accessing a disabled page for a view. - $view = Views::getView('test_page_display'); + $view = views_get_view('test_page_display'); // Disable the view, rebuild menu, and request the page again. $view->storage->disable()->save(); // Router rebuild would occur in a kernel terminate event so we need to diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayTest.php index 5a284d8..61d2611 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayTest.php @@ -57,7 +57,7 @@ public function setUp() { * @see \Drupal\views_test_data\Plugin\views\display\DisplayTest */ public function testDisplayPlugin() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); // Add a new 'display_test' display and test it's there. $view->storage->addDisplay('display_test'); @@ -146,7 +146,7 @@ public function testDisplayPlugin() { * Tests the overriding of filter_groups. */ public function testFilterGroupsOverriding() { - $view = Views::getView('test_filter_groups'); + $view = views_get_view('test_filter_groups'); $view->initDisplay(); // mark is as overridden, yes FALSE, means overridden. @@ -159,7 +159,7 @@ public function testFilterGroupsOverriding() { * Tests the getAttachedDisplays method. */ public function testGetAttachedDisplays() { - $view = Views::getView('test_get_attach_displays'); + $view = views_get_view('test_get_attach_displays'); // Both the feed_1 and the feed_2 display are attached to the page display. $view->setDisplay('page_1'); @@ -175,7 +175,7 @@ public function testGetAttachedDisplays() { public function testReadMore() { $expected_more_text = 'custom more text'; - $view = Views::getView('test_display_more'); + $view = views_get_view('test_display_more'); $this->executeView($view); $output = $view->preview(); @@ -200,7 +200,7 @@ public function testReadMore() { $more_text = $view->display_handler->useMoreText(); $this->assertEqual($more_text, $expected_more_text, 'The right more text is chosen.'); - $view = Views::getView('test_display_more'); + $view = views_get_view('test_display_more'); $view->setDisplay(); $view->display_handler->setOption('use_more', 0); $this->executeView($view); @@ -210,7 +210,7 @@ public function testReadMore() { $result = $this->xpath('//div[@class=:class]/a', array(':class' => 'more-link')); $this->assertTrue(empty($result), 'The more link is not shown.'); - $view = Views::getView('test_display_more'); + $view = views_get_view('test_display_more'); $view->setDisplay(); $view->display_handler->setOption('use_more', 0); $view->display_handler->setOption('use_more_always', 0); diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayUnitTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayUnitTest.php index 0a36d53..aa7306c 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayUnitTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayUnitTest.php @@ -6,7 +6,6 @@ namespace Drupal\views\Tests\Plugin; -use Drupal\views\Views; use Drupal\views\Tests\ViewUnitTestBase; use Drupal\views\Plugin\views\style\StylePluginBase; use Drupal\views\Plugin\views\access\AccessPluginBase; @@ -73,12 +72,12 @@ public static function getInfo() { */ public function testDefaultOptions() { // Save the view. - $view = Views::getView('test_display_defaults'); + $view = views_get_view('test_display_defaults'); $view->mergeDefaults(); $view->save(); // Reload to get saved storage values. - $view = Views::getView('test_display_defaults'); + $view = views_get_view('test_display_defaults'); $view->initDisplay(); $display_data = $view->storage->get('display'); @@ -100,7 +99,7 @@ public function testDefaultOptions() { * Tests the \Drupal\views\Plugin\views\display\DisplayPluginBase::getPlugin() method. */ public function testGetPlugin() { - $view = Views::getView('test_display_defaults'); + $view = views_get_view('test_display_defaults'); $view->initDisplay(); $display_handler = $view->display_handler; diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/ExposedFormTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/ExposedFormTest.php index 3a41e77..4f70653 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/ExposedFormTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/ExposedFormTest.php @@ -127,7 +127,7 @@ public function testResetButton() { * Tests the exposed form markup. */ public function testExposedFormRender() { - $view = Views::getView('test_exposed_form_buttons'); + $view = views_get_view('test_exposed_form_buttons'); $this->executeView($view); $exposed_form = $view->display_handler->getPlugin('exposed_form'); $output = $exposed_form->renderExposedForm(); diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/FilterTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/FilterTest.php index 77ad92e..3f0f8a2 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/FilterTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/FilterTest.php @@ -7,7 +7,6 @@ namespace Drupal\views\Tests\Plugin; -use Drupal\views\Views; use Drupal\views_test_data\Plugin\views\filter\FilterTest as FilterPlugin; /** @@ -63,7 +62,7 @@ public function testFilterQuery() { $plugin = $this->container->get('plugin.manager.views.filter')->createInstance('test_filter'); $this->assertTrue($plugin instanceof FilterPlugin, 'Test filter plugin found.'); - $view = Views::getView('test_filter'); + $view = views_get_view('test_filter'); $view->initDisplay(); // Change the filtering. diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/JoinTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/JoinTest.php index dfb470e..793e062 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/JoinTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/JoinTest.php @@ -9,7 +9,6 @@ use Drupal\views_test_data\Plugin\views\join\JoinTest as JoinTestPlugin; use Drupal\views\Plugin\views\join\JoinPluginBase; -use Drupal\views\Views; /** @@ -55,7 +54,7 @@ protected function setUp() { public function testExamplePlugin() { // Setup a simple join and test the result sql. - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->initDisplay(); $view->initQuery(); @@ -86,7 +85,7 @@ public function testExamplePlugin() { public function testBasePlugin() { // Setup a simple join and test the result sql. - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->initDisplay(); $view->initQuery(); diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/MiniPagerTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/MiniPagerTest.php index e5f684a..62961d6 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/MiniPagerTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/MiniPagerTest.php @@ -7,8 +7,6 @@ namespace Drupal\views\Tests\Plugin; -use Drupal\views\Views; - /** * Tests the mini pager plugin * @@ -117,7 +115,7 @@ public function testMiniPagerRender() { $this->assertNoText('‹‹ test', 'The previous link does not appear on the page.'); $this->assertText($this->nodes[19]->label()); - $view = Views::getView('test_mini_pager'); + $view = views_get_view('test_mini_pager'); $this->executeView($view); $this->assertIdentical($view->get_total_rows, NULL, 'The query was not forced to calculate the total number of results.'); $this->assertIdentical($view->total_rows, 1, 'The pager calculated the total number of rows.'); diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/PagerTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/PagerTest.php index 9ba46d8..9b4a20c 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/PagerTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/PagerTest.php @@ -7,8 +7,6 @@ namespace Drupal\views\Tests\Plugin; -use Drupal\views\Views; - /** * Tests the pluggable pager system. */ @@ -67,7 +65,7 @@ public function testStorePagerSettings() { $this->assertText('Mini', 'Changed pager plugin, should change some text'); // Test behavior described in http://drupal.org/node/652712#comment-2354400 - $view = Views::getView('test_store_pager_settings'); + $view = views_get_view('test_store_pager_settings'); // Make it editable in the admin interface. $view->save(); @@ -120,12 +118,12 @@ public function testNoLimit() { for ($i = 0; $i < 11; $i++) { $this->drupalCreateNode(); } - $view = Views::getView('test_pager_none'); + $view = views_get_view('test_pager_none'); $this->executeView($view); $this->assertEqual(count($view->result), 11, 'Make sure that every item is returned in the result'); // Setup and test a offset. - $view = Views::getView('test_pager_none'); + $view = views_get_view('test_pager_none'); $view->setDisplay(); $pager = array( 'type' => 'none', @@ -149,7 +147,7 @@ public function testViewTotalRowsWithoutPager() { $this->drupalCreateNode(); } - $view = Views::getView('test_pager_none'); + $view = views_get_view('test_pager_none'); $view->get_total_rows = TRUE; $this->executeView($view); @@ -166,12 +164,12 @@ public function testLimit() { $this->drupalCreateNode(); } - $view = Views::getView('test_pager_some'); + $view = views_get_view('test_pager_some'); $this->executeView($view); $this->assertEqual(count($view->result), 5, 'Make sure that only a certain count of items is returned'); // Setup and test a offset. - $view = Views::getView('test_pager_some'); + $view = views_get_view('test_pager_some'); $view->setDisplay(); $pager = array( 'type' => 'none', @@ -199,12 +197,12 @@ public function testNormalPager() { $this->drupalCreateNode(); } - $view = Views::getView('test_pager_full'); + $view = views_get_view('test_pager_full'); $this->executeView($view); $this->assertEqual(count($view->result), 5, 'Make sure that only a certain count of items is returned'); // Setup and test a offset. - $view = Views::getView('test_pager_full'); + $view = views_get_view('test_pager_full'); $view->setDisplay(); $pager = array( 'type' => 'full', @@ -218,7 +216,7 @@ public function testNormalPager() { $this->assertEqual(count($view->result), 3, 'Make sure that only a certain count of items is returned'); // Test items per page = 0 - $view = Views::getView('test_view_pager_full_zero_items_per_page'); + $view = views_get_view('test_view_pager_full_zero_items_per_page'); $this->executeView($view); $this->assertEqual(count($view->result), 11, 'All items are return'); @@ -227,7 +225,7 @@ public function testNormalPager() { // Test items per page = 0. // Setup and test a offset. - $view = Views::getView('test_pager_full'); + $view = views_get_view('test_pager_full'); $view->setDisplay(); $pager = array( 'type' => 'full', @@ -252,7 +250,7 @@ public function testRenderNullPager() { for ($i = 0; $i < 11; $i++) { $this->drupalCreateNode(); } - $view = Views::getView('test_pager_full'); + $view = views_get_view('test_pager_full'); $this->executeView($view); // Force the value again here. $view->setAjaxEnabled(TRUE); @@ -266,7 +264,7 @@ public function testRenderNullPager() { * Test the api functions on the view object. */ function testPagerApi() { - $view = Views::getView('test_pager_full'); + $view = views_get_view('test_pager_full'); $view->setDisplay(); // On the first round don't initialize the pager. diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/QueryTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/QueryTest.php index ac3513b..7da2672 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/QueryTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/QueryTest.php @@ -7,7 +7,6 @@ namespace Drupal\views\Tests\Plugin; -use Drupal\views\Views; use Drupal\views\Tests\ViewUnitTestBase; use Drupal\views_test_data\Plugin\views\query\QueryTest as QueryTestPlugin; @@ -51,7 +50,7 @@ public function testQuery() { * Tests the ViewExecutable::initQuery method. */ public function _testInitQuery() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); $view->initQuery(); @@ -59,7 +58,7 @@ public function _testInitQuery() { } public function _testQueryExecute() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); $view->initQuery(); @@ -75,7 +74,7 @@ public function _testQueryExecute() { * @see \Drupal\views\Plugin\views\query\QueryPluginBase */ protected function queryMethodsTests() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); $view->initQuery(); diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/RowEntityTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/RowEntityTest.php index 177fdea..5efa290 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/RowEntityTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/RowEntityTest.php @@ -7,7 +7,6 @@ namespace Drupal\views\Tests\Plugin; -use Drupal\views\Views; use Drupal\views\Tests\ViewUnitTestBase; /** @@ -66,7 +65,7 @@ public function testEntityRow() { $term = entity_create('taxonomy_term', array('name' => $this->randomName(), 'vid' => $vocab->id() )); $term->save(); - $view = Views::getView('test_entity_row'); + $view = views_get_view('test_entity_row'); $this->content = $view->preview(); $this->content = drupal_render($this->content); diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleGridTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleGridTest.php index e9132b1..cd913da 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleGridTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleGridTest.php @@ -7,7 +7,6 @@ namespace Drupal\views\Tests\Plugin; -use Drupal\views\Views; use Drupal\views\ViewExecutable; use Symfony\Component\HttpFoundation\Request; @@ -53,7 +52,7 @@ protected function setUp() { * Tests the grid style. */ public function testGrid() { - $view = Views::getView('test_grid'); + $view = views_get_view('test_grid'); foreach (array('horizontal', 'vertical') as $alignment) { $this->assertGrid($view, $alignment, 5); $this->assertGrid($view, $alignment, 4); diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleMappingTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleMappingTest.php index eb3fdea..7020458 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleMappingTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleMappingTest.php @@ -7,8 +7,6 @@ namespace Drupal\views\Tests\Plugin; -use Drupal\views\Views; - /** * Tests the default/mapping row style. */ @@ -35,7 +33,7 @@ public static function getInfo() { * Verifies that the fields were mapped correctly. */ public function testMappedOutput() { - $view = Views::getView('test_style_mapping'); + $view = views_get_view('test_style_mapping'); $output = $this->mappedOutputHelper($view); $this->assertTrue(strpos($output, 'job') === FALSE, 'The job field is added to the view but not in the mapping.'); $view->destroy(); diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleTableUnitTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleTableUnitTest.php index c7d0345..f5548f7 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleTableUnitTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleTableUnitTest.php @@ -7,7 +7,6 @@ namespace Drupal\views\Tests\Plugin; -use Drupal\views\Views; use Drupal\views\ViewExecutable; use Symfony\Component\HttpFoundation\Request; @@ -37,7 +36,7 @@ public static function getInfo() { * Tests the table style. */ public function testTable() { - $view = Views::getView('test_table'); + $view = views_get_view('test_table'); $view->setDisplay('default'); $view->initStyle(); diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleTest.php index b20afb6..57427ca 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleTest.php @@ -7,7 +7,6 @@ namespace Drupal\views\Tests\Plugin; -use Drupal\views\Views; use Drupal\views\Tests\ViewTestBase; use Drupal\views_test_data\Plugin\views\row\RowTest; use Drupal\views\Plugin\views\row\Fields; @@ -54,7 +53,7 @@ protected function setUp() { */ public function testStyle() { // This run use the test row plugin and render with it. - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); $style = $view->display_handler->getOption('style'); $style['type'] = 'test_style'; @@ -76,7 +75,7 @@ public function testStyle() { $this->assertTrue(strpos($output, $random_text) !== FALSE, 'Make sure that the rendering of the row plugin appears in the output of the view.'); // Test without row plugin support. - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); $style = $view->display_handler->getOption('style'); $style['type'] = 'test_style'; @@ -105,7 +104,7 @@ function testGrouping() { * Tests the grouping features of styles. */ function _testGrouping($stripped = FALSE) { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Setup grouping by the job and the age field. $view->initStyle(); @@ -224,7 +223,7 @@ function _testGrouping($stripped = FALSE) { * Tests custom css classes. */ function testCustomRowClasses() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Setup some random css class. diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleUnformattedTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleUnformattedTest.php index b8a6735..cc1785c 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleUnformattedTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleUnformattedTest.php @@ -7,8 +7,6 @@ namespace Drupal\views\Tests\Plugin; -use Drupal\views\Views; - /** * Tests the default/unformatted row style. */ @@ -33,7 +31,7 @@ public static function getInfo() { * Make sure that the default css classes works as expected. */ function testDefaultRowClasses() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); $output = $view->preview(); $this->storeViewPreview(drupal_render($output)); diff --git a/core/modules/views/lib/Drupal/views/Tests/PluginInstanceTest.php b/core/modules/views/lib/Drupal/views/Tests/PluginInstanceTest.php index e70bd1d..de571a2 100644 --- a/core/modules/views/lib/Drupal/views/Tests/PluginInstanceTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/PluginInstanceTest.php @@ -7,8 +7,6 @@ namespace Drupal\views\Tests; -use Drupal\views\Views; - /** * Checks general plugin data and instances for all plugin types. */ @@ -59,7 +57,7 @@ public static function getInfo() { protected function setUp() { parent::setUp(); - $this->definitions = Views::getPluginDefinitions(); + $this->definitions = views_get_plugin_definitions(); } /** diff --git a/core/modules/views/lib/Drupal/views/Tests/QueryGroupByTest.php b/core/modules/views/lib/Drupal/views/Tests/QueryGroupByTest.php index b35f020..4ce4bac 100644 --- a/core/modules/views/lib/Drupal/views/Tests/QueryGroupByTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/QueryGroupByTest.php @@ -7,8 +7,6 @@ namespace Drupal\views\Tests; -use Drupal\views\Views; - /** * Tests aggregate functionality of views, for example count. */ @@ -61,7 +59,7 @@ protected function setUp() { public function testAggregateCount() { $this->setupTestEntities(); - $view = Views::getView('test_aggregate_count'); + $view = views_get_view('test_aggregate_count'); $this->executeView($view); $this->assertEqual(count($view->result), 2, 'Make sure the count of items is right.'); @@ -87,7 +85,7 @@ public function testAggregateCount() { public function groupByTestHelper($aggregation_function, $values) { $this->setupTestEntities(); - $view = Views::getView('test_group_by_count'); + $view = views_get_view('test_group_by_count'); $view->setDisplay(); $view->displayHandlers->get('default')->options['fields']['id']['group_type'] = $aggregation_function; $this->executeView($view); @@ -170,7 +168,7 @@ public function testGroupByCountOnlyFilters() { $this->storageController->create(array('name' => 'name1'))->save(); } - $view = Views::getView('test_group_by_in_filters'); + $view = views_get_view('test_group_by_in_filters'); $this->executeView($view); $this->assertTrue(strpos($view->build_info['query'], 'GROUP BY'), 'Make sure that GROUP BY is in the query'); diff --git a/core/modules/views/lib/Drupal/views/Tests/TokenReplaceTest.php b/core/modules/views/lib/Drupal/views/Tests/TokenReplaceTest.php index 4b58fe0..6bea043 100644 --- a/core/modules/views/lib/Drupal/views/Tests/TokenReplaceTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/TokenReplaceTest.php @@ -7,8 +7,6 @@ namespace Drupal\views\Tests; -use Drupal\views\Views; - /** * Tests core view token replacement. */ @@ -41,7 +39,7 @@ function setUp() { */ function testTokenReplacement() { $token_handler = \Drupal::token(); - $view = Views::getView('test_tokens'); + $view = views_get_view('test_tokens'); $view->setDisplay('page_1'); $this->executeView($view); diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewElementTest.php b/core/modules/views/lib/Drupal/views/Tests/ViewElementTest.php index c7ca56d..5a13f9e 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewElementTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewElementTest.php @@ -7,8 +7,6 @@ namespace Drupal\views\Tests; -use Drupal\views\Views; - /** * Tests the 'view' element type. */ @@ -57,7 +55,7 @@ protected function setUp() { * Tests the rendered output and form output of a view element. */ public function testViewElement() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); // Set the content as our rendered array. diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php b/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php index 0d7f19e..fadc421 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php @@ -108,7 +108,7 @@ public function testFactoryService() { * Tests the initDisplay() and initHandlers() methods. */ public function testInitMethods() { - $view = Views::getView('test_destroy'); + $view = views_get_view('test_destroy'); $view->initDisplay(); $this->assertTrue($view->display_handler instanceof DefaultDisplay, 'Make sure a reference to the current display handler is set.'); @@ -176,14 +176,14 @@ public function testInitMethods() { * Tests the generation of the executable object. */ public function testConstructing() { - Views::getView('test_destroy'); + views_get_view('test_destroy'); } /** * Tests the accessing of values on the object. */ public function testProperties() { - $view = Views::getView('test_destroy'); + $view = views_get_view('test_destroy'); foreach ($this->executableProperties as $property) { $this->assertTrue(isset($view->{$property})); } @@ -193,7 +193,7 @@ public function testProperties() { * Tests the display related methods and properties. */ public function testDisplays() { - $view = Views::getView('test_executable_displays'); + $view = views_get_view('test_executable_displays'); // Tests Drupal\views\ViewExecutable::initDisplay(). $view->initDisplay(); @@ -271,7 +271,7 @@ public function testDisplays() { * Tests the setting/getting of properties. */ public function testPropertyMethods() { - $view = Views::getView('test_executable_displays'); + $view = views_get_view('test_executable_displays'); // Test the setAjaxEnabled() method. $this->assertFalse($view->ajaxEnabled()); @@ -345,7 +345,7 @@ public function testPropertyMethods() { * Tests the deconstructor to be sure that necessary objects are removed. */ public function testDestroy() { - $view = Views::getView('test_destroy'); + $view = views_get_view('test_destroy'); $view->preview(); $view->destroy(); @@ -410,7 +410,7 @@ public function testViewsHandlerTypes() { * Tests the validation of display handlers. */ public function testValidate() { - $view = Views::getView('test_executable_displays'); + $view = views_get_view('test_executable_displays'); $view->setDisplay('page_1'); $validate = $view->validate(); diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewRenderTest.php b/core/modules/views/lib/Drupal/views/Tests/ViewRenderTest.php index aee849b..02ab62d 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewRenderTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewRenderTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests; use Drupal\views\Tests\ViewTestBase; -use Drupal\views\Views; class ViewRenderTest extends ViewTestBase { @@ -41,7 +40,7 @@ public function testRender() { \Drupal::state()->set('views_render.test', 0); // Make sure that the rendering just calls the preprocess function once. - $view = Views::getView('test_view_render'); + $view = views_get_view('test_view_render'); $output = $view->preview(); drupal_render($output); diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewStorageTest.php b/core/modules/views/lib/Drupal/views/Tests/ViewStorageTest.php index d0cea34..ba67b0a 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewStorageTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewStorageTest.php @@ -13,7 +13,6 @@ use Drupal\views\Plugin\views\display\Page; use Drupal\views\Plugin\views\display\DefaultDisplay; use Drupal\views\Plugin\views\display\Feed; -use Drupal\views\Views; /** * Tests the functionality of View and ViewStorageController. @@ -124,7 +123,7 @@ protected function loadTests() { } // Make sure that loaded default views get a UUID. - $view = Views::getView('test_view_storage'); + $view = views_get_view('test_view_storage'); $this->assertTrue($view->storage->uuid()); } @@ -313,7 +312,7 @@ protected function displayMethodTests() { * Tests the createDuplicate() View method. */ public function testCreateDuplicate() { - $view = Views::getView('test_view_storage'); + $view = views_get_view('test_view_storage'); $copy = $view->storage->createDuplicate(); $this->assertTrue($copy instanceof View, 'The copied object is a View.'); diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewsHooksTest.php b/core/modules/views/lib/Drupal/views/Tests/ViewsHooksTest.php index 2a90d11..ad98fa6 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewsHooksTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewsHooksTest.php @@ -7,8 +7,6 @@ namespace Drupal\views\Tests; -use Drupal\views\Views; - /** * Tests that views hooks are registered when defined in $module.views.inc. * @@ -71,7 +69,7 @@ protected function setUp() { * Tests the hooks. */ public function testHooks() { - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); // Test each hook is found in the implementations array and is invoked. foreach (static::$hooks as $hook => $type) { diff --git a/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php b/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php index be30330..987e9a8 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Wizard/BasicTest.php @@ -8,7 +8,6 @@ namespace Drupal\views\Tests\Wizard; use Drupal\Component\Utility\String; -use Drupal\views\Views; /** * Tests creating views with the wizard and viewing them on the listing page. @@ -171,7 +170,7 @@ public function testWizardDefaultValues() { // Make sure the plugin types that should not have empty options don't have. // Test against all values is unit tested. // @see \Drupal\views\Tests\Plugin\DisplayUnitTest - $view = Views::getView($random_id); + $view = views_get_view($random_id); $displays = $view->storage->get('display'); foreach ($displays as $display) { diff --git a/core/modules/views/lib/Drupal/views/ViewExecutable.php b/core/modules/views/lib/Drupal/views/ViewExecutable.php index 3761ed8..17131c4 100644 --- a/core/modules/views/lib/Drupal/views/ViewExecutable.php +++ b/core/modules/views/lib/Drupal/views/ViewExecutable.php @@ -445,7 +445,7 @@ public function __construct(ViewStorageInterface $storage, AccountInterface $use $this->user = $user; // Add the default css for a view. - $this->element['#attached']['library'][] = 'views/views.module'; + $this->element['#attached']['library'][] = array('views', 'views.module'); } /** @@ -1361,7 +1361,7 @@ public function render($display_id = NULL) { // 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->getName(), 'views_pre_render', array($this)); + $module_handler->invoke($base->name, 'views_pre_render', array($this)); } $module_handler->invoke($GLOBALS['theme'], 'views_pre_render', array($this)); @@ -1385,7 +1385,7 @@ public function render($display_id = NULL) { // 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->getName(), 'views_post_render', array($this)); + $module_handler->invoke($base->name, 'views_post_render', array($this)); } $module_handler->invoke($GLOBALS['theme'], 'views_post_render', array($this)); diff --git a/core/modules/views/tests/Drupal/views/Tests/Controller/ViewAjaxControllerTest.php b/core/modules/views/tests/Drupal/views/Tests/Controller/ViewAjaxControllerTest.php index da1245b..8cc5d10 100644 --- a/core/modules/views/tests/Drupal/views/Tests/Controller/ViewAjaxControllerTest.php +++ b/core/modules/views/tests/Drupal/views/Tests/Controller/ViewAjaxControllerTest.php @@ -58,7 +58,7 @@ protected function setUp() { ->disableOriginalConstructor() ->getMock(); - $this->viewAjaxController = new TestViewAjaxController($this->viewStorage, $this->executableFactory); + $this->viewAjaxController = new ViewAjaxController($this->viewStorage, $this->executableFactory); } /** @@ -280,18 +280,6 @@ protected function assertViewResultCommand(ViewAjaxResponse $response, $position } -/** - * Overrides ViewAjaxController::drupalRender to protect the parent method. - */ -class TestViewAjaxController extends ViewAjaxController { - - // @todo Remove once drupal_render is converted to autoloadable code. - protected function drupalRender(array $elements) { - return isset($elements['#markup']) ? $elements['#markup'] : ''; - } - -} - } namespace { @@ -302,4 +290,11 @@ function &drupal_static($key) { } } + // @todo Remove once drupal_render is converted to autoloadable code. + if (!function_exists('drupal_render')) { + function drupal_render($array) { + return isset($array['#markup']) ? $array['#markup'] : ''; + } + } + } diff --git a/core/modules/views/tests/Drupal/views/Tests/Plugin/display/PathPluginBaseTest.php b/core/modules/views/tests/Drupal/views/Tests/Plugin/display/PathPluginBaseTest.php index 245bb9e..96ab152 100644 --- a/core/modules/views/tests/Drupal/views/Tests/Plugin/display/PathPluginBaseTest.php +++ b/core/modules/views/tests/Drupal/views/Tests/Plugin/display/PathPluginBaseTest.php @@ -5,7 +5,7 @@ * Contains \Drupal\views\Tests\Plugin\display\PathPluginBaseTest. */ -namespace Drupal\views\Tests\Plugin\display; +namespace Drupal\views\Tests\Plugin\display { use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Tests\UnitTestCase; @@ -281,3 +281,13 @@ protected function setupViewExecutableAccessPlugin() { } } + +} + +namespace { + if (!function_exists('views_get_enabled_display_extenders')) { + function views_get_enabled_display_extenders() { + return array(); + } + } +} diff --git a/core/modules/views/views.api.php b/core/modules/views/views.api.php index f2d2a1e..faacf8a 100644 --- a/core/modules/views/views.api.php +++ b/core/modules/views/views.api.php @@ -576,9 +576,9 @@ function hook_views_query_alter(ViewExecutable $view, QueryPluginBase $query) { * * @param array $rows * An associative array with two keys: - * - query: An array of rows suitable for '#type' => 'table', containing + * - query: An array of rows suitable for '#theme' => 'table', containing * information about the query and the display title and path. - * - statistics: An array of rows suitable for '#type' => 'table', + * - statistics: An array of rows suitable for '#theme' => 'table', * containing performance statistics. * @param \Drupal\views\ViewExecutable $view * The view object. diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 922a8d9..944c0c9 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -9,7 +9,6 @@ * incoming page and block requests. */ -use Drupal\Component\Utility\String; use Drupal\Core\Cache\Cache; use Drupal\Core\Database\Query\AlterableInterface; use Drupal\Core\Language\Language; @@ -58,43 +57,12 @@ function views_element_info() { } /** - * Implements hook_views_pre_render(). - */ -function views_views_pre_render($view) { - // If using AJAX, send identifying data about this view. - if ($view->ajaxEnabled() && empty($view->is_attachment) && empty($view->live_preview)) { - $settings = array( - 'views' => array( - 'ajax_path' => url('views/ajax'), - 'ajaxViews' => array( - 'views_dom_id:' . $view->dom_id => array( - 'view_name' => $view->storage->id(), - 'view_display_id' => $view->current_display, - 'view_args' => String::checkPlain(implode('/', $view->args)), - 'view_path' => String::checkPlain(current_path()), - 'view_base_path' => $view->getPath(), - 'view_dom_id' => $view->dom_id, - // To fit multiple views on a page, the programmer may have - // overridden the display's pager_element. - 'pager_element' => isset($view->pager) ? $view->pager->getPagerId() : 0, - ), - ), - ), - ); - $view->element['#attached']['js'][] = array('type' => 'setting', 'data' => $settings); - $view->element['#attached']['library'][] = 'views/views.ajax'; - } - - return $view; -} - -/** * View element pre render callback. */ function views_pre_render_view_element($element) { $element['#attributes']['class'][] = 'views-element-container'; - $view = Views::getView($element['#name']); + $view = views_get_view($element['#name']); if ($view && $view->access($element['#display_id'])) { $element['view'] = $view->preview($element['#display_id'], $element['#arguments']); } @@ -145,7 +113,7 @@ function views_theme($existing, $type, $theme, $path) { 'template' => 'views-view-grouping', ); - $plugins = Views::getPluginDefinitions(); + $plugins = views_get_plugin_definitions(); $module_handler = \Drupal::moduleHandler(); // Register theme functions for all style plugins. It provides a basic auto @@ -364,8 +332,7 @@ function views_preprocess_page(&$variables) { unset($class[$key]); $attributes['class'] = $class; $attributes['data-views-page-contextual-id'] = $variables['title_suffix']['contextual_links']['#id']; - $attached['#attached']['library'][] = 'views/views.contextual-links'; - drupal_render($attached); + drupal_add_library('views', 'views.contextual-links'); } } } @@ -999,7 +966,7 @@ function views_embed_view($name, $display_id = 'default') { // Remove $name and $display_id from the arguments. unset($args[0], $args[1]); - $view = Views::getView($name); + $view = views_get_view($name); if (!$view || !$view->access($display_id)) { return; } @@ -1029,7 +996,7 @@ function views_get_view_result($name, $display_id = NULL) { // Remove $name and $display_id from the arguments. unset($args[0], $args[1]); - $view = Views::getView($name); + $view = views_get_view($name); if (is_object($view)) { if (is_array($args)) { $view->setArguments($args); diff --git a/core/modules/views/views.services.yml b/core/modules/views/views.services.yml index f42a7bd..30aa96a 100644 --- a/core/modules/views/views.services.yml +++ b/core/modules/views/views.services.yml @@ -4,10 +4,10 @@ services: arguments: [access, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler'] plugin.manager.views.area: class: Drupal\views\Plugin\ViewsHandlerManager - arguments: [area, '@container.namespaces', '@views.views_data', '@cache.views_info', '@language_manager', '@module_handler'] + arguments: [area, '@container.namespaces', '@views.views_data'] plugin.manager.views.argument: class: Drupal\views\Plugin\ViewsHandlerManager - arguments: [argument, '@container.namespaces', '@views.views_data', '@cache.views_info', '@language_manager', '@module_handler'] + arguments: [argument, '@container.namespaces', '@views.views_data'] plugin.manager.views.argument_default: class: Drupal\views\Plugin\ViewsPluginManager arguments: [argument_default, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler'] @@ -28,13 +28,13 @@ services: arguments: [exposed_form, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler'] plugin.manager.views.field: class: Drupal\views\Plugin\ViewsHandlerManager - arguments: [field, '@container.namespaces', '@views.views_data', '@cache.views_info', '@language_manager', '@module_handler'] + arguments: [field, '@container.namespaces', '@views.views_data'] plugin.manager.views.filter: class: Drupal\views\Plugin\ViewsHandlerManager - arguments: [filter, '@container.namespaces', '@views.views_data', '@cache.views_info', '@language_manager', '@module_handler'] + arguments: [filter, '@container.namespaces', '@views.views_data'] plugin.manager.views.join: class: Drupal\views\Plugin\ViewsHandlerManager - arguments: [join, '@container.namespaces', '@views.views_data', '@cache.views_info', '@language_manager', '@module_handler'] + arguments: [join, '@container.namespaces', '@views.views_data'] plugin.manager.views.pager: class: Drupal\views\Plugin\ViewsPluginManager arguments: [pager, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler'] @@ -43,13 +43,13 @@ services: arguments: [query, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler'] plugin.manager.views.relationship: class: Drupal\views\Plugin\ViewsHandlerManager - arguments: [relationship, '@container.namespaces', '@views.views_data', '@cache.views_info', '@language_manager', '@module_handler'] + arguments: [relationship, '@container.namespaces', '@views.views_data'] plugin.manager.views.row: class: Drupal\views\Plugin\ViewsPluginManager arguments: [row, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler'] plugin.manager.views.sort: class: Drupal\views\Plugin\ViewsHandlerManager - arguments: [sort, '@container.namespaces', '@views.views_data', '@cache.views_info', '@language_manager', '@module_handler'] + arguments: [sort, '@container.namespaces', '@views.views_data'] plugin.manager.views.style: class: Drupal\views\Plugin\ViewsPluginManager arguments: [style, '@container.namespaces', '@cache.views_info', '@language_manager', '@module_handler'] diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index eaf3d86..8cb4cd2 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -106,6 +106,30 @@ function template_preprocess_views_view(&$variables) { $variables['attributes']['class'][] = 'view-dom-id-' . $variables['dom_id']; } + // If using AJAX, send identifying data about this view. + if ($view->ajaxEnabled() && empty($view->is_attachment) && empty($view->live_preview)) { + $settings = array( + 'views' => array( + 'ajax_path' => url('views/ajax'), + 'ajaxViews' => array( + 'views_dom_id:' . $variables['dom_id'] => array( + 'view_name' => $view->storage->id(), + 'view_display_id' => $view->current_display, + 'view_args' => String::checkPlain(implode('/', $view->args)), + 'view_path' => String::checkPlain(current_path()), + 'view_base_path' => $view->getPath(), + 'view_dom_id' => $variables['dom_id'], + // To fit multiple views on a page, the programmer may have + // overridden the display's pager_element. + 'pager_element' => isset($view->pager) ? $view->pager->getPagerId() : 0, + ), + ), + ), + ); + $view->element['#attached']['js'][] = array('type' => 'setting', 'data' => $settings); + $view->element['#attached']['library'][] = array('views', 'views.ajax'); + } + // If form fields were found in the view, reformat the view output as a form. if ($view->hasFormElements()) { // Copy the rows so as not to modify them by reference when rendering. @@ -708,7 +732,7 @@ function template_preprocess_views_view_table(&$variables) { } if (!empty($options['sticky'])) { - $variables['view']->element['#attached']['library'][] = 'core/drupal.tableheader'; + $variables['view']->element['#attached']['library'][] = array('core', 'drupal.tableheader'); $variables['attributes']['class'][] = "sticky-enabled"; } $variables['attributes']['class'][] = 'cols-' . count($variables['header']); @@ -731,7 +755,7 @@ function template_preprocess_views_view_table(&$variables) { // with the classes represented by the constants RESPONSIVE_PRIORITY_MEDIUM // and RESPONSIVE_PRIORITY_LOW, add the tableresponsive behaviors. if (isset($variables['header']) && $responsive) { - $variables['view']->element['#attached']['library'][] = 'core/drupal.tableresponsive'; + $variables['view']->element['#attached']['library'][] = array('core', 'drupal.tableresponsive'); // Add 'responsive-enabled' class to the table to identify it for JS. // This is needed to target tables constructed by this function. $variables['attributes']['class'][] = 'responsive-enabled'; @@ -1042,7 +1066,7 @@ function template_preprocess_views_exposed_form(&$variables) { } // Include basic theming for exposed forms. - $form['#attached']['library'][] = 'views/views.exposed-form'; + $form['#attached']['library'][] = array('views', 'views.exposed-form'); foreach ($form['#info'] as $info) { if (!empty($info['label'])) { diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Controller/ViewsUIController.php b/core/modules/views_ui/lib/Drupal/views_ui/Controller/ViewsUIController.php index 018d4d9..c68759a 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Controller/ViewsUIController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Controller/ViewsUIController.php @@ -11,7 +11,6 @@ use Drupal\Core\Controller\ControllerBase; use Drupal\views\ViewExecutable; use Drupal\views\ViewStorageInterface; -use Drupal\views\Views; use Drupal\views_ui\ViewUI; use Drupal\views\ViewsData; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -98,7 +97,7 @@ public function reportFields() { // Sort rows by field name. ksort($rows); $output = array( - '#type' => 'table', + '#theme' => 'table', '#header' => $header, '#rows' => $rows, '#empty' => t('No fields have been used in views yet.'), @@ -114,7 +113,7 @@ public function reportFields() { * The Views plugins report page. */ public function reportPlugins() { - $rows = Views::pluginList(); + $rows = views_plugin_list(); foreach ($rows as &$row) { // Link each view name to the view itself. foreach ($row['views'] as $row_name => $view) { @@ -126,7 +125,7 @@ public function reportPlugins() { // Sort rows by field name. ksort($rows); return array( - '#type' => 'table', + '#theme' => 'table', '#header' => array(t('Type'), t('Name'), t('Provided by'), t('Used in')), '#rows' => $rows, '#empty' => t('There are no enabled views.'), diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Form/AdvancedSettingsForm.php b/core/modules/views_ui/lib/Drupal/views_ui/Form/AdvancedSettingsForm.php index 3ef9653..daaee70 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Form/AdvancedSettingsForm.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Form/AdvancedSettingsForm.php @@ -8,7 +8,6 @@ namespace Drupal\views_ui\Form; use Drupal\Core\Form\ConfigFormBase; -use Drupal\views\Views; /** * Form builder for the advanced admin settings page. @@ -69,7 +68,7 @@ public function buildForm(array $form, array &$form_state) { '#default_value' => $config->get('no_javascript'), ); - $options = Views::fetchPluginNames('display_extender'); + $options = views_fetch_plugin_names('display_extender'); if (!empty($options)) { $form['extenders'] = array( '#type' => 'details', diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/CustomBooleanTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/CustomBooleanTest.php index 1b40d9f..75aed9d 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/CustomBooleanTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/CustomBooleanTest.php @@ -7,8 +7,6 @@ namespace Drupal\views_ui\Tests; -use Drupal\views\Views; - /** * Tests the UI and functionality for the Custom boolean field handler options. * @@ -55,7 +53,7 @@ public function dataSet() { */ public function testCustomOption() { // Add the boolean field handler to the test view. - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->setDisplay(); $view->displayHandlers->get('default')->overrideOption('fields', array( @@ -103,7 +101,7 @@ public function testCustomOption() { // Save the view. $this->drupalPostForm('admin/structure/views/view/test_view', array(), 'Save'); - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $output = $view->preview(); $output = drupal_render($output); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayAttachmentTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayAttachmentTest.php index 5d71210..61e534b 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayAttachmentTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayAttachmentTest.php @@ -7,8 +7,6 @@ namespace Drupal\views_ui\Tests; -use Drupal\views\Views; - /** * Tests the UI for the attachment display plugin. * @@ -51,7 +49,7 @@ public function testAttachmentUI() { $this->assertEqual($result[0]->attributes()->title, t('Page')); $this->drupalPostForm(NULL, array(), t('Save')); - $view = Views::getView('test_attachment_ui'); + $view = views_get_view('test_attachment_ui'); $view->initDisplay(); $this->assertEqual(array_keys(array_filter($view->displayHandlers->get('attachment_1')->getOption('displays'))), array('page_1'), 'The attached displays got saved as expected'); @@ -60,7 +58,7 @@ public function testAttachmentUI() { $this->assertEqual($result[0]->attributes()->title, t('Multiple displays')); $this->drupalPostForm(NULL, array(), t('Save')); - $view = Views::getView('test_attachment_ui'); + $view = views_get_view('test_attachment_ui'); $view->initDisplay(); $this->assertEqual(array_keys($view->displayHandlers->get('attachment_1')->getOption('displays')), array('default', 'page_1'), 'The attached displays got saved as expected'); } diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayExtenderUITest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayExtenderUITest.php index 388eb38..9515b4b 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayExtenderUITest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayExtenderUITest.php @@ -7,8 +7,6 @@ namespace Drupal\views_ui\Tests; -use Drupal\views\Views; - /** * Tests the display extender UI. */ @@ -35,7 +33,7 @@ public static function getInfo() { public function testDisplayExtenderUI() { \Drupal::config('views.settings')->set('display_extenders', array('display_extender_test'))->save(); - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view_edit_url = "admin/structure/views/view/{$view->storage->id()}/edit"; $display_option_url = 'admin/structure/views/nojs/display/test_view/default/test_extender_test_option'; @@ -46,7 +44,7 @@ public function testDisplayExtenderUI() { $this->drupalPostForm($display_option_url, array('test_extender_test_option' => $random_text), t('Apply')); $this->assertLink($random_text); $this->drupalPostForm(NULL, array(), t('Save')); - $view = Views::getView($view->storage->id()); + $view = views_get_view($view->storage->id()); $view->initDisplay(); $this->assertEqual($view->display_handler->getOption('test_extender_test_option'), $random_text, 'Make sure that the display extender option got saved.'); } diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayTest.php index 5590138..b0aebc2 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayTest.php @@ -47,6 +47,7 @@ public function testReorderDisplay() { 'block[create]' => TRUE ); $view = $this->randomView($view); + $path_prefix = 'admin/structure/views/view/' . $view['id'] .'/edit'; $this->clickLink(t('Reorder displays')); $this->assertTrue($this->xpath('//tr[@id="display-row-default"]'), 'Make sure the default display appears on the reorder listing'); @@ -61,7 +62,7 @@ public function testReorderDisplay() { $this->drupalPostForm(NULL, $edit, t('Apply')); $this->drupalPostForm(NULL, array(), t('Save')); - $view = Views::getView($view['id']); + $view = views_get_view($view['id']); $displays = $view->storage->get('display'); $this->assertEqual($displays['default']['position'], 0, 'Make sure the master display comes first.'); $this->assertEqual($displays['block_1']['position'], 1, 'Make sure the block display comes before the page display.'); @@ -114,7 +115,7 @@ public function testDisplayAreas() { \Drupal::config('views.settings')->set('ui.show.advanced_column', TRUE)->save(); // Add a new data display to the view. - $view = Views::getView('test_display'); + $view = views_get_view('test_display'); $view->storage->addDisplay('display_no_area_test'); $view->save(); @@ -204,7 +205,7 @@ public function testViewStatus() { $elements = $this->xpath('//div[contains(@class, :edit) and contains(@class, :status)]', array(':edit' => 'views-edit-view', ':status' => 'enabled')); $this->assertTrue($elements, 'The enabled class was found on the form wrapper'); - $view = Views::getView($id); + $view = views_get_view($id); $view->storage->disable()->save(); $this->drupalGet('admin/structure/views/view/' . $id); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayTestCRUD.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayTestCRUD.php index c027167..95f3790 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayTestCRUD.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayTestCRUD.php @@ -134,7 +134,7 @@ public function testCloneDisplay() { $this->assertNoText(t('Page settings')); $this->drupalPostForm(NULL, array(), t('Save')); - $view = Views::getView($view['id']); + $view = views_get_view($view['id']); $view->initDisplay(); $page_2 = $view->displayHandlers->get('page_2'); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/QueryTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/QueryTest.php index 0013b78..64d9a72 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/QueryTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/QueryTest.php @@ -7,7 +7,6 @@ namespace Drupal\views_ui\Tests; -use Drupal\views\Views; use Drupal\views\Tests\ViewTestBase; use Drupal\views_test_data\Plugin\views\query\QueryTest as QueryTestPlugin; @@ -52,7 +51,7 @@ public function testQueryUI() { $this->drupalPostForm(NULL, array(), t('Save')); // Check that the settings are saved into the view itself. - $view = Views::getView('test_view'); + $view = views_get_view('test_view'); $view->initDisplay(); $view->initQuery(); $this->assertEqual($random_value, $view->query->options['test_setting'], 'Query settings got saved'); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/RearrangeFieldsTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/RearrangeFieldsTest.php index b7bd570..58d20a9 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/RearrangeFieldsTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/RearrangeFieldsTest.php @@ -7,8 +7,6 @@ namespace Drupal\views_ui\Tests; -use Drupal\views\Views; - /** * Tests the reordering of fields via AJAX. * @@ -35,7 +33,7 @@ public static function getInfo() { * Gets the fields from the View. */ protected function getViewFields($view_name = 'test_view', $display_id = 'default') { - $view = Views::getView($view_name); + $view = views_get_view($view_name); $view->setDisplay($display_id); $fields = array(); foreach ($view->displayHandlers->get('default')->getHandlers('field') as $field => $handler) { diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/RowUITest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/RowUITest.php index cc8c5c3..9ff327a 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/RowUITest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/RowUITest.php @@ -7,8 +7,6 @@ namespace Drupal\views_ui\Tests; -use Drupal\views\Views; - /** * Tests the UI of row plugins. * @@ -60,7 +58,7 @@ public function testRowUI() { $this->drupalPostForm($view_edit_url, array(), t('Save')); $this->assertLink(t('Test row plugin'), 0, 'Make sure the test row plugin is shown in the UI'); - $view = Views::getView($view_name); + $view = views_get_view($view_name); $view->initDisplay(); $row = $view->display_handler->getOption('row'); $this->assertEqual($row['type'], 'test_row', 'Make sure that the test_row got saved as used row plugin.'); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/StorageTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/StorageTest.php index 4a99d2a..8466e40 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/StorageTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/StorageTest.php @@ -8,7 +8,6 @@ namespace Drupal\views_ui\Tests; use Drupal\Core\Language\Language; -use Drupal\views\Views; /** * Tests the UI of storage properties of views. @@ -58,7 +57,7 @@ public function testDetails() { $this->drupalPostForm("admin/structure/views/nojs/edit-details/$view_name/default", $edit, t('Apply')); $this->drupalPostForm(NULL, array(), t('Save')); - $view = Views::getView($view_name); + $view = views_get_view($view_name); foreach (array('label', 'tag', 'description', 'langcode') as $property) { $this->assertEqual($view->storage->get($property), $edit[$property], format_string('Make sure the property @property got probably saved.', array('@property' => $property))); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/StyleUITest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/StyleUITest.php index c58d1a5..9af6469 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/StyleUITest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/StyleUITest.php @@ -7,8 +7,6 @@ namespace Drupal\views_ui\Tests; -use Drupal\views\Views; - /** * Tests the UI of style plugins. * @@ -60,7 +58,7 @@ public function testStyleUI() { $this->drupalPostForm($view_edit_url, array(), t('Save')); $this->assertLink(t('Test style plugin'), 0, 'Make sure the test style plugin is shown in the UI'); - $view = Views::getView($view_name); + $view = views_get_view($view_name); $view->initDisplay(); $style = $view->display_handler->getOption('style'); $this->assertEqual($style['type'], 'test_style', 'Make sure that the test_style got saved as used style plugin.'); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/ViewsUITourTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/ViewsUITourTest.php index 5808cde..899e08a 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/ViewsUITourTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/ViewsUITourTest.php @@ -52,6 +52,7 @@ public function testViewsUiTourTips() { $view['id'] = strtolower($this->randomName(16)); $view['page[create]'] = 1; $view['page[path]'] = $this->randomName(16); + $view_path = $view['page[path]']; $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit')); $this->assertTourTips(); } diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewAddFormController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewAddFormController.php index 1f0b23b..7477184 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewAddFormController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewAddFormController.php @@ -76,7 +76,7 @@ public function form(array $form, array &$form_state) { '#type' => 'machine_name', '#maxlength' => 128, '#machine_name' => array( - 'exists' => '\Drupal\views\Views::getView', + 'exists' => 'views_get_view', 'source' => array('name', 'label'), ), '#description' => $this->t('A unique machine-readable name for this View. It must only contain lowercase letters, numbers, and underscores.'), diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewCloneFormController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewCloneFormController.php index f03eda4..6d9e85b 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewCloneFormController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewCloneFormController.php @@ -39,7 +39,7 @@ public function form(array $form, array &$form_state) { '#type' => 'machine_name', '#maxlength' => 128, '#machine_name' => array( - 'exists' => '\Drupal\views\Views::getView', + 'exists' => 'views_get_view', 'source' => array('label'), ), '#default_value' => '', diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php index 4af7770..0373116 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php @@ -13,7 +13,6 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\String; use Drupal\user\TempStoreFactory; -use Drupal\views\Views; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -84,13 +83,13 @@ public function form(array $form, array &$form_state) { $form['#tree'] = TRUE; - $form['#attached']['library'][] = 'core/jquery.ui.tabs'; - $form['#attached']['library'][] = 'core/jquery.ui.dialog'; - $form['#attached']['library'][] = 'core/drupal.states'; - $form['#attached']['library'][] = 'core/drupal.tabledrag'; + $form['#attached']['library'][] = array('core', 'jquery.ui.tabs'); + $form['#attached']['library'][] = array('core', 'jquery.ui.dialog'); + $form['#attached']['library'][] = array('core', 'drupal.states'); + $form['#attached']['library'][] = array('core', 'drupal.tabledrag'); if (!\Drupal::config('views.settings')->get('no_javascript')) { - $form['#attached']['library'][] = 'views_ui/views_ui.admin'; + $form['#attached']['library'][] = array('views_ui', 'views_ui.admin'); } $form['#attached']['css'] = static::getAdminCSS(); @@ -294,7 +293,7 @@ public function submit(array $form, array &$form_state) { if (!empty($destination)) { // Find out the first display which has a changed path and redirect to this url. - $old_view = Views::getView($view->id()); + $old_view = views_get_view($view->id()); $old_view->initDisplay(); foreach ($old_view->displayHandlers as $id => $display) { // Only check for displays with a path. @@ -437,7 +436,7 @@ public function getDisplayDetails($view, $display) { "#suffix" => '', ); - foreach (Views::fetchPluginNames('display', NULL, array($view->get('storage')->get('base_table'))) as $type => $label) { + foreach (views_fetch_plugin_names('display', NULL, array($view->get('storage')->get('base_table'))) as $type => $label) { if ($type == $display['display_plugin']) { continue; } @@ -734,7 +733,7 @@ public function renderDisplayTop(ViewUI $view) { } // Buttons for adding a new display. - foreach (Views::fetchPluginNames('display', NULL, array($view->get('base_table'))) as $type => $label) { + foreach (views_fetch_plugin_names('display', NULL, array($view->get('base_table'))) as $type => $label) { $element['add_display'][$type] = array( '#type' => 'submit', '#value' => $this->t('Add !display', array('!display' => $label)), diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php index 1facb3c..dc8d5e4 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php @@ -167,8 +167,8 @@ public function render() { $list['#attributes']['id'] = 'views-entity-list'; $list['#attached']['css'] = ViewFormControllerBase::getAdminCSS(); - $list['#attached']['library'][] = 'core/drupal.ajax'; - $list['#attached']['library'][] = 'views_ui/views_ui.listing'; + $list['#attached']['library'][] = array('core', 'drupal.ajax'); + $list['#attached']['library'][] = array('views_ui', 'views_ui.listing'); $form['filters'] = array( '#type' => 'container', @@ -196,7 +196,7 @@ public function render() { $list[$status]['#type'] = 'container'; $list[$status]['#attributes'] = array('class' => array('views-list-section', $status)); $list[$status]['table'] = array( - '#type' => 'table', + '#theme' => 'table', '#attributes' => array( 'class' => array('views-listing-table'), ), diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php index f959d0d..1ea7ee2 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php @@ -712,7 +712,7 @@ public function renderPreview($display_id, $args = array()) { // Assemble the preview, the query info, and the query statistics in the // requested order. $table = array( - '#type' => 'table', + '#theme' => 'table', '#prefix' => '
', '#suffix' => '
', ); diff --git a/core/modules/views_ui/views_ui.module b/core/modules/views_ui/views_ui.module index 7f140d3..1d4a598 100644 --- a/core/modules/views_ui/views_ui.module +++ b/core/modules/views_ui/views_ui.module @@ -5,7 +5,6 @@ * Provide structure for the administrative interface to Views. */ -use Drupal\views\Views; use Drupal\views\ViewExecutable; use Drupal\views\ViewStorageInterface; use Drupal\views_ui\ViewUI; @@ -373,5 +372,5 @@ function views_ui_truncate($string, $length) { * Magic load function. Wrapper to load a view. */ function views_ui_load($name) { - return Views::getView($name); + return views_get_view($name); } diff --git a/core/modules/views_ui/views_ui.theme.inc b/core/modules/views_ui/views_ui.theme.inc index b224dca..db4f3e8 100644 --- a/core/modules/views_ui/views_ui.theme.inc +++ b/core/modules/views_ui/views_ui.theme.inc @@ -195,7 +195,7 @@ function theme_views_ui_build_group_filter_form($variables) { $rows[] = array('data' => $data, 'id' => 'views-row-' . $group_id, 'class' => array('draggable')); } $table = array( - '#type' => 'table', + '#theme' => 'table', '#header' => $header, '#rows' => $rows, '#attributes' => array( @@ -297,7 +297,7 @@ function theme_views_ui_rearrange_filter_form(&$variables) { if (!empty($ungroupable_rows)) { $header = array(t('Ungroupable filters'), t('Weight'), array('class' => array('views-hide-label'), 'data' => t('Group')), array('class' => array('views-hide-label'), 'data' => t('Remove'))); $table = array( - '#type' => 'table', + '#theme' => 'table', '#header' => $header, '#rows' => $ungroupable_rows, '#attributes' => array( @@ -317,7 +317,7 @@ function theme_views_ui_rearrange_filter_form(&$variables) { // Set up tabledrag so that the weights are changed when rows are dragged. $table = array( - '#type' => 'table', + '#theme' => 'table', '#rows' => $rows, '#attributes' => array( 'id' => 'views-rearrange-filters', @@ -499,7 +499,7 @@ function template_preprocess_views_ui_view_preview_section(&$variables) { '#links' => $links, '#attributes' => array('class' => array('contextual-links')), '#attached' => array( - 'library' => array('contextual/drupal.contextual-links'), + 'library' => array(array('contextual', 'drupal.contextual-links')), ), ); $variables['links'] = $build; diff --git a/core/phpunit.xml.dist b/core/phpunit.xml.dist index aacbc2f..35ff254 100644 --- a/core/phpunit.xml.dist +++ b/core/phpunit.xml.dist @@ -1,12 +1,6 @@ - - - - - - ./tests diff --git a/core/profiles/standard/standard.install b/core/profiles/standard/standard.install index bec1107..aa0cb4a 100644 --- a/core/profiles/standard/standard.install +++ b/core/profiles/standard/standard.install @@ -4,8 +4,6 @@ * Install, update and uninstall functions for the standard installation profile. */ -use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; - /** * Implements hook_install(). * @@ -27,7 +25,7 @@ function standard_install() { \Drupal::config('system.site')->set('page.front', 'node')->save(); // Add comment field to article node type. - \Drupal::service('comment.manager')->addDefaultField('node', 'article', 'comment', CommentItemInterface::OPEN); + \Drupal::service('comment.manager')->addDefaultField('node', 'article', 'comment', COMMENT_OPEN); // Allow visitor account creation with administrative approval. $user_settings = \Drupal::config('user.settings'); diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh index 5594dd5..363c69b 100755 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -71,7 +71,7 @@ exit; } -$test_list = simpletest_script_get_test_list(); +$test_list = array_fill(0, 20, 'Drupal\toolbar\Tests\ToolbarAdminMenuTest'); // Try to allocate unlimited time to run the tests. drupal_set_time_limit(0); diff --git a/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php b/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php index 0384148..188c042 100644 --- a/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php +++ b/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php @@ -5,7 +5,7 @@ * Contains \Drupal\Tests\Core\Ajax\AjaxCommandsTest. */ -namespace Drupal\Tests\Core\Ajax; +namespace Drupal\Tests\Core\Ajax { use Drupal\Tests\UnitTestCase; use Drupal\Core\Ajax\AddCssCommand; @@ -308,7 +308,7 @@ public function testSettingsCommand() { * Tests that OpenDialogCommand objects can be constructed and rendered. */ public function testOpenDialogCommand() { - $command = new TestOpenDialogCommand('#some-dialog', 'Title', '

Text!

', array( + $command = new OpenDialogCommand('#some-dialog', 'Title', '

Text!

', array( 'url' => FALSE, 'width' => 500, )); @@ -332,7 +332,7 @@ public function testOpenDialogCommand() { * Tests that OpenModalDialogCommand objects can be constructed and rendered. */ public function testOpenModalDialogCommand() { - $command = new TestOpenModalDialogCommand('Title', '

Text!

', array( + $command = new OpenModalDialogCommand('Title', '

Text!

', array( 'url' => 'example', 'width' => 500, )); @@ -425,26 +425,12 @@ public function testRedirectCommand() { } -/** - * Wraps OpenModalDialogCommand::drupalAttachLibrary(). - * - * {@inheritdoc} - */ -class TestOpenModalDialogCommand extends OpenModalDialogCommand { - - protected function drupalAttachLibrary($name) { - } - } -/** - * Wraps OpenDialogCommand::drupalAttachLibrary(). - * - * {@inheritdoc} - */ -class TestOpenDialogCommand extends OpenDialogCommand { - - protected function drupalAttachLibrary($name) { +namespace { + if (!function_exists('drupal_add_library')) { + function drupal_add_library() { + return TRUE; + } } - } diff --git a/core/tests/Drupal/Tests/Core/Annotation/TranslationTest.php b/core/tests/Drupal/Tests/Core/Annotation/TranslationTest.php deleted file mode 100644 index 258279e..0000000 --- a/core/tests/Drupal/Tests/Core/Annotation/TranslationTest.php +++ /dev/null @@ -1,97 +0,0 @@ - '', - 'name' => '\Drupal\Core\Annotation\Translation unit test', - 'group' => 'System', - ); - } - - /** - * {@inheritdoc} - */ - public function setUp() { - $this->translationManager = $this->getStringTranslationStub(); - } - - /** - * @covers \Drupal\Core\Annotation\Translation::get() - * - * @dataProvider providerTestGet - */ - public function testGet(array $values, $expected) { - $container = new ContainerBuilder(); - $container->set('string_translation', $this->translationManager); - \Drupal::setContainer($container); - - $arguments = isset($values['arguments']) ? $values['arguments'] : array(); - $options = isset($values['context']) ? array( - 'context' => $values['context'], - ) : array(); - $this->translationManager->expects($this->once()) - ->method('translate') - ->with($values['value'], $arguments, $options); - - $annotation = new Translation($values); - - $this->assertSame($expected, $annotation->get()); - } - - /** - * Provides data to self::testGet(). - */ - public function providerTestGet() { - $data = array(); - $data[] = array( - array( - 'value' => 'Foo', - ), - 'Foo' - ); - $random = $this->randomName(); - $random_html_entity = '&' . $random; - $data[] = array( - array( - 'value' => 'Foo !bar @baz %qux', - 'arguments' => array( - '!bar' => $random, - '@baz' => $random_html_entity, - '%qux' => $random_html_entity, - ), - 'context' => $this->randomName(), - ), - 'Foo ' . $random . ' &' . $random . ' &' . $random . '', - ); - - return $data; - } - -} diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php deleted file mode 100644 index d7271d9..0000000 --- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php +++ /dev/null @@ -1,233 +0,0 @@ - '', - 'name' => '\Drupal\Core\Config\Entity\ConfigEntityBase unit test', - 'group' => 'Entity', - ); - } - - /** - * {@inheritdoc} - */ - public function setUp() { - $values = array(); - $this->entityType = $this->randomName(); - - $this->entityInfo = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface'); - - $this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface'); - $this->entityManager->expects($this->any()) - ->method('getDefinition') - ->with($this->entityType) - ->will($this->returnValue($this->entityInfo)); - - $this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface'); - - $container = new ContainerBuilder(); - $container->set('entity.manager', $this->entityManager); - $container->set('uuid', $this->uuid); - \Drupal::setContainer($container); - - $this->entity = $this->getMockBuilder('\Drupal\Core\Config\Entity\ConfigEntityBase') - ->setConstructorArgs(array($values, $this->entityType)) - ->setMethods(array('languageLoad')) - ->getMock(); - $this->entity->expects($this->any()) - ->method('languageLoad') - ->will($this->returnValue(NULL)); - } - - /** - * @covers ::setOriginalId - * @covers ::getOriginalId - */ - public function testGetOriginalId() { - $id = $this->randomName(); - $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->setOriginalId($id))); - $this->assertSame($id, $this->entity->getOriginalId()); - } - - /** - * @covers ::isNew - */ - public function testIsNew() { - $this->assertFalse($this->entity->isNew()); - $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->enforceIsNew())); - $this->assertTrue($this->entity->isNew()); - $this->entity->enforceIsNew(FALSE); - $this->assertFalse($this->entity->isNew()); - } - - /** - * @covers ::set - * @covers ::get - */ - public function testGet() { - $name = $this->randomName(); - $value = $this->randomName(); - $this->assertNull($this->entity->get($name)); - $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->set($name, $value))); - $this->assertSame($value, $this->entity->get($name)); - } - - /** - * @covers ::setStatus - * @covers ::status - */ - public function testSetStatus() { - $this->assertTrue($this->entity->status()); - $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->setStatus(FALSE))); - $this->assertFalse($this->entity->status()); - $this->entity->setStatus(TRUE); - $this->assertTrue($this->entity->status()); - } - - /** - * @covers ::enable - * @depends testSetStatus - */ - public function testEnable() { - $this->entity->setStatus(FALSE); - $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->enable())); - $this->assertTrue($this->entity->status()); - } - - /** - * @covers ::disable - * @depends testSetStatus - */ - public function testDisable() { - $this->entity->setStatus(TRUE); - $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->disable())); - $this->assertFalse($this->entity->status()); - } - - /** - * @covers ::setSyncing - * @covers ::isSyncing - */ - public function testIsSyncing() { - $this->assertFalse($this->entity->isSyncing()); - $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->setSyncing(TRUE))); - $this->assertTrue($this->entity->isSyncing()); - $this->entity->setSyncing(FALSE); - $this->assertFalse($this->entity->isSyncing()); - } - - /** - * @covers ::createDuplicate - */ - public function testCreateDuplicate() { - $this->entityInfo->expects($this->once()) - ->method('getKey') - ->with('id') - ->will($this->returnValue('id')); - - $this->entity->setOriginalId('foo'); - /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $duplicate */ - $duplicate = $this->entity->createDuplicate(); - $this->assertInstanceOf('\Drupal\Core\Entity\Entity', $duplicate); - $this->assertNotSame(spl_object_hash($this->entity), spl_object_hash($duplicate)); - $this->assertNull($duplicate->id()); - $this->assertNull($duplicate->getOriginalId()); - $this->assertNull($duplicate->uuid()); - } - - /** - * @covers ::sort - */ - public function testSort() { - $this->entityManager->expects($this->any()) - ->method('getDefinition') - ->with($this->entityType) - ->will($this->returnValue(array( - 'entity_keys' => array( - 'label' => 'label', - ), - ))); - $entity_a = $this->entity; - $entity_a->label = 'foo'; - $entity_b = clone $this->entity; - $entity_b->label = 'bar'; - $list = array($entity_a, $entity_b); - // Suppress errors because of https://bugs.php.net/bug.php?id=50688. - @usort($list, '\Drupal\Core\Config\Entity\ConfigEntityBase::sort'); - $this->assertSame(spl_object_hash($entity_b), spl_object_hash($list[0])); - $entity_a->weight = 0; - $entity_b->weight = 1; - // Suppress errors because of https://bugs.php.net/bug.php?id=50688. - @usort($list, array($entity_a, 'sort')); - $this->assertSame(spl_object_hash($entity_a), spl_object_hash($list[0])); - } - - /** - * @covers ::getExportProperties - */ - public function testGetExportProperties() { - $properties = $this->entity->getExportProperties(); - $this->assertInternalType('array', $properties); - $class_info = new \ReflectionClass($this->entity); - foreach ($class_info->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { - $name = $property->getName(); - $this->assertArrayHasKey($name, $properties); - $this->assertSame($this->entity->get($name), $properties[$name]); - } - } -} diff --git a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php deleted file mode 100644 index 789306b..0000000 --- a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php +++ /dev/null @@ -1,326 +0,0 @@ - '', - 'name' => '\Drupal\Core\Entity\ContentEntityBase unit test', - 'group' => 'Entity', - ); - } - - /** - * {@inheritdoc} - */ - public function setUp() { - $values = array(); - $this->entityType = $this->randomName(); - $this->bundle = $this->randomName(); - - $this->entityInfo = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface'); - - $this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface'); - $this->entityManager->expects($this->any()) - ->method('getDefinition') - ->with($this->entityType) - ->will($this->returnValue($this->entityInfo)); - $this->entityManager->expects($this->any()) - ->method('getFieldDefinitions') - ->with($this->entityType, $this->bundle) - ->will($this->returnValue(array( - 'id' => array( - 'type' => 'integer_field', - ), - ))); - - $this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface'); - - $this->typedDataManager = $this->getMockBuilder('\Drupal\Core\TypedData\TypedDataManager') - ->disableOriginalConstructor() - ->getMock(); - - $container = new ContainerBuilder(); - $container->set('entity.manager', $this->entityManager); - $container->set('uuid', $this->uuid); - $container->set('typed_data_manager', $this->typedDataManager); - \Drupal::setContainer($container); - - $this->entity = $this->getMockBuilder('\Drupal\Core\Entity\ContentEntityBase') - ->setConstructorArgs(array($values, $this->entityType, $this->bundle)) - ->setMethods(array('languageList', 'languageLoad')) - ->getMockForAbstractClass(); - $this->entity->expects($this->any()) - ->method('languageList') - ->will($this->returnValue(array())); - $this->entity->expects($this->any()) - ->method('languageLoad') - ->will($this->returnValue(NULL)); - } - - /** - * @covers ::isNewRevision - * @covers ::setNewRevision - */ - public function testIsNewRevision() { - $this->entityInfo->expects($this->at(0)) - ->method('hasKey') - ->with('revision') - ->will($this->returnValue(FALSE)); - $this->entityInfo->expects($this->at(1)) - ->method('hasKey') - ->with('revision') - ->will($this->returnValue(TRUE)); - - $this->assertFalse($this->entity->isNewRevision()); - $this->assertTrue($this->entity->isNewRevision()); - $this->entity->setNewRevision(TRUE); - $this->assertTRUE($this->entity->isNewRevision()); - } - - /** - * @covers ::isDefaultRevision - */ - public function testIsDefaultRevision() { - // The default value is TRUE. - $this->assertTrue($this->entity->isDefaultRevision()); - // We override the value, but it does not affect this call. - $this->assertTrue($this->entity->isDefaultRevision(FALSE)); - // The last call changed the return value for this call. - $this->assertFalse($this->entity->isDefaultRevision()); - } - - /** - * @covers ::getRevisionId - */ - public function testGetRevisionId() { - $this->assertNull($this->entity->getRevisionId()); - } - - /** - * @covers ::isTranslatable - */ - public function testIsTranslatable() { - $this->entityManager->expects($this->at(0)) - ->method('getBundleInfo') - ->with($this->entityType) - ->will($this->returnValue(array( - $this->bundle => array( - 'translatable' => TRUE, - ), - ))); - $this->assertTrue($this->entity->isTranslatable()); - $this->assertFalse($this->entity->isTranslatable()); - } - - /** - * @covers ::preSaveRevision - */ - public function testPreSaveRevision() { - // This method is internal, so check for errors on calling it only. - $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface'); - $record = new \stdClass(); - $this->entity->preSaveRevision($storage, $record); - } - - /** - * @covers ::getString - */ - public function testGetString() { - $label = $this->randomName(); - /** @var \Drupal\Core\Entity\ContentEntityBase|\PHPUnit_Framework_MockObject_MockObject $entity */ - $entity = $this->getMockBuilder('\Drupal\Core\Entity\ContentEntityBase') - ->setMethods(array('label')) - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - $entity->expects($this->once()) - ->method('label') - ->will($this->returnValue($label)); - - $this->assertSame($label, $entity->getString()); - } - - /** - * @covers ::validate - */ - public function testValidate() { - $validator = $this->getMock('\Symfony\Component\Validator\ValidatorInterface'); - /** @var \Symfony\Component\Validator\ConstraintViolationList|\PHPUnit_Framework_MockObject_MockObject $empty_violation_list */ - $empty_violation_list = $this->getMockBuilder('\Symfony\Component\Validator\ConstraintViolationList') - ->setMethods(NULL) - ->getMock(); - $non_empty_violation_list = clone $empty_violation_list; - $violation = $this->getMock('\Symfony\Component\Validator\ConstraintViolationInterface'); - $non_empty_violation_list->add($violation); - $validator->expects($this->at(0)) - ->method('validate') - ->with($this->entity) - ->will($this->returnValue($empty_violation_list)); - $validator->expects($this->at(1)) - ->method('validate') - ->with($this->entity) - ->will($this->returnValue($non_empty_violation_list)); - $this->typedDataManager->expects($this->exactly(2)) - ->method('getValidator') - ->will($this->returnValue($validator)); - $this->assertSame(0, count($this->entity->validate())); - $this->assertSame(1, count($this->entity->validate())); - } - - /** - * @covers ::getConstraints - */ - public function testGetConstraints() { - $this->assertInternalType('array', $this->entity->getConstraints()); - } - - /** - * @covers ::getName - */ - public function testGetName() { - $this->assertNull($this->entity->getName()); - } - - /** - * @covers ::getRoot - */ - public function testGetRoot() { - $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->getRoot())); - } - - /** - * @covers ::getPropertyPath - */ - public function testGetPropertyPath() { - $this->assertSame('', $this->entity->getPropertyPath()); - } - - /** - * @covers ::getParent - */ - public function testGetParent() { - $this->assertNull($this->entity->getParent()); - } - - /** - * @covers ::setContext - */ - public function testSetContext() { - $name = $this->randomName(); - $parent = $this->getMock('\Drupal\Core\TypedData\TypedDataInterface'); - $this->entity->setContext($name, $parent); - } - - /** - * @covers ::bundle - */ - public function testBundle() { - $this->assertSame($this->bundle, $this->entity->bundle()); - } - - /** - * @covers ::access - */ - public function testAccess() { - $access = $this->getMock('\Drupal\Core\Entity\EntityAccessControllerInterface'); - $operation = $this->randomName(); - $access->expects($this->at(0)) - ->method('access') - ->with($this->entity, $operation) - ->will($this->returnValue(TRUE)); - $access->expects($this->at(1)) - ->method('createAccess') - ->will($this->returnValue(TRUE)); - $this->entityManager->expects($this->exactly(2)) - ->method('getAccessController') - ->will($this->returnValue($access)); - $this->assertTrue($this->entity->access($operation)); - $this->assertTrue($this->entity->access('create')); - } - - /** - * @covers ::label - */ - public function testLabel() { - // Make a mock with one method that we use as the entity's uri_callback. We - // check that it is called, and that the entity's label is the callback's - // return value. - $callback_label = $this->randomName(); - $callback_container = $this->getMock(get_class()); - $callback_container->expects($this->once()) - ->method(__FUNCTION__) - ->will($this->returnValue($callback_label)); - $this->entityInfo->expects($this->once()) - ->method('getLabelCallback') - ->will($this->returnValue(array($callback_container, __FUNCTION__))); - - $this->assertSame($callback_label, $this->entity->label()); - } -} diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php deleted file mode 100644 index a467a90..0000000 --- a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php +++ /dev/null @@ -1,332 +0,0 @@ - '', - 'name' => '\Drupal\Core\Entity\Entity unit test', - 'group' => 'Entity', - ); - } - - /** - * {@inheritdoc} - */ - public function setUp() { - $values = array(); - $this->entityTypeId = $this->randomName(); - - $this->entityInfo = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface'); - - $this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface'); - $this->entityManager->expects($this->any()) - ->method('getDefinition') - ->with($this->entityTypeId) - ->will($this->returnValue($this->entityInfo)); - - $this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface'); - - $container = new ContainerBuilder(); - $container->set('entity.manager', $this->entityManager); - $container->set('uuid', $this->uuid); - \Drupal::setContainer($container); - - $this->entity = $this->getMockBuilder('\Drupal\Core\Entity\Entity') - ->setConstructorArgs(array($values, $this->entityTypeId)) - ->setMethods(array('languageLoad')) - ->getMock(); - $this->entity->expects($this->any()) - ->method('languageLoad') - ->will($this->returnValue(NULL)); - } - - /** - * @covers ::id - */ - public function testId() { - // @todo How to test this? - $this->assertNull($this->entity->id()); - } - - /** - * @covers ::uuid - */ - public function testUuid() { - // @todo How to test this? - $this->assertNull($this->entity->uuid()); - } - - /** - * @covers ::isNew - */ - public function testIsNew() { - // @todo How to test this? - $this->assertInternalType('bool', $this->entity->isNew()); - } - - /** - * @covers ::enforceIsNew - */ - public function testEnforceIsNew() { - $this->assertSame(spl_object_hash($this->entity), spl_object_hash($this->entity->enforceIsNew())); - } - - /** - * @covers ::getEntityType - */ - public function testGetEntityType() { - $this->assertInstanceOf('\Drupal\Core\Entity\EntityTypeInterface', $this->entity->getEntityType()); - } - - /** - * @covers ::bundle - */ - public function testBundle() { - $this->assertSame($this->entityTypeId, $this->entity->bundle()); - } - - /** - * @covers ::label - */ - public function testLabel() { - // Make a mock with one method that we use as the entity's uri_callback. We - // check that it is called, and that the entity's label is the callback's - // return value. - $callback_label = $this->randomName(); - $property_label = $this->randomName(); - $callback_container = $this->getMock(get_class()); - $callback_container->expects($this->once()) - ->method(__FUNCTION__) - ->will($this->returnValue($callback_label)); - $this->entityInfo->expects($this->at(0)) - ->method('getLabelCallback') - ->will($this->returnValue(array($callback_container, __FUNCTION__))); - $this->entityInfo->expects($this->at(1)) - ->method('getLabelCallback') - ->will($this->returnValue(NULL)); - $this->entityInfo->expects($this->at(2)) - ->method('getKey') - ->with('label') - ->will($this->returnValue('label')); - - // Set a dummy property on the entity under test to test that the label can - // be returned form a property if there is no callback. - $this->entityManager->expects($this->at(1)) - ->method('getDefinition') - ->with($this->entityTypeId) - ->will($this->returnValue(array( - 'entity_keys' => array( - 'label' => 'label', - ), - ))); - $this->entity->label = $property_label; - - $this->assertSame($callback_label, $this->entity->label()); - $this->assertSame($property_label, $this->entity->label()); - } - - /** - * @covers ::access - */ - public function testAccess() { - $access = $this->getMock('\Drupal\Core\Entity\EntityAccessControllerInterface'); - $operation = $this->randomName(); - $access->expects($this->at(0)) - ->method('access') - ->with($this->entity, $operation) - ->will($this->returnValue(TRUE)); - $access->expects($this->at(1)) - ->method('createAccess') - ->will($this->returnValue(TRUE)); - $this->entityManager->expects($this->exactly(2)) - ->method('getAccessController') - ->will($this->returnValue($access)); - $this->assertTrue($this->entity->access($operation)); - $this->assertTrue($this->entity->access('create')); - } - - /** - * @covers ::language - */ - public function testLanguage() { - $this->assertInstanceOf('\Drupal\Core\Language\Language', $this->entity->language()); - } - - /** - * @covers ::save - */ - public function testSave() { - $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface'); - $storage->expects($this->once()) - ->method('save') - ->with($this->entity); - $this->entityManager->expects($this->once()) - ->method('getStorageController') - ->with($this->entityTypeId) - ->will($this->returnValue($storage)); - $this->entity->save(); - } - - /** - * @covers ::delete - */ - public function testDelete() { - $this->entity->id = $this->randomName(); - $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface'); - // Testing the argument of the delete() method consumes too much memory. - $storage->expects($this->once()) - ->method('delete'); - $this->entityManager->expects($this->once()) - ->method('getStorageController') - ->with($this->entityTypeId) - ->will($this->returnValue($storage)); - $this->entity->delete(); - } - - /** - * @covers ::getEntityTypeId - */ - public function testGetEntityTypeId() { - $this->assertSame($this->entityTypeId, $this->entity->getEntityTypeId()); - } - - /** - * @covers ::preSave - */ - public function testPreSave() { - // This method is internal, so check for errors on calling it only. - $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface'); - $this->entity->preSave($storage); - } - - /** - * @covers ::postSave - */ - public function testPostSave() { - // This method is internal, so check for errors on calling it only. - $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface'); - $this->entity->postSave($storage); - } - - /** - * @covers ::preCreate - */ - public function testPreCreate() { - // This method is internal, so check for errors on calling it only. - $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface'); - $values = array(); - $this->entity->preCreate($storage, $values); - } - - /** - * @covers ::postCreate - */ - public function testPostCreate() { - // This method is internal, so check for errors on calling it only. - $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface'); - $this->entity->postCreate($storage); - } - - /** - * @covers ::preDelete - */ - public function testPreDelete() { - // This method is internal, so check for errors on calling it only. - $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface'); - $this->entity->preDelete($storage, array($this->entity)); - } - - /** - * @covers ::postDelete - */ - public function testPostDelete() { - $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface'); - - $entity = $this->getMockBuilder('\Drupal\Core\Entity\Entity') - ->setMethods(array('onSaveOrDelete')) - ->disableOriginalConstructor() - ->getMock(); - $entity->expects($this->once()) - ->method('onSaveOrDelete'); - - $this->entity->postDelete($storage, array($entity)); - } - - /** - * @covers ::postLoad - */ - public function testPostLoad() { - // This method is internal, so check for errors on calling it only. - $storage = $this->getMock('\Drupal\Core\Entity\EntityStorageControllerInterface'); - $entities = array($this->entity); - $this->entity->postLoad($storage, $entities); - } - - /** - * @covers ::referencedEntities - */ - public function testReferencedEntities() { - $this->assertSame(array(), $this->entity->referencedEntities()); - } -} diff --git a/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php b/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php index 309d99a..c90ed93 100644 --- a/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php @@ -9,7 +9,6 @@ use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\Field\FieldDefinition; -use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Tests\UnitTestCase; /** @@ -176,10 +175,7 @@ public function testFieldTranslatable() { public function testFieldCardinality() { $definition = FieldDefinition::create($this->fieldType); $this->assertEquals(1, $definition->getCardinality()); - $definition->setCardinality(2); - $this->assertEquals(2, $definition->getCardinality()); - $definition->setCardinality(FieldDefinitionInterface::CARDINALITY_UNLIMITED); - $this->assertEquals(FieldDefinitionInterface::CARDINALITY_UNLIMITED, $definition->getCardinality()); + // @todo: Add more tests when this can be controlled. } /** diff --git a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php index bae3c9a..9c45fd3 100644 --- a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php @@ -242,13 +242,13 @@ public function testRebuildThemeData() { ->method('scan') ->with('theme') ->will($this->returnValue(array( - 'seven' => new Extension('theme', DRUPAL_ROOT . '/core/themes/seven/seven.info.yml', 'seven.theme'), + 'seven' => new Extension('theme', DRUPAL_ROOT . '/core/themes/seven/seven.info.yml', 'seven.info.yml'), ))); $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/twig.info.yml', 'twig.engine'), + 'twig' => new Extension('theme_engine', DRUPAL_ROOT . '/core/themes/engines/twig.info.yml', 'twig.info.yml'), ))); $this->infoParser->expects($this->once()) ->method('parse') @@ -267,10 +267,10 @@ public function testRebuildThemeData() { // Ensure some basic properties. $this->assertInstanceOf('Drupal\Core\Extension\Extension', $info); - $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('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('twig', $info->prefix); $this->assertEquals('twig', $info->info['engine']); @@ -303,7 +303,7 @@ public function testRebuildThemeDataWithThemeParents() { ->method('scan') ->with('theme_engine') ->will($this->returnValue(array( - 'twig' => new Extension('theme_engine', DRUPAL_ROOT . '/core/themes/engines/twig/twig.info.yml', 'twig.engine'), + 'twig' => new Extension('theme_engine', DRUPAL_ROOT . '/core/themes/engines/twig.info.yml', 'twig.info.yml'), ))); $this->infoParser->expects($this->at(0)) ->method('parse') @@ -328,17 +328,17 @@ public function testRebuildThemeDataWithThemeParents() { // Ensure some basic properties. $this->assertInstanceOf('Drupal\Core\Extension\Extension', $info_basetheme); - $this->assertEquals('test_basetheme', $info_basetheme->getName()); + $this->assertEquals('test_basetheme', $info_basetheme->name); $this->assertInstanceOf('Drupal\Core\Extension\Extension', $info_subtheme); - $this->assertEquals('test_subtheme', $info_subtheme->getName()); + $this->assertEquals('test_subtheme', $info_subtheme->name); // 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/twig.engine', $info_basetheme->owner); + $this->assertEquals(DRUPAL_ROOT . '/core/themes/engines/twig.info.yml', $info_basetheme->owner); $this->assertEquals('twig', $info_basetheme->prefix); - $this->assertEquals(DRUPAL_ROOT . '/core/themes/engines/twig/twig.engine', $info_subtheme->owner); + $this->assertEquals(DRUPAL_ROOT . '/core/themes/engines/twig.info.yml', $info_subtheme->owner); $this->assertEquals('twig', $info_subtheme->prefix); } diff --git a/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php b/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php index a1d2ff9..487f4c8 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php @@ -125,100 +125,6 @@ public function testGetFormIdWithBaseForm() { } /** - * Tests the handling of $form_state['response']. - * - * @dataProvider formStateResponseProvider - */ - public function testHandleFormStateResponse($class, $form_state_key) { - $form_id = 'test_form_id'; - $expected_form = $form_id(); - - $response = $this->getMockBuilder($class) - ->disableOriginalConstructor() - ->getMock(); - $response->expects($this->any()) - ->method('prepare') - ->will($this->returnValue($response)); - - $form_arg = $this->getMockForm($form_id, $expected_form); - $form_arg->expects($this->any()) - ->method('submitForm') - ->will($this->returnCallback(function ($form, &$form_state) use ($response, $form_state_key) { - $form_state[$form_state_key] = $response; - })); - - $form_state = array(); - $this->formBuilder->getFormId($form_arg, $form_state); - - try { - $form_state['values'] = array(); - $form_state['input']['form_id'] = $form_id; - $this->simulateFormSubmission($form_id, $form_arg, $form_state, FALSE); - $this->fail('TestFormBuilder::sendResponse() was not triggered.'); - } - catch (\Exception $e) { - $this->assertSame('exit', $e->getMessage()); - } - $this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $form_state['response']); - } - - /** - * Provides test data for testHandleFormStateResponse(). - */ - public function formStateResponseProvider() { - return array( - array('Symfony\Component\HttpFoundation\Response', 'response'), - array('Symfony\Component\HttpFoundation\RedirectResponse', 'redirect'), - ); - } - - /** - * Tests the handling of a redirect when $form_state['response'] exists. - */ - public function testHandleRedirectWithResponse() { - $form_id = 'test_form_id'; - $expected_form = $form_id(); - - // Set up a response that will be used. - $response = $this->getMockBuilder('Symfony\Component\HttpFoundation\Response') - ->disableOriginalConstructor() - ->getMock(); - $response->expects($this->once()) - ->method('prepare') - ->will($this->returnValue($response)); - - // Set up a redirect that will not be called. - $redirect = $this->getMockBuilder('Symfony\Component\HttpFoundation\RedirectResponse') - ->disableOriginalConstructor() - ->getMock(); - $redirect->expects($this->never()) - ->method('prepare'); - - $form_arg = $this->getMockForm($form_id, $expected_form); - $form_arg->expects($this->any()) - ->method('submitForm') - ->will($this->returnCallback(function ($form, &$form_state) use ($response, $redirect) { - // Set both the response and the redirect. - $form_state['response'] = $response; - $form_state['redirect'] = $redirect; - })); - - $form_state = array(); - $this->formBuilder->getFormId($form_arg, $form_state); - - try { - $form_state['values'] = array(); - $form_state['input']['form_id'] = $form_id; - $this->simulateFormSubmission($form_id, $form_arg, $form_state, FALSE); - $this->fail('TestFormBuilder::sendResponse() was not triggered.'); - } - catch (\Exception $e) { - $this->assertSame('exit', $e->getMessage()); - } - $this->assertSame($response, $form_state['response']); - } - - /** * Tests the redirectForm() method when a redirect is expected. * * @param array $form_state diff --git a/core/tests/Drupal/Tests/Core/Form/FormTestBase.php b/core/tests/Drupal/Tests/Core/Form/FormTestBase.php index 44059c4..3b7a97f 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormTestBase.php +++ b/core/tests/Drupal/Tests/Core/Form/FormTestBase.php @@ -189,19 +189,15 @@ protected function getMockForm($form_id, $expected_form = NULL, $count = 1) { * The form object. * @param array $form_state * An associative array containing the current state of the form. - * @param bool $programmed - * Whether $form_state['programmed'] should be set to TRUE or not. If it is - * not set to TRUE, you must provide additional data in $form_state for the - * submission to take place. * * @return array * The built form. */ - protected function simulateFormSubmission($form_id, FormInterface $form_arg, array &$form_state, $programmed = TRUE) { + protected function simulateFormSubmission($form_id, FormInterface $form_arg, array &$form_state) { $form_state['build_info']['callback_object'] = $form_arg; $form_state['build_info']['args'] = array(); $form_state['input']['op'] = 'Submit'; - $form_state['programmed'] = $programmed; + $form_state['programmed'] = TRUE; $form_state['submitted'] = TRUE; return $this->formBuilder->buildForm($form_id, $form_state); } diff --git a/core/tests/Drupal/Tests/Core/Image/ImageTest.php b/core/tests/Drupal/Tests/Core/Image/ImageTest.php index d2c5fd7..728af5c 100644 --- a/core/tests/Drupal/Tests/Core/Image/ImageTest.php +++ b/core/tests/Drupal/Tests/Core/Image/ImageTest.php @@ -138,11 +138,26 @@ public function testGetMimeType() { } /** - * Tests \Drupal\Core\Image\Image::isExisting(). + * Tests \Drupal\Core\Image\Image::setResource(). */ - public function testIsExisting() { - $this->assertTrue($this->image->isExisting()); - $this->assertTrue(is_readable($this->image->getSource())); + public function testSetResource() { + $resource = fopen($this->image->getSource(), 'r'); + $this->image->setResource($resource); + $this->assertEquals($this->image->getResource(), $resource); + + // Force \Drupal\Core\Image\Image::hasResource() to return FALSE. + $this->image->setResource(FALSE); + $this->assertNotNull($this->image->getResource()); + } + + /** + * Tests \Drupal\Core\Image\Image::hasResource(). + */ + public function testHasResource() { + $this->assertFalse($this->image->hasResource()); + $resource = fopen($this->image->getSource(), 'r'); + $this->image->setResource($resource); + $this->assertTrue($this->image->hasResource()); } /** diff --git a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginBagTest.php b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginBagTest.php index 18eec54..8f9cce0 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginBagTest.php +++ b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginBagTest.php @@ -128,34 +128,6 @@ public function testGetConfiguration() { } /** - * Tests the addInstanceId() method. - */ - public function testAddInstanceId() { - $this->setupPluginBag($this->exactly(4)); - $expected = array( - 'banana' => 'banana', - 'cherry' => 'cherry', - 'apple' => 'apple', - ); - $this->defaultPluginBag->addInstanceId('apple'); - $result = $this->defaultPluginBag->getInstanceIds(); - $this->assertSame($expected, $result); - $this->assertSame($expected, array_intersect_key($result, $this->defaultPluginBag->getConfiguration())); - - $expected = array( - 'cherry' => 'cherry', - 'apple' => 'apple', - 'banana' => 'banana', - ); - $this->defaultPluginBag->removeInstanceId('banana'); - $this->defaultPluginBag->addInstanceId('banana', $this->config['banana']); - - $result = $this->defaultPluginBag->getInstanceIds(); - $this->assertSame($expected, $result); - $this->assertSame($expected, array_intersect_key($result, $this->defaultPluginBag->getConfiguration())); - } - - /** * Tests the removeInstanceId() method. * * @see \Drupal\Core\Plugin\DefaultPluginBag::removeInstanceId() @@ -204,6 +176,27 @@ public function testClear() { } /** + * Tests the setInstanceIds() method. + */ + public function testSetInstanceIds() { + $this->setupPluginBag($this->any()); + // Set the instance IDs in a different order than the original. + $this->defaultPluginBag->setInstanceIds(array( + 'apple' => 'apple', + 'cherry' => 'cherry', + )); + + $expected = array( + 'cherry' => 'cherry', + 'apple' => 'apple', + ); + $config = $this->defaultPluginBag->getConfiguration(); + $instance_ids = $this->defaultPluginBag->getInstanceIds(); + $this->assertSame($expected, $instance_ids); + $this->assertSame(array_keys($expected), array_keys($config)); + } + + /** * Tests the set() method. */ public function testSet() { diff --git a/core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php b/core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php index a46f42c..a0487c1 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php +++ b/core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php @@ -49,40 +49,6 @@ public function testGetDerivativeFetcher() { // Ensure that both test derivatives got added. $this->assertEquals(2, count($definitions)); - $this->assertEquals('non_container_aware_discovery', $definitions['non_container_aware_discovery:test_discovery_0']['id']); - $this->assertEquals('\Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscovery', $definitions['non_container_aware_discovery:test_discovery_0']['derivative']); - - $this->assertEquals('non_container_aware_discovery', $definitions['non_container_aware_discovery:test_discovery_1']['id']); - $this->assertEquals('\Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscovery', $definitions['non_container_aware_discovery:test_discovery_1']['derivative']); - } - - /** - * Tests the getDerivativeFetcher method with objects instead of arrays. - */ - public function testGetDerivativeFetcherWithAnnotationObjects() { - $definitions = array(); - $definitions['non_container_aware_discovery'] = (object) array( - 'id' => 'non_container_aware_discovery', - 'derivative' => '\Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscoveryWithObject', - ); - - $discovery_main = $this->getMock('Drupal\Component\Plugin\Discovery\DiscoveryInterface'); - $discovery_main->expects($this->any()) - ->method('getDefinitions') - ->will($this->returnValue($definitions)); - - $discovery = new DerivativeDiscoveryDecorator($discovery_main); - $definitions = $discovery->getDefinitions(); - - // Ensure that both test derivatives got added. - $this->assertEquals(2, count($definitions)); - $this->assertInstanceOf('\stdClass', $definitions['non_container_aware_discovery:test_discovery_0']); - $this->assertEquals('non_container_aware_discovery', $definitions['non_container_aware_discovery:test_discovery_0']->id); - $this->assertEquals('\Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscoveryWithObject', $definitions['non_container_aware_discovery:test_discovery_0']->derivative); - - $this->assertInstanceOf('\stdClass', $definitions['non_container_aware_discovery:test_discovery_1']); - $this->assertEquals('non_container_aware_discovery', $definitions['non_container_aware_discovery:test_discovery_1']->id); - $this->assertEquals('\Drupal\Tests\Core\Plugin\Discovery\TestDerivativeDiscoveryWithObject', $definitions['non_container_aware_discovery:test_discovery_1']->derivative); } /** @@ -90,7 +56,7 @@ public function testGetDerivativeFetcherWithAnnotationObjects() { * * @see \Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator::getDerivativeFetcher().\ * - * @expectedException \Drupal\Component\Plugin\Exception\InvalidDerivativeClassException + * @expectedException Drupal\Component\Plugin\Exception\InvalidDerivativeClassException */ public function testInvalidDerivativeFetcher() { $definitions = array(); @@ -105,6 +71,6 @@ public function testInvalidDerivativeFetcher() { ->will($this->returnValue($definitions)); $discovery = new DerivativeDiscoveryDecorator($discovery_main); - $discovery->getDefinitions(); + $definitions = $discovery->getDefinitions(); } } diff --git a/core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscovery.php b/core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscovery.php index f1bf083..d0b8218 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscovery.php +++ b/core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscovery.php @@ -17,7 +17,7 @@ class TestDerivativeDiscovery implements DerivativeInterface { /** * {@inheritdoc} */ - public function getDerivativeDefinition($derivative_id, $base_plugin_definition) { + public function getDerivativeDefinition($derivative_id, array $base_plugin_definition) { $definitions = $this->getDerivativeDefinitions($base_plugin_definition); return $definitions[$derivative_id]; } @@ -25,7 +25,7 @@ public function getDerivativeDefinition($derivative_id, $base_plugin_definition) /** * {@inheritdoc} */ - public function getDerivativeDefinitions($base_plugin_definition) { + public function getDerivativeDefinitions(array $base_plugin_definition) { $plugins = array(); for ($i = 0; $i < 2; $i++) { $plugins['test_discovery_' . $i] = $base_plugin_definition; diff --git a/core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscoveryWithObject.php b/core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscoveryWithObject.php deleted file mode 100644 index 1e7e5bc..0000000 --- a/core/tests/Drupal/Tests/Core/Plugin/Discovery/TestDerivativeDiscoveryWithObject.php +++ /dev/null @@ -1,41 +0,0 @@ -getDerivativeDefinitions($base_plugin_definition); - return $definitions[$derivative_id]; - } - - /** - * {@inheritdoc} - * @param array $base_plugin_definition - * @return array - */ - public function getDerivativeDefinitions($base_plugin_definition) { - $plugins = array(); - for ($i = 0; $i < 2; $i++) { - $plugins['test_discovery_' . $i] = $base_plugin_definition; - } - return $plugins; - } - -} diff --git a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php index 8927433..399f223 100644 --- a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php +++ b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php @@ -7,7 +7,6 @@ namespace Drupal\Tests\Core\Theme; -use Drupal\Core\Extension\Extension; use Drupal\Core\Theme\Registry; use Drupal\Tests\UnitTestCase; @@ -76,7 +75,10 @@ protected function setUp() { */ public function testGetRegistryForModule() { $this->setupTheme('test_theme'); - $this->registry->setTheme(new Extension('theme', 'core/modules/system/tests/themes/test_theme/test_theme.info.yml', 'test_theme.theme')); + $this->registry->setTheme((object) array( + 'name' => 'test_theme', + 'filename' => 'core/modules/system/tests/themes/test_theme/test_theme.theme', + )); $this->registry->setBaseThemes(array()); // Include the module so that hook_theme can be called. @@ -118,7 +120,7 @@ protected function setupTheme($theme_name = NULL) { class TestRegistry extends Registry { - public function setTheme(Extension $theme) { + public function setTheme(\stdClass $theme) { $this->theme = $theme; } diff --git a/core/tests/Drupal/Tests/UnitTestCase.php b/core/tests/Drupal/Tests/UnitTestCase.php index f64dca0..ca0968d 100644 --- a/core/tests/Drupal/Tests/UnitTestCase.php +++ b/core/tests/Drupal/Tests/UnitTestCase.php @@ -48,11 +48,12 @@ public static function getInfo() { /** * {@inheritdoc} */ - protected function setUp() { - parent::setUp(); - // Ensure that an instantiated container in the global state of \Drupal from - // a previous test does not leak into this test. - \Drupal::setContainer(NULL); + protected function tearDown() { + parent::tearDown(); + if (\Drupal::getContainer()) { + $container = new ContainerBuilder(); + \Drupal::setContainer($container); + } } /** @@ -190,7 +191,7 @@ public function getStringTranslationStub() { $translation = $this->getMock('Drupal\Core\StringTranslation\TranslationInterface'); $translation->expects($this->any()) ->method('translate') - ->will($this->returnCallback('Drupal\Component\Utility\String::format')); + ->will($this->returnCallback(function ($string, array $args = array()) { return strtr($string, $args); })); return $translation; } diff --git a/core/themes/bartik/bartik.theme b/core/themes/bartik/bartik.theme index 642674c..f90276b 100644 --- a/core/themes/bartik/bartik.theme +++ b/core/themes/bartik/bartik.theme @@ -100,7 +100,7 @@ function bartik_preprocess_maintenance_page(&$variables) { $libraries = array( '#attached' => array( 'library' => array( - 'bartik/maintenance_page', + array('bartik', 'maintenance_page'), ), ), ); @@ -169,8 +169,8 @@ function bartik_field__taxonomy_term_reference($variables) { } /** - * Helper function for handling the site name and slogan. - */ ++ * Helper function for handling the site name and slogan. ++ */ function _bartik_process_page(&$variables) { $site_config = \Drupal::config('system.site'); // Always print the site name and slogan, but if they are toggled off, we'll diff --git a/core/themes/bartik/templates/comment.html.twig b/core/themes/bartik/templates/comment.html.twig index b6d4bb9..ad03eb6 100644 --- a/core/themes/bartik/templates/comment.html.twig +++ b/core/themes/bartik/templates/comment.html.twig @@ -7,11 +7,8 @@ * - author: Comment author. Can be a link or plain text. * - content: The content-related items for the comment display. Use * {{ content }} to print them all, or print a subset such as - * {{ content.field_example }}. Use the following code to temporarily suppress - * the printing of a given child element: - * @code - * {{ content|without('field_example') }} - * @endcode + * {{ content.field_example }}. Use hide(content.field_example) to temporarily + * suppress the printing of a given element. * - created: Formatted date and time for when the comment was created. * Preprocess functions can reformat it by calling format_date() with the * desired parameters on the 'comment.created' variable. @@ -109,7 +106,9 @@ {{ title_suffix }} - {{ content|without('links') }} + {# We hide the links now so that we can render them later. #} + {% hide(content.links) %} + {{ content }}