当前位置: 首页>>代码示例>>PHP>>正文


PHP Console::startProgress方法代码示例

本文整理汇总了PHP中yii\helpers\Console::startProgress方法的典型用法代码示例。如果您正苦于以下问题:PHP Console::startProgress方法的具体用法?PHP Console::startProgress怎么用?PHP Console::startProgress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\helpers\Console的用法示例。


在下文中一共展示了Console::startProgress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 /**
  * Renders a given [[Context]].
  *
  * @param Context $context the api documentation context to render.
  * @param $targetDir
  */
 public function render($context, $targetDir)
 {
     $this->apiContext = $context;
     $this->_targetDir = $targetDir;
     $types = array_merge($context->classes, $context->interfaces, $context->traits);
     $typeCount = count($types) + 1;
     if ($this->controller !== null) {
         Console::startProgress(0, $typeCount, 'Rendering files: ', false);
     }
     $done = 0;
     foreach ($types as $type) {
         $fileContent = $this->renderWithLayout($this->typeView, ['type' => $type, 'apiContext' => $context, 'types' => $types]);
         file_put_contents($targetDir . '/' . $this->generateFileName($type->name), $fileContent);
         if ($this->controller !== null) {
             Console::updateProgress(++$done, $typeCount);
         }
     }
     $indexFileContent = $this->renderWithLayout($this->indexView, ['apiContext' => $context, 'types' => $types]);
     file_put_contents($targetDir . '/index.html', $indexFileContent);
     if ($this->controller !== null) {
         Console::updateProgress(++$done, $typeCount);
         Console::endProgress(true);
         $this->controller->stdout('done.' . PHP_EOL, Console::FG_GREEN);
     }
 }
开发者ID:136216444,项目名称:yii2-apidoc,代码行数:31,代码来源:ApiRenderer.php

示例2: render

 /**
  * @inheritDoc
  */
 public function render($files, $targetDir)
 {
     //        $types = array_merge($this->apiContext->classes, $this->apiContext->interfaces, $this->apiContext->traits);
     //
     //        $extTypes = [];
     //        foreach ($this->extensions as $k => $ext) {
     //            $extType = $this->filterTypes($types, $ext);
     //            if (empty($extType)) {
     //                unset($this->extensions[$k]);
     //                continue;
     //            }
     //            $extTypes[$ext] = $extType;
     //        }
     $fileCount = count($files) + 1;
     if ($this->controller !== null) {
         Console::startProgress(0, $fileCount, 'Rendering markdown files: ', false);
     }
     $done = 0;
     $fileData = [];
     $chapters = $this->loadGuideStructure($files);
     foreach ($files as $file) {
         $fileData[basename($file)] = file_get_contents($file);
         //            if (preg_match("/^(.*)\n=+/", $fileData[$file], $matches)) {
         //                $headlines[$file] = $matches[1];
         //            } else {
         //                $headlines[$file] = basename($file);
         //            }
     }
     $md = new ApiMarkdownLaTeX();
     $output = '';
     foreach ($chapters as $chapter) {
         if (isset($chapter['headline'])) {
             $output .= '\\chapter{' . $chapter['headline'] . "}\n";
         }
         foreach ($chapter['content'] as $content) {
             if (isset($fileData[$content['file']])) {
                 $md->labelPrefix = $content['file'] . '#';
                 $output .= '\\label{' . $content['file'] . '}';
                 $output .= $md->parse($fileData[$content['file']]) . "\n\n";
             } else {
                 $output .= '\\newpage';
                 $output .= '\\label{' . $content['file'] . '}';
                 $output .= '\\textbf{Error: not existing file: ' . $content['file'] . '}\\newpage' . "\n";
             }
             if ($this->controller !== null) {
                 Console::updateProgress(++$done, $fileCount);
             }
         }
     }
     file_put_contents($targetDir . '/guide.tex', $output);
     copy(__DIR__ . '/main.tex', $targetDir . '/main.tex');
     copy(__DIR__ . '/title.tex', $targetDir . '/title.tex');
     copy(__DIR__ . '/Makefile', $targetDir . '/Makefile');
     if ($this->controller !== null) {
         Console::updateProgress(++$done, $fileCount);
         Console::endProgress(true);
         $this->controller->stdout('done.' . PHP_EOL, Console::FG_GREEN);
     }
     echo "\nnow run `make` in {$targetDir} (you need pdflatex to compile pdf file)\n\n";
 }
