Drupal 8  8.0.2
View Class Reference
Inheritance diagram for View:

Public Member Functions

 getExecutable ()
 
 createDuplicate ()
 
 label ()
 
 addDisplay ($plugin_id= 'page', $title=NULL, $id=NULL)
 
getDisplay ($display_id)
 
 duplicateDisplayAsType ($old_display_id, $new_display_type)
 
 calculateDependencies ()
 
 preSave (EntityStorageInterface $storage)
 
 postSave (EntityStorageInterface $storage, $update=TRUE)
 
 postCreate (EntityStorageInterface $storage)
 
 mergeDefaultDisplaysOptions ()
 
 isInstallable ()
 
 __sleep ()
 
 invalidateCaches ()
 
- Public Member Functions inherited from ConfigEntityBase
 __construct (array $values, $entity_type)
 
 getOriginalId ()
 
 setOriginalId ($id)
 
 isNew ()
 
 get ($property_name)
 
 set ($property_name, $value)
 
 enable ()
 
 disable ()
 
 setStatus ($status)
 
 status ()
 
 setSyncing ($syncing)
 
 isSyncing ()
 
 setUninstalling ($uninstalling)
 
 isUninstalling ()
 
 createDuplicate ()
 
 preSave (EntityStorageInterface $storage)
 
 calculateDependencies ()
 
 urlInfo ($rel= 'edit-form', array $options=[])
 
 url ($rel= 'edit-form', $options=array())
 
 link ($text=NULL, $rel= 'edit-form', array $options=[])
 
 toUrl ($rel= 'edit-form', array $options=[])
 
 getCacheTagsToInvalidate ()
 
 getDependencies ()
 
 getConfigDependencyName ()
 
 getConfigTarget ()
 
 onDependencyRemoval (array $dependencies)
 
 setThirdPartySetting ($module, $key, $value)
 
 getThirdPartySetting ($module, $key, $default=NULL)
 
 getThirdPartySettings ($module)
 
 unsetThirdPartySetting ($module, $key)
 
 getThirdPartyProviders ()
 
 isInstallable ()
 
 trustData ()
 
 hasTrustedData ()
 
 save ()
 
- Public Member Functions inherited from Entity
 __construct (array $values, $entity_type)
 
 id ()
 
 uuid ()
 
 isNew ()
 
 enforceIsNew ($value=TRUE)
 
 getEntityTypeId ()
 
 bundle ()
 
 label ()
 
 urlInfo ($rel= 'canonical', array $options=[])
 
 toUrl ($rel= 'canonical', array $options=[])
 
 hasLinkTemplate ($rel)
 
 link ($text=NULL, $rel= 'canonical', array $options=[])
 
 toLink ($text=NULL, $rel= 'canonical', array $options=[])
 
 url ($rel= 'canonical', $options=array())
 
 uriRelationships ()
 
 access ($operation, AccountInterface $account=NULL, $return_as_object=FALSE)
 
 language ()
 
 save ()
 
 delete ()
 
 createDuplicate ()
 
 getEntityType ()
 
 preSave (EntityStorageInterface $storage)
 
 postSave (EntityStorageInterface $storage, $update=TRUE)
 
 postCreate (EntityStorageInterface $storage)
 
 referencedEntities ()
 
 getCacheContexts ()
 
 getCacheTagsToInvalidate ()
 
 getCacheTags ()
 
 getCacheMaxAge ()
 
 getOriginalId ()
 
 setOriginalId ($id)
 
 toArray ()
 
 getTypedData ()
 
 __sleep ()
 
 getConfigDependencyKey ()
 
 getConfigDependencyName ()
 
 getConfigTarget ()
 
- Public Member Functions inherited from RefinableCacheableDependencyInterface
 addCacheContexts (array $cache_contexts)
 
 addCacheTags (array $cache_tags)
 
 mergeCacheMaxAge ($max_age)
 
 addCacheableDependency ($other_object)
 

Static Public Member Functions

static postLoad (EntityStorageInterface $storage, array &$entities)
 
static preCreate (EntityStorageInterface $storage, array &$values)
 
static postDelete (EntityStorageInterface $storage, array $entities)
 
- Static Public Member Functions inherited from ConfigEntityBase
static sort (ConfigEntityInterface $a, ConfigEntityInterface $b)
 
- Static Public Member Functions inherited from Entity
static preCreate (EntityStorageInterface $storage, array &$values)
 
static preDelete (EntityStorageInterface $storage, array $entities)
 
static postDelete (EntityStorageInterface $storage, array $entities)
 
static postLoad (EntityStorageInterface $storage, array &$entities)
 
