133 $block = $model->getBlock();
136 if(count($idComponents) === 0){
137 throw new \InvalidArgumentException(
"No ID components provided");
145 if(count($properties) > 0){
146 $this->serializer->map($block,
function(
Block $block) use ($idComponents, $properties) : Writer{
147 $id = self::serializeFlattenedId($block, $idComponents);
149 $writer =
new Writer($id);
150 foreach($properties as $property){
151 $property->serialize($block, $writer);
157 $this->serializer->map($block,
function(Block $block) use ($idComponents) : BlockStateData{
159 $id = self::serializeFlattenedId($block, $idComponents);
164 $idPermutations = self::compileFlattenedIdPartMatrix($idComponents);
165 foreach($idPermutations as $idParts){
168 $preparedBlock = self::deserializeFlattenedId($block, $idComponents, $idParts);
169 $id = implode(
"", $idParts);
171 if(count($properties) > 0){
172 $this->deserializer->map($id,
function(Reader $reader) use ($preparedBlock, $properties) : Block{
173 $block = clone $preparedBlock;
175 foreach($properties as $property){
176 $property->deserialize($block, $reader);
182 $this->deserializer->map($id, fn() => clone $preparedBlock);
218 $id = $model->getId();
222 $this->deserializer->map($id,
static function(Reader $in) use ($block, $propertyDescriptors) :
Block{
223 $newBlock = clone $block;
224 foreach($propertyDescriptors as $descriptor){
225 $descriptor->deserialize($newBlock, $in);
229 $this->serializer->map($block,
static function(
Block $block) use ($id, $propertyDescriptors) : Writer{
230 $writer =
new Writer($id);
231 foreach($propertyDescriptors as $descriptor){
232 $descriptor->serialize($block, $writer);