开发者ID:yiisoft,项目名称:yii2-apidoc,代码行数:63,代码来源:GuideRenderer.php

示例3: processCron

 /**
  * Processes update e-mails for all users
  */
 public static function processCron($controller)
 {
     // Detect the mailing interval we're in
     $interval = 0;
     if (Yii::$app->controller->action->id == 'hourly') {
         $interval = self::INTERVAL_HOURY;
     } elseif (Yii::$app->controller->action->id == 'daily') {
         $interval = self::INTERVAL_DAILY;
     } else {
         throw new \yii\console\Exception('Invalid mail update interval!');
     }
     // Get users
     $users = User::find()->distinct()->joinWith(['httpSessions', 'profile'])->where(['user.status' => User::STATUS_ENABLED]);
     $totalUsers = $users->count();
     $processed = 0;
     Console::startProgress($processed, $totalUsers, 'Sending update e-mails to users... ', false);
     $mailsSent = 0;
     foreach ($users->each() as $user) {
         $mailSender = new self();
         $mailSender->user = $user;
         $mailSender->interval = $interval;
         if ($mailSender->send()) {
             $mailsSent++;
         }
         Console::updateProgress(++$processed, $totalUsers);
     }
     Console::endProgress(true);
     $controller->stdout('done - ' . $mailsSent . ' email(s) sent.' . PHP_EOL, Console::FG_GREEN);
     // Switch back to system language
     self::switchLanguage();
 }
开发者ID:kreativmind,项目名称:humhub,代码行数:34,代码来源:MailUpdateSender.php

示例4: generatePosts

 private function generatePosts()
 {
     $count = mt_rand(300, 500);
     Console::startProgress(0, $count, 'Generating posts: ');
     $sectionIds = (new Query())->select('id')->from('{{%section}}')->where('section_id IS NOT NULL')->column($this->getDb());
     $authorIds = (new Query())->select('id')->from('{{%user}}')->column($this->getDb());
     for ($i = 1; $i <= $count; ++$i) {
         $title = rtrim($this->getFaker()->sentence(mt_rand(3, 10)), '.');
         $this->getDb()->createCommand()->insert('{{%post}}', ['title' => $title, 'slug' => Inflector::slug($title), 'section_id' => $sectionIds[array_rand($sectionIds)], 'author_id' => $authorIds[array_rand($authorIds)], 'text' => implode("\n\n", $this->getFaker()->paragraphs(mt_rand(1, 5))), 'created_at' => time(), 'updated_at' => time()])->execute();
         Console::updateProgress($i, $count);
     }
     Console::endProgress();
 }
开发者ID:resurtm,项目名称:forum,代码行数:13,代码来源:DataController.php

