Git Product home page Git Product logo

Comments (5)

nikophil avatar nikophil commented on July 23, 2024

Hi @Fabrn

I don't fully understand what you're trying to achieve: without Doctrine, the objects which are created in a story are not persisted at all (moreover in a global state). They are not "stored" anywhere, where you could retrieve them.

At first, I thought your issue was the same than #573 but they are adding a afterInstantiate() callback, in order to store their objects somewhere (in memory, in a sql table but without using doctrine, etc...)

I debugged MyFactory::all() and saw that every items had their ID reset, and most importantly, the persisted boolean was set to true

When MyFactory::all() is called, no factory is instantiated, because the underlying call is static::repository()->findAll() so it's kinda normal that persistence is not disabled at this step.

from foundry.

Fabrn avatar Fabrn commented on July 23, 2024

Hello !

Thanks for your quick answer 😄

I don't fully understand what you're trying to achieve: without Doctrine, the objects which are created in a story are not persisted at all (moreover in a global state). They are not "stored" anywhere, where you could retrieve them.

My goal was to store non-persistent Proxies into the Story states in order to retrieve them later in the code.

When MyFactory::all() is called, no factory is instantiated, because the underlying call is static::repository()->findAll() so it's kinda normal that persistence is not disabled at this step.

My bad, didn't check what was happening under the hood there. However, the bit of code that persists the Proxies happens to be called while adding a state to the Story (addState -> normalizeObject -> persists). Shouldn't it be possible to add non-persistent Proxies to the Story states ? I would find it useful to be able to have accessible set of Proxies throught my tests that are not persisted sometimes

from foundry.

nikophil avatar nikophil commented on July 23, 2024

My goal was to store non-persistent Proxies into the Story states in order to retrieve them later in the code.

whoops, you're right stories do keep their own states, the other part of the issue misguided me: I thought you wanted to access from MyFactory::all() to your objects created with "not persisting" stories 😅

So I guess this PR does what you need?

from foundry.

Fabrn avatar Fabrn commented on July 23, 2024

So I guess #580 does what you need?

Well I guess this PR does the job indeed 😄 I wonder if it wouldn't have been cleaner to check if the save method is callable (according to persistence) instead of preventing the action behind the scenes but that's fine I guess !

from foundry.

nikophil avatar nikophil commented on July 23, 2024

Hi! I'm closing this, since this works in Foundry v2 and we won't support this in v1

from foundry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.