Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Marketplace/Input/PluginName.php')
-rw-r--r--plugins/Marketplace/Input/PluginName.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/plugins/Marketplace/Input/PluginName.php b/plugins/Marketplace/Input/PluginName.php
new file mode 100644
index 0000000000..354b7ff9d9
--- /dev/null
+++ b/plugins/Marketplace/Input/PluginName.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+
+namespace Piwik\Plugins\Marketplace\Input;
+use Piwik\Common;
+use Piwik\Plugin;
+use Exception;
+
+/**
+ */
+class PluginName
+{
+ private $requestParam = '';
+
+ public function __construct($requestParam = 'pluginName')
+ {
+ $this->requestParam = $requestParam;
+ }
+
+ public function getPluginName()
+ {
+ $pluginName = Common::getRequestVar($this->requestParam, null, 'string');
+
+ $this->dieIfPluginNameIsInvalid($pluginName);
+
+ return $pluginName;
+ }
+
+ private function dieIfPluginNameIsInvalid($pluginName)
+ {
+ if (!Plugin\Manager::getInstance()->isValidPluginName($pluginName)){
+ throw new Exception('Invalid plugin name given');
+ }
+ }
+
+}