Skip to content

Relationship behaviour on handlePost #50

@nohponex

Description

@nohponex

Relationship class is defined as

<?php
public function __construct(
        ResourceModel $model,
        int $type = Relationship::TYPE_TO_ONE,
        string $recordDataAttribute = null,
        \stdClass $callbacks = null,
        int $flags = Relationship::FLAG_DEFAULT
    )

So data can be fetched/manipulated using $recordDataAttribute or $callbacks object

Currently, when a Resource is parsed using parseFromRecord($record) it will:

  • check if $recordDataAttribute is defined, and that property is defined in given record
  • if no then it will check if $callbacks defines a GET callback to retrieve the data

On the other hand when inserting new resources using handlePost

  • If it's TYPE_TO_ONE attribute will be injected to inserted record
  • If it's TYPE_TO_MANY it will use POST callback to insert the data after the record is created (it will also throw an exception if POST is not defined)

Should we have similar behaviour for post ?

  • If $recordDataAttribute, both for TYPE_TO_ONE and TYPE_TO_MANY, it will inject attribute to inserted record
  • If not will will require POST callback to be defined

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions