当前位置: 首页>>代码示例>>PHP>>正文


PHP StaticContainer::get方法代码示例

本文整理汇总了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;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:30,代码来源:Run.php

示例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);
     }
 }
开发者ID:piwik,项目名称:plugin-CustomDimensions,代码行数:33,代码来源:CustomDimension.php

示例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);
     }
 }
开发者ID:heiglandreas,项目名称:plugin-LoginLdap,代码行数:15,代码来源:Client.php

示例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));
     }
 }
开发者ID:jon48,项目名称:webtrees-tools,代码行数:25,代码来源:Tasks.php

示例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);
 }
开发者ID:piwik,项目名称:piwik,代码行数:16,代码来源:MeasurableSetting.php

示例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);
 }
开发者ID:mgou-net,项目名称:piwik,代码行数:7,代码来源:FilesystemTest.php

示例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;
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:43,代码来源:CoreTranslations.php

示例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);
 }
开发者ID:hichnik,项目名称:piwik,代码行数:11,代码来源:Login.php

示例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);
     }
 }
开发者ID:peterbo,项目名称:PiwikCustomOptOut,代码行数:31,代码来源:CustomOptOut.php

示例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');
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:7,代码来源:Visit.php

示例11: setUp

 public function setUp()
 {
     parent::setUp();
     /** @var PluginManager $manager */
     $manager = StaticContainer::get('Piwik\\Plugin\\Manager');
     $manager->loadPlugins(array('Events', 'Contents'));
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:7,代码来源:DimensionMetadataProviderTest.php

示例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;
 }
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:45,代码来源:BatchInsert.php

示例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);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:7,代码来源:WatchLog.php

示例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());
 }
开发者ID:piwik,项目名称:piwik,代码行数:7,代码来源:PromoServices.php

示例15: getKey

 public function getKey($key)
 {
     if ($key === 'auth') {
         $key = 'Piwik\\Auth';
     }
     return StaticContainer::get($key);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:7,代码来源:Registry.php


注:本文中的Piwik\Container\StaticContainer::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。