Ejemplo n.º 1
0
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $manager = $this->getUserManager();
     $admin = $manager->find(1);
     if (empty($admin)) {
         // Creating admin user.
         /** @var User $admin */
         $admin = $manager->createUser();
         $accessUrl = $this->getAccessUrlManager()->find(1);
         $accessUrlRelUser = new AccessUrlRelUser();
         $accessUrlRelUser->setUser($admin);
         $accessUrlRelUser->setPortal($accessUrl);
         $admin->setPortal($accessUrlRelUser);
         $admin->setUsername('admin');
         $admin->setUserId(1);
         $admin->setStatus(1);
         // teacher
         $admin->setFirstname('Jane');
         $admin->setLastname('Doe');
         $admin->setEmail('*****@*****.**');
         $admin->setPlainPassword('admin');
         $admin->setEnabled(true);
         $admin->setSuperAdmin(true);
         $admin->setLocked(false);
     }
     // Reference added in LoadGroupData.php
     $group = $this->getReference('group_admin');
     $admin->setGroups(array($group));
     $manager->updateUser($admin);
 }
Ejemplo n.º 2
0
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $manager = $this->getUserManager();
     $groupManager = $this->getGroupManager();
     //$faker = $this->getFaker();
     $criteria = ['code' => 'student'];
     $studentGroup = $groupManager->findGroupBy($criteria);
     $criteria = ['code' => 'teacher'];
     $teacherGroup = $groupManager->findGroupBy($criteria);
     // Loading test users
     // @todo add setting in installer to load sample content
     $root = $this->container->get('kernel')->getRealRootDir();
     $dataUserFile = $root . '/tests/datafiller/data_users.php';
     $accessUrl = $this->getAccessUrlManager()->find(1);
     if (file_exists($dataUserFile)) {
         $users = (require $root . '/tests/datafiller/data_users.php');
         foreach ($users as $userData) {
             /** @var User $user */
             $user = $manager->createUser();
             $accessUrlRelUser = new AccessUrlRelUser();
             $accessUrlRelUser->setUser($user);
             $accessUrlRelUser->setPortal($accessUrl);
             $user->setPortal($accessUrlRelUser);
             $user->setFirstname($userData['firstname']);
             $user->setLastname($userData['lastname']);
             $user->setUsername($userData['username']);
             $user->setEmail($userData['email']);
             $user->setPlainPassword($userData['pass']);
             $user->setEnabled(true);
             $user->setLocked(false);
             if ($userData['status'] == 5) {
                 $user->addGroup($studentGroup);
             } else {
                 $user->addGroup($teacherGroup);
             }
             $manager->updateUser($user);
         }
     }
     // Creating random student users using faker
     /*
             foreach (range(3, 100) as $id) {
                 $user = $manager->createUser();
                 $user->setUserId($id);
                 $user->setFirstname($faker->firstName);
                 $user->setLastname($faker->lastName);
                 //$user->setPhone($faker->phoneNumber);
                 $user->setUsername($faker->userName);
                 $user->setEmail($faker->safeEmail);
                 $user->setPlainPassword($faker->randomNumber());
                 $user->setEnabled(true);
                 $user->setLocked(false);
                 $user->addGroup($studentGroup);
                 $manager->updateUser($user);
             }*/
 }
