Skip to content
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

Introduce Factory for all resources #3613

Merged

Conversation

pjedrzejewski
Copy link
Member

Q A
Bug fix? no
New feature? yes
BC breaks? yes
Deprecations? no
Fixed tickets -
License MIT
Doc PR Sylius/Sylius-Docs#370

This is first step extracted from #2255. The original PR became too big and unmergeable and very hard to maintain for me. It was not the best move from my side to make it that big, but it gave me a good insight into how I want SyliusResourceBundle to look like.

This is the first step, which will effectively allow us to fix #480, #3480 and probably much more bugs. Also, it makes everything much cleaner and we can add more methods to our Factories. For now, I kept only createNew by default (except InventoryUnitFactory, which required changes) because I want to keep this PR as slim as possible.

Main thing here is that we can easily inject stuff into Factories, which was not possible/simple/clean with Repository taking care of object creation. I updated all tests, specs and also tracked down createNew calls in stuff that has no coverage of specs/tests/scenarios.

This is a BC break, pretty big one, but this PR took me maybe 8-12 hours to update whole Sylius, so it should be a pretty straightforward upgrade. :)

Review appreciated!

  • Update changelogs
  • Fix the build
  • Add a PR to documentation

QA:

  • ORM fixtures
  • PHPCR Fixtures
  • sylius:install

@pjedrzejewski pjedrzejewski added BC Break PRs introducing BC breaks (do not even try to merge). New Feature labels Nov 23, 2015
@pjedrzejewski pjedrzejewski added this to the v0.16.0 milestone Nov 23, 2015
@peteward
Copy link

👍 looks sensible to me, although difficult to see the bigger picture

It took you 8 - 12 hours to do find/replace?

@pjedrzejewski
Copy link
Member Author

@peteward I wish it was as simple as find replace. You need to update specs etc. but sometimes it does not mean only replacing Repository with a Factory. Sometimes you need both etc. I think 8-12 hours is too much, was just a shot to give some idea how difficult upgrade is.

@peteward
Copy link

I was joking ;) good work

@pjedrzejewski
Copy link
Member Author

Green! 🎉

@pamil
Copy link
Contributor

pamil commented Nov 24, 2015

Good job 👍 Related PR: #3480 :)

/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
class TranslatableFactory extends Factory implements TranslatableFactoryInterface
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make this a decorator for FactoryInterface? Doing so, we can write specs for setting both current locale and fallback locale.

Copy link
Contributor

Choose a reason for hiding this comment

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

Anyway, if we rewrite this class as decorator, it is possible to make some vendor class translatable even without changing its factory code.

Copy link
Member Author

Choose a reason for hiding this comment

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

I know there was a reason why I have not used a decoration here, can't recall now. Will try to do this and see how it works out, should not be that hard to change.

Copy link
Contributor

Choose a reason for hiding this comment

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

If there is nothing against going for decorator pattern, we should pick this direction, because it definitely makes sense here.

@michalmarcinkowski
Copy link
Contributor

@pjedrzejewski great job! 👍 Small step that starts the big improvement, looking forward to see more!

@pjedrzejewski
Copy link
Member Author

Applied all changes. Good to go! :) Woohoo!

michalmarcinkowski added a commit that referenced this pull request Nov 24, 2015
@michalmarcinkowski michalmarcinkowski merged commit 2dab785 into Sylius:master Nov 24, 2015
@michalmarcinkowski
Copy link
Contributor

@pjedrzejewski one more thing left, global upgrade and changelog update :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BC Break PRs introducing BC breaks (do not even try to merge).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Variant class hardcoded in Product
5 participants