You are here

final class UserDeveloperConverter in Apigee Edge 8

Same name in this branch
  1. 8 src/UserDeveloperConverter.php \Drupal\apigee_edge\UserDeveloperConverter
  2. 8 tests/modules/apigee_edge_test/src/UserDeveloperConverter.php \Drupal\apigee_edge_test\UserDeveloperConverter

Service decorator for user-developer converter.

Hierarchy

Expanded class hierarchy of UserDeveloperConverter

1 string reference to 'UserDeveloperConverter'
apigee_edge_test.services.yml in tests/modules/apigee_edge_test/apigee_edge_test.services.yml
tests/modules/apigee_edge_test/apigee_edge_test.services.yml
1 service uses UserDeveloperConverter
apigee_edge_test.converter.user_developer in tests/modules/apigee_edge_test/apigee_edge_test.services.yml
Drupal\apigee_edge_test\UserDeveloperConverter

File

tests/modules/apigee_edge_test/src/UserDeveloperConverter.php, line 35

Namespace

Drupal\apigee_edge_test
View source
final class UserDeveloperConverter extends DecoratedUserDeveloperConverter {
  public const DRUPAL_ROLE_ATTRIBUTE_NAME = 'DP_USER_ROLES';

  /**
   * The decorated user-developer converter service.
   *
   * @var \Drupal\apigee_edge\UserDeveloperConverterInterface
   */
  private $innerService;

  /**
   * UserToDeveloper constructor.
   *
   * @param \Drupal\apigee_edge\UserDeveloperConverterInterface $inner_service
   *   The decorated user-developer converter service.
   * @param \Drupal\Core\Config\ConfigFactory $config_factory
   *   Config factory service.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   Entity type manager service.
   * @param \Drupal\apigee_edge\Plugin\FieldStorageFormatManagerInterface $field_storage_manager
   *   Field storage manager service.
   * @param \Drupal\apigee_edge\FieldAttributeConverterInterface $field_attribute_converter
   *   Field name to attribute name converter service.
   */
  public function __construct(UserDeveloperConverterInterface $inner_service, ConfigFactory $config_factory, EntityTypeManagerInterface $entity_type_manager, FieldStorageFormatManagerInterface $field_storage_manager, FieldAttributeConverterInterface $field_attribute_converter) {
    $this->configFactory = $config_factory;
    $this->fieldStorageFormatManager = $field_storage_manager;
    $this->entityTypeManager = $entity_type_manager;
    $this->fieldAttributeConverter = $field_attribute_converter;
    $this->innerService = $inner_service;
    parent::__construct($config_factory, $entity_type_manager, $field_storage_manager, $field_attribute_converter);
  }

  /**
   * Push but do not sync Drupal user roles to Apigee Edge.
   *
   * {@inheritdoc}
   */
  public function convertUser(UserInterface $user) : UserToDeveloperConversionResult {
    $original_result = parent::convertUser($user);
    $original_result
      ->getDeveloper()
      ->setAttribute(static::DRUPAL_ROLE_ATTRIBUTE_NAME, implode(',', $user
      ->getRoles()));
    return new UserToDeveloperConversionResult($original_result
      ->getDeveloper(), $original_result
      ->getSuccessfullyAppliedChanges() + 1, $original_result
      ->getProblems());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
UserDeveloperConverter::$configFactory protected property Config factory service.
UserDeveloperConverter::$entityTypeManager protected property Entity type manager service.
UserDeveloperConverter::$fieldAttributeConverter protected property Field-attribute converter service.
UserDeveloperConverter::$fieldStorageFormatManager protected property Field storage formatter service.
UserDeveloperConverter::$innerService private property The decorated user-developer converter service.
UserDeveloperConverter::convertDeveloper public function Converts a developer entity to a Drupal user entity. Overrides UserDeveloperConverterInterface::convertDeveloper
UserDeveloperConverter::convertUser public function Push but do not sync Drupal user roles to Apigee Edge. Overrides UserDeveloperConverter::convertUser
UserDeveloperConverter::DRUPAL_ROLE_ATTRIBUTE_NAME public constant
UserDeveloperConverter::__construct public function UserToDeveloper constructor. Overrides UserDeveloperConverter::__construct
UserDeveloperConverterInterface::DEVELOPER_PROP_USER_BASE_FIELD_MAP public constant Developer-user base field mapping.