• Модуль: translate
  • Путь к файлу: ~/bitrix/modules/translate/lib/cli/indexcommand.php
  • Класс: BitrixTranslateCliIndexCommand
  • Вызов: IndexCommand::execute
protected function execute(ConsoleInputInputInterface $input, ConsoleOutputOutputInterface $output)
{
	$vn = ($output->getVerbosity() > ConsoleOutputOutputInterface::VERBOSITY_QUIET);
	$vv = ($output->getVerbosity() >= ConsoleOutputOutputInterface::VERBOSITY_VERY_VERBOSE);

	$path = $input->getOption('path');

	if ($vn)
	{
		$startTime = microtime(true);
		$memoryBefore = memory_get_usage();
		$output->writeln('--------Translate::index-----------');
		$output->writeln("Indexing path: {$path}");
	}

	$filt = new TranslateFilter([
		'path' => $path
	]);

	//-----------------
	// lang folders
	$pathLang = new TranslateIndexPathLangCollection();
	if ($vn)
	{
		$pathLang::$verbose = $vv;
		$output->write("PathLangCollection::purge..");
	}

	$pathLang->purge($filt);

	if ($vn)
	{
		$time = round(microtime(true) - $startTime, 2);
		$output->writeln("tdonet{$time}sec");
		$output->write("PathLangCollection::collect..");
	}

	$pathLang->collect($filt);

	if ($vn)
	{
		$time = round(microtime(true) - $startTime, 2);
		$output->writeln("tdonet{$time}sec");
	}

	//-----------------
	// path structure
	$pathIndex = new TranslateIndexPathIndexCollection();
	if ($vn)
	{
		$pathIndex::$verbose = $vv;
		$output->write("PathIndexCollection::purge..");
	}

	$pathIndex->purge($filt)->unvalidate($filt);
	if ($vn)
	{
		$time = round(microtime(true) - $startTime, 2);
		$output->writeln("tdonet{$time}sec");
		$output->write("PathIndexCollection::collect..");
	}

	$pathIndex->collect($filt);

	if ($vn)
	{
		$time = round(microtime(true) - $startTime, 2);
		$output->writeln("tdonet{$time}sec");
	}

	//-----------------
	// lang files
	$fileIndex = new TranslateIndexFileIndexCollection();
	if ($vn)
	{
		$fileIndex::$verbose = $vv;
		$output->write("FileIndexCollection::collect..");
	}

	$fileIndex->collect($filt);

	if ($vn)
	{
		$time = round(microtime(true) - $startTime, 2);
		$output->writeln("tdonet{$time}sec");
	}

	//-----------------
	// phrases
	$phraseIndex = new TranslateIndexPhraseIndexCollection();
	if ($vn)
	{
		$phraseIndex::$verbose = $vv;
		$output->write("PhraseIndexCollection::collect..");
	}

	$phraseIndex->collect($filt);
	$pathIndex->validate($filt, false);

	if ($vn)
	{
		// summary stats
		$time = round(microtime(true) - $startTime, 2);
		$output->writeln("tdonet{$time}sec");

		$memoryAfter = memory_get_usage();
		$memoryDiff = $memoryAfter - $memoryBefore;
		$output->writeln('Memory usage: '.(round($memoryAfter/1024/1024, 1)).'M (+'.(round($memoryDiff/1024/1024, 1)).'M)');
		$output->writeln('Memory peak usage: '.(round(memory_get_peak_usage()/1024/1024, 1)).'M');
	}

	return 0;
}