本文整理汇总了PHP中Piwik\Url::setHost方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::setHost方法的具体用法?PHP Url::setHost怎么用?PHP Url::setHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Url
的用法示例。
在下文中一共展示了Url::setHost方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$serverGlobal = $input->getOption('server-global');
if ($serverGlobal) {
$_SERVER = json_decode($serverGlobal, true);
}
$this->requireFixtureFiles($input);
$this->setIncludePathAsInTestBootstrap();
$host = Url::getHost();
if (empty($host)) {
Url::setHost('localhost');
}
$fixture = $this->createFixture($input);
$this->setupDatabaseOverrides($input, $fixture);
// perform setup and/or teardown
if ($input->getOption('teardown')) {
$fixture->getTestEnvironment()->save();
$fixture->performTearDown();
} else {
$fixture->performSetUp();
}
if ($input->getOption('set-phantomjs-symlinks')) {
$this->createSymbolicLinksForUITests();
}
$this->writeSuccessMessage($output, array("Fixture successfully setup!"));
$sqlDumpPath = $input->getOption('sqldump');
if ($sqlDumpPath) {
$this->createSqlDump($sqlDumpPath, $output);
}
}
示例2: setUp
public function setUp()
{
parent::setup();
File::reset();
Url::setHost(false);
$this->output = new Output('myid');
}
示例3: initHostAndQueryString
/**
* @param InputInterface $input
*/
protected function initHostAndQueryString(InputInterface $input)
{
$_GET = array();
$hostname = $input->getOption('piwik-domain');
Url::setHost($hostname);
$query = $input->getArgument('url-query');
$query = UrlHelper::getArrayFromQueryString($query);
foreach ($query as $name => $value) {
$_GET[$name] = $value;
}
}
示例4: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!defined('PIWIK_TEST_MODE')) {
define('PIWIK_TEST_MODE', true);
}
Environment::setGlobalEnvironmentManipulator(new TestingEnvironmentManipulator(new TestingEnvironmentVariables()));
$serverGlobal = $input->getOption('server-global');
if ($serverGlobal) {
$_SERVER = json_decode($serverGlobal, true);
}
if (Config::getInstance()->database_tests['tables_prefix'] !== '') {
throw new \Exception("To generate OmniFixture for the UI tests, you must set an empty tables_prefix in [database_tests]");
}
$this->requireFixtureFiles($input);
$this->setIncludePathAsInTestBootstrap();
$host = Url::getHost();
if (empty($host)) {
$host = 'localhost';
Url::setHost('localhost');
}
$configDomainToSave = $input->getOption('save-config');
if (!empty($configDomainToSave)) {
$pathToDomainConfig = PIWIK_INCLUDE_PATH . '/config/' . $host . '.config.ini.php';
if (!file_exists($pathToDomainConfig)) {
link(PIWIK_INCLUDE_PATH . '/config/config.ini.php', $pathToDomainConfig);
}
}
if ($input->getOption('set-phantomjs-symlinks')) {
$this->createSymbolicLinksForUITests();
}
$fixture = $this->createFixture($input, $allowSave = !empty($configDomainToSave));
$this->setupDatabaseOverrides($input, $fixture);
// perform setup and/or teardown
if ($input->getOption('teardown')) {
$fixture->getTestEnvironment()->save();
$fixture->performTearDown();
} else {
$fixture->performSetUp();
}
$this->writeSuccessMessage($output, array("Fixture successfully setup!"));
$sqlDumpPath = $input->getOption('sqldump');
if ($sqlDumpPath) {
$this->createSqlDump($sqlDumpPath, $output);
}
if (!empty($configDomainToSave)) {
Config::getInstance()->forceSave();
}
}
示例5: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$serverGlobal = $input->getOption('server-global');
if ($serverGlobal) {
$_SERVER = json_decode($serverGlobal, true);
}
$this->requireFixtureFiles($input);
$this->setIncludePathAsInTestBootstrap();
$host = Url::getHost();
if (empty($host)) {
$host = 'localhost';
Url::setHost('localhost');
}
$configDomainToSave = $input->getOption('save-config');
if (!empty($configDomainToSave)) {
$pathToDomainConfig = PIWIK_INCLUDE_PATH . '/config/' . $host . '.config.ini.php';
if (!file_exists($pathToDomainConfig)) {
link(PIWIK_INCLUDE_PATH . '/config/config.ini.php', $pathToDomainConfig);
}
}
$fixture = $this->createFixture($input);
$this->setupDatabaseOverrides($input, $fixture);
// perform setup and/or teardown
if ($input->getOption('teardown')) {
$fixture->getTestEnvironment()->save();
$fixture->performTearDown();
} else {
$fixture->performSetUp();
}
if ($input->getOption('set-phantomjs-symlinks')) {
$this->createSymbolicLinksForUITests();
}
$this->writeSuccessMessage($output, array("Fixture successfully setup!"));
$sqlDumpPath = $input->getOption('sqldump');
if ($sqlDumpPath) {
$this->createSqlDump($sqlDumpPath, $output);
}
if (!empty($configDomainToSave)) {
Config::getInstance()->forceSave();
}
}
示例6: beforeContainerCreated
public function beforeContainerCreated()
{
$this->vars->reload();
if ($this->vars->queryParamOverride) {
foreach ($this->vars->queryParamOverride as $key => $value) {
$_GET[$key] = $value;
}
}
if ($this->vars->globalsOverride) {
foreach ($this->vars->globalsOverride as $key => $value) {
$GLOBALS[$key] = $value;
}
}
if ($this->vars->hostOverride) {
\Piwik\Url::setHost($this->vars->hostOverride);
}
if ($this->vars->useXhprof) {
\Piwik\Profiler::setupProfilerXHProf($mainRun = false, $setupDuringTracking = true);
}
\Piwik\Cache\Backend\File::$invalidateOpCacheBeforeRead = true;
}
示例7: initPiwikHost
protected function initPiwikHost(InputInterface $input)
{
$piwikHostname = $input->getParameterOption('--piwik-domain');
if (empty($piwikHostname)) {
$piwikHostname = $input->getParameterOption('--url');
}
$piwikHostname = UrlHelper::getHostFromUrl($piwikHostname);
Url::setHost($piwikHostname);
}
示例8: getPiwikDomain
define('PIWIK_ENABLE_SESSION_START', false);
require_once PIWIK_INCLUDE_PATH . "/index.php";
if (!Common::isPhpCliMode()) {
return;
}
$testmode = in_array('--testmode', $_SERVER['argv']);
if ($testmode) {
define('PIWIK_TEST_MODE', true);
Environment::setGlobalEnvironmentManipulator(new TestingEnvironmentManipulator(new TestingEnvironmentVariables()));
}
function getPiwikDomain()
{
foreach ($_SERVER['argv'] as $param) {
$pattern = '--piwik-domain=';
if (false !== strpos($param, $pattern)) {
return substr($param, strlen($pattern));
}
}
return null;
}
$environment = new Environment('cli');
$environment->init();
$piwikDomain = getPiwikDomain();
if ($piwikDomain) {
Url::setHost($piwikDomain);
}
$token = Db::get()->fetchOne("SELECT token_auth\n FROM " . Common::prefixTable("user") . "\n WHERE superuser_access = 1\n ORDER BY date_registered ASC");
$filename = $environment->getContainer()->get('path.tmp') . '/cache/token.php';
$content = "<?php exit; //\t" . $token;
file_put_contents($filename, $content);
echo $filename;
示例9: initConfigObject
/**
* Checks the config file is found.
*
* @param $piwikUrl
* @throws Exception
*/
protected function initConfigObject($piwikUrl)
{
// HOST is required for the Config object
$parsed = parse_url($piwikUrl);
Url::setHost($parsed['host']);
Config::getInstance()->clear();
try {
Config::getInstance()->checkLocalConfigFound();
} catch (Exception $e) {
throw new Exception("The configuration file for Piwik could not be found. " . "Please check that config/config.ini.php is readable by the user " . get_current_user());
}
}
示例10: setUp
public function setUp()
{
\Piwik\Url::setHost(false);
$this->output = new Output('myid');
}
示例11: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$serverGlobal = $input->getOption('server-global');
if ($serverGlobal) {
$_SERVER = json_decode($serverGlobal, true);
}
$this->requireFixtureFiles();
$this->setIncludePathAsInTestBootstrap();
$file = $input->getOption('file');
if ($file) {
if (is_file($file)) {
require_once $file;
} else {
if (is_file(PIWIK_INCLUDE_PATH . '/' . $file)) {
require_once PIWIK_INCLUDE_PATH . '/' . $file;
} else {
throw new \Exception("Cannot find --file option file '{$file}'.");
}
}
}
$host = Url::getHost();
if (empty($host)) {
Url::setHost('localhost');
}
// get the fixture class
$fixtureClass = $input->getArgument('fixture');
if (class_exists("Piwik\\Tests\\Fixtures\\" . $fixtureClass)) {
$fixtureClass = "Piwik\\Tests\\Fixtures\\" . $fixtureClass;
}
if (!class_exists($fixtureClass)) {
throw new \Exception("Cannot find fixture class '{$fixtureClass}'.");
}
// create the fixture
$fixture = new $fixtureClass();
$fixture->printToScreen = true;
$dbName = $input->getOption('db-name');
if ($dbName) {
$fixture->dbName = $dbName;
}
if ($input->getOption('persist-fixture-data')) {
$fixture->persistFixtureData = true;
}
if ($input->getOption('drop')) {
$fixture->resetPersistedFixture = true;
}
$extraPluginsToLoad = $input->getOption('plugins');
if ($extraPluginsToLoad) {
$fixture->extraPluginsToLoad = explode(',', $extraPluginsToLoad);
}
if ($fixture->createConfig) {
Config::getInstance()->setTestEnvironment();
}
$fixture->createConfig = false;
// setup database overrides
$testingEnvironment = $fixture->getTestEnvironment();
$optionsToOverride = array('dbname' => $fixture->getDbName(), 'host' => $input->getOption('db-host'), 'user' => $input->getOption('db-user'), 'password' => $input->getOption('db-pass'));
foreach ($optionsToOverride as $configOption => $value) {
if ($value) {
$configOverride = $testingEnvironment->configOverride;
$configOverride['database_tests'][$configOption] = $configOverride['database'][$configOption] = $value;
$testingEnvironment->configOverride = $configOverride;
Config::getInstance()->database[$configOption] = $value;
}
}
// perform setup and/or teardown
if ($input->getOption('teardown')) {
$testingEnvironment->save();
$fixture->performTearDown();
} else {
$fixture->performSetUp();
}
if ($input->getOption('set-phantomjs-symlinks')) {
// make sure symbolic links exist (phantomjs doesn't support symlink-ing yet)
foreach (array('libs', 'plugins', 'tests', 'piwik.js') as $linkName) {
$linkPath = PIWIK_INCLUDE_PATH . '/tests/PHPUnit/proxy/' . $linkName;
if (!file_exists($linkPath)) {
symlink(PIWIK_INCLUDE_PATH . '/' . $linkName, $linkPath);
}
}
}
$this->writeSuccessMessage($output, array("Fixture successfully setup!"));
}