static load ($id)
 
static loadMultiple (array $ids=NULL)
 
static create (array $values=array())
 

Protected Member Functions

 generateDisplayId ($plugin_id)
 
 addCacheMetadata ()
 
- Protected Member Functions inherited from ConfigEntityBase
 getTypedConfig ()
 
 addDependency ($type, $name)
 
 invalidateTagsOnSave ($update)
 
- Protected Member Functions inherited from Entity
 entityManager ()
 
 entityTypeManager ()
 
 languageManager ()
 
 uuidGenerator ()
 
 linkTemplates ()
 
 urlRouteParameters ($rel)
 
 invalidateTagsOnSave ($update)
 

Protected Attributes

 $base_table = 'node'
 
 $id = NULL
 
 $label
 
 $description = ''
 
 $tag = ''
 
 $core = \Drupal::CORE_COMPATIBILITY
 
 $display = array()
 
 $base_field = 'nid'
 
 $executable
 
 $module = 'views'
 
- Protected Attributes inherited from ConfigEntityBase
 $originalId
 
 $pluginConfigKey
 
 $status = TRUE
 
 $uuid
 
 $langcode = 'en'
 
 $third_party_settings = array()
 
 $_core = []
 
 $trustedData = FALSE
 
- Protected Attributes inherited from Entity
 $entityTypeId
 
 $enforceIsNew
 
 $typedData
 

Additional Inherited Members

- Static Protected Member Functions inherited from ConfigEntityBase
static invalidateTagsOnDelete (EntityTypeInterface $entity_type, array $entities)
 
static getConfigManager ()
 
- Static Protected Member Functions inherited from Entity
static invalidateTagsOnDelete (EntityTypeInterface $entity_type, array $entities)
 

Detailed Description

Defines a View configuration entity class.

( id = "view", label = ("View", context = "View entity type"), handlers = { "access" = "Drupal\views\ViewAccessControlHandler" }, admin_permission = "administer views", entity_keys = { "id" = "id", "label" = "label", "status" = "status" }, config_export = { "id", "label", "module", "description", "tag", "base_table", "base_field", "core", "display", } )

Member Function Documentation

__sleep ( )

{}

addCacheMetadata ( )
protected

Fills in the cache metadata of this view.

Cache metadata is set per view and per display, and ends up being stored in the view's configuration. This allows Views to determine very efficiently:

  • the max-age
  • the cache contexts
  • the cache tags

In other words: this allows us to do the (expensive) work of initializing Views plugins and handlers to determine their effect on the cacheability of a view at save time rather than at runtime.

References View\getDisplay(), View\getExecutable(), Cache\mergeContexts(), and LanguageInterface\TYPE_INTERFACE.

Referenced by View\preSave().

Here is the call graph for this function:

Here is the caller graph for this function:

addDisplay (   $plugin_id = 'page',
  $title = NULL,
  $id = NULL 
)

{Adds a new display handler to the view, automatically creating an ID.

Parameters
string$plugin_id(optional) The plugin type from the Views plugin annotation. Defaults to 'page'.
string$title(optional) The title of the display. Defaults to NULL.
string$id(optional) The ID to use, e.g., 'default', 'page_1', 'block_2'. Defaults to NULL.
Returns
string|bool The key to the display in $view->display, or FALSE if no plugin ID was provided.
}

Implements ViewEntityInterface.

References View\generateDisplayId(), Views\pluginManager(), and t().

Here is the call graph for this function:

calculateDependencies ( )

{Calculates dependencies and stores them in the dependency property.

Returns
$this
See Also
}

Implements ConfigEntityInterface.

References ConfigEntityBase\addDependency(), and View\getExecutable().

Here is the call graph for this function:

createDuplicate ( )

{Creates a duplicate of the entity.

Returns
static A clone of $this with all identifiers unset, so saving it inserts a new entity into the storage system.
}

Implements EntityInterface.

duplicateDisplayAsType (   $old_display_id,
  $new_display_type 
)

{Duplicates an existing display into a new display type.For example clone to display a page display as a block display.

Parameters
string$old_display_idThe origin of the duplicated display.
string$new_display_typeThe display type of the new display.
Returns
string The display ID of the new display.
}

Implements ViewEntityInterface.

References View\getExecutable(), NestedArray\mergeDeep(), and ConfigEntityBase\set().

Here is the call graph for this function:

generateDisplayId (   $plugin_id)
protected

Generates a display ID of a certain plugin type.

Parameters
string$plugin_idWhich plugin should be used for the new display ID.
Returns
string

Referenced by View\addDisplay().

Here is the caller graph for this function:

