Giter Site home page Giter Site logo

Serialization Problems about broadway HOT 5 CLOSED

broadway avatar broadway commented on July 24, 2024
Serialization Problems

from broadway.

Comments (5)

cordoval avatar cordoval commented on July 24, 2024

https://github.com/qandidate-labs/broadway/blob/master/src/Broadway/Serializer/SerializerInterface.php#L15-L16

It seems this was not built to support objects but scalars. Perhaps that can clarify the question.

I am also interested if this was done for elasticsearch, why the interface was forced to that and not support objects underneath the serialization output?

from broadway.

cordoval avatar cordoval commented on July 24, 2024

I think also in https://github.com/qandidate-labs/broadway/blob/master/src/Broadway/Domain/Metadata.php#L50 when it gets serialized and the information accessible as an array then is a bit misleading. Maybe there should be a note somewhere in the docs about acknowledging that the concept of serialization is not to strings but to arrays because of elastic search and for practical reasons which would be good to list. This I say having in view that lots of users come from the background where serialization ends up in a string.

from broadway.

cordoval avatar cordoval commented on July 24, 2024

one more reason to tag the package to include the metadata accessing fix on projector land from @mbadolato ! 👴

from broadway.

wjzijderveld avatar wjzijderveld commented on July 24, 2024

@Richtermeister thanks for the compliment 😄

I wasn't involved from the start, so I don't know about all the design decisions. But I'm guessing serializing to flat array is just convenient. In the end it gets saved as json in the database, which is a lot easier with arrays :-)

How we handle value object, is by calling the serialize method on those objects:

class Foo {
  private $stringProperty;
  private $valueObject;

  public function serialize() {
    return array(
      'stringProperty' => $this->stringProperty,
      'valueObject'    => $this->valueObject->serialize()
    );
  }
}

And with deserializing we reconstuct the value objects. Which usually is just instantiating it, as all properties are part of the constructor in our case.

from broadway.

wjzijderveld avatar wjzijderveld commented on July 24, 2024

@Richtermeister I'm closing this for now, if you have any further questions, please re-open or ask in our IRC channel (#qandidate on Freenode)

from broadway.

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.