| @@ 23-61 (lines=39) @@ | ||
| 20 | /** |
|
| 21 | * Class UserToPolicyCoupler. |
|
| 22 | */ |
|
| 23 | class UserGroupToPolicyCoupler extends AbstractDataCoupler |
|
| 24 | { |
|
| 25 | /** @var string */ |
|
| 26 | protected $connectorIdKey = 'id_user_group_to_am_policy'; |
|
| 27 | /** @var string */ |
|
| 28 | protected $connectorDataGroup = 'webhemi_user_group_to_am_policy'; |
|
| 29 | /** @var array */ |
|
| 30 | protected $dependentDataGroups = [ |
|
| 31 | UserGroupEntity::class => [ |
|
| 32 | 'source_key' => 'fk_user_group', |
|
| 33 | 'connector_key' => 'fk_am_policy', |
|
| 34 | 'depending_group' => 'webhemi_am_policy', |
|
| 35 | 'depending_id_key' => 'id_am_policy', |
|
| 36 | ], |
|
| 37 | PolicyEntity::class => [ |
|
| 38 | 'source_key' => 'fk_am_policy', |
|
| 39 | 'connector_key' => 'fk_user_group', |
|
| 40 | 'depending_group' => 'webhemi_user_group', |
|
| 41 | 'depending_id_key' => 'id_user_group', |
|
| 42 | ] |
|
| 43 | ]; |
|
| 44 | ||
| 45 | use UserGroupEntityTrait; |
|
| 46 | use PolicyEntityTrait; |
|
| 47 | ||
| 48 | /** |
|
| 49 | * Gets a DataEntityInterface instance from the provided data according to the reference entity. |
|
| 50 | * |
|
| 51 | * @param DataEntityInterface $referenceEntity |
|
| 52 | * @param array $entityData |
|
| 53 | * @return DataEntityInterface |
|
| 54 | */ |
|
| 55 | protected function getDependingEntity(DataEntityInterface $referenceEntity, array $entityData) |
|
| 56 | { |
|
| 57 | return $referenceEntity instanceof UserGroupEntity |
|
| 58 | ? $this->createPolicyEntity($entityData) |
|
| 59 | : $this->createUserGroupEntity($entityData); |
|
| 60 | } |
|
| 61 | } |
|
| 62 | ||
| @@ 23-61 (lines=39) @@ | ||
| 20 | /** |
|
| 21 | * Class UserToPolicyCoupler. |
|
| 22 | */ |
|
| 23 | class UserToGroupCoupler extends AbstractDataCoupler |
|
| 24 | { |
|
| 25 | /** @var string */ |
|
| 26 | protected $connectorIdKey = 'id_user_to_user_group'; |
|
| 27 | /** @var string */ |
|
| 28 | protected $connectorDataGroup = 'webhemi_user_to_user_group'; |
|
| 29 | /** @var array */ |
|
| 30 | protected $dependentDataGroups = [ |
|
| 31 | UserEntity::class => [ |
|
| 32 | 'source_key' => 'fk_user', |
|
| 33 | 'connector_key' => 'fk_user_group', |
|
| 34 | 'depending_group' => 'webhemi_user_group', |
|
| 35 | 'depending_id_key' => 'id_user_group', |
|
| 36 | ], |
|
| 37 | UserGroupEntity::class => [ |
|
| 38 | 'source_key' => 'fk_user_group', |
|
| 39 | 'connector_key' => 'fk_user', |
|
| 40 | 'depending_group' => 'webhemi_user', |
|
| 41 | 'depending_id_key' => 'id_user', |
|
| 42 | ] |
|
| 43 | ]; |
|
| 44 | ||
| 45 | use UserEntityTrait; |
|
| 46 | use UserGroupEntityTrait; |
|
| 47 | ||
| 48 | /** |
|
| 49 | * Gets a DataEntityInterface instance from the provided data according to the reference entity. |
|
| 50 | * |
|
| 51 | * @param DataEntityInterface $referenceEntity |
|
| 52 | * @param array $entityData |
|
| 53 | * @return DataEntityInterface |
|
| 54 | */ |
|
| 55 | protected function getDependingEntity(DataEntityInterface $referenceEntity, array $entityData) |
|
| 56 | { |
|
| 57 | return $referenceEntity instanceof UserEntity |
|
| 58 | ? $this->createUserGroupEntity($entityData) |
|
| 59 | : $this->createUserEntity($entityData); |
|
| 60 | } |
|
| 61 | } |
|
| 62 | ||
| @@ 23-61 (lines=39) @@ | ||
| 20 | /** |
|
| 21 | * Class UserToPolicyCoupler. |
|
| 22 | */ |
|
| 23 | class UserToPolicyCoupler extends AbstractDataCoupler |
|
| 24 | { |
|
| 25 | /** @var string */ |
|
| 26 | protected $connectorIdKey = 'id_user_to_am_policy'; |
|
| 27 | /** @var string */ |
|
| 28 | protected $connectorDataGroup = 'webhemi_user_to_am_policy'; |
|
| 29 | /** @var array */ |
|
| 30 | protected $dependentDataGroups = [ |
|
| 31 | UserEntity::class => [ |
|
| 32 | 'source_key' => 'fk_user', |
|
| 33 | 'connector_key' => 'fk_am_policy', |
|
| 34 | 'depending_group' => 'webhemi_am_policy', |
|
| 35 | 'depending_id_key' => 'id_am_policy', |
|
| 36 | ], |
|
| 37 | PolicyEntity::class => [ |
|
| 38 | 'source_key' => 'fk_am_policy', |
|
| 39 | 'connector_key' => 'fk_user', |
|
| 40 | 'depending_group' => 'webhemi_user', |
|
| 41 | 'depending_id_key' => 'id_user', |
|
| 42 | ] |
|
| 43 | ]; |
|
| 44 | ||
| 45 | use UserEntityTrait; |
|
| 46 | use PolicyEntityTrait; |
|
| 47 | ||
| 48 | /** |
|
| 49 | * Gets a DataEntityInterface instance from the provided data according to the reference entity. |
|
| 50 | * |
|
| 51 | * @param DataEntityInterface $referenceEntity |
|
| 52 | * @param array $entityData |
|
| 53 | * @return DataEntityInterface |
|
| 54 | */ |
|
| 55 | protected function getDependingEntity(DataEntityInterface $referenceEntity, array $entityData) |
|
| 56 | { |
|
| 57 | return $referenceEntity instanceof UserEntity |
|
| 58 | ? $this->createPolicyEntity($entityData) |
|
| 59 | : $this->createUserEntity($entityData); |
|
| 60 | } |
|
| 61 | } |
|
| 62 | ||