You are here

class JsonFileStorage in Tome 8

Defines the JSON file storage.

@internal

Hierarchy

Expanded class hierarchy of JsonFileStorage

1 string reference to 'JsonFileStorage'
tome_sync.services.yml in modules/tome_sync/tome_sync.services.yml
modules/tome_sync/tome_sync.services.yml
1 service uses JsonFileStorage
tome_sync.storage.content in modules/tome_sync/tome_sync.services.yml
Drupal\tome_sync\JsonFileStorage

File

modules/tome_sync/src/JsonFileStorage.php, line 12

Namespace

Drupal\tome_sync
View source
class JsonFileStorage extends FileStorage {

  /**
   * {@inheritdoc}
   */
  public static function getFileExtension() {
    return 'json';
  }

  /**
   * {@inheritdoc}
   */
  public function encode($data) {
    return \Drupal::service('serializer')
      ->encode($data, 'json', [
      'json_encode_options' => JSON_PRETTY_PRINT,
    ]);
  }

  /**
   * {@inheritdoc}
   */
  public function decode($data) {
    return \Drupal::service('serializer')
      ->decode($data, 'json');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FileStorage::$collection protected property The storage collection.
FileStorage::$directory protected property The filesystem path for configuration objects. 1
FileStorage::$fileCache protected property The file cache object.
FileStorage::createCollection public function Creates a collection on the storage. Overrides StorageInterface::createCollection 1
FileStorage::delete public function Deletes a configuration object from the storage. Overrides StorageInterface::delete 2
FileStorage::deleteAll public function Deletes configuration objects whose names start with a given prefix. Overrides StorageInterface::deleteAll 1
FileStorage::ensureStorage protected function Check if the directory exists and create it if not.
FileStorage::exists public function Returns whether a configuration object exists. Overrides StorageInterface::exists 2
FileStorage::getAllCollectionNames public function Gets the existing collections. Overrides StorageInterface::getAllCollectionNames
FileStorage::getAllCollectionNamesHelper protected function Helper function for getAllCollectionNames().
FileStorage::getCollectionDirectory protected function Gets the directory for the collection.
FileStorage::getCollectionName public function Gets the name of the current collection the storage is using. Overrides StorageInterface::getCollectionName
FileStorage::getFilePath public function Returns the path to the configuration file. 1
FileStorage::getFileSystem private function Returns file system service.
FileStorage::listAll public function Gets configuration object names starting with a given prefix. Overrides StorageInterface::listAll 1
FileStorage::read public function Implements Drupal\Core\Config\StorageInterface::read(). Overrides StorageInterface::read
FileStorage::readMultiple public function Reads configuration data from the storage. Overrides StorageInterface::readMultiple
FileStorage::rename public function Renames a configuration object in the storage. Overrides StorageInterface::rename 1
FileStorage::write public function Writes configuration data to the storage. Overrides StorageInterface::write 1
FileStorage::__construct public function Constructs a new FileStorage. 2
JsonFileStorage::decode public function Decodes configuration data from the storage-specific format. Overrides FileStorage::decode
JsonFileStorage::encode public function Encodes configuration data into the storage-specific format. Overrides FileStorage::encode
JsonFileStorage::getFileExtension public static function Returns the file extension used by the file storage for all configuration files. Overrides FileStorage::getFileExtension
StorageInterface::DEFAULT_COLLECTION constant The default collection name.