protected function buildDefinition(array $metadata)
    {
        if (!isset($metadata['attribute']) && !isset($metadata['key'])) {
            throw new \RuntimeException('Invalid metadata should provide an attribute or a key');
        }

        // @TODO Rethink this hacky method cause I hate annotation ?
        if (!isset($metadata['key'])) {
            $metadata['key'] = $this->formatter->toMongoKey($metadata['attribute']);
        } elseif (!isset($metadata['attribute'])) {
            $metadata['attribute'] = $this->formatter->toPhpAttribute($metadata['key']);
        }

        $metadata['accessor'] = $this->formatter->getPhpAccessor($metadata['attribute']);
        $metadata['mutator'] = $this->formatter->getPhpMutator($metadata['attribute']);

        $className = $this->getDefinitionClassName();
        $definition = new $className($metadata);

        return $definition;
    }
protected function buildDefinition(array $metadata)
    {
        if (!isset($metadata['attribute']) && !isset($metadata['key'])) {
            throw new \RuntimeException('Invalid metadata should provide an attribute or a key');
        }

        // @TODO Rethink this hacky method cause I hate annotation ?
        if (!isset($metadata['key'])) {
            $metadata['key'] = $this->formatter->toMongoKey($metadata['attribute']);
        } elseif (!isset($metadata['attribute'])) {
            $metadata['attribute'] = $this->formatter->toPhpAttribute($metadata['key']);
        }

        $metadata['accessor'] = $this->formatter->getPhpAccessor($metadata['attribute']);
        $metadata['mutator'] = $this->formatter->getPhpMutator($metadata['attribute']);

        $className = $this->getDefinitionClassName();
        $definition = new $className($metadata);

        return $definition;
    }
protected function buildDefinition ( array $ metadata ) { if ( ! isset ( $ metadata [ 'attribute' ] ) && ! isset ( $ metadata [ 'key' ] ) ) { throw new \ RuntimeException ( 'Invalid metadata should provide an attribute or a key' ) ; } // @TODO Rethink this hacky method cause I hate annotation ? if ( ! isset ( $ metadata [ 'key' ] ) ) { $ metadata [ 'key' ] = $ this -> formatter -> toMongoKey ( $ metadata [ 'attribute' ] ) ; } elseif ( ! isset ( $ metadata [ 'attribute' ] ) ) { $ metadata [ 'attribute' ] = $ this -> formatter -> toPhpAttribute ( $ metadata [ 'key' ] ) ; } $ metadata [ 'accessor' ] = $ this -> formatter -> getPhpAccessor ( $ metadata [ 'attribute' ] ) ; $ metadata [ 'mutator' ] = $ this -> formatter -> getPhpMutator ( $ metadata [ 'attribute' ] ) ; $ className = $ this -> getDefinitionClassName ( ) ; $ definition = new $ className ( $ metadata ) ; return $ definition ; }
Build a Definition

@param array $metadata

@return Definition
Build a Definition