drupal/core/modules/entity/entity.install

87 lines
2.1 KiB
Plaintext

<?php
/**
* @file
* Install, update and uninstall functions for the entity module.
*/
/**
* Returns the raw configuration object for an EntityDisplay entity.
*
* The function returns the existing configuration entry if it exists, or
* creates a fresh structure.
*
* @param string $entity_type
* The entity type.
* @param string $bundle
* The bundle name.
* @param string $view_mode
* The view mode.
*
* @return \Drupal\Core\Config\Config
* The configuration object.
*/
function _update_8000_entity_get_display($entity_type, $bundle, $view_mode) {
$id = $entity_type . '.' . $bundle . '.' . $view_mode;
$config = \Drupal::config("entity.display.$id");
if ($config->get()) {
return $config;
}
// Initialize a fresh structure.
$uuid = \Drupal::service('uuid');
$properties = array(
'id' => $id,
'uuid' => $uuid->generate(),
'targetEntityType' => $entity_type,
'bundle' => $bundle,
'mode' => $view_mode,
'content' => array(),
'status' => TRUE,
);
foreach ($properties as $key => $value) {
$config->set($key, $value);
}
return $config;
}
/**
* Returns the raw configuration object for an EntityFormDisplay entity.
*
* The function returns the existing configuration entry if it exists, or
* creates a fresh structure.
*
* @param string $entity_type
* The entity type.
* @param string $bundle
* The bundle name.
* @param string $form_mode
* The form mode.
*
* @return \Drupal\Core\Config\Config
* The configuration object.
*/
function _update_8000_entity_get_form_display($entity_type, $bundle, $form_mode) {
$id = $entity_type . '.' . $bundle . '.' . $form_mode;
$config = \Drupal::config("entity.form_display.$id");
if ($config->get()) {
return $config;
}
// Initialize a fresh structure.
$uuid = \Drupal::service('uuid');
$properties = array(
'id' => $id,
'uuid' => $uuid->generate(),
'targetEntityType' => $entity_type,
'bundle' => $bundle,
'mode' => $form_mode,
'content' => array(),
'status' => TRUE,
);
foreach ($properties as $key => $value) {
$config->set($key, $value);
}
return $config;
}