Skip to content
This repository was archived by the owner on Mar 27, 2022. It is now read-only.

Add custom doctrine types before mapping them #23

Closed

Conversation

svycka
Copy link
Contributor

@svycka svycka commented Jun 23, 2017

This allows creating connection without entitymanager and still have working types.
Before this fix creating connection throwed exception:

[Zend\ServiceManager\Exception\ServiceNotCreatedException]                                                                       
  Service with name "doctrine.connection.orm_default" could not be created. Reason: Type to be overwritten point does not exist. 

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 45.968% when pulling 9667a46 on svycka:hotfix/add-custom-types-before-registering into be47616 on DASPRiD:master.

@svycka
Copy link
Contributor Author

svycka commented Jun 23, 2017

HHVM failure is not because of this fix

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 46.505% when pulling b3e1c6e on svycka:hotfix/add-custom-types-before-registering into be47616 on DASPRiD:master.

@svycka
Copy link
Contributor Author

svycka commented Jun 23, 2017

@DASPRiD @asgrim is it possible to have this released soon?

Copy link

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - just some nitpicking changes needed :-)

}

$applicationConfig = $container->has('config') ? $container->get('config') : [];
$doctrineConfig = array_key_exists('doctrine', $applicationConfig) ? $applicationConfig['doctrine'] : [];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$doctrineConfig = $applicationConfig['doctrine'] ?? []

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

php5.5 support 😞

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WHAT?!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣

return;
}

$applicationConfig = $container->has('config') ? $container->get('config') : [];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just let it crash if 'config' is not set - this is a very likely failure scenario that, if made silent, can lead to a lot of hair pulling

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't this is desired behavior and tested I guess because this test fails https://github.com/DASPRiD/container-interop-doctrine/blob/master/test/ConnectionFactoryTest.php#L40 but I agree with you @Ocramius this should fail, but I guess this needs to be changed in more places so maybe leave it for next time or remove the test case 😄

Type::addType($name, $className);
}

self::$areTypesRegistered = true;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flag should be moved up, or else the logic may be re-executed if any of the Type::* operation throws an exception

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would override type but not throw exception but ok does not make much difference

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read one more time and now I got what you say 😄 should be ok now

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 46.505% when pulling 5390d85 on svycka:hotfix/add-custom-types-before-registering into be47616 on DASPRiD:master.

@asgrim asgrim self-assigned this Jun 30, 2017
@asgrim asgrim added this to the 1.0.0 milestone Jun 30, 2017
@asgrim
Copy link
Collaborator

asgrim commented Jun 30, 2017

Merging as failure came from HHVM and we don't care about that any more. Gonna remove that in another PR.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 46.505% when pulling a51a8a0 on svycka:hotfix/add-custom-types-before-registering into 6dd456c on DASPRiD:master.

asgrim pushed a commit that referenced this pull request Jun 30, 2017
@asgrim
Copy link
Collaborator

asgrim commented Jun 30, 2017

I rebased this as wasn't keen on the merge commit that the GitHub UI's conflict resolution created. This is now merged in a4833d2.

@asgrim asgrim closed this Jun 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants