Piwik\Plugin\MetadataLoader::load PHP Method

load() public method

@see Plugin::getInformation.
public load ( ) : array
return array
    public function load()
    {
        $defaults = $this->getDefaultPluginInformation();
        $plugin = $this->loadPluginInfoJson();
        // use translated plugin description if available
        if ($defaults['description'] != Piwik::translate($defaults['description'])) {
            unset($plugin['description']);
        }
        // look for a license file
        $licenseFile = $this->getPathToLicenseFile();
        if (!empty($licenseFile)) {
            $plugin['license_file'] = $licenseFile;
        }
        return array_merge($defaults, $plugin);
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Constructor.
  *
  * @param string|bool $pluginName A plugin name to force. If not supplied, it is set
  *                                to the last part of the class name.
  * @throws \Exception If plugin metadata is defined in both the getInformation() method
  *                    and the **plugin.json** file.
  */
 public function __construct($pluginName = false)
 {
     if (empty($pluginName)) {
         $pluginName = explode('\\', get_class($this));
         $pluginName = end($pluginName);
     }
     $this->pluginName = $pluginName;
     $metadataLoader = new MetadataLoader($pluginName);
     $this->pluginInformation = $metadataLoader->load();
     if ($this->hasDefinedPluginInformationInPluginClass() && $metadataLoader->hasPluginJson()) {
         throw new \Exception('Plugin ' . $pluginName . ' has defined the method getInformation() and as well as having a plugin.json file. Please delete the getInformation() method from the plugin class. Alternatively, you may delete the plugin directory from plugins/' . $pluginName);
     }
     $this->cache = new PersistentCache('Plugin' . $pluginName);
 }
All Usage Examples Of Piwik\Plugin\MetadataLoader::load