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

Expose preexistent logic in public function getVersionId #31

Merged
merged 2 commits into from
May 15, 2017

Conversation

bouland
Copy link

@bouland bouland commented May 5, 2017

Need external access to this part inside beforeSave.

class ConcurrentListener implements EventListenerInterface
{
    public function implementedEvents()
    {
        return [
            'Model.beforeSave' => 'onModelBeforeChange',
            'Model.beforeDelete' => 'onModelBeforeChange',
        ];
    }

    public function onModelBeforeChange(Event $event, Entity $entity)
    {
        $table = $event->getSubject();
        if ($table->behaviors()->has('Version')) {
            $version_id = $table->getVersionId($entity);
            if ($version_id !== $entity->version_id) {
                $event->stopPropagation();
                $entity->setError('version_id', 'This entity has changed since you get it.');
                return false;
            }
        }
    }
}

@coveralls
Copy link

Coverage Status

Coverage remained the same at 91.908% when pulling 5542910 on bouland:master into 4f0c098 on josegonzalez:master.

@josegonzalez
Copy link
Owner

Can you add a test for this new method?

@bouland
Copy link
Author

bouland commented May 9, 2017

Done, but coverage would not change since I only have moved code.

@bouland
Copy link
Author

bouland commented May 15, 2017

Did you see that checkstyle rules failed on vendor which are not ignored.
Maybe Travis config need update ?

@josegonzalez josegonzalez merged commit 2bfee28 into josegonzalez:master May 15, 2017
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.

3 participants