PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.12.1
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.12.1
5.12.1 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 months ago Dimension 2 months ago API.php 8 months ago AggregatedMetric.php 2 years ago ArchivedMetric.php 2 weeks ago Archiver.php 2 months ago Categories.php 2 years ago ComponentFactory.php 2 weeks ago ComputedMetric.php 1 year ago ConsoleCommand.php 2 months ago Controller.php 2 months ago ControllerAdmin.php 2 weeks ago Dependency.php 2 months ago LogTablesProvider.php 2 weeks ago Manager.php 2 weeks ago Menu.php 2 weeks ago MetadataLoader.php 2 weeks ago Metric.php 2 months ago PluginException.php 1 year ago ProcessedMetric.php 4 months ago ReleaseChannels.php 4 months ago Report.php 2 months ago ReportsProvider.php 2 years ago RequestProcessors.php 5 months ago Segment.php 4 months ago SettingsProvider.php 2 weeks ago Tasks.php 2 months ago ThemeStyles.php 2 weeks ago ViewDataTable.php 2 weeks ago Visualization.php 2 weeks ago WidgetsProvider.php 4 months 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 */
78 private function factory($releaseChannelId) : ?ReleaseChannel
79 {
80 $releaseChannelId = strtolower($releaseChannelId);
81 foreach ($this->getAllReleaseChannels() as $releaseChannel) {
82 if ($releaseChannelId === strtolower($releaseChannel->getId())) {
83 return $releaseChannel;
84 }
85 }
86 return null;
87 }
88 }
89