本文整理汇总了PHP中app\Project::getEntityManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::getEntityManager方法的具体用法?PHP Project::getEntityManager怎么用?PHP Project::getEntityManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Project
的用法示例。
在下文中一共展示了Project::getEntityManager方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loginAction
public function loginAction()
{
$this->setTitle('Conectare - Auto Parts Supply');
$error = '';
$isAlreadyLogged = Session::has('logged_user');
if (!$isAlreadyLogged && isset($_POST['email']) && isset($_POST['password'])) {
$email = $_POST['email'];
$password = $_POST['password'];
if ($email && $password) {
$em = Project::getEntityManager();
$user = $em->getOneBy('App\\Entity\\UserEntity', array('email' => $email));
if ($user && Security::checkPasswordForUser($password, $user)) {
Session::set('logged_user', $user->getId());
$this->redirectTo('');
}
if (!$user) {
$error = 'Email-ul nu este valid.';
}
if ($user && !Security::checkPasswordForUser($password, $user)) {
$error = 'Parola nu este valida pentru acest email, te rugam incearca dinou.';
}
} else {
$error = 'Introdu te rog un email si o parola.';
}
} elseif ($isAlreadyLogged) {
throw new \Exception('A user is already logged');
}
$this->renderTemplate('security/login.php', array('error' => $error));
}
示例2: registerAction
public function registerAction()
{
$this->setTitle('Inregistrare - Auto Parts Supply');
$error = '';
if (isset($_POST['email']) && isset($_POST['password']) && isset($_POST['name'])) {
$email = $_POST['email'];
$name = $_POST['name'];
$password = $_POST['password'];
$repassword = $_POST['repassword'];
if ($email && $name && $password && $repassword) {
if ($password != $repassword) {
$error = 'Parolele nu sunt egale.';
} else {
$em = Project::getEntityManager();
$created = new \DateTime();
$entity = $em->insert('App\\Entity\\UserEntity', array('name' => $name, 'email' => $email, 'password' => Security::generatePassword($password), 'status' => 1, 'created' => $created->format('Y-m-d H:i:s'), 'updated' => $created->format('Y-m-d H:i:s')));
if (!$entity) {
$error = 'A fost o eroare in momentul inregistrari, te rugam incearca dinou.';
} else {
$this->redirectTo('security/login');
}
}
} else {
$error = 'Introdu valori valide.';
}
}
$this->renderTemplate('user/register.php', array('error' => $error));
}
示例3: getLoggedUser
/**
* Return Logged User
*
* @return UserEntity|null
*/
public static function getLoggedUser()
{
$loggedUserId = Session::get('logged_user');
if (!$loggedUserId) {
return null;
}
$em = Project::getEntityManager();
$user = $em->get('App\\Entity\\UserEntity', intval($loggedUserId));
return $user;
}
示例4: modelAction
public function modelAction($brandId)
{
$models = Project::getEntityManager()->getAllBy('App\\Entity\\ModelAutoEntity', array('brand_id' => $brandId), array('orderBy' => 'name'));
if (empty($models)) {
return 0;
}
foreach ($models as $model) {
echo '<option value="' . $model->getId() . '">' . $model->getName() . '</option>';
}
}
示例5: indexAction
public function indexAction()
{
$this->setTitle('Auto Parts Supply');
$products = Project::getEntityManager()->getAll('App\\Entity\\ProductEntity', array('limit' => 3, 'orderBy' => 'created', 'order' => 'DESC'));
$this->renderTemplate('home.php', array('products' => $products));
}