本文整理汇总了PHP中Oro\Bundle\EntityConfigBundle\Config\ConfigManager::updateConfigFieldModel方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigManager::updateConfigFieldModel方法的具体用法?PHP ConfigManager::updateConfigFieldModel怎么用?PHP ConfigManager::updateConfigFieldModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\EntityConfigBundle\Config\ConfigManager
的用法示例。
在下文中一共展示了ConfigManager::updateConfigFieldModel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUpdateConfigFieldModelWithForceForCustomField
public function testUpdateConfigFieldModelWithForceForCustomField()
{
$configId = new FieldConfigId('entity', self::ENTITY_CLASS, 'id', 'int');
$metadata = $this->getEntityMetadata(self::ENTITY_CLASS);
$idFieldMetadata = $this->getFieldMetadata(self::ENTITY_CLASS, 'id', ['translatable1' => 'labelVal1', 'other1' => 'otherVal1', 'translatable2' => 'labelVal2', 'other2' => 'otherVal2']);
$metadata->addPropertyMetadata($idFieldMetadata);
$this->metadataFactory->expects($this->once())->method('getMetadataForClass')->with(self::ENTITY_CLASS)->willReturn($metadata);
$propertyConfigContainer = $this->getPropertyConfigContainerMock();
$propertyConfigContainer->expects($this->once())->method('getDefaultValues')->with(PropertyConfigContainer::TYPE_FIELD, 'int')->willReturn(['translatable10' => 'labelVal10', 'other10' => 'otherVal10']);
$propertyConfigContainer->expects($this->once())->method('getTranslatableValues')->with(PropertyConfigContainer::TYPE_FIELD)->willReturn(['translatable1', 'translatable2', 'translatable10', 'auto_generated']);
$this->configProvider->expects($this->any())->method('getPropertyConfig')->willReturn($propertyConfigContainer);
$config = $this->getConfig($configId, ['translatable2' => 'labelVal2_old', 'other2' => 'otherVal2_old']);
$this->configProvider->expects($this->once())->method('getConfig')->with(self::ENTITY_CLASS)->willReturn($config);
$extendConfig = $this->getConfig(new FieldConfigId('extend', self::ENTITY_CLASS, 'id'));
$extendConfig->set('owner', ExtendScope::OWNER_CUSTOM);
$extendConfigProvider = $this->getConfigProviderMock();
$extendConfigProvider->expects($this->any())->method('getScope')->willReturn('extend');
$this->configManager->addProvider($extendConfigProvider);
$extendConfigProvider->expects($this->once())->method('hasConfig')->with(self::ENTITY_CLASS, 'id')->willReturn(true);
$extendConfigProvider->expects($this->exactly(2))->method('getConfig')->with(self::ENTITY_CLASS, 'id')->willReturn($extendConfig);
$extendPropertyConfigContainer = $this->getPropertyConfigContainerMock();
$extendPropertyConfigContainer->expects($this->once())->method('getDefaultValues')->with(PropertyConfigContainer::TYPE_FIELD)->willReturn(['owner' => ExtendScope::OWNER_SYSTEM]);
$extendPropertyConfigContainer->expects($this->once())->method('getTranslatableValues')->with(PropertyConfigContainer::TYPE_FIELD)->willReturn([]);
$extendConfigProvider->expects($this->any())->method('getPropertyConfig')->willReturn($extendPropertyConfigContainer);
$extendConfigProvider->expects($this->never())->method('persist');
$expectedConfig = $this->getConfig($configId, ['translatable2' => 'labelVal2_old', 'other2' => 'otherVal2_old', 'translatable10' => 'labelVal10', 'other10' => 'otherVal10', 'translatable1' => 'labelVal1', 'other1' => 'otherVal1', 'auto_generated' => 'oro.entityconfig.tests.unit.fixture.demoentity.id.auto_generated']);
$this->configManager->updateConfigFieldModel(self::ENTITY_CLASS, 'id', true);
$this->assertEquals($expectedConfig, $this->configManager->getUpdateConfig()[0]);
}
示例2: loadFieldConfigs
/**
* @param string $className
* @param string $fieldName
* @param string $fieldType
* @param bool $force
*/
protected function loadFieldConfigs($className, $fieldName, $fieldType, $force)
{
if ($this->configManager->hasConfig($className, $fieldName)) {
$this->logger->info(sprintf('Update config for "%s" field.', $fieldName));
$this->configManager->updateConfigFieldModel($className, $fieldName, $force);
} else {
$this->logger->info(sprintf('Create config for "%s" field.', $fieldName));
$this->configManager->createConfigFieldModel($className, $fieldName, $fieldType);
}
}
示例3: testUpdateConfigFieldModelWithForceForCustomField
public function testUpdateConfigFieldModelWithForceForCustomField()
{
$configId = new FieldConfigId('entity', self::ENTITY_CLASS, 'id', 'int');
$metadata = new EntityMetadata(self::ENTITY_CLASS);
$idFieldMetadata = new FieldMetadata(self::ENTITY_CLASS, 'id');
$metadata->addPropertyMetadata($idFieldMetadata);
$idFieldMetadata->defaultValues['entity'] = ['translatable1' => 'labelVal1', 'other1' => 'otherVal1', 'translatable2' => 'labelVal2', 'other2' => 'otherVal2'];
$this->metadataFactory->expects($this->once())->method('getMetadataForClass')->with(self::ENTITY_CLASS)->will($this->returnValue($metadata));
$propertyConfigContainer = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Provider\\PropertyConfigContainer')->disableOriginalConstructor()->getMock();
$propertyConfigContainer->expects($this->once())->method('getDefaultValues')->with(PropertyConfigContainer::TYPE_FIELD, 'int')->will($this->returnValue(['translatable10' => 'labelVal10', 'other10' => 'otherVal10']));
$propertyConfigContainer->expects($this->once())->method('getTranslatableValues')->with(PropertyConfigContainer::TYPE_FIELD)->will($this->returnValue(['translatable1', 'translatable2', 'translatable10', 'auto_generated']));
$this->configProvider->expects($this->any())->method('getPropertyConfig')->will($this->returnValue($propertyConfigContainer));
$config = new Config($configId);
$config->set('translatable2', 'labelVal2_old');
$config->set('other2', 'otherVal2_old');
$this->configProvider->expects($this->once())->method('getConfig')->with(self::ENTITY_CLASS)->will($this->returnValue($config));
$extendConfig = new Config(new FieldConfigId('extend', self::ENTITY_CLASS, 'id'));
$extendConfig->set('owner', ExtendScope::OWNER_CUSTOM);
$extendConfigProvider = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Provider\\ConfigProvider')->disableOriginalConstructor()->getMock();
$extendConfigProvider->expects($this->any())->method('getScope')->will($this->returnValue('extend'));
$this->configProviderBag->addProvider($extendConfigProvider);
$extendConfigProvider->expects($this->once())->method('hasConfig')->with(self::ENTITY_CLASS, 'id')->will($this->returnValue(true));
$extendConfigProvider->expects($this->exactly(2))->method('getConfig')->with(self::ENTITY_CLASS, 'id')->will($this->returnValue($extendConfig));
$extendPropertyConfigContainer = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Provider\\PropertyConfigContainer')->disableOriginalConstructor()->getMock();
$extendPropertyConfigContainer->expects($this->once())->method('getDefaultValues')->with(PropertyConfigContainer::TYPE_FIELD)->will($this->returnValue(['owner' => ExtendScope::OWNER_SYSTEM]));
$extendPropertyConfigContainer->expects($this->once())->method('getTranslatableValues')->with(PropertyConfigContainer::TYPE_FIELD)->will($this->returnValue([]));
$extendConfigProvider->expects($this->any())->method('getPropertyConfig')->will($this->returnValue($extendPropertyConfigContainer));
$extendConfigProvider->expects($this->never())->method('persist');
$expectedConfig = new Config($configId);
$expectedConfig->set('translatable2', 'labelVal2_old');
$expectedConfig->set('other2', 'otherVal2_old');
$expectedConfig->set('translatable10', 'labelVal10');
$expectedConfig->set('other10', 'otherVal10');
$expectedConfig->set('translatable1', 'labelVal1');
$expectedConfig->set('other1', 'otherVal1');
$expectedConfig->set('auto_generated', 'oro.entityconfig.tests.unit.fixture.demoentity.id.auto_generated');
$actualConfig = null;
$this->configProvider->expects($this->once())->method('persist')->will($this->returnCallback(function ($c) use(&$actualConfig) {
$actualConfig = $c;
}));
$this->configManager->updateConfigFieldModel(self::ENTITY_CLASS, 'id', true);
$this->assertEquals($expectedConfig, $actualConfig);
}