protected function setReferences($item, $step)
    {
        if (!array_key_exists('references', $step->dsl)) {
            return false;
        }

        $referencesDefs = $this->setReferencesCommon($item, $step->dsl['references']);

        $this->insureEntityCountCompatibility($item, $referencesDefs, $step);

        $multivalued = ($this->getReferencesType($step) == self::REFERENCE_TYPE_ARRAY);

        if ($item instanceof AbstractCollection) {
            $items = $item;
        } else {
            $items = array($item);
        }

        $referencesValues = array();
        foreach ($items as $item) {
            $itemReferencesValues = $this->getReferencesValues($item, $referencesDefs, $step);
            if (!$multivalued) {
                $referencesValues = $itemReferencesValues;
            } else {
                foreach ($itemReferencesValues as $refName => $refValue) {
                    if (!isset($referencesValues[$refName])) {
                        $referencesValues[$refName] = array($refValue);
                    } else {
                        $referencesValues[$refName][] = $refValue;
                    }
                }
            }
        }

        foreach($referencesDefs as $reference) {
            $overwrite = false;
            if (isset($reference['overwrite'])) {
                $overwrite = $reference['overwrite'];
            }
            $this->referenceResolver->addReference($reference['identifier'], count($referencesValues) ? $referencesValues[$reference['identifier']] : array(), $overwrite);
        }

        return true;
    }
protected function setReferences($item, $step)
    {
        if (!array_key_exists('references', $step->dsl)) {
            return false;
        }

        $referencesDefs = $this->setReferencesCommon($item, $step->dsl['references']);

        $this->insureEntityCountCompatibility($item, $referencesDefs, $step);

        $multivalued = ($this->getReferencesType($step) == self::REFERENCE_TYPE_ARRAY);

        if ($item instanceof AbstractCollection) {
            $items = $item;
        } else {
            $items = array($item);
        }

        $referencesValues = array();
        foreach ($items as $item) {
            $itemReferencesValues = $this->getReferencesValues($item, $referencesDefs, $step);
            if (!$multivalued) {
                $referencesValues = $itemReferencesValues;
            } else {
                foreach ($itemReferencesValues as $refName => $refValue) {
                    if (!isset($referencesValues[$refName])) {
                        $referencesValues[$refName] = array($refValue);
                    } else {
                        $referencesValues[$refName][] = $refValue;
                    }
                }
            }
        }

        foreach($referencesDefs as $reference) {
            $overwrite = false;
            if (isset($reference['overwrite'])) {
                $overwrite = $reference['overwrite'];
            }
            $this->referenceResolver->addReference($reference['identifier'], count($referencesValues) ? $referencesValues[$reference['identifier']] : array(), $overwrite);
        }

        return true;
    }
protected function setReferences ( $ item , $ step ) { if ( ! array_key_exists ( 'references' , $ step -> dsl ) ) { return false ; } $ referencesDefs = $ this -> setReferencesCommon ( $ item , $ step -> dsl [ 'references' ] ) ; $ this -> insureEntityCountCompatibility ( $ item , $ referencesDefs , $ step ) ; $ multivalued = ( $ this -> getReferencesType ( $ step ) == self :: REFERENCE_TYPE_ARRAY ) ; if ( $ item instanceof AbstractCollection ) { $ items = $ item ; } else { $ items = array ( $ item ) ; } $ referencesValues = array ( ) ; foreach ( $ items as $ item ) { $ itemReferencesValues = $ this -> getReferencesValues ( $ item , $ referencesDefs , $ step ) ; if ( ! $ multivalued ) { $ referencesValues = $ itemReferencesValues ; } else { foreach ( $ itemReferencesValues as $ refName => $ refValue ) { if ( ! isset ( $ referencesValues [ $ refName ] ) ) { $ referencesValues [ $ refName ] = array ( $ refValue ) ; } else { $ referencesValues [ $ refName ] [ ] = $ refValue ; } } } } foreach ( $ referencesDefs as $ reference ) { $ overwrite = false ; if ( isset ( $ reference [ 'overwrite' ] ) ) { $ overwrite = $ reference [ 'overwrite' ] ; } $ this -> referenceResolver -> addReference ( $ reference [ 'identifier' ] , count ( $ referencesValues ) ? $ referencesValues [ $ reference [ 'identifier' ] ] : array ( ) , $ overwrite ) ; } return true ; }
Sets references to certain attributes of the items returned by steps.

@param \Object|AbstractCollection $item
@param MigrationStep $step
@throws \InvalidArgumentException When trying to set a reference to an unsupported attribute
@return boolean
@todo should we allow to be passed in plain arrays as well as Collections?
Sets references to certain attributes of the items returned by steps .