Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
cache_register-3183611
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
0
Merge Requests
0
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
Issue forks
cache_register-3183611
Commits
0f345005
Commit
0f345005
authored
Nov 18, 2020
by
mrweiner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename CacheRegister class and references to Drawer
parent
5fc3e317
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
36 deletions
+37
-36
src/CacheRegisterFactory.php
src/CacheRegisterFactory.php
+6
-6
src/CacheRegisterFactoryInterface.php
src/CacheRegisterFactoryInterface.php
+5
-5
src/Drawer.php
src/Drawer.php
+16
-14
src/DrawerInterface.php
src/DrawerInterface.php
+6
-7
src/Slot.php
src/Slot.php
+4
-4
No files found.
src/CacheRegisterFactory.php
View file @
0f345005
...
...
@@ -29,17 +29,17 @@ class CacheRegisterFactory implements CacheRegisterFactoryInterface {
/**
* {@inheritDoc}
*/
public
function
createRegister
(
string
$implementor_id
,
$cache_register_id
=
NULL
)
{
public
function
openDrawer
(
string
$implementor_id
,
$drawer_name
=
NULL
)
{
$cache_register_name
=
$implementor_id
;
if
(
$
cache_register_id
)
{
$bucket_suffix
=
is_array
(
$
cache_register_id
)
?
implode
(
'.'
,
$
cache_register_id
)
:
$
cache_register_id
;
if
(
$
drawer_name
)
{
$bucket_suffix
=
is_array
(
$
drawer_name
)
?
implode
(
'.'
,
$
drawer_name
)
:
$
drawer_name
;
$cache_register_name
.
=
".
$bucket_suffix
"
;
}
return
new
CacheRegist
er
(
$this
->
cache
,
$cache_register_name
);
return
new
Draw
er
(
$this
->
cache
,
$cache_register_name
);
}
}
src/CacheRegisterFactoryInterface.php
View file @
0f345005
...
...
@@ -7,20 +7,20 @@ namespace Drupal\cache_register;
interface
CacheRegisterFactoryInterface
{
/**
* Creates a
n EasyCache interaction
object.
* Creates a
Drawer
object.
*
* @param string $implementor_id
* This should generally be the implementing module's name.
* It will be used as the beginning of all child slots'
* cache entry IDs.
* @param string|array|null $
cache_register_id
* An identifier for the
regist
er itself.
* @param string|array|null $
drawer_name
* An identifier for the
draw
er itself.
* It will be appended to the $implementor_id when
* determining child slot's cache entry IDs.
* - If passed an array, slots will be imploded.
*
* @return \Drupal\cache_register\
CacheRegist
erInterface
* @return \Drupal\cache_register\
Draw
erInterface
*/
public
function
createRegister
(
string
$implementor_id
,
$cache_register_id
=
NULL
);
public
function
openDrawer
(
string
$implementor_id
,
$drawer_name
=
NULL
);
}
src/
CacheRegist
er.php
→
src/
Draw
er.php
View file @
0f345005
...
...
@@ -4,7 +4,7 @@ namespace Drupal\cache_register;
use
Drupal\Core\Cache\CacheBackendInterface
;
class
CacheRegister
implements
CacheRegist
erInterface
{
class
Drawer
implements
Draw
erInterface
{
/**
* The cache backend service.
...
...
@@ -14,16 +14,18 @@ class CacheRegister implements CacheRegisterInterface {
protected
$cache
;
/**
* @var string Used to name the cache.
* This Drawer's identifier.
*
* @var string
*/
protected
$
registerName
;
protected
$
id
;
/**
* Array of slots in the
regist
er.
* Array of slots in the
draw
er.
*
* @var Slot[]
*/
protected
$
registerS
lots
=
[];
protected
$
s
lots
=
[];
/**
* The constructor.
...
...
@@ -31,15 +33,15 @@ class CacheRegister implements CacheRegisterInterface {
* @param \Drupal\Core\Cache\CacheBackendInterface $cache
* Cache backend.
*
* @param string $
cache_register_name
* @param string $
drawer_id
* Prefixes the cache entry IDs of child Slots.
* This should generally be prefixed by the implementor's name,
* so something like my_module.bookshelf
*/
public
function
__construct
(
CacheBackendInterface
$cache
,
string
$
cache_register_name
)
{
public
function
__construct
(
CacheBackendInterface
$cache
,
string
$
drawer_id
)
{
$this
->
cache
=
$cache
;
// Set to null to help flag if it wasn't implemented in child class
$this
->
registerName
=
$cache_register_name
;
$this
->
id
=
$drawer_id
;
}
/**
...
...
@@ -47,29 +49,29 @@ class CacheRegister implements CacheRegisterInterface {
*/
public
function
createSlot
(
$slot_ids
)
{
$slot
=
new
Slot
(
$this
->
cache
,
$this
,
$slot_ids
);
$this
->
registerS
lots
[]
=
$slot
;
$this
->
s
lots
[]
=
$slot
;
return
$slot
;
}
/**
* {@inheritDoc}
*/
public
function
getName
()
{
return
$this
->
registerName
;
public
function
id
()
{
return
$this
->
id
;
}
/**
* {@inheritDoc}
*/
public
function
getSlots
()
{
return
$this
->
registerS
lots
;
return
$this
->
s
lots
;
}
/**
* {@inheritDoc}
*/
public
function
deleteAll
()
{
foreach
(
$this
->
registerS
lots
as
$slot
)
{
foreach
(
$this
->
s
lots
as
$slot
)
{
$slot
->
deleteCache
();
}
}
...
...
@@ -78,7 +80,7 @@ class CacheRegister implements CacheRegisterInterface {
* {@inheritDoc}
*/
public
function
invalidateAll
()
{
foreach
(
$this
->
registerS
lots
as
$slot
)
{
foreach
(
$this
->
s
lots
as
$slot
)
{
$slot
->
invalidateCache
();
}
}
...
...
src/
CacheRegist
erInterface.php
→
src/
Draw
erInterface.php
View file @
0f345005
...
...
@@ -4,15 +4,14 @@
namespace
Drupal\cache_register
;
interface
CacheRegist
erInterface
{
interface
Draw
erInterface
{
/**
* Creates a new Slot in the
regist
er.
* Creates a new Slot in the
Draw
er.
*
* @note This does note create/populate the associated
* cache entry. You must implement $this->set($data)
* after instantiating the Slot to
* populate its cache entry.
* cache entry. You must implement $slot->set($data)
* to populate its cache entry.
*
* @param array|string $slot_ids
* The ID(s) to use for the slot's cache identifier.
...
...
@@ -25,9 +24,9 @@ interface CacheRegisterInterface {
/**
* @return string
* The
regist
er's name.
* The
draw
er's name.
*/
public
function
getName
();
public
function
id
();
/**
* @return \Drupal\cache_register\SlotInterface[]
...
...
src/Slot.php
View file @
0f345005
...
...
@@ -16,7 +16,7 @@ class Slot implements SlotInterface {
/**
* The parent CacheRegister.
*
* @var \Drupal\cache_register\
CacheRegist
erInterface
* @var \Drupal\cache_register\
Draw
erInterface
*/
protected
$parentCacheRegister
;
...
...
@@ -32,13 +32,13 @@ class Slot implements SlotInterface {
*
* @param \Drupal\Core\Cache\CacheBackendInterface $cache
* Cache backend.
* @param
CacheRegist
erInterface $parent_cache_register
* @param
Draw
erInterface $parent_cache_register
* The parent CacheRegister object.
* @param array|string $slot_ids
* The ID(s) to use for the slot's cache identifier.
*/
public
function
__construct
(
CacheBackendInterface
$cache
,
CacheRegist
erInterface
$parent_cache_register
,
string
$item_ids
)
{
public
function
__construct
(
CacheBackendInterface
$cache
,
Draw
erInterface
$parent_cache_register
,
string
$item_ids
)
{
$this
->
cache
=
$cache
;
$this
->
parentCacheRegister
=
$parent_cache_register
;
$this
->
cacheEntryId
=
$this
->
constructCacheEntryId
(
$slot_ids
);
...
...
@@ -139,7 +139,7 @@ class Slot implements SlotInterface {
*/
private
function
constructCacheEntryId
(
$slot_cache_ids
)
{
$cache_id
=
is_array
(
$slot_cache_ids
)
?
implode
(
'.'
,
$slot_cache_ids
)
:
$slot_cache_ids
;
return
"
{
$this
->
parentCacheRegister
->
getName
()
}
:
$cache_id
"
;
return
"
{
$this
->
parentCacheRegister
->
id
()
}
:
$cache_id
"
;
}
}
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