示例#1
0
文件: Plugin.php 项目: xphere/elcodi
 /**
  * Merge this plugin instance with a new one, and saves the result in
  * this instance.
  *
  * This method will give priority to its own properties values.
  *
  * @param Plugin $newPlugin New plugin configuration
  *
  * @return $this Self object
  */
 public function merge(Plugin $newPlugin)
 {
     if ($newPlugin->getNamespace() !== $this->getNamespace()) {
         throw new RuntimeException('Both plugins cannot be merged');
     }
     $this->configuration->merge($newPlugin->getConfiguration());
     return $this;
 }
示例#2
0
 /**
  * Create or update existing plugin given a set of plugin instances and the
  * information to create a new one.
  *
  * @param string $pluginNamespace     Plugin namespace
  * @param array  $pluginConfiguration Plugin Configuration
  *
  * @return Plugin Plugin instance
  */
 private function getPluginInstance($pluginNamespace, array $pluginConfiguration)
 {
     $pluginType = $pluginConfiguration['type'];
     $pluginCategory = $pluginConfiguration['category'];
     $pluginEnabledByDefault = $pluginConfiguration['enabled_by_default'];
     unset($pluginConfiguration['type']);
     $pluginInstance = Plugin::create($pluginNamespace, $pluginType, $pluginCategory, PluginConfiguration::create($pluginConfiguration), $pluginEnabledByDefault);
     return $pluginInstance;
 }
示例#3
0
 /**
  * Test merge with exception.
  *
  * @expectedException \RuntimeException
  */
 public function testMergeException()
 {
     $this->plugin->merge(Plugin::create('A\\Nother\\Plugin', 'plugin', 'social', PluginConfiguration::create(['name' => 'A Plugin', 'description' => 'A plugin description', 'fa_icon' => 'plugin_icon', 'fields' => ['field1' => ['type' => 'text', 'label' => 'label1', 'required' => true, 'data' => null, 'options' => []]]]), true));
 }