You are here

protected static function Og::getFieldBaseDefinition in Organic groups 8

Get an OG field base definition.

Parameters

string $plugin_id: The plugin ID, which is also the default field name.

Return value

OgFieldBase|bool An array with the field storage config and field config definitions, or FALSE if none found.

Throws

\Exception Thrown when the requested plugin is not valid.

File

src/Og.php, line 363

Class

Og
A static helper class for OG.

Namespace

Drupal\og

Code

protected static function getFieldBaseDefinition($plugin_id) {

  /** @var OgFieldsPluginManager $plugin_manager */
  $plugin_manager = \Drupal::service('plugin.manager.og.fields');
  $field_config = $plugin_manager
    ->getDefinition($plugin_id);
  if (!$field_config) {
    throw new \Exception("The Organic Groups field with plugin ID {$plugin_id} is not a valid plugin.");
  }
  return $plugin_manager
    ->createInstance($plugin_id);
}