Commit f718eda9 authored by alexpott's avatar alexpott

Issue #2175569 by Xano: Add default configuration to FactoryInterface::createInstance().

parent 7a6fb338
......@@ -40,7 +40,7 @@ public function __construct(DiscoveryInterface $discovery) {
/**
* Implements Drupal\Component\Plugin\Factory\FactoryInterface::createInstance().
*/
public function createInstance($plugin_id, array $configuration) {
public function createInstance($plugin_id, array $configuration = array()) {
$plugin_definition = $this->discovery->getDefinition($plugin_id);
$plugin_class = static::getPluginClass($plugin_id, $plugin_definition);
return new $plugin_class($configuration, $plugin_id, $plugin_definition);
......
......@@ -22,6 +22,6 @@ interface FactoryInterface {
* @return object
* A fully configured plugin instance.
*/
public function createInstance($plugin_id, array $configuration);
public function createInstance($plugin_id, array $configuration = array());
}
......@@ -17,7 +17,7 @@ class ReflectionFactory extends DefaultFactory {
/**
* Implements Drupal\Component\Plugin\Factory\FactoryInterface::createInstance().
*/
public function createInstance($plugin_id, array $configuration) {
public function createInstance($plugin_id, array $configuration = array()) {
$plugin_definition = $this->discovery->getDefinition($plugin_id);
$plugin_class = static::getPluginClass($plugin_id, $plugin_definition);
......
......@@ -121,7 +121,7 @@ public function create(array $definition, $value = NULL, $name = NULL, $parent =
/**
* Overrides Drupal\Core\TypedData\TypedDataFactory::createInstance().
*/
public function createInstance($plugin_id, array $configuration, $name = NULL, $parent = NULL) {
public function createInstance($plugin_id, array $configuration = array(), $name = NULL, $parent = NULL) {
$type_definition = $this->getDefinition($plugin_id);
if (!isset($type_definition)) {
throw new \InvalidArgumentException(String::format('Invalid data type %plugin_id has been given.', array('%plugin_id' => $plugin_id)));
......
......@@ -59,7 +59,7 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac
/**
* {@inheritdoc}
*/
public function createInstance($plugin_id, array $configuration) {
public function createInstance($plugin_id, array $configuration = array()) {
$plugin_definition = $this->getDefinition($plugin_id);
$plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition);
......
......@@ -17,7 +17,7 @@ class WidgetFactory extends DefaultFactory {
/**
* {@inheritdoc}
*/
public function createInstance($plugin_id, array $configuration) {
public function createInstance($plugin_id, array $configuration = array()) {
$plugin_definition = $this->discovery->getDefinition($plugin_id);
$plugin_class = static::getPluginClass($plugin_id, $plugin_definition);
return new $plugin_class($plugin_id, $plugin_definition, $configuration['field_definition'], $configuration['settings']);
......
......@@ -16,7 +16,7 @@ class ContainerFactory extends DefaultFactory {
/**
* {@inheritdoc}
*/
public function createInstance($plugin_id, array $configuration) {
public function createInstance($plugin_id, array $configuration = array()) {
$plugin_definition = $this->discovery->getDefinition($plugin_id);
$plugin_class = static::getPluginClass($plugin_id, $plugin_definition);
......
......@@ -83,7 +83,7 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac
* @return \Drupal\Core\TypedData\TypedDataInterface
* The instantiated typed data object.
*/
public function createInstance($data_type, array $configuration) {
public function createInstance($data_type, array $configuration = array()) {
$data_definition = $configuration['data_definition'];
$type_definition = $this->getDefinition($data_type);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment