当前位置: 首页>>代码示例>>PHP>>正文


PHP ConfigManager::updateConfigEntityModel方法代码示例

本文整理汇总了PHP中Oro\Bundle\EntityConfigBundle\Config\ConfigManager::updateConfigEntityModel方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigManager::updateConfigEntityModel方法的具体用法?PHP ConfigManager::updateConfigEntityModel怎么用?PHP ConfigManager::updateConfigEntityModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Oro\Bundle\EntityConfigBundle\Config\ConfigManager的用法示例。


在下文中一共展示了ConfigManager::updateConfigEntityModel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadEntityConfigs

 /**
  * @param ClassMetadata $metadata
  * @param bool          $force
  */
 protected function loadEntityConfigs(ClassMetadata $metadata, $force)
 {
     if ($this->hasEntityConfigs($metadata)) {
         $className = $metadata->getName();
         if ($this->configManager->hasConfig($className)) {
             $this->logger->info(sprintf('Update config for "%s" entity.', $className));
             $this->configManager->updateConfigEntityModel($className, $force);
         } else {
             $this->logger->info(sprintf('Create config for "%s" entity.', $className));
             $this->configManager->createConfigEntityModel($className);
         }
         $fieldNames = $metadata->getFieldNames();
         foreach ($fieldNames as $fieldName) {
             if ($this->hasFieldConfigs($metadata, $fieldName)) {
                 $fieldType = $metadata->getTypeOfField($fieldName);
                 $this->loadFieldConfigs($className, $fieldName, $fieldType, $force);
             }
         }
         $associationNames = $metadata->getAssociationNames();
         foreach ($associationNames as $associationName) {
             if ($this->hasAssociationConfigs($metadata, $associationName)) {
                 $associationType = $metadata->isSingleValuedAssociation($associationName) ? 'ref-one' : 'ref-many';
                 $this->loadFieldConfigs($className, $associationName, $associationType, $force);
             }
         }
     }
 }
开发者ID:startupz,项目名称:platform-1,代码行数:31,代码来源:ConfigLoader.php

示例2: testUpdateConfigEntityModelWithForceForCustomEntity

 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testUpdateConfigEntityModelWithForceForCustomEntity()
 {
     $configId = new EntityConfigId('entity', self::ENTITY_CLASS);
     $metadata = $this->getEntityMetadata(self::ENTITY_CLASS, ['translatable1' => 'labelVal1', 'other1' => 'otherVal1', 'translatable2' => 'labelVal2', 'other2' => 'otherVal2']);
     $this->modelManager->expects($this->once())->method('findEntityModel')->with(self::ENTITY_CLASS)->willReturn($this->createEntityConfigModel(self::ENTITY_CLASS));
     $this->metadataFactory->expects($this->any())->method('getMetadataForClass')->with(self::ENTITY_CLASS)->willReturn($metadata);
     $propertyConfigContainer = $this->getPropertyConfigContainerMock();
     $propertyConfigContainer->expects($this->once())->method('getDefaultValues')->with(PropertyConfigContainer::TYPE_ENTITY)->willReturn(['translatable10' => 'labelVal10', 'other10' => 'otherVal10']);
     $propertyConfigContainer->expects($this->once())->method('getTranslatableValues')->with(PropertyConfigContainer::TYPE_ENTITY)->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);
     $this->eventDispatcher->expects($this->once())->method('dispatch')->with(Events::UPDATE_ENTITY);
     $extendConfig = $this->getConfig(new EntityConfigId('extend', self::ENTITY_CLASS));
     $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)->willReturn(true);
     $extendConfigProvider->expects($this->exactly(2))->method('getConfig')->with(self::ENTITY_CLASS)->willReturn($extendConfig);
     $extendPropertyConfigContainer = $this->getPropertyConfigContainerMock();
     $extendPropertyConfigContainer->expects($this->once())->method('getDefaultValues')->with(PropertyConfigContainer::TYPE_ENTITY)->willReturn(['owner' => ExtendScope::OWNER_SYSTEM]);
     $extendPropertyConfigContainer->expects($this->once())->method('getTranslatableValues')->with(PropertyConfigContainer::TYPE_ENTITY)->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.entity_auto_generated']);
     $this->configManager->updateConfigEntityModel(self::ENTITY_CLASS, true);
     $this->assertEquals($expectedConfig, $this->configManager->getUpdateConfig()[0]);
 }
开发者ID:Maksold,项目名称:platform,代码行数:32,代码来源:ConfigManagerTest.php

示例3: testUpdateConfigEntityModelWithForceForCustomEntity

 public function testUpdateConfigEntityModelWithForceForCustomEntity()
 {
     $configId = new EntityConfigId('entity', self::ENTITY_CLASS);
     $metadata = new EntityMetadata(self::ENTITY_CLASS);
     $metadata->defaultValues['entity'] = ['translatable1' => 'labelVal1', 'other1' => 'otherVal1', 'translatable2' => 'labelVal2', 'other2' => 'otherVal2'];
     $this->modelManager->expects($this->once())->method('findEntityModel')->with(self::ENTITY_CLASS)->will($this->returnValue($this->createEntityConfigModel(self::ENTITY_CLASS)));
     $this->metadataFactory->expects($this->any())->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_ENTITY)->will($this->returnValue(['translatable10' => 'labelVal10', 'other10' => 'otherVal10']));
     $propertyConfigContainer->expects($this->once())->method('getTranslatableValues')->with(PropertyConfigContainer::TYPE_ENTITY)->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));
     $this->eventDispatcher->expects($this->once())->method('dispatch')->with(Events::UPDATE_ENTITY_CONFIG);
     $extendConfig = new Config(new EntityConfigId('extend', self::ENTITY_CLASS));
     $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)->will($this->returnValue(true));
     $extendConfigProvider->expects($this->exactly(2))->method('getConfig')->with(self::ENTITY_CLASS)->will($this->returnValue($extendConfig));
     $extendPropertyConfigContainer = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Provider\\PropertyConfigContainer')->disableOriginalConstructor()->getMock();
     $extendPropertyConfigContainer->expects($this->once())->method('getDefaultValues')->with(PropertyConfigContainer::TYPE_ENTITY)->will($this->returnValue(['owner' => ExtendScope::OWNER_SYSTEM]));
     $extendPropertyConfigContainer->expects($this->once())->method('getTranslatableValues')->with(PropertyConfigContainer::TYPE_ENTITY)->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.entity_auto_generated');
     $actualConfig = null;
     $this->configProvider->expects($this->once())->method('persist')->will($this->returnCallback(function ($c) use(&$actualConfig) {
         $actualConfig = $c;
     }));
     $this->configManager->updateConfigEntityModel(self::ENTITY_CLASS, true);
     $this->assertEquals($expectedConfig, $actualConfig);
 }
开发者ID:gmoigneu,项目名称:platform,代码行数:43,代码来源:ConfigManagerTest.php


注:本文中的Oro\Bundle\EntityConfigBundle\Config\ConfigManager::updateConfigEntityModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。