setInstanceConfiguration example

return $instances;
  }

  /** * {@inheritdoc} */
  public function setConfiguration($configuration) {
    // Track each instance ID as it is updated.     $unprocessed_instance_ids = $this->getInstanceIds();

    foreach ($configuration as $instance_id => $instance_configuration) {
      $this->setInstanceConfiguration($instance_id$instance_configuration);
      // Remove this instance ID from the list being updated.       unset($unprocessed_instance_ids[$instance_id]);
    }

    // Remove remaining instances that had no configuration specified for them.     foreach ($unprocessed_instance_ids as $unprocessed_instance_id) {
      $this->removeInstanceId($unprocessed_instance_id);
    }
    return $this;
  }

  

  public function getPluginCollections() {
    return ['filters' => $this->filters()];
  }

  /** * {@inheritdoc} */
  public function setFilterConfig($instance_id, array $configuration) {
    $this->filters[$instance_id] = $configuration;
    if (isset($this->filterCollection)) {
      $this->filterCollection->setInstanceConfiguration($instance_id$configuration);
    }
    return $this;
  }

  /** * {@inheritdoc} */
  public function toArray() {
    $properties = parent::toArray();
    // The 'roles' property is only used during install and should never     // actually be saved.
/** * {@inheritdoc} */
  public function setVisibilityConfig($instance_id, array $configuration) {
    $conditions = $this->getVisibilityConditions();
    if (!$conditions->has($instance_id)) {
      $configuration['id'] = $instance_id;
      $conditions->addInstanceId($instance_id$configuration);
    }
    else {
      $conditions->setInstanceConfiguration($instance_id$configuration);
    }
    return $this;
  }

  /** * {@inheritdoc} */
  public function getVisibilityConditions() {
    if (!isset($this->visibilityCollection)) {
      $this->visibilityCollection = new ConditionPluginCollection($this->conditionPluginManager()$this->get('visibility'));
    }
    
/** * @covers ::setInstanceConfiguration */
  public function testSetInstanceConfiguration() {
    $this->setupPluginCollection($this->exactly(3));
    $expected = [
      'id' => 'cherry',
      'key' => 'value',
      'custom' => 'bananas',
    ];
    $this->defaultPluginCollection->setInstanceConfiguration('cherry', $expected);
    $config = $this->defaultPluginCollection->getConfiguration();
    $this->assertSame($expected$config['cherry']);
  }

  /** * @covers ::count */
  public function testCount() {
    $this->setupPluginCollection();
    $this->assertCount(3, $this->defaultPluginCollection);
  }

  
Home | Imprint | This part of the site doesn't use cookies.