本文整理汇总了PHP中Piwik\Option::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Option::get方法的具体用法?PHP Option::get怎么用?PHP Option::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Option
的用法示例。
在下文中一共展示了Option::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testWebArchiving
public function testWebArchiving()
{
if (self::isMysqli() && self::isTravisCI()) {
$this->markTestSkipped('Skipping on Mysqli as it randomly fails.');
}
$host = Fixture::getRootUrl();
$token = Fixture::getTokenAuth();
$urlTmp = Option::get('piwikUrl');
Option::set('piwikUrl', $host . 'tests/PHPUnit/proxy/index.php');
$url = $host . 'tests/PHPUnit/proxy/archive.php?token_auth=' . $token;
$output = Http::sendHttpRequest($url, 600);
// ignore random build issues
if (empty($output) || strpos($output, \Piwik\CronArchive::NO_ERROR) === false) {
$message = "This test has failed. Because it sometimes randomly fails, we skip the test, and ignore this failure.\n";
$message .= "If you see this message often, or in every build, please investigate as this should only be a random and rare occurence!\n";
$message .= "\n\narchive web failed: " . $output . "\n\nurl used: {$url}";
$this->markTestSkipped($message);
}
if (!empty($urlTmp)) {
Option::set('piwikUrl', $urlTmp);
} else {
Option::delete('piwikUrl');
}
$this->assertContains('Starting Piwik reports archiving...', $output);
$this->assertContains('Archived website id = 1', $output);
$this->assertContains('Done archiving!', $output);
$this->compareArchivePhpOutputAgainstExpected($output);
}
示例2: setUpBeforeClass
public static function setUpBeforeClass()
{
$dbName = false;
if (!empty($GLOBALS['PIWIK_BENCHMARK_DATABASE'])) {
$dbName = $GLOBALS['PIWIK_BENCHMARK_DATABASE'];
}
// connect to database
self::createTestConfig();
self::connectWithoutDatabase();
// create specified fixture (global var not set, use default no-data fixture (see end of this file))
if (empty($GLOBALS['PIWIK_BENCHMARK_FIXTURE'])) {
$fixtureName = 'Piwik_Test_Fixture_EmptyOneSite';
} else {
$fixtureName = 'Piwik_Test_Fixture_' . $GLOBALS['PIWIK_BENCHMARK_FIXTURE'];
}
self::$fixture = new $fixtureName();
// figure out if the desired fixture has already been setup, and if not empty the database
$installedFixture = false;
try {
if (isset(self::$fixture->tablesPrefix)) {
Config::getInstance()->database['tables_prefix'] = self::$fixture->tablesPrefix;
}
Db::query("USE " . $dbName);
$installedFixture = \Piwik\Option::get('benchmark_fixture_name');
} catch (Exception $ex) {
// ignore
}
$createEmptyDatabase = $fixtureName != $installedFixture;
parent::_setUpBeforeClass($dbName, $createEmptyDatabase);
// if we created an empty database, setup the fixture
if ($createEmptyDatabase) {
self::$fixture->setUp();
\Piwik\Option::set('benchmark_fixture_name', $fixtureName);
}
}
示例3: index
public function index()
{
Piwik::checkUserHasSuperUserAccess();
$view = new View('@TasksTimetable/index.twig');
$this->setGeneralVariablesView($view);
$tasks = Option::get('TaskScheduler.timetable');
if (!empty($tasks)) {
$tasks = unserialize($tasks);
}
if (empty($tasks)) {
$tasks = array();
} else {
asort($tasks);
}
$tsNow = Date::now()->getTimestamp();
$dateFormat = Piwik::translate(Date::DATE_FORMAT_LONG) . ' h:mm:ss';
$formatter = new Formatter();
$tasksFormatted = array();
foreach ($tasks as $name => $timestamp) {
$tasksFormatted[] = array('name' => $name, 'executionDate' => Date::factory($timestamp)->getLocalized($dateFormat), 'ts_difference' => $formatter->getPrettyTimeFromSeconds($timestamp - $tsNow));
}
$view->currentTime = Date::now()->getLocalized($dateFormat);
$view->tasks = $tasksFormatted;
return $view->render();
}
示例4: test_rememberToInvalidateArchivedReportsLater_shouldCreateAnEntryInCaseThereIsNoneYet
public function test_rememberToInvalidateArchivedReportsLater_shouldCreateAnEntryInCaseThereIsNoneYet()
{
$key = 'report_to_invalidate_2_2014-04-05';
$this->assertFalse(Option::get($key));
$this->rememberReport(2, '2014-04-05');
$this->assertSame('1', Option::get($key));
}
示例5: testMarkComponentSuccessfullyUninstalled_ShouldCreateAnOptionEntry
/**
* @depends testMarkComponentSuccessfullyUpdated_ShouldCreateAnOptionEntry
*/
public function testMarkComponentSuccessfullyUninstalled_ShouldCreateAnOptionEntry()
{
$updater = $this->createUpdater();
$updater->markComponentSuccessfullyUninstalled('test_entry');
$value = Option::get('version_test_entry');
$this->assertFalse($value);
}
示例6: isNewestVersionAvailable
/**
* Returns version number of a newer Piwik release.
*
* @return string|bool false if current version is the latest available,
* or the latest version number if a newest release is available
*/
public static function isNewestVersionAvailable()
{
$latestVersion = Option::get(self::LATEST_VERSION);
if (!empty($latestVersion) && version_compare(Version::VERSION, $latestVersion) == -1) {
return $latestVersion;
}
return false;
}
示例7: getAllSiteIdsToArchive
public function getAllSiteIdsToArchive()
{
Option::clearCachedOption('SharedSiteIdsToArchive');
$siteIdsToArchive = Option::get('SharedSiteIdsToArchive');
if (empty($siteIdsToArchive)) {
return array();
}
return explode(',', trim($siteIdsToArchive));
}
示例8: migratePluginEmailUpdateSetting
private function migratePluginEmailUpdateSetting()
{
$isEnabled = Option::get('enableUpdateCommunicationPlugins');
Access::doAsSuperUser(function () use($isEnabled) {
$settings = StaticContainer::get('Piwik\\Plugins\\CoreUpdater\\SystemSettings');
$settings->sendPluginUpdateEmail->setValue(!empty($isEnabled));
$settings->save();
});
}
示例9: test_UpdateCommand_DoesNotExecuteUpdate_IfPiwikUpToDate
public function test_UpdateCommand_DoesNotExecuteUpdate_IfPiwikUpToDate()
{
Option::set('version_core', Version::VERSION);
$result = $this->applicationTester->run(array('command' => 'core:update', '--yes' => true));
$this->assertEquals(0, $result, $this->getCommandDisplayOutputErrorMessage());
// check no update occurred
$this->assertContains("Everything is already up to date.", $this->applicationTester->getDisplay());
$this->assertEquals(Version::VERSION, Option::get('version_core'));
}
示例10: updateIPAnonymizationSettings
private static function updateIPAnonymizationSettings()
{
$optionName = 'PrivacyManager.ipAnonymizerEnabled';
$value = Option::get($optionName);
if ($value !== false) {
// If the config is defined, nothing to do
return;
}
// We disable IP anonymization if it wasn't configured (because by default it has gone from disabled to enabled)
Option::set($optionName, '0');
}
示例11: rememberToInvalidateArchivedReportsLater
public function rememberToInvalidateArchivedReportsLater($idSite, Date $date)
{
$key = $this->buildRememberArchivedReportId($idSite, $date->toString());
$value = Option::get($key);
// we do not really have to get the value first. we could simply always try to call set() and it would update or
// insert the record if needed but we do not want to lock the table (especially since there are still some
// MyISAM installations)
if (false === $value) {
Option::set($key, '1');
}
}
示例12: getFromOption
private function getFromOption($name, $config)
{
$name = $this->prefix($name);
$value = Option::get($name);
if (false !== $value) {
settype($value, $config['type']);
} else {
$value = $config['default'];
}
return $value;
}
示例13: test_getAll_ReturnsValueInOption_IfOptionCacheHasSeparateValue
public function test_getAll_ReturnsValueInOption_IfOptionCacheHasSeparateValue()
{
// get option so cache is loaded
Option::get(self::TEST_OPTION_NAME);
// set option value to something else
$newList = array('1', '2', '3');
$this->initOptionValue($newList);
// test option is now different
$list = $this->distributedList->getAll();
$this->assertEquals($newList, $list);
}
示例14: getCurrentRecordedComponentVersion
/**
* Retrieve the current version of a recorded component
* @param string $name
* @return false|string
* @throws \Exception
*/
public static function getCurrentRecordedComponentVersion($name)
{
try {
$currentVersion = Option::get(self::getNameInOptionTable($name));
} catch (\Exception $e) {
// mysql error 1146: table doesn't exist
if (Db::get()->isErrNo($e, '1146')) {
// case when the option table is not yet created (before 0.2.10)
$currentVersion = false;
} else {
// failed for some other reason
throw $e;
}
}
return $currentVersion;
}
示例15: loadSpammerList
private function loadSpammerList()
{
if ($this->spammerList !== null) {
return $this->spammerList;
}
// Read first from the auto-updated list in database
$list = Option::get(self::OPTION_STORAGE_NAME);
if ($list) {
$this->spammerList = unserialize($list);
} else {
// Fallback to reading the bundled list
$file = PIWIK_VENDOR_PATH . '/piwik/referrer-spam-blacklist/spammers.txt';
$this->spammerList = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
}
return $this->spammerList;
}