Doctrine\ODM\MongoDB\Mapping\Driver\XmlDriver::setShardKey PHP Method

setShardKey() private method

private setShardKey ( ClassMetadataInfo $class, SimpleXmlElement $xmlShardkey )
$class Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo
$xmlShardkey SimpleXmlElement
    private function setShardKey(ClassMetadataInfo $class, \SimpleXmlElement $xmlShardkey)
    {
        $attributes = $xmlShardkey->attributes();
        $keys = array();
        $options = array();
        foreach ($xmlShardkey->{'key'} as $key) {
            $keys[(string) $key['name']] = isset($key['order']) ? (string) $key['order'] : 'asc';
        }
        if (isset($attributes['unique'])) {
            $options['unique'] = 'true' === (string) $attributes['unique'];
        }
        if (isset($attributes['numInitialChunks'])) {
            $options['numInitialChunks'] = (int) $attributes['numInitialChunks'];
        }
        if (isset($xmlShardkey->{'option'})) {
            foreach ($xmlShardkey->{'option'} as $option) {
                $value = (string) $option['value'];
                if ($value === 'true') {
                    $value = true;
                } elseif ($value === 'false') {
                    $value = false;
                } elseif (is_numeric($value)) {
                    $value = preg_match('/^[-]?\\d+$/', $value) ? (int) $value : (double) $value;
                }
                $options[(string) $option['name']] = $value;
            }
        }
        $class->setShardKey($keys, $options);
    }