Nextras\Orm\Entity\Reflection\MetadataParser::initPrimaryKey PHP Méthode

initPrimaryKey() protected méthode

protected initPrimaryKey ( )
    protected function initPrimaryKey()
    {
        $primaryKey = array_values(array_filter(array_map(function (PropertyMetadata $metadata) {
            return $metadata->isPrimary && !$metadata->isVirtual ? $metadata->name : null;
        }, $this->metadata->getProperties())));
        if (empty($primaryKey)) {
            throw new InvalidStateException("Entity {$this->reflection->name} does not have defined any primary key.");
        } elseif (!$this->metadata->hasProperty('id') || !$this->metadata->getProperty('id')->isPrimary) {
            throw new InvalidStateException("Entity {$this->reflection->name} has to have defined \$id property as {primary} or {primary-proxy}.");
        }
        $this->metadata->setPrimaryKey($primaryKey);
    }