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;
    }
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;
    }
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 ; }
Initializes an entity from a schema to work properly with this bundle.

@param SchemaInterface $schema

@throws \Exception If the entity is not an instance of EntityInterface

@return EntityInterface
Initializes an entity from a schema to work properly with this bundle .