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


PHP ConfigManager::createConfigEntityModel方法代码示例

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


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

 public function testCreateConfigEntityModel()
 {
     $configId = new EntityConfigId('entity', self::ENTITY_CLASS);
     $model = $this->createEntityConfigModel(self::ENTITY_CLASS);
     $this->modelManager->expects($this->once())->method('findEntityModel')->with(self::ENTITY_CLASS)->will($this->returnValue(null));
     $this->modelManager->expects($this->once())->method('createEntityModel')->with(self::ENTITY_CLASS, ConfigModelManager::MODE_DEFAULT)->will($this->returnValue($model));
     $metadata = new EntityMetadata(self::ENTITY_CLASS);
     $metadata->defaultValues['entity'] = ['translatable' => 'labelVal', 'other' => 'otherVal'];
     $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_ENTITY)->will($this->returnValue(['translatable10' => 'labelVal10', 'other10' => 'otherVal10']));
     $propertyConfigContainer->expects($this->once())->method('getTranslatableValues')->with(PropertyConfigContainer::TYPE_ENTITY)->will($this->returnValue(['translatable', 'translatable10', 'auto_generated']));
     $this->configProvider->expects($this->any())->method('getPropertyConfig')->will($this->returnValue($propertyConfigContainer));
     $this->eventDispatcher->expects($this->once())->method('dispatch')->with(Events::NEW_ENTITY_CONFIG, new EntityConfigEvent(self::ENTITY_CLASS, $this->configManager));
     $config = new Config($configId);
     $config->set('other', 'otherVal');
     $config->set('translatable', 'labelVal');
     $config->set('other10', 'otherVal10');
     $config->set('translatable10', 'labelVal10');
     $config->set('auto_generated', 'oro.entityconfig.tests.unit.fixture.demoentity.entity_auto_generated');
     $result = $this->configManager->createConfigEntityModel(self::ENTITY_CLASS);
     $this->assertEquals($model, $result);
     $this->assertEquals([$config], $this->configManager->getUpdateConfig());
     // test that a config for a created model is stored in a local cache
     $result = $this->configManager->getConfig($configId);
     $this->assertEquals($config, $result);
 }
开发者ID:xamin123,项目名称:platform,代码行数:27,代码来源:ConfigManagerTest.php

示例3: createEntityModel

 /**
  * @param string $className
  * @param string $mode
  * @param array  $configs
  * @throws \LogicException
  */
 protected function createEntityModel($className, $mode, array $configs)
 {
     if (!ExtendHelper::isCustomEntity($className)) {
         throw new \LogicException(sprintf('A new model can be created for custom entity only. Class: %s.', $className));
     }
     $this->logger->info(sprintf('Create entity "%s".', $className), ['configs' => $configs]);
     $this->configManager->createConfigEntityModel($className, $mode);
     $this->updateConfigs($configs, $className);
     $extendConfigProvider = $this->configManager->getProvider('extend');
     $extendConfig = $extendConfigProvider->getConfig($className);
     $extendConfig->set('state', ExtendScope::STATE_NEW);
     $this->configManager->persist($extendConfig);
 }
开发者ID:startupz,项目名称:platform-1,代码行数:19,代码来源:ExtendConfigProcessor.php

