View source
<?php
use Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface;
use Drupal\eck\Entity\EckEntityBundle;
function eck_update_8001() {
$entity_types = \Drupal::entityTypeManager()
->getStorage('eck_entity_type')
->loadMultiple();
$names = [];
foreach ($entity_types as $entity_type) {
$names[] = "eck.eck_entity_type.{$entity_type->id()}";
}
foreach ($names as $name) {
$config = \Drupal::configFactory()
->getEditable($name);
$data = $config
->getRawData();
foreach ([
'uid',
'title',
'created',
'changed',
] as $field) {
$data[$field] = TRUE;
}
$config
->setData($data);
$config
->save();
}
drupal_flush_all_caches();
EntityDefinitionUpdateManagerInterface::getChangeList();
}
function eck_update_8002() {
$bundles = EckEntityBundle::loadMultiple();
foreach ($bundles as $bundle) {
$bundle
->save();
}
}
function eck_update_8003() {
EntityDefinitionUpdateManagerInterface::getChangeList();
}
function eck_update_8004() {
$schema = Drupal::database()
->schema();
$entityDefinitionUpdateManager = Drupal::service('entity.definition_update_manager');
$entityTypeManager = Drupal::entityTypeManager();
$eckEntityTypes = $entityTypeManager
->getStorage('eck_entity_type')
->loadMultiple();
$idColumnSpec = [
'primary key' => TRUE,
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
];
foreach ($eckEntityTypes as $machineName => $entity_type) {
$entityTypeDefinition = $entityTypeManager
->getDefinition($machineName);
$schema
->changeField($entityTypeDefinition
->getBaseTable(), 'id', 'id', $idColumnSpec);
$schema
->changeField($entityTypeDefinition
->getDataTable(), 'id', 'id', $idColumnSpec);
$entityDefinitionUpdateManager
->installEntityType($entityTypeDefinition);
}
}
function eck_update_8005() {
$config_factory = \Drupal::configFactory();
foreach ($config_factory
->listAll('eck.eck_entity_type.') as $name) {
$config = $config_factory
->getEditable($name);
$config
->set('status', FALSE);
$config
->save();
}
}
function eck_update_8006() {
$definition_update_manager = \Drupal::entityDefinitionUpdateManager();
foreach (\Drupal::entityTypeManager()
->getStorage('eck_entity_type')
->loadMultiple() as $entity_type) {
$entity_type = $definition_update_manager
->getEntityType($entity_type
->id());
$keys = $entity_type
->getKeys();
$keys['published'] = 'status';
$entity_type
->set('entity_keys', $keys);
$definition_update_manager
->updateEntityType($entity_type);
}
}