Esempio n. 1
0
 /**
  * Populate the EntityRepository $repo with $count entities.
  *
  * @see \Population\Populator::populate
  *
  * @access public
  * @param EntityRepository $repo
  * @param int $count
  * @param array $options
  * @param callable $callback Function which populates the data for each instance. It is passed a single argument,
  *     the entity to be populated. If $callback returns false, the entity will not be persisted.
  * @param array $options (default: array())
  *     perFlush:        Limit the number of insertions performed in a single flush (default: 100)
  *     clearAfterFlush: Clear the EntityManager after each flush (default:true)
  *     factory:         Optionally, specify a factory callback for populated objects
  *     constructorArgs: An array of args, passed directly to the document's constructor (default: null)
  * @return void
  */
 public function populateEntity(EntityRepository $repo, $count, $callback, array $options = array())
 {
     $em = $repo->getEntityManager();
     if (isset($options['factory'])) {
         $factory = $options['factory'];
     } else {
         $reflClass = $repo->getClassMetadata()->reflClass;
         $factory = array($reflClass, 'newInstanceArgs');
     }
     $this->populateObject($em, $factory, $count, $callback, $options);
 }
Esempio n. 2
0
 public function getClassMetadata()
 {
     return parent::getClassMetadata();
 }