示例4: createEntityModel

 /**
  * @param $entityName
  * @param $entityConfig
  * @return void
  */
 protected function createEntityModel($entityName, $entityConfig)
 {
     $mode = isset($entityConfig['mode']) ? $entityConfig['mode'] : ConfigModelManager::MODE_DEFAULT;
     $this->configManager->createConfigEntityModel($entityName, $mode);
     if (class_exists($entityName)) {
         $doctrineMetadata = $this->configManager->getEntityManager()->getClassMetadata($entityName);
         foreach ($doctrineMetadata->getFieldNames() as $fieldName) {
             $type = $doctrineMetadata->getTypeOfField($fieldName);
             $this->configManager->createConfigFieldModel($doctrineMetadata->getName(), $fieldName, $type);
         }
         foreach ($doctrineMetadata->getAssociationNames() as $fieldName) {
             $type = $doctrineMetadata->isSingleValuedAssociation($fieldName) ? 'ref-one' : 'ref-many';
             $this->configManager->createConfigFieldModel($doctrineMetadata->getName(), $fieldName, $type);
         }
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:21,代码来源:InitCommand.php

示例5: testCreateConfigEntityModel

 public function testCreateConfigEntityModel()
 {
     $configId = new EntityConfigId('entity', self::ENTITY_CLASS);
     $model = $this->createEntityConfigModel(self::ENTITY_CLASS);
     $metadata = $this->getEntityMetadata(self::ENTITY_CLASS, ['translatable' => 'labelVal', 'other' => 'otherVal']);
     $this->modelManager->expects($this->once())->method('findEntityModel')->with(self::ENTITY_CLASS)->willReturn(null);
     $this->modelManager->expects($this->once())->method('createEntityModel')->with(self::ENTITY_CLASS, ConfigModelManager::MODE_DEFAULT)->willReturn($model);
     $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_ENTITY)->willReturn(['translatable10' => 'labelVal10', 'other10' => 'otherVal10']);
     $propertyConfigContainer->expects($this->once())->method('getTranslatableValues')->with(PropertyConfigContainer::TYPE_ENTITY)->willReturn(['translatable', 'translatable10', 'auto_generated']);
     $this->configProvider->expects($this->any())->method('getPropertyConfig')->willReturn($propertyConfigContainer);
     $this->eventDispatcher->expects($this->once())->method('dispatch')->with(Events::NEW_ENTITY_CONFIG, new EntityConfigEvent(self::ENTITY_CLASS, $this->configManager));
     $config = $this->getConfig($configId, ['other' => 'otherVal', 'translatable' => 'labelVal', 'other10' => 'otherVal10', 'translatable10' => 'labelVal10', 'auto_generated' => 'oro.entityconfig.tests.unit.fixture.demoentity.entity_auto_generated']);
     $this->configCache->expects($this->once())->method('saveConfig')->with($config, true);
     $result = $this->configManager->createConfigEntityModel(self::ENTITY_CLASS);
     $this->assertEquals($model, $result);
     $this->assertEquals([$config], $this->configManager->getUpdateConfig());
 }
开发者ID:northdakota,项目名称:platform,代码行数:19,代码来源:ConfigManagerTest.php

示例6: testCreateConfigEntityModel

 /**
  * @dataProvider createConfigEntityModelProvider
  */
 public function testCreateConfigEntityModel($mode, $hasMetadata, $metadataMode, $expectedMode, $cachedEntities, $expectedSavedCachedEntities)
 {
     $configId = new EntityConfigId('entity', self::ENTITY_CLASS);
     $model = $this->createEntityConfigModel(self::ENTITY_CLASS, $expectedMode);
     $metadata = null;
     if ($hasMetadata) {
         $metadata = $this->getEntityMetadata(self::ENTITY_CLASS, ['translatable' => 'labelVal', 'other' => 'otherVal']);
         if (null !== $metadataMode) {
             $metadata->mode = $metadataMode;
         }
     }
     $this->modelManager->expects($this->once())->method('findEntityModel')->with(self::ENTITY_CLASS)->willReturn(null);
     $this->modelManager->expects($this->once())->method('createEntityModel')->with(self::ENTITY_CLASS, $expectedMode)->willReturn($model);
     $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_ENTITY)->willReturn(['translatable10' => 'labelVal10', 'other10' => 'otherVal10']);
     $propertyConfigContainer->expects($this->once())->method('getTranslatableValues')->with(PropertyConfigContainer::TYPE_ENTITY)->willReturn(['translatable', 'translatable10', 'auto_generated']);
     $this->configProvider->expects($this->any())->method('getPropertyConfig')->willReturn($propertyConfigContainer);
     $this->eventDispatcher->expects($this->once())->method('dispatch')->with(Events::CREATE_ENTITY, new EntityConfigEvent(self::ENTITY_CLASS, $this->configManager));
     $config = $this->getConfig($configId, ['translatable' => 'oro.entityconfig.tests.unit.fixture.demoentity.entity_translatable', 'other10' => 'otherVal10', 'translatable10' => 'labelVal10', 'auto_generated' => 'oro.entityconfig.tests.unit.fixture.demoentity.entity_auto_generated']);
     if ($metadata) {
         $config->set('other', 'otherVal');
         $config->set('translatable', 'labelVal');
     }
     $this->configCache->expects($this->once())->method('saveConfig')->with($config, true);
     $this->configCache->expects($this->once())->method('saveConfigurable')->with(true, self::ENTITY_CLASS, null, true);
     $this->configCache->expects($this->once())->method('getEntities')->with(true)->willReturn($cachedEntities);
     if (null === $expectedSavedCachedEntities) {
         $this->configCache->expects($this->never())->method('saveEntities');
     } else {
         $this->configCache->expects($this->once())->method('saveEntities')->with($expectedSavedCachedEntities, true);
     }
     $result = $this->configManager->createConfigEntityModel(self::ENTITY_CLASS, $mode);
     $this->assertEquals($model, $result);
     $this->assertEquals([$config], $this->configManager->getUpdateConfig());
 }
