Example #1
0
<?php

/**
 * Created by PhpStorm.
 * User: Younes
 * Date: 13/12/2015
 * Time: 17:57
 */
require_once 'vendor/autoload.php';
require_once __DIR__ . '/config.php';
use Orm\Orm\Orm, Orm\Entity\User;
Orm::init();
$user = new User();
$user->setMail('younes@gmail.com');
$user->setUsername('younes');
$user->setPassword('younes');
$user->save();
$user->setUsername('LOL');
$user->save();
$nmbUser = User::countItem();
var_dump($nmbUser);
//$user->deleteD();
$nmbUser = User::countItem();
var_dump($nmbUser);
Example #2
0
 /**
  * @param  array   $columnValues
  * @param  boolean $useColumnsValuesId
  *
  * @throws \Cms\Exception
  * @return \Cms\Data\User
  */
 public function create(array $columnValues, $useColumnsValuesId = false)
 {
     $user = new User();
     if ($this->isEmailAlreadyTaken($columnValues['email'])) {
         throw new CmsException(1001, __METHOD__, __LINE__);
     }
     if ($useColumnsValuesId && isset($columnValues['id'])) {
         $user->setId($columnValues['id']);
     } else {
         $user->setNewGeneratedId();
     }
     $user->setFirstname($columnValues['firstname']);
     $user->setLastname($columnValues['lastname']);
     $user->setEmail($columnValues['email']);
     if (isset($columnValues['gender'])) {
         $user->setGender($columnValues['gender']);
     }
     if (isset($columnValues['language'])) {
         $user->setLanguage($columnValues['language']);
     }
     $user->setPassword('');
     $user->setSuperuser($columnValues['isSuperuser']);
     $user->setDeletable($columnValues['isDeletable']);
     try {
         $entityManager = $this->getEntityManager();
         $entityManager->persist($user);
         $entityManager->flush();
         $entityManager->refresh($user);
     } catch (Exception $e) {
         throw new CmsException(1004, __METHOD__, __LINE__, null, $e);
     }
     return $this->convertToCmsDataObject($user);
 }
Example #3
0
 /**
  * {@inheritDoc}
  */
 public function toCmsData()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'toCmsData', array());
     return parent::toCmsData();
 }