You are here

public function NodeRevisionDelete::saveContentTypeConfig in Node Revision Delete 8

Save the content type config variable.

Parameters

string $content_type: Content type machine name.

int $minimum_revisions_to_keep: Minimum number of revisions to keep.

int $minimum_age_to_delete: Minimum age in months of revision to delete.

int $when_to_delete: Number of inactivity months to wait for delete a revision.

Overrides NodeRevisionDeleteInterface::saveContentTypeConfig

File

src/NodeRevisionDelete.php, line 179

Class

NodeRevisionDelete
Class NodeRevisionDelete.

Namespace

Drupal\node_revision_delete

Code

public function saveContentTypeConfig($content_type, $minimum_revisions_to_keep, $minimum_age_to_delete, $when_to_delete) {

  // Getting the config file.
  $config = $this->configFactory
    ->getEditable('node.type.' . $content_type);

  // Getting the variables with the content types configuration.
  $third_party_settings = $config
    ->get('third_party_settings');

  // Adding the info into the array.
  $third_party_settings['node_revision_delete'] = [
    'minimum_revisions_to_keep' => $minimum_revisions_to_keep,
    'minimum_age_to_delete' => $minimum_age_to_delete,
    'when_to_delete' => $when_to_delete,
  ];

  // Saving the values in the config.
  $config
    ->set('third_party_settings', $third_party_settings)
    ->save();
}