开发者ID:Maksold,项目名称:platform,代码行数:39,代码来源:ConfigManagerTest.php

示例7: createEnumValueConfigEntityModel

 /**
  * @param string    $enumValueClassName The full class name of an entity is used to store enum values
  * @param string    $enumCode           The unique identifier of an enum
  * @param bool      $isMultiple         Indicates whether several options can be selected for this enum
  *                                      or it supports only one selected option
  * @param bool|null $isPublic           Indicates whether this enum can be used by any entity or
  *                                      it is designed to use in one entity only
  *                                      NULL means unspecified. In this case this attribute will not be
  *                                      changed for existing enum entity and will be set to FALSE
  *                                      for new enum entity
  */
 protected function createEnumValueConfigEntityModel($enumValueClassName, $enumCode, $isMultiple, $isPublic)
 {
     if ($this->configManager->hasConfigEntityModel($enumValueClassName)) {
         if (null !== $isPublic) {
             $this->relationBuilder->updateEntityConfigs($enumValueClassName, ['enum' => ['public' => $isPublic]]);
         }
         return;
     }
     if (null === $isPublic) {
         $isPublic = false;
     }
     // create entity
     $this->configManager->createConfigEntityModel($enumValueClassName, ConfigModelManager::MODE_HIDDEN);
     $this->relationBuilder->updateEntityConfigs($enumValueClassName, ['entity' => ['label' => ExtendHelper::getEnumTranslationKey('label', $enumCode), 'plural_label' => ExtendHelper::getEnumTranslationKey('plural_label', $enumCode), 'description' => ExtendHelper::getEnumTranslationKey('description', $enumCode)], 'extend' => ['owner' => ExtendScope::OWNER_SYSTEM, 'is_extend' => true, 'table' => $this->nameGenerator->generateEnumTableName($enumCode, true), 'inherit' => ExtendHelper::BASE_ENUM_VALUE_CLASS], 'enum' => ['code' => $enumCode, 'public' => $isPublic, 'multiple' => $isMultiple]]);
     // create fields
     $this->configManager->createConfigFieldModel($enumValueClassName, 'id', 'string');
     $this->relationBuilder->updateFieldConfigs($enumValueClassName, 'id', ['entity' => ['label' => ExtendHelper::getEnumTranslationKey('label', $enumCode, 'id'), 'description' => ExtendHelper::getEnumTranslationKey('description', $enumCode, 'id')], 'importexport' => ['identity' => true]]);
     $this->configManager->createConfigFieldModel($enumValueClassName, 'name', 'string');
     $this->relationBuilder->updateFieldConfigs($enumValueClassName, 'name', ['entity' => ['label' => ExtendHelper::getEnumTranslationKey('label', $enumCode, 'name'), 'description' => ExtendHelper::getEnumTranslationKey('description', $enumCode, 'name')], 'datagrid' => ['is_visible' => false]]);
     $this->configManager->createConfigFieldModel($enumValueClassName, 'priority', 'integer');
     $this->relationBuilder->updateFieldConfigs($enumValueClassName, 'priority', ['entity' => ['label' => ExtendHelper::getEnumTranslationKey('label', $enumCode, 'priority'), 'description' => ExtendHelper::getEnumTranslationKey('description', $enumCode, 'priority')], 'datagrid' => ['is_visible' => false]]);
     $this->configManager->createConfigFieldModel($enumValueClassName, 'default', 'boolean');
     $this->relationBuilder->updateFieldConfigs($enumValueClassName, 'default', ['entity' => ['label' => ExtendHelper::getEnumTranslationKey('label', $enumCode, 'default'), 'description' => ExtendHelper::getEnumTranslationKey('description', $enumCode, 'default')], 'datagrid' => ['is_visible' => false]]);
 }
开发者ID:hugeval,项目名称:platform,代码行数:35,代码来源:EnumEntityConfigDumperExtension.php


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