8000 Resettable feature by pascalwacker · Pull Request #213 · msgphp/msgphp · GitHub
[go: up one dir, main page]

Skip to content

Resettable feature #213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function process(ContainerBuilder $container): void
throw new InvalidArgumentException(sprintf('Provider "%s" must implement "%s".', $providerId, ObjectFieldMappingsProviderInterface::class));
}

foreach ($providerClass::provideObjectFieldMappings() as $class => $mapping) {
foreach ($providerClass::provideObjectFieldMappings($container->getParameter('msgphp.doctrine.key_max_length')) as $class => $mapping) {
if (isset($mappings[$class])) {
continue;
}
Expand Down
1 change: 1 addition & 0 deletions src/Domain/Infra/DependencyInjection/ExtensionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public static function configureDoctrineOrm(ContainerBuilder $container, array $

$container->setParameter($param = 'msgphp.doctrine.type_config', $container->hasParameter($param) ? $typeConfig + $container->getParameter($param) : $typeConfig);
$container->setParameter($param = 'msgphp.doctrine.mapping_files', $container->hasParameter($param) ? array_merge($container->getParameter($param), $mappingFiles) : $mappingFiles);
$container->setParameter($param = 'msgphp.doctrine.key_max_length', $container->hasParameter($param) ? intval($container->getParameter($param)) : 255);

$container->prependExtensionConfig('doctrine', [
'dbal' => [
Expand Down
3 changes: 2 additions & 1 deletion src/Domain/Infra/Doctrine/ObjectFieldMappings.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
*/
final class ObjectFieldMappings implements ObjectFieldMappingsProviderInterface
{
public static function provideObjectFieldMappings(): iterable
public static function provideObjectFieldMappings(int $keyMaxLength = 255): iterable
{
yield Features\CanBeConfirmed::class => [
'confirmationToken' => [
'type' => 'string',
'unique' => true,
'nullable' => true,
'length' => $keyMaxLength,
],
'confirmedAt' => [
'type' => 'datetime',
Expand Down
10000
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ interface ObjectFieldMappingsProviderInterface
public const TYPE_ONE_TO_MANY = 'oneToMany';
public const TYPE_ONE_TO_ONE = 'oneToOne';

public static function provideObjectFieldMappings(): iterable;
public static function provideObjectFieldMappings(int $keyMaxLength = 255): iterable;
}
2 changes: 1 addition & 1 deletion src/Eav/Infra/Doctrine/ObjectFieldMappings.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
final class ObjectFieldMappings implements ObjectFieldMappingsProviderInterface
{
public static function provideObjectFieldMappings(): iterable
public static function provideObjectFieldMappings(int $keyMaxLength = 255): iterable
{
yield Features\EntityAttributeValue::class => [
'attributeValue' => [
Expand Down
10 changes: 9 additions & 1 deletion src/User/Infra/Doctrine/ObjectFieldMappings.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ final class ObjectFieldMappings implements ObjectFieldMappingsProviderInterface
Features\TokenCredential::class => Credential\Token::class,
];

public static function provideObjectFieldMappings(): iterable
private $keyMaxLength;

public function __construct(int $keyMaxLength = 255)
{
$this->keyMaxLength = $keyMaxLength;
}

public static function provideObjectFieldMappings(int $keyMaxLength = 255): iterable
{
foreach (self::CREDENTIALS as $object => $credential) {
yield $object => [
Expand All @@ -41,6 +48,7 @@ public static function provideObjectFieldMappings(): iterable
'type' => 'string',
'unique' => true,
'nullable' => true,
'length' => $keyMaxLength,
],
'passwordRequestedAt' => [
'type' => 'datetime',
Expand Down
0