Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relationship behaviour on handlePost #50

Open
nohponex opened this issue Oct 9, 2016 · 1 comment
Open

Relationship behaviour on handlePost #50

nohponex opened this issue Oct 9, 2016 · 1 comment

Comments

@nohponex
Copy link
Member

nohponex commented Oct 9, 2016

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
@nohponex nohponex added this to the Release 3.x milestone Oct 9, 2016
@nohponex
Copy link
Member Author

@alkallio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant