Exemplo n.º 1
0
 /**
  * Creates all needed classes and fills them with random data
  */
 public function installAction()
 {
     Time::check();
     $this->createTables();
     Console::getInstance()->writeLine('Tables created in ' . Time::check() . ' sec.');
     $pupilService = $this->getPupilService();
     $count = $this->generateItems($pupilService, $this->getRequest()->getParam('pupils', 100000), ['email', 'birthday'], function ($item) {
         return ['name' => $item['full'], 'email' => $item['email'], 'birthday' => $item['birthday'], 'level' => \Application\Entity\Pupil::$levels[rand(0, 5)]];
     });
     Console::getInstance()->writeLine($count . ' pupils generated in ' . Time::check() . ' sec.');
     $teachersCount = $this->getRequest()->getParam('teachers', 10000);
     $teacherService = $this->getTeacherService();
     $this->generateItems($teacherService, $teachersCount, ['phone'], function ($item) {
         $gender = $item['gender'] === \NameGenerator\Gender::GENDER_MALE ? TeacherEntity::GENDER_MALE : TeacherEntity::GENDER_FEMALE;
         return ['gender' => $gender, 'name' => $item['full'], 'phone' => $item['phone']];
     });
     Console::getInstance()->writeLine($teachersCount . ' teachers generated in ' . Time::check() . ' sec.');
     $pupilMaxId = $pupilService->getMaxId();
     $teacherMaxId = $teacherService->getMaxId();
     $teacherPupilService = $this->getTeacherPupilService();
     $linksCount = 0;
     for ($teacherId = 1; $teacherId < $teacherMaxId; $teacherId++) {
         $except = [];
         for ($j = 0; $j < rand(0, 3); $j++) {
             $pupil_id = rand(0, $pupilMaxId);
             if (in_array($pupil_id, $except)) {
                 continue;
             }
             $except[] = $pupil_id;
             $teacherPupilService->insert(['teacher_id' => $teacherId, 'pupil_id' => $pupil_id]);
             $linksCount++;
         }
     }
     Console::getInstance()->writeLine($linksCount . ' links generated in ' . Time::check() . ' sec.');
 }
Exemplo n.º 2
0
 /**
  * Init object
  */
 public function __construct()
 {
     $this->_sender = $this->_getSender();
     $this->_recipients = [['email' => '*****@*****.**', 'name' => 'test']];
     $this->_messageSubject = 'Letual products ' . Time::getDateAndTime(Time::DATE_FORMAT_FOR_MAIL_SUBJECT);
     $this->_messageText = 'See attached file';
 }
Exemplo n.º 3
0
 /**
  * Init object
  */
 public function __construct()
 {
     $this->_filePath = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Export' . DIRECTORY_SEPARATOR . 'letual_products_' . Time::getDateAndTime(Time::DATE_FORMAT_FOR_FILE);
     $this->_lineHeaders = ['Бренд', 'Артикул', 'Название', 'Цена от', 'Цена до', 'В корзину', 'Предзаказ', 'Ограниченное количество'];
 }
Exemplo n.º 4
0
 /**
  * Get line
  *
  * @param null       $prefix   Prefix
  * @param string     $value    Value
  * @param bool|false $lastLine Is last line
  *
  * @return string
  */
 public function getLine($prefix = null, $value = null, $lastLine = false)
 {
     if (is_null($value)) {
         $value = Time::getDateAndTime();
     }
     $line = $prefix . ' ' . $value . "\n";
     if ($lastLine) {
         $line .= "\n";
     }
     return $line;
 }