public function initializeEntity(SchemaInterface $schema)
    {
        $valueSet = $this->createValueSet();
        $valueSet->setSchema($schema);

        // To avoid persisting Value entities with no actual value to the database
        // we create empty ones, that will be removed on postPersist events.
        $this->replaceEmptyValues($valueSet);

        $entity = $schema->getObjectClass();
        $entity = new $entity();

        if (!$entity instanceof EntityInterface) {
            throw new \Exception(sprintf('The entity specified in schema "%d" schema must implement Opifer\EavBundle\Model\EntityInterface.', $schema->getId()));
        }

        $entity->setValueSet($valueSet);
        $entity->setSchema($schema);

        return $entity;
    }