function VariantCollectionTrait::addVariant

Same name in other branches
  1. 8.x-3.x src/Plugin/VariantCollectionTrait.php \Drupal\ctools\Plugin\VariantCollectionTrait::addVariant()

See also

\Drupal\ctools\Plugin\VariantCollectionInterface::addVariant()

File

src/Plugin/VariantCollectionTrait.php, line 20

Class

VariantCollectionTrait
Provides methods for VariantCollectionInterface.

Namespace

Drupal\ctools\Plugin

Code

public function addVariant(array $configuration) {
    $configuration['uuid'] = $this->uuidGenerator()
        ->generate();
    $this->getVariants()
        ->addInstanceId($configuration['uuid'], $configuration);
    return $configuration['uuid'];
}