本文整理匯總了PHP中Piwik\Piwik::doAsSuperUser方法的典型用法代碼示例。如果您正苦於以下問題:PHP Piwik::doAsSuperUser方法的具體用法?PHP Piwik::doAsSuperUser怎麽用?PHP Piwik::doAsSuperUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Piwik\Piwik
的用法示例。
在下文中一共展示了Piwik::doAsSuperUser方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
// Set memory limit to off
@ini_set('memory_limit', -1);
Piwik::doAsSuperUser(function () use($input, $output) {
$settings = new MigratorSettings();
$settings->idSite = $input->getArgument('idSite');
$settings->site = $this->getSite($settings->idSite);
$settings->dateFrom = $input->getOption('date-from') ? new \DateTime($input->getOption('date-from')) : null;
$settings->dateTo = $input->getOption('date-to') ? new \DateTime($input->getOption('date-to')) : null;
$settings->skipArchiveData = $input->getOption('skip-archive-data');
$settings->skipLogData = $input->getOption('skip-log-data');
$config = Db::getDatabaseConfig();
$startTime = microtime(true);
$this->createTargetDatabaseConfig($input, $output, $config);
$tmpConfig = $config;
$sourceDb = Db::get();
try {
$targetDb = @Db\Adapter::factory($config['adapter'], $tmpConfig);
} catch (\Exception $e) {
throw new \RuntimeException('Unable to connect to the target database: ' . $e->getMessage(), 0, $e);
}
$sourceDbHelper = new DBHelper($sourceDb, Db::getDatabaseConfig());
$migratorFacade = new Migrator($sourceDbHelper, new DBHelper($targetDb, $config), GCHelper::getInstance(), $settings, new ArchiveLister($sourceDbHelper));
$migratorFacade->migrate();
$endTime = microtime(true);
Log::debug(sprintf('Time taken: %01.2f sec', $endTime - $startTime));
Log::debug(sprintf('Peak memory usage: %01.2f MB', memory_get_peak_usage(true) / 1048576));
});
}