diff --git a/core/config/schema/core.data_types.schema.yml b/core/config/schema/core.data_types.schema.yml index c695934..3615197 100644 --- a/core/config/schema/core.data_types.schema.yml +++ b/core/config/schema/core.data_types.schema.yml @@ -364,9 +364,9 @@ field_config_base: label: 'Translatable' default_value: type: field.[%parent.field_type].value - default_value_callback: + default_value_function: type: string - label: 'Default value callback' + label: 'Default value function' settings: type: field.[%parent.field_type].field_settings third_party_settings: diff --git a/core/includes/batch.inc b/core/includes/batch.inc index 786ee3c..7e6e12f 100644 --- a/core/includes/batch.inc +++ b/core/includes/batch.inc @@ -157,7 +157,7 @@ function _batch_progress_page() { $batch['url_options']['query']['id'] = $batch['id']; $batch['url_options']['query']['op'] = $new_op; - $url = _url($batch['url'], $batch['url_options']); + $url = url($batch['url'], $batch['url_options']); $build = array( '#theme' => 'progress_bar', @@ -452,18 +452,11 @@ function _batch_finished() { if ($_batch['form_state']->getRedirect() === NULL) { $redirect = $_batch['batch_redirect'] ?: $_batch['source_url']; $options = UrlHelper::parse($redirect); - // Any path with a scheme does not correspond to a route. - if (parse_url($options['path'], PHP_URL_SCHEME)) { - $redirect = Url::fromUri($options['path'], $options); - } - else { - $redirect = \Drupal::pathValidator()->getUrlIfValid($options['path']); - if (!$redirect) { - // Stay on the same page if the redirect was invalid. - $redirect = Url::fromRoute(''); - } - $redirect->setOptions($options); + if (!UrlHelper::isExternal($options['path'])) { + $options['path'] = $GLOBALS['base_url'] . '/' . $options['path']; } + $redirect = Url::createFromPath($options['path']); + $redirect->setOptions($options); $_batch['form_state']->setRedirectUrl($redirect); } @@ -486,7 +479,7 @@ function _batch_finished() { } elseif ($callback === NULL) { // Default to RedirectResponse objects when nothing specified. - $url = _url($_batch['source_url'], array( + $url = url($_batch['source_url'], array( 'absolute' => TRUE, 'query' => array('op' => 'finish', 'id' => $_batch['id']), )); diff --git a/core/includes/common.inc b/core/includes/common.inc index 81c61b3..e57821e 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -638,24 +638,9 @@ function _format_date_callback(array $matches = NULL, $new_langcode = NULL) { * When creating links in modules, consider whether l() could be a better * alternative than url(). * - * @see \Drupal\Core\Url::fromUri() - * @see \Drupal\Core\Url::fromRoute() - * @see \Drupal\Core\Url::toString() - * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.0. - * Use \Drupal\Core\Url::fromRoute() for internal paths served by Drupal - * controllers or \Drupal\Core\Url::fromUri() for external paths or - * non-controller or sub-domain URIs such as core/install.php. Note that - * \Drupal\Core\Url::fromUri() expects a valid URI including the scheme. URIs - * from the same sub-domain that are not handled by Drupal controllers should - * be prepended with base://. For example: - * @code - * $installer_url = \Drupal\Core\Url::fromUri('base://core/install.php')->toString(); - * $external_url = \Drupal\Core\Url::fromUri('http://example.com', ['query' => ['foo' => 'bar']])->toString(); - * $internal_url = \Drupal\Core\Url::fromRoute('system.admin')->toString(); - * @endcode + * @see \Drupal\Core\Routing\UrlGeneratorInterface::generateFromPath(). */ -function _url($path = NULL, array $options = array()) { +function url($path = NULL, array $options = array()) { return \Drupal::urlGenerator()->generateFromPath($path, $options); } @@ -745,27 +730,10 @@ function drupal_http_header_attributes(array $attributes = array()) { * @return string * An HTML string containing a link to the given path. * - * @see _url() + * @see url() * @see system_page_build() - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.0. - * Use \Drupal::linkGenerator()->generate($url) where $url is an instance of - * \Drupal\Core\Url. To build a \Drupal\Core\Url object for internal paths - * served by Drupal controllers use \Drupal\Core\Url::fromRoute(). For - * external paths or non-controller or sub-domain URIs such as - * core/install.php use \Drupal\Core\Url::fromUri(). Note that - * \Drupal\Core\Url::fromUri() expects a valid URI including the scheme. URIs - * from the same sub-domain that are not handled by Drupal controllers should - * be prepended with base://. For example: - * @code - * $installer_url = \Drupal\Core\Url::fromUri('base://core/install.php')->toString(); - * $installer_link = \Drupal::linkGenerator()->generate($installer_url); - * $external_url = \Drupal\Core\Url::fromUri('http://example.com', ['query' => ['foo' => 'bar']])->toString(); - * $external_link = \Drupal::linkGenerator()->generate($external_url); - * $internal_url = \Drupal\Core\Url::fromRoute('system.admin')->toString(); - * $internal_link = \Drupal::linkGenerator()->generate($internal_url); - * @endcode */ -function _l($text, $path, array $options = array()) { +function l($text, $path, array $options = array()) { // Start building a structured representation of our link to be altered later. $variables = array( 'text' => is_array($text) ? drupal_render($text) : $text, @@ -820,7 +788,7 @@ function _l($text, $path, array $options = array()) { // The result of url() is a plain-text URL. Because we are using it here // in an HTML argument context, we need to encode it properly. - $url = String::checkPlain(_url($variables['path'], $variables['options'])); + $url = String::checkPlain(url($variables['path'], $variables['options'])); // Sanitize the link text if necessary. $text = $variables['options']['html'] ? $variables['text'] : String::checkPlain($variables['text']); @@ -1541,7 +1509,7 @@ function _drupal_add_js($data = NULL, $options = NULL) { $scriptPath = $GLOBALS['script_path']; $pathPrefix = ''; $current_query = \Drupal::service('request_stack')->getCurrentRequest()->query->all(); - _url('', array('script' => &$scriptPath, 'prefix' => &$pathPrefix)); + url('', array('script' => &$scriptPath, 'prefix' => &$pathPrefix)); $current_path = current_path(); $current_path_is_admin = FALSE; // The function path_is_admin() is not available on update.php pages. diff --git a/core/includes/form.inc b/core/includes/form.inc index 5aafe81..260ffbe 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -949,7 +949,7 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = NU if ($batch['progressive']) { // Now that we have a batch id, we can generate the redirection link in // the generic error message. - $batch['error_message'] = t('Please continue to the error page', array('@error_url' => _url($url, array('query' => array('id' => $batch['id'], 'op' => 'finished'))))); + $batch['error_message'] = t('Please continue to the error page', array('@error_url' => url($url, array('query' => array('id' => $batch['id'], 'op' => 'finished'))))); // Clear the way for the redirection to the batch processing page, by // saving and unsetting the 'destination', if there is any. @@ -977,7 +977,7 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = NU } else { $options['absolute'] = TRUE; - return new RedirectResponse(_url($batch['url'], $options)); + return new RedirectResponse(url($batch['url'], $options)); } } else { diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 7c48116..5a6859d 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -543,10 +543,7 @@ function install_run_task($task, &$install_state) { } // Process the batch. For progressive batches, this will redirect. // Otherwise, the batch will complete. - // install_redirect_url() returns core/install.php, so let's ensure to - // drop it from it and use base:// as batch_process() is using the - // unrouted URL assembler, which requires base://. - $response = batch_process(preg_replace('@^core/@', 'base://', install_redirect_url($install_state)), install_full_redirect_url($install_state)); + $response = batch_process(install_redirect_url($install_state), install_full_redirect_url($install_state)); if ($response instanceof Response) { // Save $_SESSION data from batch. \Drupal::service('session_manager')->save(); diff --git a/core/includes/pager.inc b/core/includes/pager.inc index 0dcfcb7..730be44 100644 --- a/core/includes/pager.inc +++ b/core/includes/pager.inc @@ -219,7 +219,7 @@ function template_preprocess_pager(&$variables) { $options = array( 'query' => pager_query_add_page($parameters, $element, 0), ); - $items['first']['href'] = _url($current_path, $options); + $items['first']['href'] = url($current_path, $options); if (isset($tags[0])) { $items['first']['text'] = $tags[0]; } @@ -228,7 +228,7 @@ function template_preprocess_pager(&$variables) { $options = array( 'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] - 1), ); - $items['previous']['href'] = _url($current_path, $options); + $items['previous']['href'] = url($current_path, $options); if (isset($tags[1])) { $items['previous']['text'] = $tags[1]; } @@ -244,7 +244,7 @@ function template_preprocess_pager(&$variables) { $options = array( 'query' => pager_query_add_page($parameters, $element, $i - 1), ); - $items['pages'][$i]['href'] = _url($current_path, $options); + $items['pages'][$i]['href'] = url($current_path, $options); if ($i == $pager_current) { $variables['current'] = $i; } @@ -261,7 +261,7 @@ function template_preprocess_pager(&$variables) { $options = array( 'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] + 1), ); - $items['next']['href'] = _url($current_path, $options); + $items['next']['href'] = url($current_path, $options); if (isset($tags[3])) { $items['next']['text'] = $tags[3]; } @@ -270,7 +270,7 @@ function template_preprocess_pager(&$variables) { $options = array( 'query' => pager_query_add_page($parameters, $element, $pager_max - 1), ); - $items['last']['href'] = _url($current_path, $options); + $items['last']['href'] = url($current_path, $options); if (isset($tags[4])) { $items['last']['text'] = $tags[4]; } diff --git a/core/includes/tablesort.inc b/core/includes/tablesort.inc index 0c8d25b..0b3574f 100644 --- a/core/includes/tablesort.inc +++ b/core/includes/tablesort.inc @@ -61,7 +61,7 @@ function tablesort_header(&$cell_content, array &$cell_attributes, array $header $ts['sort'] = 'asc'; $image = ''; } - $cell_content = _l($cell_content . $image, current_path(), array( + $cell_content = l($cell_content . $image, current_path(), array( 'attributes' => array('title' => $title), 'query' => array_merge($ts['query'], array( 'sort' => $ts['sort'], diff --git a/core/includes/theme.inc b/core/includes/theme.inc index f136ca1..f2c3ac1 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -2296,6 +2296,7 @@ function drupal_common_theme() { ), 'indentation' => array( 'variables' => array('size' => 1), + 'function' => 'theme_indentation', ), // From theme.maintenance.inc. 'maintenance_page' => array( @@ -2312,9 +2313,15 @@ function drupal_common_theme() { ), 'authorize_message' => array( 'variables' => array('message' => NULL, 'success' => TRUE), + 'function' => 'theme_authorize_message', + 'path' => 'core/includes', + 'file' => 'theme.maintenance.inc', ), 'authorize_report' => array( 'variables' => array('messages' => array()), + 'function' => 'theme_authorize_report', + 'path' => 'core/includes', + 'file' => 'theme.maintenance.inc', ), // From pager.inc. 'pager' => array( diff --git a/core/lib/Drupal/Component/Utility/UrlHelper.php b/core/lib/Drupal/Component/Utility/UrlHelper.php index 45a8036..cf87435 100644 --- a/core/lib/Drupal/Component/Utility/UrlHelper.php +++ b/core/lib/Drupal/Component/Utility/UrlHelper.php @@ -134,7 +134,7 @@ public static function filterQueryParameters(array $query, array $exclude = arra * - fragment: The fragment component from $url, if it exists. * * @see \Drupal\Core\Utility\LinkGenerator - * @see _url() + * @see url() * @see http://tools.ietf.org/html/rfc3986 * * @ingroup php_wrappers @@ -288,7 +288,7 @@ public static function setAllowedProtocols(array $protocols = array()) { * to being output to an HTML attribute value. It is often called as part of * check_url() or Drupal\Component\Utility\Xss::filter(), but those functions * return an HTML-encoded string, so this function can be called independently - * when the output needs to be a plain-text string for passing to t(), _l(), + * when the output needs to be a plain-text string for passing to t(), l(), * Drupal\Core\Template\Attribute, or another function that will call * \Drupal\Component\Utility\String::checkPlain() separately. * diff --git a/core/lib/Drupal/Core/Ajax/RedirectCommand.php b/core/lib/Drupal/Core/Ajax/RedirectCommand.php index 4b31e52..4b0914a 100644 --- a/core/lib/Drupal/Core/Ajax/RedirectCommand.php +++ b/core/lib/Drupal/Core/Ajax/RedirectCommand.php @@ -28,7 +28,7 @@ class RedirectCommand implements CommandInterface { * * @param string $url * The URL that will be loaded into window.location. This should be a full - * URL, one that has already been run through the _url() function. + * URL, one that has already been run through the url() function. */ public function __construct($url) { $this->url = $url; diff --git a/core/lib/Drupal/Core/Asset/CssOptimizer.php b/core/lib/Drupal/Core/Asset/CssOptimizer.php index baa2de4..1090d5a 100644 --- a/core/lib/Drupal/Core/Asset/CssOptimizer.php +++ b/core/lib/Drupal/Core/Asset/CssOptimizer.php @@ -119,7 +119,7 @@ public function loadFile($file, $optimize = NULL, $reset_basepath = TRUE) { * Loads stylesheets recursively and returns contents with corrected paths. * * This function is used for recursive loading of stylesheets and - * returns the stylesheet content with all _url() paths corrected. + * returns the stylesheet content with all url() paths corrected. * * @param array $matches * An array of matches by a preg_replace_callback() call that scans for @@ -138,10 +138,10 @@ protected function loadNestedFile($matches) { // Determine the file's directory. $directory = dirname($filename); // If the file is in the current directory, make sure '.' doesn't appear in - // the _url() path. + // the url() path. $directory = $directory == '.' ? '' : $directory .'/'; - // Alter all internal _url() paths. Leave external paths alone. We don't need + // Alter all internal url() paths. Leave external paths alone. We don't need // to normalize absolute paths here (i.e. remove folder/... segments) // because that will be done later. return preg_replace('/url\(\s*([\'"]?)(?![a-z]+:|\/+)([^\'")]+)([\'"]?)\s*\)/i', 'url(\1' . $directory . '\2\3)', $file); @@ -215,7 +215,7 @@ protected function processCss($contents, $optimize = FALSE) { * * @param array $matches * An array of matches by a preg_replace_callback() call that scans for - * _url() references in CSS files, except for external or absolute ones. + * url() references in CSS files, except for external or absolute ones. * * Note: the only reason this method is public is so color.module can call it; * it is not on the AssetOptimizerInterface, so future refactorings can make diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 07e50c7..de1d04f 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -192,7 +192,7 @@ public function urlInfo($rel = 'canonical', array $options = []) { } } - // Pass the entity data to _url() so that alter functions do not need to + // Pass the entity data to url() so that alter functions do not need to // look up this entity again. $uri ->setOption('entity_type', $this->getEntityTypeId()) diff --git a/core/lib/Drupal/Core/Field/BaseFieldDefinition.php b/core/lib/Drupal/Core/Field/BaseFieldDefinition.php index 613f88f..7eb0d8a 100644 --- a/core/lib/Drupal/Core/Field/BaseFieldDefinition.php +++ b/core/lib/Drupal/Core/Field/BaseFieldDefinition.php @@ -397,7 +397,7 @@ public function getDefaultValue(ContentEntityInterface $entity) { * * If set, the callback overrides any set default value. * - * @param string|null $callback + * @param callable|null $callback * The callback to invoke for getting the default value (pass NULL to unset * a previously set callback). The callback will be invoked with the * following arguments: @@ -411,9 +411,6 @@ public function getDefaultValue(ContentEntityInterface $entity) { * @return $this */ public function setDefaultValueCallback($callback) { - if (isset($callback) && !is_string($callback)) { - throw new \InvalidArgumentException('Default value callback must be a string, like "function_name" or "ClassName::methodName"'); - } $this->definition['default_value_callback'] = $callback; return $this; } diff --git a/core/lib/Drupal/Core/Field/FieldConfigBase.php b/core/lib/Drupal/Core/Field/FieldConfigBase.php index e0764cd..69473f4 100644 --- a/core/lib/Drupal/Core/Field/FieldConfigBase.php +++ b/core/lib/Drupal/Core/Field/FieldConfigBase.php @@ -135,7 +135,7 @@ * hook_field_schema(). If the number of items exceeds the cardinality of the * field, extraneous items will be ignored. * - * This property is overlooked if the $default_value_callback is non-empty. + * This property is overlooked if the $default_value_function is non-empty. * * Example for a integer field: * @code @@ -165,7 +165,7 @@ * * @var string */ - public $default_value_callback = ''; + public $default_value_function = ''; /** * The field storage object. @@ -334,8 +334,8 @@ public function isRequired() { */ public function getDefaultValue(ContentEntityInterface $entity) { // Allow custom default values function. - if ($callback = $this->default_value_callback) { - $value = call_user_func($callback, $entity, $this); + if ($function = $this->default_value_function) { + $value = call_user_func($function, $entity, $this); } else { $value = $this->default_value; diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php index 393b827..f6ae7d5 100644 --- a/core/lib/Drupal/Core/Field/FieldItemList.php +++ b/core/lib/Drupal/Core/Field/FieldItemList.php @@ -318,7 +318,7 @@ public function getConstraints() { * {@inheritdoc} */ public function defaultValuesForm(array &$form, FormStateInterface $form_state) { - if (empty($this->getFieldDefinition()->default_value_callback)) { + if (empty($this->getFieldDefinition()->default_value_function)) { // Place the input in a separate place in the submitted values tree. $widget = $this->defaultValueWidget($form_state); diff --git a/core/lib/Drupal/Core/Menu/LocalTaskManager.php b/core/lib/Drupal/Core/Menu/LocalTaskManager.php index 3914d8e..4e1f675 100644 --- a/core/lib/Drupal/Core/Menu/LocalTaskManager.php +++ b/core/lib/Drupal/Core/Menu/LocalTaskManager.php @@ -250,7 +250,7 @@ public function getLocalTasksForRoute($route_name) { foreach ($children[$parent] as $plugin_id => $task_info) { $plugin = $this->createInstance($plugin_id); $this->instances[$route_name][$level][$plugin_id] = $plugin; - // Normally, _l() compares the href of every link with the current + // Normally, l() compares the href of every link with the current // path and sets the active class accordingly. But the parents of // the current local task may be on a different route in which // case we have to set the class manually by flagging it active. diff --git a/core/lib/Drupal/Core/Menu/MenuLinkBase.php b/core/lib/Drupal/Core/Menu/MenuLinkBase.php index c82bef3..b09bfa9 100644 --- a/core/lib/Drupal/Core/Menu/MenuLinkBase.php +++ b/core/lib/Drupal/Core/Menu/MenuLinkBase.php @@ -141,7 +141,9 @@ public function getUrlObject($title_attribute = TRUE) { return new Url($this->pluginDefinition['route_name'], $this->pluginDefinition['route_parameters'], $options); } else { - return Url::fromUri($this->pluginDefinition['url'], $options); + $url = Url::createFromPath($this->pluginDefinition['url']); + $url->setOptions($options); + return $url; } } diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php index 2ed2fb0..fb75390 100644 --- a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php @@ -1278,7 +1278,7 @@ protected static function schemaDefinition() { 'not null' => FALSE, ), 'options' => array( - 'description' => 'A serialized array of options to be passed to the _url() or _l() function, such as a query string or HTML attributes.', + 'description' => 'A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.', 'type' => 'blob', 'size' => 'big', 'not null' => FALSE, diff --git a/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php b/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php index 8711ee2..164f7f5 100644 --- a/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php +++ b/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php @@ -110,7 +110,7 @@ public function preparePage(HtmlPage $page, &$page_array) { foreach (drupal_get_feeds() as $feed) { // Force the URL to be absolute, for consistency with other tags // output by Drupal. - $link = new FeedLinkElement($feed['title'], _url($feed['url'], array('absolute' => TRUE))); + $link = new FeedLinkElement($feed['title'], url($feed['url'], array('absolute' => TRUE))); $page->addLinkElement($link); } diff --git a/core/lib/Drupal/Core/Path/AliasWhitelist.php b/core/lib/Drupal/Core/Path/AliasWhitelist.php index 11c68f7..394dfa2 100644 --- a/core/lib/Drupal/Core/Path/AliasWhitelist.php +++ b/core/lib/Drupal/Core/Path/AliasWhitelist.php @@ -88,7 +88,7 @@ protected function loadMenuPathRoots() { */ public function get($offset) { $this->lazyLoadCache(); - // _url() may be called with paths that are not represented by menu router + // url() may be called with paths that are not represented by menu router // items such as paths that will be rewritten by hook_url_outbound_alter(). // Therefore internally TRUE is used to indicate whitelisted paths. FALSE is // used to indicate paths that have already been checked but are not diff --git a/core/lib/Drupal/Core/Path/PathValidator.php b/core/lib/Drupal/Core/Path/PathValidator.php index e6ebf5d..1b519c7 100644 --- a/core/lib/Drupal/Core/Path/PathValidator.php +++ b/core/lib/Drupal/Core/Path/PathValidator.php @@ -99,7 +99,7 @@ public function getUrlIfValid($path) { if (empty($parsed_url['path'])) { return FALSE; } - return Url::fromUri($path); + return Url::createFromPath($path); } $path = ltrim($path, '/'); diff --git a/core/lib/Drupal/Core/Render/Element/Link.php b/core/lib/Drupal/Core/Render/Element/Link.php index 474e9f5..12bddb7 100644 --- a/core/lib/Drupal/Core/Render/Element/Link.php +++ b/core/lib/Drupal/Core/Render/Element/Link.php @@ -7,7 +7,7 @@ namespace Drupal\Core\Render\Element; -use Drupal\Core\Url as UrlObject; +use Drupal\Core\Url; /** * Provides a link render element. @@ -34,21 +34,21 @@ public function getInfo() { * Doing so during pre_render gives modules a chance to alter the link parts. * * @param array $element - * A structured array whose keys form the arguments to _l(): - * - #title: The link text to pass as argument to _l(). + * A structured array whose keys form the arguments to l(): + * - #title: The link text to pass as argument to l(). * - One of the following * - #route_name and (optionally) a #route_parameters array; The route * name and route parameters which will be passed into the link * generator. - * - #href: The system path or URL to pass as argument to _l(). - * - #options: (optional) An array of options to pass to _l() or the link + * - #href: The system path or URL to pass as argument to l(). + * - #options: (optional) An array of options to pass to l() or the link * generator. * * @return array * The passed-in element containing a rendered link in '#markup'. */ public static function preRenderLink($element) { - // By default, link options to pass to _l() are normally set in #options. + // By default, link options to pass to l() are normally set in #options. $element += array('#options' => array()); // However, within the scope of renderable elements, #attributes is a valid // way to specify attributes, too. Take them into account, but do not override @@ -85,11 +85,10 @@ public static function preRenderLink($element) { if (isset($element['#route_name'])) { $element['#route_parameters'] = empty($element['#route_parameters']) ? array() : $element['#route_parameters']; - $element['#markup'] = \Drupal::l($element['#title'], new UrlObject($element['#route_name'], $element['#route_parameters'], $element['#options'])); + $element['#markup'] = \Drupal::l($element['#title'], new Url($element['#route_name'], $element['#route_parameters'], $element['#options'])); } else { - // @todo Convert to \Drupal::l(): https://www.drupal.org/node/2347045. - $element['#markup'] = _l($element['#title'], $element['#href'], $element['#options']); + $element['#markup'] = l($element['#title'], $element['#href'], $element['#options']); } return $element; } diff --git a/core/lib/Drupal/Core/Render/Element/RenderElement.php b/core/lib/Drupal/Core/Render/Element/RenderElement.php index 38e09fc..553496c 100644 --- a/core/lib/Drupal/Core/Render/Element/RenderElement.php +++ b/core/lib/Drupal/Core/Render/Element/RenderElement.php @@ -248,7 +248,7 @@ public static function preRenderAjaxForm($element) { } // Change path to URL. - $settings['url'] = isset($settings['path']) ? _url($settings['path'], $settings['options']) : NULL; + $settings['url'] = isset($settings['path']) ? url($settings['path'], $settings['options']) : NULL; unset($settings['path'], $settings['options']); // Add special data to $settings['submit'] so that when this element @@ -286,7 +286,7 @@ public static function preRenderAjaxForm($element) { } // Change progress path to a full URL. if (isset($settings['progress']['path'])) { - $settings['progress']['url'] = _url($settings['progress']['path']); + $settings['progress']['url'] = url($settings['progress']['path']); unset($settings['progress']['path']); } diff --git a/core/lib/Drupal/Core/Routing/UrlGenerator.php b/core/lib/Drupal/Core/Routing/UrlGenerator.php index ae41c9c..8e2522a 100644 --- a/core/lib/Drupal/Core/Routing/UrlGenerator.php +++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php @@ -238,7 +238,7 @@ public function generateFromPath($path = NULL, $options = array()) { // \Drupal\Component\Utility\UrlHelper::stripDangerousProtocols() if $path // contains a ':' before any / ? or #. Note: we could use // \Drupal\Component\Utility\UrlHelper::isExternal($path) here, but that - // would require another function call, and performance inside _url() is + // would require another function call, and performance inside url() is // critical. $colonpos = strpos($path, ':'); $options['external'] = ($colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && UrlHelper::stripDangerousProtocols($path) == $path); diff --git a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php index 06e600d..ad58aca 100644 --- a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php +++ b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php @@ -67,10 +67,10 @@ * - 'script': Added to the URL between the base path and the path prefix. * Defaults to empty string when clean URLs are in effect, and to * 'index.php/' when they are not. - * - 'entity_type': The entity type of the object that called _url(). Only - * set if _url() is invoked by Drupal\Core\Entity\Entity::uri(). + * - 'entity_type': The entity type of the object that called url(). Only + * set if url() is invoked by Drupal\Core\Entity\Entity::uri(). * - 'entity': The entity object (such as a node) for which the URL is being - * generated. Only set if _url() is invoked by Drupal\Core\Entity\Entity::uri(). + * generated. Only set if url() is invoked by Drupal\Core\Entity\Entity::uri(). * * @return * A string containing a URL to the given path. diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php index 632e42a..20c71e6 100644 --- a/core/lib/Drupal/Core/Template/TwigExtension.php +++ b/core/lib/Drupal/Core/Template/TwigExtension.php @@ -214,7 +214,7 @@ public function getLink($text, $url) { } else { // @todo Convert once https://www.drupal.org/node/2306901 is in - return _l($text, $url); + return l($text, $url); } } diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php index da3122c..8c9efb3 100644 --- a/core/lib/Drupal/Core/Theme/Registry.php +++ b/core/lib/Drupal/Core/Theme/Registry.php @@ -401,6 +401,9 @@ protected function build() { * @see _theme() * @see hook_theme() * @see list_themes() + * @see twig_render_template() + * + * @throws \BadFunctionCallException */ protected function processExtension(&$cache, $name, $type, $theme, $path) { $result = array(); @@ -430,12 +433,6 @@ protected function processExtension(&$cache, $name, $type, $theme, $path) { $result[$hook]['type'] = $type; $result[$hook]['theme path'] = $path; - // If function and file are omitted, default to standard naming - // conventions. - if (!isset($info['template']) && !isset($info['function'])) { - $result[$hook]['function'] = ($type == 'module' ? 'theme_' : $name . '_') . $hook; - } - if (isset($cache[$hook]['includes'])) { $result[$hook]['includes'] = $cache[$hook]['includes']; } @@ -451,20 +448,37 @@ protected function processExtension(&$cache, $name, $type, $theme, $path) { $result[$hook]['includes'][] = $include_file; } + // A template file is the default implementation for a theme hook, but + // if the theme hook specifies a function callback instead, check to + // ensure the function actually exists. + if (isset($info['function']) && !function_exists($info['function'])) { + throw new \BadFunctionCallException(sprintf( + 'Theme hook "%s" refers to a theme function callback that does not exist: "%s"', + $hook, + $info['function'] + )); + } + // Provide a default naming convention for 'template' based on the + // hook used. If the template does not exist, the theme engine used + // should throw an exception at runtime when attempting to include + // the template file. + elseif (!isset($info['template'])) { + $info['template'] = strtr($hook, '_', '-'); + $result[$hook]['template'] = $info['template']; + } + + // Prepend the current theming path when none is set. This is required + // for the default theme engine to know where the template lives. + if (isset($result[$hook]['template']) && !isset($info['path'])) { + $result[$hook]['path'] = $path . '/templates'; + } + // If the default keys are not set, use the default values registered // by the module. if (isset($cache[$hook])) { $result[$hook] += array_intersect_key($cache[$hook], $hook_defaults); } - // The following apply only to theming hooks implemented as templates. - if (isset($info['template'])) { - // Prepend the current theming path when none is set. - if (!isset($info['path'])) { - $result[$hook]['template'] = $path . '/templates/' . $info['template']; - } - } - // Preprocess variables for all theming hooks, whether the hook is // implemented as a template or as a function. Ensure they are arrays. if (!isset($info['preprocess functions']) || !is_array($info['preprocess functions'])) { diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php index a6f0220..d97f017 100644 --- a/core/lib/Drupal/Core/Url.php +++ b/core/lib/Drupal/Core/Url.php @@ -7,10 +7,10 @@ namespace Drupal\Core; +use Drupal\Component\Utility\UrlHelper; use Drupal\Core\DependencyInjection\DependencySerializationTrait; use Drupal\Core\Routing\UrlGeneratorInterface; use Drupal\Core\Session\AccountInterface; -use Drupal\Core\Utility\UnroutedUrlAssemblerInterface; use Symfony\Cmf\Component\Routing\RouteObjectInterface; use Symfony\Component\HttpFoundation\Request; @@ -28,13 +28,6 @@ class Url { protected $urlGenerator; /** - * The unrouted URL assembler. - * - * @var \Drupal\Core\Utility\UnroutedUrlAssemblerInterface - */ - protected $urlAssembler; - - /** * The access manager * * @var \Drupal\Core\Access\AccessManagerInterface @@ -63,35 +56,24 @@ class Url { protected $options = array(); /** - * Indicates whether this object contains an external URL. + * Indicates whether this URL is external. * * @var bool */ protected $external = FALSE; /** - * Indicates whether this URL is for a URI without a Drupal route. - * - * @var bool - */ - protected $unrouted = FALSE; - - /** - * The non-route URI. + * The external path. * - * Only used if self::$unrouted is TRUE. + * Only used if self::$external is TRUE. * * @var string */ - protected $uri; + protected $path; /** * Constructs a new Url object. * - * In most cases, use Url::fromRoute() or Url::fromUri() rather than - * constructing Url objects directly in order to avoid ambiguity and make your - * code more self-documenting. - * * @param string $route_name * The name of the route * @param array $route_parameters @@ -113,12 +95,6 @@ class Url { * defined, the current scheme is used, so the user stays on HTTP or HTTPS * respectively. if mixed mode sessions are permitted, TRUE enforces HTTPS * and FALSE enforces HTTP. - * - * @see static::fromRoute() - * @see static::fromUri() - * - * @todo Update this documentation for non-routed URIs in - * https://www.drupal.org/node/2346787 */ public function __construct($route_name, $route_parameters = array(), $options = array()) { $this->routeName = $route_name; @@ -127,101 +103,44 @@ public function __construct($route_name, $route_parameters = array(), $options = } /** - * Creates a new Url object for a URL that has a Drupal route. - * - * This method is for URLs that have Drupal routes (that is, most pages - * generated by Drupal). For non-routed local URIs relative to the base - * path (like robots.txt) use Url::fromUri() with the base:// scheme. - * - * @param string $route_name - * The name of the route - * @param array $route_parameters - * (optional) An associative array of route parameter names and values. - * @param array $options - * (optional) An associative array of additional URL options, with the - * following elements: - * - 'query': An array of query key/value-pairs (without any URL-encoding) - * to append to the URL. Merged with the parameters array. - * - 'fragment': A fragment identifier (named anchor) to append to the URL. - * Do not include the leading '#' character. - * - 'absolute': Defaults to FALSE. Whether to force the output to be an - * absolute link (beginning with http:). Useful for links that will be - * displayed outside the site, such as in an RSS feed. - * - 'language': An optional language object used to look up the alias - * for the URL. If $options['language'] is omitted, it defaults to the - * current language for the language type LanguageInterface::TYPE_URL. - * - 'https': Whether this URL should point to a secure location. If not - * defined, the current scheme is used, so the user stays on HTTP or HTTPS - * respectively. if mixed mode sessions are permitted, TRUE enforces HTTPS - * and FALSE enforces HTTP. - * - * @return \Drupal\Core\Url - * A new Url object for a routed (internal to Drupal) URL. - * - * @see static::fromUri() - */ - public static function fromRoute($route_name, $route_parameters = array(), $options = array()) { - return new static($route_name, $route_parameters, $options); - } - - /** - * Creates a new Url object for a URI that does not have a Drupal route. - * - * This method is for generating URLs for URIs that do not have Drupal - * routes, both external URLs and unrouted local URIs like - * base://robots.txt. For URLs that have Drupal routes (that is, most pages - * generated by Drupal), use Url::fromRoute(). + * Returns the Url object matching a path. READ THE FOLLOWING SECURITY NOTE. * - * @param string $uri - * The URI of the external resource including the scheme. For Drupal paths - * that are not handled by the routing system, use base:// for the scheme. - * @param array $options - * (optional) An associative array of additional URL options, with the - * following elements: - * - 'query': An array of query key/value-pairs (without any URL-encoding) - * to append to the URL. Merged with the parameters array. - * - 'fragment': A fragment identifier (named anchor) to append to the URL. - * Do not include the leading '#' character. - * - 'absolute': Defaults to FALSE. Whether to force the output to be an - * absolute link (beginning with http:). Useful for links that will be - * displayed outside the site, such as in an RSS feed. - * - 'language': An optional language object used to look up the alias - * for the URL. If $options['language'] is omitted, it defaults to the - * current language for the language type LanguageInterface::TYPE_URL. - * - 'https': Whether this URL should point to a secure location. If not - * defined, the current scheme is used, so the user stays on HTTP or HTTPS - * respectively. if mixed mode sessions are permitted, TRUE enforces HTTPS - * and FALSE enforces HTTP. + * SECURITY NOTE: The path is not checked to be valid and accessible by the + * current user to allow storing and reusing Url objects by different users. + * The 'path.validator' service getUrlIfValid() method should be used instead + * of this one if validation and access check is desired. Otherwise, + * 'access_manager' service checkNamedRoute() method should be used on the + * router name and parameters stored in the Url object returned by this + * method. * - * @return \Drupal\Core\Url - * A new Url object for an unrouted (non-Drupal) URL. + * @param string $path + * A path (e.g. 'node/1', 'http://drupal.org'). * - * @throws \InvalidArgumentException - * Thrown when the passed in path has no scheme. + * @return static + * An Url object. Warning: the object is created even if the current user + * can not access the path. * - * @see static::fromRoute() + * @throws \Drupal\Core\Routing\MatchingRouteNotFoundException + * Thrown when the path cannot be matched. */ - public static function fromUri($uri, $options = array()) { - if (!parse_url($uri, PHP_URL_SCHEME)) { - throw new \InvalidArgumentException('You must use a valid URI scheme. Use base:// for a path, e.g., to a Drupal file that needs the base path. Do not use this for internal paths controlled by Drupal.'); + public static function createFromPath($path) { + if (UrlHelper::isExternal($path)) { + $url = new static($path); + $url->setExternal(); + return $url; } - $url = new static($uri, array(), $options); - $url->setUnrouted(); - - return $url; + // Special case the front page route. + if ($path == '') { + return new static($path); + } + else { + return static::createFromRequest(Request::create("/$path")); + } } /** - * Returns the Url object matching a request. - * - * SECURITY NOTE: The request path is not checked to be valid and accessible - * by the current user to allow storing and reusing Url objects by different - * users. The 'path.validator' service getUrlIfValid() method should be used - * instead of this one if validation and access check is desired. Otherwise, - * 'access_manager' service checkNamedRoute() method should be used on the - * router name and parameters stored in the Url object returned by this - * method. + * Returns the Url object matching a request. READ THE SECURITY NOTE ON createFromPath(). * * @param \Symfony\Component\HttpFoundation\Request $request * A request object. @@ -244,23 +163,23 @@ public static function createFromRequest(Request $request) { } /** - * Sets this Url to encapsulate an unrouted URI. + * Sets this Url to be external. * * @return $this */ - protected function setUnrouted() { - $this->unrouted = TRUE; - // What was passed in as the route name is actually the URI. - // @todo Consider fixing this in https://www.drupal.org/node/2346787. - $this->uri = $this->routeName; + protected function setExternal() { + $this->external = TRUE; + + // What was passed in as the route name is actually the path. + $this->path = $this->routeName; + // Set empty route name and parameters. $this->routeName = NULL; $this->routeParameters = array(); - // @todo Add a method for the check below in - // https://www.drupal.org/node/2346859. - if ($this->external = strpos($this->uri, 'base://') !== 0) { - $this->options['external'] = TRUE; - } + // Flag the path as external so the UrlGenerator does not need to check. + $this->options['external'] = TRUE; + + return $this; } /** @@ -273,24 +192,15 @@ public function isExternal() { } /** - * Indicates if this Url has a Drupal route. - * - * @return bool - */ - public function isRouted() { - return !$this->unrouted; - } - - /** * Returns the route name. * * @return string * * @throws \UnexpectedValueException. - * If this is a URI with no corresponding route. + * If this is an external URL with no corresponding route. */ public function getRouteName() { - if ($this->unrouted) { + if ($this->isExternal()) { throw new \UnexpectedValueException('External URLs do not have an internal route name.'); } @@ -303,10 +213,10 @@ public function getRouteName() { * @return array * * @throws \UnexpectedValueException. - * If this is a URI with no corresponding route. + * If this is an external URL with no corresponding route. */ public function getRouteParameters() { - if ($this->unrouted) { + if ($this->isExternal()) { throw new \UnexpectedValueException('External URLs do not have internal route parameters.'); } @@ -320,13 +230,10 @@ public function getRouteParameters() { * The array of parameters. * * @return $this - * - * @throws \UnexpectedValueException. - * If this is a URI with no corresponding route. */ public function setRouteParameters($parameters) { - if ($this->unrouted) { - throw new \UnexpectedValueException('External URLs do not have route parameters.'); + if ($this->isExternal()) { + throw new \Exception('External URLs do not have route parameters.'); } $this->routeParameters = $parameters; return $this; @@ -341,13 +248,10 @@ public function setRouteParameters($parameters) { * The route parameter. * * @return $this - * - * @throws \UnexpectedValueException. - * If this is a URI with no corresponding route. */ public function setRouteParameter($key, $value) { - if ($this->unrouted) { - throw new \UnexpectedValueException('External URLs do not have route parameters.'); + if ($this->isExternal()) { + throw new \Exception('External URLs do not have route parameters.'); } $this->routeParameters[$key] = $value; return $this; @@ -408,22 +312,22 @@ public function setOption($name, $value) { } /** - * Returns the URI of the URL. + * Returns the external path of the URL. * - * Only to be used if self::$unrouted is TRUE. + * Only to be used if self::$external is TRUE. * * @return string - * A URI not connected to a route. May be an external URL. + * The external path. * * @throws \UnexpectedValueException - * Thrown when the URI was requested for a routed URL. + * Thrown when the path was requested for an internal URL. */ - public function getUri() { - if (!$this->unrouted) { - throw new \UnexpectedValueException('This URL has a Drupal route, so the canonical form is not a URI.'); + public function getPath() { + if (!$this->isExternal()) { + throw new \UnexpectedValueException('Internal URLs do not have external paths.'); } - return $this->uri; + return $this->path; } /** @@ -440,11 +344,11 @@ public function setAbsolute($absolute = TRUE) { } /** - * Generates the URI for this Url object. + * Generates the path for this Url object. */ public function toString() { - if ($this->unrouted) { - return $this->unroutedUrlAssembler()->assemble($this->getUri(), $this->getOptions()); + if ($this->isExternal()) { + return $this->urlGenerator()->generateFromPath($this->getPath(), $this->getOptions()); } return $this->urlGenerator()->generateFromRoute($this->getRouteName(), $this->getRouteParameters(), $this->getOptions()); @@ -457,10 +361,9 @@ public function toString() { * An associative array containing all the properties of the route. */ public function toArray() { - if ($this->unrouted) { + if ($this->isExternal()) { return array( - // @todo Change 'path' to 'href': https://www.drupal.org/node/2347025. - 'path' => $this->getUri(), + 'path' => $this->getPath(), 'options' => $this->getOptions(), ); } @@ -480,9 +383,9 @@ public function toArray() { * An associative array suitable for a render array. */ public function toRenderArray() { - if ($this->unrouted) { + if ($this->isExternal()) { return array( - '#href' => $this->getUri(), + '#href' => $this->getPath(), '#options' => $this->getOptions(), ); } @@ -505,14 +408,14 @@ public function toRenderArray() { * The internal path for this route. * * @throws \UnexpectedValueException. - * If this is a URI with no corresponding system path. + * If this is an external URL with no corresponding system path. * * @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 getInternalPath() { - if ($this->unrouted) { - throw new \UnexpectedValueException('Unrouted URIs do not have internal representations.'); + if ($this->isExternal()) { + throw new \UnexpectedValueException('External URLs do not have internal representations.'); } return $this->urlGenerator()->getPathFromRoute($this->getRouteName(), $this->getRouteParameters()); } @@ -570,19 +473,6 @@ protected function urlGenerator() { } /** - * Gets the unrouted URL assembler for non-Drupal URLs. - * - * @return \Drupal\Core\Utility\UnroutedUrlAssemblerInterface - * The unrouted URL assembler. - */ - protected function unroutedUrlAssembler() { - if (!$this->urlAssembler) { - $this->urlAssembler = \Drupal::service('unrouted_url_assembler'); - } - return $this->urlAssembler; - } - - /** * Sets the URL generator. * * @param \Drupal\Core\Routing\UrlGeneratorInterface @@ -595,17 +485,4 @@ public function setUrlGenerator(UrlGeneratorInterface $url_generator) { return $this; } - /** - * Sets the unrouted URL assembler. - * - * @param \Drupal\Core\Utility\UnroutedUrlAssemblerInterface - * The unrouted URL assembler. - * - * @return $this - */ - public function setUnroutedUrlAssembler(UnroutedUrlAssemblerInterface $url_assembler) { - $this->urlAssembler = $url_assembler; - return $this; - } - } diff --git a/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php b/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php index 52d1d13..05fb19f 100644 --- a/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php +++ b/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php @@ -56,7 +56,7 @@ public function assemble($uri, array $options = []) { // UrlHelper::isExternal() only returns true for safe protocols. return $this->buildExternalUrl($uri, $options); } - throw new \InvalidArgumentException('You must use a valid URI scheme. Use base:// for a path e.g. to a Drupal file that needs the base path.'); + throw new \InvalidArgumentException('You must use a valid URI scheme. Use base:// for a path e.g. to a Drupal file that needs the base path.'); } /** diff --git a/core/lib/Drupal/Core/Utility/UnroutedUrlAssemblerInterface.php b/core/lib/Drupal/Core/Utility/UnroutedUrlAssemblerInterface.php index c1caa44..cba87fe 100644 --- a/core/lib/Drupal/Core/Utility/UnroutedUrlAssemblerInterface.php +++ b/core/lib/Drupal/Core/Utility/UnroutedUrlAssemblerInterface.php @@ -12,24 +12,23 @@ interface UnroutedUrlAssemblerInterface { /** - * Builds a domain-local or external URL from a URI. + * Builds a domain-local or external URL from a path or URL. * * For actual implementations the logic probably has to be split up between - * domain-local URIs and external URLs. + * domain-local and external URLs. * * @param string $uri - * A local URI or an external URL being linked to, such as "base://foo" + * A path on the same domain or external URL being linked to, such as "foo" * or "http://example.com/foo". * - If you provide a full URL, it will be considered an external URL as * long as it has an allowed protocol. - * - If you provide only a local URI (e.g. "base://foo"), it will be - * considered a path local to Drupal, but not handled by the routing - * system. The base path (the subdirectory where the front controller - * is found) will be added to the path. Additional query arguments for - * local paths must be supplied in $options['query'], not part of $uri. + * - If you provide only a path (e.g. "foo"), it will be + * considered a URL local to the same domain. Additional query + * arguments for local paths must be supplied in $options['query'], not + * included in $path. * - If your external URL contains a query (e.g. http://example.com/foo?a=b), * then you can either URL encode the query keys and values yourself and - * include them in $uri, or use $options['query'] to let this method + * include them in $path, or use $options['query'] to let this method * URL encode them. * * @param array $options @@ -49,9 +48,6 @@ * * @return * A string containing a relative or absolute URL. - * - * @throws \InvalidArgumentException - * Thrown when the passed in path has no scheme. */ public function assemble($uri, array $options = array()); diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index 5e85078..aecd844 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -26,7 +26,6 @@ function aggregator_help($route_name, RouteMatchInterface $route_match) { $output .= '

' . t('The Aggregator module is an on-site syndicator and news reader that gathers and displays fresh content from RSS-, RDF-, and Atom-based feeds made available across the web. Thousands of sites (particularly news sites and blogs) publish their latest headlines in feeds, using a number of standardized XML-based formats. For more information, see the online documentation for the Aggregator module.', array('!aggregator-module' => 'https://drupal.org/documentation/modules/aggregator')) . '

'; $output .= '

' . t('Uses') . '

'; $output .= '
'; - // Check if the aggregator sources View is enabled. if ($url = $path_validator->getUrlIfValid('aggregator/sources')) { $output .= '
' . t('Viewing feeds') . '
'; $output .= '
' . t('Users view feed content in the main aggregator display, or by their source (usually via an RSS feed reader). The most recent content in a feed can be displayed as a block through the Blocks administration page.', array('!aggregator' => \Drupal::url('aggregator.page_last'), '!aggregator-sources' => $url->toString(), '!admin-block' => \Drupal::url('block.admin_display'))) . '
'; @@ -34,7 +33,6 @@ function aggregator_help($route_name, RouteMatchInterface $route_match) { $output .= '
' . t('Adding, editing, and deleting feeds') . '
'; $output .= '
' . t('Administrators can add, edit, and delete feeds, and choose how often to check each feed for newly updated items on the Feed aggregator administration page.', array('!feededit' => \Drupal::url('aggregator.admin_overview'))) . '
'; $output .= '
' . t('OPML integration') . '
'; - // Check if the aggregator opml View is enabled. if ($url = $path_validator->getUrlIfValid('aggregator/opml')) { $output .= '
' . t('A machine-readable OPML file of all feeds is available. OPML is an XML-based file format used to share outline-structured information such as a list of RSS feeds. Feeds can also be imported via an OPML file.', array('!aggregator-opml' => $url->toString(), '!import-opml' => \Drupal::url('aggregator.opml_add'))) . '
'; } diff --git a/core/modules/aggregator/src/Entity/Item.php b/core/modules/aggregator/src/Entity/Item.php index 0cebc3b..493e4cb 100644 --- a/core/modules/aggregator/src/Entity/Item.php +++ b/core/modules/aggregator/src/Entity/Item.php @@ -244,7 +244,7 @@ public function getListCacheTags() { * Entity URI callback. */ public static function buildUri(ItemInterface $item) { - return Url::fromUri($item->getLink()); + return Url::createFromPath($item->getLink()); } } diff --git a/core/modules/aggregator/src/Tests/FeedParserTest.php b/core/modules/aggregator/src/Tests/FeedParserTest.php index a6d44c7..2ac0a94 100644 --- a/core/modules/aggregator/src/Tests/FeedParserTest.php +++ b/core/modules/aggregator/src/Tests/FeedParserTest.php @@ -80,7 +80,7 @@ function testHtmlEntitiesSample() { */ function testRedirectFeed() { // Simulate a typo in the URL to force a curl exception. - $invalid_url = _url('aggregator/redirect', array('absolute' => TRUE)); + $invalid_url = url('aggregator/redirect', array('absolute' => TRUE)); $feed = entity_create('aggregator_feed', array('url' => $invalid_url, 'title' => $this->randomMachineName())); $feed->save(); $feed->refreshItems(); diff --git a/core/modules/aggregator/src/Tests/Views/IntegrationTest.php b/core/modules/aggregator/src/Tests/Views/IntegrationTest.php index 8b6edaa..5084bdf 100644 --- a/core/modules/aggregator/src/Tests/Views/IntegrationTest.php +++ b/core/modules/aggregator/src/Tests/Views/IntegrationTest.php @@ -107,7 +107,7 @@ public function testAggregatorItemView() { // Ensure that the rendering of the linked title works as expected. foreach ($view->result as $row) { $iid = $view->field['iid']->getValue($row); - $expected_link = _l($items[$iid]->getTitle(), $items[$iid]->getLink(), array('absolute' => TRUE)); + $expected_link = l($items[$iid]->getTitle(), $items[$iid]->getLink(), array('absolute' => TRUE)); $this->assertEqual($view->field['title']->advancedRender($row), $expected_link, 'Ensure the right link is generated'); $expected_author = aggregator_filter_xss($items[$iid]->getAuthor()); diff --git a/core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php b/core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php index b45105b..62346a1 100644 --- a/core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php +++ b/core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php @@ -150,7 +150,7 @@ protected function basicAuthGet($path, $username, $password) { $out = $this->curlExec( array( CURLOPT_HTTPGET => TRUE, - CURLOPT_URL => _url($path, array('absolute' => TRUE)), + CURLOPT_URL => url($path, array('absolute' => TRUE)), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => $username . ':' . $password, diff --git a/core/modules/book/book.module b/core/modules/book/book.module index dc20b1d..54ddd96 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -62,6 +62,7 @@ function book_theme() { ), 'book_link' => array( 'render element' => 'element', + 'function' => 'theme_book_link', ), 'book_export_html' => array( 'variables' => array('title' => NULL, 'contents' => NULL, 'depth' => NULL), @@ -70,6 +71,7 @@ function book_theme() { 'book_admin_table' => array( 'render element' => 'form', 'file' => 'book.admin.inc', + 'function' => 'theme_book_admin_table', ), 'book_all_books_block' => array( 'render element' => 'book_menus', diff --git a/core/modules/book/config/install/core.base_field_override.node.book.promote.yml b/core/modules/book/config/install/core.base_field_override.node.book.promote.yml index 609d391..96ce2f6 100644 --- a/core/modules/book/config/install/core.base_field_override.node.book.promote.yml +++ b/core/modules/book/config/install/core.base_field_override.node.book.promote.yml @@ -15,6 +15,6 @@ translatable: true default_value: - value: 0 -default_value_callback: '' +default_value_function: '' settings: { } field_type: boolean diff --git a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php index b2f2c11..aa03882 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php +++ b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php @@ -32,7 +32,7 @@ class DateTimeFieldItemList extends FieldItemList { * {@inheritdoc} */ public function defaultValuesForm(array &$form, FormStateInterface $form_state) { - if (empty($this->getFieldDefinition()->default_value_callback)) { + if (empty($this->getFieldDefinition()->default_value_function)) { $default_value = $this->getFieldDefinition()->default_value; $element = array( diff --git a/core/modules/dblog/src/Controller/DbLogController.php b/core/modules/dblog/src/Controller/DbLogController.php index a11fcb8..4e7b974 100644 --- a/core/modules/dblog/src/Controller/DbLogController.php +++ b/core/modules/dblog/src/Controller/DbLogController.php @@ -252,11 +252,11 @@ public function eventDetails($event_id) { ), array( array('data' => $this->t('Location'), 'header' => TRUE), - _l($dblog->location, $dblog->location), + l($dblog->location, $dblog->location), ), array( array('data' => $this->t('Referrer'), 'header' => TRUE), - _l($dblog->referer, $dblog->referer), + l($dblog->referer, $dblog->referer), ), array( array('data' => $this->t('Message'), 'header' => TRUE), diff --git a/core/modules/field/src/Tests/FieldAttachStorageTest.php b/core/modules/field/src/Tests/FieldAttachStorageTest.php index e6c578f..205dd20 100644 --- a/core/modules/field/src/Tests/FieldAttachStorageTest.php +++ b/core/modules/field/src/Tests/FieldAttachStorageTest.php @@ -194,7 +194,7 @@ function testFieldAttachSaveEmptyDataDefaultValue() { $this->createFieldWithStorage('', $entity_type); // Add a default value function. - $this->fieldTestData->field->default_value_callback = 'field_test_default_value'; + $this->fieldTestData->field->default_value_function = 'field_test_default_value'; $this->fieldTestData->field->save(); // Verify that fields are populated with default values. diff --git a/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import.yml b/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import.yml index b205693..a9ef175 100644 --- a/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import.yml +++ b/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import.yml @@ -7,7 +7,7 @@ label: 'Test import field' description: '' required: false default_value: { } -default_value_callback: '' +default_value_function: '' settings: { } field_type: text dependencies: diff --git a/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import_2.yml b/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import_2.yml index ce26663..6c359e2 100644 --- a/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import_2.yml +++ b/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.entity_test.field_test_import_2.yml @@ -7,7 +7,7 @@ label: 'Test import field 2 on entity_test bundle' description: '' required: false default_value: { } -default_value_callback: '' +default_value_function: '' settings: { } field_type: text dependencies: diff --git a/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.test_bundle.field_test_import_2.yml b/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.test_bundle.field_test_import_2.yml index 37adede..7d63acb 100644 --- a/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.test_bundle.field_test_import_2.yml +++ b/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.test_bundle.field_test_import_2.yml @@ -7,7 +7,7 @@ label: 'Test import field 2 on test bundle' description: '' required: false default_value: { } -default_value_callback: '' +default_value_function: '' settings: { } field_type: text dependencies: diff --git a/core/modules/field/tests/modules/field_test_config/staging/field.field.entity_test.entity_test.field_test_import_staging.yml b/core/modules/field/tests/modules/field_test_config/staging/field.field.entity_test.entity_test.field_test_import_staging.yml index fe28921..9a088dd 100644 --- a/core/modules/field/tests/modules/field_test_config/staging/field.field.entity_test.entity_test.field_test_import_staging.yml +++ b/core/modules/field/tests/modules/field_test_config/staging/field.field.entity_test.entity_test.field_test_import_staging.yml @@ -8,7 +8,7 @@ label: 'Import from staging' description: '' required: '0' default_value: { } -default_value_callback: '' +default_value_function: '' settings: { } field_type: text dependencies: diff --git a/core/modules/field/tests/modules/field_test_config/staging/field.field.entity_test.test_bundle.field_test_import_staging_2.yml b/core/modules/field/tests/modules/field_test_config/staging/field.field.entity_test.test_bundle.field_test_import_staging_2.yml index d1db2b2..cc8ccd4 100644 --- a/core/modules/field/tests/modules/field_test_config/staging/field.field.entity_test.test_bundle.field_test_import_staging_2.yml +++ b/core/modules/field/tests/modules/field_test_config/staging/field.field.entity_test.test_bundle.field_test_import_staging_2.yml @@ -8,7 +8,7 @@ label: 'Test import field 2 on test bundle' description: '' required: '0' default_value: { } -default_value_callback: '' +default_value_function: '' settings: { } field_type: text dependencies: diff --git a/core/modules/field/tests/modules/field_test_config/staging/field.field.entity_test.test_bundle_2.field_test_import_staging_2.yml b/core/modules/field/tests/modules/field_test_config/staging/field.field.entity_test.test_bundle_2.field_test_import_staging_2.yml index 07953c9..f58572a 100644 --- a/core/modules/field/tests/modules/field_test_config/staging/field.field.entity_test.test_bundle_2.field_test_import_staging_2.yml +++ b/core/modules/field/tests/modules/field_test_config/staging/field.field.entity_test.test_bundle_2.field_test_import_staging_2.yml @@ -8,7 +8,7 @@ label: 'Test import field 2 on test bundle 2' description: '' required: '0' default_value: { } -default_value_callback: '' +default_value_function: '' settings: { } field_type: text dependencies: diff --git a/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php b/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php index eb516d7..15e3d65 100644 --- a/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php +++ b/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php @@ -159,7 +159,7 @@ public function testToArray() { 'description' => '', 'required' => FALSE, 'default_value' => array(), - 'default_value_callback' => '', + 'default_value_function' => '', 'settings' => array(), 'dependencies' => array(), 'field_type' => 'test_field', diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index 5bce9dd..5721172 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -66,6 +66,7 @@ function field_ui_theme() { return array( 'field_ui_table' => array( 'render element' => 'elements', + 'function' => 'theme_field_ui_table', ), ); } diff --git a/core/modules/field_ui/src/FieldUI.php b/core/modules/field_ui/src/FieldUI.php index 7edb1c6..77ec651 100644 --- a/core/modules/field_ui/src/FieldUI.php +++ b/core/modules/field_ui/src/FieldUI.php @@ -51,15 +51,15 @@ public static function getNextDestination(array $destinations) { $next_destination += array( 'route_parameters' => array(), ); - $next_destination = Url::fromRoute($next_destination['route_name'], $next_destination['route_parameters'], $next_destination['options']); + $next_destination = new Url($next_destination['route_name'], $next_destination['route_parameters'], $next_destination['options']); } else { $options = UrlHelper::parse($next_destination); if ($destinations) { $options['query']['destinations'] = $destinations; } - // Redirect to any given path within the same domain. - $next_destination = Url::fromUri('base://' . $options['path']); + $next_destination = Url::createFromPath($options['path']); + $next_destination->setOptions($options); } return $next_destination; } diff --git a/core/modules/file/file.module b/core/modules/file/file.module index 55f99ac..a516836 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -1589,7 +1589,7 @@ function template_preprocess_file_link(&$variables) { $options['attributes']['title'] = String::checkPlain($file_entity->getFilename()); } - $variables['link'] = _l($link_text, $url, $options); + $variables['link'] = l($link_text, $url, $options); $variables['attributes'] = array('class' => array('file')); } diff --git a/core/modules/file/src/Tests/DownloadTest.php b/core/modules/file/src/Tests/DownloadTest.php index ac81651..f99f327 100644 --- a/core/modules/file/src/Tests/DownloadTest.php +++ b/core/modules/file/src/Tests/DownloadTest.php @@ -112,8 +112,8 @@ function testFileCreateUrl() { '%C3%A9%C3%B8%C3%AF%D0%B2%CE%B2%E4%B8%AD%E5%9C%8B%E6%9B%B8%DB%9E'; // Public files should not be served by Drupal, so their URLs should not be - // generated by _url(), whereas private files should be served by Drupal, so - // their URLs should be generated by _url(). The difference is most apparent + // generated by url(), whereas private files should be served by Drupal, so + // their URLs should be generated by url(). The difference is most apparent // when $script_path is not empty (i.e., when not using clean URLs). $clean_url_settings = array( 'clean' => '', diff --git a/core/modules/filter/src/Tests/FilterDefaultConfigTest.php b/core/modules/filter/src/Tests/FilterDefaultConfigTest.php index 5af4758..79a1160 100644 --- a/core/modules/filter/src/Tests/FilterDefaultConfigTest.php +++ b/core/modules/filter/src/Tests/FilterDefaultConfigTest.php @@ -21,7 +21,7 @@ class FilterDefaultConfigTest extends DrupalUnitTestBase { protected function setUp() { parent::setUp(); - // Drupal\filter\FilterPermissions::permissions() calls into _url() to output + // Drupal\filter\FilterPermissions::permissions() calls into url() to output // a link in the description. $this->installSchema('system', 'url_alias'); diff --git a/core/modules/forum/config/install/core.base_field_override.node.forum.promote.yml b/core/modules/forum/config/install/core.base_field_override.node.forum.promote.yml index 3f20b64..42c7cce 100644 --- a/core/modules/forum/config/install/core.base_field_override.node.forum.promote.yml +++ b/core/modules/forum/config/install/core.base_field_override.node.forum.promote.yml @@ -15,6 +15,6 @@ translatable: true default_value: - value: 0 -default_value_callback: '' +default_value_function: '' settings: { } field_type: boolean diff --git a/core/modules/forum/config/install/core.base_field_override.node.forum.title.yml b/core/modules/forum/config/install/core.base_field_override.node.forum.title.yml index c956f34..cd1f9d3 100644 --- a/core/modules/forum/config/install/core.base_field_override.node.forum.title.yml +++ b/core/modules/forum/config/install/core.base_field_override.node.forum.title.yml @@ -13,6 +13,6 @@ description: 'The title of this node, always treated as non-markup plain text.' required: true translatable: true default_value: { } -default_value_callback: '' +default_value_function: '' settings: { } field_type: string diff --git a/core/modules/forum/config/install/field.field.taxonomy_term.forums.forum_container.yml b/core/modules/forum/config/install/field.field.taxonomy_term.forums.forum_container.yml index 8056915..b1c47ea 100644 --- a/core/modules/forum/config/install/field.field.taxonomy_term.forums.forum_container.yml +++ b/core/modules/forum/config/install/field.field.taxonomy_term.forums.forum_container.yml @@ -10,7 +10,7 @@ required: true default_value: - value: 0 -default_value_callback: '' +default_value_function: '' settings: { } field_type: boolean dependencies: diff --git a/core/modules/hal/src/Tests/DenormalizeTest.php b/core/modules/hal/src/Tests/DenormalizeTest.php index 8b5711c..761b804 100644 --- a/core/modules/hal/src/Tests/DenormalizeTest.php +++ b/core/modules/hal/src/Tests/DenormalizeTest.php @@ -24,7 +24,7 @@ public function testTypeHandling() { $data_with_valid_type = array( '_links' => array( 'type' => array( - 'href' => _url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), + 'href' => url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), ), ), ); @@ -36,10 +36,10 @@ public function testTypeHandling() { '_links' => array( 'type' => array( array( - 'href' => _url('rest/types/foo', array('absolute' => TRUE)), + 'href' => url('rest/types/foo', array('absolute' => TRUE)), ), array( - 'href' => _url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), + 'href' => url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), ), ), ), @@ -51,7 +51,7 @@ public function testTypeHandling() { $data_with_invalid_type = array( '_links' => array( 'type' => array( - 'href' => _url('rest/types/foo', array('absolute' => TRUE)), + 'href' => url('rest/types/foo', array('absolute' => TRUE)), ), ), ); @@ -84,7 +84,7 @@ public function testMarkFieldForDeletion() { $no_field_data = array( '_links' => array( 'type' => array( - 'href' => _url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), + 'href' => url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), ), ), ); @@ -94,7 +94,7 @@ public function testMarkFieldForDeletion() { $empty_field_data = array( '_links' => array( 'type' => array( - 'href' => _url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), + 'href' => url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), ), ), 'field_test_text' => array(), @@ -112,7 +112,7 @@ public function testBasicFieldDenormalization() { $data = array( '_links' => array( 'type' => array( - 'href' => _url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), + 'href' => url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), ), ), 'uuid' => array( @@ -182,7 +182,7 @@ public function testPatchDenormailzation() { $data = array( '_links' => array( 'type' => array( - 'href' => _url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), + 'href' => url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), ), ), 'field_test_text' => array( diff --git a/core/modules/hal/src/Tests/NormalizeTest.php b/core/modules/hal/src/Tests/NormalizeTest.php index ee40c25..00d6687 100644 --- a/core/modules/hal/src/Tests/NormalizeTest.php +++ b/core/modules/hal/src/Tests/NormalizeTest.php @@ -59,8 +59,8 @@ public function testNormalize() { $entity->getTranslation('en')->set('field_test_entity_reference', array(0 => $translation_values['field_test_entity_reference'])); $entity->save(); - $type_uri = _url('rest/type/entity_test/entity_test', array('absolute' => TRUE)); - $relation_uri = _url('rest/relation/entity_test/entity_test/field_test_entity_reference', array('absolute' => TRUE)); + $type_uri = url('rest/type/entity_test/entity_test', array('absolute' => TRUE)); + $relation_uri = url('rest/relation/entity_test/entity_test/field_test_entity_reference', array('absolute' => TRUE)); $expected_array = array( '_links' => array( diff --git a/core/modules/image/image.field.inc b/core/modules/image/image.field.inc index 4668e26..93ac36b 100644 --- a/core/modules/image/image.field.inc +++ b/core/modules/image/image.field.inc @@ -86,6 +86,6 @@ function template_preprocess_image_formatter(&$variables) { if (isset($variables['path']['path'])) { $path = $variables['path']['path']; $options = isset($variables['path']['options']) ? $variables['path']['options'] : array(); - $variables['url'] = _url($path, $options); + $variables['url'] = url($path, $options); } } diff --git a/core/modules/image/src/Entity/ImageStyle.php b/core/modules/image/src/Entity/ImageStyle.php index 752dc1e..0579dbc 100644 --- a/core/modules/image/src/Entity/ImageStyle.php +++ b/core/modules/image/src/Entity/ImageStyle.php @@ -216,12 +216,12 @@ public function buildUrl($path, $clean_urls = NULL) { } // If not using clean URLs, the image derivative callback is only available - // with the script path. If the file does not exist, use _url() to ensure + // with the script path. If the file does not exist, use url() to ensure // that it is included. Once the file exists it's fine to fall back to the // actual file path, this avoids bootstrapping PHP once the files are built. if ($clean_urls === FALSE && file_uri_scheme($uri) == 'public' && !file_exists($uri)) { $directory_path = file_stream_wrapper_get_instance_by_uri($uri)->getDirectoryPath(); - return _url($directory_path . '/' . file_uri_target($uri), array('absolute' => TRUE, 'query' => $token_query)); + return url($directory_path . '/' . file_uri_target($uri), array('absolute' => TRUE, 'query' => $token_query)); } $file_url = file_create_url($uri); diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 40b9bfa..7fa87b7 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -100,10 +100,12 @@ function language_theme() { 'language_negotiation_configure_browser_form_table' => array( 'render element' => 'form', 'file' => 'language.admin.inc', + 'function' => 'theme_language_negotiation_configure_browser_form_table', ), 'language_content_settings_table' => array( 'render element' => 'element', 'file' => 'language.admin.inc', + 'function' => 'theme_language_content_settings_table', ), ); } diff --git a/core/modules/language/src/LanguageNegotiatorInterface.php b/core/modules/language/src/LanguageNegotiatorInterface.php index fa46958..c5991c2 100644 --- a/core/modules/language/src/LanguageNegotiatorInterface.php +++ b/core/modules/language/src/LanguageNegotiatorInterface.php @@ -25,7 +25,7 @@ * - Content language: The language used to present content that is available * in more than one language. * - URL language: The language associated with URLs. When generating a URL, - * this value will be used by _url() as a default if no explicit preference is + * this value will be used by url() as a default if no explicit preference is * provided. * Modules can define additional language types through * hook_language_types_info(), and alter existing language type definitions diff --git a/core/modules/language/src/Tests/LanguageSwitchingTest.php b/core/modules/language/src/Tests/LanguageSwitchingTest.php index dfd8d2e..9d8f7f9 100644 --- a/core/modules/language/src/Tests/LanguageSwitchingTest.php +++ b/core/modules/language/src/Tests/LanguageSwitchingTest.php @@ -185,7 +185,7 @@ protected function doTestLanguageLinkActiveClassAuthenticated() { $function_name = '#type link'; $path = 'language_test/type-link-active-class'; - // Test links generated by _l() on an English page. + // Test links generated by l() on an English page. $current_language = 'English'; $this->drupalGet($path); @@ -210,7 +210,7 @@ protected function doTestLanguageLinkActiveClassAuthenticated() { $this->assertIdentical($settings['path']['isFront'], FALSE, 'drupalSettings.path.isFront is set correctly to allow drupal.active-link to mark the correct links as active.'); $this->assertIdentical($settings['path']['currentLanguage'], 'en', 'drupalSettings.path.currentLanguage is set correctly to allow drupal.active-link to mark the correct links as active.'); - // Test links generated by _l() on a French page. + // Test links generated by l() on a French page. $current_language = 'French'; $this->drupalGet('fr/language_test/type-link-active-class'); @@ -246,7 +246,7 @@ protected function doTestLanguageLinkActiveClassAnonymous() { $this->drupalLogout(); - // Test links generated by _l() on an English page. + // Test links generated by l() on an English page. $current_language = 'English'; $this->drupalGet('language_test/type-link-active-class'); @@ -265,7 +265,7 @@ protected function doTestLanguageLinkActiveClassAnonymous() { $links = $this->xpath('//a[@id = :id and not(contains(@class, :class))]', array(':id' => 'fr_link', ':class' => 'active')); $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is NOT marked active.', array(':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode))); - // Test links generated by _l() on a French page. + // Test links generated by l() on a French page. $current_language = 'French'; $this->drupalGet('fr/language_test/type-link-active-class'); diff --git a/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php index b1d40c0..4753539 100644 --- a/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php @@ -388,7 +388,7 @@ function testUrlLanguageFallback() { } /** - * Tests _url() when separate domains are used for multiple languages. + * Tests url() when separate domains are used for multiple languages. */ function testLanguageDomain() { // Add the Italian language. @@ -417,26 +417,26 @@ function testLanguageDomain() { // Test URL in another language: http://it.example.com/admin. // Base path gives problems on the testbot, so $correct_link is hard-coded. // @see UrlAlterFunctionalTest::assertUrlOutboundAlter (path.test). - $italian_url = _url('admin', array('language' => $languages['it'], 'script' => '')); + $italian_url = url('admin', array('language' => $languages['it'], 'script' => '')); $url_scheme = \Drupal::request()->isSecure() ? 'https://' : 'http://'; $correct_link = $url_scheme . $link; - $this->assertEqual($italian_url, $correct_link, format_string('The _url() function returns the right URL (@url) in accordance with the chosen language', array('@url' => $italian_url))); + $this->assertEqual($italian_url, $correct_link, format_string('The url() function returns the right URL (@url) in accordance with the chosen language', array('@url' => $italian_url))); // Test HTTPS via options. $this->settingsSet('mixed_mode_sessions', TRUE); $this->rebuildContainer(); - $italian_url = _url('admin', array('https' => TRUE, 'language' => $languages['it'], 'script' => '')); + $italian_url = url('admin', array('https' => TRUE, 'language' => $languages['it'], 'script' => '')); $correct_link = 'https://' . $link; - $this->assertTrue($italian_url == $correct_link, format_string('The _url() function returns the right HTTPS URL (via options) (@url) in accordance with the chosen language', array('@url' => $italian_url))); + $this->assertTrue($italian_url == $correct_link, format_string('The url() function returns the right HTTPS URL (via options) (@url) in accordance with the chosen language', array('@url' => $italian_url))); $this->settingsSet('mixed_mode_sessions', FALSE); // Test HTTPS via current URL scheme. $request = Request::create('', 'GET', array(), array(), array(), array('HTTPS' => 'on')); $this->container->get('request_stack')->push($request); $generator = $this->container->get('url_generator'); - $italian_url = _url('admin', array('language' => $languages['it'], 'script' => '')); + $italian_url = url('admin', array('language' => $languages['it'], 'script' => '')); $correct_link = 'https://' . $link; - $this->assertTrue($italian_url == $correct_link, format_string('The _url() function returns the right URL (via current URL scheme) (@url) in accordance with the chosen language', array('@url' => $italian_url))); + $this->assertTrue($italian_url == $correct_link, format_string('The url() function returns the right URL (via current URL scheme) (@url) in accordance with the chosen language', array('@url' => $italian_url))); } } diff --git a/core/modules/language/src/Tests/LanguageUrlRewritingTest.php b/core/modules/language/src/Tests/LanguageUrlRewritingTest.php index ca3d935..73b54cd 100644 --- a/core/modules/language/src/Tests/LanguageUrlRewritingTest.php +++ b/core/modules/language/src/Tests/LanguageUrlRewritingTest.php @@ -126,7 +126,7 @@ function testDomainNameNegotiationPort() { // Create an absolute French link. $language = \Drupal::languageManager()->getLanguage('fr'); - $url = _url('', array( + $url = url('', array( 'absolute' => TRUE, 'language' => $language, )); @@ -135,8 +135,8 @@ function testDomainNameNegotiationPort() { $this->assertEqual($url, $expected, 'The right port is used.'); - // If we set the port explicitly in _url(), it should not be overriden. - $url = _url('', array( + // If we set the port explicitly in url(), it should not be overriden. + $url = url('', array( 'absolute' => TRUE, 'language' => $language, 'base_url' => $request->getBaseUrl() . ':90', diff --git a/core/modules/language/tests/language_test/src/Controller/LanguageTestController.php b/core/modules/language/tests/language_test/src/Controller/LanguageTestController.php index 2935b7d..8095270 100644 --- a/core/modules/language/tests/language_test/src/Controller/LanguageTestController.php +++ b/core/modules/language/tests/language_test/src/Controller/LanguageTestController.php @@ -53,7 +53,7 @@ public static function create(ContainerInterface $container) { /** * Returns links to the current page with different langcodes. * - * Using #type 'link' causes these links to be rendered with _l(). + * Using #type 'link' causes these links to be rendered with l(). */ public function typeLinkActiveClass() { // We assume that 'en' and 'fr' have been configured. diff --git a/core/modules/link/link.module b/core/modules/link/link.module index 9207818..58d3059 100644 --- a/core/modules/link/link.module +++ b/core/modules/link/link.module @@ -69,6 +69,6 @@ function template_preprocess_link_formatter_link_separate(&$variables) { $variables['link'] = \Drupal::l($variables['url_title'], $variables['url']); } else { - $variables['link'] = _l($variables['url_title'], $variables['url']->getUri(), $variables['url']->getOptions()); + $variables['link'] = l($variables['url_title'], $variables['url']->getPath(), $variables['url']->getOptions()); } } diff --git a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php index ca753f8..05caf97 100644 --- a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php +++ b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php @@ -13,7 +13,6 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Drupal\link\LinkItemInterface; -use Symfony\Component\HttpFoundation\Request; /** * Plugin implementation of the 'link' formatter. @@ -136,7 +135,7 @@ public function viewElements(FieldItemListInterface $items) { // If the title field value is available, use it for the link text. if (empty($settings['url_only']) && !empty($item->title)) { // Unsanitized token replacement here because $options['html'] is FALSE - // by default in _l(). + // by default in l(). $link_title = \Drupal::token()->replace($item->title, array($entity->getEntityTypeId() => $entity), array('sanitize' => FALSE, 'clear' => TRUE)); } @@ -164,7 +163,7 @@ public function viewElements(FieldItemListInterface $items) { '#options' => $url->getOptions(), ); if ($url->isExternal()) { - $element[$delta]['#href'] = $url->getUri(); + $element[$delta]['#href'] = $url->getPath(); } else { $element[$delta]['#route_name'] = $url->getRouteName(); @@ -207,10 +206,11 @@ protected function buildUrl(LinkItemInterface $item) { } if ($item->isExternal()) { - $url = Url::fromUri($item->url, $options); + $url = Url::createFromPath($item->url); + $url->setOptions($options); } else { - $url = Url::fromRoute($item->route_name, (array) $item->route_parameters, (array) $options); + $url = new Url($item->route_name, (array) $item->route_parameters, (array) $options); } return $url; diff --git a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkSeparateFormatter.php b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkSeparateFormatter.php index a32e611..40daa44 100644 --- a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkSeparateFormatter.php +++ b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkSeparateFormatter.php @@ -54,7 +54,7 @@ public function viewElements(FieldItemListInterface $items) { // If the link text field value is available, use it for the text. if (empty($settings['url_only']) && !empty($item->title)) { // Unsanitized token replacement here because $options['html'] is FALSE - // by default in _l(). + // by default in l(). $link_title = \Drupal::token()->replace($item->title, array($entity->getEntityTypeId() => $entity), array('sanitize' => FALSE, 'clear' => TRUE)); } diff --git a/core/modules/link/src/Tests/LinkFieldTest.php b/core/modules/link/src/Tests/LinkFieldTest.php index 4bd30cd..a508c0c 100644 --- a/core/modules/link/src/Tests/LinkFieldTest.php +++ b/core/modules/link/src/Tests/LinkFieldTest.php @@ -275,7 +275,7 @@ function testLinkTitle() { $this->assertText(t('entity_test @id has been created.', array('@id' => $id))); $this->renderTestEntity($id); - $expected_link = _l($value, $value); + $expected_link = l($value, $value); $this->assertRaw($expected_link); // Verify that a link with text is rendered using the link text. @@ -287,7 +287,7 @@ function testLinkTitle() { $this->assertText(t('entity_test @id has been updated.', array('@id' => $id))); $this->renderTestEntity($id); - $expected_link = _l($title, $value); + $expected_link = l($title, $value); $this->assertRaw($expected_link); } @@ -354,7 +354,7 @@ function testLinkFormatter() { // Verify that the link is output according to the formatter settings. // Not using generatePermutations(), since that leads to 32 cases, which // would not test actual link field formatter functionality but rather - // _l() and options/attributes. Only 'url_plain' has a dependency on + // l() and options/attributes. Only 'url_plain' has a dependency on // 'url_only', so we have a total of ~10 cases. $options = array( 'trim_length' => array(NULL, 6), diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 40934de..7da921f 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -182,6 +182,7 @@ function locale_theme() { 'locale_translate_edit_form_strings' => array( 'render element' => 'form', 'file' => 'locale.pages.inc', + 'function' => 'theme_locale_translate_edit_form_strings', ), 'locale_translation_last_check' => array( 'variables' => array('last' => NULL), diff --git a/core/modules/locale/src/Tests/LocaleUpdateBase.php b/core/modules/locale/src/Tests/LocaleUpdateBase.php index 5e9b81e..772ac2a 100644 --- a/core/modules/locale/src/Tests/LocaleUpdateBase.php +++ b/core/modules/locale/src/Tests/LocaleUpdateBase.php @@ -53,7 +53,7 @@ protected function setUp() { // Update module should not go out to d.o to check for updates. We override // the url to the default update_test xml path. But without providing // a mock xml file, no update data will be found. - \Drupal::config('update.settings')->set('fetch.url', _url('update-test', array('absolute' => TRUE)))->save(); + \Drupal::config('update.settings')->set('fetch.url', url('update-test', array('absolute' => TRUE)))->save(); // Setup timestamps to identify old and new translation sources. $this->timestampOld = REQUEST_TIME - 300; diff --git a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php index ec719c2..55f3489 100644 --- a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php +++ b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php @@ -107,7 +107,7 @@ public function getUrlObject() { else { $path = $this->getUrl(); if (isset($path)) { - $url = Url::fromUri($path); + $url = Url::createFromPath($path); } else { $url = new Url(''); @@ -334,7 +334,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['options'] = BaseFieldDefinition::create('map') ->setLabel(t('Options')) - ->setDescription(t('A serialized array of options to be passed to the _url() or _l() function, such as a query string or HTML attributes.')) + ->setDescription(t('A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.')) ->setSetting('default_value', array()); $fields['external'] = BaseFieldDefinition::create('boolean') diff --git a/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php b/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php index 4fb93b2..2d37566 100644 --- a/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php +++ b/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php @@ -198,7 +198,7 @@ public function extractFormValues(array &$form, FormStateInterface $form_state) if ($extracted) { if ($extracted->isExternal()) { - $new_definition['url'] = $extracted->getUri(); + $new_definition['url'] = $extracted->getPath(); } else { $new_definition['route_name'] = $extracted->getRouteName(); diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module index 148203a..cc9eb79 100644 --- a/core/modules/menu_ui/menu_ui.module +++ b/core/modules/menu_ui/menu_ui.module @@ -78,6 +78,7 @@ function menu_ui_theme() { 'menu_overview_form' => array( 'file' => 'menu_ui.admin.inc', 'render element' => 'form', + 'function' => 'theme_menu_overview_form', ), ); } diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_field_instance.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_field_instance.yml index 978fb2c..1ef6a30 100644 --- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_field_instance.yml +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_field_instance.yml @@ -36,7 +36,7 @@ process: - widget_settings - global_settings - default_value_callback: '' + default_value_function: '' default_value: plugin: d6_field_instance_defaults source: diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 4e3bc46..6988f1e 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -141,6 +141,7 @@ function node_theme() { ), 'node_search_admin' => array( 'render element' => 'form', + 'function' => 'theme_node_search_admin', ), 'node_add_list' => array( 'variables' => array('content' => NULL), diff --git a/core/modules/node/src/Entity/Node.php b/core/modules/node/src/Entity/Node.php index b5bb8f8..b01ae1e 100644 --- a/core/modules/node/src/Entity/Node.php +++ b/core/modules/node/src/Entity/Node.php @@ -376,7 +376,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setRevisionable(TRUE) ->setSetting('target_type', 'user') ->setSetting('handler', 'default') - ->setDefaultValueCallback('Drupal\node\Entity\Node::getCurrentUserId') + ->setDefaultValueCallback(array('Drupal\node\Entity\Node', 'getCurrentUserId')) ->setTranslatable(TRUE) ->setDisplayOptions('view', array( 'label' => 'hidden', diff --git a/core/modules/node/src/Tests/NodeFieldOverridesTest.php b/core/modules/node/src/Tests/NodeFieldOverridesTest.php deleted file mode 100644 index b5d13b4..0000000 --- a/core/modules/node/src/Tests/NodeFieldOverridesTest.php +++ /dev/null @@ -1,69 +0,0 @@ -installEntitySchema('node'); - $this->installConfig(array('user')); - $this->user = $this->createUser(); - \Drupal::service('current_user')->setAccount($this->user); - } - - /** - * Tests that field overrides work as expected. - */ - public function testFieldOverrides() { - if (!NodeType::load('ponies')) { - NodeType::create(['name' => 'Ponies', 'type' => 'ponies'])->save(); - } - $override = BaseFieldOverride::loadByName('node', 'ponies', 'uid'); - if ($override) { - $override->delete(); - } - $uid_field = \Drupal::entityManager()->getBaseFieldDefinitions('node')['uid']; - $config = $uid_field->getConfig('ponies'); - $config->save(); - $this->assertEqual($config->get('default_value_callback'), 'Drupal\node\Entity\Node::getCurrentUserId'); - /** @var \Drupal\node\NodeInterface $node */ - $node = Node::create(['type' => 'ponies']); - $owner = $node->getOwner(); - $this->assertTrue($owner instanceof \Drupal\user\UserInterface); - $this->assertEqual($owner->id(), $this->user->id()); - } - -} diff --git a/core/modules/node/src/Tests/NodeTranslationUITest.php b/core/modules/node/src/Tests/NodeTranslationUITest.php index b5fd27a..13eced4 100644 --- a/core/modules/node/src/Tests/NodeTranslationUITest.php +++ b/core/modules/node/src/Tests/NodeTranslationUITest.php @@ -335,7 +335,7 @@ protected function doTestTranslations($path, array $values) { protected function doTestAlternateHreflangLinks($path) { $languages = $this->container->get('language_manager')->getLanguages(); foreach ($this->langcodes as $langcode) { - $urls[$langcode] = _url($path, array('absolute' => TRUE, 'language' => $languages[$langcode])); + $urls[$langcode] = url($path, array('absolute' => TRUE, 'language' => $languages[$langcode])); } foreach ($this->langcodes as $langcode) { $this->drupalGet($path, array('language' => $languages[$langcode])); diff --git a/core/modules/node/src/Tests/NodeViewTest.php b/core/modules/node/src/Tests/NodeViewTest.php index 426fec1..03c0035 100644 --- a/core/modules/node/src/Tests/NodeViewTest.php +++ b/core/modules/node/src/Tests/NodeViewTest.php @@ -24,13 +24,13 @@ public function testHtmlHeadLinks() { $this->drupalGet($node->getSystemPath()); $result = $this->xpath('//link[@rel = "version-history"]'); - $this->assertEqual($result[0]['href'], _url("node/{$node->id()}/revisions")); + $this->assertEqual($result[0]['href'], url("node/{$node->id()}/revisions")); $result = $this->xpath('//link[@rel = "edit-form"]'); - $this->assertEqual($result[0]['href'], _url("node/{$node->id()}/edit")); + $this->assertEqual($result[0]['href'], url("node/{$node->id()}/edit")); $result = $this->xpath('//link[@rel = "canonical"]'); - $this->assertEqual($result[0]['href'], _url("node/{$node->id()}")); + $this->assertEqual($result[0]['href'], url("node/{$node->id()}")); } } diff --git a/core/modules/path/src/Controller/PathController.php b/core/modules/path/src/Controller/PathController.php index 96dd34b..6144b67 100644 --- a/core/modules/path/src/Controller/PathController.php +++ b/core/modules/path/src/Controller/PathController.php @@ -73,10 +73,10 @@ public function adminOverview($keys) { $destination = drupal_get_destination(); foreach ($this->aliasStorage->getAliasesForAdminListing($header, $keys) as $data) { $row = array(); - $row['data']['alias'] = _l(truncate_utf8($data->alias, 50, FALSE, TRUE), $data->source, array( + $row['data']['alias'] = l(truncate_utf8($data->alias, 50, FALSE, TRUE), $data->source, array( 'attributes' => array('title' => $data->alias), )); - $row['data']['source'] = _l(truncate_utf8($data->source, 50, FALSE, TRUE), $data->source, array( + $row['data']['source'] = l(truncate_utf8($data->source, 50, FALSE, TRUE), $data->source, array( 'alias' => TRUE, 'attributes' => array('title' => $data->source), )); diff --git a/core/modules/path/src/Form/PathFormBase.php b/core/modules/path/src/Form/PathFormBase.php index ecb970c..8564156 100644 --- a/core/modules/path/src/Form/PathFormBase.php +++ b/core/modules/path/src/Form/PathFormBase.php @@ -95,7 +95,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $pid = NU '#maxlength' => 255, '#size' => 45, '#description' => $this->t('Specify the existing path you wish to alias. For example: node/28, forum/1, taxonomy/term/1.'), - '#field_prefix' => _url(NULL, array('absolute' => TRUE)), + '#field_prefix' => url(NULL, array('absolute' => TRUE)), '#required' => TRUE, ); $form['alias'] = array( @@ -105,7 +105,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $pid = NU '#maxlength' => 255, '#size' => 45, '#description' => $this->t('Specify an alternative path by which this data can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'), - '#field_prefix' => _url(NULL, array('absolute' => TRUE)), + '#field_prefix' => url(NULL, array('absolute' => TRUE)), '#required' => TRUE, ); diff --git a/core/modules/path/src/Tests/PathLanguageTest.php b/core/modules/path/src/Tests/PathLanguageTest.php index 6f1beed..d6399a0 100644 --- a/core/modules/path/src/Tests/PathLanguageTest.php +++ b/core/modules/path/src/Tests/PathLanguageTest.php @@ -109,7 +109,7 @@ function testAliasTranslation() { $this->drupalGet('fr/' . $edit['path[0][alias]']); $this->assertText($french_node->body->value, 'Alias for French translation works.'); - // Confirm that the alias is returned by _url(). Languages are cached on + // Confirm that the alias is returned by url(). Languages are cached on // many levels, and we need to clear those caches. $this->container->get('language_manager')->reset(); $languages = $this->container->get('language_manager')->getLanguages(); diff --git a/core/modules/rdf/src/Tests/Field/LinkFieldRdfaTest.php b/core/modules/rdf/src/Tests/Field/LinkFieldRdfaTest.php index 8478bae..8c23c07 100644 --- a/core/modules/rdf/src/Tests/Field/LinkFieldRdfaTest.php +++ b/core/modules/rdf/src/Tests/Field/LinkFieldRdfaTest.php @@ -75,8 +75,7 @@ public function testAllFormattersInternal() { // Set up test values. $this->testValue = 'admin'; $this->entity = entity_create('entity_test', array()); - $this->entity->{$this->fieldName}->route_name = 'system.admin'; - $this->entity->{$this->fieldName}->url = 'admin'; + $this->entity->{$this->fieldName}->url = $this->testValue; // Set up the expected result. // AssertFormatterRdfa looks for a full path. @@ -95,8 +94,7 @@ public function testAllFormattersFront() { // Set up test values. $this->testValue = ''; $this->entity = entity_create('entity_test', array()); - $this->entity->{$this->fieldName}->route_name = $this->testValue; - $this->entity->{$this->fieldName}->url = ''; + $this->entity->{$this->fieldName}->url = $this->testValue; // Set up the expected result. $expected_rdf = array( diff --git a/core/modules/responsive_image/responsive_image.module b/core/modules/responsive_image/responsive_image.module index 8a8df92..13f3b45 100644 --- a/core/modules/responsive_image/responsive_image.module +++ b/core/modules/responsive_image/responsive_image.module @@ -80,6 +80,7 @@ function responsive_image_theme() { 'attributes' => array(), 'mapping_id' => array(), ), + 'function' => 'theme_responsive_image', ), 'responsive_image_formatter' => array( 'variables' => array( @@ -88,6 +89,7 @@ function responsive_image_theme() { 'image_style' => NULL, 'mapping_id' => array(), ), + 'function' => 'theme_responsive_image_formatter', ), 'responsive_image_source' => array( 'variables' => array( @@ -96,6 +98,7 @@ function responsive_image_theme() { 'dimensions' => NULL, 'media' => NULL, ), + 'function' => 'theme_responsive_image_source', ), ); } @@ -147,7 +150,7 @@ function theme_responsive_image_formatter($variables) { $path = $variables['path']['path']; $options = isset($variables['path']['options']) ? $variables['path']['options'] : array(); $options['html'] = TRUE; - return _l($responsive_image, $path, $options); + return l($responsive_image, $path, $options); } return drupal_render($responsive_image); diff --git a/core/modules/rest/src/LinkManager/RelationLinkManager.php b/core/modules/rest/src/LinkManager/RelationLinkManager.php index f5ed9fb..04ed8ee 100644 --- a/core/modules/rest/src/LinkManager/RelationLinkManager.php +++ b/core/modules/rest/src/LinkManager/RelationLinkManager.php @@ -44,7 +44,7 @@ public function __construct(CacheBackendInterface $cache, EntityManagerInterface */ public function getRelationUri($entity_type, $bundle, $field_name) { // @todo Make the base path configurable. - return _url("rest/relation/$entity_type/$bundle/$field_name", array('absolute' => TRUE)); + return url("rest/relation/$entity_type/$bundle/$field_name", array('absolute' => TRUE)); } /** diff --git a/core/modules/rest/src/LinkManager/TypeLinkManager.php b/core/modules/rest/src/LinkManager/TypeLinkManager.php index 6c37782..fb21a5f 100644 --- a/core/modules/rest/src/LinkManager/TypeLinkManager.php +++ b/core/modules/rest/src/LinkManager/TypeLinkManager.php @@ -42,7 +42,7 @@ public function __construct(CacheBackendInterface $cache) { */ public function getTypeUri($entity_type, $bundle) { // @todo Make the base path configurable. - return _url("rest/type/$entity_type/$bundle", array('absolute' => TRUE)); + return url("rest/type/$entity_type/$bundle", array('absolute' => TRUE)); } /** diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php index b565cea..c39b88f 100644 --- a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php +++ b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php @@ -96,7 +96,7 @@ public function post(EntityInterface $entity = NULL) { $entity->save(); $this->logger->notice('Created entity %type with ID %id.', array('%type' => $entity->getEntityTypeId(), '%id' => $entity->id())); - $url = _url(strtr($this->pluginId, ':', '/') . '/' . $entity->id(), array('absolute' => TRUE)); + $url = url(strtr($this->pluginId, ':', '/') . '/' . $entity->id(), array('absolute' => TRUE)); // 201 Created responses have an empty body. return new ResourceResponse(NULL, 201, array('Location' => $url)); } diff --git a/core/modules/rest/src/Tests/AuthTest.php b/core/modules/rest/src/Tests/AuthTest.php index 230b24c..257e7f1 100644 --- a/core/modules/rest/src/Tests/AuthTest.php +++ b/core/modules/rest/src/Tests/AuthTest.php @@ -87,7 +87,7 @@ protected function basicAuthGet($path, $username, $password) { $out = $this->curlExec( array( CURLOPT_HTTPGET => TRUE, - CURLOPT_URL => _url($path, array('absolute' => TRUE)), + CURLOPT_URL => url($path, array('absolute' => TRUE)), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => $username . ':' . $password, diff --git a/core/modules/rest/src/Tests/CsrfTest.php b/core/modules/rest/src/Tests/CsrfTest.php index 84bf71f..9099245 100644 --- a/core/modules/rest/src/Tests/CsrfTest.php +++ b/core/modules/rest/src/Tests/CsrfTest.php @@ -107,7 +107,7 @@ protected function getCurlOptions() { CURLOPT_HTTPGET => FALSE, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $this->serialized, - CURLOPT_URL => _url('entity/' . $this->testEntityType, array('absolute' => TRUE)), + CURLOPT_URL => url('entity/' . $this->testEntityType, array('absolute' => TRUE)), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPHEADER => array( "Content-Type: {$this->defaultMimeType}", diff --git a/core/modules/rest/src/Tests/NodeTest.php b/core/modules/rest/src/Tests/NodeTest.php index 96619b7..4cd2bc9 100644 --- a/core/modules/rest/src/Tests/NodeTest.php +++ b/core/modules/rest/src/Tests/NodeTest.php @@ -68,7 +68,7 @@ public function testNodes() { $data = array( '_links' => array( 'type' => array( - 'href' => _url('rest/type/node/resttest', array('absolute' => TRUE)), + 'href' => url('rest/type/node/resttest', array('absolute' => TRUE)), ), ), 'title' => array( diff --git a/core/modules/rest/src/Tests/RESTTestBase.php b/core/modules/rest/src/Tests/RESTTestBase.php index 32fa9c3..a2e0ffe 100644 --- a/core/modules/rest/src/Tests/RESTTestBase.php +++ b/core/modules/rest/src/Tests/RESTTestBase.php @@ -86,7 +86,7 @@ protected function httpRequest($url, $method, $body = NULL, $mime_type = NULL) { $curl_options = array( CURLOPT_HTTPGET => TRUE, CURLOPT_CUSTOMREQUEST => 'GET', - CURLOPT_URL => _url($url, $options), + CURLOPT_URL => url($url, $options), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPHEADER => array('Accept: ' . $mime_type), ); @@ -97,7 +97,7 @@ protected function httpRequest($url, $method, $body = NULL, $mime_type = NULL) { CURLOPT_HTTPGET => FALSE, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $body, - CURLOPT_URL => _url($url, array('absolute' => TRUE)), + CURLOPT_URL => url($url, array('absolute' => TRUE)), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPHEADER => array( 'Content-Type: ' . $mime_type, @@ -111,7 +111,7 @@ protected function httpRequest($url, $method, $body = NULL, $mime_type = NULL) { CURLOPT_HTTPGET => FALSE, CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_POSTFIELDS => $body, - CURLOPT_URL => _url($url, array('absolute' => TRUE)), + CURLOPT_URL => url($url, array('absolute' => TRUE)), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPHEADER => array( 'Content-Type: ' . $mime_type, @@ -125,7 +125,7 @@ protected function httpRequest($url, $method, $body = NULL, $mime_type = NULL) { CURLOPT_HTTPGET => FALSE, CURLOPT_CUSTOMREQUEST => 'PATCH', CURLOPT_POSTFIELDS => $body, - CURLOPT_URL => _url($url, array('absolute' => TRUE)), + CURLOPT_URL => url($url, array('absolute' => TRUE)), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPHEADER => array( 'Content-Type: ' . $mime_type, @@ -138,7 +138,7 @@ protected function httpRequest($url, $method, $body = NULL, $mime_type = NULL) { $curl_options = array( CURLOPT_HTTPGET => FALSE, CURLOPT_CUSTOMREQUEST => 'DELETE', - CURLOPT_URL => _url($url, array('absolute' => TRUE)), + CURLOPT_URL => url($url, array('absolute' => TRUE)), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPHEADER => array('X-CSRF-Token: ' . $token), ); diff --git a/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php b/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php index e7c98c6..7a145b6 100644 --- a/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php +++ b/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php @@ -269,8 +269,8 @@ public function testMultipleSearchPages() { // Ensure both search pages have their tabs displayed. $this->drupalGet('search'); $elements = $this->xpath('//*[contains(@class, :class)]//a', array(':class' => 'tabs primary')); - $this->assertIdentical((string) $elements[0]['href'], _url('search/' . $first['path'])); - $this->assertIdentical((string) $elements[1]['href'], _url('search/' . $second['path'])); + $this->assertIdentical((string) $elements[0]['href'], url('search/' . $first['path'])); + $this->assertIdentical((string) $elements[1]['href'], url('search/' . $second['path'])); // Switch the weight of the search pages and check the order of the tabs. $edit = array( @@ -280,8 +280,8 @@ public function testMultipleSearchPages() { $this->drupalPostForm('admin/config/search/pages', $edit, t('Save configuration')); $this->drupalGet('search'); $elements = $this->xpath('//*[contains(@class, :class)]//a', array(':class' => 'tabs primary')); - $this->assertIdentical((string) $elements[0]['href'], _url('search/' . $second['path'])); - $this->assertIdentical((string) $elements[1]['href'], _url('search/' . $first['path'])); + $this->assertIdentical((string) $elements[0]['href'], url('search/' . $second['path'])); + $this->assertIdentical((string) $elements[1]['href'], url('search/' . $first['path'])); // Check the initial state of the search pages. $this->drupalGet('admin/config/search/pages'); diff --git a/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php b/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php index d1855ad..b8f7c73 100644 --- a/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php +++ b/core/modules/search/tests/modules/search_extra_type/src/Plugin/Search/SearchExtraTypeSearch.php @@ -57,7 +57,7 @@ public function execute() { } return array( array( - 'link' => _url('node'), + 'link' => url('node'), 'type' => 'Dummy result type', 'title' => 'Dummy title', 'snippet' => SafeMarkup::set("Dummy search snippet to display. Keywords: {$this->keywords}\n\nConditions: " . print_r($this->searchParameters, TRUE)), diff --git a/core/modules/serialization/src/Tests/EntityResolverTest.php b/core/modules/serialization/src/Tests/EntityResolverTest.php index 2bf4ed9..3cf8952 100644 --- a/core/modules/serialization/src/Tests/EntityResolverTest.php +++ b/core/modules/serialization/src/Tests/EntityResolverTest.php @@ -58,16 +58,16 @@ function testUuidEntityResolver() { $entity->set('field_test_entity_reference', array(array('target_id' => 1))); $entity->save(); - $field_uri = _url('rest/relation/entity_test_mulrev/entity_test_mulrev/field_test_entity_reference', array('absolute' => TRUE)); + $field_uri = url('rest/relation/entity_test_mulrev/entity_test_mulrev/field_test_entity_reference', array('absolute' => TRUE)); $data = array( '_links' => array( 'type' => array( - 'href' => _url('rest/type/entity_test_mulrev/entity_test_mulrev', array('absolute' => TRUE)), + 'href' => url('rest/type/entity_test_mulrev/entity_test_mulrev', array('absolute' => TRUE)), ), $field_uri => array( array( - 'href' => _url('entity/entity_test_mulrev/' . $entity->id()), + 'href' => url('entity/entity_test_mulrev/' . $entity->id()), ), ), ), @@ -75,7 +75,7 @@ function testUuidEntityResolver() { $field_uri => array( array( '_links' => array( - 'self' => _url('entity/entity_test_mulrev/' . $entity->id()), + 'self' => url('entity/entity_test_mulrev/' . $entity->id()), ), 'uuid' => array( array( diff --git a/core/modules/shortcut/src/Entity/Shortcut.php b/core/modules/shortcut/src/Entity/Shortcut.php index 4bd041e..df96d6f 100644 --- a/core/modules/shortcut/src/Entity/Shortcut.php +++ b/core/modules/shortcut/src/Entity/Shortcut.php @@ -14,7 +14,6 @@ use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Url; use Drupal\shortcut\ShortcutInterface; -use Symfony\Component\HttpFoundation\Request; /** * Defines the shortcut entity class. @@ -135,15 +134,7 @@ public static function preCreate(EntityStorageInterface $storage, array &$values public function preSave(EntityStorageInterface $storage) { parent::preSave($storage); - // @todo fix PathValidatorInterface::getUrlIfValid() so we can use it - // here. The problem is that we need an exception, not a FALSE - // return value. https://www.drupal.org/node/2346695 - if ($this->path->value == '') { - $url = new Url($this->path->value); - } - else { - $url = Url::createFromRequest(Request::create("/{$this->path->value}")); - } + $url = Url::createFromPath($this->path->value); $this->setRouteName($url->getRouteName()); $this->setRouteParams($url->getRouteParameters()); } diff --git a/core/modules/simpletest/src/TestBase.php b/core/modules/simpletest/src/TestBase.php index b8bed09..171df78 100644 --- a/core/modules/simpletest/src/TestBase.php +++ b/core/modules/simpletest/src/TestBase.php @@ -745,7 +745,7 @@ protected function verbose($message) { $verbose_filename = $this->verboseDirectory . '/' . $this->verboseClassName . '-' . $this->verboseId . '.html'; if (file_put_contents($verbose_filename, $message, FILE_APPEND)) { $url = $this->verboseDirectoryUrl . '/' . $this->verboseClassName . '-' . $this->verboseId . '.html'; - // Not using _l() to avoid invoking the theme system, so that unit tests + // Not using l() to avoid invoking the theme system, so that unit tests // can use verbose() as well. $url = 'Verbose message'; $this->error($url, 'User notice'); diff --git a/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php b/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php index 869dbca..69712c3 100644 --- a/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php +++ b/core/modules/simpletest/src/Tests/SimpleTestBrowserTest.php @@ -77,7 +77,7 @@ public function testInternalBrowser() { // Not using File API; a potential error must trigger a PHP warning. unlink($this->siteDirectory . '/.htkey'); global $base_url; - $this->drupalGet(_url($base_url . '/core/install.php', array('external' => TRUE, 'absolute' => TRUE))); + $this->drupalGet(url($base_url . '/core/install.php', array('external' => TRUE, 'absolute' => TRUE))); $this->assertResponse(403, 'Cannot access install.php.'); } diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index 3c826bf..ab560b2 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -1476,7 +1476,7 @@ protected function drupalGet($path, array $options = array(), array $headers = a * @param string $path * Path to request AJAX from. * @param array $options - * Array of options to pass to _url(). + * Array of options to pass to url(). * @param array $headers * Array of headers. Eg array('Accept: application/vnd.drupal-ajax'). * @@ -1925,11 +1925,11 @@ protected function drupalProcessAjaxResponse($content, array $ajax_response, arr * * @see WebTestBase::getAjaxPageStatePostData() * @see WebTestBase::curlExec() - * @see _url() + * @see url() */ protected function drupalPost($path, $accept, array $post, $options = array()) { return $this->curlExec(array( - CURLOPT_URL => _url($path, $options + array('absolute' => TRUE)), + CURLOPT_URL => url($path, $options + array('absolute' => TRUE)), CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $this->serializePostValues($post), CURLOPT_HTTPHEADER => array( diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module index 00ca78d..3c80cd8 100644 --- a/core/modules/statistics/statistics.module +++ b/core/modules/statistics/statistics.module @@ -39,7 +39,7 @@ function statistics_help($route_name, RouteMatchInterface $route_match) { function statistics_node_view(array &$build, EntityInterface $node, EntityViewDisplayInterface $display, $view_mode) { if (!$node->isNew() && $view_mode == 'full' && node_is_page($node) && empty($node->in_preview)) { $build['statistics_content_counter']['#attached']['library'][] = 'statistics/drupal.statistics'; - $settings = array('data' => array('nid' => $node->id()), 'url' => _url(drupal_get_path('module', 'statistics') . '/statistics.php')); + $settings = array('data' => array('nid' => $node->id()), 'url' => url(drupal_get_path('module', 'statistics') . '/statistics.php')); $build['statistics_content_counter']['#attached']['js'][] = array( 'data' => array('statistics' => $settings), 'type' => 'setting', diff --git a/core/modules/system/language.api.php b/core/modules/system/language.api.php index f52e22d..3a74f82 100644 --- a/core/modules/system/language.api.php +++ b/core/modules/system/language.api.php @@ -95,7 +95,7 @@ * Perform alterations on language switcher links. * * A language switcher link may need to point to a different path or use a - * translated link text before going through _l(), which will just handle the + * translated link text before going through l(), which will just handle the * path aliases. * * @param $links diff --git a/core/modules/system/src/Form/SiteInformationForm.php b/core/modules/system/src/Form/SiteInformationForm.php index 7ae14cf..d8328df 100644 --- a/core/modules/system/src/Form/SiteInformationForm.php +++ b/core/modules/system/src/Form/SiteInformationForm.php @@ -114,7 +114,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#default_value' => $front_page, '#size' => 40, '#description' => t('Optionally, specify a relative URL to display as the front page. Leave blank to display the default front page.'), - '#field_prefix' => _url(NULL, array('absolute' => TRUE)), + '#field_prefix' => url(NULL, array('absolute' => TRUE)), ); $form['error_page'] = array( '#type' => 'details', @@ -127,7 +127,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#default_value' => $site_config->get('page.403'), '#size' => 40, '#description' => t('This page is displayed when the requested document is denied to the current user. Leave blank to display a generic "access denied" page.'), - '#field_prefix' => _url(NULL, array('absolute' => TRUE)), + '#field_prefix' => url(NULL, array('absolute' => TRUE)), ); $form['error_page']['site_404'] = array( '#type' => 'textfield', @@ -135,7 +135,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#default_value' => $site_config->get('page.404'), '#size' => 40, '#description' => t('This page is displayed when no other content matches the requested document. Leave blank to display a generic "page not found" page.'), - '#field_prefix' => _url(NULL, array('absolute' => TRUE)), + '#field_prefix' => url(NULL, array('absolute' => TRUE)), ); return parent::buildForm($form, $form_state); diff --git a/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php b/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php index 7efb671..4b4e222 100644 --- a/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php +++ b/core/modules/system/src/Tests/Cache/PageCacheTagsIntegrationTest.php @@ -149,7 +149,7 @@ protected function verifyPageCacheTags($path, $expected_tags) { sort($actual_tags); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT'); $this->assertIdentical($actual_tags, $expected_tags); - $cid_parts = array(_url($path, array('absolute' => TRUE)), 'html'); + $cid_parts = array(url($path, array('absolute' => TRUE)), 'html'); $cid = sha1(implode(':', $cid_parts)); $cache_entry = \Drupal::cache('render')->get($cid); sort($cache_entry->tags); diff --git a/core/modules/system/src/Tests/Cache/PageCacheTagsTestBase.php b/core/modules/system/src/Tests/Cache/PageCacheTagsTestBase.php index e54f97b..f3a0d76 100644 --- a/core/modules/system/src/Tests/Cache/PageCacheTagsTestBase.php +++ b/core/modules/system/src/Tests/Cache/PageCacheTagsTestBase.php @@ -46,7 +46,7 @@ protected function verifyPageCache($path, $hit_or_miss, $tags = FALSE) { $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), $hit_or_miss, $message); if ($hit_or_miss === 'HIT' && is_array($tags)) { - $cid_parts = array(_url($path, array('absolute' => TRUE)), 'html'); + $cid_parts = array(url($path, array('absolute' => TRUE)), 'html'); $cid = sha1(implode(':', $cid_parts)); $cache_entry = \Drupal::cache('render')->get($cid); sort($cache_entry->tags); diff --git a/core/modules/system/src/Tests/Common/AddFeedTest.php b/core/modules/system/src/Tests/Common/AddFeedTest.php index a24581d..8de6090 100644 --- a/core/modules/system/src/Tests/Common/AddFeedTest.php +++ b/core/modules/system/src/Tests/Common/AddFeedTest.php @@ -23,11 +23,11 @@ class AddFeedTest extends WebTestBase { function testBasicFeedAddNoTitle() { $path = $this->randomMachineName(12); $external_url = 'http://' . $this->randomMachineName(12) . '/' . $this->randomMachineName(12); - $fully_qualified_local_url = _url($this->randomMachineName(12), array('absolute' => TRUE)); + $fully_qualified_local_url = url($this->randomMachineName(12), array('absolute' => TRUE)); $path_for_title = $this->randomMachineName(12); $external_for_title = 'http://' . $this->randomMachineName(12) . '/' . $this->randomMachineName(12); - $fully_qualified_for_title = _url($this->randomMachineName(12), array('absolute' => TRUE)); + $fully_qualified_for_title = url($this->randomMachineName(12), array('absolute' => TRUE)); // Possible permutations of drupal_add_feed() to test. // - 'input_url': the path passed to drupal_add_feed(), @@ -35,7 +35,7 @@ function testBasicFeedAddNoTitle() { // - 'title' == the title of the feed as passed into drupal_add_feed(). $urls = array( 'path without title' => array( - 'url' => _url($path, array('absolute' => TRUE)), + 'url' => url($path, array('absolute' => TRUE)), 'title' => '', ), 'external URL without title' => array( @@ -47,7 +47,7 @@ function testBasicFeedAddNoTitle() { 'title' => '', ), 'path with title' => array( - 'url' => _url($path_for_title, array('absolute' => TRUE)), + 'url' => url($path_for_title, array('absolute' => TRUE)), 'title' => $this->randomMachineName(12), ), 'external URL with title' => array( diff --git a/core/modules/system/src/Tests/Common/RenderElementTypesTest.php b/core/modules/system/src/Tests/Common/RenderElementTypesTest.php index 9757a2b..6d83838 100644 --- a/core/modules/system/src/Tests/Common/RenderElementTypesTest.php +++ b/core/modules/system/src/Tests/Common/RenderElementTypesTest.php @@ -147,7 +147,7 @@ function testMoreLink() { '#type' => 'more_link', '#href' => 'a/link', ), - 'expected' => '//div[@class="more-link"]/a[@href="' . _url('a/link') . '" and text()="More"]', + 'expected' => '//div[@class="more-link"]/a[@href="' . url('a/link') . '" and text()="More"]', ), array( 'name' => "#type 'more_link' anchor tag with a route", @@ -165,7 +165,7 @@ function testMoreLink() { '#href' => 'admin/content', '#options' => array('absolute' => TRUE), ), - 'expected' => '//div[@class="more-link"]/a[@href="' . _url('admin/content', array('absolute' => TRUE)) . '" and text()="More"]', + 'expected' => '//div[@class="more-link"]/a[@href="' . url('admin/content', array('absolute' => TRUE)) . '" and text()="More"]', ), array( 'name' => "#type 'more_link' anchor tag to the front page", @@ -173,7 +173,7 @@ function testMoreLink() { '#type' => 'more_link', '#href' => '', ), - 'expected' => '//div[@class="more-link"]/a[@href="' . _url('') . '" and text()="More"]', + 'expected' => '//div[@class="more-link"]/a[@href="' . url('') . '" and text()="More"]', ), ); diff --git a/core/modules/system/src/Tests/Common/RenderWebTest.php b/core/modules/system/src/Tests/Common/RenderWebTest.php index 3e58fb0..3c8725a 100644 --- a/core/modules/system/src/Tests/Common/RenderWebTest.php +++ b/core/modules/system/src/Tests/Common/RenderWebTest.php @@ -111,7 +111,7 @@ function testDrupalRenderFormElements() { ), ); $this->assertRenderedElement($element, '//a[@href=:href and contains(., :title)]', array( - ':href' => _url($element['#href'], array('absolute' => TRUE)), + ':href' => url($element['#href'], array('absolute' => TRUE)), ':title' => $element['#title'], )); diff --git a/core/modules/system/src/Tests/Common/UrlTest.php b/core/modules/system/src/Tests/Common/UrlTest.php index 0097512..4edae14 100644 --- a/core/modules/system/src/Tests/Common/UrlTest.php +++ b/core/modules/system/src/Tests/Common/UrlTest.php @@ -12,12 +12,12 @@ use Drupal\simpletest\WebTestBase; /** - * Confirm that _url(), + * Confirm that url(), * \Drupal\Component\Utility\UrlHelper::filterQueryParameters(), - * \Drupal\Component\Utility\UrlHelper::buildQuery(), and _l() work correctly + * \Drupal\Component\Utility\UrlHelper::buildQuery(), and l() work correctly * with various input. * - * _url() calls \Drupal::moduleHandler()->getImplementations(), + * url() calls \Drupal::moduleHandler()->getImplementations(), * which may issue a db query, which requires * inheriting from a web test case rather than a unit test case. * @@ -31,12 +31,12 @@ class UrlTest extends WebTestBase { * Confirms that invalid URLs are filtered in link generating functions. */ function testLinkXSS() { - // Test _l(). + // Test l(). $text = $this->randomMachineName(); $path = ""; - $link = _l($text, $path); - $sanitized_path = check_url(_url($path)); - $this->assertTrue(strpos($link, $sanitized_path) !== FALSE, format_string('XSS attack @path was filtered by _l().', array('@path' => $path))); + $link = l($text, $path); + $sanitized_path = check_url(url($path)); + $this->assertTrue(strpos($link, $sanitized_path) !== FALSE, format_string('XSS attack @path was filtered by l().', array('@path' => $path))); // Test #type 'link'. $link_array = array( @@ -45,7 +45,7 @@ function testLinkXSS() { '#href' => $path, ); $type_link = drupal_render($link_array); - $sanitized_path = check_url(_url($path)); + $sanitized_path = check_url(url($path)); $this->assertTrue(strpos($type_link, $sanitized_path) !== FALSE, format_string('XSS attack @path was filtered by #theme', array('@path' => $path))); } @@ -76,7 +76,7 @@ function testLinkAttributes() { $rendered = drupal_render($hreflang_override_link); $this->assertTrue($this->hasAttribute('hreflang', $rendered, 'foo'), format_string('hreflang attribute with value @hreflang is present on a rendered link when @hreflang is provided in the render array.', array('@hreflang' => 'foo'))); - // Test the active class in links produced by _l() and #type 'link'. + // Test the active class in links produced by l() and #type 'link'. $options_no_query = array(); $options_query = array( 'query' => array( @@ -95,27 +95,27 @@ function testLinkAttributes() { $path = 'common-test/type-link-active-class'; $this->drupalGet($path, $options_no_query); - $links = $this->xpath('//a[@href = :href and contains(@class, :class)]', array(':href' => _url($path, $options_no_query), ':class' => 'active')); - $this->assertTrue(isset($links[0]), 'A link generated by _l() to the current page is marked active.'); + $links = $this->xpath('//a[@href = :href and contains(@class, :class)]', array(':href' => url($path, $options_no_query), ':class' => 'active')); + $this->assertTrue(isset($links[0]), 'A link generated by l() to the current page is marked active.'); - $links = $this->xpath('//a[@href = :href and not(contains(@class, :class))]', array(':href' => _url($path, $options_query), ':class' => 'active')); - $this->assertTrue(isset($links[0]), 'A link generated by _l() to the current page with a query string when the current page has no query string is not marked active.'); + $links = $this->xpath('//a[@href = :href and not(contains(@class, :class))]', array(':href' => url($path, $options_query), ':class' => 'active')); + $this->assertTrue(isset($links[0]), 'A link generated by l() to the current page with a query string when the current page has no query string is not marked active.'); $this->drupalGet($path, $options_query); - $links = $this->xpath('//a[@href = :href and contains(@class, :class)]', array(':href' => _url($path, $options_query), ':class' => 'active')); - $this->assertTrue(isset($links[0]), 'A link generated by _l() to the current page with a query string that matches the current query string is marked active.'); + $links = $this->xpath('//a[@href = :href and contains(@class, :class)]', array(':href' => url($path, $options_query), ':class' => 'active')); + $this->assertTrue(isset($links[0]), 'A link generated by l() to the current page with a query string that matches the current query string is marked active.'); - $links = $this->xpath('//a[@href = :href and contains(@class, :class)]', array(':href' => _url($path, $options_query_reverse), ':class' => 'active')); - $this->assertTrue(isset($links[0]), 'A link generated by _l() to the current page with a query string that has matching parameters to the current query string but in a different order is marked active.'); + $links = $this->xpath('//a[@href = :href and contains(@class, :class)]', array(':href' => url($path, $options_query_reverse), ':class' => 'active')); + $this->assertTrue(isset($links[0]), 'A link generated by l() to the current page with a query string that has matching parameters to the current query string but in a different order is marked active.'); - $links = $this->xpath('//a[@href = :href and not(contains(@class, :class))]', array(':href' => _url($path, $options_no_query), ':class' => 'active')); - $this->assertTrue(isset($links[0]), 'A link generated by _l() to the current page without a query string when the current page has a query string is not marked active.'); + $links = $this->xpath('//a[@href = :href and not(contains(@class, :class))]', array(':href' => url($path, $options_no_query), ':class' => 'active')); + $this->assertTrue(isset($links[0]), 'A link generated by l() to the current page without a query string when the current page has a query string is not marked active.'); - // Test adding a custom class in links produced by _l() and #type 'link'. - // Test _l(). + // Test adding a custom class in links produced by l() and #type 'link'. + // Test l(). $class_l = $this->randomMachineName(); - $link_l = _l($this->randomMachineName(), current_path(), array('attributes' => array('class' => array($class_l)))); - $this->assertTrue($this->hasAttribute('class', $link_l, $class_l), format_string('Custom class @class is present on link when requested by _l()', array('@class' => $class_l))); + $link_l = l($this->randomMachineName(), current_path(), array('attributes' => array('class' => array($class_l)))); + $this->assertTrue($this->hasAttribute('class', $link_l, $class_l), format_string('Custom class @class is present on link when requested by l()', array('@class' => $class_l))); // Test #type. $class_theme = $this->randomMachineName(); @@ -137,12 +137,12 @@ function testLinkAttributes() { * Tests that link functions support render arrays as 'text'. */ function testLinkRenderArrayText() { - // Build a link with _l() for reference. - $l = _l('foo', 'http://drupal.org'); + // Build a link with l() for reference. + $l = l('foo', 'http://drupal.org'); - // Test a renderable array passed to _l(). + // Test a renderable array passed to l(). $renderable_text = array('#markup' => 'foo'); - $l_renderable_text = _l($renderable_text, 'http://drupal.org'); + $l_renderable_text = l($renderable_text, 'http://drupal.org'); $this->assertEqual($l_renderable_text, $l); // Test a themed link with plain text 'text'. @@ -261,30 +261,30 @@ function testExternalUrls() { // Verify external URL can contain a fragment. $url = $test_url . '#drupal'; - $result = _url($url); + $result = url($url); $this->assertEqual($url, $result, 'External URL with fragment works without a fragment in $options.'); // Verify fragment can be overidden in an external URL. $url = $test_url . '#drupal'; $fragment = $this->randomMachineName(10); - $result = _url($url, array('fragment' => $fragment)); + $result = url($url, array('fragment' => $fragment)); $this->assertEqual($test_url . '#' . $fragment, $result, 'External URL fragment is overidden with a custom fragment in $options.'); // Verify external URL can contain a query string. $url = $test_url . '?drupal=awesome'; - $result = _url($url); + $result = url($url); $this->assertEqual($url, $result, 'External URL with query string works without a query string in $options.'); // Verify external URL can be extended with a query string. $url = $test_url; $query = array($this->randomMachineName(5) => $this->randomMachineName(5)); - $result = _url($url, array('query' => $query)); + $result = url($url, array('query' => $query)); $this->assertEqual($url . '?' . http_build_query($query, '', '&'), $result, 'External URL can be extended with a query string in $options.'); // Verify query string can be extended in an external URL. $url = $test_url . '?drupal=awesome'; $query = array($this->randomMachineName(5) => $this->randomMachineName(5)); - $result = _url($url, array('query' => $query)); + $result = url($url, array('query' => $query)); $this->assertEqual($url . '&' . http_build_query($query, '', '&'), $result, 'External URL query string can be extended with a custom query string in $options.'); } } diff --git a/core/modules/system/src/Tests/Entity/EntityTranslationTest.php b/core/modules/system/src/Tests/Entity/EntityTranslationTest.php index efb96c7..e6b67d5 100644 --- a/core/modules/system/src/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/src/Tests/Entity/EntityTranslationTest.php @@ -438,7 +438,7 @@ function testEntityTranslationAPI() { $entity = $this->reloadEntity($entity); $field_id = implode('.', array($entity->getEntityTypeId(), $entity->bundle(), $this->field_name)); $field = $this->entityManager->getStorage('field_config')->load($field_id); - $field->default_value_callback = 'entity_test_field_default_value'; + $field->default_value_function = 'entity_test_field_default_value'; $field->save(); $translation = $entity->addTranslation($langcode2); $field_storage = $translation->get($this->field_name); diff --git a/core/modules/system/src/Tests/Form/RebuildTest.php b/core/modules/system/src/Tests/Form/RebuildTest.php index a1d4ac2..7affa60 100644 --- a/core/modules/system/src/Tests/Form/RebuildTest.php +++ b/core/modules/system/src/Tests/Form/RebuildTest.php @@ -105,6 +105,6 @@ function testPreserveFormActionAfterAJAX() { // Ensure that the form's action is correct. $forms = $this->xpath('//form[contains(@class, "node-page-form")]'); - $this->assert(count($forms) == 1 && $forms[0]['action'] == _url('node/add/page'), 'Re-rendered form contains the correct action value.'); + $this->assert(count($forms) == 1 && $forms[0]['action'] == url('node/add/page'), 'Re-rendered form contains the correct action value.'); } } diff --git a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php index d5d7250..cf5ab1a 100644 --- a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php +++ b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php @@ -280,7 +280,7 @@ function testBreadCrumbs() { // other than the breadcrumb trail. $elements = $this->xpath('//nav[@id=:menu]/descendant::a[@href=:href]', array( ':menu' => 'block-bartik-tools', - ':href' => _url($link_path), + ':href' => url($link_path), )); $this->assertTrue(count($elements) == 1, "Link to {$link_path} appears only once."); diff --git a/core/modules/system/src/Tests/Menu/LocalActionTest.php b/core/modules/system/src/Tests/Menu/LocalActionTest.php index 3c02aad..bcc443b 100644 --- a/core/modules/system/src/Tests/Menu/LocalActionTest.php +++ b/core/modules/system/src/Tests/Menu/LocalActionTest.php @@ -48,7 +48,7 @@ protected function assertLocalAction(array $actions) { $index = 0; foreach ($actions as $href => $title) { $this->assertEqual((string) $elements[$index], $title); - $this->assertEqual($elements[$index]['href'], _url($href)); + $this->assertEqual($elements[$index]['href'], url($href)); $index++; } } diff --git a/core/modules/system/src/Tests/Menu/LocalTasksTest.php b/core/modules/system/src/Tests/Menu/LocalTasksTest.php index fc61315..957e2eb 100644 --- a/core/modules/system/src/Tests/Menu/LocalTasksTest.php +++ b/core/modules/system/src/Tests/Menu/LocalTasksTest.php @@ -34,7 +34,7 @@ protected function assertLocalTasks(array $hrefs, $level = 0) { )); $this->assertTrue(count($elements), 'Local tasks found.'); foreach ($hrefs as $index => $element) { - $expected = _url($hrefs[$index]); + $expected = url($hrefs[$index]); $method = ($elements[$index]['href'] == $expected ? 'pass' : 'fail'); $this->{$method}(format_string('Task @number href @value equals @expected.', array( '@number' => $index + 1, diff --git a/core/modules/system/src/Tests/Menu/MenuRouterTest.php b/core/modules/system/src/Tests/Menu/MenuRouterTest.php index 48c7500..89a6a32 100644 --- a/core/modules/system/src/Tests/Menu/MenuRouterTest.php +++ b/core/modules/system/src/Tests/Menu/MenuRouterTest.php @@ -70,8 +70,8 @@ protected function doTestHookMenuIntegration() { $this->assertLink('Local task A'); $this->assertLink('Local task B'); // Confirm correct local task href. - $this->assertLinkByHref(_url($base_path)); - $this->assertLinkByHref(_url($base_path . '/b')); + $this->assertLinkByHref(url($base_path)); + $this->assertLinkByHref(url($base_path . '/b')); } /** diff --git a/core/modules/system/src/Tests/Menu/MenuTestBase.php b/core/modules/system/src/Tests/Menu/MenuTestBase.php index 2478af3..fc896d8 100644 --- a/core/modules/system/src/Tests/Menu/MenuTestBase.php +++ b/core/modules/system/src/Tests/Menu/MenuTestBase.php @@ -64,7 +64,7 @@ protected function assertBreadcrumbParts($trail) { // this test would go into an infinite loop, so we need to check that too. while ($trail && !empty($parts)) { foreach ($trail as $path => $title) { - $url = _url($path); + $url = url($path); $part = array_shift($parts); $pass = ($pass && $part['href'] === $url && $part['text'] === String::checkPlain($title)); } @@ -101,7 +101,7 @@ protected function assertMenuActiveTrail($tree, $last_active) { $part_xpath .= 'li[contains(@class, :class)]/a[contains(@href, :href) and contains(text(), :title)]'; $part_args = array( ':class' => 'active-trail', - ':href' => _url($link_path), + ':href' => url($link_path), ':title' => $link_title, ); $xpath .= $this->buildXPathQuery($part_xpath, $part_args); @@ -121,7 +121,7 @@ protected function assertMenuActiveTrail($tree, $last_active) { $args = array( ':class-trail' => 'active-trail', ':class-active' => 'active', - ':href' => _url($active_link_path), + ':href' => url($active_link_path), ':title' => $active_link_title, ); $elements = $this->xpath($xpath, $args); diff --git a/core/modules/system/src/Tests/Menu/MenuTranslateTest.php b/core/modules/system/src/Tests/Menu/MenuTranslateTest.php index ea4b302..99e1401 100644 --- a/core/modules/system/src/Tests/Menu/MenuTranslateTest.php +++ b/core/modules/system/src/Tests/Menu/MenuTranslateTest.php @@ -40,7 +40,7 @@ public function testMenuTranslate() { $this->assertResponse(403); $elements = $this->xpath('//ul[@class=:class]/li/a[@href=:href]', array( ':class' => 'tabs primary', - ':href' => _url('foo/asdf'), + ':href' => url('foo/asdf'), )); $this->assertTrue(empty($elements), 'No tab linking to foo/asdf found'); $this->assertNoLinkByHref('foo/asdf/b'); diff --git a/core/modules/system/src/Tests/Path/UrlAlterFunctionalTest.php b/core/modules/system/src/Tests/Path/UrlAlterFunctionalTest.php index 7f64ddb..6f81d0d 100644 --- a/core/modules/system/src/Tests/Path/UrlAlterFunctionalTest.php +++ b/core/modules/system/src/Tests/Path/UrlAlterFunctionalTest.php @@ -87,9 +87,9 @@ function testCurrentUrlRequestedPath() { * Assert that an outbound path is altered to an expected value. * * @param $original - * A string with the original path that is run through _url(). + * A string with the original path that is run through url(). * @param $final - * A string with the expected result after _url(). + * A string with the expected result after url(). * @return * TRUE if $original was correctly altered to $final, FALSE otherwise. */ @@ -107,7 +107,7 @@ protected function assertUrlOutboundAlter($original, $final) { * @param $original * The original path before it has been altered by inbound URL processing. * @param $final - * A string with the expected result after _url(). + * A string with the expected result after url(). * @return * TRUE if $original was correctly altered to $final, FALSE otherwise. */ diff --git a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php index eaed0a6..2152474 100644 --- a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php +++ b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php @@ -74,7 +74,7 @@ public function testClear() { * Tests the generation of all system site information tokens. */ public function testSystemSiteTokenReplacement() { - // The use of the _url() function requires the url_alias table to exist. + // The use of the url() function requires the url_alias table to exist. $this->installSchema('system', 'url_alias'); $url_options = array( 'absolute' => TRUE, diff --git a/core/modules/system/src/Tests/Theme/FunctionsTest.php b/core/modules/system/src/Tests/Theme/FunctionsTest.php index c8d068c..c970553 100644 --- a/core/modules/system/src/Tests/Theme/FunctionsTest.php +++ b/core/modules/system/src/Tests/Theme/FunctionsTest.php @@ -170,7 +170,7 @@ function testItemList() { * Tests links.html.twig. */ function testLinks() { - // Turn off the query for the _l() function to compare the active + // Turn off the query for the l() function to compare the active // link correctly. $original_query = \Drupal::request()->query->all(); \Drupal::request()->query->replace(array()); @@ -216,9 +216,9 @@ function testLinks() { $expected_links = ''; $expected_links .= '