Commit 368cf514 authored by alexpott's avatar alexpott

Issue #2417567 by xjm, effulgentsia, mpdonadio, hussainweb: Rename user-path: scheme to internal:

parent df44266e
......@@ -237,7 +237,7 @@ public static function fromUserInput($user_input, $options = []) {
// fromUri() requires an absolute URI, so prepend the appropriate scheme
// name.
return static::fromUri('user-path:' . $user_input, $options);
return static::fromUri('internal:' . $user_input, $options);
}
/**
......@@ -256,7 +256,7 @@ public static function fromUserInput($user_input, $options = []) {
*
* @param string $uri
* The URI of the resource including the scheme. For user input that may
* correspond to a Drupal route, use user-path: for the scheme. For paths
* correspond to a Drupal route, use internal: for the scheme. For paths
* that are known not to be handled by the Drupal routing system (such as
* static files), use base: for the scheme to get a link relative to the
* Drupal base path (like the <base> HTML element). For a link to an entity
......@@ -278,7 +278,7 @@ public static function fromUserInput($user_input, $options = []) {
* defined, the current scheme is used, so the user stays on HTTP or HTTPS
* respectively. TRUE enforces HTTPS and FALSE enforces HTTP.
*
* Note: the user-path: scheme should be avoided except when processing actual
* Note: the internal: scheme should be avoided except when processing actual
* user input that may or may not correspond to a Drupal route. Normally use
* Url::fromRoute() for code linking to any any Drupal page.
*
......@@ -299,7 +299,7 @@ public static function fromUri($uri, $options = []) {
throw new \InvalidArgumentException(String::format('The URI "@uri" is malformed.', ['@uri' => $uri]));
}
if (empty($uri_parts['scheme'])) {
throw new \InvalidArgumentException(String::format('The URI "@uri" is invalid. You must use a valid URI scheme. Use base: for items like a static file that needs the base path. Use user-path: for user input without a scheme. Use entity: for referencing the canonical route of a content entity. Use route: for directly representing a route name and parameters.', ['@uri' => $uri]));
throw new \InvalidArgumentException(String::format('The URI "@uri" is invalid. You must use a valid URI scheme.', ['@uri' => $uri]));
}
$uri_parts += ['path' => ''];
// Discard empty fragment in $options for consistency with parse_url().
......@@ -324,8 +324,8 @@ public static function fromUri($uri, $options = []) {
if ($uri_parts['scheme'] === 'entity') {
$url = static::fromEntityUri($uri_parts, $uri_options, $uri);
}
elseif ($uri_parts['scheme'] === 'user-path') {
$url = static::fromUserPathUri($uri_parts, $uri_options);
elseif ($uri_parts['scheme'] === 'internal') {
$url = static::fromInternalUri($uri_parts, $uri_options);
}
elseif ($uri_parts['scheme'] === 'route') {
$url = static::fromRouteUri($uri_parts, $uri_options, $uri);
......@@ -369,49 +369,49 @@ protected static function fromEntityUri(array $uri_parts, array $options, $uri)
}
/**
* Creates a new Url object for 'user-path:' URIs.
* Creates a new Url object for 'internal:' URIs.
*
* Important note: the URI minus the scheme can NOT simply be validated by a
* \Drupal\Core\Path\PathValidatorInterface implementation. The semantics of
* the 'user-path:' URI scheme are different:
* the 'internal:' URI scheme are different:
* - PathValidatorInterface accepts paths without a leading slash (e.g.
* 'node/add') as well as 2 special paths: '<front>' and '<none>', which are
* mapped to the correspondingly named routes.
* - 'user-path:' URIs store paths with a leading slash that represents the
* root — i.e. the front page — (e.g. 'user-path:/node/add'), and doesn't
* - 'internal:' URIs store paths with a leading slash that represents the
* root — i.e. the front page — (e.g. 'internal:/node/add'), and doesn't
* have any exceptions.
*
* To clarify, a few examples of path plus corresponding 'user-path:' URI:
* - 'node/add' -> 'user-path:/node/add'
* - 'node/add?foo=bar' -> 'user-path:/node/add?foo=bar'
* - 'node/add#kitten' -> 'user-path:/node/add#kitten'
* - '<front>' -> 'user-path:/'
* - '<front>foo=bar' -> 'user-path:/?foo=bar'
* - '<front>#kitten' -> 'user-path:/#kitten'
* - '<none>' -> 'user-path:'
* - '<none>foo=bar' -> 'user-path:?foo=bar'
* - '<none>#kitten' -> 'user-path:#kitten'
*
* Therefore, when using a PathValidatorInterface to validate 'user-path:'
* To clarify, a few examples of path plus corresponding 'internal:' URI:
* - 'node/add' -> 'internal:/node/add'
* - 'node/add?foo=bar' -> 'internal:/node/add?foo=bar'
* - 'node/add#kitten' -> 'internal:/node/add#kitten'
* - '<front>' -> 'internal:/'
* - '<front>foo=bar' -> 'internal:/?foo=bar'
* - '<front>#kitten' -> 'internal:/#kitten'
* - '<none>' -> 'internal:'
* - '<none>foo=bar' -> 'internal:?foo=bar'
* - '<none>#kitten' -> 'internal:#kitten'
*
* Therefore, when using a PathValidatorInterface to validate 'internal:'
* URIs, we must map:
* - 'user-path:' (path component is '') to the special '<none>' path
* - 'user-path:/' (path component is '/') to the special '<front>' path
* - 'user-path:/some-path' (path component is '/some-path') to 'some-path'
* - 'internal:' (path component is '') to the special '<none>' path
* - 'internal:/' (path component is '/') to the special '<front>' path
* - 'internal:/some-path' (path component is '/some-path') to 'some-path'
*
* @param array $uri_parts
* Parts from an URI of the form user-path:{path} as from parse_url().
* Parts from an URI of the form internal:{path} as from parse_url().
* @param array $options
* An array of options, see static::fromUri() for details.
*
* @return \Drupal\Core\Url
* A new Url object for a 'user-path:' URI.
* A new Url object for a 'internal:' URI.
*
* @throws \InvalidArgumentException
* Thrown when the URI's path component doesn't have a leading slash.
*/
protected static function fromUserPathUri(array $uri_parts, array $options) {
protected static function fromInternalUri(array $uri_parts, array $options) {
// Both PathValidator::getUrlIfValidWithoutAccessCheck() and 'base:' URIs
// only accept/contain paths without a leading slash, unlike 'user-path:'
// only accept/contain paths without a leading slash, unlike 'internal:'
// URIs, for which the leading slash means "relative to Drupal root" and
// "relative to Symfony app root" (just like in Symfony/Drupal 8 routes).
if (empty($uri_parts['path'])) {
......@@ -422,7 +422,7 @@ protected static function fromUserPathUri(array $uri_parts, array $options) {
}
else {
if ($uri_parts['path'][0] !== '/') {
throw new \InvalidArgumentException(String::format('The user-path path component "@path" is invalid. Its path component must have a leading slash, e.g. user-path:/foo.', ['@path' => $uri_parts['path']]));
throw new \InvalidArgumentException(String::format('The internal path component "@path" is invalid. Its path component must have a leading slash, e.g. internal:/foo.', ['@path' => $uri_parts['path']]));
}
// Remove the leading slash.
$uri_parts['path'] = substr($uri_parts['path'], 1);
......@@ -518,7 +518,7 @@ protected function setUnrouted() {
* Generates a URI string that represents tha data in the Url object.
*
* The URI will typically have the scheme of route: even if the object was
* constructed using an entity: or user-path: scheme. A user-path: URI that
* constructed using an entity: or internal: scheme. A internal: URI that
* does not match a Drupal route with be returned here with the base: scheme,
* and external URLs will be returned in their original form.
*
......@@ -723,7 +723,7 @@ public function setAbsolute($absolute = TRUE) {
* string or fragment specified by the options array.
*
* If this Url object was constructed from a Drupal route or from an internal
* URI (URIs using the user-path:, base:, or entity: schemes), the returned
* URI (URIs using the internal:, base:, or entity: schemes), the returned
* string will either be a relative URL like /node/1 or an absolute URL like
* http://example.com/node/1 depending on the options array, plus any
* specified query string or fragment.
......
......@@ -210,7 +210,7 @@ public function viewElements(FieldItemListInterface $items) {
// attribute.
// @todo Does RDF need a URL rather than an internal URI here?
// @see \Drupal\rdf\Tests\Field\LinkFieldRdfaTest.
$content = str_replace('user-path:/', '', $item->uri);
$content = str_replace('internal:/', '', $item->uri);
$item->_attributes += array('content' => $content);
}
}
......
......@@ -42,11 +42,11 @@ public static function defaultSettings() {
}
/**
* Gets the URI without the 'user-path:' or 'entity:' scheme.
* Gets the URI without the 'internal:' or 'entity:' scheme.
*
* The following two forms of URIs are transformed:
* - 'entity:' URIs: to entity autocomplete ("label (entity id)") strings;
* - 'user-path:' URIs: the scheme is stripped.
* - 'internal:' URIs: the scheme is stripped.
*
* This method is the inverse of ::getUserEnteredStringAsUri().
*
......@@ -63,9 +63,9 @@ protected static function getUriAsDisplayableString($uri) {
// By default, the displayable string is the URI.
$displayable_string = $uri;
// A different displayable string may be chosen in case of the 'user-path:'
// A different displayable string may be chosen in case of the 'internal:'
// or 'entity:' built-in schemes.
if ($scheme === 'user-path') {
if ($scheme === 'internal') {
$uri_reference = explode(':', $uri, 2)[1];
// @todo '<front>' is valid input for BC reasons, may be removed by
......@@ -94,7 +94,7 @@ protected static function getUriAsDisplayableString($uri) {
*
* The following two forms of input are mapped to URIs:
* - entity autocomplete ("label (entity id)") strings: to 'entity:' URIs;
* - strings without a detectable scheme: to 'user-path:' URIs.
* - strings without a detectable scheme: to 'internal:' URIs.
*
* This method is the inverse of ::getUriAsDisplayableString().
*
......@@ -117,7 +117,7 @@ protected static function getUserEnteredStringAsUri($string) {
// https://www.drupal.org/node/2423093.
$uri = 'entity:node/' . $entity_id;
}
// Detect a schemeless string, map to 'user-path:' URI.
// Detect a schemeless string, map to 'internal:' URI.
elseif (!empty($string) && parse_url($string, PHP_URL_SCHEME) === NULL) {
// @todo '<front>' is valid input for BC reasons, may be removed by
// https://www.drupal.org/node/2421941
......@@ -126,7 +126,7 @@ protected static function getUserEnteredStringAsUri($string) {
if (strpos($string, '<front>') === 0) {
$string = '/' . substr($string, strlen('<front>'));
}
$uri = 'user-path:' . $string;
$uri = 'internal:' . $string;
}
return $uri;
......@@ -139,11 +139,11 @@ public static function validateUriElement($element, FormStateInterface $form_sta
$uri = static::getUserEnteredStringAsUri($element['#value']);
$form_state->setValueForElement($element, $uri);
// If getUserEnteredStringAsUri() mapped the entered value to a 'user-path:'
// If getUserEnteredStringAsUri() mapped the entered value to a 'internal:'
// URI , ensure the raw value begins with '/', '?' or '#'.
// @todo '<front>' is valid input for BC reasons, may be removed by
// https://www.drupal.org/node/2421941
if (parse_url($uri, PHP_URL_SCHEME) === 'user-path' && !in_array($element['#value'][0], ['/', '?', '#'], TRUE) && substr($element['#value'], 0, 7) !== '<front>') {
if (parse_url($uri, PHP_URL_SCHEME) === 'internal' && !in_array($element['#value'][0], ['/', '?', '#'], TRUE) && substr($element['#value'], 0, 7) !== '<front>') {
$form_state->setError($element, t('Manually entered paths should start with /, ? or #.'));
return;
}
......@@ -363,7 +363,7 @@ public function massageFormValues(array $values, array $form, FormStateInterface
/**
* {@inheritdoc}
*
* Override the '%uri' message parameter, to ensure that 'user-path:' URIs
* Override the '%uri' message parameter, to ensure that 'internal:' URIs
* show a validation error message that doesn't mention that scheme.
*/
public function flagErrors(FieldItemListInterface $items, ConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state) {
......
......@@ -45,7 +45,7 @@ function menu_link_content_path_insert($path) {
}
/**
* Helper function to update plugin definition using user-path scheme.
* Helper function to update plugin definition using internal scheme.
*
* @param string $path
* The path alias.
......@@ -57,7 +57,7 @@ function _menu_link_content_update_path_alias($path) {
/** @var \Drupal\menu_link_content\MenuLinkContentInterface[] $entities */
$entities = \Drupal::entityManager()
->getStorage('menu_link_content')
->loadByProperties(['link.uri' => 'user-path:/' . $path]);
->loadByProperties(['link.uri' => 'internal:/' . $path]);
foreach ($entities as $menu_link) {
$menu_link_manager->updateDefinition($menu_link->getPluginId(), $menu_link->getPluginDefinition(), FALSE);
}
......
......@@ -186,7 +186,7 @@ public static function preCreate(EntityStorageInterface $storage, array &$values
public function preSave(EntityStorageInterface $storage) {
parent::preSave($storage);
if (parse_url($this->link->uri, PHP_URL_SCHEME) === 'user-path') {
if (parse_url($this->link->uri, PHP_URL_SCHEME) === 'internal') {
$this->setRequiresRediscovery(TRUE);
}
else {
......
......@@ -67,14 +67,14 @@ function createLinkHierarchy($module = 'menu_test') {
);
$parent = $base_options + array(
'link' => ['uri' => 'user-path:/menu-test/hierarchy/parent'],
'link' => ['uri' => 'internal:/menu-test/hierarchy/parent'],
);
$link = entity_create('menu_link_content', $parent);
$link->save();
$links['parent'] = $link->getPluginId();
$child_1 = $base_options + array(
'link' => ['uri' => 'user-path:/menu-test/hierarchy/parent/child'],
'link' => ['uri' => 'internal:/menu-test/hierarchy/parent/child'],
'parent' => $links['parent'],
);
$link = entity_create('menu_link_content', $child_1);
......@@ -82,7 +82,7 @@ function createLinkHierarchy($module = 'menu_test') {
$links['child-1'] = $link->getPluginId();
$child_1_1 = $base_options + array(
'link' => ['uri' => 'user-path:/menu-test/hierarchy/parent/child2/child'],
'link' => ['uri' => 'internal:/menu-test/hierarchy/parent/child2/child'],
'parent' => $links['child-1'],
);
$link = entity_create('menu_link_content', $child_1_1);
......@@ -90,7 +90,7 @@ function createLinkHierarchy($module = 'menu_test') {
$links['child-1-1'] = $link->getPluginId();
$child_1_2 = $base_options + array(
'link' => ['uri' => 'user-path:/menu-test/hierarchy/parent/child2/child'],
'link' => ['uri' => 'internal:/menu-test/hierarchy/parent/child2/child'],
'parent' => $links['child-1'],
);
$link = entity_create('menu_link_content', $child_1_2);
......@@ -98,7 +98,7 @@ function createLinkHierarchy($module = 'menu_test') {
$links['child-1-2'] = $link->getPluginId();
$child_2 = $base_options + array(
'link' => ['uri' => 'user-path:/menu-test/hierarchy/parent/child'],
'link' => ['uri' => 'internal:/menu-test/hierarchy/parent/child'],
'parent' => $links['parent'],
);
$link = entity_create('menu_link_content', $child_2);
......@@ -128,7 +128,7 @@ public function testCreateLink() {
$options = array(
'menu_name' => 'menu_test',
'bundle' => 'menu_link_content',
'link' => [['uri' => 'user-path:/']],
'link' => [['uri' => 'internal:/']],
);
$link = entity_create('menu_link_content', $options);
$link->save();
......
......@@ -46,7 +46,7 @@ public function testRediscover() {
// Set up a custom menu link pointing to a specific path.
MenuLinkContent::create([
'title' => 'Example',
'link' => [['uri' => 'user-path:/example-path']],
'link' => [['uri' => 'internal:/example-path']],
'menu_name' => 'tools',
])->save();
$menu_tree = \Drupal::menuTree()->load('tools', new MenuTreeParameters());
......
......@@ -57,7 +57,7 @@ protected function getAdministratorPermissions() {
*/
protected function createEntity($values, $langcode, $bundle_name = NULL) {
$values['menu_name'] = 'tools';
$values['link']['uri'] = 'user-path:/admin/structure/menu';
$values['link']['uri'] = 'internal:/admin/structure/menu';
$values['title'] = 'Test title';
return parent::createEntity($values, $langcode, $bundle_name);
......@@ -70,7 +70,7 @@ public function testTranslationLinkOnMenuEditForm() {
$this->drupalGet('admin/structure/menu/manage/tools');
$this->assertNoLink(t('Translate'));
$menu_link_content = MenuLinkContent::create(['menu_name' => 'tools', 'link' => ['uri' => 'user-path:/admin/structure/menu']]);
$menu_link_content = MenuLinkContent::create(['menu_name' => 'tools', 'link' => ['uri' => 'internal:/admin/structure/menu']]);
$menu_link_content->save();
$this->drupalGet('admin/structure/menu/manage/tools');
$this->assertLink(t('Translate'));
......
......@@ -64,7 +64,7 @@ public function testPathAliasChange() {
$menu_link_content = MenuLinkContent::create([
'title' => 'Menu title',
'link' => ['uri' => 'user-path:/my-blog'],
'link' => ['uri' => 'internal:/my-blog'],
'menu_name' => 'tools',
]);
$menu_link_content->save();
......
......@@ -83,7 +83,7 @@ public function testMenuBlock() {
'title' => 'Alpaca',
'menu_name' => 'llama',
'link' => [[
'uri' => 'user-path:/',
'uri' => 'internal:/',
]],
'bundle' => 'menu_name',
));
......
......@@ -105,8 +105,8 @@ function testMenu() {
$this->verifyAccess(403);
foreach ($this->items as $item) {
// Menu link URIs are stored as 'user-path:/node/$nid'.
$node = Node::load(str_replace('user-path:/node/', '', $item->link->uri));
// Menu link URIs are stored as 'internal:/node/$nid'.
$node = Node::load(str_replace('internal:/node/', '', $item->link->uri));
$this->verifyMenuLink($item, $node);
}
......
......@@ -23,7 +23,7 @@ process:
migration: d6_menu
source: menu_name
'link/uri':
plugin: userpath_uri
plugin: internal_uri
source:
- link_path
'link/options': options
......
......@@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\UserPathUri.
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\InternalUri.
*/
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
......@@ -12,13 +12,13 @@
use Drupal\migrate\Row;
/**
* Process a path into a 'user-path:' URI.
* Process a path into an 'internal:' URI.
*
* @MigrateProcessPlugin(
* id = "userpath_uri"
* id = "internal_uri"
* )
*/
class UserPathUri extends ProcessPluginBase {
class InternalUri extends ProcessPluginBase {
/**
* {@inheritdoc}
......@@ -27,7 +27,7 @@ public function transform($value, MigrateExecutable $migrate_executable, Row $ro
list($path) = $value;
if (parse_url($path, PHP_URL_SCHEME) === NULL) {
return 'user-path:/' . $path;
return 'internal:/' . $path;
}
return $path;
}
......
......@@ -57,7 +57,7 @@ public function testMenuLinks() {
$this->assertIdentical($menu_link->isEnabled(), TRUE);
$this->assertIdentical($menu_link->isExpanded(), FALSE);
$this->assertIdentical($menu_link->link->options, ['attributes' => ['title' => 'Test menu link 1']]);
$this->assertIdentical($menu_link->link->uri, 'user-path:/user/login');
$this->assertIdentical($menu_link->link->uri, 'internal:/user/login');
$this->assertIdentical($menu_link->getWeight(), 15);
$menu_link = entity_load('menu_link_content', 139);
......@@ -67,7 +67,7 @@ public function testMenuLinks() {
$this->assertIdentical($menu_link->isEnabled(), TRUE);
$this->assertIdentical($menu_link->isExpanded(), TRUE);
$this->assertIdentical($menu_link->link->options, ['query' => 'foo=bar', 'attributes' => ['title' => 'Test menu link 2']]);
$this->assertIdentical($menu_link->link->uri, 'user-path:/admin');
$this->assertIdentical($menu_link->link->uri, 'internal:/admin');
$this->assertIdentical($menu_link->getWeight(), 12);
$menu_link = entity_load('menu_link_content', 140);
......
......@@ -67,7 +67,7 @@ public function testAllFormattersInternal() {
// Set up test values.
$this->testValue = 'admin';
$this->entity = entity_create('entity_test', array());
$this->entity->{$this->fieldName}->uri = 'user-path:/admin';
$this->entity->{$this->fieldName}->uri = 'internal:/admin';
// Set up the expected result.
// AssertFormatterRdfa looks for a full path.
......@@ -86,7 +86,7 @@ public function testAllFormattersFront() {
// Set up test values.
$this->testValue = '/';
$this->entity = entity_create('entity_test', array());
$this->entity->{$this->fieldName}->uri = 'user-path:/';
$this->entity->{$this->fieldName}->uri = 'internal:/';
// Set up the expected result.
$expected_rdf = array(
......
......@@ -65,7 +65,7 @@ public function addShortcutLinkInline(ShortcutSetInterface $shortcut_set, Reques
'title' => $name,
'shortcut_set' => $shortcut_set->id(),
'link' => array(
'uri' => 'user-path:/' . $link,
'uri' => 'internal:/' . $link,
),
));
......
......@@ -46,7 +46,7 @@ protected function createEntity() {
'shortcut_set' => 'default',
'title' => t('Llama'),
'weight' => 0,
'link' => [['uri' => 'user-path:/admin']],
'link' => [['uri' => 'internal:/admin']],
));
$shortcut->save();
......
......@@ -66,7 +66,7 @@ public function testShortcutLinkAdd() {
$this->assertResponse(200);
$saved_set = ShortcutSet::load($set->id());
$paths = $this->getShortcutInformation($saved_set, 'link');
$this->assertTrue(in_array('user-path:' . $test_path, $paths), 'Shortcut created: ' . $test_path);
$this->assertTrue(in_array('internal:' . $test_path, $paths), 'Shortcut created: ' . $test_path);
if (in_array($test_path, $test_cases_non_access)) {
$this->assertNoLink($title, String::format('Shortcut link %url not accessible on the page.', ['%url' => $test_path]));
......@@ -168,7 +168,7 @@ public function testShortcutLinkChangePath() {
$this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), array('title[0][value]' => $shortcut->getTitle(), 'link[0][uri]' => $new_link_path), t('Save'));
$saved_set = ShortcutSet::load($set->id());
$paths = $this->getShortcutInformation($saved_set, 'link');
$this->assertTrue(in_array('user-path:' . $new_link_path, $paths), 'Shortcut path changed: ' . $new_link_path);
$this->assertTrue(in_array('internal:' . $new_link_path, $paths), 'Shortcut path changed: ' . $new_link_path);
$this->assertLinkByHref($new_link_path, 0, 'Shortcut with new path appears on the page.');
}
......
......@@ -66,7 +66,7 @@ protected function setUp() {
'title' => t('Add content'),
'weight' => -20,
'link' => array(
'uri' => 'user-path:/node/add',
'uri' => 'internal:/node/add',
),
));
$shortcut->save();
......@@ -76,7 +76,7 @@ protected function setUp() {
'title' => t('All content'),
'weight' => -19,
'link' => array(
'uri' => 'user-path:/admin/content',
'uri' => 'internal:/admin/content',
),
));
$shortcut->save();
......
......@@ -50,7 +50,7 @@ protected function getTranslatorPermissions() {
* {@inheritdoc}
*/
protected function createEntity($values, $langcode, $bundle_name = NULL) {
$values['link']['uri'] = 'user-path:/user';
$values['link']['uri'] = 'internal:/user';
return parent::createEntity($values, $langcode, $bundle_name);
}
......
......@@ -247,7 +247,7 @@ function testBreadCrumbs() {
$this->drupalPostForm("admin/structure/menu/manage/$menu/add", $edit, t('Save'));
$menu_links = entity_load_multiple_by_properties('menu_link_content', array(
'title' => $edit['title[0][value]'],
'link.uri' => 'user-path:/taxonomy/term/' . $term->id(),
'link.uri' => 'internal:/taxonomy/term/' . $term->id(),
));
$tags[$name]['link'] = reset($menu_links);
$parent_mlid = $tags[$name]['link']->getPluginId();
......
......@@ -67,9 +67,9 @@ public function testDeleteLinksInMenu() {
\Drupal::entityManager()->getStorage('menu')->create(array('id' => 'menu1'))->save();
\Drupal::entityManager()->getStorage('menu')->create(array('id' => 'menu2'))->save();
\Drupal::entityManager()->getStorage('menu_link_content')->create(array('link' => ['uri' => 'user-path:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content'))->save();
\Drupal::entityManager()->getStorage('menu_link_content')->create(array('link' => ['uri' => 'user-path:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content'))->save();
\Drupal::entityManager()->getStorage('menu_link_content')->create(array('link' => ['uri' => 'user-path:/menu_name_test'], 'menu_name' => 'menu2', 'bundle' => 'menu_link_content'))->save();
\Drupal::entityManager()->getStorage('menu_link_content')->create(array('link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content'))->save();
\Drupal::entityManager()->getStorage('menu_link_content')->create(array('link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content'))->save();
\Drupal::entityManager()->getStorage('menu_link_content')->create(array('link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu2', 'bundle' => 'menu_link_content'))->save();
$output = $this->linkTree->load('menu1', new MenuTreeParameters());
$this->assertEqual(count($output), 2);
......
......@@ -456,7 +456,7 @@ protected function validatePath($path) {
$errors[] = $this->t('No query allowed.');
}
if (!parse_url('user-path:/' . $path)) {
if (!parse_url('internal:/' . $path)) {
$errors[] = $this->t('Invalid path. Valid characters are alphanumerics as well as "-", ".", "_" and "~".');
}
......
......@@ -1334,7 +1334,7 @@ protected function renderAsLink($alter, $text, $tokens) {
// Url::toUriString() call above, because we support twig tokens in
// rewrite settings of views fields.
// In that case the original path looks like
// user-path:/admin/content/files/usage/{{ fid }}, which will be escaped by
// internal:/admin/content/files/usage/{{ fid }}, which will be escaped by
// the toUriString() call above.
$path = preg_replace(['/(\%7B){2}(\%20)*/', '/(\%20)*(\%7D){2}/'], ['{{','}}'], $path);
......
......@@ -85,7 +85,7 @@ protected function getLinks() {
$path = strip_tags(String::decodeEntities($this->viewsTokenReplace($path, $tokens)));
$links[$field] = array(
'url' => $path ? UrlObject::fromUri('user-path:/' . $path) : $url,
'url' => $path ? UrlObject::fromUri('internal:/' . $path) : $url,
'title' => $title,
);
if (!empty($this->options['destination'])) {
......
......@@ -50,7 +50,7 @@ public function testEntityOperations() {
foreach ($entities as $entity) {
$operations = \Drupal::entityManager()->getListBuilder('entity_test')->getOperations($entity);
foreach ($operations as $operation) {
$expected_destination = Url::fromUri('user-path:/test-entity-operations');
$expected_destination = Url::fromUri('internal:/test-entity-operations');
$result = $this->xpath('//ul[contains(@class, dropbutton)]/li/a[contains(@href, :path) and text()=:title]', array(':path' => $operation['url'] . '?destination=' . $expected_destination, ':title' => $operation['title']));
$this->assertEqual(count($result), 1, t('Found entity @operation link with destination parameter.', array('@operation' => $operation['title'])));
}
......
......@@ -58,7 +58,7 @@ function standard_install() {
'shortcut_set' => 'default',
'title' => t('Add content'),
'weight' => -20,
'link' => array('uri' => 'user-path:/node/add'),
'link' => array('uri' => 'internal:/node/add'),
));
$shortcut->save();
......@@ -66,7 +66,7 @@ function standard_install() {
'shortcut_set' => 'default',
'title' => t('All content'),
'weight' => -19,
'link' => array('uri' => 'user-path:/admin/content'),
'link' => array('uri' => 'internal:/admin/content'),
));
$shortcut->save();
......
......@@ -175,7 +175,7 @@ public function testFromRouteFront() {
* Tests the fromUserInput method with valid paths.
*
* @covers ::fromUserInput
* @dataProvider providerFromValidUserPathUri
* @dataProvider providerFromValidInternalUri
*/
public function testFromUserInput($path) {
$url = Url::fromUserInput($path);
......@@ -208,7 +208,7 @@ public function testFromUserInput($path) {
*
* @covers ::fromUserInput
* @expectedException \InvalidArgumentException
* @dataProvider providerFromInvalidUserPathUri
* @dataProvider providerFromInvalidInternalUri
*/
public function testFromInvalidUserInput($path) {
$url = Url::fromUserInput($path);
......@@ -224,7 +224,7 @@ public function testFromRoutedPathWithInvalidRoute() {
->method('getUrlIfValidWithoutAccessCheck')
->with('invalid-path')
->willReturn(FALSE);
$url = Url::fromUri('user-path:/invalid-path');
$url = Url::fromUri('internal:/invalid-path');
$this->assertSame(FALSE, $url->isRouted());
$this->assertSame('base:invalid-path', $url->getUri());
}
......@@ -240,7 +240,7 @@ public function testFromRoutedPathWithValidRoute() {
->method('getUrlIfValidWithoutAccessCheck')
->with('valid-path')
->willReturn($url);
$result_url = Url::fromUri('user-path:/valid-path');
$result_url = Url::fromUri('internal:/valid-path');
$this->assertSame($url, $result_url);
}
......@@ -636,13 +636,13 @@ public function providerTestToUriStringForEntity() {
}
/**
* Tests the toUriString() method with user-path: URIs.
* Tests the toUriString() method with internal: URIs.
*
* @covers ::toUriString
*
* @dataProvider providerTestToUriStringForUserPath
* @dataProvider providerTestToUriStringForInternal
*/
public function testToUriStringForUserPath($uri, $options, $uri_string) {
public function testToUriStringForInternal($uri, $options, $uri_string) {
$url = Url::fromRoute('entity.test_entity.canonical', ['test_entity' => '1']);
$this->pathValidator->expects($this->any())
->method('getUrlIfValidWithoutAccessCheck')
......@@ -656,45 +656,45 @@ public function testToUriStringForUserPath($uri, $options, $uri_string) {
}
/**
* Data provider for testing user-path URIs
* Data provider for testing internal URIs.
*/
public function providerTestToUriStringForUserPath() {
public function providerTestToUriStringForInternal() {
return [
// The four permutations of a regular path.
['user-path:/test-entity/1', [], 'route:entity.test_entity.canonical;test_entity=1'],
['user-path:/test-entity/1', ['fragment' => 'top'], 'route:entity.test_entity.canonical;test_entity=1#top'],
['user-path:/test-entity/1', ['fragment' => 'top', 'query' => ['page' => '2']], 'route:entity.test_entity.canonical;test_entity=1?page=2#top'],
['user-path:/test-entity/1?page=2#top', [], 'route:entity.test_entity.canonical;test_entity=1?page=2#top'],
['internal:/test-entity/1', [], 'route:entity.test_entity.canonical;test_entity=1'],
['internal:/test-entity/1', ['fragment' => 'top'], 'route:entity.test_entity.canonical;test_entity=1#top'],
['internal:/test-entity/1', ['fragment' => 'top', 'query' => ['page' => '2']], 'route:entity.test_entity.canonical;test_entity=1?page=2#top'],
['internal:/test-entity/1?page=2#top', [], 'route:entity.test_entity.canonical;test_entity=1?page=2#top'],
// The four permutations of the special '<front>' path.
['user-path:/', [], 'route:<front>'],
['user-path:/', ['fragment' => 'top'], 'route:<front>#top'],
['user-path:/', ['fragment' => 'top', 'query' => ['page' => '2']], 'route:<front>?page=2#top'],
['user-path:/?page=2#top', [], 'route:<front>?page=2#top'],
['internal:/', [], 'route:<front>'],
['internal:/', ['fragment' => 'top'], 'route:<front>#top'],
['internal:/', ['fragment' => 'top', 'query' => ['page' => '2']], 'route:<front>?page=2#top'],
['internal:/?page=2#top', [], 'route:<front>?page=2#top'],
// The four permutations of the special '<none>' path.
['user-path:', [], 'route:<none>'],
['user-path:', ['fragment' => 'top'], 'route:<none>#top'],
['user-path:', ['fragment' => 'top', 'query' => ['page' => '2']], 'route:<none>?page=2#top'],
['user-path:?page=2#top', [], 'route:<none>?page=2#top'],
['internal:', [], 'route:<none>'],
['internal:', ['fragment' => 'top'], 'route:<none>#top'],
['internal:', ['fragment' => 'top', 'query' => ['page' => '2']], 'route:<none>?page=2#top'],
['internal:?page=2#top', [], 'route:<none>?page=2#top'],
];
}
/**
* Tests the fromUri() method with a valid user-path: URI.
* Tests the fromUri() method with a valid internal: URI.
*
* @covers ::fromUri