PHP code example of ingenerator / be_entity

1. Go to this page and download the library: Download ingenerator/be_entity 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/ */

    

ingenerator / be_entity example snippets


namespace Ingenerator\BeEntity\Factory;

class User extends Ingenerator\BeEntity\Factory {

	protected function _locate($identifier)
	{
		return $this->entity_manager->getRepository('Project\User')->findOneBy(array('email' => $identifier));
	}

	protected function _create($identifier)
	{
		$user = new Project\User;
		$user->set_email($identifier);
		$user->set_password('foo');
		return $user;
	}

}


class FeatureContext extends Behat\Behat\Context\BehatContext {

	public function __construct()
	{
		$em = new Doctrine\ORM\EntityManager;  // Whatever code you need to get an EntityManager instance in your app

		$this->useContext('be_entity', new Ingenerator\BeEntity\Context\BeEntityContext($em));
	}
}