public function setUp() { $this->project = Project::fetch(self::$conn, 1); $this->status = AreaStatus::fetchByProject(self::$conn, 1, $this->project); $this->territory = Territory::fetchByProject(self::$conn, 1, $this->project); $this->area = Area::newArea($this->project, $this->territory, $this->status, 'Area1'); $this->area->insert(self::$conn); $this->area2 = Area::newArea($this->project, $this->territory, $this->status, 'Area2'); $lang = new Language(); $lang->setId(1); $this->user = User::newUser('login', 'Some user', $lang); $this->user->insert(self::$conn); $this->user2 = User::newUser('login2', 'Another user', $lang); $this->user2->insert(self::$conn); $tpa1 = new CourseProgress($this->area); $tpa1->insert(self::$conn); }
public function setUp() { $this->project = Project::fetch(self::$conn, 1); $this->status = AreaStatus::fetchByProject(self::$conn, 1, $this->project); $this->territory = Territory::fetchByProject(self::$conn, 1, $this->project); $this->area = Area::newArea($this->project, $this->territory, $this->status, 'Area1'); $this->area->insert(self::$conn); $this->course = new Course(); $this->course->setProject($this->project); $this->course->setName('Foo'); $this->course->setAuthorName('Foo'); $this->course->setAuthorEmail('*****@*****.**'); $this->course->setPresentationLink('http://www.example.com/'); $this->course->setIsPublished(true); $this->course->insert(self::$conn); $lang = new Language(); $lang->setId(1); $this->user = User::newUser('login', 'Some user', $lang); $this->user->insert(self::$conn); $this->anotherUser = User::newUser('login2', 'Another user', $lang); $this->anotherUser->insert(self::$conn); $pp = new CourseProgress($this->area); $pp->insert(self::$conn); }
public static function fromArray($array, $prefix = '') { $user = new User(); DataMappers::fromArray($user, $array, $prefix); if (isset($array['language_id'])) { $user->settingsLanguage = Language::fromArray($array, 'language'); } if ($user->getAdmin()) { $user->addRole('ROLE_ADMIN'); } return $user; }
/** * @return UserRegistration */ public function getItem($id) { $this->transaction->requestTransaction(); $data = $this->conn->fetchAssoc('SELECT r.*, l.`id` AS `language_id`, l.`name` AS `language_name`, l.`locale` AS `language_locale` ' . 'FROM `' . CoreTables::USER_REGISTRATION_TBL . '` r ' . 'INNER JOIN `' . CoreTables::LANGUAGE_TBL . '` l ON l.`id` = r.`languageId` ' . 'WHERE r.`id` = :id', [':id' => $id]); if (false === $data) { $this->transaction->requestRollback(); throw new ItemNotFoundException('The specified item has not been found.', $id); } $item = UserRegistration::fromArray($data); $item->setLanguage(Language::fromArray($data, 'language')); return $item; }
public function remove(Language $language) { $this->transaction->requestTransaction(); return $language->remove($this->conn); }