Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
300
Merge Requests
300
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
1a51606b
Commit
1a51606b
authored
Mar 26, 2014
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2199381
by slashrsm, Xano: Add \Drupal\Core\Path\PathInterface.
parent
bc7f7f3c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
135 additions
and
101 deletions
+135
-101
core/includes/path.inc
core/includes/path.inc
+1
-1
core/lib/Drupal/Core/Path/AliasManager.php
core/lib/Drupal/Core/Path/AliasManager.php
+3
-3
core/lib/Drupal/Core/Path/Path.php
core/lib/Drupal/Core/Path/Path.php
+9
-69
core/lib/Drupal/Core/Path/PathInterface.php
core/lib/Drupal/Core/Path/PathInterface.php
+103
-0
core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/UrlAlias.php
...ib/Drupal/migrate/Plugin/migrate/destination/UrlAlias.php
+4
-4
core/modules/path/lib/Drupal/path/Form/DeleteForm.php
core/modules/path/lib/Drupal/path/Form/DeleteForm.php
+5
-5
core/modules/path/path.api.php
core/modules/path/path.api.php
+10
-19
No files found.
core/includes/path.inc
View file @
1a51606b
...
...
@@ -103,7 +103,7 @@ function current_path() {
* A string representing the source, a number representing the pid, or an
* array of query conditions.
*
* @see \Drupal\Core\Path\Path::load()
* @see \Drupal\Core\Path\Path
Interface
::load()
*/
function
path_load
(
$conditions
)
{
if
(
is_numeric
(
$conditions
))
{
...
...
core/lib/Drupal/Core/Path/AliasManager.php
View file @
1a51606b
...
...
@@ -15,7 +15,7 @@ class AliasManager implements AliasManagerInterface {
/**
* The Path CRUD service.
*
* @var \Drupal\Core\Path\Path
* @var \Drupal\Core\Path\Path
Interface
*/
protected
$path
;
...
...
@@ -74,14 +74,14 @@ class AliasManager implements AliasManagerInterface {
/**
* Constructs an AliasManager.
*
* @param \Drupal\Core\Path\Path $path
* @param \Drupal\Core\Path\Path
Interface
$path
* The Path CRUD service.
* @param \Drupal\Core\Path\AliasWhitelistInterface $whitelist
* The whitelist implementation to use.
* @param \Drupal\Core\Language\LanguageManager $language_manager
* The language manager.
*/
public
function
__construct
(
Path
$path
,
AliasWhitelistInterface
$whitelist
,
LanguageManager
$language_manager
)
{
public
function
__construct
(
Path
Interface
$path
,
AliasWhitelistInterface
$whitelist
,
LanguageManager
$language_manager
)
{
$this
->
path
=
$path
;
$this
->
languageManager
=
$language_manager
;
$this
->
whitelist
=
$whitelist
;
...
...
core/lib/Drupal/Core/Path/Path.php
View file @
1a51606b
...
...
@@ -2,7 +2,7 @@
/**
* @file
* Contains Drupal\Core\Path\Path.
* Contains
\
Drupal\Core\Path\Path.
*/
namespace
Drupal\Core\Path
;
...
...
@@ -12,9 +12,9 @@
use
Drupal\Core\Language\Language
;
/**
*
Defin
es a class for CRUD operations on path aliases.
*
Provid
es a class for CRUD operations on path aliases.
*/
class
Path
{
class
Path
implements
PathInterface
{
/**
* The database connection.
...
...
@@ -45,27 +45,7 @@ public function __construct(Connection $connection, ModuleHandlerInterface $modu
}
/**
* Saves a path alias to the database.
*
* @param string $source
* The internal system path.
*
* @param string $alias
* The URL alias.
*
* @param string $langcode
* The language code of the alias.
*
* @param int $pid
* Unique path alias identifier.
*
* @return
* FALSE if the path could not be saved or an associative array containing
* the following keys:
* - source: The internal system path.
* - alias: The URL alias.
* - pid: Unique path alias identifier.
* - langcode: The language code of the alias.
* {@inheritdoc}
*/
public
function
save
(
$source
,
$alias
,
$langcode
=
Language
::
LANGCODE_NOT_SPECIFIED
,
$pid
=
NULL
)
{
...
...
@@ -100,18 +80,7 @@ public function save($source, $alias, $langcode = Language::LANGCODE_NOT_SPECIFI
}
/**
* Fetches a specific URL alias from the database.
*
* @param $conditions
* An array of query conditions.
*
* @return
* FALSE if no alias was found or an associative array containing the
* following keys:
* - source: The internal system path.
* - alias: The URL alias.
* - pid: Unique path alias identifier.
* - langcode: The language code of the alias.
* {@inheritdoc}
*/
public
function
load
(
$conditions
)
{
$select
=
$this
->
connection
->
select
(
'url_alias'
);
...
...
@@ -125,10 +94,7 @@ public function load($conditions) {
}
/**
* Deletes a URL alias.
*
* @param array $conditions
* An array of criteria.
* {@inheritdoc}
*/
public
function
delete
(
$conditions
)
{
$path
=
$this
->
load
(
$conditions
);
...
...
@@ -143,15 +109,7 @@ public function delete($conditions) {
}
/**
* Preloads path alias information for a given list of source paths.
*
* @param $path
* The path to investigate for corresponding aliases.
* @param $langcode
* Language code to search the path with. If there's no path defined for
* that language it will search paths without language.
* @return array
* Source (keys) to alias (values) mapping.
* {@inheritdoc}
*/
public
function
preloadPathAlias
(
$preloaded
,
$langcode
)
{
$args
=
array
(
...
...
@@ -182,16 +140,7 @@ public function preloadPathAlias($preloaded, $langcode) {
}
/**
* Returns an alias of Drupal system URL.
*
* @param string $path
* The path to investigate for corresponding path aliases.
* @param string $langcode
* Language code to search the path with. If there's no path defined for
* that language it will search paths without language.
*
* @return string|bool
* A path alias, or FALSE if no path was found.
* {@inheritdoc}
*/
public
function
lookupPathAlias
(
$path
,
$langcode
)
{
$args
=
array
(
...
...
@@ -215,16 +164,7 @@ public function lookupPathAlias($path, $langcode) {
}
/**
* Returns Drupal system URL of an alias.
*
* @param string $path
* The path to investigate for corresponding system URLs.
* @param string $langcode
* Language code to search the path with. If there's no path defined for
* that language it will search paths without language.
*
* @return string|bool
* A Drupal system path, or FALSE if no path was found.
* {@inheritdoc}
*/
public
function
lookupPathSource
(
$path
,
$langcode
)
{
$args
=
array
(
...
...
core/lib/Drupal/Core/Path/PathInterface.php
0 → 100644
View file @
1a51606b
<?php
/**
* @file
* Contains \Drupal\Core\Path\PathInterface.
*/
namespace
Drupal\Core\Path
;
use
Drupal\Core\Language\Language
;
/**
* Provides a class for CRUD operations on path aliases.
*/
interface
PathInterface
{
/**
* Saves a path alias to the database.
*
* @param string $source
* The internal system path.
* @param string $alias
* The URL alias.
* @param string $langcode
* The language code of the alias.
* @param int|null $pid
* Unique path alias identifier.
*
* @return mixed[]|bool
* FALSE if the path could not be saved or an associative array containing
* the following keys:
* - source (string): The internal system path.
* - alias (string): The URL alias.
* - pid (int): Unique path alias identifier.
* - langcode (string): The language code of the alias.
*/
public
function
save
(
$source
,
$alias
,
$langcode
=
Language
::
LANGCODE_NOT_SPECIFIED
,
$pid
=
NULL
);
/**
* Fetches a specific URL alias from the database.
*
* @param $conditions
* An array of query conditions.
*
* @return mixed[]|bool
* FALSE if no alias was found or an associative array containing the
* following keys:
* - source (string): The internal system path.
* - alias (string): The URL alias.
* - pid (int): Unique path alias identifier.
* - langcode (string): The language code of the alias.
*/
public
function
load
(
$conditions
);
/**
* Deletes a URL alias.
*
* @param array $conditions
* An array of criteria.
*/
public
function
delete
(
$conditions
);
/**
* Pre-loads path alias information for a given list of source paths.
*
* @param $preloaded
* @param $langcode
* Language code to search the path with. If there's no path defined for
* that language it will search paths without language.
*
* @return string[]
* Source (keys) to alias (values) mapping.
*/
public
function
preloadPathAlias
(
$preloaded
,
$langcode
);
/**
* Returns an alias of Drupal system URL.
*
* @param string $path
* The path to investigate for corresponding path aliases.
* @param string $langcode
* Language code to search the path with. If there's no path defined for
* that language it will search paths without language.
*
* @return string|false
* A path alias, or FALSE if no path was found.
*/
public
function
lookupPathAlias
(
$path
,
$langcode
);
/**
* Returns Drupal system URL of an alias.
*
* @param string $path
* The path to investigate for corresponding system URLs.
* @param string $langcode
* Language code to search the path with. If there's no path defined for
* that language it will search paths without language.
*
* @return string|false
* A Drupal system path, or FALSE if no path was found.
*/
public
function
lookupPathSource
(
$path
,
$langcode
);
}
core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/UrlAlias.php
View file @
1a51606b
...
...
@@ -7,9 +7,9 @@
namespace
Drupal\migrate\Plugin\migrate\destination
;
use
Drupal\Core\Path\PathInterface
;
use
Drupal\migrate\Entity\MigrationInterface
;
use
Drupal\migrate\Row
;
use
Drupal\Core\Path\Path
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Drupal\Core\Plugin\ContainerFactoryPluginInterface
;
...
...
@@ -23,7 +23,7 @@ class UrlAlias extends DestinationBase implements ContainerFactoryPluginInterfac
/**
* The path crud service.
*
* @var
Path
$path
* @var
\Drupal\Core\Path\PathInterface
$path
*/
protected
$path
;
...
...
@@ -38,10 +38,10 @@ class UrlAlias extends DestinationBase implements ContainerFactoryPluginInterfac
* The plugin implementation definition.
* @param MigrationInterface $migration
* The migration.
* @param \Drupal\Core\Path\Path $path
* @param \Drupal\Core\Path\Path
Interface
$path
* The path crud service.
*/
public
function
__construct
(
array
$configuration
,
$plugin_id
,
array
$plugin_definition
,
MigrationInterface
$migration
,
Path
$path
)
{
public
function
__construct
(
array
$configuration
,
$plugin_id
,
array
$plugin_definition
,
MigrationInterface
$migration
,
Path
Interface
$path
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
,
$migration
);
$this
->
path
=
$path
;
}
...
...
core/modules/path/lib/Drupal/path/Form/DeleteForm.php
View file @
1a51606b
...
...
@@ -8,7 +8,7 @@
namespace
Drupal\path\Form
;
use
Drupal\Core\Form\ConfirmFormBase
;
use
Drupal\Core\Path\Path
;
use
Drupal\Core\Path\Path
Interface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
...
...
@@ -19,7 +19,7 @@ class DeleteForm extends ConfirmFormBase {
/**
* The path crud service.
*
* @var Path $path
* @var Path
Interface
$path
*/
protected
$path
;
...
...
@@ -31,12 +31,12 @@ class DeleteForm extends ConfirmFormBase {
protected
$pathAlias
;
/**
* Constructs a \Drupal\
Core\Path\Path
object.
* Constructs a \Drupal\
path\Form\DeleteForm
object.
*
* @param \Drupal\Core\Path\Path $path
* @param \Drupal\Core\Path\Path
Interface
$path
* The path crud service.
*/
public
function
__construct
(
Path
$path
)
{
public
function
__construct
(
Path
Interface
$path
)
{
$this
->
path
=
$path
;
}
...
...
core/modules/path/path.api.php
View file @
1a51606b
...
...
@@ -13,14 +13,11 @@
/**
* Respond to a path being inserted.
*
* @param $path
* An associative array containing the following keys:
* - source: The internal system path.
* - alias: The URL alias.
* - pid: Unique path alias identifier.
* - langcode: The language code of the alias.
* @param array $path
* The array structure is identical to that of the return value of
* \Drupal\Core\Path\PathInterface::save().
*
* @see \Drupal\Core\Path\Path::save()
* @see \Drupal\Core\Path\Path
Interface
::save()
*/
function
hook_path_insert
(
$path
)
{
db_insert
(
'mytable'
)
...
...
@@ -35,13 +32,10 @@ function hook_path_insert($path) {
* Respond to a path being updated.
*
* @param $path
* An associative array containing the following keys:
* - source: The internal system path.
* - alias: The URL alias.
* - pid: Unique path alias identifier.
* - langcode: The language code of the alias.
* The array structure is identical to that of the return value of
* \Drupal\Core\Path\PathInterface::save().
*
* @see \Drupal\Core\Path\Path::save()
* @see \Drupal\Core\Path\Path
Interface
::save()
*/
function
hook_path_update
(
$path
)
{
db_update
(
'mytable'
)
...
...
@@ -54,13 +48,10 @@ function hook_path_update($path) {
* Respond to a path being deleted.
*
* @param $path
* An associative array containing the following keys:
* - source: The internal system path.
* - alias: The URL alias.
* - pid: Unique path alias identifier.
* - langcode: The language code of the alias.
* The array structure is identical to that of the return value of
* \Drupal\Core\Path\PathInterface::save().
*
* @see \Drupal\Core\Path\Path::delete()
* @see \Drupal\Core\Path\Path
Interface
::delete()
*/
function
hook_path_delete
(
$path
)
{
db_delete
(
'mytable'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment