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
9d276ca5
Commit
9d276ca5
authored
Jan 29, 2013
by
catch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1892462
by tim.plunkett: EntityManager should use the CacheDecorator.
parent
8c1caeda
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
76 deletions
+13
-76
core/includes/common.inc
core/includes/common.inc
+2
-1
core/includes/entity.inc
core/includes/entity.inc
+6
-16
core/lib/Drupal/Component/Plugin/Discovery/CachedDiscoveryInterface.php
...l/Component/Plugin/Discovery/CachedDiscoveryInterface.php
+1
-1
core/lib/Drupal/Core/Entity/EntityManager.php
core/lib/Drupal/Core/Entity/EntityManager.php
+3
-57
core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSettingsTest.php
...ranslation_entity/Tests/EntityTranslationSettingsTest.php
+1
-1
No files found.
core/includes/common.inc
View file @
9d276ca5
...
...
@@ -6430,7 +6430,8 @@ function drupal_flush_all_caches() {
drupal_static_reset
();
// Clear all non-drupal_static() static caches.
// None currently; kept if any static caches need to be reset in the future.
// @todo Rebuild the kernel/container.
drupal_container
()
->
get
(
'plugin.manager.entity'
)
->
clearCachedDefinitions
();
// Rebuild module and theme data.
system_rebuild_module_data
();
...
...
core/includes/entity.inc
View file @
9d276ca5
...
...
@@ -23,24 +23,15 @@
*
* @see \Drupal\Core\Entity\EntityManager
* @see hook_entity_info_alter()
*
* @deprecated Use \Drupal\Core\Entity\EntityManager::getDefinitions() directly.
*/
function
entity_get_info
(
$entity_type
=
NULL
)
{
// Use the advanced drupal_static() pattern, since this is called very often.
static
$drupal_static_fast
;
if
(
!
isset
(
$drupal_static_fast
))
{
$drupal_static_fast
[
'entity_info'
]
=
&
drupal_static
(
__FUNCTION__
);
}
$entity_info
=
&
$drupal_static_fast
[
'entity_info'
];
if
(
empty
(
$entity_info
))
{
$entity_info
=
drupal_container
()
->
get
(
'plugin.manager.entity'
)
->
getDefinitions
();
}
if
(
empty
(
$entity_type
))
{
return
$entity_info
;
return
drupal_container
()
->
get
(
'plugin.manager.entity'
)
->
getDefinitions
()
;
}
else
if
(
isset
(
$entity_info
[
$entity_type
]))
{
return
$entity_info
[
$entity_type
]
;
else
{
return
drupal_container
()
->
get
(
'plugin.manager.entity'
)
->
getDefinition
(
$entity_type
)
;
}
}
...
...
@@ -48,11 +39,10 @@ function entity_get_info($entity_type = NULL) {
* Resets the cached information about entity types.
*/
function
entity_info_cache_clear
()
{
drupal_static_reset
(
'entity_get_info'
);
drupal_static_reset
(
'entity_get_view_modes'
);
drupal_static_reset
(
'entity_get_bundles'
);
// Clear all languages.
cache
()
->
deleteTags
(
array
(
'entity_info'
=>
TRUE
)
);
drupal_container
()
->
get
(
'plugin.manager.entity'
)
->
clearCachedDefinitions
(
);
}
/**
...
...
core/lib/Drupal/Component/Plugin/Discovery/CachedDiscoveryInterface.php
View file @
9d276ca5
...
...
@@ -13,7 +13,7 @@
interface
CachedDiscoveryInterface
extends
DiscoveryInterface
{
/**
* Clears
cached plugin definition
s.
* Clears
static and persistent plugin definition cache
s.
*/
public
function
clearCachedDefinitions
();
...
...
core/lib/Drupal/Core/Entity/EntityManager.php
View file @
9d276ca5
...
...
@@ -11,6 +11,7 @@
use
Drupal\Component\Plugin\Factory\DefaultFactory
;
use
Drupal\Component\Plugin\Discovery\ProcessDecorator
;
use
Drupal\Core\Plugin\Discovery\AlterDecorator
;
use
Drupal\Core\Plugin\Discovery\CacheDecorator
;
use
Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery
;
use
Drupal\Core\Plugin\Discovery\InfoHookDecorator
;
use
Drupal\Core\Cache\CacheBackendInterface
;
...
...
@@ -129,34 +130,6 @@
*/
class
EntityManager
extends
PluginManagerBase
{
/**
* The cache bin used for entity plugin definitions.
*
* @var string
*/
protected
$cacheBin
=
'cache'
;
/**
* The cache key used for entity plugin definitions.
*
* @var string
*/
protected
$cacheKey
=
'entity_info'
;
/**
* The cache expiration for entity plugin definitions.
*
* @var int
*/
protected
$cacheExpire
=
CacheBackendInterface
::
CACHE_PERMANENT
;
/**
* The cache tags used for entity plugin definitions.
*
* @var array
*/
protected
$cacheTags
=
array
(
'entity_info'
=>
TRUE
);
/**
* Contains instantiated controllers keyed by controller type and entity type.
*
...
...
@@ -197,36 +170,9 @@ public function __construct() {
$this
->
discovery
=
new
InfoHookDecorator
(
$this
->
discovery
,
'entity_info'
);
$this
->
discovery
=
new
ProcessDecorator
(
$this
->
discovery
,
array
(
$this
,
'processDefinition'
));
$this
->
discovery
=
new
AlterDecorator
(
$this
->
discovery
,
'entity_info'
);
$this
->
factory
=
new
DefaultFactory
(
$this
);
$this
->
discovery
=
new
CacheDecorator
(
$this
->
discovery
,
'entity_info:'
.
language
(
LANGUAGE_TYPE_INTERFACE
)
->
langcode
,
'cache'
,
CacheBackendInterface
::
CACHE_PERMANENT
,
array
(
'entity_info'
=>
TRUE
)
);
// Entity type plugins includes translated strings, so each language is
// cached separately.
$this
->
cacheKey
.
=
':'
.
language
(
LANGUAGE_TYPE_INTERFACE
)
->
langcode
;
}
/**
* Overrides Drupal\Component\Plugin\PluginManagerBase::getDefinition().
*/
public
function
getDefinition
(
$plugin_id
)
{
$definitions
=
$this
->
getDefinitions
();
return
isset
(
$definitions
[
$plugin_id
])
?
$definitions
[
$plugin_id
]
:
NULL
;
}
/**
* Overrides Drupal\Component\Plugin\PluginManagerBase::getDefinitions().
*/
public
function
getDefinitions
()
{
// Because \Drupal\Core\Plugin\Discovery\CacheDecorator runs before
// definitions are processed and does not support cache tags, we perform our
// own caching.
if
(
$cache
=
cache
(
$this
->
cacheBin
)
->
get
(
$this
->
cacheKey
))
{
return
$cache
->
data
;
}
else
{
$definitions
=
parent
::
getDefinitions
();
cache
(
$this
->
cacheBin
)
->
set
(
$this
->
cacheKey
,
$definitions
,
$this
->
cacheExpire
,
$this
->
cacheTags
);
return
$definitions
;
}
$this
->
factory
=
new
DefaultFactory
(
$this
->
discovery
);
}
/**
...
...
core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSettingsTest.php
View file @
9d276ca5
...
...
@@ -115,7 +115,7 @@ protected function assertSettings($entity_type, $bundle, $enabled, $edit) {
$this
->
drupalPost
(
'admin/config/regional/content-language'
,
$edit
,
t
(
'Save'
));
$args
=
array
(
'@entity_type'
=>
$entity_type
,
'@bundle'
=>
$bundle
,
'@enabled'
=>
$enabled
?
'enabled'
:
'disabled'
);
$message
=
format_string
(
'Translation for entity @entity_type (@bundle) is @enabled.'
,
$args
);
drupal_static_reset
();
entity_info_cache_clear
();
return
$this
->
assertEqual
(
translation_entity_enabled
(
$entity_type
,
$bundle
),
$enabled
,
$message
);
}
...
...
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