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

Add a way to load fixtures from a specific bundle #130

Merged
merged 5 commits into from
Apr 6, 2012
Merged

Add a way to load fixtures from a specific bundle #130

merged 5 commits into from
Apr 6, 2012

Conversation

Palleas
Copy link

@Palleas Palleas commented Apr 4, 2012

Today I wanted to load a set of fixtures from a specific bundle. With this PR you'll be able to do :

$ app/console propel:fixtures:load @MySuperBundle

What do you think?

@havvg
Copy link
Member

havvg commented Apr 4, 2012

I like the idea, but don't like the implementation, could you re-factor it into using the FileLocator?

@willdurand
Copy link

👍

@hhamon
Copy link
Member

hhamon commented Apr 5, 2012

I don't like the @ before the name of the template. Can we just tell the bundle name instead?

@willdurand
Copy link

@hhamon isn't a kind of convention used in other bundles?

@havvg
Copy link
Member

havvg commented Apr 5, 2012

Is the actual path fixed, or do we want to specify a complete path to the fixtures directory.
Something like $ app/console propel:fixtures:load @AcmeBlogBundle/Resources/fixtures/demo? This would also allow to alter the fixtures of a bundle using bundle inheritance. The default fixtures directory will be unchanged, meaning app/propel/fixtures.

@hhamon
Copy link
Member

hhamon commented Apr 5, 2012

I have never seen the @ notation from a CLI command in Symfony...

@havvg
Copy link
Member

havvg commented Apr 5, 2012

BehatBundle for example does it, to run features from a specific bundle.

@Palleas
Copy link
Author

Palleas commented Apr 5, 2012

Yep, the cool thing with Behat commands is running very specifics scenarios with @Bundle/featurefile:line (for example) but I'm not sure we need that.
I'm ok to use the file locator (even if I'm not sure why, because I'm only retrieving a path so it works just like if we'd used the -d option), but @havvg can you tell me more about what you don't like in this implementation?
I wanted to keep it very simple and directly look for Resources/fixtures folder, "convention over configuration" or something like that ;-)

@willdurand
Copy link

Yeah, I like the @ notation, just update your PR using the FileLocator as @havvg said, and it will be ok.

@Palleas
Copy link
Author

Palleas commented Apr 5, 2012

I'm sorry but I'm not sure I see what you mean when you want me to use the FileLocator, as all I'm doing is retrieving a path. You want to get rid of the absoluteFixturesPath property ?

@havvg
Copy link
Member

havvg commented Apr 5, 2012

There is a 'file_locator' service, which should be used to retrieve files/directories with a notation like you suggested, but the complete path. For example $this->container->get('file_locator')->locate('@AcmeBlogBundle/Resources/fixtures/demo/posts.yml'); which will yield the filename with bundle inheritance and other changes/customizations in mind. See https://github.com/propelorm/PropelBundle/blob/master/Command/AbstractPropelCommand.php#L234 for an example.

@hhamon
Copy link
Member

hhamon commented Apr 5, 2012

For your information, the doctrine:generate:entities command does not take the @ notation for specifying a bundle name.

@Palleas
Copy link
Author

Palleas commented Apr 6, 2012

I can remove it, I only had Behat in mind when I wrote this so...
I'll update this PR this afternoon, it's almost done :)

@Palleas
Copy link
Author

Palleas commented Apr 6, 2012

Updated :)

$files = $finder->in(null !== $in ? $in : $this->absoluteFixturesPath);

if (null === $this->bundle) {

Choose a reason for hiding this comment

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

You should remove this blank line

Copy link
Author

Choose a reason for hiding this comment

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

I thought it was in the Symfony2's CS?

Choose a reason for hiding this comment

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

yes it is, but just if you have code before I think..

Choose a reason for hiding this comment

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

See the first code example: http://symfony.com/doc/current/contributing/code/standards.html the first return in the transform method doesn't have a blank line before.

Copy link
Author

Choose a reason for hiding this comment

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

Indeed, fixed!

willdurand added a commit that referenced this pull request Apr 6, 2012
Add a way to load fixtures from a specific bundle
@willdurand willdurand merged commit cfb7873 into propelorm:master Apr 6, 2012
@willdurand
Copy link

Thanks!

@Palleas
Copy link
Author

Palleas commented Apr 6, 2012

Hiii, my first contribution to Propel \o/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants