PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.1.4
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.1.4
5.12.0 5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / core / Plugin / ReleaseChannels.php
matomo / app / core / Plugin Last commit date
ConsoleCommand 2 years ago Dimension 2 years ago API.php 2 years ago AggregatedMetric.php 2 years ago ArchivedMetric.php 2 years ago Archiver.php 2 years ago Categories.php 2 years ago ComponentFactory.php 2 years ago ComputedMetric.php 2 years ago ConsoleCommand.php 2 years ago Controller.php 2 years ago ControllerAdmin.php 2 years ago Dependency.php 2 years ago LogTablesProvider.php 2 years ago Manager.php 2 years ago Menu.php 2 years ago MetadataLoader.php 2 years ago Metric.php 2 years ago PluginException.php 2 years ago ProcessedMetric.php 2 years ago ReleaseChannels.php 2 years ago Report.php 2 years ago ReportsProvider.php 2 years ago RequestProcessors.php 2 years ago Segment.php 2 years ago SettingsProvider.php 2 years ago Tasks.php 2 years ago ThemeStyles.php 2 years ago ViewDataTable.php 2 years ago Visualization.php 2 years ago WidgetsProvider.php 2 years ago
ReleaseChannels.php
89 lines
1 <?php
2
3 /**
4 * Matomo - free/libre analytics platform
5 *
6 * @link https://matomo.org
7 * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
8 */
9 namespace Piwik\Plugin;
10
11 use Piwik\Config;
12 use Piwik\Container\StaticContainer;
13 use Piwik\UpdateCheck\ReleaseChannel;
14 /**
15 * Get release channels that are defined by plugins.
16 */
17 class ReleaseChannels
18 {
19 /**
20 * @var Manager
21 */
22 private $pluginManager;
23 public function __construct(\Piwik\Plugin\Manager $pluginManager)
24 {
25 $this->pluginManager = $pluginManager;
26 }
27 /**
28 * @return ReleaseChannel[]
29 */
30 public function getAllReleaseChannels()
31 {
32 $classNames = $this->pluginManager->findMultipleComponents('ReleaseChannel', 'Piwik\\UpdateCheck\\ReleaseChannel');
33 $channels = array();
34 foreach ($classNames as $className) {
35 $channels[] = StaticContainer::get($className);
36 }
37 usort($channels, function (ReleaseChannel $a, ReleaseChannel $b) {
38 if ($a->getOrder() === $b->getOrder()) {
39 return 0;
40 }
41 return $a->getOrder() < $b->getOrder() ? -1 : 1;
42 });
43 return $channels;
44 }
45 /**
46 * @return ReleaseChannel
47 */
48 public function getActiveReleaseChannel()
49 {
50 $channel = Config::getInstance()->General['release_channel'];
51 $channel = $this->factory($channel);
52 if (!empty($channel)) {
53 return $channel;
54 }
55 $channels = $this->getAllReleaseChannels();
56 // we default to the one with lowest id
57 return reset($channels);
58 }
59 /**
60 * Sets the given release channel in config but does not save id. $config->forceSave() still needs to be called
61 * @internal tests only
62 * @param string $channel
63 */
64 public function setActiveReleaseChannelId($channel)
65 {
66 $general = Config::getInstance()->General;
67 $general['release_channel'] = $channel;
68 Config::getInstance()->General = $general;
69 }
70 public function isValidReleaseChannelId($releaseChannelId)
71 {
72 $channel = $this->factory($releaseChannelId);
73 return !empty($channel);
74 }
75 /**
76 * @param string $releaseChannelId
77 * @return ReleaseChannel
78 */
79 private function factory($releaseChannelId)
80 {
81 $releaseChannelId = strtolower($releaseChannelId);
82 foreach ($this->getAllReleaseChannels() as $releaseChannel) {
83 if ($releaseChannelId === strtolower($releaseChannel->getId())) {
84 return $releaseChannel;
85 }
86 }
87 }
88 }
89