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;
    }