translator === null) { $this->translator = Translator::getInstance(); } return $this->translator->trans($id, $parameters, self::MESSAGE_DOMAIN, $locale); } public function postActivation(ConnectionInterface $con = null) { try { GameQuery::create()->findOne(); QuestionQuery::create()->findOne(); AnswerQuery::create()->findOne(); ParticipateQuery::create()->findOne(); } catch (\Exception $e) { $database = new Database($con); $database->insertSql(null, [__DIR__ . "/Config/create.sql", __DIR__ . "/Config/insert.sql"]); } //MAIL DECLARATION $this->declareMessage(self::MESSAGE_WIN, 'You win', 'You win'); $this->declareMessage(self::MESSAGE_FRIEND, 'You get invited to a game', 'You get invited to a game'); //OPTION INIT $this->initOption(self::WIN_OPTION,true); $this->initOption(self::CONNECT_OPTION,false); $this->initOption(self::FRIEND_OPTION,false); $this->initOption(self::FRIEND_MAX_OPTION,5); $this->initOption(self::MAX_PARTICIPATE_OPTION,1); } protected function declareMessage($name, $subject, $title) { $languages = LangQuery::create()->find(); if (null === MessageQuery::create()->findOneByName($name)) { $message = new Message(); $message ->setName($name) ->setHtmlLayoutFileName('') ->setHtmlTemplateFileName($name . '.html') ->setTextLayoutFileName('') ->setTextTemplateFileName($name . '.txt'); foreach ($languages as $language) { /** @var Lang $language */ $locale = $language->getLocale(); $message->setLocale($locale); $message->setTitle( $this->trans($title, $locale) ); $message->setSubject( $this->trans($subject, $locale) ); } $message->save(); } } protected function initOption($name, $value) { if (!$this->getConfigValue($name)) { $this->setConfigValue($name, $value); } } }