Stange, here's my patch.
@shumer, thanks so much, it works perfectly. As for the context, I went for serialize function like in the module. Here's my complete example :
function MYMODULE_deploy_SOMENAME(): void {
$bundle = 'newbundle';
$config_pages_loader = \Drupal::service('config_pages.loader');
$type = ConfigPagesType::load($bundle);
foreach (['en', 'fr'] as $langcode) {
$context = serialize([['language' => $langcode]]);
$config_page = $config_pages_loader->load($bundle, $context);
if (!$config_page) {
$config_page = ConfigPages::create([
'type' => $bundle,
'label' => $type->label(),
'context' => $context,
]);
$config_page->save();
}
$config_page->set('field_x', t("My string", [], $options));
$config_page->save();
}
}
JFKiwad → created an issue.
@jwilde, here's a quick patch
7 years later! In case you need to do it, heres what's in their test code :
// Create a referencing entity.
$referencing_entity = $this->container->get('entity_type.manager')
->getStorage('entity_test')
->create(['name' => $this->randomMachineName()]);
$referencing_entity->field_test->plugin_id = 'block_field_test_access';
$referencing_entity->field_test->settings = [
'label' => 'Custom access.',
'label_display' => TRUE,
'access' => TRUE,
];
$referencing_entity->save();