You are here

public function Crop::provider in Crop API 8

Same name and namespace in other branches
  1. 8.2 src/Entity/Crop.php \Drupal\crop\Entity\Crop::provider()

Gets entity provider for the crop.

Return value

\Drupal\crop\EntityProviderInterface Entity provider.

Throws

\Drupal\crop\EntityProviderNotFoundException Thrown if entity provider not found.

Overrides CropInterface::provider

File

src/Entity/Crop.php, line 111

Class

Crop
Defines the crop entity class.

Namespace

Drupal\crop\Entity

Code

public function provider() {

  /** @var \Drupal\crop\EntityProviderManager $plugin_manager */
  $plugin_manager = \Drupal::service('plugin.manager.crop.entity_provider');
  if (!$plugin_manager
    ->hasDefinition($this->entity_type->value)) {
    throw new EntityProviderNotFoundException(t('Entity provider @id not found.', [
      '@id' => $this->entity_type->value,
    ]));
  }
  return $plugin_manager
    ->createInstance($this->entity_type->value);
}