-
-
Notifications
You must be signed in to change notification settings - Fork 329
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
References access #392
Comments
I don't really want to open For more extended and custom usages, you can always create your own loaded inheriting from alice one, Note that in v3 the loader will be stateless so any external reference will need to be injected in the loading method. |
That said I don't know what your use case is, if you feel like I missed something feel free to give me more details :) |
Ok so what I see for now it's: $this->objects = new Collection; in constructor of Nelmio\Alice\Fixtures\Loader and I have only ability to replace all references by /**
* @param string $key
* @param object $object
*/
public function addReference($key, $object)
{
$this->objects->set($key, $object);
} |
But you don't "add", because in that case It's a bit more verbose but you can already do it: $references = $loader->getReferences();
$references->set($key, $object);
$loader->setReferences($references); Granted it's not very nice, but as this won't be in v3 and is potentially confusing (you're not adding but setting), I would prefer not change that. |
This code $loader->setReferences($references); is too expensive, because it will foreach all references again and again. |
But that will end up being a BC break, which is not allowed for v2, and this problem won't happen in v3. So in any case I think the best solution for you is to override Alice loader through inheritance. |
yep, I'll do. And what will happen in v3 that it's resolve my problem with references? |
You will have to inject the references in the load, cf. LoaderInterface and the default loader will not hold the objects. That said it will still be possible to have a loader keeping the references by decorating the native one and implementing the loader interface. If you wish to know more about what will change in v3 check #265. |
It would be nice upgrade! Wish you the best. |
Is there any way to add new reference to alice? Now I have to set array References with setReferences in Loader but can't add just one reference in runtime without reload all of references. Maybe you can open access to
$objects
property in Loader?The text was updated successfully, but these errors were encountered: