UpdateStatusEntities.php in CMS Content Sync 2.1.x
File
modules/cms_content_sync_views/src/Controller/UpdateStatusEntities.php
View source
<?php
namespace Drupal\cms_content_sync_views\Controller;
use Drupal\Core\Controller\ControllerBase;
class UpdateStatusEntities extends ControllerBase {
public static function updateStatusEntities($ids, &$context) {
$status_entity_storage = \Drupal::entityTypeManager()
->getStorage('cms_content_sync_entity_status');
foreach ($ids as $id) {
$status_info_entity = $status_entity_storage
->load($id);
$referenced_entity = \Drupal::service('entity.repository')
->loadEntityByUuid($status_info_entity
->get('entity_type')->value, $status_info_entity
->get('entity_uuid')->value);
$status_info_entity
->set('entity', $referenced_entity);
$status_info_entity
->save();
}
}
public static function updateStatusEntitiesFinished($success, $results, $operations) {
\Drupal::messenger()
->addMessage('Status Entities have been updated.');
}
}