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
222
Merge Requests
222
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
d726c5f5
Commit
d726c5f5
authored
Apr 05, 2014
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2223951
by damiankloip: Move Sql::getEntityTableInfo() to QueryPluginBase.
parent
9c56b518
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
57 deletions
+58
-57
core/modules/views/lib/Drupal/views/Plugin/views/query/QueryPluginBase.php
...s/lib/Drupal/views/Plugin/views/query/QueryPluginBase.php
+58
-0
core/modules/views/lib/Drupal/views/Plugin/views/query/Sql.php
...modules/views/lib/Drupal/views/Plugin/views/query/Sql.php
+0
-57
No files found.
core/modules/views/lib/Drupal/views/Plugin/views/query/QueryPluginBase.php
View file @
d726c5f5
...
...
@@ -10,6 +10,7 @@
use
Drupal\views\Plugin\views\PluginBase
;
use
Drupal\views\Plugin\views\display\DisplayPluginBase
;
use
Drupal\views\ViewExecutable
;
use
Drupal\views\Views
;
/**
* @todo.
...
...
@@ -208,4 +209,61 @@ public function getDateFormat($field, $format) {
return
$field
;
}
/**
* Returns an array of all tables from the query that map to an entity type.
*
* Includes the base table and all relationships, if eligible.
*
* Available keys for each table:
* - base: The actual base table (i.e. "user" for an author relationship).
* - relationship_id: The id of the relationship, or "none".
* - alias: The alias used for the relationship.
* - entity_type: The entity type matching the base table.
* - revision: A boolean that specifies whether the table is a base table or
* a revision table of the entity type.
*
* @return array
* An array of table information, keyed by table alias.
*/
public
function
getEntityTableInfo
()
{
// Start with the base table.
$entity_tables
=
array
();
$views_data
=
Views
::
viewsData
();
$base_table
=
$this
->
view
->
storage
->
get
(
'base_table'
);
$base_table_data
=
$views_data
->
get
(
$base_table
);
if
(
isset
(
$base_table_data
[
'table'
][
'entity type'
]))
{
$entity_tables
[
$base_table_data
[
'table'
][
'entity type'
]]
=
array
(
'base'
=>
$base_table
,
'alias'
=>
$base_table
,
'relationship_id'
=>
'none'
,
'entity_type'
=>
$base_table_data
[
'table'
][
'entity type'
],
'revision'
=>
FALSE
,
);
}
// Include all relationships.
foreach
(
$this
->
view
->
relationship
as
$relationship_id
=>
$relationship
)
{
$table_data
=
$views_data
->
get
(
$relationship
->
definition
[
'base'
]);
if
(
isset
(
$table_data
[
'table'
][
'entity type'
]))
{
$entity_tables
[
$table_data
[
'table'
][
'entity type'
]]
=
array
(
'base'
=>
$relationship
->
definition
[
'base'
],
'relationship_id'
=>
$relationship_id
,
'alias'
=>
$relationship
->
alias
,
'entity_type'
=>
$table_data
[
'table'
][
'entity type'
],
'revision'
=>
FALSE
,
);
}
}
// Determine which of the tables are revision tables.
foreach
(
$entity_tables
as
$table_alias
=>
$table
)
{
$entity_type
=
\
Drupal
::
entityManager
()
->
getDefinition
(
$table
[
'entity_type'
]);
if
(
$entity_type
->
getRevisionTable
()
==
$table
[
'base'
])
{
$entity_tables
[
$table_alias
][
'revision'
]
=
TRUE
;
}
}
return
$entity_tables
;
}
}
core/modules/views/lib/Drupal/views/Plugin/views/query/Sql.php
View file @
d726c5f5
...
...
@@ -1452,63 +1452,6 @@ function execute(ViewExecutable $view) {
$view
->
execute_time
=
microtime
(
TRUE
)
-
$start
;
}
/**
* Returns an array of all tables from the query that map to an entity type.
*
* Includes the base table and all relationships, if eligible.
*
* Available keys for each table:
* - base: The actual base table (i.e. "user" for an author relationship).
* - relationship_id: The id of the relationship, or "none".
* - alias: The alias used for the relationship.
* - entity_type: The entity type matching the base table.
* - revision: A boolean that specifies whether the table is a base table or
* a revision table of the entity type.
*
* @return array
* An array of table information, keyed by table alias.
*/
public
function
getEntityTableInfo
()
{
// Start with the base table.
$entity_tables
=
array
();
$views_data
=
Views
::
viewsData
();
$base_table
=
$this
->
view
->
storage
->
get
(
'base_table'
);
$base_table_data
=
$views_data
->
get
(
$base_table
);
if
(
isset
(
$base_table_data
[
'table'
][
'entity type'
]))
{
$entity_tables
[
$base_table_data
[
'table'
][
'entity type'
]]
=
array
(
'base'
=>
$base_table
,
'alias'
=>
$base_table
,
'relationship_id'
=>
'none'
,
'entity_type'
=>
$base_table_data
[
'table'
][
'entity type'
],
'revision'
=>
FALSE
,
);
}
// Include all relationships.
foreach
(
$this
->
view
->
relationship
as
$relationship_id
=>
$relationship
)
{
$table_data
=
$views_data
->
get
(
$relationship
->
definition
[
'base'
]);
if
(
isset
(
$table_data
[
'table'
][
'entity type'
]))
{
$entity_tables
[
$table_data
[
'table'
][
'entity type'
]]
=
array
(
'base'
=>
$relationship
->
definition
[
'base'
],
'relationship_id'
=>
$relationship_id
,
'alias'
=>
$relationship
->
alias
,
'entity_type'
=>
$table_data
[
'table'
][
'entity type'
],
'revision'
=>
FALSE
,
);
}
}
// Determine which of the tables are revision tables.
foreach
(
$entity_tables
as
$table_alias
=>
$table
)
{
$entity_type
=
\
Drupal
::
entityManager
()
->
getDefinition
(
$table
[
'entity_type'
]);
if
(
$entity_type
->
getRevisionTable
()
==
$table
[
'base'
])
{
$entity_tables
[
$table_alias
][
'revision'
]
=
TRUE
;
}
}
return
$entity_tables
;
}
/**
* Loads all entities contained in the passed-in $results.
*.
...
...
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