You are here

public static function LockFieldsFormManager::submitLockFieldsList in TMGMT Translator Smartling 8.4

Saves locked fields list using States API

We don't use TMGMT Job Item for storing data because there are will be situations when one entity sits in many TMGMT Job Items and it will not be clear which item to choose for getting/setting locked fields list.

This callback is intentionally static and passed to form as

$form['actions']['submit']['#submit'][] = [
  LockFieldsFormManager::class,
  'submitLockFieldsList',
];

to avoid the serialization issue because $this contains implicit relation to \Drupal\Core\Database\Connection object which is not serializable and throws an exception from __sleep method.

Parameters

array $form:

FormStateInterface $form_state:

File

src/Smartling/LockFields/LockFieldsFormManager.php, line 106

Class

LockFieldsFormManager
Class LockFieldsFormManager

Namespace

Drupal\tmgmt_smartling\Smartling\LockFields

Code

public static function submitLockFieldsList(array &$form, FormStateInterface $form_state) {
  \Drupal::getContainer()
    ->get('tmgmt_smartling.lock_fields_manager')
    ->setLockedFields($form_state
    ->getFormObject()
    ->getEntity(), $form_state
    ->getValue('locked_fields'));
}