ViewUI
class ViewUI implements ViewEntityInterface (View source)
Stores UI related temporary settings.
Properties
| bool | $editing | Indicates if a view is currently being edited. |
|
| array | $changed_display | Stores an array of displays that have been changed. |
|
| float | $render_time | How long the view takes to render in microseconds. |
|
| bool | $changed | If this view has been changed. |
|
| array | $temporary_options | Stores options temporarily while editing. |
|
| array | $stack | Stores a stack of UI forms to display. |
|
| bool | $live_preview | Is the view run in a context of the preview in the admin interface. |
|
| $renderPreview | |||
| protected ViewEntityInterface | $storage | The View storage object. |
|
| protected array | $additionalQueries | Stores a list of database queries run beside the main one from views. |
|
| static array | $forms | Contains an array of form keys and their respective classes. |
Methods
Returns the value of a property.
Sets the status of the configuration entity.
Sets the value of a property.
Sets the status of the synchronization flag.
{@inheritdoc}
Returns whether this entity is being changed as part of a synchronization.
Returns whether this entity is being changed during the uninstall process.
Basic submit handler applicable to all 'standard' forms.
Provide a standard set of Apply/Cancel/OK buttons for the forms. Also provide a hidden op operator because the forms plugin doesn't seem to properly provide which button was clicked.
Return the was_defaulted, is_defaulted and revert state of a form.
Add another form to the stack; clicking 'apply' will go to this form rather than closing the ajax popup.
Submit handler for adding new item(s) to a view.
Set up query capturing.
Add the list of queries run during render to buildinfo.
No description
Get the user's current progress through the form stack.
Sets a cached view object in the shared tempstore.
Returns whether the current view is locked.
Passes through all unknown calls onto the storage object.
Retrieves a specific display's configuration by reference.
Gets the identifier.
Gets the entity UUID (Universally Unique Identifier).
Determines whether the entity is new.
Gets the ID of the type of the entity.
Gets the bundle of the entity.
Gets the entity type definition.
Creates a duplicate of the entity.
Loads an entity.
Loads one or more entities.
Constructs a new entity object, without permanently saving it.
Deletes an entity permanently.
Saves an entity permanently.
Generates the HTML for a link to this entity.
Gets the label of the entity.
Enforces an entity to be new.
Gets an array of all property values.
Gets the language of the entity.
Checks data value access.
Enables the configuration entity.
Disables the configuration entity.
Returns whether the configuration entity is enabled.
Gets the original ID.
Sets the original ID.
Acts on a saved entity before the insert or update hook is invoked.
Changes the values of an entity before it is created.
Acts on entities before they are deleted and before hooks are invoked.
Acts on deleted entities before the delete hook is invoked.
Gets an executable instance for this view.
Duplicates an existing display into a new display type.
Add defaults to the display options.
Gets a list of URI relationships supported by this entity.
Gets a list of entities referenced by this entity.
Indicates if a link template exists for a given key.
Calculates dependencies and stores them in the dependency property.
Gets the key that is used to store configuration dependencies.
Gets the configuration dependency name.
Gets the configuration target identifier for the entity.
Informs the entity that entities it depends on will be deleted.
Gets the configuration dependencies.
The cache contexts associated with this object.
The cache tags associated with this object.
The maximum age for which this object may be cached.
Gets a typed data object for this entity object.
Adds a new display handler to the view, automatically creating an ID.
Checks whether this entity is installable.
Sets the value of a third-party setting.
Gets the value of a third-party setting.
Gets all third-party settings of a given module.
Unsets a third-party setting.
Gets the list of third parties that store information.
Sets that the data should be trusted.
Gets whether on not the data is trusted.
Adds a dependency on an object: merges its cacheability metadata.
Adds cache contexts.
Merges the maximum age (in seconds) with the existing maximum age.
Returns the cache tags that should be used to invalidate caches.
Adds cache tags.
Unsets the lock on this View.
Details
__construct(ViewEntityInterface $storage)
Constructs a View UI object.
mixed
get(string $property_name, $langcode = NULL)
Returns the value of a property.
$this
setStatus(bool $status)
Sets the status of the configuration entity.
$this
set(string $property_name, mixed $value, $notify = TRUE)
Sets the value of a property.
$this
setSyncing($syncing)
Sets the status of the synchronization flag.
setUninstalling($isUninstalling)
{@inheritdoc}
bool
isSyncing()
Returns whether this entity is being changed as part of a synchronization.
If you are writing code that responds to a change in this entity (insert, update, delete, presave, etc.), and your code would result in a change to this entity itself, a configuration change (whether related to this entity, another entity, or non-entity configuration), you need to check and see if this entity change is part of a synchronization process, and skip executing your code if that is the case.
For example, \Drupal\node\Entity\NodeType::postSave() adds the default body field to newly created node type configuration entities, which is a configuration change. You would not want this code to run during an import, because imported entities were already given the body field when they were originally created, and the imported configuration includes all of their currently-configured fields. On the other hand, \Drupal\field\Entity\FieldStorageConfig::preSave() and the methods it calls make sure that the storage tables are created or updated for the field storage configuration entity, which is not a configuration change, and it must be done whether due to an import or not. So, the first method should check $entity->isSyncing() and skip executing if it returns TRUE, and the second should not perform this check.
bool
isUninstalling()
Returns whether this entity is being changed during the uninstall process.
If you are writing code that responds to a change in this entity (insert, update, delete, presave, etc.), and your code would result in a configuration change (whether related to this configuration entity, another configuration entity, or non-entity configuration) or your code would result in a change to this entity itself, you need to check and see if this entity change is part of an uninstall process, and skip executing your code if that is the case.
For example, \Drupal\language\Entity\ConfigurableLanguage::preDelete() prevents the API from deleting the default language. However during an uninstall of the language module it is expected that the default language should be deleted.
standardSubmit($form, FormStateInterface $form_state)
Basic submit handler applicable to all 'standard' forms.
This submit handler determines whether the user wants the submitted changes to apply to the default display or to the current display, and dispatches control appropriately.
standardCancel($form, FormStateInterface $form_state)
Submit handler for cancel button.
getStandardButtons($form, FormStateInterface $form_state, $form_id, $name = NULL)
Provide a standard set of Apply/Cancel/OK buttons for the forms. Also provide a hidden op operator because the forms plugin doesn't seem to properly provide which button was clicked.
TODO: Is the hidden op operator still here somewhere, or is that part of the docblock outdated?
getOverrideValues($form, FormStateInterface $form_state)
Return the was_defaulted, is_defaulted and revert state of a form.
addFormToStack($key, $display_id, $type, $id = NULL, $top = FALSE, $rebuild_keys = FALSE)
Add another form to the stack; clicking 'apply' will go to this form rather than closing the ajax popup.
submitItemAdd($form, FormStateInterface $form_state)
Submit handler for adding new item(s) to a view.
startQueryCapture()
Set up query capturing.
\Drupal\Core\Database\Database stores the queries that it runs, if logging is enabled.
endQueryCapture()
Add the list of queries run during render to buildinfo.
renderPreview($display_id, $args = [])
No description
false
getFormProgress()
Get the user's current progress through the form stack.
cacheSet()
Sets a cached view object in the shared tempstore.
bool
isLocked()
Returns whether the current view is locked.
__call($method, $args)
Passes through all unknown calls onto the storage object.
array
getDisplay(string $display_id)
Retrieves a specific display's configuration by reference.
string|int|null
id()
Gets the identifier.
string|null
uuid()
Gets the entity UUID (Universally Unique Identifier).
The UUID is guaranteed to be unique and can be used to identify an entity across multiple systems.
bool
isNew()
Determines whether the entity is new.
Usually an entity is new if no ID exists for it yet. However, entities may be enforced to be new with existing IDs too.
string
getEntityTypeId()
Gets the ID of the type of the entity.
string
bundle()
Gets the bundle of the entity.
EntityTypeInterface
getEntityType()
Gets the entity type definition.
EntityInterface
createDuplicate()
Creates a duplicate of the entity.
static EntityInterface|null
load(mixed $id)
Loads an entity.
static EntityInterface[]
loadMultiple(array $ids = NULL)
Loads one or more entities.
static EntityInterface
create(array $values = [])
Constructs a new entity object, without permanently saving it.
delete()
Deletes an entity permanently.
int
save()
Saves an entity permanently.
When saving existing entities, the entity is assumed to be complete, partial updates of entities are not supported.
Url
toUrl(string $rel = 'edit-form', array $options = [])
Gets the URL object for the entity.
The entity must have an id already. Content entities usually get their IDs by saving them.
URI templates might be set in the links array in an annotation, for example:
Link
toLink(string|null $text = NULL, string $rel = 'edit-form', array $options = [])
Generates the HTML for a link to this entity.
string|TranslatableMarkup|null
label()
Gets the label of the entity.
$this
enforceIsNew(bool $value = TRUE)
Enforces an entity to be new.
Allows migrations to create entities with pre-defined IDs by forcing the entity to be new before saving.
array
toArray()
Gets an array of all property values.
LanguageInterface
language()
Gets the language of the entity.
bool|AccessResultInterface
access(string $operation = 'view', AccountInterface $account = NULL, bool $return_as_object = FALSE)
Checks data value access.
$this
enable()
Enables the configuration entity.
$this
disable()
Disables the configuration entity.
bool
status()
Returns whether the configuration entity is enabled.
Status implementations for configuration entities should follow these general rules:
- Status does not affect the loading of entities. I.e. Disabling configuration entities should only have UI/access implications.
- It should only take effect when a 'status' key is explicitly declared in the entity_keys info of a configuration entity's annotation data.
- Each entity implementation (entity/controller) is responsible for checking and managing the status.
int|string|null
getOriginalId()
Gets the original ID.
$this
setOriginalId(int|string|null $id)
Sets the original ID.
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.
postSave(EntityStorageInterface $storage, bool $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.
static
preCreate(EntityStorageInterface $storage, array $values)
Changes the values of an entity before it is created.
Load defaults for example.
postCreate(EntityStorageInterface $storage)
Acts on a created entity before hooks are invoked.
Used after the entity is created, but before saving the entity and before any of the presave hooks are invoked.
See the @link entity_crud Entity CRUD topic @endlink for more information.
static
preDelete(EntityStorageInterface $storage, array $entities)
Acts on entities before they are deleted and before hooks are invoked.
Used before the entities are deleted and before invoking the delete hook.
static
postDelete(EntityStorageInterface $storage, array $entities)
Acts on deleted entities before the delete hook is invoked.
Used after the entities are deleted but before invoking the delete hook.
static
postLoad(EntityStorageInterface $storage, array $entities)
Acts on loaded entities.
ViewExecutable
getExecutable()
Gets an executable instance for this view.
string
duplicateDisplayAsType(string $old_display_id, string $new_display_type)
Duplicates an existing display into a new display type.
For example clone to display a page display as a block display.
mergeDefaultDisplaysOptions()
Add defaults to the display options.
string[]
uriRelationships()
Gets a list of URI relationships supported by this entity.
EntityInterface[]
referencedEntities()
Gets a list of entities referenced by this entity.
bool
hasLinkTemplate(string $key)
Indicates if a link template exists for a given key.
$this
calculateDependencies()
Calculates dependencies and stores them in the dependency property.
string
getConfigDependencyKey()
Gets the key that is used to store configuration dependencies.
string
getConfigDependencyName()
Gets the configuration dependency name.
Configuration entities can depend on content and configuration entities. They store an array of content and config dependency names in their "dependencies" key.
string
getConfigTarget()
Gets the configuration target identifier for the entity.
Used to supply the correct format for storing a reference targeting this entity in configuration.
bool
onDependencyRemoval(array $dependencies)
Informs the entity that entities it depends on will be deleted.
This method allows configuration entities to remove dependencies instead of being deleted themselves. Configuration entities can use this method to avoid being unnecessarily deleted during an extension uninstallation. For example, entity displays remove references to widgets and formatters if the plugin that supplies them depends on a module that is being uninstalled.
If this method returns TRUE then the entity needs to be re-saved by the caller for the changes to take effect. Implementations should not save the entity.
array
getDependencies()
Gets the configuration dependencies.
string[]
getCacheContexts()
The cache contexts associated with this object.
These identify a specific variation/representation of the object.
Cache contexts are tokens: placeholders that are converted to cache keys by the @cache_contexts_manager service. The replacement value depends on the request context (the current URL, language, and so on). They're converted before storing an object in cache.
string[]
getCacheTags()
The cache tags associated with this object.
When this object is modified, these cache tags will be invalidated.
int
getCacheMaxAge()
The maximum age for which this object may be cached.
ComplexDataInterface
getTypedData()
Gets a typed data object for this entity object.
The returned typed data object wraps this entity and allows dealing with entities based on the generic typed data API.
string|bool
addDisplay(string $plugin_id = 'page', string $title = NULL, string $id = NULL)
Adds a new display handler to the view, automatically creating an ID.
bool
isInstallable()
Checks whether this entity is installable.
For example, a default view might not be installable if the base table doesn't exist.
$this
setThirdPartySetting(string $module, string $key, mixed $value)
Sets the value of a third-party setting.
mixed
getThirdPartySetting(string $module, string $key, mixed $default = NULL)
Gets the value of a third-party setting.
array
getThirdPartySettings(string $module)
Gets all third-party settings of a given module.
mixed
unsetThirdPartySetting(string $module, string $key)
Unsets a third-party setting.
array
getThirdPartyProviders()
Gets the list of third parties that store information.
$this
trustData()
Sets that the data should be trusted.
If the data is trusted then dependencies will not be calculated on save and schema will not be used to cast the values. Generally this is only used during module and theme installation. Once the config entity has been saved the data will no longer be marked as trusted. This is an optimization for creation of configuration during installation.
bool
hasTrustedData()
Gets whether on not the data is trusted.
$this
addCacheableDependency(CacheableDependencyInterface|object $other_object)
Adds a dependency on an object: merges its cacheability metadata.
$this
addCacheContexts(array $cache_contexts)
Adds cache contexts.
$this
mergeCacheMaxAge(int $max_age)
Merges the maximum age (in seconds) with the existing maximum age.
The max age will be set to the given value if it is lower than the existing value.
string[]
getCacheTagsToInvalidate()
Returns the cache tags that should be used to invalidate caches.
This will not return additional cache tags added through addCacheTags().
$this
addCacheTags(array $cache_tags)
Adds cache tags.
Lock|null
getLock()
Gets the lock on this View.
$this
setLock(Lock $lock)
Sets a lock on this View.
$this
unsetLock()
Unsets the lock on this View.