Drupal 8  8.0.2
ViewsData Class Reference

Public Member Functions

 __construct (CacheBackendInterface $cache_backend, ConfigFactoryInterface $config, ModuleHandlerInterface $module_handler, LanguageManagerInterface $language_manager)
 
 get ($key=NULL)
 
 fetchBaseTables ()
 
 clear ()
 

Protected Member Functions

 cacheGet ($cid)
 
 cacheSet ($cid, $data)
 
 prepareCid ($cid)
 
 getData ()
 
 processEntityTypes (array &$data)
 

Protected Attributes

 $baseCid = 'views_data'
 
 $cacheBackend
 
 $storage = array()
 
 $allStorage = array()
 
 $fullyLoaded = FALSE
 
 $skipCache = FALSE
 
 $langcode
 
 $moduleHandler
 
 $languageManager
 

Detailed Description

Class to manage and lazy load cached views data.

If a table is requested and cannot be loaded from cache, all data is then requested from cache. A table-specific cache entry will then be created for the requested table based on this cached data. Table data is only rebuilt when no cache entry for all table data can be retrieved.

Constructor & Destructor Documentation

__construct ( CacheBackendInterface  $cache_backend,
ConfigFactoryInterface  $config,
ModuleHandlerInterface  $module_handler,
LanguageManagerInterface  $language_manager 
)

Constructs this ViewsData object.

Parameters
\Drupal\Core\Cache\CacheBackendInterface$cache_backendThe cache backend to use.
\Drupal\Core\Config\ConfigFactoryInterface$configThe configuration factory object to use.
\Drupal\Core\Extension\ModuleHandlerInterface$module_handlerThe module handler class to use for invoking hooks.
\Drupal\Core\Language\LanguageManagerInterface$language_managerThe language manager.

References ConfigFactoryInterface\get(), Drupal\languageManager(), and Drupal\moduleHandler().

Here is the call graph for this function:

Member Function Documentation

cacheGet (   $cid)
protected

Gets data from the cache backend.

Parameters
string$cidThe cache ID to return.
Returns
mixed The cached data, if any. This will immediately return FALSE if the $skipCache property is TRUE.

References ViewsData\prepareCid().

Referenced by ViewsData\get(), and ViewsData\getData().

Here is the call graph for this function:

Here is the caller graph for this function:

cacheSet (   $cid,
  $data 
)
protected

Sets data to the cache backend.

Parameters
string$cidThe cache ID to set.
mixed$dataThe data that will be cached.

References Cache\PERMANENT, and ViewsData\prepareCid().

Referenced by ViewsData\get(), and ViewsData\getData().

Here is the call graph for this function:

Here is the caller graph for this function:

clear ( )

Clears the class storage and cache.

References Cache\invalidateTags().

Here is the call graph for this function:

fetchBaseTables ( )

Fetches a list of all base tables available.

Returns
array An array of base table data keyed by table name. Each item contains the following keys:
  • title: The title label for the base table.
  • help: The help text for the base table.
  • weight: The weight of the base table.
get (   $key = NULL)

Gets data for a particular table, or all tables.

Parameters
string | null$keyThe key of the cache entry to retrieve. Defaults to NULL, this will return all table data.
Returns
array $data An array of table data.

References ViewsData\cacheGet(), ViewsData\cacheSet(), and ViewsData\getData().

Here is the call graph for this function:

getData ( )
protected

Gets all data invoked by hook_views_data().

This is requested from the cache before being rebuilt.

Returns
array An array of all data.

References ViewsData\cacheGet(), ViewsData\cacheSet(), NestedArray\mergeDeep(), Drupal\moduleHandler(), and ViewsData\processEntityTypes().

Referenced by ViewsData\get().

Here is the call graph for this function:

Here is the caller graph for this function:

prepareCid (   $cid)
protected

Prepares the cache ID by appending a language code.

Parameters
string$cidThe cache ID to prepare.
Returns
string The prepared cache ID.

Referenced by ViewsData\cacheGet(), and ViewsData\cacheSet().

Here is the caller graph for this function:

processEntityTypes ( array &  $data)
protected

Links tables with 'entity type' to respective generic entity-type tables.

Parameters
array$dataThe array of data to alter entity data for, passed by reference.

Referenced by ViewsData\getData().

Here is the caller graph for this function:


The documentation for this class was generated from the following file: