diff --git a/core/includes/ajax.inc b/core/includes/ajax.inc index 837d0f9..c07d44a 100644 --- a/core/includes/ajax.inc +++ b/core/includes/ajax.inc @@ -5,6 +5,8 @@ * Functions for use with Drupal's Ajax framework. */ +use Drupal\Component\Utility\Json; + /** * @defgroup ajax Ajax framework * @{ @@ -217,7 +219,8 @@ * @code * $commands = array(); * $commands[] = ajax_command_replace(NULL, $output); - * $commands[] = ajax_command_prepend(NULL, theme('status_messages')); + * $status_messages = array('#theme' => 'status_messages'); + * $commands[] = ajax_command_prepend(NULL, drupal_render($status_messages)); * return array('#type' => 'ajax', '#commands' => $commands); * @endcode * @@ -300,7 +303,7 @@ function ajax_render($commands = array()) { // Allow modules to alter any Ajax response. drupal_alter('ajax_render', $commands); - return drupal_json_encode($commands); + return Json::encode($commands); } /** diff --git a/core/includes/batch.inc b/core/includes/batch.inc index 15f82f2..d78248d 100644 --- a/core/includes/batch.inc +++ b/core/includes/batch.inc @@ -411,7 +411,7 @@ function _batch_finished() { if (is_callable($batch_set['finished'])) { $queue = _batch_queue($batch_set); $operations = $queue->getAllItems(); - $batch_set['finished']($batch_set['success'], $batch_set['results'], $operations, format_interval($batch_set['elapsed'] / 1000)); + call_user_func_array($batch_set['finished'], array($batch_set['success'], $batch_set['results'], $operations, format_interval($batch_set['elapsed'] / 1000))); } } } diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index fd24e01..e62c07d 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -491,7 +491,7 @@ function drupal_valid_http_host($host) { */ function drupal_settings_initialize() { // Export these settings.php variables to the global namespace. - global $base_url, $databases, $cookie_domain, $drupal_hash_salt, $config_directories, $config; + global $base_url, $databases, $cookie_domain, $config_directories, $config; $settings = array(); $config = array(); @@ -827,7 +827,9 @@ function drupal_page_is_cacheable($allow_caching = NULL) { * @param $append * Whether to append the value to an existing header or to replace it. * - * @deprecated Header handling is being shifted to a Symfony response object. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Symfony\Component\HttpFoundation\Response->headers->set(). + * See https://drupal.org/node/2181523. */ function drupal_add_http_header($name, $value, $append = FALSE) { // The headers as name/value pairs. @@ -860,7 +862,9 @@ function drupal_add_http_header($name, $value, $append = FALSE) { * A string containing the header value, or FALSE if the header has been set, * or NULL if the header has not been set. * - * @deprecated Header handling is being shifted to a Symfony response object. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Symfony\Component\HttpFoundation\Response->headers->get(). + * See https://drupal.org/node/2181523. */ function drupal_get_http_header($name = NULL) { $headers = &drupal_static('drupal_http_headers', array()); @@ -879,7 +883,8 @@ function drupal_get_http_header($name = NULL) { * Header names are case-insensitive, but for maximum compatibility they should * follow "common form" (see RFC 2616, section 4.2). * - * @deprecated Header handling is being shifted to a Symfony response object. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * See https://drupal.org/node/2181523. */ function _drupal_set_preferred_header_name($name = NULL) { static $header_names = array(); @@ -902,7 +907,8 @@ function _drupal_set_preferred_header_name($name = NULL) { * (optional) If TRUE and headers have already been sent, send only the * specified headers. * - * @deprecated Header handling is being shifted to a Symfony response object. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * See https://drupal.org/node/2181523. */ function drupal_send_headers($default_headers = array(), $only_default = FALSE) { $headers_sent = &drupal_static(__FUNCTION__, FALSE); @@ -958,7 +964,8 @@ function drupal_send_headers($default_headers = array(), $only_default = FALSE) * * @see drupal_page_set_cache() * - * @deprecated Header handling is being shifted to a Symfony response object. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * See https://drupal.org/node/2181523. */ function drupal_page_header() { $headers_sent = &drupal_static(__FUNCTION__, FALSE); @@ -1148,12 +1155,11 @@ function format_string($string, array $args = array()) { /** * Encodes special characters in a plain-text string for display as HTML. * - * @see \Drupal\Component\Utility\String::checkPlain() * @see drupal_validate_utf8() * @ingroup sanitization * - * @deprecated as of Drupal 8.0. Use - * Drupal\Component\Utility\String::checkPlain() directly instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Component\Utility\String::checkPlain(). */ function check_plain($text) { return String::checkPlain($text); @@ -1300,7 +1306,7 @@ function watchdog($type, $message, array $variables = NULL, $severity = WATCHDOG // It is possible that the error handling will itself trigger an error. In that case, we could // end up in an infinite loop. To avoid that, we implement a simple static semaphore. - if (!$in_error_state && function_exists('module_implements')) { + if (!$in_error_state && \Drupal::hasService('module_handler')) { $in_error_state = TRUE; // The user object may not exist in all conditions, so 0 is substituted if needed. @@ -1662,10 +1668,13 @@ function drupal_get_user_timezone() { * A salt based on information in settings.php, not in the database. */ function drupal_get_hash_salt() { - global $drupal_hash_salt, $databases; - // If the $drupal_hash_salt variable is empty, a hash of the serialized - // database credentials is used as a fallback salt. - return empty($drupal_hash_salt) ? hash('sha256', serialize($databases)) : $drupal_hash_salt; + $hash_salt = settings()->get('hash_salt'); + // This should never happen, as it breaks user logins and many other services. + // Therefore, explicitly notify the user (developer) by throwing an exception. + if (empty($hash_salt)) { + throw new \RuntimeException('Missing $settings[\'hash_salt\'] in settings.php.'); + } + return $hash_salt; } /** @@ -1843,8 +1852,8 @@ function drupal_get_bootstrap_phase() { /** * Returns the list of enabled modules. * - * @deprecated as of Drupal 8.0. Use - * \Drupal::moduleHandler()->getModuleList(). + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::moduleHandler()->getModuleList(). * * @see \Drupal\Core\Extension\ModuleHandler::getModuleList() */ @@ -1856,8 +1865,8 @@ function module_list() { /** * Determines which modules are implementing a hook. * - * @deprecated as of Drupal 8.0. Use - * \Drupal::moduleHandler()->getImplementations($hook). + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::moduleHandler()->getImplementations($hook). * * @see \Drupal\Core\Extension\ModuleHandler::getImplementations() */ @@ -1868,13 +1877,13 @@ function module_implements($hook) { /** * Invokes a hook in a particular module. * - * All arguments are passed by value. Use drupal_alter() if you need to pass - * arguments by reference. + * All arguments are passed by value. Use \Drupal::moduleHandler()->alter() if + * you need to pass arguments by reference. * - * @deprecated as of Drupal 8.0. Use + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. Use * \Drupal::moduleHandler()->invoke($module, $hook, $args = array()). * - * @see drupal_alter() + * @see \Drupal\Core\Extension\ModuleHandler::alter() * @see \Drupal\Core\Extension\ModuleHandler::invoke() */ function module_invoke($module, $hook) { @@ -1890,8 +1899,8 @@ function module_invoke($module, $hook) { * All arguments are passed by value. Use drupal_alter() if you need to pass * arguments by reference. * - * @deprecated as of Drupal 8.0. Use - * \Drupal::moduleHandler()->invokeAll($hook). + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::moduleHandler()->invokeAll($hook). * * @see drupal_alter() * @see \Drupal\Core\Extension\ModuleHandler::invokeAll() @@ -1906,8 +1915,8 @@ function module_invoke_all($hook) { /** * Passes alterable variables to specific hook_TYPE_alter() implementations. * - * @deprecated as of Drupal 8.0. Use - * \Drupal::moduleHandler()->alter($hook). + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::moduleHandler()->alter($hook). * * @see \Drupal\Core\Extension\ModuleHandler::alter() */ @@ -1918,8 +1927,8 @@ function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL) { /** * Determines whether a given module exists. * - * @deprecated as of Drupal 8.0. Use - * \Drupal::moduleHandler()->moduleExists($module). + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::moduleHandler()->moduleExists($module). * * @see \Drupal\Core\Extension\ModuleHandler::moduleExists() */ @@ -1930,8 +1939,8 @@ function module_exists($module) { /** * Determines whether a module implements a hook. * - * @deprecated as of Drupal 8.0. Use - * \Drupal::moduleHandler()->implementsHook($module, $hook). + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::moduleHandler()->implementsHook($module, $hook). * * @see \Drupal\Core\Extension\ModuleHandler::implementsHook() */ @@ -2070,8 +2079,8 @@ function drupal_language_initialize() { * @param string $type * The type of language object needed, e.g. Language::TYPE_INTERFACE. * - * @deprecated as of Drupal 8.0. Use - * \Drupal::languageManager()->getCurrentLanguage(). + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::languageManager()->getCurrentLanguage(). */ function language($type) { return \Drupal::languageManager()->getCurrentLanguage($type); @@ -2089,8 +2098,8 @@ function language($type) { * An associative array of languages, keyed by the language code, ordered by * weight ascending and name ascending. * - * @deprecated as of Drupal 8.0. Use - * \Drupal::languageManager()->getLanguages() instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::languageManager()->getLanguages(). */ function language_list($flags = Language::STATE_CONFIGURABLE) { return \Drupal::languageManager()->getLanguages($flags); @@ -2107,8 +2116,8 @@ function language_list($flags = Language::STATE_CONFIGURABLE) { * * @see \Drupal\Core\Language\LanguageManager::getLanguage() * - * @deprecated as of Drupal 8.0. Use \Drupal::languageManager()->getLanguage() - * instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::languageManager()->getLanguage(). */ function language_load($langcode) { return \Drupal::languageManager()->getLanguage($langcode); @@ -2120,8 +2129,10 @@ function language_load($langcode) { * @return \Drupal\Core\Language\Language * A language object. * - * @deprecated as of Drupal 8.0. Use - * \Drupal::languageManager()->getDefaultLanguage() instead. + * @see \Drupal\Core\Language\LanguageManager::getLanguage() + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::languageManager()->getDefaultLanguage(). */ function language_default() { return \Drupal::languageManager()->getDefaultLanguage(); @@ -2621,8 +2632,8 @@ function drupal_check_memory_limit($required, $memory_limit = NULL) { /** * Get locking layer instance. * - * @deprecated Use \Drupal::lock() instead, or even better have the lock service - * injected into your object. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::lock(). * * @return \Drupal\Core\Lock\LockBackendInterface */ diff --git a/core/includes/cache.inc b/core/includes/cache.inc index b39b7ff..771d4d5 100644 --- a/core/includes/cache.inc +++ b/core/includes/cache.inc @@ -24,6 +24,9 @@ * The cache object associated with the specified bin. * * @see \Drupal\Core\Cache\CacheBackendInterface + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::cache(). */ function cache($bin = 'cache') { return \Drupal::cache($bin); @@ -42,7 +45,7 @@ function cache($bin = 'cache') { * @param array $tags * The list of tags to invalidate cache items for. * - * @deprecated 8.x + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. * Use \Drupal\Core\Cache\Cache::invalidateTags(). */ function cache_invalidate_tags(array $tags) { diff --git a/core/includes/common.inc b/core/includes/common.inc index 8fc8c50..43201d8 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -428,7 +428,8 @@ function drupal_get_feeds($delimiter = "\n") { * @return * An array containing query parameters, which can be used for url(). * - * @deprecated as of Drupal 8.0. Use Url::filterQueryParameters() instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Component\Utility\Url::filterQueryParameters(). */ function drupal_get_query_parameters(array $query = NULL, array $exclude = array(), $parent = '') { if (!isset($query)) { @@ -441,10 +442,10 @@ function drupal_get_query_parameters(array $query = NULL, array $exclude = array * Parses an array into a valid, rawurlencoded query string. * * @see drupal_get_query_parameters() - * @deprecated as of Drupal 8.0. Use Url::buildQuery() instead. * @ingroup php_wrappers * - * @deprecated as of Drupal 8.0. Use Url::buildQuery() instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Component\Utility\Url::buildQuery(). */ function drupal_http_build_query(array $query, $parent = '') { return Url::buildQuery($query, $parent); @@ -520,7 +521,8 @@ function drupal_get_destination() { * @see url() * @ingroup php_wrappers * - * @deprecated as of Drupal 8.0. Use Url::parse() instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Component\Utility\Url::parse(). */ function drupal_parse_url($url) { return Url::parse($url); @@ -537,7 +539,8 @@ function drupal_parse_url($url) { * @param $path * The Drupal path to encode. * - * @deprecated as of Drupal 8.0. Use Url::encodePath() instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Component\Utility\Url::encodePath(). */ function drupal_encode_path($path) { return Url::encodePath($path); @@ -552,7 +555,8 @@ function drupal_encode_path($path) { * @return * TRUE if the URL has the same domain and base path. * - * @deprecated as of Drupal 8.0. Use Url::externalIsLocal() instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Component\Utility\Url::externalIsLocal(). */ function _external_url_is_local($url) { return Url::externalIsLocal($url, base_path()); @@ -611,7 +615,8 @@ function valid_email_address($mail) { * * @see \Drupal\Component\Utility\Url::isValid() * - * @deprecated as of Drupal 8.0. Use Url::isValid() instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Component\Utility\Url::isValid(). */ function valid_url($url, $absolute = FALSE) { return Url::isValid($url, $absolute); @@ -633,8 +638,8 @@ function valid_url($url, $absolute = FALSE) { * @return bool * TRUE if no step mismatch has occurred, or FALSE otherwise. * - * @deprecated as of Drupal 8.0. Use - * \Drupal\Component\Utility\Number::validStep() directly instead + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Component\Utility\Number::validStep(). */ function valid_number_step($value, $step, $offset = 0.0) { return Number::validStep($value, $step, $offset); @@ -903,8 +908,10 @@ function format_xml_elements($array) { * * @see t() * @see format_string() + * @see \Drupal\Core\StringTranslation\TranslationManager->formatPlural() * - * @deprecated as of Drupal 8.0. Use \Drupal::translation()->formatPlural() + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::translation()->formatPlural(). */ function format_plural($count, $singular, $plural, array $args = array(), array $options = array()) { return \Drupal::translation()->formatPlural($count, $singular, $plural, $args, $options); @@ -986,7 +993,10 @@ function format_size($size, $langcode = NULL) { * @return * A translated string representation of the interval. * - * @deprecated as of Drupal 8.0. Use \Drupal::service('date')->formatInterval(). + * @see \Drupal\Core\Datetime\Date::formatInterval() + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::service('date')->formatInterval(). */ function format_interval($interval, $granularity = 2, $langcode = NULL) { return \Drupal::service('date')->formatInterval($interval, $granularity, $langcode); @@ -1378,7 +1388,7 @@ function base_path() { * Adds a LINK tag with a distinct 'rel' attribute to the page's HEAD. * * This function can be called as long the HTML header hasn't been sent, which - * on normal pages is up through the preprocess step of theme('html'). Adding + * on normal pages is up through the preprocess step of _theme('html'). Adding * a link will overwrite a prior link with the exact same 'rel' and 'href' * attributes. * @@ -2940,8 +2950,15 @@ function drupal_get_library($extension, $name = NULL) { * into a table. The table must have an ID attribute set. If using * theme_table(), the ID may be set as follows: * @code - * $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'my-module-table'))); - * return $output; + * $table = array( + * '#type' => 'table', + * '#header' => $header, + * '#rows' => $rows, + * '#attributes' => array( + * 'id' => 'my-module-table', + * ), + * ); + * return drupal_render($table); * @endcode * * In the theme function for the form, a special class must be added to each @@ -3088,9 +3105,11 @@ function drupal_clear_js_cache() { * We use HTML-safe strings, with several characters escaped. * * @see drupal_json_decode() + * * @ingroup php_wrappers - * @deprecated as of Drupal 8.0. Use Drupal\Component\Utility\Json::encode() - * directly instead. + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Component\Utility\Json::encode(). */ function drupal_json_encode($var) { return Json::encode($var); @@ -3100,9 +3119,11 @@ function drupal_json_encode($var) { * Converts an HTML-safe JSON string into its PHP equivalent. * * @see drupal_json_encode() + * * @ingroup php_wrappers - * @deprecated as of Drupal 8.0. Use Drupal\Component\Utility\Json::decode() - * directly instead. + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Component\Utility\Json::decode(). */ function drupal_json_decode($var) { return Json::decode($var); @@ -3114,9 +3135,10 @@ function drupal_json_decode($var) { * @return string * The private key. * - * @see \Drupal\Core\Access\CsrfTokenManager + * @see \Drupal\Core\Access\CsrfTokenGenerator * - * @deprecated as of Drupal 8.0. Use the 'private_key' service instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::service('private_key')->get(). */ function drupal_get_private_key() { return \Drupal::service('private_key')->get(); @@ -3139,10 +3161,11 @@ function drupal_get_private_key() { * 'drupal_private_key' configuration variable. * * @see drupal_get_hash_salt() - * @see \Drupal\Core\Access\CsrfTokenManager + * @see \Drupal\Core\Access\CsrfTokenGenerator * @see drupal_session_start() * - * @deprecated as of Drupal 8.0. Use the csrf_token service instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::csrfToken()->get(). */ function drupal_get_token($value = '') { return \Drupal::csrfToken()->get($value); @@ -3162,9 +3185,10 @@ function drupal_get_token($value = '') { * True for a valid token, false for an invalid token. When $skip_anonymous * is true, the return value will always be true for anonymous users. * - * @see \Drupal\Core\Access\CsrfTokenManager + * @see \Drupal\Core\Access\CsrfTokenGenerator * - * @deprecated as of Drupal 8.0. Use the csrf_token service instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use return \Drupal::csrfToken()->validate(). */ function drupal_valid_token($token, $value = '', $skip_anonymous = FALSE) { return \Drupal::csrfToken()->validate($token, $value, $skip_anonymous); @@ -3291,7 +3315,7 @@ function drupal_page_set_cache(Response $response, Request $request) { if ($page_compressed) { $cache->data['body'] = gzencode($cache->data['body'], 9, FORCE_GZIP); } - cache('page')->set($cache->cid, $cache->data, $cache->expire, $cache->tags); + \Drupal::cache('page')->set($cache->cid, $cache->data, $cache->expire, $cache->tags); } return $cache; } @@ -3683,6 +3707,20 @@ function drupal_prepare_page($page) { // 'sidebar_first', 'footer', etc. drupal_alter('page', $page); + // The "main" and "secondary" menus are never part of the page-level render + // array and therefore their cache tags will never bubble up into the page + // cache, even though they should be. This happens because they're rendered + // directly by the theme system. + // @todo Remove this once https://drupal.org/node/1869476 lands. + if (theme_get_setting('features.main_menu') && count(menu_main_menu())) { + $main_links_source = _menu_get_links_source('main_links', 'main'); + $page['page_top']['#cache']['tags']['menu'][$main_links_source] = $main_links_source; + } + if (theme_get_setting('features.secondary_menu') && count(menu_secondary_menu())) { + $secondary_links_source = _menu_get_links_source('secondary_links', 'account'); + $page['page_top']['#cache']['tags']['menu'][$secondary_links_source] = $secondary_links_source; + } + // If no module has taken care of the main content, add it to the page now. // This allows the site to still be usable even if no modules that // control page regions (for example, the Block module) are enabled. @@ -3772,9 +3810,9 @@ function drupal_render_page($page) { * $elements['#sorted'] = TRUE to avoid sorting them a second time. * - The main render phase to produce #children for this element takes place: * - If this element has #theme defined and #theme is an implemented theme - * hook/suggestion then theme() is called and must render both the element - * and its children. If #render_children is set, theme() will not be - * called. #render_children is usually only set internally by theme() so + * hook/suggestion then _theme() is called and must render both the element + * and its children. If #render_children is set, _theme() will not be + * called. #render_children is usually only set internally by _theme() so * that we can avoid the situation where drupal_render() called from * within a theme preprocess function creates an infinite loop. * - If this element does not have a defined #theme, or the defined #theme @@ -3792,7 +3830,7 @@ function drupal_render_page($page) { * drupal_process_attached(). * - If this element has an array of #theme_wrappers defined and * #render_children is not set, #children is then re-rendered by passing the - * element in its current state to theme() successively for each item in + * element in its current state to _theme() successively for each item in * #theme_wrappers. Since #theme and #theme_wrappers hooks often define * variables with the same names it is possible to explicitly override each * attribute passed to each #theme_wrappers hook by setting the hook name as @@ -3852,7 +3890,7 @@ function drupal_render_page($page) { * The rendered HTML. * * @see element_info() - * @see theme() + * @see _theme() * @see drupal_process_states() * @see drupal_process_attached() */ @@ -3925,11 +3963,11 @@ function drupal_render(&$elements, $is_recursive_call = FALSE) { // property is set, do not call the #theme function to prevent infinite // recursion. if ($theme_is_implemented && !isset($elements['#render_children'])) { - $elements['#children'] = theme($elements['#theme'], $elements); + $elements['#children'] = _theme($elements['#theme'], $elements); - // If theme() returns FALSE this means that the hook in #theme was not found - // in the registry and so we need to update our flag accordingly. This is - // common for theme suggestions. + // If _theme() returns FALSE this means that the hook in #theme was not + // found in the registry and so we need to update our flag accordingly. This + // is common for theme suggestions. $theme_is_implemented = ($elements['#children'] !== FALSE); } @@ -3972,7 +4010,7 @@ function drupal_render(&$elements, $is_recursive_call = FALSE) { // If the value of a #theme_wrappers item is an array then the theme hook // is found in the key of the item and the value contains attribute // overrides. Attribute overrides replace key/value pairs in $elements for - // only this theme() call. This allows #theme hooks and #theme_wrappers + // only this _theme() call. This allows #theme hooks and #theme_wrappers // hooks to share variable names without conflict or ambiguity. $wrapper_elements = $elements; if (is_string($key)) { @@ -3985,7 +4023,7 @@ function drupal_render(&$elements, $is_recursive_call = FALSE) { $wrapper_hook = $value; } - $elements['#children'] = theme($wrapper_hook, $wrapper_elements); + $elements['#children'] = _theme($wrapper_hook, $wrapper_elements); } } @@ -4171,7 +4209,7 @@ function drupal_render_cache_get(array $elements) { } $bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'cache'; - if (!empty($cid) && $cache = cache($bin)->get($cid)) { + if (!empty($cid) && $cache = \Drupal::cache($bin)->get($cid)) { $cached_element = $cache->data; // Add additional libraries, JavaScript, CSS and other data attached // to this element. @@ -4225,7 +4263,7 @@ function drupal_render_cache_set(&$markup, array $elements) { $bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'cache'; $expire = isset($elements['#cache']['expire']) ? $elements['#cache']['expire'] : Cache::PERMANENT; $tags = drupal_render_collect_cache_tags($elements); - cache($bin)->set($cid, $data, $expire, $tags); + \Drupal::cache($bin)->set($cid, $data, $expire, $tags); } /** @@ -4513,7 +4551,7 @@ function drupal_cache_tags_page_get(Response $response) { * added to this string and is also part of the cache key in * drupal_render_cache_set() and drupal_render_cache_get(). * @param $expire - * The cache expire time, passed eventually to cache()->set(). + * The cache expire time, passed eventually to \Drupal::cache()->set(). * @param $granularity * One or more granularity constants passed to drupal_render_cid_parts(). * @@ -4625,9 +4663,8 @@ function drupal_render_cid_create($elements) { * @return int * The comparison result for uasort(). * - * @see \Drupal\Component\Utility\SortArray::sortByWeightProperty() - * - * @deprecated as of Drupal 8.0. Use SortArray::sortByWeightProperty() instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Component\Utility\SortArray::sortByWeightProperty(). */ function element_sort($a, $b) { return SortArray::sortByWeightProperty($a, $b); @@ -4649,9 +4686,8 @@ function element_sort($a, $b) { * @return int * The comparison result for uasort(). * - * @see \Drupal\Component\Utility\SortArray::sortByTitleProperty() - * - * @deprecated as of Drupal 8.0. Use SortArray::sortByTitleProperty() instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Component\Utility\SortArray::sortByTitleProperty(). */ function element_sort_by_title($a, $b) { return SortArray::sortByTitleProperty($a, $b); @@ -4712,9 +4748,8 @@ function element_info_property($type, $property_name, $default = NULL) { * @return int * The comparison result for uasort(). * - * @see \Drupal\Component\Utility\SortArray::sortByTitleElement() - * - * @deprecated as of Drupal 8.0. Use SortArray::sortByTitleElement() instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Component\Utility\SortArray::sortByTitleElement(). */ function drupal_sort_title($a, $b) { return SortArray::sortByTitleElement($a, $b); @@ -4723,9 +4758,8 @@ function drupal_sort_title($a, $b) { /** * Checks if the key is a property. * - * @see \Drupal\Core\Render\Element::property() - * - * @deprecated as of Drupal 8.0. Use Element::property() instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Core\Render\Element::property(). */ function element_property($key) { return Element::property($key); @@ -4734,9 +4768,8 @@ function element_property($key) { /** * Gets properties of a structured array element (keys beginning with '#'). * - * @see \Drupal\Core\Render\Element::properties() - * - * @deprecated as of Drupal 8.0. Use Element::properties() instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Core\Render\Element::properties(). */ function element_properties($element) { return Element::properties($element); @@ -4745,9 +4778,8 @@ function element_properties($element) { /** * Checks if the key is a child. * - * @see \Drupal\Core\Render\Element::child() - * - * @deprecated as of Drupal 8.0. Use Element::child() instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Core\Render\Element::child(). */ function element_child($key) { return Element::child($key); @@ -4767,9 +4799,8 @@ function element_child($key) { * @return * The array keys of the element's children. * - * @see \Drupal\Core\Render\Element::children() - * - * @deprecated as of Drupal 8.0. Use Element::children() instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Core\Render\Element::children(). */ function element_children(&$elements, $sort = FALSE) { return Element::children($elements, $sort); @@ -4784,9 +4815,8 @@ function element_children(&$elements, $sort = FALSE) { * @return * The array keys of the element's visible children. * - * @see \Drupal\Core\Render\Element::getVisibleChildren() - * - * @deprecated as of Drupal 8.0. Use Element::getVisibleChildren() instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Core\Render\Element::getVisibleChildren(). */ function element_get_visible_children(array $elements) { return Element::getVisibleChildren($elements); @@ -4804,9 +4834,8 @@ function element_get_visible_children(array $elements) { * except for the leading '#', then an attribute name value is sufficient and * no property name needs to be specified. * - * @see \Drupal\Core\Render\Element::setAttributes() - * - * @deprecated as of Drupal 8.0. Use Element::setAttributes() instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Core\Render\Element::setAttributes(). */ function element_set_attributes(array &$element, array $map) { Element::setAttributes($element, $map); @@ -4823,8 +4852,8 @@ function element_set_attributes(array &$element, array $map) { * * @see \Drupal\Core\Extension\InfoParser::parse(). * - * @deprecated as of Drupal 8.0. Use \Drupal::service('info_parser')->parse() - * instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::service('info_parser')->parse(). */ function drupal_parse_info_file($filename) { return \Drupal::service('info_parser')->parse($filename); @@ -4858,9 +4887,9 @@ function watchdog_severity_levels() { * Explodes a string of tags into an array. * * @see drupal_implode_tags() - * @see \Drupal\Component\Utility\String::explodeTags(). * - * @deprecated as of Drupal 8.0. Use Tags::explode() instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Component\Utility\Tags::explode(). */ function drupal_explode_tags($tags) { return Tags::explode($tags); @@ -4870,9 +4899,9 @@ function drupal_explode_tags($tags) { * Implodes an array of tags into a string. * * @see drupal_explode_tags() - * @see \Drupal\Component\Utility\String::implodeTags(). * - * @deprecated as of Drupal 8.0. Use Tags::implode() instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal\Component\Utility\Tags::implode(). */ function drupal_implode_tags($tags) { return Tags::implode($tags); diff --git a/core/includes/config.inc b/core/includes/config.inc index 9604ee5..c673744 100644 --- a/core/includes/config.inc +++ b/core/includes/config.inc @@ -22,13 +22,13 @@ function config_get_storage_names_with_prefix($prefix = '') { * @code \Drupal::config('book.admin') @endcode will return a configuration * object in which the book module can store its administrative settings. * - * @deprecated Deprecated since Drupal 8.x-dev, to be removed in Drupal 8.0. - * Use \Drupal::config() instead. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::config(). * * @param string $name * The name of the configuration object to retrieve. The name corresponds to - * a configuration file. For @code \Drupal::config('book.admin') @endcode, the - * config object returned will contain the contents of book.admin + * a configuration file. For @code \Drupal::config('book.admin') @endcode, + * the config object returned will contain the contents of book.admin * configuration file. * * @return \Drupal\Core\Config\Config diff --git a/core/includes/entity.inc b/core/includes/entity.inc index c2054c2..9e93990 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -11,33 +11,6 @@ use Drupal\Core\Language\Language; /** - * Gets the entity definition for an entity type. - * - * @param string|null $entity_type - * (optional) The entity type (e.g. 'node'). Leave NULL to retrieve - * information for all entity types. - * - * @return array - * An array containing the entity type's definition, as retrieved with - * \Drupal\Core\Entity\EntityManagerInterface. If $entity_type is NULL, an - * associative array of all entity type definitions keyed by entity type is - * returned. - * - * @see \Drupal\Core\Entity\EntityManagerInterface - * @see hook_entity_info_alter() - * - * @deprecated Use \Drupal\Core\Entity\EntityManagerInterface::getDefinitions() directly. - */ -function entity_get_info($entity_type = NULL) { - if (empty($entity_type)) { - return \Drupal::entityManager()->getDefinitions(); - } - else { - return \Drupal::entityManager()->getDefinition($entity_type); - } -} - -/** * Resets the cached information about entity types. */ function entity_info_cache_clear() { @@ -121,7 +94,7 @@ function entity_get_form_modes($entity_type = NULL) { $form_modes = &drupal_static(__FUNCTION__); if (!$form_modes) { $langcode = language(Language::TYPE_INTERFACE)->id; - if ($cache = cache()->get("entity_form_mode_info:$langcode")) { + if ($cache = \Drupal::cache()->get("entity_form_mode_info:$langcode")) { $form_modes = $cache->data; } else { @@ -131,7 +104,7 @@ function entity_get_form_modes($entity_type = NULL) { $form_modes[$form_mode_entity_type][$form_mode_name] = (array) $form_mode; } drupal_alter('entity_form_mode_info', $form_modes); - cache()->set("entity_form_mode_info:$langcode", $form_modes, Cache::PERMANENT, array('entity_info' => TRUE)); + \Drupal::cache()->set("entity_form_mode_info:$langcode", $form_modes, Cache::PERMANENT, array('entity_types' => TRUE)); } } @@ -159,7 +132,7 @@ function entity_get_view_modes($entity_type = NULL) { $view_modes = &drupal_static(__FUNCTION__); if (!$view_modes) { $langcode = language(Language::TYPE_INTERFACE)->id; - if ($cache = cache()->get("entity_view_mode_info:$langcode")) { + if ($cache = \Drupal::cache()->get("entity_view_mode_info:$langcode")) { $view_modes = $cache->data; } else { @@ -169,7 +142,7 @@ function entity_get_view_modes($entity_type = NULL) { $view_modes[$view_mode_entity_type][$view_mode_name] = (array) $view_mode; } drupal_alter('entity_view_mode_info', $view_modes); - cache()->set("entity_view_mode_info:$langcode", $view_modes, Cache::PERMANENT, array('entity_info' => TRUE)); + \Drupal::cache()->set("entity_view_mode_info:$langcode", $view_modes, Cache::PERMANENT, array('entity_types' => TRUE)); } } @@ -397,7 +370,10 @@ function entity_create($entity_type, array $values = array()) { * * @return \Drupal\Core\Entity\EntityStorageControllerInterface * - * @deprecated Use \Drupal\Core\Entity\EntityManagerInterface::getStorageController(). + * @see \Drupal\Core\Entity\EntityManagerInterface::getStorageController(). + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::entityManager()->getStorageController(). */ function entity_get_controller($entity_type) { return \Drupal::entityManager() @@ -435,7 +411,10 @@ function entity_page_label(EntityInterface $entity, $langcode = NULL) { * @return \Drupal\Core\Entity\EntityAccessControllerInterface * An entity access controller instance. * - * @deprecated Use \Drupal\Core\Entity\EntityManagerInterface::getAccessController(). + * @see \Drupal\Core\Entity\EntityManagerInterface::getAccessController(). + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::entityManager()->getAccessController(). */ function entity_access_controller($entity_type) { return \Drupal::entityManager() @@ -451,7 +430,10 @@ function entity_access_controller($entity_type) { * @return \Drupal\Core\Entity\EntityListControllerInterface * An entity list controller. * - * @deprecated Use \Drupal\Core\Entity\EntityManagerInterface::getFormController(). + * @see \Drupal\Core\Entity\EntityManagerInterface::getListController(). + * + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * Use \Drupal::entityManager()->getListController(). */ function entity_list_controller($entity_type) { return \Drupal::entityManager() diff --git a/core/includes/errors.inc b/core/includes/errors.inc index 208a679..761b7bd 100644 --- a/core/includes/errors.inc +++ b/core/includes/errors.inc @@ -169,7 +169,7 @@ function _drupal_log_error($error, $fatal = FALSE) { } } - if (\Drupal::request()->isXmlHttpRequest()) { + if (\Drupal::hasRequest() && \Drupal::request()->isXmlHttpRequest()) { if ($fatal) { if (error_displayable($error)) { // When called from JavaScript, simply output the error message. @@ -289,7 +289,8 @@ function _drupal_get_error_level() { * @return string * A plain-text line-wrapped string ready to be put inside
.
*
- * @deprecated Use \Drupal\Core\Utility\Error::formatBacktrace() instead.
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal\Core\Utility\Error::formatBacktrace().
*/
function format_backtrace(array $backtrace) {
return Error::formatBacktrace($backtrace);
diff --git a/core/includes/form.inc b/core/includes/form.inc
index 450ce84..96eb0d0 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -106,7 +106,10 @@
/**
* Returns a renderable form array for a given form ID.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->getForm()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->getForm().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::getForm().
*/
function drupal_get_form($form_arg) {
return call_user_func_array(array(\Drupal::formBuilder(), 'getForm'), func_get_args());
@@ -115,7 +118,10 @@ function drupal_get_form($form_arg) {
/**
* Builds and processes a form for a given form ID.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->buildForm()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->buildForm().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::buildForm().
*/
function drupal_build_form($form_id, &$form_state) {
return \Drupal::formBuilder()->buildForm($form_id, $form_state);
@@ -124,7 +130,10 @@ function drupal_build_form($form_id, &$form_state) {
/**
* Retrieves default values for the $form_state array.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->getFormStateDefaults()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->getFormStateDefaults().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::getFormStateDefaults().
*/
function form_state_defaults() {
return \Drupal::formBuilder()->getFormStateDefaults();
@@ -133,7 +142,10 @@ function form_state_defaults() {
/**
* Constructs a new $form from the information in $form_state.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->rebuildForm()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->rebuildForm().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::rebuildForm().
*/
function drupal_rebuild_form($form_id, &$form_state, $old_form = NULL) {
return \Drupal::formBuilder()->rebuildForm($form_id, $form_state, $old_form);
@@ -142,7 +154,10 @@ function drupal_rebuild_form($form_id, &$form_state, $old_form = NULL) {
/**
* Fetches a form from the cache.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->getCache()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->getCache().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::getCache().
*/
function form_get_cache($form_build_id, &$form_state) {
return \Drupal::formBuilder()->getCache($form_build_id, $form_state);
@@ -151,7 +166,10 @@ function form_get_cache($form_build_id, &$form_state) {
/**
* Stores a form in the cache.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->setCache()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->setCache().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::setCache().
*/
function form_set_cache($form_build_id, $form, $form_state) {
\Drupal::formBuilder()->setCache($form_build_id, $form, $form_state);
@@ -209,7 +227,10 @@ function form_load_include(&$form_state, $type, $module, $name = NULL) {
/**
* Retrieves, populates, and processes a form.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->submitForm()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->submitForm().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::submitForm().
*/
function drupal_form_submit($form_arg, &$form_state) {
\Drupal::formBuilder()->submitForm($form_arg, $form_state);
@@ -218,7 +239,10 @@ function drupal_form_submit($form_arg, &$form_state) {
/**
* Retrieves the structured array that defines a given form.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->retrieveForm()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->retrieveForm().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::retrieveForm().
*/
function drupal_retrieve_form($form_id, &$form_state) {
return \Drupal::formBuilder()->retrieveForm($form_id, $form_state);
@@ -227,7 +251,10 @@ function drupal_retrieve_form($form_id, &$form_state) {
/**
* Processes a form submission.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->processForm()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->processForm().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::processForm().
*/
function drupal_process_form($form_id, &$form, &$form_state) {
\Drupal::formBuilder()->processForm($form_id, $form, $form_state);
@@ -236,7 +263,10 @@ function drupal_process_form($form_id, &$form, &$form_state) {
/**
* Prepares a structured form array.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->prepareForm()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->prepareForm().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::prepareForm().
*/
function drupal_prepare_form($form_id, &$form, &$form_state) {
\Drupal::formBuilder()->prepareForm($form_id, $form, $form_state);
@@ -245,7 +275,10 @@ function drupal_prepare_form($form_id, &$form, &$form_state) {
/**
* Validates user-submitted form data in the $form_state array.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->validateForm()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->validateForm().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::validateForm().
*/
function drupal_validate_form($form_id, &$form, &$form_state) {
\Drupal::formBuilder()->validateForm($form_id, $form, $form_state);
@@ -254,7 +287,10 @@ function drupal_validate_form($form_id, &$form, &$form_state) {
/**
* Redirects the user to a URL after a form has been processed.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->redirectForm()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->redirectForm().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::redirectForm().
*/
function drupal_redirect_form($form_state) {
return \Drupal::formBuilder()->redirectForm($form_state);
@@ -263,7 +299,10 @@ function drupal_redirect_form($form_state) {
/**
* Executes custom validation and submission handlers for a given form.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->executeHandlers()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->executeHandlers().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::executeHandlers().
*/
function form_execute_handlers($type, &$form, &$form_state) {
\Drupal::formBuilder()->executeHandlers($type, $form, $form_state);
@@ -272,7 +311,10 @@ function form_execute_handlers($type, &$form, &$form_state) {
/**
* Files an error against a form element.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->setErrorByName()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->setErrorByName().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::setErrorByName().
*/
function form_set_error($name, array &$form_state, $message = '') {
\Drupal::formBuilder()->setErrorByName($name, $form_state, $message);
@@ -281,7 +323,10 @@ function form_set_error($name, array &$form_state, $message = '') {
/**
* Clears all errors against all form elements made by form_set_error().
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->clearErrors()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->clearErrors().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::clearErrors().
*/
function form_clear_error(array &$form_state) {
\Drupal::formBuilder()->clearErrors($form_state);
@@ -290,7 +335,10 @@ function form_clear_error(array &$form_state) {
/**
* Returns an associative array of all errors.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->getErrors()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->getErrors().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::getErrors().
*/
function form_get_errors(array &$form_state) {
return \Drupal::formBuilder()->getErrors($form_state);
@@ -299,7 +347,10 @@ function form_get_errors(array &$form_state) {
/**
* Returns the error message filed against the given form element.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->getError()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->getError().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::getError().
*/
function form_get_error($element, array &$form_state) {
return \Drupal::formBuilder()->getError($element, $form_state);
@@ -308,7 +359,10 @@ function form_get_error($element, array &$form_state) {
/**
* Flags an element as having an error.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->setError()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->setError().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::setError().
*/
function form_error(&$element, array &$form_state, $message = '') {
\Drupal::formBuilder()->setError($element, $form_state, $message);
@@ -317,7 +371,10 @@ function form_error(&$element, array &$form_state, $message = '') {
/**
* Builds and processes all elements in the structured form array.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->doBuildForm()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->doBuildForm().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::doBuildForm().
*/
function form_builder($form_id, &$element, &$form_state) {
return \Drupal::formBuilder()->doBuildForm($form_id, $element, $form_state);
@@ -718,7 +775,10 @@ function form_type_token_value($element, $input = FALSE) {
/**
* Changes submitted form values during form validation.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->setValue()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->setValue().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::setValue().
*/
function form_set_value($element, $value, &$form_state) {
\Drupal::formBuilder()->setValue($element, $value, $form_state);
@@ -737,7 +797,10 @@ function form_set_value($element, $value, &$form_state) {
* @return
* An array with all hierarchical elements flattened to a single array.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::formBuilder()->flattenOptions()
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::formBuilder()->flattenOptions().
+ *
+ * @see \Drupal\Core\Form\FormBuilderInterface::flattenOptions().
*/
function form_options_flatten($array) {
return \Drupal::formBuilder()->flattenOptions($array);
@@ -951,30 +1014,49 @@ function theme_fieldset($variables) {
element_set_attributes($element, array('id'));
_form_set_attributes($element, array('form-wrapper'));
+ $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.
+ // @see theme_form_element_label()
+ $required = '';
+ if (!empty($element['#required'])) {
+ $marker = array(
+ '#theme' => 'form_required_marker',
+ '#element' => $element,
+ );
+ $required = drupal_render($marker);
+ }
+
$legend_attributes = array();
if (isset($element['#title_display']) && $element['#title_display'] == 'invisible') {
$legend_attributes['class'][] = 'visually-hidden';
}
$output = '\n";
@@ -990,7 +1072,7 @@ function theme_fieldset($variables) {
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #attributes, #children, #collapsed, #collapsible,
- * #description, #id, #title, #value.
+ * #description, #id, #title, #value, #optional.
*
* @ingroup themeable
*/
@@ -1259,7 +1341,10 @@ function form_pre_render_conditional_form_element($element) {
}
if (isset($element['#title']) || isset($element['#description'])) {
- $element['#theme_wrappers'][] = 'form_element';
+ // @see #type 'fieldgroup'
+ $element['#theme_wrappers'][] = 'fieldset';
+ $element['#attributes']['class'][] = 'fieldgroup';
+ $element['#attributes']['class'][] = 'form-composite';
}
return $element;
}
@@ -1956,9 +2041,6 @@ function form_process_group(&$element, &$form_state) {
$form_state['groups'][$group][] = &$element;
}
- // Contains form element summary functionalities.
- $element['#attached']['library'][] = array('core', 'drupal.form');
-
return $element;
}
@@ -1985,6 +2067,14 @@ function form_pre_render_details($element) {
$element['#attributes']['open'] = 'open';
}
+ // Do not render optional details elements if there are no children.
+ if (isset($element['#parents'])) {
+ $group = implode('][', $element['#parents']);
+ if (!empty($element['#optional']) && !element_get_visible_children($element['#groups'][$group])) {
+ $element['#printed'] = TRUE;
+ }
+ }
+
return $element;
}
@@ -2025,6 +2115,9 @@ function form_pre_render_group($element) {
}
if (isset($element['#group'])) {
+ // Contains form element summary functionalities.
+ $element['#attached']['library'][] = array('core', 'drupal.form');
+
$group = $element['#group'];
// If this element belongs to a group, but the group-holding element does
// not exist, we need to render it (at its original location).
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index 5b2b7b6..872b55c 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -1255,17 +1255,14 @@ function install_settings_form_submit($form, &$form_state) {
'value' => $database,
'required' => TRUE,
);
- $settings['drupal_hash_salt'] = (object) array(
+ $settings['settings']['hash_salt'] = (object) array(
'value' => Crypt::randomStringHashed(55),
'required' => TRUE,
);
-
// Remember the profile which was used.
- $settings['settings'] = array(
- 'install_profile' => (object) array(
- 'value' => $install_state['parameters']['profile'],
- 'required' => TRUE,
- ),
+ $settings['settings']['install_profile'] = (object) array(
+ 'value' => $install_state['parameters']['profile'],
+ 'required' => TRUE,
);
drupal_rewrite_settings($settings);
diff --git a/core/includes/install.inc b/core/includes/install.inc
index 895f068..d7a7573 100644
--- a/core/includes/install.inc
+++ b/core/includes/install.inc
@@ -7,6 +7,7 @@
use Symfony\Component\HttpFoundation\RedirectResponse;
use Drupal\Component\Utility\Crypt;
+use Drupal\Component\Utility\Settings;
use Drupal\Core\Database\Database;
use Drupal\Core\DrupalKernel;
@@ -199,8 +200,14 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
}
// Build list of setting names and insert the values into the global namespace.
$variable_names = array();
+ $settings_settings = array();
foreach ($settings as $setting => $data) {
- _drupal_rewrite_settings_global($GLOBALS[$setting], $data);
+ if ($setting != 'settings') {
+ _drupal_rewrite_settings_global($GLOBALS[$setting], $data);
+ }
+ else {
+ _drupal_rewrite_settings_global($settings_settings, $data);
+ }
$variable_names['$'. $setting] = $setting;
}
$contents = file_get_contents(DRUPAL_ROOT . '/' . $settings_file);
@@ -307,6 +314,14 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
if (file_put_contents(DRUPAL_ROOT . '/' . $settings_file, $buffer) === FALSE) {
throw new Exception(t('Failed to modify %settings. Verify the file permissions.', array('%settings' => $settings_file)));
}
+ else {
+ // In case any $settings variables were written, import them into the
+ // Settings singleton.
+ if (!empty($settings_settings)) {
+ $old_settings = settings()->getAll();
+ new Settings($settings_settings + $old_settings);
+ }
+ }
}
else {
throw new Exception(t('Failed to open %settings. Verify the file permissions.', array('%settings' => $settings_file)));
@@ -648,8 +663,9 @@ function drupal_install_system($install_state) {
->set('enabled.system', 0)
->save();
- // Update the module list to include it.
+ // Update the module list to include it. Reboot the kernel too.
\Drupal::moduleHandler()->setModuleList(array('system' => $system_path . '/system.module'));
+ $kernel->updateModules(array('system' => $system_path . '/system.module'));
\Drupal::service('config.installer')->installDefaultConfig('module', 'system');
@@ -660,7 +676,7 @@ function drupal_install_system($install_state) {
->save();
}
- module_invoke('system', 'install');
+ \Drupal::moduleHandler()->invoke('system', 'install');
}
/**
@@ -1012,7 +1028,7 @@ function drupal_requirements_severity(&$requirements) {
function drupal_check_module($module) {
module_load_install($module);
// Check requirements
- $requirements = module_invoke($module, 'requirements', 'install');
+ $requirements = \Drupal::moduleHandler()->invoke($module, 'requirements', array('install'));
if (is_array($requirements) && drupal_requirements_severity($requirements) == REQUIREMENT_ERROR) {
// Print any error messages
foreach ($requirements as $requirement) {
diff --git a/core/includes/mail.inc b/core/includes/mail.inc
index 61dfb7e..0209bd5 100644
--- a/core/includes/mail.inc
+++ b/core/includes/mail.inc
@@ -5,6 +5,9 @@
* API functions for processing and sending e-mail.
*/
+use Drupal\Component\Utility\Html;
+use Drupal\Component\Utility\Xss;
+
/**
* Composes and optionally sends an e-mail message.
*
@@ -151,8 +154,9 @@ function drupal_mail($module, $key, $to, $langcode, $params = array(), $reply =
$message['headers'] = $headers;
// Build the e-mail (get subject and body, allow additional headers) by
- // invoking hook_mail() on this module. We cannot use module_invoke() as
- // we need to have $message by reference in hook_mail().
+ // invoking hook_mail() on this module. We cannot use
+ // moduleHandler()->invoke() as we need to have $message by reference in
+ // hook_mail().
if (function_exists($function = $module . '_mail')) {
$function($key, $message, $params);
}
@@ -287,7 +291,7 @@ function drupal_html_to_text($string, $allowed_tags = NULL) {
$allowed_tags = isset($allowed_tags) ? array_intersect($supported_tags, $allowed_tags) : $supported_tags;
// Make sure tags, entities and attributes are well-formed and properly nested.
- $string = _filter_htmlcorrector(filter_xss($string, $allowed_tags));
+ $string = Html::normalize(Xss::filter($string, $allowed_tags));
// Apply inline styles.
$string = preg_replace('!?(em|i)((?> +)[^>]*)?>!i', '/', $string);
diff --git a/core/includes/menu.inc b/core/includes/menu.inc
index 8619448..c491641 100644
--- a/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@ -1047,6 +1047,9 @@ function menu_tree_output($tree) {
// Add the theme wrapper for outer markup.
// Allow menu-specific theme overrides.
$build['#theme_wrappers'][] = 'menu_tree__' . strtr($data['link']['menu_name'], '-', '_');
+ // Set cache tag.
+ $menu_name = $data['link']['menu_name'];
+ $build['#cache']['tags']['menu'][$menu_name] = $menu_name;
}
return $build;
@@ -1083,7 +1086,7 @@ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) {
if (!isset($tree[$cid])) {
// If the static variable doesn't have the data, check {cache_menu}.
- $cache = cache('menu')->get($cid);
+ $cache = \Drupal::cache('menu')->get($cid);
if ($cache && isset($cache->data)) {
// If the cache entry exists, it contains the parameters for
// menu_build_tree().
@@ -1110,7 +1113,7 @@ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) {
}
// Cache the tree building parameters using the page-specific cid.
- cache('menu')->set($cid, $tree_parameters, Cache::PERMANENT, array('menu' => $menu_name));
+ \Drupal::cache('menu')->set($cid, $tree_parameters, Cache::PERMANENT, array('menu' => $menu_name));
}
// Build the tree using the parameters; the resulting tree will be cached
@@ -1228,7 +1231,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail =
if (!isset($tree[$cid])) {
// If the static variable doesn't have the data, check {cache_menu}.
- $cache = cache('menu')->get($cid);
+ $cache = \Drupal::cache('menu')->get($cid);
if ($cache && isset($cache->data)) {
// If the cache entry exists, it contains the parameters for
// menu_build_tree().
@@ -1296,7 +1299,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail =
$tree_parameters['active_trail'] = $active_trail;
}
// Cache the tree building parameters using the page-specific cid.
- cache('menu')->set($cid, $tree_parameters, Cache::PERMANENT, array('menu' => $menu_name));
+ \Drupal::cache('menu')->set($cid, $tree_parameters, Cache::PERMANENT, array('menu' => $menu_name));
}
// Build the tree using the parameters; the resulting tree will be cached
@@ -1364,7 +1367,7 @@ function _menu_build_tree($menu_name, array $parameters = array()) {
// If we do not have this tree in the static cache, check {cache_menu}.
if (!isset($trees[$tree_cid])) {
- $cache = cache('menu')->get($tree_cid);
+ $cache = \Drupal::cache('menu')->get($tree_cid);
if ($cache && isset($cache->data)) {
$trees[$tree_cid] = $cache->data;
}
@@ -1407,7 +1410,7 @@ function _menu_build_tree($menu_name, array $parameters = array()) {
menu_tree_collect_node_links($data['tree'], $data['node_links']);
// Cache the data, if it is not already in the cache.
- cache('menu')->set($tree_cid, $data, Cache::PERMANENT, array('menu' => $menu_name));
+ \Drupal::cache('menu')->set($tree_cid, $data, Cache::PERMANENT, array('menu' => $menu_name));
$trees[$tree_cid] = $data;
}
@@ -1705,10 +1708,7 @@ function menu_list_system_menus() {
* Returns an array of links to be rendered as the Main menu.
*/
function menu_main_menu() {
- $config = \Drupal::config('menu.settings');
- $menu_enabled = \Drupal::moduleHandler()->moduleExists('menu');
- // When menu module is not enabled, we need a hardcoded default value.
- $main_links_source = $menu_enabled ? $config->get('main_links') : 'main';
+ $main_links_source = _menu_get_links_source('main_links', 'main');
return menu_navigation_links($main_links_source);
}
@@ -1716,11 +1716,8 @@ function menu_main_menu() {
* Returns an array of links to be rendered as the Secondary links.
*/
function menu_secondary_menu() {
- $config = \Drupal::config('menu.settings');
- $menu_enabled = \Drupal::moduleHandler()->moduleExists('menu');
- // When menu module is not enabled, we need a hardcoded default value.
- $main_links_source = $menu_enabled ? $config->get('main_links') : 'main';
- $secondary_links_source = $menu_enabled ? $config->get('secondary_links') : 'account';
+ $main_links_source = _menu_get_links_source('main_links', 'main');
+ $secondary_links_source = _menu_get_links_source('secondary_links', 'account');
// If the secondary menu source is set as the primary menu, we display the
// second level of the primary menu.
@@ -1733,6 +1730,22 @@ function menu_secondary_menu() {
}
/**
+ * Returns the source of links of a menu.
+ *
+ * @param string $name
+ * A string configuration key of menu link source.
+ * @param string $default
+ * Default menu name.
+ *
+ * @return string
+ * Returns menu name, if exist
+ */
+function _menu_get_links_source($name, $default) {
+ $config = \Drupal::config('menu.settings');
+ return \Drupal::moduleHandler()->moduleExists('menu') ? $config->get($name) : $default;
+}
+
+/**
* Returns an array of links for a navigation menu.
*
* @param $menu_name
@@ -2351,22 +2364,13 @@ function menu_get_active_trail() {
}
/**
- * Clears the cached cached data for a single named menu.
- */
-function menu_cache_clear($menu_name = 'tools') {
- Cache::deleteTags(array('menu' => $menu_name));
- // Also clear the menu system static caches.
- menu_reset_static_cache();
-}
-
-/**
* Clears all cached menu data.
*
* This should be called any time broad changes
* might have been made to the router items or menu links.
*/
function menu_cache_clear_all() {
- cache('menu')->deleteAll();
+ \Drupal::cache('menu')->deleteAll();
menu_reset_static_cache();
}
@@ -2716,13 +2720,13 @@ function _menu_clear_page_cache() {
// Clear the page and block caches, but at most twice, including at
// the end of the page load when there are multiple links saved or deleted.
if ($cache_cleared == 0) {
- cache_invalidate_tags(array('content' => TRUE));
+ Cache::invalidateTags(array('content' => TRUE));
// Keep track of which menus have expanded items.
_menu_set_expanded_menus();
$cache_cleared = 1;
}
elseif ($cache_cleared == 1) {
- drupal_register_shutdown_function('cache_invalidate_tags', array('content' => TRUE));
+ drupal_register_shutdown_function('Drupal\Core\Cache\Cache::invalidateTags', array('content' => TRUE));
// Keep track of which menus have expanded items.
drupal_register_shutdown_function('_menu_set_expanded_menus');
$cache_cleared = 2;
diff --git a/core/includes/module.inc b/core/includes/module.inc
index 3d03b8e..4c60604 100644
--- a/core/includes/module.inc
+++ b/core/includes/module.inc
@@ -31,7 +31,7 @@
*/
function system_list($type) {
$lists = &drupal_static(__FUNCTION__);
- if ($cached = cache('bootstrap')->get('system_list')) {
+ if ($cached = \Drupal::cache('bootstrap')->get('system_list')) {
$lists = $cached->data;
}
else {
@@ -93,7 +93,7 @@ function system_list($type) {
// Set the theme engine prefix.
$lists['theme'][$key]->prefix = ($lists['theme'][$key]->info['engine'] == 'theme') ? $base_key : $lists['theme'][$key]->info['engine'];
}
- cache('bootstrap')->set('system_list', $lists);
+ \Drupal::cache('bootstrap')->set('system_list', $lists);
}
// To avoid a separate database lookup for the filepath, prime the
// drupal_get_filename() static cache with all enabled modules and themes.
@@ -111,8 +111,8 @@ function system_list_reset() {
drupal_static_reset('system_list');
drupal_static_reset('system_rebuild_module_data');
drupal_static_reset('list_themes');
- cache('bootstrap')->delete('system_list');
- cache()->delete('system_info');
+ \Drupal::cache('bootstrap')->delete('system_list');
+ \Drupal::cache()->delete('system_info');
// Clear the library info cache.
// Libraries may be provided by all extension types, and may be altered by any
@@ -212,8 +212,10 @@ function module_load_include($type, $module, $name = NULL) {
/**
* Installs a given list of modules.
*
- * @deprecated as of Drupal 8.0. Use
- * \Drupal::moduleHandler()->install($module_list, $enable_dependencies = TRUE)
+ * @see \Drupal\Core\Extension\ModuleHandlerInterface::install()
+ *
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. Use
+ * \Drupal::moduleHandler()->install($module_list, $enable_dependencies = TRUE).
*/
function module_install($module_list, $enable_dependencies = TRUE) {
return \Drupal::moduleHandler()->install($module_list, $enable_dependencies);
@@ -222,8 +224,10 @@ function module_install($module_list, $enable_dependencies = TRUE) {
/**
* Installs a given list of modules.
*
- * @deprecated as of Drupal 8.0. Use
- * \Drupal::moduleHandler()->install($module_list, $enable_dependencies = TRUE).
+ * @see \Drupal\Core\Extension\ModuleHandlerInterface::module_install()
+ *
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. Use
+ * \Drupal::moduleHandler()->uninstall($module_list, $enable_dependencies = TRUE).
*/
function module_uninstall($module_list = array(), $uninstall_dependents = TRUE) {
return \Drupal::moduleHandler()->uninstall($module_list, $uninstall_dependents);
diff --git a/core/includes/pager.inc b/core/includes/pager.inc
index 9874689..f90066c 100644
--- a/core/includes/pager.inc
+++ b/core/includes/pager.inc
@@ -36,10 +36,10 @@ function pager_find_page($element = 0) {
}
/**
- * Initializes a pager for theme('pager').
+ * Initializes a pager for _theme('pager').
*
* This function sets up the necessary global variables so that future calls
- * to theme('pager') will render a pager that correctly corresponds to the
+ * to _theme('pager') will render a pager that correctly corresponds to the
* items being displayed.
*
* If the items being displayed result from a database query performed using
@@ -67,10 +67,14 @@ function pager_find_page($element = 0) {
* // Next, retrieve and display the items for the current page.
* $offset = $num_per_page * $page;
* $result = mymodule_select("SELECT * FROM data " . $where . " LIMIT %d, %d", $offset, $num_per_page)->fetchAll();
- * $output = theme('mymodule_results', array('result' => $result));
+ * $output = drupal_render(
+ * '#theme' => 'mymodule_results',
+ * '#result' => $result,
+ * );
*
* // Finally, display the pager controls, and return.
- * $output .= theme('pager');
+ * $pager = array('#theme' => 'pager');
+ * $output .= drupal_render($pager);
* return $output;
* @endcode
*
@@ -93,10 +97,16 @@ function pager_find_page($element = 0) {
* pager_default_initialize($result->total, $num_per_page);
*
* // Display the search results.
- * $output = theme('search_results', array('results' => $result->data, 'type' => 'remote'));
+ * $search_results = array(
+ * '#theme' => 'search_results',
+ * '#results' => $result->data,
+ * '#type' => 'remote',
+ * );
+ * $output = drupal_render($search_results);
*
* // Finally, display the pager controls, and return.
- * $output .= theme('pager');
+ * $pager = array('#theme' => 'pager');
+ * $output .= drupal_render($pager);
* return $output;
* @endcode
*
@@ -148,9 +158,9 @@ function pager_get_query_parameters() {
*
* Default template: pager.html.twig.
*
- * Menu callbacks that display paged query results should call theme('pager') to
- * retrieve a pager control so that users can view other results. Format a list
- * of nearby pages with additional query results.
+ * Menu callbacks that display paged query results should call _theme('pager')
+ * to retrieve a pager control so that users can view other results. Format a
+ * list of nearby pages with additional query results.
*
* @param array $variables
* An associative array containing:
diff --git a/core/includes/schema.inc b/core/includes/schema.inc
index bb1c6e6..c9ee6ae 100644
--- a/core/includes/schema.inc
+++ b/core/includes/schema.inc
@@ -65,7 +65,7 @@ function drupal_get_complete_schema($rebuild = FALSE) {
if (!isset($schema) || $rebuild) {
// Try to load the schema from cache.
- if (!$rebuild && $cached = cache()->get('schema')) {
+ if (!$rebuild && $cached = \Drupal::cache()->get('schema')) {
$schema = $cached->data;
}
// Otherwise, rebuild the schema cache.
@@ -80,9 +80,9 @@ function drupal_get_complete_schema($rebuild = FALSE) {
// Cast the result of hook_schema() to an array, as a NULL return value
// would cause array_merge() to set the $schema variable to NULL as well.
// That would break modules which use $schema further down the line.
- $current = (array) module_invoke($module, 'schema');
+ $current = (array) \Drupal::moduleHandler()->invoke($module, 'schema');
// Set 'module' and 'name' keys for each table, and remove descriptions,
- // as they needlessly slow down cache()->get() for every single request.
+ // as they needlessly slow down \Drupal::cache()->get() for every single request.
_drupal_schema_initialize($current, $module);
$schema = array_merge($schema, $current);
}
@@ -94,7 +94,7 @@ function drupal_get_complete_schema($rebuild = FALSE) {
// If the schema is empty, avoid saving it: some database engines require
// the schema to perform queries, and this could lead to infinite loops.
if (!empty($schema) && (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL)) {
- cache()->set('schema', $schema, Cache::PERMANENT, array('schema' => TRUE));
+ \Drupal::cache()->set('schema', $schema, Cache::PERMANENT, array('schema' => TRUE));
}
}
}
@@ -268,7 +268,7 @@ function drupal_uninstall_schema($module) {
function drupal_get_schema_unprocessed($module, $table = NULL) {
// Load the .install file to get hook_schema.
module_load_install($module);
- $schema = module_invoke($module, 'schema');
+ $schema = \Drupal::moduleHandler()->invoke($module, 'schema');
if (isset($table)) {
if (isset($schema[$table])) {
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index c65ba3b..e91ecf2 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -72,7 +72,10 @@
* Boolean TRUE if the theme is enabled or is the site administration theme;
* FALSE otherwise.
*
- * @deprecated Use \Drupal::service('access_check.theme')->checkAccess().
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::service('access_check.theme')->checkAccess().
+ *
+ * @see \Drupal\Core\Theme\ThemeAccessCheck::checkAccess().
*/
function drupal_theme_access($theme) {
if (is_object($theme)) {
@@ -362,7 +365,10 @@ function drupal_theme_rebuild() {
* names. This element is not set if there are no themes on the system that
* declare this theme as their base theme.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::service('theme_handler')->listInfo().
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::service('theme_handler')->listInfo().
+ *
+ * @see \Drupal\Core\Extension\ThemeHandler::listInfo().
*/
function list_themes($refresh = FALSE) {
/** @var \Drupal\Core\Extension\ThemeHandler $theme_handler */
@@ -391,7 +397,10 @@ function list_themes($refresh = FALSE) {
* Returns an array of all of the theme's ancestors; the first element's value
* will be NULL if an error occurred.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::service('theme_handler')->getBaseThemes().
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::service('theme_handler')->getBaseThemes().
+ *
+ * @see \Drupal\Core\Extension\ThemeHandler::getBaseThemes().
*/
function drupal_find_base_themes($themes, $key) {
return \Drupal::service('theme_handler')->getBaseThemes($themes, $key);
@@ -401,15 +410,15 @@ function drupal_find_base_themes($themes, $key) {
* Generates themed output.
*
* All requests for themed output must go through this function (however,
- * calling the theme() function directly is strongly discouraged - see next
- * paragraph). It examines the request and routes it to the appropriate
+ * 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
+ * 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().
+ * _theme().
*
* @section sec_theme_hooks Theme Hooks
* Most commonly, the first argument to this function is the name of the theme
@@ -473,21 +482,21 @@ function drupal_find_base_themes($themes, $key) {
* 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).
+ * 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.
+ * 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
* double-underscore ('__') and there isn't an implementation for the full
* name, the part before the '__' is checked. This allows a fallback to a
- * more generic implementation. For example, if theme('links__node', ...) is
+ * more generic implementation. For example, if _theme('links__node', ...) is
* called, but there is no implementation of that theme hook, then the
* 'links' implementation is used. This process is iterative, so if
- * theme('links__contextual__node', ...) is called, theme() checks for the
+ * _theme('links__contextual__node', ...) is called, _theme() checks for the
* following implementations, and uses the first one that exists:
* - links__contextual__node
* - links__contextual
@@ -495,7 +504,7 @@ function drupal_find_base_themes($themes, $key) {
* This allows themes to create specific theme implementations for named
* objects and contexts of otherwise generic theme hooks. The $hook parameter
* may also be an array, in which case the first theme hook that has an
- * implementation is used. This allows for the code that calls theme() to
+ * implementation is used. This allows for the code that calls _theme() to
* explicitly specify the fallback order in a situation where using the '__'
* convention is not desired or is insufficient.
* @param $variables
@@ -514,13 +523,13 @@ function drupal_find_base_themes($themes, $key) {
* @see hook_theme()
* @see template_preprocess()
*/
-function theme($hook, $variables = array()) {
+function _theme($hook, $variables = array()) {
static $default_attributes;
// If called before all modules are loaded, we do not necessarily have a full
// theme registry to work with, and therefore cannot process the theme
// request properly. See also \Drupal\Core\Theme\Registry::get().
if (!\Drupal::moduleHandler()->isLoaded() && !defined('MAINTENANCE_MODE')) {
- throw new Exception(t('theme() may not be called until all modules are loaded.'));
+ throw new Exception(t('_theme() may not be called until all modules are loaded.'));
}
/** @var \Drupal\Core\Utility\ThemeRegistry $theme_registry */
@@ -558,7 +567,7 @@ function theme($hook, $variables = array()) {
watchdog('theme', 'Theme hook %hook not found.', array('%hook' => $hook), WATCHDOG_WARNING);
}
// There is no theme implementation for the hook passed. Return FALSE so
- // the function calling theme() can differentiate between a hook that
+ // the function calling _theme() can differentiate between a hook that
// exists and renders an empty string and a hook that is not implemented.
return FALSE;
}
@@ -622,7 +631,7 @@ function theme($hook, $variables = array()) {
// Invoke hook_theme_suggestions_HOOK().
$suggestions = Drupal::moduleHandler()->invokeAll('theme_suggestions_' . $base_theme_hook, array($variables));
- // If theme() was invoked with a direct theme suggestion like
+ // If _theme() was invoked with a direct theme suggestion like
// '#theme' => 'node__article', add it to the suggestions array before
// invoking suggestion alter hooks.
if (isset($info['base hook'])) {
@@ -638,8 +647,8 @@ function theme($hook, $variables = array()) {
\Drupal::moduleHandler()->alter($hooks, $suggestions, $variables, $base_theme_hook);
// Check if each suggestion exists in the theme registry, and if so,
- // use it instead of the hook that theme() was called with. For example, a
- // function may call theme('node', ...), but a module can add
+ // use it instead of the hook that _theme() was called with. For example, a
+ // function may call _theme('node', ...), but a module can add
// 'node__article' as a suggestion via hook_theme_suggestions_HOOK_alter(),
// enabling a theme to have an alternate template file for article nodes.
foreach (array_reverse($suggestions) as $suggestion) {
@@ -1089,7 +1098,10 @@ function theme_settings_convert_to_config(array $theme_settings, Config $config)
* @param $theme_list
* An array of theme names.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::service('theme_handler')->enable().
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::service('theme_handler')->enable().
+ *
+ * @see \Drupal\Core\Extension\ThemeHandler::enable().
*/
function theme_enable($theme_list) {
\Drupal::service('theme_handler')->enable($theme_list);
@@ -1101,7 +1113,10 @@ function theme_enable($theme_list) {
* @param $theme_list
* An array of theme names.
*
- * @deprecated as of Drupal 8.0. Use \Drupal::service('theme_handler')->disable().
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal::service('theme_handler')->disable().
+ *
+ * @see \Drupal\Core\Extension\ThemeHandler::disable().
*/
function theme_disable($theme_list) {
\Drupal::service('theme_handler')->disable($theme_list);
@@ -1352,7 +1367,7 @@ function template_preprocess_links(&$variables) {
* to an empty string, but can be set to NULL for the attribute to be
* omitted. Usually, neither omission nor an empty string satisfies
* accessibility requirements, so it is strongly encouraged for code
- * calling theme('image') to pass a meaningful value for this variable.
+ * calling _theme('image') to pass a meaningful value for this variable.
* - http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.8
* - http://www.w3.org/TR/xhtml1/dtds.html
* - http://dev.w3.org/html5/spec/Overview.html#alt
@@ -1956,10 +1971,10 @@ function _theme_table_cell($cell, $header = FALSE) {
* This function is called for theme hooks implemented as templates only, not
* for theme hooks implemented as functions. This preprocess function is the
* first in the sequence of preprocessing functions that are called when
- * preparing variables for a template. See theme() for more details about the
+ * preparing variables for a template. See _theme() for more details about the
* full sequence.
*
- * @see theme()
+ * @see _theme()
*/
function template_preprocess(&$variables, $hook, $info) {
// Tell all templates where they are located.
@@ -2562,10 +2577,10 @@ function drupal_common_theme() {
// HTML 4 and XHTML 1.0 always require an alt attribute. The HTML 5 draft
// allows the alt attribute to be omitted in some cases. Therefore,
// default the alt attribute to an empty string, but allow code calling
- // theme('image') to pass explicit NULL for it to be omitted. Usually,
+ // _theme('image') to pass explicit NULL for it to be omitted. Usually,
// neither omission nor an empty string satisfies accessibility
// requirements, so it is strongly encouraged for code calling
- // theme('image') to pass a meaningful value for the alt variable.
+ // _theme('image') to pass a meaningful value for the alt variable.
// - http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.8
// - http://www.w3.org/TR/xhtml1/dtds.html
// - http://dev.w3.org/html5/spec/Overview.html#alt
diff --git a/core/includes/update.inc b/core/includes/update.inc
index c3bc07a..3431886 100644
--- a/core/includes/update.inc
+++ b/core/includes/update.inc
@@ -426,9 +426,9 @@ function update_get_update_list() {
// Otherwise, get the list of updates defined by this module.
$updates = drupal_get_schema_versions($module);
if ($updates !== FALSE) {
- // module_invoke returns NULL for nonexisting hooks, so if no updates
- // are removed, it will == 0.
- $last_removed = module_invoke($module, 'update_last_removed');
+ // \Drupal::moduleHandler()->invoke() returns NULL for nonexisting hooks,
+ // so if no updates are removed, it will == 0.
+ $last_removed = \Drupal::moduleHandler()->invoke($module, 'update_last_removed');
if ($schema_version < $last_removed) {
$ret[$module]['warning'] = '' . $module . ' module cannot be updated. Its schema version is ' . $schema_version . '. Updates up to and including ' . $last_removed . ' have been removed in this release. In order to update ' . $module . ' module, you will first need to upgrade to the last version in which these updates were available.';
continue;
diff --git a/core/includes/utility.inc b/core/includes/utility.inc
index 023ecb0..b18c941 100644
--- a/core/includes/utility.inc
+++ b/core/includes/utility.inc
@@ -20,7 +20,8 @@
* @return string
* The variable exported in a way compatible to Drupal's coding standards.
*
- * @deprecated Use \Drupal\Component\Utility\Variable::export().
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal\Component\Utility\Variable::export().
*/
function drupal_var_export($var, $prefix = '') {
return Variable::export($var, $prefix);
diff --git a/core/lib/Drupal.php b/core/lib/Drupal.php
index f07ea7f..6127738 100644
--- a/core/lib/Drupal.php
+++ b/core/lib/Drupal.php
@@ -150,6 +150,16 @@ public static function hasService($id) {
}
/**
+ * Indicates if there is a currently active request object.
+ *
+ * @return bool
+ * TRUE if there is a currently active request object, FALSE otherwise.
+ */
+ public static function hasRequest() {
+ return static::$container && static::$container->has('request') && static::$container->initialized('request') && static::$container->isScopeActive('request');
+ }
+
+ /**
* Retrieves the currently active request object.
*
* Note: The use of this wrapper in particular is especially discouraged. Most
diff --git a/core/lib/Drupal/Component/Utility/Html.php b/core/lib/Drupal/Component/Utility/Html.php
new file mode 100644
index 0000000..bc0a916
--- /dev/null
+++ b/core/lib/Drupal/Component/Utility/Html.php
@@ -0,0 +1,137 @@
+
+
+
+!html
+
+EOD;
+ // PHP's \DOMDocument serialization adds straw whitespace in case the markup
+ // of the wrapping document contains newlines, so ensure to remove all
+ // newlines before injecting the actual HTML body to process.
+ $document = strtr($document, array("\n" => '', '!html' => $html));
+
+ $dom = new \DOMDocument();
+ // Ignore warnings during HTML soup loading.
+ @$dom->loadHTML($document);
+
+ return $dom;
+ }
+
+ /**
+ * Converts the body of a \DOMDocument back to an HTML snippet.
+ *
+ * The function serializes the body part of a \DOMDocument back to an (X)HTML
+ * snippet. The resulting (X)HTML snippet will be properly formatted to be
+ * compatible with HTML user agents.
+ *
+ * @param \DOMDocument $document
+ * A \DOMDocument object to serialize, only the tags below the first
+ * node will be converted.
+ *
+ * @return string
+ * A valid (X)HTML snippet, as a string.
+ */
+ public static function serialize(\DOMDocument $document) {
+ $body_node = $document->getElementsByTagName('body')->item(0);
+ $html = '';
+
+ foreach ($body_node->getElementsByTagName('script') as $node) {
+ static::escapeCdataElement($node);
+ }
+ foreach ($body_node->getElementsByTagName('style') as $node) {
+ static::escapeCdataElement($node, '/*', '*/');
+ }
+ foreach ($body_node->childNodes as $node) {
+ $html .= $document->saveXML($node);
+ }
+ return $html;
+ }
+
+ /**
+ * Adds comments around a childNodes as $child_node) {
+ if ($child_node instanceof \DOMCdataSection) {
+ $embed_prefix = "\n{$comment_end}\n";
+
+ // Prevent invalid cdata escaping as this would throw a DOM error.
+ // This is the same behavior as found in libxml2.
+ // Related W3C standard: http://www.w3.org/TR/REC-xml/#dt-cdsection
+ // Fix explanation: http://en.wikipedia.org/wiki/CDATA#Nesting
+ $data = str_replace(']]>', ']]]]>', $child_node->data);
+
+ $fragment = $node->ownerDocument->createDocumentFragment();
+ $fragment->appendXML($embed_prefix . $data . $embed_suffix);
+ $node->appendChild($fragment);
+ $node->removeChild($child_node);
+ }
+ }
+ }
+
+}
diff --git a/core/lib/Drupal/Component/Utility/Json.php b/core/lib/Drupal/Component/Utility/Json.php
index 54614b5..88e55ae 100644
--- a/core/lib/Drupal/Component/Utility/Json.php
+++ b/core/lib/Drupal/Component/Utility/Json.php
@@ -40,7 +40,6 @@ public static function encode($variable) {
* @return mixed
* Returns the decoded string.
*
- * @see drupal_json_encode()
* @ingroup php_wrappers
*/
public static function decode($string) {
diff --git a/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php
index 5f920d4..cdaf1d8 100644
--- a/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php
+++ b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php
@@ -7,6 +7,7 @@
namespace Drupal\Core\Asset;
use Drupal\Core\KeyValueStore\StateInterface;
+use Drupal\Component\Utility\Json;
/**
* Renders JavaScript assets.
@@ -67,7 +68,7 @@ public function render(array $js_assets) {
switch ($js_asset['type']) {
case 'setting':
$element['#value_prefix'] = $embed_prefix;
- $element['#value'] = 'var drupalSettings = ' . drupal_json_encode(drupal_merge_js_settings($js_asset['data'])) . ";";
+ $element['#value'] = 'var drupalSettings = ' . Json::encode(drupal_merge_js_settings($js_asset['data'])) . ";";
$element['#value_suffix'] = $embed_suffix;
break;
diff --git a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php
index 0046918..3bdbc64 100644
--- a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php
+++ b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php
@@ -38,8 +38,8 @@
* To access your custom cache bin, specify the name of the bin when storing
* or retrieving cached data:
* @code
- * cache('custom_bin')->set($cid, $data, $expire);
- * cache('custom_bin')->get($cid);
+ * \Drupal::cache('custom_bin')->set($cid, $data, $expire);
+ * \Drupal::cache('custom_bin')->get($cid);
* @endcode
*
* There are two ways to "remove" a cache item:
@@ -66,7 +66,7 @@
* the other requests can proceed using the stale value. As soon as the cache
* item has been updated, all future requests will use the updated value.
*
- * @see cache()
+ * @see \Drupal::cache()
* @see \Drupal\Core\Cache\DatabaseBackend
*/
interface CacheBackendInterface {
diff --git a/core/lib/Drupal/Core/Config/BatchConfigImporter.php b/core/lib/Drupal/Core/Config/BatchConfigImporter.php
new file mode 100644
index 0000000..b5cf1dc
--- /dev/null
+++ b/core/lib/Drupal/Core/Config/BatchConfigImporter.php
@@ -0,0 +1,88 @@
+validate();
+
+ if (!$this->lock->acquire(static::ID)) {
+ // Another process is synchronizing configuration.
+ throw new ConfigImporterException(sprintf('%s is already importing', static::ID));
+ }
+ $this->totalToProcess = 0;
+ foreach(array('create', 'delete', 'update') as $op) {
+ $this->totalToProcess += count($this->getUnprocessed($op));
+ }
+ }
+
+ /**
+ * Processes batch.
+ *
+ * @param array $context.
+ * The batch context.
+ */
+ public function processBatch(array &$context) {
+ $operation = $this->getNextOperation();
+ if (!empty($operation)) {
+ $this->process($operation['op'], $operation['name']);
+ $context['message'] = t('Synchronizing @name.', array('@name' => $operation['name']));
+ $context['finished'] = $this->batchProgress();
+ }
+ else {
+ $context['finished'] = 1;
+ }
+ if ($context['finished'] >= 1) {
+ $this->notify('import');
+ // The import is now complete.
+ $this->lock->release(static::ID);
+ $this->reset();
+ }
+ }
+
+ /**
+ * Gets percentage of progress made.
+ *
+ * @return float
+ * The percentage of progress made expressed as a float between 0 and 1.
+ */
+ protected function batchProgress() {
+ $processed_count = count($this->processed['create']) + count($this->processed['delete']) + count($this->processed['update']);
+ return $processed_count / $this->totalToProcess;
+ }
+
+ /**
+ * Gets the next operation to perform.
+ *
+ * @return array|bool
+ * An array containing the next operation and configuration name to perform
+ * it on. If there is nothing left to do returns FALSE;
+ */
+ protected function getNextOperation() {
+ foreach(array('create', 'delete', 'update') as $op) {
+ $names = $this->getUnprocessed($op);
+ if (!empty($names)) {
+ return array(
+ 'op' => $op,
+ 'name' => array_shift($names),
+ );
+ }
+ }
+ return FALSE;
+ }
+}
diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php
index d159034..b91964e 100644
--- a/core/lib/Drupal/Core/Config/ConfigImporter.php
+++ b/core/lib/Drupal/Core/Config/ConfigImporter.php
@@ -7,6 +7,7 @@
namespace Drupal\Core\Config;
+use Drupal\Core\DependencyInjection\DependencySerialization;
use Drupal\Core\Lock\LockBackendInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -29,7 +30,7 @@
*
* @see \Drupal\Core\Config\ConfigImporterEvent
*/
-class ConfigImporter {
+class ConfigImporter extends DependencySerialization {
/**
* The name used to identify events and the lock.
@@ -204,8 +205,15 @@ public function import() {
// Another process is synchronizing configuration.
throw new ConfigImporterException(sprintf('%s is already importing', static::ID));
}
- $this->importInvokeOwner();
- $this->importConfig();
+ // First pass deleted, then new, and lastly changed configuration, in order
+ // to handle dependencies correctly.
+ // @todo Implement proper dependency ordering using
+ // https://drupal.org/node/2080823
+ foreach (array('delete', 'create', 'update') as $op) {
+ foreach ($this->getUnprocessed($op) as $name) {
+ $this->process($op, $name);
+ }
+ }
// Allow modules to react to a import.
$this->notify('import');
@@ -234,63 +242,84 @@ public function validate() {
}
/**
- * Writes an array of config changes from the source to the target storage.
+ * Processes a configuration change.
+ *
+ * @param string $op
+ * The change operation.
+ * @param string $name
+ * The name of the configuration to process.
*/
- protected function importConfig() {
- foreach (array('delete', 'create', 'update') as $op) {
- foreach ($this->getUnprocessed($op) as $name) {
- $config = new Config($name, $this->storageComparer->getTargetStorage(), $this->eventDispatcher, $this->typedConfigManager);
- if ($op == 'delete') {
- $config->delete();
- }
- else {
- $data = $this->storageComparer->getSourceStorage()->read($name);
- $config->setData($data ? $data : array());
- $config->save();
- }
- $this->setProcessed($op, $name);
- }
+ protected function process($op, $name) {
+ if (!$this->importInvokeOwner($op, $name)) {
+ $this->importConfig($op, $name);
}
}
/**
+ * Writes a configuration change from the source to the target storage.
+ *
+ * @param string $op
+ * The change operation.
+ * @param string $name
+ * The name of the configuration to process.
+ */
+ protected function importConfig($op, $name) {
+ $config = new Config($name, $this->storageComparer->getTargetStorage(), $this->eventDispatcher, $this->typedConfigManager);
+ if ($op == 'delete') {
+ $config->delete();
+ }
+ else {
+ $data = $this->storageComparer->getSourceStorage()->read($name);
+ $config->setData($data ? $data : array());
+ $config->save();
+ }
+ $this->setProcessed($op, $name);
+ }
+
+ /**
* Invokes import* methods on configuration entity storage controllers.
*
* Allow modules to take over configuration change operations for higher-level
* configuration data.
*
* @todo Add support for other extension types; e.g., themes etc.
+ *
+ * @param string $op
+ * The change operation to get the unprocessed list for, either delete,
+ * create or update.
+ * @param string $name
+ * The name of the configuration to process.
+ *
+ * @return bool
+ * TRUE if the configuration was imported as a configuration entity. FALSE
+ * otherwise.
*/
- protected function importInvokeOwner() {
- // First pass deleted, then new, and lastly changed configuration, in order
- // to handle dependencies correctly.
- foreach (array('delete', 'create', 'update') as $op) {
- foreach ($this->getUnprocessed($op) as $name) {
- // Call to the configuration entity's storage controller to handle the
- // configuration change.
- $handled_by_module = FALSE;
- // Validate the configuration object name before importing it.
- // Config::validateName($name);
- if ($entity_type = $this->configManager->getEntityTypeIdByName($name)) {
- $old_config = new Config($name, $this->storageComparer->getTargetStorage(), $this->eventDispatcher, $this->typedConfigManager);
- if ($old_data = $this->storageComparer->getTargetStorage()->read($name)) {
- $old_config->initWithData($old_data);
- }
-
- $data = $this->storageComparer->getSourceStorage()->read($name);
- $new_config = new Config($name, $this->storageComparer->getTargetStorage(), $this->eventDispatcher, $this->typedConfigManager);
- if ($data !== FALSE) {
- $new_config->setData($data);
- }
-
- $method = 'import' . ucfirst($op);
- $handled_by_module = $this->configManager->getEntityManager()->getStorageController($entity_type)->$method($name, $new_config, $old_config);
- }
- if (!empty($handled_by_module)) {
- $this->setProcessed($op, $name);
- }
+ protected function importInvokeOwner($op, $name) {
+ // Call to the configuration entity's storage controller to handle the
+ // configuration change.
+ $handled_by_module = FALSE;
+ // Validate the configuration object name before importing it.
+ // Config::validateName($name);
+ if ($entity_type = $this->configManager->getEntityTypeIdByName($name)) {
+ $old_config = new Config($name, $this->storageComparer->getTargetStorage(), $this->eventDispatcher, $this->typedConfigManager);
+ if ($old_data = $this->storageComparer->getTargetStorage()->read($name)) {
+ $old_config->initWithData($old_data);
+ }
+
+ $data = $this->storageComparer->getSourceStorage()->read($name);
+ $new_config = new Config($name, $this->storageComparer->getTargetStorage(), $this->eventDispatcher, $this->typedConfigManager);
+ if ($data !== FALSE) {
+ $new_config->setData($data);
}
+
+ $method = 'import' . ucfirst($op);
+ $handled_by_module = $this->configManager->getEntityManager()->getStorageController($entity_type)->$method($name, $new_config, $old_config);
+ }
+ if (!empty($handled_by_module)) {
+ $this->setProcessed($op, $name);
+ return TRUE;
}
+ return FALSE;
}
/**
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
index cd870f2..e8dcff4 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
@@ -35,6 +35,13 @@
public $status = TRUE;
/**
+ * The UUID for this entity.
+ *
+ * @var string
+ */
+ public $uuid;
+
+ /**
* Whether the config is being created, updated or deleted through the
* import process.
*
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php
new file mode 100644
index 0000000..c72b707
--- /dev/null
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php
@@ -0,0 +1,68 @@
+ 'Drupal\Core\Config\Entity\ConfigStorageController',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getConfigPrefix() {
+ return isset($this->config_prefix) ? $this->config_prefix : FALSE;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBaseTable() {
+ return FALSE;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getRevisionDataTable() {
+ return FALSE;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getRevisionTable() {
+ return FALSE;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getDataTable() {
+ return FALSE;
+ }
+
+}
diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
index 6b717b7..46db8c7 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php
@@ -389,9 +389,9 @@ public function save(EntityInterface $entity) {
*/
protected function invokeHook($hook, EntityInterface $entity) {
// Invoke the hook.
- module_invoke_all($this->entityTypeId . '_' . $hook, $entity);
+ $this->moduleHandler->invokeAll($this->entityTypeId . '_' . $hook, array($entity));
// Invoke the respective entity-level hook.
- module_invoke_all('entity_' . $hook, $entity, $this->entityTypeId);
+ $this->moduleHandler->invokeAll('entity_' . $hook, array($entity, $this->entityTypeId));
}
/**
diff --git a/core/lib/Drupal/Core/Config/Entity/Query/Query.php b/core/lib/Drupal/Core/Config/Entity/Query/Query.php
index 1df3ffd..7332680 100644
--- a/core/lib/Drupal/Core/Config/Entity/Query/Query.php
+++ b/core/lib/Drupal/Core/Config/Entity/Query/Query.php
@@ -10,6 +10,7 @@
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Entity\EntityManagerInterface;
+use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Query\QueryBase;
use Drupal\Core\Entity\Query\QueryInterface;
@@ -19,13 +20,6 @@
class Query extends QueryBase implements QueryInterface {
/**
- * Stores the entity manager.
- *
- * @var \Drupal\Core\Entity\EntityManagerInterface
- */
- protected $entityManager;
-
- /**
* The config storage used by the config entity query.
*
* @var \Drupal\Core\Config\StorageInterface
@@ -42,13 +36,11 @@ class Query extends QueryBase implements QueryInterface {
/**
* Constructs a Query object.
*
- * @param string $entity_type
- * The entity type.
+ * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
+ * The entity type definition.
* @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.
- * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
- * The entity manager that stores all meta information.
* @param \Drupal\Core\Config\StorageInterface $config_storage
* The actual config storage which is used to list all config items.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
@@ -56,9 +48,8 @@ class Query extends QueryBase implements QueryInterface {
* @param array $namespaces
* List of potential namespaces of the classes belonging to this query.
*/
- function __construct($entity_type, $conjunction, EntityManagerInterface $entity_manager, StorageInterface $config_storage, ConfigFactoryInterface $config_factory, array $namespaces) {
+ function __construct(EntityTypeInterface $entity_type, $conjunction, StorageInterface $config_storage, ConfigFactoryInterface $config_factory, array $namespaces) {
parent::__construct($entity_type, $conjunction, $namespaces);
- $this->entityManager = $entity_manager;
$this->configStorage = $config_storage;
$this->configFactory = $config_factory;
}
@@ -126,15 +117,14 @@ public function execute() {
* Config records keyed by entity IDs.
*/
protected function loadRecords() {
- $entity_type = $this->entityManager->getDefinition($this->getEntityType());
- $prefix = $entity_type->getConfigPrefix() . '.';
+ $prefix = $this->entityType->getConfigPrefix() . '.';
$prefix_length = strlen($prefix);
// Search the conditions for restrictions on entity IDs.
$ids = array();
if ($this->condition->getConjunction() == 'AND') {
foreach ($this->condition->conditions() as $condition) {
- if (is_string($condition['field']) && $condition['field'] == $entity_type->getKey('id')) {
+ if (is_string($condition['field']) && $condition['field'] == $this->entityType->getKey('id')) {
$operator = $condition['operator'] ?: (is_array($condition['value']) ? 'IN' : '=');
if ($operator == '=') {
$ids = array($condition['value']);
diff --git a/core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php b/core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php
index 6d557cf..f239a66 100644
--- a/core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php
+++ b/core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php
@@ -10,6 +10,7 @@
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Entity\EntityManagerInterface;
+use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Query\QueryBase;
use Drupal\Core\Entity\Query\QueryException;
use Drupal\Core\Entity\Query\QueryFactoryInterface;
@@ -57,14 +58,14 @@ public function __construct(StorageInterface $config_storage, ConfigFactoryInter
/**
* {@inheritdoc}
*/
- public function get($entity_type, $conjunction, EntityManagerInterface $entity_manager) {
- return new Query($entity_type, $conjunction, $entity_manager, $this->configStorage, $this->configFactory, $this->namespaces);
+ public function get(EntityTypeInterface $entity_type, $conjunction) {
+ return new Query($entity_type, $conjunction, $this->configStorage, $this->configFactory, $this->namespaces);
}
/**
* {@inheritdoc}
*/
- public function getAggregate($entity_type, $conjunction, EntityManagerInterface $entity_manager) {
+ public function getAggregate(EntityTypeInterface $entity_type, $conjunction) {
throw new QueryException('Aggregation over configuration entities is not supported');
}
diff --git a/core/lib/Drupal/Core/CoreServiceProvider.php b/core/lib/Drupal/Core/CoreServiceProvider.php
index d99ae28..8f4f66c 100644
--- a/core/lib/Drupal/Core/CoreServiceProvider.php
+++ b/core/lib/Drupal/Core/CoreServiceProvider.php
@@ -54,6 +54,10 @@ public function register(ContainerBuilder $container) {
$this->registerModuleHandler($container);
$this->registerUuid($container);
+ // Add the compiler pass that lets service providers modify existing
+ // service definitions. This pass must come first so that later
+ // list-building passes are operating on the post-alter services list.
+ $container->addCompilerPass(new ModifyServiceDefinitionsPass());
$container->addCompilerPass(new RegisterRouteFiltersPass());
// Add a compiler pass for registering event subscribers.
$container->addCompilerPass(new RegisterKernelListenersPass(), PassConfig::TYPE_AFTER_REMOVING);
@@ -75,9 +79,6 @@ public function register(ContainerBuilder $container) {
// Add the compiler pass that will process the tagged theme negotiator
// service.
$container->addCompilerPass(new ThemeNegotiatorPass());
- // Add the compiler pass that lets service providers modify existing
- // service definitions.
- $container->addCompilerPass(new ModifyServiceDefinitionsPass());
// Add the compiler pass that will process tagged authentication services.
$container->addCompilerPass(new RegisterAuthenticationPass());
// Register Twig extensions.
diff --git a/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php b/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php
new file mode 100644
index 0000000..b99e472
--- /dev/null
+++ b/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php
@@ -0,0 +1,22 @@
+ 'Drupal\Core\Entity\FieldableDatabaseStorageController',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getConfigPrefix() {
+ return FALSE;
+ }
+
+}
diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
index 7dfedbc..44ea24b 100644
--- a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
+++ b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
@@ -18,7 +18,7 @@
use Drupal\field\FieldUpdateForbiddenException;
use Drupal\field\FieldInterface;
use Drupal\field\FieldInstanceInterface;
-use Drupal\field\Entity\Field;
+use Drupal\field\Entity\FieldConfig;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php
index 6a2385f..d100546 100644
--- a/core/lib/Drupal/Core/Entity/EntityManager.php
+++ b/core/lib/Drupal/Core/Entity/EntityManager.php
@@ -30,7 +30,7 @@
* Manages entity type plugin definitions.
*
* Each entity type definition array is set in the entity type's
- * annotation and altered by hook_entity_info_alter().
+ * annotation and altered by hook_entity_type_alter().
*
* The defaults for the plugin definition are provided in
* \Drupal\Core\Entity\EntityManagerInterface::defaults.
@@ -38,7 +38,7 @@
* @see \Drupal\Core\Entity\Annotation\EntityType
* @see \Drupal\Core\Entity\EntityInterface
* @see \Drupal\Core\Entity\EntityTypeInterface
- * @see hook_entity_info_alter()
+ * @see hook_entity_type_alter()
*/
class EntityManager extends PluginManagerBase implements EntityManagerInterface {
@@ -134,7 +134,7 @@ class EntityManager extends PluginManagerBase implements EntityManagerInterface
* The string translationManager.
*/
public function __construct(\Traversable $namespaces, ContainerInterface $container, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache, LanguageManager $language_manager, TranslationInterface $translation_manager) {
- // Allow the plugin definition to be altered by hook_entity_info_alter().
+ // Allow the plugin definition to be altered by hook_entity_type_alter().
$this->moduleHandler = $module_handler;
$this->cache = $cache;
@@ -143,9 +143,9 @@ public function __construct(\Traversable $namespaces, ContainerInterface $contai
$this->translationManager = $translation_manager;
$this->discovery = new AnnotatedClassDiscovery('Entity', $namespaces, 'Drupal\Core\Entity\Annotation\EntityType');
- $this->discovery = new InfoHookDecorator($this->discovery, 'entity_info');
- $this->discovery = new AlterDecorator($this->discovery, 'entity_info');
- $this->discovery = new CacheDecorator($this->discovery, 'entity_info:' . $this->languageManager->getCurrentLanguage()->id, 'cache', Cache::PERMANENT, array('entity_info' => TRUE));
+ $this->discovery = new InfoHookDecorator($this->discovery, 'entity_type_build');
+ $this->discovery = new AlterDecorator($this->discovery, 'entity_type');
+ $this->discovery = new CacheDecorator($this->discovery, 'entity_type:' . $this->languageManager->getCurrentLanguage()->id, 'cache', Cache::PERMANENT, array('entity_types' => TRUE));
$this->container = $container;
}
@@ -352,7 +352,7 @@ public function getFieldDefinitions($entity_type_id, $bundle = NULL) {
}
}
- $this->cache->set($cid, $this->entityFieldInfo[$entity_type_id], Cache::PERMANENT, array('entity_info' => TRUE, 'entity_field_info' => TRUE));
+ $this->cache->set($cid, $this->entityFieldInfo[$entity_type_id], Cache::PERMANENT, array('entity_types' => TRUE, 'entity_field_info' => TRUE));
}
}
@@ -414,7 +414,7 @@ public function getAllBundleInfo() {
}
}
$this->moduleHandler->alter('entity_bundle_info', $this->bundleInfo);
- $this->cache->set("entity_bundle_info:$langcode", $this->bundleInfo, Cache::PERMANENT, array('entity_info' => TRUE));
+ $this->cache->set("entity_bundle_info:$langcode", $this->bundleInfo, Cache::PERMANENT, array('entity_types' => TRUE));
}
}
diff --git a/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php b/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php
index cbe2871..3da5abc 100644
--- a/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php
+++ b/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php
@@ -12,7 +12,7 @@
*
* All entity controller classes specified via the "controllers['storage']" key
* returned by \Drupal\Core\Entity\EntityManagerInterface or
- * hook_entity_info_alter() have to implement this interface.
+ * hook_entity_type_alter() have to implement this interface.
*
* Most simple, SQL-based entity controllers will do better by extending
* Drupal\Core\Entity\DatabaseStorageController instead of implementing this
diff --git a/core/lib/Drupal/Core/Entity/EntityType.php b/core/lib/Drupal/Core/Entity/EntityType.php
index b4fe29c..4eae0df 100644
--- a/core/lib/Drupal/Core/Entity/EntityType.php
+++ b/core/lib/Drupal/Core/Entity/EntityType.php
@@ -164,13 +164,6 @@ class EntityType implements EntityTypeInterface {
protected $translatable = FALSE;
/**
- * Returns the config prefix used by the configuration entity type.
- *
- * @var string
- */
- protected $config_prefix;
-
- /**
* The human-readable name of the type.
*
* @var string
@@ -541,7 +534,7 @@ public function isTranslatable() {
* {@inheritdoc}
*/
public function getConfigPrefix() {
- return isset($this->config_prefix) ? $this->config_prefix : FALSE;
+ return FALSE;
}
/**
diff --git a/core/lib/Drupal/Core/Entity/EntityTypeInterface.php b/core/lib/Drupal/Core/Entity/EntityTypeInterface.php
index 4305c6b..857d3e7 100644
--- a/core/lib/Drupal/Core/Entity/EntityTypeInterface.php
+++ b/core/lib/Drupal/Core/Entity/EntityTypeInterface.php
@@ -10,8 +10,8 @@
/**
* Provides an interface for an entity type and its metadata.
*
- * Additional information can be provided by modules: hook_entity_info() can be
- * implemented to define new properties, while hook_entity_info_alter() can be
+ * Additional information can be provided by modules: hook_entity_type_build() can be
+ * implemented to define new properties, while hook_entity_type_alter() can be
* implemented to alter existing data and fill-in defaults. Module-specific
* properties should be documented in the hook implementations defining them.
*/
diff --git a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php
index bffc731..751f021 100644
--- a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php
+++ b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php
@@ -113,7 +113,7 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang
}
// Invoke hook_entity_prepare_view().
- module_invoke_all('entity_prepare_view', $this->entityTypeId, $entities, $displays, $view_mode);
+ \Drupal::moduleHandler()->invokeAll('entity_prepare_view', array($this->entityTypeId, $entities, $displays, $view_mode));
// Let the displays build their render arrays.
foreach ($entities_by_bundle as $bundle => $bundle_entities) {
@@ -225,8 +225,8 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la
foreach ($entities as $key => $entity) {
$entity_view_mode = isset($entity->content['#view_mode']) ? $entity->content['#view_mode'] : $view_mode;
$display = $displays[$entity_view_mode][$entity->bundle()];
- module_invoke_all($view_hook, $entity, $display, $entity_view_mode, $langcode);
- module_invoke_all('entity_view', $entity, $display, $entity_view_mode, $langcode);
+ \Drupal::moduleHandler()->invokeAll($view_hook, array($entity, $display, $entity_view_mode, $langcode));
+ \Drupal::moduleHandler()->invokeAll('entity_view', array($entity, $display, $entity_view_mode, $langcode));
$build[$key] = $entity->content;
// We don't need duplicate rendering info in $entity->content.
diff --git a/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php b/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php
index ca9e694..6a1c8f8 100644
--- a/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php
+++ b/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php
@@ -17,7 +17,7 @@
use Drupal\field\FieldUpdateForbiddenException;
use Drupal\field\FieldInterface;
use Drupal\field\FieldInstanceInterface;
-use Drupal\field\Entity\Field;
+use Drupal\field\Entity\FieldConfig;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -1099,7 +1099,7 @@ public function onBundleRename($bundle, $bundle_new) {
// We need to account for deleted fields and instances. The method runs
// before the instance definitions are updated, so we need to fetch them
// using the old bundle name.
- $instances = entity_load_multiple_by_properties('field_instance', array('entity_type' => $this->entityTypeId, 'bundle' => $bundle, 'include_deleted' => TRUE));
+ $instances = entity_load_multiple_by_properties('field_instance_config', array('entity_type' => $this->entityTypeId, 'bundle' => $bundle, 'include_deleted' => TRUE));
foreach ($instances as $instance) {
$field = $instance->getField();
$table_name = static::_fieldTableName($field);
@@ -1451,7 +1451,7 @@ static public function _fieldIndexName(FieldInterface $field, $index) {
* unique among all other fields.
*/
static public function _fieldColumnName(FieldInterface $field, $column) {
- return in_array($column, Field::getReservedColumns()) ? $column : $field->getName() . '_' . $column;
+ return in_array($column, FieldConfig::getReservedColumns()) ? $column : $field->getName() . '_' . $column;
}
}
diff --git a/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php b/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php
index 22b54a3..17fd274 100644
--- a/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php
+++ b/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php
@@ -134,7 +134,7 @@ protected function loadFieldItems(array $entities) {
foreach ($entities as $id => $entity) {
$cids[] = "field:{$this->entityTypeId}:$id";
}
- $cache = cache('field')->getMultiple($cids);
+ $cache = \Drupal::cache('field')->getMultiple($cids);
// Put the cached field values back into the entities and remove them from
// the list of entities to query.
foreach ($entities as $id => $entity) {
@@ -183,7 +183,7 @@ protected function loadFieldItems(array $entities) {
}
}
$cid = "field:{$this->entityTypeId}:$id";
- cache('field')->set($cid, $data);
+ \Drupal::cache('field')->set($cid, $data);
}
}
}
@@ -207,7 +207,7 @@ protected function saveFieldItems(EntityInterface $entity, $update = TRUE) {
if ($update) {
$entity_type = $entity->getEntityType();
if ($entity_type->isFieldDataCacheable()) {
- cache('field')->delete('field:' . $entity->getEntityTypeId() . ':' . $entity->id());
+ \Drupal::cache('field')->delete('field:' . $entity->getEntityTypeId() . ':' . $entity->id());
}
}
}
@@ -227,7 +227,7 @@ protected function deleteFieldItems(EntityInterface $entity) {
$entity_type = $entity->getEntityType();
if ($entity_type->isFieldDataCacheable()) {
- cache('field')->delete('field:' . $entity->getEntityTypeId() . ':' . $entity->id());
+ \Drupal::cache('field')->delete('field:' . $entity->getEntityTypeId() . ':' . $entity->id());
}
}
diff --git a/core/lib/Drupal/Core/Entity/Query/QueryBase.php b/core/lib/Drupal/Core/Entity/Query/QueryBase.php
index 3ba51ec..e98755a 100644
--- a/core/lib/Drupal/Core/Entity/Query/QueryBase.php
+++ b/core/lib/Drupal/Core/Entity/Query/QueryBase.php
@@ -9,11 +9,12 @@
use Drupal\Core\Database\Query\PagerSelectExtender;
use Drupal\Core\Entity\EntityStorageControllerInterface;
+use Drupal\Core\Entity\EntityTypeInterface;
/**
* The base entity query class.
*/
-abstract class QueryBase {
+abstract class QueryBase implements QueryInterface {
/**
* The entity type this query runs against.
@@ -23,6 +24,13 @@
protected $entityTypeId;
/**
+ * Information about the entity type.
+ *
+ * @var \Drupal\Core\Entity\EntityTypeInterface
+ */
+ protected $entityType;
+
+ /**
* The list of sorts.
*
* @var array
@@ -127,9 +135,18 @@
/**
* Constructs this object.
+ *
+ * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
+ * The entity type definition.
+ * @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.
+ * @param array $namespaces
+ * List of potential namespaces of the classes belonging to this query.
*/
- public function __construct($entity_type, $conjunction, array $namespaces) {
- $this->entityTypeId = $entity_type;
+ public function __construct(EntityTypeInterface $entity_type, $conjunction, array $namespaces) {
+ $this->entityTypeId = $entity_type->id();
+ $this->entityType = $entity_type;
$this->conjunction = $conjunction;
$this->namespaces = $namespaces;
$this->condition = $this->conditionGroupFactory($conjunction);
@@ -139,9 +156,9 @@ public function __construct($entity_type, $conjunction, array $namespaces) {
}
/**
- * Implements \Drupal\Core\Entity\Query\QueryInterface::getEntityType().
+ * {@inheritdoc}
*/
- public function getEntityType() {
+ public function getEntityTypeId() {
return $this->entityTypeId;
}
diff --git a/core/lib/Drupal/Core/Entity/Query/QueryFactory.php b/core/lib/Drupal/Core/Entity/Query/QueryFactory.php
index 27bccbd..fff7c864 100644
--- a/core/lib/Drupal/Core/Entity/Query/QueryFactory.php
+++ b/core/lib/Drupal/Core/Entity/Query/QueryFactory.php
@@ -35,8 +35,8 @@ public function __construct(EntityManagerInterface $entity_manager) {
/**
* Returns a query object for a given entity type.
*
- * @param string $entity_type
- * The entity type.
+ * @param string $entity_type_id
+ * The entity type ID.
* @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.
@@ -44,16 +44,16 @@ public function __construct(EntityManagerInterface $entity_manager) {
* @return \Drupal\Core\Entity\Query\QueryInterface
* The query object that can query the given entity type.
*/
- public function get($entity_type, $conjunction = 'AND') {
- $service_name = $this->entityManager->getStorageController($entity_type)->getQueryServicename();
- return $this->container->get($service_name)->get($entity_type, $conjunction, $this->entityManager);
+ public function get($entity_type_id, $conjunction = 'AND') {
+ $service_name = $this->entityManager->getStorageController($entity_type_id)->getQueryServicename();
+ return $this->container->get($service_name)->get($this->entityManager->getDefinition($entity_type_id), $conjunction);
}
/**
* Returns an aggregated query object for a given entity type.
*
- * @param string $entity_type
- * The entity type.
+ * @param string $entity_type_id
+ * The entity type ID.
* @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.
@@ -61,9 +61,9 @@ public function get($entity_type, $conjunction = 'AND') {
* @return \Drupal\Core\Entity\Query\QueryAggregateInterface
* The aggregated query object that can query the given entity type.
*/
- public function getAggregate($entity_type, $conjunction = 'AND') {
- $service_name = $this->entityManager->getStorageController($entity_type)->getQueryServicename();
- return $this->container->get($service_name)->getAggregate($entity_type, $conjunction, $this->entityManager);
+ public function getAggregate($entity_type_id, $conjunction = 'AND') {
+ $service_name = $this->entityManager->getStorageController($entity_type_id)->getQueryServicename();
+ return $this->container->get($service_name)->getAggregate($this->entityManager->getDefinition($entity_type_id), $conjunction);
}
}
diff --git a/core/lib/Drupal/Core/Entity/Query/QueryFactoryInterface.php b/core/lib/Drupal/Core/Entity/Query/QueryFactoryInterface.php
index de22118..c42635c 100644
--- a/core/lib/Drupal/Core/Entity/Query/QueryFactoryInterface.php
+++ b/core/lib/Drupal/Core/Entity/Query/QueryFactoryInterface.php
@@ -6,8 +6,7 @@
*/
namespace Drupal\Core\Entity\Query;
-
-use Drupal\Core\Entity\EntityManagerInterface;
+use Drupal\Core\Entity\EntityTypeInterface;
/**
* Defines an interface for QueryFactory classes.
@@ -17,35 +16,29 @@
/**
* Instantiates an entity query for a given entity type.
*
- * @param string $entity_type
- * The entity type for the query.
+ * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
+ * The entity type definition.
* @param string $conjunction
* The operator to use to combine conditions: 'AND' or 'OR'.
- * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
- * The entity manager that handles the entity type.
- * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
- * The entity manager that handles the entity type.
*
* @return \Drupal\Core\Entity\Query\QueryInterface
* An entity query for a specific configuration entity type.
*/
- public function get($entity_type, $conjunction, EntityManagerInterface $entity_manager);
+ public function get(EntityTypeInterface $entity_type, $conjunction);
/**
* Returns a aggregation query object for a given entity type.
*
- * @param string $entity_type
- * The entity type.
+ * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
+ * The entity type definition.
* @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.
- * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
- * The entity manager that handles the entity type.
*
* @throws \Drupal\Core\Entity\Query\QueryException
* @return \Drupal\Core\Entity\Query\QueryAggregateInterface
* The query object that can query the given entity type.
*/
- public function getAggregate($entity_type, $conjunction, EntityManagerInterface $entity_manager);
+ public function getAggregate(EntityTypeInterface $entity_type, $conjunction);
}
diff --git a/core/lib/Drupal/Core/Entity/Query/QueryInterface.php b/core/lib/Drupal/Core/Entity/Query/QueryInterface.php
index 8f2ed21..4a9420b 100644
--- a/core/lib/Drupal/Core/Entity/Query/QueryInterface.php
+++ b/core/lib/Drupal/Core/Entity/Query/QueryInterface.php
@@ -19,11 +19,11 @@
interface QueryInterface extends AlterableInterface {
/**
- * Gets the entity type for this query.
+ * Gets the ID of the entity type for this query.
*
* @return string
*/
- public function getEntityType();
+ public function getEntityTypeId();
/**
* Add a condition to the query or a condition group.
diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Query.php b/core/lib/Drupal/Core/Entity/Query/Sql/Query.php
index 7d7d901..407cef5 100644
--- a/core/lib/Drupal/Core/Entity/Query/Sql/Query.php
+++ b/core/lib/Drupal/Core/Entity/Query/Sql/Query.php
@@ -10,6 +10,7 @@
use Drupal\Core\Database\Connection;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\Core\Entity\EntityManagerInterface;
+use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Query\QueryBase;
use Drupal\Core\Entity\Query\QueryException;
use Drupal\Core\Entity\Query\QueryInterface;
@@ -20,13 +21,6 @@
class Query extends QueryBase implements QueryInterface {
/**
- * The entity type definition.
- *
- * @var \Drupal\Core\Entity\EntityTypeInterface
- */
- protected $entityType;
-
- /**
* The build sql select query.
*
* @var \Drupal\Core\Database\Query\SelectInterface
@@ -68,19 +62,18 @@ class Query extends QueryBase implements QueryInterface {
/**
* Constructs a query object.
*
- * @param string $entity_type
- * The entity type.
- * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
- * The entity manager service.
+ * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
+ * The entity type definition.
* @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.
* @param \Drupal\Core\Database\Connection $connection
* The database connection to run the query against.
+ * @param array $namespaces
+ * List of potential namespaces of the classes belonging to this query.
*/
- public function __construct($entity_type, EntityManagerInterface $entity_manager, $conjunction, Connection $connection, array $namespaces) {
+ public function __construct(EntityTypeInterface $entity_type, $conjunction, Connection $connection, array $namespaces) {
parent::__construct($entity_type, $conjunction, $namespaces);
- $this->entityManager = $entity_manager;
$this->connection = $connection;
}
@@ -107,8 +100,6 @@ public function execute() {
* Returns the called object.
*/
protected function prepare() {
- $entity_type = $this->entityTypeId;
- $this->entityType = $this->entityManager->getDefinition($entity_type);
if (!$base_table = $this->entityType->getBaseTable()) {
throw new QueryException("No base table, invalid query.");
}
@@ -117,7 +108,7 @@ protected function prepare() {
$simple_query = FALSE;
}
$this->sqlQuery = $this->connection->select($base_table, 'base_table', array('conjunction' => $this->conjunction));
- $this->sqlQuery->addMetaData('entity_type', $entity_type);
+ $this->sqlQuery->addMetaData('entity_type', $this->entityTypeId);
$id_field = $this->entityType->getKey('id');
// Add the key field for fetchAllKeyed().
if (!$revision_field = $this->entityType->getKey('revision')) {
@@ -135,7 +126,7 @@ protected function prepare() {
$this->sqlFields["base_table.$id_field"] = array('base_table', $id_field);
}
if ($this->accessCheck) {
- $this->sqlQuery->addTag($entity_type . '_access');
+ $this->sqlQuery->addTag($this->entityTypeId . '_access');
}
$this->sqlQuery->addTag('entity_query');
$this->sqlQuery->addTag('entity_query_' . $this->entityTypeId);
diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/QueryFactory.php b/core/lib/Drupal/Core/Entity/Query/Sql/QueryFactory.php
index 13e269a..4b7de43 100644
--- a/core/lib/Drupal/Core/Entity/Query/Sql/QueryFactory.php
+++ b/core/lib/Drupal/Core/Entity/Query/Sql/QueryFactory.php
@@ -9,6 +9,7 @@
use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityManagerInterface;
+use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Query\QueryBase;
use Drupal\Core\Entity\Query\QueryFactoryInterface;
@@ -46,37 +47,19 @@ public function __construct(Connection $connection) {
}
/**
- * Constructs a entity query for a certain entity type.
- *
- * @param string $entity_type
- * The entity type.
- * @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\Sql\Query
- * The factored query.
+ * {@inheritdoc}
*/
- public function get($entity_type, $conjunction, EntityManagerInterface $entity_manager) {
+ public function get(EntityTypeInterface $entity_type, $conjunction) {
$class = QueryBase::getClass($this->namespaces, 'Query');
- return new $class($entity_type, $entity_manager, $conjunction, $this->connection, $this->namespaces);
+ return new $class($entity_type, $conjunction, $this->connection, $this->namespaces);
}
/**
- * Constructs a entity aggregation query for a certain entity type.
- *
- * @param string $entity_type
- * The entity type.
- * @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\Sql\QueryAggregate
- * The factored aggregation query.
+ * {@inheritdoc}
*/
- public function getAggregate($entity_type, $conjunction, EntityManagerInterface $entity_manager) {
+ public function getAggregate(EntityTypeInterface $entity_type, $conjunction) {
$class = QueryBase::getClass($this->namespaces, 'QueryAggregate');
- return new $class($entity_type, $entity_manager, $conjunction, $this->connection, $this->namespaces);
+ return new $class($entity_type, $conjunction, $this->connection, $this->namespaces);
}
}
diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
index add9c73..0621500 100644
--- a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
+++ b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
@@ -12,7 +12,7 @@
use Drupal\Core\Entity\FieldableDatabaseStorageController;
use Drupal\Core\Entity\Plugin\DataType\EntityReference;
use Drupal\Core\Entity\Query\QueryException;
-use Drupal\field\Entity\Field;
+use Drupal\field\Entity\FieldConfig;
use Drupal\field\Field as FieldInfo;
/**
@@ -118,7 +118,7 @@ public function addField($field, $type, $langcode) {
$next = $specifiers[$key + 1];
// Is this a field column?
$columns = $field->getColumns();
- if (isset($columns[$next]) || in_array($next, Field::getReservedColumns())) {
+ if (isset($columns[$next]) || in_array($next, FieldConfig::getReservedColumns())) {
// Use it.
$column = $next;
// Do not process it again.
diff --git a/core/lib/Drupal/Core/Extension/UpdateModuleHandler.php b/core/lib/Drupal/Core/Extension/UpdateModuleHandler.php
index a8334b8..1b8a466 100644
--- a/core/lib/Drupal/Core/Extension/UpdateModuleHandler.php
+++ b/core/lib/Drupal/Core/Extension/UpdateModuleHandler.php
@@ -24,7 +24,7 @@ public function getImplementations($hook) {
if (substr($hook, -6) === '_alter') {
return array();
}
- // theme() is called during updates and fires hooks, so whitelist the
+ // _theme() is called during updates and fires hooks, so whitelist the
// system module.
if (substr($hook, 0, 6) == 'theme_') {
return array('system');
@@ -49,7 +49,7 @@ public function getImplementations($hook) {
// This is called during rebuild to find testing themes.
case 'system_theme_info':
// Those are needed by user_access() to check access on update.php.
- case 'entity_info':
+ case 'entity_type_build':
case 'entity_load':
case 'user_role_load':
return array();
diff --git a/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php b/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php
index aba828f..8146d9e 100644
--- a/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php
+++ b/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php
@@ -27,18 +27,19 @@
* It is up to the class implementing this interface to manage where the
* information comes from. For example, field.module provides an implementation
* based on two levels of configuration. It allows the site administrator to add
- * custom fields to any entity type and bundle via the "field_entity" and
- * "field_instance" configuration entities. The former for storing configuration
- * that is independent of which entity type and bundle the field is added to,
- * and the latter for storing configuration that is specific to the entity type
- * and bundle. The class that implements "field_instance" configuration entities
- * also implements this interface, returning information from either itself, or
- * from the corresponding "field_entity" configuration, as appropriate.
+ * custom fields to any entity type and bundle via the "field_config" and
+ * "field_instance_config" configuration entities. The former for storing
+ * configuration that is independent of which entity type and bundle the field
+ * is added to, and the latter for storing configuration that is specific to the
+ * entity type and bundle. The class that implements "field_instance_config"
+ * configuration entities also implements this interface, returning information
+ * from either itself, or from the corresponding "field_config" configuration,
+ * as appropriate.
*
* However, entity base fields, such as $node->title, are not managed by
- * field.module and its "field_entity"/"field_instance" configuration entities.
- * Therefore, their definitions are provided by different objects based on the
- * class \Drupal\Core\Field\FieldDefinition, which implements this
+ * field.module and its "field_config"/"field_instance_config" configuration
+ * entities. Therefore, their definitions are provided by different objects
+ * based on the class \Drupal\Core\Field\FieldDefinition, which implements this
* interface as well.
*
* Field definitions may fully define a concrete data object (e.g.,
diff --git a/core/lib/Drupal/Core/Field/WidgetBase.php b/core/lib/Drupal/Core/Field/WidgetBase.php
index e73a34f..58e5d25 100644
--- a/core/lib/Drupal/Core/Field/WidgetBase.php
+++ b/core/lib/Drupal/Core/Field/WidgetBase.php
@@ -9,6 +9,7 @@
use Drupal\Component\Utility\NestedArray;
use Drupal\Component\Utility\SortArray;
+use Drupal\Component\Utility\String;
use Symfony\Component\Validator\ConstraintViolationInterface;
/**
@@ -74,7 +75,7 @@ public function form(FieldItemListInterface $items, array &$form, array &$form_s
if ($this->handlesMultipleValues() || isset($get_delta)) {
$delta = isset($get_delta) ? $get_delta : 0;
$element = array(
- '#title' => check_plain($this->fieldDefinition->getLabel()),
+ '#title' => String::checkPlain($this->fieldDefinition->getLabel()),
'#description' => field_filter_xss(\Drupal::token()->replace($this->fieldDefinition->getDescription())),
);
$element = $this->formSingleElement($items, $delta, $element, $form, $form_state);
@@ -161,7 +162,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f
$id_prefix = implode('-', array_merge($parents, array($field_name)));
$wrapper_id = drupal_html_id($id_prefix . '-add-more-wrapper');
- $title = check_plain($this->fieldDefinition->getLabel());
+ $title = String::checkPlain($this->fieldDefinition->getLabel());
$description = field_filter_xss(\Drupal::token()->replace($this->fieldDefinition->getDescription()));
$elements = array();
diff --git a/core/lib/Drupal/Core/Menu/LocalActionManager.php b/core/lib/Drupal/Core/Menu/LocalActionManager.php
index 32ae80e..79e40c9 100644
--- a/core/lib/Drupal/Core/Menu/LocalActionManager.php
+++ b/core/lib/Drupal/Core/Menu/LocalActionManager.php
@@ -11,6 +11,7 @@
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\LanguageManager;
+use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Menu\LocalActionInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\Component\Plugin\Discovery\ProcessDecorator;
@@ -94,7 +95,7 @@ class LocalActionManager extends DefaultPluginManager {
/**
* The plugin instances.
*
- * @var array
+ * @var \Drupal\Core\Menu\LocalActionInterface[]
*/
protected $instances = array();
@@ -112,12 +113,14 @@ class LocalActionManager extends DefaultPluginManager {
* The module handler.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
- * @param \Drupal\Core\Language\LanguageManager $language_manager
+ * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager.
* @param \Drupal\Core\Access\AccessManager $access_manager
* The access manager.
+ * @param \Drupal\Core\Session\AccountInterface $account
+ * The current user.
*/
- public function __construct(ControllerResolverInterface $controller_resolver, Request $request, RouteProviderInterface $route_provider, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache_backend, LanguageManager $language_manager, AccessManager $access_manager, AccountInterface $account) {
+ public function __construct(ControllerResolverInterface $controller_resolver, Request $request, RouteProviderInterface $route_provider, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache_backend, LanguageManagerInterface $language_manager, AccessManager $access_manager, AccountInterface $account) {
// Skip calling the parent constructor, since that assumes annotation-based
// discovery.
$this->discovery = new YamlDiscovery('local_actions', $module_handler->getModuleDirectories());
@@ -179,10 +182,10 @@ public function getActionsForRoute($route_appears) {
}
}
$links = array();
- foreach ($this->instances[$route_appears] as $plugin) {
+ foreach ($this->instances[$route_appears] as $plugin_id => $plugin) {
$route_name = $plugin->getRouteName();
$route_parameters = $plugin->getRouteParameters($this->request);
- $links[$route_name] = array(
+ $links[$plugin_id] = array(
'#theme' => 'menu_local_action',
'#link' => array(
'title' => $this->getTitle($plugin),
diff --git a/core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php b/core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php
index 9f3fbf0..667bebe 100644
--- a/core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php
+++ b/core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php
@@ -7,7 +7,7 @@
namespace Drupal\Core\Plugin;
-use Drupal\Component\Plugin\ContextAwarePluginBase as PluginBase;
+use Drupal\Component\Plugin\ContextAwarePluginBase as ComponentContextAwarePluginBase;
use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Core\Plugin\Context\Context;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
@@ -20,7 +20,7 @@
* the Context class. This code is exactly the same as what is in Component
* ContextAwarePluginBase but it is using a different Context class.
*/
-abstract class ContextAwarePluginBase extends PluginBase {
+abstract class ContextAwarePluginBase extends ComponentContextAwarePluginBase {
/**
* Override of \Drupal\Component\Plugin\ContextAwarePluginBase::__construct().
diff --git a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php
index a2ce7d1..5c42a81 100644
--- a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php
+++ b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php
@@ -77,7 +77,7 @@
*
* @throws \Drupal\Core\Routing\GeneratorNotInitializedException.
*
- * @deprecated since version 8.0
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
* System paths should not be used - use route names and parameters.
*/
public function generateFromPath($path = NULL, $options = array());
@@ -94,7 +94,7 @@ public function generateFromPath($path = NULL, $options = array());
* @return string
* The internal Drupal path corresponding to the route.
*
- * @deprecated since version 8.0
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
* System paths should not be used - use route names and parameters.
*/
public function getPathFromRoute($name, $parameters = array());
diff --git a/core/lib/Drupal/Core/Template/TwigEnvironment.php b/core/lib/Drupal/Core/Template/TwigEnvironment.php
index 24c9084..2bbf3c9 100644
--- a/core/lib/Drupal/Core/Template/TwigEnvironment.php
+++ b/core/lib/Drupal/Core/Template/TwigEnvironment.php
@@ -36,7 +36,7 @@ class TwigEnvironment extends \Twig_Environment {
*/
public function __construct(\Twig_LoaderInterface $loader = NULL, $options = array(), ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler) {
// @todo Pass as arguments from the DIC.
- $this->cache_object = cache();
+ $this->cache_object = \Drupal::cache();
// Set twig path namespace for themes and modules.
$namespaces = $module_handler->getModuleList();
diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php
index b0fed73..1d3cb22 100644
--- a/core/lib/Drupal/Core/Theme/Registry.php
+++ b/core/lib/Drupal/Core/Theme/Registry.php
@@ -59,12 +59,12 @@ class Registry implements DestructableInterface {
* from; e.g., 'module' for theme hook 'node' of Node module.
* - name: The name of the extension the original theme hook originates
* from; e.g., 'node' for theme hook 'node' of Node module.
- * - theme path: The effective path_to_theme() during theme(), available as
+ * - theme path: The effective path_to_theme() during _theme(), available as
* 'directory' variable in templates.
* functions, it should point to the respective theme. For templates,
* it should point to the directory that contains the template.
* - includes: (optional) An array of include files to load when the theme
- * hook is executed by theme().
+ * hook is executed by _theme().
* - file: (optional) A filename to add to 'includes', either prefixed with
* the value of 'path', or the path of the extension implementing
* hook_theme().
@@ -291,7 +291,7 @@ public function getBaseHook($hook) {
* for base hooks (e.g., 'block__node' for the base hook 'block') need to be
* determined based on the full registry and classified as 'base hook'.
*
- * @see theme()
+ * @see _theme()
* @see hook_theme_registry_alter()
*
* @return \Drupal\Core\Utility\ThemeRegistry
@@ -374,7 +374,7 @@ protected function build() {
* in hook_theme(). If there is more than one implementation and
* 'render element' is not specified in a later one, then the previous
* definition is kept.
- * - 'preprocess functions': See theme() for detailed documentation.
+ * - 'preprocess functions': See _theme() for detailed documentation.
* @param string $name
* The name of the module, theme engine, base theme engine, theme or base
* theme implementing hook_theme().
@@ -391,7 +391,7 @@ protected function build() {
* The directory where $name is. For example, modules/system or
* themes/bartik.
*
- * @see theme()
+ * @see _theme()
* @see hook_theme()
* @see list_themes()
*/
@@ -486,7 +486,7 @@ protected function processExtension(&$cache, $name, $type, $theme, $path) {
}
foreach ($prefixes as $prefix) {
// Only use non-hook-specific variable preprocessors for theming
- // hooks implemented as templates. See theme().
+ // hooks implemented as templates. See _theme().
if (isset($info['template']) && function_exists($prefix . '_preprocess')) {
$info['preprocess functions'][] = $prefix . '_preprocess';
}
@@ -522,7 +522,7 @@ protected function processExtension(&$cache, $name, $type, $theme, $path) {
$cache[$hook]['preprocess functions'] = array();
}
// Only use non-hook-specific variable preprocessors for theme hooks
- // implemented as templates. See theme().
+ // implemented as templates. See _theme().
if (isset($info['template']) && function_exists($name . '_preprocess')) {
$cache[$hook]['preprocess functions'][] = $name . '_preprocess';
}
diff --git a/core/lib/Drupal/Core/Utility/CacheArray.php b/core/lib/Drupal/Core/Utility/CacheArray.php
index 2323756..fb46569 100644
--- a/core/lib/Drupal/Core/Utility/CacheArray.php
+++ b/core/lib/Drupal/Core/Utility/CacheArray.php
@@ -61,28 +61,29 @@
* procedural code. Extending classes may wish to alter this behavior, for
* example by overriding offsetSet() and adding an automatic call to persist().
*
- * @deprecated as of Drupal 8.0. Use \Drupal\Core\Cache\CacheCollector instead.
+ * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
+ * Use \Drupal\Core\Cache\CacheCollector.
*
* @see SchemaCache
*/
abstract class CacheArray implements \ArrayAccess {
/**
- * A cid to pass to cache()->set() and cache()->get().
+ * A cid to pass to \Drupal::cache()->set() and \Drupal::cache()->get().
*
* @var string
*/
protected $cid;
/**
- * A tags array to pass to cache()->set().
+ * A tags array to pass to \Drupal::cache()->set().
*
* @var array
*/
protected $tags;
/**
- * A bin to pass to cache()->set() and cache()->get().
+ * A bin to pass to \Drupal::cache()->set() and \Drupal::cache()->get().
*
* @var string
*/
@@ -117,7 +118,7 @@ public function __construct($cid, $bin, $tags = array()) {
$this->bin = $bin;
$this->tags = $tags;
- if ($cached = cache($bin)->get($this->cid)) {
+ if ($cached = \Drupal::cache($bin)->get($this->cid)) {
$this->storage = $cached->data;
}
}
@@ -202,10 +203,10 @@ protected function set($data, $lock = TRUE) {
// To implement locking for cache misses, override __construct().
$lock_name = $this->cid . ':' . $this->bin;
if (!$lock || lock()->acquire($lock_name)) {
- if ($cached = cache($this->bin)->get($this->cid)) {
+ if ($cached = \Drupal::cache($this->bin)->get($this->cid)) {
$data = $cached->data + $data;
}
- cache($this->bin)->set($this->cid, $data, Cache::PERMANENT, $this->tags);
+ \Drupal::cache($this->bin)->set($this->cid, $data, Cache::PERMANENT, $this->tags);
if ($lock) {
lock()->release($lock_name);
}
@@ -218,7 +219,7 @@ protected function set($data, $lock = TRUE) {
public function clear() {
$this->storage = array();
$this->keysToPersist = array();
- cache($this->bin)->delete($this->cid);
+ \Drupal::cache($this->bin)->delete($this->cid);
}
/**
diff --git a/core/lib/Drupal/Core/Utility/ThemeRegistry.php b/core/lib/Drupal/Core/Utility/ThemeRegistry.php
index 8d3e1f8..dbd44e9 100644
--- a/core/lib/Drupal/Core/Utility/ThemeRegistry.php
+++ b/core/lib/Drupal/Core/Utility/ThemeRegistry.php
@@ -26,7 +26,7 @@ class ThemeRegistry extends CacheCollector implements DestructableInterface {
/**
* Whether the partial registry can be persisted to the cache.
*
- * This is only allowed if all modules and the request method is GET. theme()
+ * This is only allowed if all modules and the request method is GET. _theme()
* should be very rarely called on POST requests and this avoids polluting
* the runtime cache.
*/
diff --git a/core/lib/Drupal/Core/Utility/Token.php b/core/lib/Drupal/Core/Utility/Token.php
index 29fef78..e612de8 100644
--- a/core/lib/Drupal/Core/Utility/Token.php
+++ b/core/lib/Drupal/Core/Utility/Token.php
@@ -108,8 +108,8 @@ public function __construct(ModuleHandlerInterface $module_handler) {
* - sanitize: A boolean flag indicating that tokens should be sanitized for
* display to a web browser. Defaults to TRUE. Developers who set this
* option to FALSE assume responsibility for running filter_xss(),
- * check_plain() or other appropriate scrubbing functions before displaying
- * data to users.
+ * String::checkPlain() or other appropriate scrubbing functions before
+ * displaying data to users.
*
* @return string
* Text with tokens replaced.
@@ -200,7 +200,7 @@ public function scan($text) {
* encoding or truncation to a specific length.
* - sanitize: A boolean flag indicating that tokens should be sanitized for
* display to a web browser. Developers who set this option to FALSE assume
- * responsibility for running filter_xss(), check_plain() or other
+ * responsibility for running filter_xss(), String::checkPlain() or other
* appropriate scrubbing functions before displaying data to users.
*
* @return array
diff --git a/core/modules/action/action.module b/core/modules/action/action.module
index cc6821b..07e7b48 100644
--- a/core/modules/action/action.module
+++ b/core/modules/action/action.module
@@ -71,11 +71,11 @@ function action_menu_link_defaults() {
}
/**
- * Implements hook_entity_info().
+ * Implements hook_entity_type_build().
*/
-function action_entity_info(&$entity_info) {
- /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */
- $entity_info['action']
+function action_entity_type_build(array &$entity_types) {
+ /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
+ $entity_types['action']
->setFormClass('add', 'Drupal\action\ActionAddFormController')
->setFormClass('edit', 'Drupal\action\ActionEditFormController')
->setFormClass('delete', 'Drupal\action\Form\ActionDeleteForm')
diff --git a/core/modules/action/action.views_execution.inc b/core/modules/action/action.views_execution.inc
index 859cffd..32bc883 100644
--- a/core/modules/action/action.views_execution.inc
+++ b/core/modules/action/action.views_execution.inc
@@ -5,12 +5,14 @@
* Provides views runtime hooks for action.module.
*/
+use Drupal\Component\Utility\String;
+
/**
* Implements hook_views_form_substitutions().
*/
function action_views_form_substitutions() {
- // Views check_plain()s the column label, so we need to match that.
- $select_all_placeholder = check_plain('');
+ // Views String::checkPlain()s the column label, so we need to match that.
+ $select_all_placeholder = String::checkPlain('');
$select_all = array(
'#type' => 'checkbox',
'#default_value' => FALSE,
diff --git a/core/modules/aggregator/aggregator.pages.inc b/core/modules/aggregator/aggregator.pages.inc
deleted file mode 100644
index 95b6f6f..0000000
--- a/core/modules/aggregator/aggregator.pages.inc
+++ /dev/null
@@ -1,39 +0,0 @@
-fid identifying the feed used to
- * as filter.
- * The $data parameter is not used when $type is 'sum'.
- * @param int $limit
- * (optional) The number of records to return. Defaults to 20.
- *
- * @deprecated Use \Drupal\aggregator\ItemStorageController::loadAll() for
- * loading all feed items, \Drupal\aggregator\ItemStorageController::loadByFeed()
- *
- * @return \Drupal\aggregator\ItemInterface[]
- * An array of the feed items.
- */
-function aggregator_load_feed_items($type, $data = NULL, $limit = 20) {
- $storage_controller = \Drupal::entityManager()->getStorageController('aggregator_item');
- switch ($type) {
- case 'sum':
- return $storage_controller->loadAll($limit);
-
- case 'source':
- return $storage_controller->loadByFeed($data->id(), $limit);
- }
-}
diff --git a/core/modules/aggregator/aggregator.theme.inc b/core/modules/aggregator/aggregator.theme.inc
index 5531dd6..ef43d44 100644
--- a/core/modules/aggregator/aggregator.theme.inc
+++ b/core/modules/aggregator/aggregator.theme.inc
@@ -6,6 +6,7 @@
*/
use Drupal\Core\Entity\EntityInterface;
+use Drupal\Component\Utility\String;
/**
* Prepares variables for aggregator item templates.
@@ -21,7 +22,7 @@ function template_preprocess_aggregator_item(&$variables) {
$item = $variables['aggregator_item'];
$variables['feed_url'] = check_url($item->getLink());
- $variables['feed_title'] = check_plain($item->getTitle());
+ $variables['feed_title'] = String::checkPlain($item->getTitle());
$variables['content'] = aggregator_filter_xss($item->getDescription());
$variables['source_url'] = '';
@@ -29,7 +30,7 @@ function template_preprocess_aggregator_item(&$variables) {
$fid = $item->getFeedId();
if (isset($item->ftitle) && $fid !== NULL) {
$variables['source_url'] = url('aggregator/sources/' . $fid);
- $variables['source_title'] = check_plain($item->ftitle);
+ $variables['source_title'] = String::checkPlain($item->ftitle);
}
if (date('Ymd', $item->getPostedTime()) == date('Ymd')) {
$variables['source_date'] = t('%ago ago', array('%ago' => format_interval(REQUEST_TIME - $item->getPostedTime())));
@@ -59,12 +60,12 @@ function theme_aggregator_page_opml($variables) {
$output = "\n";
$output .= " and
in an intelligent fashion.
*
* Based on: http://photomatt.net/scripts/autop
@@ -1219,7 +1116,7 @@ function _filter_html_image_secure_process($text) {
// Find the directory on the server where index.php resides.
$local_dir = DRUPAL_ROOT . '/';
- $html_dom = filter_dom_load($text);
+ $html_dom = Html::load($text);
$images = $html_dom->getElementsByTagName('img');
foreach ($images as $image) {
$src = $image->getAttribute('src');
@@ -1245,7 +1142,7 @@ function _filter_html_image_secure_process($text) {
// indicator. See filter_filter_secure_image_alter().
\Drupal::moduleHandler()->alter('filter_secure_image', $image);
}
- $text = filter_dom_serialize($html_dom);
+ $text = Html::serialize($html_dom);
return $text;
}
diff --git a/core/modules/filter/lib/Drupal/filter/Entity/FilterFormat.php b/core/modules/filter/lib/Drupal/filter/Entity/FilterFormat.php
index 15537ac..6666c86 100644
--- a/core/modules/filter/lib/Drupal/filter/Entity/FilterFormat.php
+++ b/core/modules/filter/lib/Drupal/filter/Entity/FilterFormat.php
@@ -17,7 +17,7 @@
/**
* Represents a text format.
*
- * @EntityType(
+ * @ConfigEntityType(
* id = "filter_format",
* label = @Translation("Text format"),
* controllers = {
@@ -28,7 +28,6 @@
* },
* "list" = "Drupal\filter\FilterFormatListController",
* "access" = "Drupal\filter\FilterFormatAccessController",
- * "storage" = "Drupal\Core\Config\Entity\ConfigStorageController"
* },
* config_prefix = "filter.format",
* admin_permission = "administer filters",
@@ -183,7 +182,7 @@ public function disable() {
parent::disable();
// Allow modules to react on text format deletion.
- module_invoke_all('filter_format_disable', $this);
+ \Drupal::moduleHandler()->invokeAll('filter_format_disable', array($this));
// Clear the filter cache whenever a text format is disabled.
filter_formats_reset();
diff --git a/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterCaption.php b/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterCaption.php
index 5b5ce63..51cb70a 100644
--- a/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterCaption.php
+++ b/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterCaption.php
@@ -7,6 +7,7 @@
namespace Drupal\filter\Plugin\Filter;
+use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\String;
use Drupal\Component\Utility\Unicode;
use Drupal\Component\Utility\Xss;
@@ -30,7 +31,7 @@ class FilterCaption extends FilterBase {
public function process($text, $langcode, $cache, $cache_id) {
if (stristr($text, 'data-caption') !== FALSE || stristr($text, 'data-align') !== FALSE) {
- $dom = filter_dom_load($text);
+ $dom = Html::load($text);
$xpath = new \DOMXPath($dom);
foreach ($xpath->query('//*[@data-caption or @data-align]') as $node) {
$caption = NULL;
@@ -82,7 +83,7 @@ public function process($text, $langcode, $cache, $cache_id) {
$altered_html = drupal_render($filter_caption);
// Load the altered HTML into a new DOMDocument and retrieve the element.
- $updated_node = filter_dom_load($altered_html)->getElementsByTagName('body')
+ $updated_node = Html::load($altered_html)->getElementsByTagName('body')
->item(0)
->childNodes
->item(0);
@@ -94,7 +95,7 @@ public function process($text, $langcode, $cache, $cache_id) {
$node->parentNode->replaceChild($updated_node, $node);
}
- return filter_dom_serialize($dom);
+ return Html::serialize($dom);
}
return $text;
diff --git a/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtmlCorrector.php b/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtmlCorrector.php
index 8d9b8e0..bc0a036 100644
--- a/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtmlCorrector.php
+++ b/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtmlCorrector.php
@@ -7,6 +7,7 @@
namespace Drupal\filter\Plugin\Filter;
+use Drupal\Component\Utility\Html;
use Drupal\filter\Plugin\FilterBase;
/**
@@ -25,7 +26,7 @@ class FilterHtmlCorrector extends FilterBase {
* {@inheritdoc}
*/
public function process($text, $langcode, $cache, $cache_id) {
- return _filter_htmlcorrector($text);
+ return Html::normalize($text);
}
}
diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php
index e10c5ca..248a9dd 100644
--- a/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php
+++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php
@@ -154,7 +154,7 @@ function testFilterAdmin() {
$this->drupalGet('admin/config/content/formats/manage/' . $restricted);
$this->assertFieldByName('filters[filter_html][settings][allowed_html]', $edit['filters[filter_html][settings][allowed_html]'], 'Allowed HTML tag added.');
- $this->assertTrue(cache('filter')->isEmpty(), 'Cache cleared.');
+ $this->assertTrue(\Drupal::cache('filter')->isEmpty(), 'Cache cleared.');
$elements = $this->xpath('//select[@name=:first]/following::select[@name=:second]', array(
':first' => 'filters[' . $first_filter . '][weight]',
diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterDefaultFormatTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterDefaultFormatTest.php
index ae74dc1..b9b6b71 100644
--- a/core/modules/filter/lib/Drupal/filter/Tests/FilterDefaultFormatTest.php
+++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterDefaultFormatTest.php
@@ -13,6 +13,14 @@
* Tests the default filter functionality in the Filter module.
*/
class FilterDefaultFormatTest extends WebTestBase {
+
+ /**
+ * Modules to enable.
+ *
+ * @var array
+ */
+ public static $modules = array('filter');
+
public static function getInfo() {
return array(
'name' => 'Default text format functionality',
diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterNoFormatTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterNoFormatTest.php
index 59629ba..9f2090c 100644
--- a/core/modules/filter/lib/Drupal/filter/Tests/FilterNoFormatTest.php
+++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterNoFormatTest.php
@@ -13,6 +13,14 @@
* Tests the behavior of check_markup() when it is called without text format.
*/
class FilterNoFormatTest extends WebTestBase {
+
+ /**
+ * Modules to enable.
+ *
+ * @var array
+ */
+ public static $modules = array('filter');
+
public static function getInfo() {
return array(
'name' => 'Unassigned text format functionality',
diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterUnitTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterUnitTest.php
index f686cee..a51d6b9 100644
--- a/core/modules/filter/lib/Drupal/filter/Tests/FilterUnitTest.php
+++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterUnitTest.php
@@ -7,6 +7,7 @@
namespace Drupal\filter\Tests;
+use Drupal\Component\Utility\Html;
use Drupal\simpletest\DrupalUnitTestBase;
use Drupal\filter\FilterBag;
@@ -741,117 +742,117 @@ function testUrlFilterContent() {
*/
function testHtmlCorrectorFilter() {
// Tag closing.
- $f = _filter_htmlcorrector('
text'); + $f = Html::normalize('
text'); $this->assertEqual($f, '
text
', 'HTML corrector -- tag closing at the end of input.'); - $f = _filter_htmlcorrector('text
text'); + $f = Html::normalize('
text
text'); $this->assertEqual($f, '
text
text
', 'HTML corrector -- tag closing.'); - $f = _filter_htmlcorrector("test
'); + $f = Html::normalize('test
'); $this->assertEqual($f, 'test
', 'HTML corrector -- Convert uppercased tags to proper lowercased ones.'); - $f = _filter_htmlcorrector('test
'); + $f = Html::normalize('test
'); $this->assertEqual($f, 'test
', 'HTML corrector -- Convert uppercased tags to proper lowercased ones.'); - $f = _filter_htmlcorrector('test
test');
+ $f = Html::normalize('
test');
$this->assertEqual($f, '
test', 'HTML corrector -- Automatically close single tags.');
- $f = _filter_htmlcorrector('line1
line1
line1
line1
line1
line1
test
test
\n'); + $f = Html::normalize('test
test
\n'); $this->assertEqual($f, 'test
test
\n', 'HTML corrector -- Auto-close improperly nested tags.'); - $f = _filter_htmlcorrector('Line1 Line1 Line1 test\n test\n test\n دروبال');
+ $f = Html::normalize(' دروبال');
$this->assertEqual($f, ' دروبال
bold stuff');
+ $f = Html::normalize('
bold stuff');
$this->assertEqual($f, '
bold stuff