Bugfix #36

Merged
merged 1 commit into from Apr 17, 2012

3 participants

@daniphp

Bugfix: a property set should be dirty if there are clean and new propertiesBugfix: a property set should be dirty if there are clean and new properties

@kkamkou

Hello daniphp, why we can't use this one?

<?php
foreach ($this as $property) {
    $state = $property->getState();
    if (Enum::STATE_CLEAN == $state) {
                $hasCleanProperty = true;
    }

    if (Enum::STATE_NEW == $propertyState) {
        $hasNewProperty = true;
    }

        if ($hasCleanProperty && $hasNewProperty) {
            return Enum::STATE_DIRTY;
        }
}

// or fastest one

$states = array();
foreach ($this as $property) {
    $states[$property->getState()] = true;
}

if (isset($states[Enum::STATE_NEW]) && isset($states[Enum::STATE_CLEAN])) {
    return Enum::STATE_DIRTY;
}

p.s. in any case, thx for the solution.

@daniphp

You still have to conside Enum::STATE_DIRTY, that exists for a property if it's updated.

@a-musing-moose a-musing-moose merged commit cce7a14 into a-musing-moose:master Apr 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment