You are here

final class DeveloperWithUser in Apigee Edge 8

Resolves "developer_with_user" type parameters in routes.

Use this parameter converter instead of paramconverter.entity if you would like to ensure that a developer (by UUID or email address) from Apigee Edge has a user in Drupal.

Hierarchy

Expanded class hierarchy of DeveloperWithUser

1 string reference to 'DeveloperWithUser'
apigee_edge.services.yml in ./apigee_edge.services.yml
apigee_edge.services.yml
1 service uses DeveloperWithUser
paramconverter.developer_with_user in ./apigee_edge.services.yml
Drupal\apigee_edge\ParamConverter\DeveloperWithUser

File

src/ParamConverter/DeveloperWithUser.php, line 34

Namespace

Drupal\apigee_edge\ParamConverter
View source
final class DeveloperWithUser implements ParamConverterInterface {

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  private $entityTypeManager;

  /**
   * DeveloperWithUser constructor.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * {@inheritdoc}
   */
  public function convert($value, $definition, $name, array $defaults) {

    /** @var \Drupal\apigee_edge\Entity\DeveloperInterface|null $developer */
    $developer = $this->entityTypeManager
      ->getStorage('developer')
      ->load($value);
    if ($developer) {
      return $developer
        ->getOwner() ? $developer : NULL;
    }
    return NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function applies($definition, $name, Route $route) {
    return !empty($definition['type']) && $definition['type'] == 'developer_with_user';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeveloperWithUser::$entityTypeManager private property The entity type manager.
DeveloperWithUser::applies public function Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface::applies
DeveloperWithUser::convert public function Converts path variables to their corresponding objects. Overrides ParamConverterInterface::convert
DeveloperWithUser::__construct public function DeveloperWithUser constructor.