Comments (4)
I think i found what you were trying to do:
Did you try to add a Provider from Faker directly? Like:
services:
your.faker.provider:
class: Faker\Provider\DateTime
tags:
- { name: h4cc_alice_fixtures.provider }
These providers do not need to be added manually to faker, they are always available anyway: https://github.com/fzaninotto/Faker/blob/master/src/Faker/Factory.php#L9-20
And if your own provider would need a special dependency, it has to configured like so:
services:
provider.dependency:
class: ProviderDependency
provider:
class: Provider
arguments: [@provider.dependency]
tags:
- { name: h4cc_alice_fixtures.provider }
from alicefixturesbundle.
That's not what I tried to do.
I simply create a new Provider:
<?php
namespace AppBundle\DataFixtures\Provider;
use Faker\Provider\Base;
/**
* Class MathProvider
*/
class Math extends Base
{
/**
* Evaluates a math operation
*
* @param string $string
*
* @return mixed
*/
public function math($string)
{
return "whatever"
}
}
and register it as a service following the README file (not working for me):
parameters:
math.provider.class: AppBundle\DataFixtures\Provider\Math
services:
math.provider:
class: %math.provider.class%
tags:
- { name: h4cc_alice_fixtures.provider }
But this way, of course, it is working:
parameters:
math.provider.class: AppBundle\DataFixtures\Provider\Math
faker.generator.class: Faker\Factory
services:
faker.generator:
class: %faker.generator.class%
factory: [%faker.generator.class%, create]
math.provider:
class: %math.provider.class%
arguments: [@faker.generator]
tags:
- { name: h4cc_alice_fixtures.provider }
Because every Faker provider needs the @faker.generator
service as argument.
My question is:
Should not this bundle take care of registering the needed Faker services taking into account that Faker is a dependency of Nelmio/Alice or I have to register as a service the dependencies of my dependencies
If the second one, maybe the documentation should mention that in order to create a Faker provider we need to register the Faker services before but IMO I think the bundle must take care of registering its dependencies services.
Thank you
from alicefixturesbundle.
Because every Faker provider needs the @faker.generator service as argument.
This is not correct. Any class can be faker provider, it does not need to extend Faker\Provider\Base
.
So its not the responsibility of this bundle to provide services regarding Faker.
But in the end it would be helpful and convenient to provide such a service like Faker\Generator
, if it would not depend from the given locale Faker\Factory::create($locale = self::DEFAULT_LOCALE)
. Currently, all the Faker Generators are managed inside Alice, as can be seen here: https://github.com/nelmio/alice/blob/1.x/src/Nelmio/Alice/Loader/Base.php#L461
There is no way to access these Generators from the outside.
from alicefixturesbundle.
I created a issue at nelmio/alice for a access to these generators: nelmio/alice#186
from alicefixturesbundle.
Related Issues (20)
- Error in the new version HOT 2
- How to use AliceFixturesBundle within DoctrineFixturesBundle? HOT 3
- Reference mask "Pais*" did not match any existing reference, sets order load how to? HOT 8
- Add Ordering for Fixture Sets
- Loading fixtures by string instead of files. HOT 1
- Working with Doctrine Proxy Objects or References HOT 2
- Loading fixtures which rely on associationKey with generation fails HOT 5
- Troubleshooting entities which are not created HOT 2
- Multiple paths for YAML files and FixtureSets
- Handle doctrine resolved interfaces HOT 2
- Using custom faker data providers without standard doctrine fixtures HOT 2
- Dependencies issue HOT 1
- Make this bundle work with alice v2.0 HOT 1
- h4cc_alice_fixtures:load:files trunkates migration_versions table HOT 4
- Function remove on fixture manager does not delete all the fixtures in a db
- Doctrine 2.5 Embeddables
- FixtureSets contain no reference to the used manager
- Can't reference entities' ID inside a Fixtures Set HOT 1
- On errors give the fixture yaml filename
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alicefixturesbundle.