本文整理汇总了PHP中Piwik\Container\StaticContainer::get方法的典型用法代码示例。如果您正苦于以下问题:PHP StaticContainer::get方法的具体用法?PHP StaticContainer::get怎么用?PHP StaticContainer::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Container\StaticContainer
的用法示例。
在下文中一共展示了StaticContainer::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
// Replace this with dependency injection once available
/** @var DiagnosticService $diagnosticService */
$diagnosticService = StaticContainer::get('Piwik\\Plugins\\Diagnostics\\DiagnosticService');
$showAll = $input->getOption('all');
$report = $diagnosticService->runDiagnostics();
foreach ($report->getAllResults() as $result) {
$items = $result->getItems();
if (!$showAll && $result->getStatus() === DiagnosticResult::STATUS_OK) {
continue;
}
if (count($items) === 1) {
$output->writeln($result->getLabel() . ': ' . $this->formatItem($items[0]), OutputInterface::OUTPUT_PLAIN);
continue;
}
$output->writeln($result->getLabel() . ':');
foreach ($items as $item) {
$output->writeln("\t- " . $this->formatItem($item), OutputInterface::OUTPUT_PLAIN);
}
}
if ($report->hasWarnings()) {
$output->writeln(sprintf('<comment>%d warnings detected</comment>', $report->getWarningCount()));
}
if ($report->hasErrors()) {
$output->writeln(sprintf('<error>%d errors detected</error>', $report->getErrorCount()));
return 1;
}
return 0;
}
示例2: configureSegments
protected function configureSegments()
{
$idSite = Common::getRequestVar('idSite', 0, 'int');
if (empty($idSite)) {
return array();
}
$configuration = StaticContainer::get('Piwik\\Plugins\\CustomDimensions\\Dao\\Configuration');
$dimensions = $configuration->getCustomDimensionsForSite($idSite);
foreach ($dimensions as $dimension) {
if (!$dimension['active']) {
continue;
}
$segment = new Segment();
$segment->setSegment(CustomDimensionsRequestProcessor::buildCustomDimensionTrackingApiName($dimension));
$segment->setType(Segment::TYPE_DIMENSION);
$segment->setName($dimension['name']);
$columnName = LogTable::buildCustomDimensionColumnName($dimension);
if ($dimension['scope'] === CustomDimensions::SCOPE_ACTION) {
$segment->setSqlSegment('log_link_visit_action. ' . $columnName);
$segment->setCategory('General_Actions');
$segment->setSuggestedValuesCallback(function ($idSite, $maxValuesToReturn) use($dimension) {
$autoSuggest = new AutoSuggest();
return $autoSuggest->getMostUsedActionDimensionValues($dimension, $idSite, $maxValuesToReturn);
});
} elseif ($dimension['scope'] === CustomDimensions::SCOPE_VISIT) {
$segment->setSqlSegment('log_visit. ' . $columnName);
$segment->setCategory('General_Visit');
} else {
continue;
}
$this->addSegment($segment);
}
}
示例3: __construct
/**
* Constructor.
*
* @param string|null $serverHostName The hostname of the LDAP server. If not null, an attempt
* to connect is made.
* @param int $port The server port to use.
* @throws Exception if a connection is attempted and it fails.
*/
public function __construct($serverHostName = null, $port = ServerInfo::DEFAULT_LDAP_PORT, $timeout = self::DEFAULT_TIMEOUT_SECS, LoggerInterface $logger = null)
{
$this->logger = $logger ?: StaticContainer::get('Psr\\Log\\LoggerInterface');
if (!empty($serverHostName)) {
$this->connect($serverHostName, $port, $timeout);
}
}
示例4: triggerWebtreesAdminTasks
public function triggerWebtreesAdminTasks()
{
$settings = new Settings();
$this->logger = \Piwik\Container\StaticContainer::get('Psr\\Log\\LoggerInterface');
$this->logger->info('Webtrees Admin Task triggered');
$rooturl = $settings->getSetting('webtreesRootUrl');
if (!$rooturl || strlen($rooturl->getValue()) === 0) {
return;
}
$token = $settings->getSetting('webtreesToken');
if (!$token || strlen($token->getValue()) === 0) {
return;
}
$taskname = $settings->getSetting('webtreesTaskName');
if (!$taskname || strlen($taskname->getValue()) === 0) {
return;
}
$url = sprintf('%1$s/module.php?mod=perso_admintasks&mod_action=trigger&force=%2$s&task=%3$s', $rooturl->getValue(), $token->getValue(), $taskname->getValue());
$this->logger->info('webtrees url : {url}', array('url' => $url));
try {
\Piwik\Http::sendHttpRequest($url, Webtrees::SOCKET_TIMEOUT);
} catch (Exception $e) {
$this->logger->warning('an error occured', array('exception' => $e));
}
}
示例5: __construct
/**
* Constructor.
*
* @param string $name The persisted name of the setting.
* @param mixed $defaultValue Default value for this setting if no value was specified.
* @param string $type Eg an array, int, ... see TYPE_* constants
* @param string $pluginName The name of the plugin the setting belongs to
* @param int $idSite The idSite this setting belongs to.
*/
public function __construct($name, $defaultValue, $type, $pluginName, $idSite)
{
parent::__construct($name, $defaultValue, $type, $pluginName);
$this->idSite = $idSite;
$storageFactory = StaticContainer::get('Piwik\\Settings\\Storage\\Factory');
$this->storage = $storageFactory->getMeasurableSettingsStorage($idSite, $this->pluginName);
}
示例6: test_removeFile_shouldRemoveFile
public function test_removeFile_shouldRemoveFile()
{
$tmpFile = StaticContainer::get('path.tmp') . '/filesystem-test-file';
touch($tmpFile);
Filesystem::remove($tmpFile);
$this->assertFileNotExists($tmpFile);
}
示例7: isValid
/**
* Validates the given translations
* * There need to be more than 250 translations present
* * Locale and TranslatorName needs to be set in plugin General
* * Locale must be valid (format, language & country)
*
* @param array $translations
*
* @return boolean
*/
public function isValid($translations)
{
$this->message = null;
if (empty($translations['General']['Locale'])) {
$this->message = self::ERRORSTATE_LOCALEREQUIRED;
return false;
}
if (empty($translations['General']['TranslatorName'])) {
$this->message = self::ERRORSTATE_TRANSLATORINFOREQUIRED;
return false;
}
/** @var LanguageDataProvider $languageDataProvider */
$languageDataProvider = StaticContainer::get('Piwik\\Intl\\Data\\Provider\\LanguageDataProvider');
/** @var RegionDataProvider $regionDataProvider */
$regionDataProvider = StaticContainer::get('Piwik\\Intl\\Data\\Provider\\RegionDataProvider');
$allLanguages = $languageDataProvider->getLanguageList();
$allCountries = $regionDataProvider->getCountryList();
if (!preg_match('/^([a-z]{2})_([A-Z]{2})\\.UTF-8$/', $translations['General']['Locale'], $matches)) {
$this->message = self::ERRORSTATE_LOCALEINVALID;
return false;
} else {
if (!array_key_exists($matches[1], $allLanguages)) {
$this->message = self::ERRORSTATE_LOCALEINVALIDLANGUAGE;
return false;
} else {
if (!array_key_exists(strtolower($matches[2]), $allCountries)) {
$this->message = self::ERRORSTATE_LOCALEINVALIDCOUNTRY;
return false;
}
}
}
return true;
}
示例8: ApiRequestAuthenticate
/**
* Set login name and authentication token for API request.
* Listens to API.Request.authenticate hook.
*/
public function ApiRequestAuthenticate($tokenAuth)
{
/** @var \Piwik\Auth $auth */
$auth = StaticContainer::get('Piwik\\Auth');
$auth->setLogin($login = null);
$auth->setTokenAuth($tokenAuth);
}
示例9: addOptOutStyles
/**
* @throws \Exception
*/
public function addOptOutStyles()
{
/** @var \Piwik\Plugins\CoreAdminHome\OptOutManager $manager */
$manager = StaticContainer::get('Piwik\\Plugins\\CoreAdminHome\\OptOutManager');
// See Issue #33
$siteId = Common::getRequestVar('idsite', 0, 'integer');
// Is still available for BC
if (!$siteId) {
$siteId = Common::getRequestVar('idSite', 0, 'integer');
}
// Try to find siteId in Session
if (!$siteId) {
return;
}
$site = API::getInstance()->getSiteDataId($siteId);
if (!$site) {
return;
}
$manager->addQueryParameter('idsite', $siteId);
// Add CSS file if set
if (!empty($site['custom_css_file'])) {
$manager->addStylesheet($site['custom_css_file'], false);
}
// Add CSS Inline Styles if set
if (!empty($site['custom_css'])) {
$manager->addStylesheet($site['custom_css'], true);
}
}
示例10: __construct
public function __construct()
{
$this->requestProcessors = StaticContainer::get('tracker.request.processors');
$this->visitorRecognizer = StaticContainer::get('Piwik\\Tracker\\VisitorRecognizer');
$this->visitProperties = null;
$this->userSettings = StaticContainer::get('Piwik\\Tracker\\Settings');
}
示例11: setUp
public function setUp()
{
parent::setUp();
/** @var PluginManager $manager */
$manager = StaticContainer::get('Piwik\\Plugin\\Manager');
$manager->loadPlugins(array('Events', 'Contents'));
}
示例12: tableInsertBatch
/**
* Performs a batch insert into a specific table using either LOAD DATA INFILE or plain INSERTs,
* as a fallback. On MySQL, LOAD DATA INFILE is 20x faster than a series of plain INSERTs.
*
* @param string $tableName PREFIXED table name! you must call Common::prefixTable() before passing the table name
* @param array $fields array of unquoted field names
* @param array $values array of data to be inserted
* @param bool $throwException Whether to throw an exception that was caught while trying
* LOAD DATA INFILE, or not.
* @throws Exception
* @return bool True if the bulk LOAD was used, false if we fallback to plain INSERTs
*/
public static function tableInsertBatch($tableName, $fields, $values, $throwException = false)
{
$filePath = StaticContainer::get('path.tmp') . '/assets/' . $tableName . '-' . Common::generateUniqId() . '.csv';
$loadDataInfileEnabled = Config::getInstance()->General['enable_load_data_infile'];
if ($loadDataInfileEnabled && Db::get()->hasBulkLoader()) {
try {
$fileSpec = array('delim' => "\t", 'quote' => '"', 'escape' => '\\\\', 'escapespecial_cb' => function ($str) {
return str_replace(array(chr(92), chr(34)), array(chr(92) . chr(92), chr(92) . chr(34)), $str);
}, 'eol' => "\r\n", 'null' => 'NULL');
// hack for charset mismatch
if (!DbHelper::isDatabaseConnectionUTF8() && !isset(Config::getInstance()->database['charset'])) {
$fileSpec['charset'] = 'latin1';
}
self::createCSVFile($filePath, $fileSpec, $values);
if (!is_readable($filePath)) {
throw new Exception("File {$filePath} could not be read.");
}
$rc = self::createTableFromCSVFile($tableName, $fields, $filePath, $fileSpec);
if ($rc) {
unlink($filePath);
return true;
}
} catch (Exception $e) {
if ($throwException) {
throw $e;
}
}
}
// if all else fails, fallback to a series of INSERTs
@unlink($filePath);
self::tableInsertBatchIterate($tableName, $fields, $values);
return false;
}
示例13: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$path = StaticContainer::get('path.tmp') . '/logs/';
$cmd = sprintf('tail -f %s*.log', $path);
$output->writeln('Executing command: ' . $cmd);
passthru($cmd);
}
示例14: configure
public static function configure(WidgetConfig $config)
{
$config->setCategoryId('About Piwik');
$config->setName('ProfessionalServices_WidgetProfessionalServicesForPiwik');
$advertising = StaticContainer::get('Piwik\\ProfessionalServices\\Advertising');
$config->setIsEnabled($advertising->areAdsForProfessionalServicesEnabled());
}
示例15: getKey
public function getKey($key)
{
if ($key === 'auth') {
$key = 'Piwik\\Auth';
}
return StaticContainer::get($key);
}