& getDisplay (   $display_id)

{Retrieves a specific display's configuration by reference.

Parameters
string$display_idThe display ID to retrieve, e.g., 'default', 'page_1', 'block_2'.
Returns
array A reference to the specified display configuration.
}

Implements ViewEntityInterface.

Referenced by View\addCacheMetadata().

Here is the caller graph for this function:

getExecutable ( )

{Gets an executable instance for this view.

Returns
A view executable instance.
}

Implements ViewEntityInterface.

References Views\executableFactory().

Referenced by View\addCacheMetadata(), WizardPluginBase\addDisplays(), View\calculateDependencies(), and View\duplicateDisplayAsType().

Here is the call graph for this function:

Here is the caller graph for this function:

invalidateCaches ( )

Invalidates cache tags.

References Entity\getCacheTags(), and Drupal\service().

Referenced by View\postSave().

Here is the call graph for this function:

Here is the caller graph for this function:

isInstallable ( )

{Checks whether this entity is installable.For example, a default view might not be installable if the base table doesn't exist.bool TRUE if the entity is installable, FALSE otherwise.}

Implements ConfigEntityInterface.

References Drupal\service().

Here is the call graph for this function:

label ( )

{Gets the label of the entity.

Returns
string|null The label of the entity, or NULL if there is no label defined.
}

Implements EntityInterface.

References View\$label, and Entity\id().

Here is the call graph for this function:

mergeDefaultDisplaysOptions ( )

{Add defaults to the display options.}

Implements ViewEntityInterface.

References ConfigEntityBase\set().

Referenced by View\postCreate().

Here is the call graph for this function:

Here is the caller graph for this function:

postCreate ( EntityStorageInterface  $storage)

{Acts on an entity after it is created but before hooks are invoked.

Parameters
\Drupal\Core\Entity\EntityStorageInterface$storageThe entity storage object.
}

Implements EntityInterface.

References View\mergeDefaultDisplaysOptions().

Here is the call graph for this function:

static postDelete ( EntityStorageInterface  $storage,
array  $entities 
)
static

{Acts on deleted entities before the delete hook is invoked.Used after the entities are deleted but before invoking the delete hook.

Parameters
\Drupal\Core\Entity\EntityStorageInterface$storageThe entity storage object.
\Drupal\Core\Entity\EntityInterface[]$entities An array of entities.
}

Implements EntityInterface.

References Drupal\service().

Here is the call graph for this function:

static postLoad ( EntityStorageInterface  $storage,
array &  $entities 
)
static

{Acts on loaded entities.

Parameters
\Drupal\Core\Entity\EntityStorageInterface$storageThe entity storage object.
\Drupal\Core\Entity\EntityInterface[]$entities An array of entities.
}

Implements EntityInterface.

postSave ( EntityStorageInterface  $storage,
  $update = TRUE 
)

{Acts on a saved entity before the insert or update hook is invoked.Used after the entity is saved, but before invoking the insert or update hook. Note that in case of translatable content entities this callback is only fired on their current translation. It is up to the developer to iterate over all translations if needed.

Parameters
\Drupal\Core\Entity\EntityStorageInterface$storageThe entity storage object.
bool$updateTRUE if the entity has been updated, or FALSE if it has been inserted.
}

Implements EntityInterface.

References View\invalidateCaches(), Drupal\service(), and ConfigEntityBase\status().

Here is the call graph for this function:

static preCreate ( EntityStorageInterface  $storage,
array &  $values 
)
static

{Changes the values of an entity before it is created.Load defaults for example.

Parameters
\Drupal\Core\Entity\EntityStorageInterface$storageThe entity storage object.
mixed[]$values An array of values to set, keyed by property name. If the entity type has bundles the bundle key has to be specified.
}

Implements EntityInterface.

preSave ( EntityStorageInterface  $storage)

{Acts on an entity before the presave hook is invoked.Used before the entity is saved and before invoking the presave hook. Note that in case of translatable content entities this callback is only fired on their current translation. It is up to the developer to iterate over all translations if needed. This is different from its counterpart in the Field API, FieldItemListInterface::preSave(), which is fired on all field translations automatically.

Todo:
Adjust existing implementations and the documentation according to https://www.drupal.org/node/2577609 to have a consistent API.
Parameters
\Drupal\Core\Entity\EntityStorageInterface$storageThe entity storage object.
See Also
::preSave()
}

Implements EntityInterface.

References View\addCacheMetadata(), ConfigEntityBase\isSyncing(), and ConfigEntityBase\set().

Here is the call graph for this function:

Field Documentation

$label
protected

The label of the view.

Referenced by View\label().


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