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
Relationship class is defined as
So data can be fetched/manipulated using
$recordDataAttributeor$callbacksobjectCurrently, when a
Resourceis parsed usingparseFromRecord($record)it will:$recordDataAttributeis defined, and that property is defined in given recordOn the other hand when inserting new resources using handlePost
TYPE_TO_ONEattribute will be injected to inserted recordTYPE_TO_MANYit 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 ?
$recordDataAttribute, both forTYPE_TO_ONEandTYPE_TO_MANY, it will inject attribute to inserted record