protected ThemeRegistry::updateCache($lock = TRUE)
Writes a value to the persistent cache immediately.
Parameters
bool $lock: (optional) Whether to acquire a lock before writing to cache. Defaults to TRUE.
Overrides CacheCollector::updateCache
File
- core/lib/Drupal/Core/Utility/ThemeRegistry.php, line 134
Class
- ThemeRegistry
- Builds the run-time theme registry.
Namespace
Drupal\Core\Utility
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | protected function updateCache( $lock = TRUE) { if (! $this ->persistable) { return ; } // @todo: Is the custom implementation necessary? $data = array (); foreach ( $this ->keysToPersist as $offset => $persist ) { if ( $persist ) { $data [ $offset ] = $this ->storage[ $offset ]; } } if ( empty ( $data )) { return ; } $lock_name = $this ->cid . ':' . __CLASS__ ; if (! $lock || $this ->lock->acquire( $lock_name )) { if ( $cached = $this ->cache->get( $this ->cid)) { // Use array merge instead of union so that filled in values in $data // overwrite empty values in the current cache. $data = array_merge ( $cached ->data, $data ); } else { $registry = $this ->initializeRegistry(); $data = array_merge ( $registry , $data ); } $this ->cache->set( $this ->cid, $data , Cache::PERMANENT, $this ->tags); if ( $lock ) { $this ->lock->release( $lock_name ); } } } |
Please login to continue.