Ejemplo n.º 3
0
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     /** @var HttpKernelInterface $kernel */
     $kernel = $this->container->get('kernel');
     $courseCategory = new CourseCategory();
     $courseCategory->setName('Language skills');
     $courseCategory->setCode('LANG');
     $courseCategory->setTreePos(1);
     $courseCategory->setAuthCatChild('TRUE');
     $courseCategory->setAuthCourseChild('TRUE');
     $manager->persist($courseCategory);
     $courseCategory = new CourseCategory();
     $courseCategory->setName('PC Skills');
     $courseCategory->setCode('PC');
     $courseCategory->setTreePos(2);
     $courseCategory->setAuthCatChild('TRUE');
     $courseCategory->setAuthCourseChild('TRUE');
     $manager->persist($courseCategory);
     $courseCategory = new CourseCategory();
     $courseCategory->setName('Projects');
     $courseCategory->setCode('PROJ');
     $courseCategory->setTreePos(3);
     $courseCategory->setAuthCatChild('TRUE');
     $courseCategory->setAuthCourseChild('TRUE');
     $manager->persist($courseCategory);
     $courseField = new CourseField();
     $courseField->setFieldType(13);
     $courseField->setFieldVariable('special_course');
     $courseField->setFieldDisplayText('Special course');
     $courseField->setFieldDefaultValue('Yes');
     $courseField->setFieldVisible(1);
     $courseField->setFieldChangeable(1);
     $manager->persist($courseField);
     /*
         Saving available languages depending in
         the ChamiloCoreBundle/Resources/translations folder
     */
     $languages = Intl::getLocaleBundle()->getLocaleNames('en');
     // Getting po files inside the path
     $translationPath = $kernel->locateResource('@ChamiloCoreBundle/Resources/translations');
     $finder = new Finder();
     $finder->files()->in($translationPath);
     $avoidIsoCodeList = array('AvanzuAdminTheme.en.po');
     $availableIsoCode = array();
     foreach ($finder as $file) {
         $fileName = $file->getRelativePathname();
         if (in_array($fileName, $avoidIsoCodeList)) {
             continue;
         }
         $isoCodeInFolder = str_replace(array('all.', '.po'), '', $fileName);
         $availableIsoCode[] = $isoCodeInFolder;
     }
     foreach ($languages as $code => $languageName) {
         if (!in_array($code, $availableIsoCode)) {
             continue;
         }
         \Locale::setDefault($code);
         $localeName = Intl::getLocaleBundle()->getLocaleName($code);
         $lang = new Language();
         $lang->setAvailable(1);
         $lang->setIsocode($code);
         $lang->setOriginalName($localeName);
         $lang->setEnglishName($languageName);
         $manager->persist($lang);
     }
     $adminUser = $this->getUserManager()->findUserByUsername('admin');
     // Ids used
     $adminUserId = $adminUser->getId();
     $accessUrlId = 1;
     $accessUrl = new AccessUrl();
     $accessUrl->setUrl('http://localhost/');
     $accessUrl->setActive(1);
     $accessUrl->setDescription(' ');
     $accessUrl->setCreatedBy($adminUserId);
     $manager->persist($accessUrl);
     $this->setReference('access_url', $accessUrl);
     $accessUrlRelUser = new AccessUrlRelUser();
     $accessUrlRelUser->setUserId($adminUserId);
     $accessUrlRelUser->setAccessUrlId($accessUrlId);
     $manager->persist($accessUrlRelUser);
     /*$systemTemplate = new SystemTemplate();
       $systemTemplate->setTitle('');
       $systemTemplate->setComment('');
       $systemTemplate->setImage('');
       $systemTemplate->setContent('');*/
     $userFriendRelationType = new UserFriendRelationType();
     $userFriendRelationType->setId(1);
     $userFriendRelationType->setTitle('SocialUnknow');
     $manager->persist($userFriendRelationType);
     $userFriendRelationType = new UserFriendRelationType();
     $userFriendRelationType->setId(2);
     $userFriendRelationType->setTitle('SocialParent');
     $manager->persist($userFriendRelationType);
     $userFriendRelationType = new UserFriendRelationType();
     $userFriendRelationType->setId(3);
     $userFriendRelationType->setTitle('SocialFriend');
     $manager->persist($userFriendRelationType);
     $userFriendRelationType = new UserFriendRelationType();
     $userFriendRelationType->setId(4);
     $userFriendRelationType->setTitle('SocialGoodFriend');
     $manager->persist($userFriendRelationType);
     $userFriendRelationType = new UserFriendRelationType();
     $userFriendRelationType->setId(5);
     $userFriendRelationType->setTitle('SocialEnemy');
     $manager->persist($userFriendRelationType);
     $userFriendRelationType = new UserFriendRelationType();
     $userFriendRelationType->setId(6);
     $userFriendRelationType->setTitle('SocialDeleted');
     $manager->persist($userFriendRelationType);
     $skill = new Skill();
     $skill->setName('Root');
     $skill->setDescription(' ');
     $skill->setShortCode('root');
     $skill->setIcon(' ');
     $skill->setAccessUrlId($accessUrlId);
     $manager->persist($skill);
     $skillRelSkill = new SkillRelSkill();
     $skillRelSkill->setId(1);
     $skillRelSkill->setSkillId(1);
     $skillRelSkill->setParentId(0);
     $skillRelSkill->setRelationType(0);
     $skillRelSkill->setLevel(0);
     $manager->persist($skillRelSkill);
     $courseType = new CourseType();
     $courseType->setName('All Tools');
     $manager->persist($courseType);
     $courseType = new CourseType();
     $courseType->setName('Entry exam');
     $manager->persist($courseType);
     $branch = new BranchSync();
     $branch->setAccessUrlId($accessUrlId);
     $branch->setBranchName('Local');
     $branch->setBranchIp('127.0.0.1');
     $manager->persist($branch);
     $branchTransactionStatus = new BranchTransactionStatus();
     $branchTransactionStatus->setTitle('To be executed');
     $manager->persist($branchTransactionStatus);
     $branchTransactionStatus = new BranchTransactionStatus();
     $branchTransactionStatus->setTitle('Executed success');
     $manager->persist($branchTransactionStatus);
     $branchTransactionStatus = new BranchTransactionStatus();
     $branchTransactionStatus->setTitle('Execution deprecated');
     $manager->persist($branchTransactionStatus);
     $branchTransactionStatus = new BranchTransactionStatus();
     $branchTransactionStatus->setTitle('Execution failed');
     $manager->persist($branchTransactionStatus);
     $toolChain = $this->container->get('chamilo_course.tool_chain');
     $toolChain->createTools($manager);
     /*
             $tool = new Tool();
             $tool->setName('agenda');
             $manager->persist($tool);
     
             $tool = new Tool();
             $tool->setName('announcements');
             $manager->persist($tool);
     
             $tool = new Tool();
             $tool->setName('exercise');
             $manager->persist($tool);
     
             $tool = new Tool();
             $tool->setName('document');
             $manager->persist($tool);
     
             $tool = new Tool();
             $tool->setName('link');
             $manager->persist($tool);
     
             $tool = new Tool();
             $tool->setName('forum');
             $manager->persist($tool);
     
             $tool = new Tool();
             $tool->setName('glossary');
             $manager->persist($tool);*/
     $manager->flush();
 }