示例5: getProgress

 /**
  * Returns progress closure.
  *
  * @param string $action
  * @return callable
  */
 private function getProgress($action)
 {
     $progress = false;
     return function ($processed, $total, $message = null) use($progress, $action) {
         if (!$progress) {
             Console::startProgress(0, $total, $action);
         }
         if ($message) {
             Console::endProgress($message . PHP_EOL, false);
         } else {
             Console::updateProgress($processed, $total);
         }
     };
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:20,代码来源:IndexController.php

示例6: clearAliases

 private function clearAliases($assets)
 {
     $len = count($assets);
     $message = '';
     Console::startProgress(0, $len, 'Doing Updates: ', false);
     foreach ($assets as $key => $asset) {
         $uri = Yii::getAlias($asset);
         FileHelper::removeDirectory($uri);
         FileHelper::createDirectory($uri);
         Console::updateProgress($key + 1, $len);
         $message .= 'cleared: ' . $this->ansiFormat($uri, Console::FG_GREEN) . PHP_EOL;
     }
     Console::endProgress("done." . PHP_EOL);
     echo $message;
 }
开发者ID:claudejanz,项目名称:yii2-toolbox,代码行数:15,代码来源:ClearController.php

示例7: onSubscribe

 public function onSubscribe($redis, $chan, $msg)
 {
     if ($msg === 'ready') {
         $this->post = ['s_bidnmKor' => '', 's_openDtm1' => date('Y/m/d', strtotime('-7 day')), 's_openDtm2' => date('Y/m/d'), 's_cstrtnJobGbCd' => '', 's_bidNum' => '', 'pageSpec' => 'default', 'targetRow' => 1, 'devonOrderBy' => '', 'selectednum' => ''];
         $this->pub->publish($this->channel . '-client', ['url' => self::URL, 'post' => http_build_query($this->post)]);
         return;
     }
     $html = iconv('euckr', 'utf-8//IGNORE', $msg);
     $html = strip_tags($html, '<tr><td><option>');
     $html = preg_replace('/<td[^>]*>/i', '<td>', $html);
     if (strpos($html, '한국정보인증(주)의 보안S/W를 설치중입니다') > 0) {
         return;
     }
     $p = '#<tr onclick="fn_dds_open\\(\'\\d{7}\', \'(?<subno>\\d{2})\',[^>]*>' . ' <td>(?<notinum>\\d{7})</td>' . ' <td>(?<bidtype>[^<]*)</td>' . ' <td>(?<bidcls>[^<]*)</td>' . ' <td>(?<constnm>[^<]*)</td>' . ' <td>(?<constdt>\\d{4}/\\d{2}/\\d{2} \\d{2}:\\d{2})</td>' . ' <td>(?<status>[^<]*)</td>' . ' </tr>#i';
     if (preg_match_all(str_replace(' ', '\\s*', $p), $html, $matches, PREG_SET_ORDER)) {
         foreach ($matches as $m) {
             $row = ['notinum' => trim($m['notinum']), 'subno' => trim($m['subno']), 'bidtype' => trim($m['bidtype']), 'bidcls' => trim($m['bidcls']), 'constnm' => trim($m['constnm']), 'constdt' => trim($m['constdt']), 'status' => trim($m['status'])];
             $event = new WatchEvent();
             $event->row = $row;
             $this->trigger(WatchEvent::EVENT_ROW, $event);
         }
     }
     if (preg_match('#/ (?<total_page>\\d+) 페이지\\)#', $html, $m)) {
         $total_page = intval($m['total_page']);
     }
     if (!$total_page) {
         $this->sub->close();
         throw new \Exception('total_page is null');
     }
     $page = ceil($this->post['targetRow'] / 10);
     if ($page === 1) {
         Console::startProgress(0, $total_page);
         Console::updateProgress(1, $total_page);
     } else {
         Console::updateProgress($page, $total_page);
     }
     if ($page == $total_page) {
         $this->pub->publish($this->channel . '-client', ['url' => 'close', 'post' => '']);
         $this->sub->close();
         Console::endProgress();
         return;
     } else {
         $this->post['targetRow'] += 10;
     }
     sleep(mt_rand($this->module->delay_min, $this->module->delay_max));
     $this->pub->publish($this->channel . '-client', ['url' => self::URL, 'post' => http_build_query($this->post)]);
 }
开发者ID:didwjdgks,项目名称:yii2-ebid-lh,代码行数:47,代码来源:SucWatcher.php

示例8: generateFakeData

 public function generateFakeData($num)
 {
     Console::startProgress(0, 100);
     $topic = new Topic();
     $comment = new PostComment();
     $node = new PostMeta();
     $faker = Faker\Factory::create('zh_CN');
     $nodeData = [['name' => '分享', 'alias' => '', 'parent' => 0], ['name' => '招聘', 'alias' => 'jobs', 'parent' => 1], ['name' => '瞎扯淡', 'alias' => 'booshit', 'parent' => 1], ['name' => '健康', 'alias' => 'health', 'parent' => 1], ['name' => '创业', 'alias' => 'startup', 'parent' => 1]];
     $transaction = Yii::$app->db->beginTransaction();
     try {
         for ($j = 0; $j < count($nodeData); $j++) {
             $_node = clone $node;
             $_node->setAttributes($nodeData[$j] + ['type' => 'topic_category']);
             $_node->save();
         }
         $this->execute("INSERT INTO {{%merit_template}} (`id`, `type`, `title`, `unique_id`, `method`, `event`, `action_type`, `rule_key`, `rule_value`, `increment`, `status`, `created_at`, `updated_at`) VALUES\n(1, 1, '登录', 'site/login', 2, 0, 2, 1, 1, 2, 1, 1458657160, 1458823425),\n(2, 1, '发帖', 'topic/default/create', 2, 0, 2, 0, NULL, 6, 1, 1458657218, 1458657218),\n(3, 1, '回复', 'topic/comment/create', 2, 0, 2, 0, NULL, 4, 1, 1458657251, 1458657251),\n(4, 1, '发动弹', 'tweet/default/create', 2, 0, 2, 0, NULL, 4, 1, 1458657296, 1468647701);\n");
         /** @var User $user */
         $user = User::find()->where(['role' => User::ROLE_SUPER_ADMIN])->one();
         Yii::$app->user->setIdentity($user);
         for ($i = 1; $i <= $num; $i++) {
             $_topic = clone $topic;
             $_topic->setAttributes(['type' => Topic::TYPE, 'title' => $faker->text(rand(10, 50)), 'post_meta_id' => rand(2, 4), 'status' => rand(1, 2), 'content' => $faker->text(rand(100, 2000)), 'user_id' => 1]);
             if (!$_topic->save()) {
                 throw new Exception(array_values($_topic->getFirstErrors())[0]);
             }
             for ($_i = 1; $_i <= rand(1, 20); $_i++) {
                 $_comment = clone $comment;
                 $_comment->setAttributes(['comment' => $faker->text(rand(100, 2000)), 'post_id' => $_topic->id, 'ip' => '127.0.0.1', 'user_id' => 1]);
                 if (!$_comment->save()) {
                     throw new Exception(array_values($_comment->getFirstErrors())[0]);
                 }
                 // 更新回复时间
                 $_topic->lastCommentToUpdate($user['username']);
                 // 评论计数器
                 Topic::updateAllCounters(['comment_count' => 1], ['id' => $_topic->id]);
                 // 更新个人总统计
                 UserInfo::updateAllCounters(['comment_count' => 1], ['user_id' => $_topic->user_id]);
             }
             Console::updateProgress($i / $num * 100, 100);
         }
         $transaction->commit();
     } catch (\Exception $e) {
         $transaction->rollBack();
         throw $e;
     }
     Console::endProgress();
 }
开发者ID:iiyii,项目名称:getyii,代码行数:47,代码来源:m190908_055507_init_data.php

示例9: actionGenerate

 /**
  * Generate fake data and
  */
 public function actionGenerate()
 {
     $input = $this->parseArguments(func_get_args());
     $container = new Container();
     $container->set(GeneratorInterface::class, array_merge(['class' => $this->generator_fqn], $input['generator']));
     $container->set(DbProviderInterface::class, array_merge(['class' => $this->dbprovider_fqn], $input['dbprovider']));
     $this->generator_obj = $container->get(GeneratorInterface::class);
     if (!$this->force && !$this->confirmGeneration()) {
         return;
     }
     $this->dbprovider_obj = $container->get(DbProviderInterface::class);
     Console::startProgress(0, $this->count);
     foreach ($this->dbprovider_obj->export($this->count) as $count) {
         Console::updateProgress($this->count - $count, $this->count);
     }
     Console::endProgress(true);
 }
开发者ID:miksir,项目名称:yii2-db-faker,代码行数:20,代码来源:FakerController.php

示例10: actionRun

 /**
  * Импортировать товары
  */
 public function actionRun()
 {
     $products = $this->_getProducts();
     $total = count($products);
     $this->stdout("Import products from yupe: {$total}\n", Console::BOLD);
     Console::startProgress(0, $total);
     $counter = 0;
     foreach ($products as $product) {
         //print_R($product);die;
         $counter++;
         Console::updateProgress($counter, $total);
         $name = ArrayHelper::getValue($product, 'name');
         $v3toysId = ArrayHelper::getValue($product, 'external_id');
         $this->_addProduct($product);
         //sleep(1);
     }
     Console::endProgress();
 }
开发者ID:v3toys,项目名称:skeeks,代码行数:21,代码来源:YupeImportController.php

示例11: render

 /**
  * Renders a given [[Context]].
  *
  * @param Controller $controller the apidoc controller instance. Can be used to control output.
  */
 public function render($files, $targetDir)
 {
     $this->_targetDir = $targetDir;
     $fileCount = count($files) + 1;
     if ($this->controller !== null) {
         Console::startProgress(0, $fileCount, 'Rendering markdown files: ', false);
     }
     $done = 0;
     $fileData = [];
     $headlines = [];
     foreach ($files as $file) {
         $fileData[$file] = file_get_contents($file);
         if (basename($file) == 'index.md') {
             continue;
             // to not add index file to nav
         }
         if (preg_match("/^(.*)\n=+/", $fileData[$file], $matches)) {
             $headlines[$file] = $matches[1];
         } else {
             $headlines[$file] = basename($file);
         }
     }
     foreach ($fileData as $file => $content) {
         $output = ApiMarkdown::process($content);
         // TODO generate links to yiiframework.com by default
         $output = $this->fixMarkdownLinks($output);
         if ($this->layout !== false) {
             $params = ['headlines' => $headlines, 'currentFile' => $file, 'content' => $output];
             $output = $this->getView()->renderFile($this->layout, $params, $this);
         }
         $fileName = $this->generateGuideFileName($file);
         file_put_contents($targetDir . '/' . $fileName, $output);
         if ($this->controller !== null) {
             Console::updateProgress(++$done, $fileCount);
         }
     }
     if ($this->controller !== null) {
         Console::updateProgress(++$done, $fileCount);
         Console::endProgress(true);
         $this->controller->stdout('done.' . PHP_EOL, Console::FG_GREEN);
     }
 }
开发者ID:dawei101,项目名称:plants,代码行数:47,代码来源:GuideRenderer.php

示例12: actionCity

 public function actionCity()
 {
     $this->stdout('Request API: Cities.', Console::FG_GREEN);
     $data = TravelPayoutsApi::getCities();
     $_count = count($data);
     $this->stdout(' Get: ' . $_count . ' Cities.' . PHP_EOL, Console::FG_GREEN);
     Console::startProgress(0, $_count);
     $count = 0;
     $count_ = 0;
     foreach ($data as $value) {
         $value->lon = !empty($value->coordinates->lon) ? (string) $value->coordinates->lon : '';
         $value->lat = !empty($value->coordinates->lat) ? (string) $value->coordinates->lat : '';
         $name_translations = $value->name_translations;
         unset($value->name_translations);
         unset($value->coordinates);
         $city = City::find()->where(['code' => $value->code])->one();
         if (!$city) {
             $this->stdout($value->code . ' ', Console::FG_YELLOW);
             $city = new City();
             $city->attributes = (array) $value;
             $local = ['en-GB', 'en-AU', 'en-CA', 'en-NZ', 'en-IE', 'en-SG', 'en-IN'];
             foreach ($name_translations as $_key => $_name) {
                 if (array_search($_key, $local) === false) {
                     $city['name_' . $_key] = trim($_name);
                 }
             }
             if (!$city->save()) {
                 print_r($value);
                 print_r($city->errors);
                 return Controller::EXIT_CODE_ERROR;
             }
             $count++;
         } else {
             Console::updateProgress(++$count_, $_count);
         }
     }
     Console::endProgress();
     $this->stdout(PHP_EOL . 'Added: ' . $count . ' Cities.' . PHP_EOL, Console::FG_BLUE);
     return Controller::EXIT_CODE_NORMAL;
 }
开发者ID:BeforyDeath,项目名称:tfa,代码行数:40,代码来源:ImportController.php

示例13: generateFakeData

 public function generateFakeData($num)
 {
     Console::startProgress(0, 100);
     $queston = new Question();
     $answer = new Answer();
     $faker = Faker\Factory::create('zh_CN');
     for ($i = 1; $i <= $num; $i++) {
         $_question = clone $queston;
         $_question->setAttributes(['subject' => $faker->text(rand(10, 100)), 'content' => $faker->text(rand(100, 2000)), 'author_id' => 1]);
         if ($_question->save()) {
             $_question->setActive();
             for ($_i = 1; $_i <= rand(1, 20); $_i++) {
                 $_answer = clone $answer;
                 $_answer->setAttributes(['content' => $faker->text(rand(100, 2000)), 'author_id' => 1]);
                 if ($_question->addAnswer($_answer)) {
                     $_answer->setActive();
                 }
             }
         }
         Console::updateProgress($i / $num * 100, 100);
     }
     Console::endProgress();
 }
开发者ID:rocketyang,项目名称:huajuan,代码行数:23,代码来源:m150116_154254_initQuestion.php

示例14: generateFakeData

 public function generateFakeData($num)
 {
     Console::startProgress(0, 100);
     $topic = new Topic();
     $comment = new PostComment();
     $node = new PostMeta();
     $faker = Faker\Factory::create('zh_CN');
     $nodeData = [['name' => '分享', 'alias' => '', 'parent' => 0], ['name' => '招聘', 'alias' => 'recruit', 'parent' => 1], ['name' => '瞎扯淡', 'alias' => 'booshit', 'parent' => 1], ['name' => '健康', 'alias' => 'health', 'parent' => 1], ['name' => '创业', 'alias' => 'startup', 'parent' => 1]];
     for ($j = 0; $j < count($nodeData); $j++) {
         $_node = clone $node;
         $_node->setAttributes($nodeData[$j] + ['type' => 'topic_category']);
         $_node->save();
     }
     $user = User::find()->where(['role' => User::ROLE_SUPER_ADMIN])->one();
     for ($i = 1; $i <= $num; $i++) {
         $_topic = clone $topic;
         $_topic->setAttributes(['type' => Topic::TYPE, 'title' => $faker->text(rand(10, 50)), 'post_meta_id' => rand(2, 4), 'status' => rand(1, 2), 'content' => $faker->text(rand(100, 2000)), 'user_id' => 1]);
         if (!$_topic->save()) {
             throw new Exception(array_values($_topic->getFirstErrors())[0]);
         }
         for ($_i = 1; $_i <= rand(1, 20); $_i++) {
             $_comment = clone $comment;
             $_comment->setAttributes(['comment' => $faker->text(rand(100, 2000)), 'post_id' => $_topic->id, 'ip' => '127.0.0.1', 'user_id' => 1]);
             if (!$_comment->save()) {
                 throw new Exception(array_values($_comment->getFirstErrors())[0]);
             }
             // 更新回复时间
             $_topic->lastCommentToUpdate($user['username']);
             // 评论计数器
             Topic::updateAllCounters(['comment_count' => 1], ['id' => $_topic->id]);
             // 更新个人总统计
             UserInfo::updateAllCounters(['comment_count' => 1], ['user_id' => $_topic->user_id]);
         }
         Console::updateProgress($i / $num * 100, 100);
     }
     Console::endProgress();
 }
开发者ID:grutabow,项目名称:getyii,代码行数:37,代码来源:m150908_055507_init_data.php

示例15: actionIndex

 /**
  * Renders API documentation files
  * @param array $sourceDirs
  * @param string $targetDir
  * @return int
  */
 public function actionIndex(array $sourceDirs, $targetDir)
 {
     $renderer = $this->findRenderer($this->template);
     $targetDir = $this->normalizeTargetDir($targetDir);
     if ($targetDir === false || $renderer === false) {
         return 1;
     }
     $renderer->apiUrl = './';
     $renderer->guidePrefix = $this->guidePrefix;
     if ($this->pageTitle !== null) {
         $renderer->pageTitle = $this->pageTitle;
     }
     // setup reference to guide
     if ($this->guide !== null) {
         $renderer->guideUrl = $guideUrl = $this->guide;
     } else {
         $guideUrl = './';
         $renderer->guideUrl = $targetDir;
         if (file_exists($renderer->generateGuideUrl('README.md'))) {
             $renderer->guideUrl = $guideUrl;
         } else {
             $renderer->guideUrl = null;
         }
     }
     // search for files to process
     if (($files = $this->searchFiles($sourceDirs)) === false) {
         return 1;
     }
     // load context from cache
     $context = $this->loadContext($targetDir);
     $this->stdout('Checking for updated files... ');
     foreach ($context->files as $file => $sha) {
         if (!file_exists($file)) {
             $this->stdout('At least one file has been removed. Rebuilding the context...');
             $context = new Context();
             if (($files = $this->searchFiles($sourceDirs)) === false) {
                 return 1;
             }
             break;
         }
         if (sha1_file($file) === $sha) {
             unset($files[$file]);
         }
     }
     $this->stdout('done.' . PHP_EOL, Console::FG_GREEN);
     // process files
     $fileCount = count($files);
     $this->stdout($fileCount . ' file' . ($fileCount == 1 ? '' : 's') . ' to update.' . PHP_EOL);
     Console::startProgress(0, $fileCount, 'Processing files... ', false);
     $done = 0;
     foreach ($files as $file) {
         $context->addFile($file);
         Console::updateProgress(++$done, $fileCount);
     }
     Console::endProgress(true);
     $this->stdout('done.' . PHP_EOL, Console::FG_GREEN);
     // save processed data to cache
     $this->storeContext($context, $targetDir);
     $this->updateContext($context);
     // render models
     $renderer->controller = $this;
     $renderer->render($context, $targetDir);
     if (!empty($context->errors)) {
         ArrayHelper::multisort($context->errors, 'file');
         file_put_contents($targetDir . '/errors.txt', print_r($context->errors, true));
         $this->stdout(count($context->errors) . " errors have been logged to {$targetDir}/errors.txt\n", Console::FG_RED, Console::BOLD);
     }
 }
开发者ID:tonylow,项目名称:skillslink,代码行数:74,代码来源:ApiController.php


注:本文中的yii\helpers\Console::startProgress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。