Exemple #1
0
 public function onEvent(GenericEvent $event, $eventName, $uid)
 {
     switch ($eventName) {
         case 'user.created':
             $this->domain_manager->joinDomainById($uid, DomainUtil::getGlobalDomainId());
             break;
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // 导入题目模板
     $output->writeln('Importing problem template...');
     $template = file_get_contents(__DIR__ . '/data/problem-template.md');
     Application::coll('System')->update(['_id' => 'ProblemTemplate'], ['$set' => ['markdown' => $template]], ['upsert' => true]);
     // 创建全局域
     $output->writeln('Creating global domain...');
     try {
         $doc = ['_id' => DomainUtil::getGlobalDomainId(), 'name' => 'OpenVJ', 'owner' => VJ::USER_ID_SYSTEM, 'at' => new \MongoDate()];
         Application::coll('Domain')->insert($doc);
     } catch (\Exception $e) {
     }
     // 导入关键字
     $this->importKeyword($output, 'keywords-general-base64.txt', 'general');
     $this->importKeyword($output, 'keywords-name-base64.txt', 'name');
 }