PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 1.3.1
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v1.3.1
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 / API.php
matomo / app / core / Plugin Last commit date
Dimension 6 years ago API.php 6 years ago AggregatedMetric.php 6 years ago ArchivedMetric.php 6 years ago Archiver.php 6 years ago Categories.php 6 years ago ComponentFactory.php 6 years ago ComputedMetric.php 6 years ago ConsoleCommand.php 6 years ago Controller.php 6 years ago ControllerAdmin.php 6 years ago Dependency.php 6 years ago LogTablesProvider.php 6 years ago Manager.php 6 years ago Menu.php 6 years ago MetadataLoader.php 6 years ago Metric.php 6 years ago PluginException.php 6 years ago ProcessedMetric.php 6 years ago ReleaseChannels.php 6 years ago Report.php 6 years ago ReportsProvider.php 6 years ago RequestProcessors.php 6 years ago Segment.php 6 years ago SettingsProvider.php 6 years ago Tasks.php 6 years ago ThemeStyles.php 6 years ago ViewDataTable.php 6 years ago Visualization.php 6 years ago WidgetsProvider.php 6 years ago
API.php
109 lines
1 <?php
2 /**
3 * Piwik - free/libre analytics platform
4 *
5 * @link https://matomo.org
6 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
7 *
8 */
9
10 namespace Piwik\Plugin;
11
12 use Piwik\Container\StaticContainer;
13 use Psr\Log\LoggerInterface;
14
15 /**
16 * The base class of all API singletons.
17 *
18 * Plugins that want to expose functionality through the Reporting API should create a class
19 * that extends this one. Every public method in that class that is not annotated with **@ignore**
20 * will be callable through Matomo's Web API.
21 *
22 * _Note: If your plugin calculates and stores reports, they should be made available through the API._
23 *
24 * ### Examples
25 *
26 * **Defining an API for a plugin**
27 *
28 * class API extends \Piwik\Plugin\API
29 * {
30 * public function myMethod($idSite, $period, $date, $segment = false)
31 * {
32 * $dataTable = // ... get some data ...
33 * return $dataTable;
34 * }
35 * }
36 *
37 * **Linking to an API method**
38 *
39 * <a href="?module=API&method=MyPlugin.myMethod&idSite=1&period=day&date=2013-10-23">Link</a>
40 *
41 * @api
42 */
43 abstract class API
44 {
45 private static $instances;
46
47 /**
48 * Returns the singleton instance for the derived class. If the singleton instance
49 * has not been created, this method will create it.
50 *
51 * @return static
52 */
53 public static function getInstance()
54 {
55 $class = get_called_class();
56
57 if (!isset(self::$instances[$class])) {
58 $container = StaticContainer::getContainer();
59
60 $refl = new \ReflectionClass($class);
61
62 if (!$refl->getConstructor() || $refl->getConstructor()->isPublic()) {
63 self::$instances[$class] = $container->get($class);
64 } else {
65 /** @var LoggerInterface $logger */
66 $logger = $container->get('Psr\Log\LoggerInterface');
67
68 // BC with API defining a protected constructor
69 $logger->notice('The API class {class} defines a protected constructor which is deprecated, make the constructor public instead', array('class' => $class));
70 self::$instances[$class] = new $class;
71 }
72 }
73
74 return self::$instances[$class];
75 }
76
77 /**
78 * Used in tests only
79 * @ignore
80 * @deprecated
81 */
82 public static function unsetInstance()
83 {
84 $class = get_called_class();
85 unset(self::$instances[$class]);
86 }
87
88 /**
89 * Used in tests only
90 * @ignore
91 * @deprecated
92 */
93 public static function unsetAllInstances()
94 {
95 self::$instances = array();
96 }
97
98 /**
99 * Sets the singleton instance. For testing purposes.
100 * @ignore
101 * @deprecated
102 */
103 public static function setSingletonInstance($instance)
104 {
105 $class = get_called_class();
106 self::$instances[$class] = $instance;
107 }
108 }
109