lib/Accessible/AutomatedBehaviorTrait.php
protected function updatePropertyAssociation($property, array $values)
    {
        $this->getPropertiesInfo();

        $oldValue = empty($values['oldValue']) ? null : $values['oldValue'];
        $newValue = empty($values['newValue']) ? null : $values['newValue'];

        $association = $this->_associationsList[$property];
        if (!empty($association)) {
            $associatedProperty = $association['property'];
            switch ($association['association']) {
                case 'inverted':
                    $invertedGetMethod = 'get' . ucfirst($associatedProperty);
                    $invertedSetMethod = 'set' . ucfirst($associatedProperty);
                    if ($oldValue !== null && $oldValue->$invertedGetMethod() === $this) {
                        $oldValue->$invertedSetMethod(null);
                    }
                    if ($newValue !== null && $newValue->$invertedGetMethod() !== $this) {
                        $newValue->$invertedSetMethod($this);
                    }
                    break;

                case 'mapped':
                    $itemName = $association['itemName'];
                    $mappedGetMethod = 'get' . ucfirst($associatedProperty);
                    $mappedAddMethod = 'add' . ucfirst($itemName);
                    $mappedRemoveMethod = 'remove' . ucfirst($itemName);

                    if ($oldValue !== null && CollectionManager::collectionContains($this, $oldValue->$mappedGetMethod())) {
                        $oldValue->$mappedRemoveMethod($this);
                    }
                    if ($newValue !== null && !CollectionManager::collectionContains($this, $newValue->$mappedGetMethod())) {
                        $newValue->$mappedAddMethod($this);
                    }
                    break;
            }
        }
    }
protected function updatePropertyAssociation($property, array $values)
    {
        $this->getPropertiesInfo();

        $oldValue = empty($values['oldValue']) ? null : $values['oldValue'];
        $newValue = empty($values['newValue']) ? null : $values['newValue'];

        $association = $this->_associationsList[$property];
        if (!empty($association)) {
            $associatedProperty = $association['property'];
            switch ($association['association']) {
                case 'inverted':
                    $invertedGetMethod = 'get' . ucfirst($associatedProperty);
                    $invertedSetMethod = 'set' . ucfirst($associatedProperty);
                    if ($oldValue !== null && $oldValue->$invertedGetMethod() === $this) {
                        $oldValue->$invertedSetMethod(null);
                    }
                    if ($newValue !== null && $newValue->$invertedGetMethod() !== $this) {
                        $newValue->$invertedSetMethod($this);
                    }
                    break;

                case 'mapped':
                    $itemName = $association['itemName'];
                    $mappedGetMethod = 'get' . ucfirst($associatedProperty);
                    $mappedAddMethod = 'add' . ucfirst($itemName);
                    $mappedRemoveMethod = 'remove' . ucfirst($itemName);

                    if ($oldValue !== null && CollectionManager::collectionContains($this, $oldValue->$mappedGetMethod())) {
                        $oldValue->$mappedRemoveMethod($this);
                    }
                    if ($newValue !== null && !CollectionManager::collectionContains($this, $newValue->$mappedGetMethod())) {
                        $newValue->$mappedAddMethod($this);
                    }
                    break;
            }
        }
    }
protected function updatePropertyAssociation ( $ property , array $ values ) { $ this -> getPropertiesInfo ( ) ; $ oldValue = empty ( $ values [ 'oldValue' ] ) ? null : $ values [ 'oldValue' ] ; $ newValue = empty ( $ values [ 'newValue' ] ) ? null : $ values [ 'newValue' ] ; $ association = $ this -> _associationsList [ $ property ] ; if ( ! empty ( $ association ) ) { $ associatedProperty = $ association [ 'property' ] ; switch ( $ association [ 'association' ] ) { case 'inverted' : $ invertedGetMethod = 'get' . ucfirst ( $ associatedProperty ) ; $ invertedSetMethod = 'set' . ucfirst ( $ associatedProperty ) ; if ( $ oldValue !== null && $ oldValue -> $ invertedGetMethod ( ) === $ this ) { $ oldValue -> $ invertedSetMethod ( null ) ; } if ( $ newValue !== null && $ newValue -> $ invertedGetMethod ( ) !== $ this ) { $ newValue -> $ invertedSetMethod ( $ this ) ; } break ; case 'mapped' : $ itemName = $ association [ 'itemName' ] ; $ mappedGetMethod = 'get' . ucfirst ( $ associatedProperty ) ; $ mappedAddMethod = 'add' . ucfirst ( $ itemName ) ; $ mappedRemoveMethod = 'remove' . ucfirst ( $ itemName ) ; if ( $ oldValue !== null && CollectionManager :: collectionContains ( $ this , $ oldValue -> $ mappedGetMethod ( ) ) ) { $ oldValue -> $ mappedRemoveMethod ( $ this ) ; } if ( $ newValue !== null && ! CollectionManager :: collectionContains ( $ this , $ newValue -> $ mappedGetMethod ( ) ) ) { $ newValue -> $ mappedAddMethod ( $ this ) ; } break ; } } }
Update the property associated to the given property.
You can pass the old or the new value given to the property.

@param  string $property The property of the current class to update
@param  object $values   An array of old a new value under the following form:
['oldValue' => $oldvalue, 'newValue' => $newValue]
If one of theses values is not given, it will simply not be updated.
Update the property associated to the given property . You can pass the old or the new value given to the property .