Ejemplo n.º 4
0
 /**
  * Creates a new user for the platform
  * @author Hugues Peeters <*****@*****.**>,
  * @author Roan Embrechts <*****@*****.**>
  * @param  string Firstname
  * @param  string Lastname
  * @param  int    Status (1 for course tutor, 5 for student, 6 for anonymous)
  * @param  string e-mail address
  * @param  string Login
  * @param  string Password
  * @param  string Any official code (optional)
  * @param  string User language    (optional) (isocode)
  * @param  string Phone number    (optional)
  * @param  string Picture URI        (optional)
  * @param  string Authentication source    (optional, defaults to 'platform', dependind on constant)
  * @param  string Account expiration date (optional, defaults to null)
  * @param  int     Whether the account is enabled or disabled by default
  * @param  int     The department of HR in which the user is registered (optional, defaults to 0)
  * @param  array Extra fields
  * @param  string Encrypt method used if password is given encrypted. Set to an empty string by default
  * @param  bool $send_mail
  * @param  bool $isAdmin
  *
  * @return mixed   new user id - if the new user creation succeeds, false otherwise
  * @desc The function tries to retrieve user id from the session.
  * If it exists, the current user id is the creator id. If a problem arises,
  * it stores the error message in global $api_failureList
  * @assert ('Sam','Gamegie',5,'*****@*****.**','jo','jo') > 1
  * @assert ('Pippin','Took',null,null,'jo','jo') === false
  */
 public static function create_user($firstName, $lastName, $status, $email, $loginName, $password, $official_code = '', $language = '', $phone = '', $picture_uri = '', $auth_source = PLATFORM_AUTH_SOURCE, $expirationDate = null, $active = 1, $hr_dept_id = 0, $extra = null, $encrypt_method = '', $send_mail = false, $isAdmin = false)
 {
     $currentUserId = api_get_user_id();
     $hook = HookCreateUser::create();
     if (!empty($hook)) {
         $hook->notifyCreateUser(HOOK_EVENT_TYPE_PRE);
     }
     $original_password = $password;
     if (empty($password)) {
         Display::addFlash(Display::return_message(get_lang('ThisFieldIsRequired') . ': ' . get_lang('Password'), 'warning'));
         return false;
     }
     // database table definition
     $table_user = Database::get_main_table(TABLE_MAIN_USER);
     //Checking the user language
     $languages = api_get_languages();
     if (!in_array($language, array_keys($languages))) {
         $language = api_get_setting('language.platform_language');
     }
     if (!empty($currentUserId)) {
         $creator_id = $currentUserId;
     } else {
         $creator_id = 0;
     }
     // First check wether the login already exists
     if (!self::is_username_available($loginName)) {
         throw new \Exception("Username '{$loginName}' already exists");
     }
     $currentDate = api_get_utc_datetime();
     $now = new DateTime($currentDate);
     if (empty($expirationDate) || $expirationDate == '0000-00-00 00:00:00') {
         // Default expiration date
         // if there is a default duration of a valid account then
         // we have to change the expiration_date accordingly
         // Accept 0000-00-00 00:00:00 as a null value to avoid issues with
         // third party code using this method with the previous (pre-1.10)
         // value of 0000...
         if (api_get_setting('profile.account_valid_duration') != '') {
             $expirationDate = new DateTime($currentDate);
             $days = intval(api_get_setting('profile.account_valid_duration'));
             $expirationDate->modify('+' . $days . ' day');
         }
     } else {
         $expirationDate = api_get_utc_datetime($expirationDate);
         $expirationDate = new \DateTime($expirationDate, new DateTimeZone('UTC'));
     }
     $em = Database::getManager();
     $userManager = self::getManager();
     /** @var User $user */
     $user = $userManager->createUser();
     $user->setLastname($lastName)->setFirstname($firstName)->setUsername($loginName)->setStatus($status)->setPlainPassword($password)->setEmail($email)->setOfficialCode($official_code)->setPictureUri($picture_uri)->setCreatorId($creator_id)->setAuthSource($auth_source)->setPhone($phone)->setLanguage($language)->setRegistrationDate($now)->setHrDeptId($hr_dept_id)->setActive($active)->setEnabled($active);
     $url = $em->getRepository('ChamiloCoreBundle:AccessUrl')->find(api_get_current_access_url_id());
     $accessRelUser = new AccessUrlRelUser();
     $accessRelUser->setUser($user);
     $accessRelUser->setPortal($url);
     $user->setPortal($accessRelUser);
     if (!empty($expirationDate)) {
         $user->setExpirationDate($expirationDate);
     }
     switch ($status) {
         case STUDENT:
             $group = 'student';
             break;
         case COURSEMANAGER:
             $group = 'teacher';
             break;
         case DRH:
             $group = 'drh';
             break;
         case SESSIONADMIN:
             $group = 'session_manager';
             break;
             /*case QUESTION:
               $group = 'question_manager';
               break;*/
         /*case QUESTION:
           $group = 'question_manager';
           break;*/
         case STUDENT_BOSS:
             $group = 'student_boss';
             break;
         case INVITEE:
             $group = 'invitee';
             break;
     }
     if ($isAdmin) {
         $group = 'admin';
     }
     $criteria = ['code' => $group];
     $group = $em->getRepository('ChamiloUserBundle:Group')->findOneBy($criteria);
     $user->setGroups(array($group));
     $userManager->updateUser($user, true);
     $userId = $user->getId();
     if (!empty($userId)) {
         $return = $userId;
         $sql = "UPDATE {$table_user} SET user_id = {$return} WHERE id = {$return}";
         Database::query($sql);
         if ($isAdmin) {
             UserManager::add_user_as_admin($user);
         }
         if (api_get_multiple_access_url()) {
             UrlManager::add_user_to_url($return, api_get_current_access_url_id());
         } else {
             //we are adding by default the access_url_user table with access_url_id = 1
             UrlManager::add_user_to_url($return, 1);
         }
         if (!empty($email) && $send_mail) {
             $recipient_name = api_get_person_name($firstName, $lastName, null, PERSON_NAME_EMAIL_ADDRESS);
             $emailSubject = Container::getTemplating()->render('@template_style/mail/subject_registration_platform.html.twig');
             $sender_name = api_get_person_name(api_get_setting('admin.administrator_name'), api_get_setting('admin.administrator_surname'), null, PERSON_NAME_EMAIL_ADDRESS);
             $email_admin = api_get_setting('admin.administrator_email');
             $url = api_get_path(WEB_PATH);
             if (api_is_multiple_url_enabled()) {
                 $access_url_id = api_get_current_access_url_id();
                 if ($access_url_id != -1) {
                     $url = api_get_access_url($access_url_id);
                 }
             }
             $emailBody = Container::getTemplating()->render('@template_style/mail/content_registration_platform.html.twig', ['complete_name' => stripslashes(api_get_person_name($firstName, $lastName)), 'login_name' => $loginName, 'original_password' => stripslashes($original_password), 'mail_web_path' => $url]);
             /* MANAGE EVENT WITH MAIL */
             if (EventsMail::check_if_using_class('user_registration')) {
                 $values["about_user"] = $return;
                 $values["password"] = $original_password;
                 $values["send_to"] = array($return);
                 $values["prior_lang"] = null;
                 EventsDispatcher::events('user_registration', $values);
             } else {
                 $phoneNumber = isset($extra['mobile_phone_number']) ? $extra['mobile_phone_number'] : null;
                 $additionalParameters = array('smsType' => SmsPlugin::WELCOME_LOGIN_PASSWORD, 'userId' => $return, 'mobilePhoneNumber' => $phoneNumber, 'password' => $original_password);
                 api_mail_html($recipient_name, $email, $emailSubject, $emailBody, $sender_name, $email_admin, null, null, null, $additionalParameters);
             }
             /* ENDS MANAGE EVENT WITH MAIL */
         }
         Event::addEvent(LOG_USER_CREATE, LOG_USER_ID, $return);
     } else {
         throw new \Exception('error inserting in Database');
     }
     if (is_array($extra) && count($extra) > 0) {
         $res = true;
         foreach ($extra as $fname => $fvalue) {
             $res = $res && self::update_extra_field_value($return, $fname, $fvalue);
         }
     }
     self::update_extra_field_value($return, 'already_logged_in', 'false');
     if (!empty($hook)) {
         $hook->setEventData(array('return' => $return, 'originalPassword' => $original_password));
         $hook->notifyCreateUser(HOOK_EVENT_TYPE_POST);
     }
     return $return;
 }
