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

API Cleanup inconsistent SiteTree::duplicate API #1525

Merged
merged 1 commit into from Jul 13, 2016

Conversation

tractorcow
Copy link
Contributor

@tractorcow tractorcow commented Jun 13, 2016

Merge this before accepting symbiote/silverstripe-advancedworkflow#261

At the moment onBeforeDuplicate is run on both the original and the duplicate.

This corrects the behaviour to run only on the duplicate, and have it pass in the original to the first parameter consistently.

dataobject implements as:

public function duplicate($doWrite = true) {
        $className = $this->class;
        $clone = new $className( $this->toMap(), false, $this->model );
        $clone->ID = 0;

        $clone->invokeWithExtensions('onBeforeDuplicate', $this, $doWrite);
        if($doWrite) {
            $clone->write();
            $this->duplicateManyManyRelations($this, $clone);
        }
        $clone->invokeWithExtensions('onAfterDuplicate', $this, $doWrite);

        return $clone;
    }

@tractorcow
Copy link
Contributor Author

Fixes #1253

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

Successfully merging this pull request may close these issues.

None yet

2 participants