protected function GTMTestBase::saveContainers in GoogleTagManager 8
Save containers in the database and create snippet files.
1 call to GTMTestBase::saveContainers()
- GTMTestBase::testModule in tests/
src/ Functional/ GTMTestBase.php - Test the module.
File
- tests/
src/ Functional/ GTMTestBase.php, line 141
Class
- GTMTestBase
- Tests the Google Tag Manager.
Namespace
Drupal\Tests\google_tag\FunctionalCode
protected function saveContainers() {
foreach ($this->variables as $key => $variables) {
// Create container with default container settings, then modify.
$container = new Container([], 'google_tag_container');
$container
->enforceIsNew();
$container
->set('id', $variables->id);
// @todo This has unintended collateral effect; the id property is gone forever.
// Code in submitContainers() needs this value.
$values = (array) $variables;
unset($values['id']);
array_walk($values, function ($value, $key) use ($container) {
$container->{$key} = $value;
});
// Save container.
$container
->save();
// Create snippet files.
$manager = $this->container
->get('google_tag.container_manager');
$manager
->createAssets($container);
}
}