PHP code example of cube / doctrine-entity-factory
1. Go to this page and download the library: Download cube/doctrine-entity-factory library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cube / doctrine-entity-factory example snippets
class DoctrineResource
{
public function create($data)
{
$entityClass = $this->getEntityClass();
// ...
$entity = new $entityClass(); // notice this line
// ...
return $entity;
}
}
use Cube\DoctrineEntityFactory\EntityFactoryInterface;
class DoctrineResource
{
/**
* @var EntityFactoryInterface Set e.g. via DI, can default to SimpleEntityFactory
* to avoid BC breaks
*/
private $entityFactory;
public function create($data)
{
$entityClass = $this->getEntityClass();
// ...
$entity = $this->entityFactory->get($entityClass);
// ...
return $entity;
}
}
bash
$ php composer.phar