Ejemplo n.º 5
0
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     /** @var HttpKernelInterface $kernel */
     //$kernel = $this->container->get('kernel');
     // Create course categories
     $courseCategory = new CourseCategory();
     $courseCategory->setName('Language skills');
     $courseCategory->setCode('LANG');
     $courseCategory->setTreePos(1);
     $courseCategory->setAuthCatChild('TRUE');
     $courseCategory->setAuthCourseChild('TRUE');
     $manager->persist($courseCategory);
     $courseCategory = new CourseCategory();
     $courseCategory->setName('PC Skills');
     $courseCategory->setCode('PC');
     $courseCategory->setTreePos(2);
     $courseCategory->setAuthCatChild('TRUE');
     $courseCategory->setAuthCourseChild('TRUE');
     $manager->persist($courseCategory);
     $courseCategory = new CourseCategory();
     $courseCategory->setName('Projects');
     $courseCategory->setCode('PROJ');
     $courseCategory->setTreePos(3);
     $courseCategory->setAuthCatChild('TRUE');
     $courseCategory->setAuthCourseChild('TRUE');
     $manager->persist($courseCategory);
     /* $courseField = new CourseField();
        $courseField->setFieldType(13);
        $courseField->setFieldVariable('special_course');
        $courseField->setFieldDisplayText('Special course');
        $courseField->setFieldDefaultValue('Yes');
        $courseField->setFieldVisible(1);
        $courseField->setFieldChangeable(1);
        $manager->persist($courseField);*/
     /*
         Saving available languages depending in
         the ChamiloCoreBundle/Resources/translations folder
     */
     $adminUser = $this->getUserManager()->findUserByUsername('admin');
     // Create first portal (multiple url feature)
     $adminUserId = $adminUser->getId();
     $accessUrlId = 1;
     $accessUrl = new AccessUrl();
     $accessUrl->setUrl('http://localhost/');
     $accessUrl->setActive(1);
     $accessUrl->setDescription(' ');
     $accessUrl->setCreatedBy($adminUserId);
     $manager->persist($accessUrl);
     $this->setReference('access_url', $accessUrl);
     // Add admin user to portal 1
     $accessUrlRelUser = new AccessUrlRelUser();
     $accessUrlRelUser->setUser($adminUser);
     $accessUrlRelUser->setPortal($accessUrl);
     $manager->persist($accessUrlRelUser);
     /*$systemTemplate = new SystemTemplate();
       $systemTemplate->setTitle('');
       $systemTemplate->setComment('');
       $systemTemplate->setImage('');
       $systemTemplate->setContent('');*/
     // Create social network relations
     $userFriendRelationType = new UserFriendRelationType();
     $userFriendRelationType->setId(1);
     $userFriendRelationType->setTitle('SocialUnknow');
     $manager->persist($userFriendRelationType);
     $userFriendRelationType = new UserFriendRelationType();
     $userFriendRelationType->setId(2);
     $userFriendRelationType->setTitle('SocialParent');
     $manager->persist($userFriendRelationType);
     $userFriendRelationType = new UserFriendRelationType();
     $userFriendRelationType->setId(3);
     $userFriendRelationType->setTitle('SocialFriend');
     $manager->persist($userFriendRelationType);
     $userFriendRelationType = new UserFriendRelationType();
     $userFriendRelationType->setId(4);
     $userFriendRelationType->setTitle('SocialGoodFriend');
     $manager->persist($userFriendRelationType);
     $userFriendRelationType = new UserFriendRelationType();
     $userFriendRelationType->setId(5);
     $userFriendRelationType->setTitle('SocialEnemy');
     $manager->persist($userFriendRelationType);
     $userFriendRelationType = new UserFriendRelationType();
     $userFriendRelationType->setId(6);
     $userFriendRelationType->setTitle('SocialDeleted');
     $manager->persist($userFriendRelationType);
     // Create default skills
     $skill = new Skill();
     $skill->setName('Root');
     $skill->setStatus(Skill::STATUS_ENABLED);
     $skill->setDescription(' ');
     $skill->setShortCode('root');
     $skill->setIcon(' ');
     $skill->setAccessUrlId($accessUrlId);
     $manager->persist($skill);
     $skillRelSkill = new SkillRelSkill();
     $skillRelSkill->setId(1);
     $skillRelSkill->setSkillId(1);
     $skillRelSkill->setParentId(0);
     $skillRelSkill->setRelationType(0);
     $skillRelSkill->setLevel(0);
     $manager->persist($skillRelSkill);
     $courseType = new CourseType();
     $courseType->setName('All Tools');
     $manager->persist($courseType);
     $courseType = new CourseType();
     $courseType->setName('Entry exam');
     $manager->persist($courseType);
     // Branch
     $branch = new BranchSync();
     $branch->setAccessUrlId($accessUrlId);
     $branch->setBranchName('Local');
     $branch->setBranchIp('127.0.0.1');
     $manager->persist($branch);
     $branchTransactionStatus = new BranchTransactionStatus();
     $branchTransactionStatus->setTitle('To be executed');
     $manager->persist($branchTransactionStatus);
     $branchTransactionStatus = new BranchTransactionStatus();
     $branchTransactionStatus->setTitle('Executed success');
     $manager->persist($branchTransactionStatus);
     $branchTransactionStatus = new BranchTransactionStatus();
     $branchTransactionStatus->setTitle('Execution deprecated');
     $manager->persist($branchTransactionStatus);
     $branchTransactionStatus = new BranchTransactionStatus();
     $branchTransactionStatus->setTitle('Execution failed');
     $manager->persist($branchTransactionStatus);
     // Tools
     // Tool chain contains all tools (services with tag "chamilo_course.tool" )
     $toolChain = $this->container->get('chamilo_course.tool_chain');
     $toolChain->createTools($manager);
     // Fill the language table
     $languages = Intl::getLocaleBundle()->getLocaleNames('en');
     // @todo use this iso languages just for now
     $availableIsoCode = ['en', 'es', 'fr', 'nl', 'ru', 'de'];
     foreach ($languages as $code => $languageName) {
         if (!in_array($code, $availableIsoCode)) {
             continue;
         }
         \Locale::setDefault($code);
         $localeName = Intl::getLocaleBundle()->getLocaleName($code);
         $lang = new Language();
         $lang->setAvailable(1)->setIsocode($code)->setOriginalName($localeName)->setEnglishName($languageName);
         $manager->persist($lang);
     }
     $manager->flush();
 }