You are here

protected function OptionalModuleManager::validateSocialFeatureData in Open Social 8.9

Same name and namespace in other branches
  1. 8.8 src/Installer/OptionalModuleManager.php \Drupal\social\Installer\OptionalModuleManager::validateSocialFeatureData()
  2. 10.3.x src/Installer/OptionalModuleManager.php \Drupal\social\Installer\OptionalModuleManager::validateSocialFeatureData()
  3. 10.0.x src/Installer/OptionalModuleManager.php \Drupal\social\Installer\OptionalModuleManager::validateSocialFeatureData()
  4. 10.1.x src/Installer/OptionalModuleManager.php \Drupal\social\Installer\OptionalModuleManager::validateSocialFeatureData()
  5. 10.2.x src/Installer/OptionalModuleManager.php \Drupal\social\Installer\OptionalModuleManager::validateSocialFeatureData()

Validate the data for an Open Social optional feature.

Parameters

string $module_name: The name of the module that's being validated for error messages.

array $info: The array of info to validate.

Return value

true Returns TRUE when the data is valid.

Throws

\Drupal\social\Exception\SocialFeatureDataException An exception that indicates what's wrong with the data.

2 calls to OptionalModuleManager::validateSocialFeatureData()
OptionalModuleManager::getInstallProfileFeatureDefinitions in src/Installer/OptionalModuleManager.php
Loads feature definitions from a `profile.feature_list.yml` in the profile.
OptionalModuleManager::getOptionalModuleInfo in src/Installer/OptionalModuleManager.php
Load the optional module info for the extension.

File

src/Installer/OptionalModuleManager.php, line 180

Class

OptionalModuleManager
Optional Module Manager.

Namespace

Drupal\social\Installer

Code

protected function validateSocialFeatureData(string $module_name, array $info) : bool {
  if (!isset($info['name'])) {
    throw new SocialFeatureDataException("Missing `name` field in `{$module_name}.social_feature.yml`.");
  }
  if (!isset($info['description'])) {
    throw new SocialFeatureDataException("Missing `description` field in `{$module_name}.social_feature.yml`.");
  }
  if (!is_bool($info['default'])) {
    throw new SocialFeatureDataException("Field `default` must be of type `bool` in `{$module_name}.social_feature.yml`.");
  }
  if (!is_int($info['weight'])) {
    throw new SocialFeatureDataException("Field `weight` must be of type `int` in `{$module_name}.social_feature.yml`.");
  }
  return TRUE;
}