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


PHP Config\ConfigInterface类代码示例

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


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

示例1: build

 /**
  * {@inheritdoc}
  */
 public function build(ClassMetadataBuilder $metadataBuilder, ConfigInterface $extendConfig)
 {
     $relations = $extendConfig->get('relation');
     foreach ($relations as $relation) {
         /** @var FieldConfigId $fieldId */
         $fieldId = $relation['field_id'];
         if ($relation['assign'] && $fieldId) {
             $targetEntity = $relation['target_entity'];
             /** @var FieldConfigId|null $targetFieldId */
             $targetFieldId = !empty($relation['target_field_id']) ? $relation['target_field_id'] : null;
             $cascade = !empty($relation['cascade']) ? $relation['cascade'] : [];
             switch ($fieldId->getFieldType()) {
                 case 'manyToOne':
                     $cascade[] = 'detach';
                     $this->buildManyToOneRelation($metadataBuilder, $fieldId, $targetEntity, $targetFieldId, $cascade);
                     break;
                 case 'oneToMany':
                     $cascade[] = 'detach';
                     $this->buildOneToManyRelation($metadataBuilder, $fieldId, $targetEntity, $targetFieldId, $cascade);
                     break;
                 case 'manyToMany':
                     if ($relation['owner']) {
                         $this->buildManyToManyOwningSideRelation($metadataBuilder, $fieldId, $targetEntity, $targetFieldId, $cascade);
                     } elseif ($targetFieldId) {
                         $this->buildManyToManyTargetSideRelation($metadataBuilder, $fieldId, $targetEntity, $targetFieldId);
                     }
                     break;
             }
         }
     }
 }
开发者ID:xamin123,项目名称:platform,代码行数:34,代码来源:RelationMetadataBuilder.php

示例2: build

 /**
  * {@inheritdoc}
  */
 public function build(ClassMetadataBuilder $metadataBuilder, ConfigInterface $extendConfig)
 {
     $relations = $extendConfig->get('relation', false, []);
     $schema = $extendConfig->get('schema', false, []);
     foreach ($relations as $relation) {
         /** @var FieldConfigId $fieldId */
         $fieldId = $relation['field_id'];
         if ($fieldId && isset($schema['relation'][$fieldId->getFieldName()])) {
             $targetEntity = $relation['target_entity'];
             /** @var FieldConfigId|null $targetFieldId */
             $targetFieldId = !empty($relation['target_field_id']) ? $relation['target_field_id'] : null;
             $cascade = !empty($relation['cascade']) ? $relation['cascade'] : [];
             switch ($fieldId->getFieldType()) {
                 case RelationType::MANY_TO_ONE:
                     $cascade[] = 'detach';
                     $this->buildManyToOneRelation($metadataBuilder, $fieldId, $targetEntity, $targetFieldId, $cascade);
                     break;
                 case RelationType::ONE_TO_MANY:
                     $cascade[] = 'detach';
                     $this->buildOneToManyRelation($metadataBuilder, $fieldId, $targetEntity, $targetFieldId, $cascade);
                     break;
                 case RelationType::MANY_TO_MANY:
                     if ($relation['owner']) {
                         $this->buildManyToManyOwningSideRelation($metadataBuilder, $fieldId, $targetEntity, $targetFieldId, $cascade);
                     } elseif ($targetFieldId) {
                         $this->buildManyToManyTargetSideRelation($metadataBuilder, $fieldId, $targetEntity, $targetFieldId);
                     }
                     break;
             }
         }
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:35,代码来源:RelationMetadataBuilder.php

示例3: getEntityFieldData

 /**
  * @param ConfigInterface $fieldConfig
  * @param string          $fieldName
  * @param object          $entity
  * @return null|mixed
  */
 protected function getEntityFieldData(ConfigInterface $fieldConfig, $fieldName, $entity)
 {
     if ($fieldConfig->getId()->getFieldType() != 'optionSet' || !FieldAccessor::hasGetter($entity, $fieldName) || !($options = FieldAccessor::getValue($entity, $fieldName))) {
         return null;
     }
     return $options;
 }
开发者ID:xamin123,项目名称:platform,代码行数:13,代码来源:OptionSetListener.php

示例4: getMissingTranslationKeys

 /**
  * @param ConfigInterface $config
  *
  * @return array
  */
 protected function getMissingTranslationKeys(ConfigInterface $config)
 {
     $keys = ['label'];
     if ($config->getId() instanceof EntityConfigId) {
         $keys[] = 'plural_label';
     }
     $missingTranslationKeys = [];
     foreach ($keys as $key) {
         $transKey = $config->get($key);
         /**
          * Ignore custom entities created for test environment only (class name starts with "Test").
          * It's done to avoid adding and accumulation of unnecessary test entity/field/relation translations.
          */
         if (0 === strpos($transKey, 'extend.entity.test')) {
             continue;
         }
         if (!$this->getTranslator()->hasTrans($transKey)) {
             $configId = $config->getId();
             if ($configId instanceof FieldConfigId) {
                 $transKey .= sprintf(' [Entity: %s; Field: %s]', $configId->getClassName(), $configId->getFieldName());
             } else {
                 $transKey .= sprintf(' [Entity: %s]', $configId->getClassName());
             }
             $missingTranslationKeys[] = $transKey;
         }
     }
     return $missingTranslationKeys;
 }
开发者ID:woei66,项目名称:platform,代码行数:33,代码来源:ConfigTranslationTest.php

示例5: addManyToOneRelation

 /**
  * @param ConfigInterface $sourceEntityConfig The 'extend' config of the source entity
  * @param string          $targetEntityName
  * @param string          $relationName
  * @param string          $targetFieldName    A field name is used to show related entity
  * @param array           $options
  * @param string          $fieldType          The field type. By default the field type is manyToOne,
  *                                            but you can specify another type if it is based on manyToOne.
  *                                            In this case this type should be registered
  *                                            in entity_extend.yml under underlying_types section
  *
  * @return string The relation key
  */
 public function addManyToOneRelation(ConfigInterface $sourceEntityConfig, $targetEntityName, $relationName, $targetFieldName, $options = [], $fieldType = RelationType::MANY_TO_ONE)
 {
     $sourceEntityName = $sourceEntityConfig->getId()->getClassName();
     $relationKey = ExtendHelper::buildRelationKey($sourceEntityName, $relationName, RelationType::MANY_TO_ONE, $targetEntityName);
     // add a relation field config
     if (!$this->configManager->hasConfigFieldModel($sourceEntityName, $relationName)) {
         $this->configManager->createConfigFieldModel($sourceEntityName, $relationName, $fieldType);
         $options['extend']['state'] = ExtendScope::STATE_NEW;
     } else {
         $configFieldModel = $this->configManager->getConfigFieldModel($sourceEntityName, $relationName);
         if ($configFieldModel->getType() !== $fieldType) {
             $this->configManager->changeFieldType($sourceEntityName, $relationName, $fieldType);
         }
     }
     $options['extend']['is_extend'] = true;
     $options['extend']['relation_key'] = $relationKey;
     $options['extend']['target_entity'] = $targetEntityName;
     $options['extend']['target_field'] = $targetFieldName;
     $this->updateFieldConfigs($sourceEntityName, $relationName, $options);
     // add relation to config
     $relations = $sourceEntityConfig->get('relation', false, []);
     if (!isset($relations[$relationKey])) {
         $fieldId = new FieldConfigId('extend', $sourceEntityName, $relationName, RelationType::MANY_TO_ONE);
         $relations[$relationKey] = ['assign' => false, 'field_id' => $fieldId, 'owner' => true, 'target_entity' => $targetEntityName, 'target_field_id' => false];
         if (isset($options['extend']['cascade'])) {
             $relations[$relationKey]['cascade'] = $options['extend']['cascade'];
         }
         $sourceEntityConfig->set('relation', $relations);
         $extendConfigProvider = $this->configManager->getProvider('extend');
         $extendConfigProvider->persist($sourceEntityConfig);
     }
     return $relationKey;
 }
开发者ID:northdakota,项目名称:platform,代码行数:46,代码来源:RelationBuilder.php

示例6: createOwnerRelation

 /**
  * @param ConfigInterface $entityConfig
  * @param string          $targetEntityClassName
  * @param string          $relationName
  */
 protected function createOwnerRelation(ConfigInterface $entityConfig, $targetEntityClassName, $relationName)
 {
     $relationKey = ExtendHelper::buildRelationKey($entityConfig->getId()->getClassName(), $relationName, 'manyToOne', $this->ownershipMetadataProvider->getOrganizationClass());
     if (!isset($entityConfig->get('relation')[$relationKey])) {
         $this->relationBuilder->addManyToOneRelation($entityConfig, $targetEntityClassName, $relationName, 'id', ['entity' => ['label' => 'oro.custom_entity.' . $relationName . '.label', 'description' => 'oro.custom_entity.' . $relationName . '.description'], 'view' => ['is_displayable' => false], 'form' => ['is_enabled' => false], 'dataaudit' => ['auditable' => true]]);
     }
 }
开发者ID:northdakota,项目名称:platform,代码行数:12,代码来源:OwnershipEntityConfigDumperExtension.php

示例7: getTypeGuess

 /**
  * @param ConfigInterface $formConfig
  * @param string          $class
  * @param string          $property
  *
  * @return TypeGuess
  */
 protected function getTypeGuess(ConfigInterface $formConfig, $class, $property)
 {
     $formType = $formConfig->get('form_type');
     $formOptions = $formConfig->has('form_options') ? $formConfig->get('form_options') : array();
     $formOptions = $this->addLabelOption($formOptions, $class, $property);
     // fallback guess from recursive call must be with low confidence
     return is_null($property) ? $this->createTypeGuess($formType, $formOptions, TypeGuess::LOW_CONFIDENCE) : $this->createTypeGuess($formType, $formOptions);
 }
开发者ID:northdakota,项目名称:platform,代码行数:15,代码来源:FormConfigGuesser.php

示例8: setDefaultOrganization

 /**
  * @param TokenInterface  $token
  * @param ConfigInterface $config
  * @param object          $entity
  */
 protected function setDefaultOrganization(TokenInterface $token, ConfigInterface $config, $entity)
 {
     if ($token instanceof OrganizationContextTokenInterface && $config->has('organization_field_name')) {
         $accessor = PropertyAccess::createPropertyAccessor();
         $fieldName = $config->get('organization_field_name');
         if (!$accessor->getValue($entity, $fieldName)) {
             $accessor->setValue($entity, $fieldName, $token->getOrganizationContext());
         }
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:15,代码来源:RecordOwnerDataListener.php

示例9: putConfigInCache

 /**
  * @param ConfigInterface $config
  * @return bool
  * @throws \LogicException
  */
 public function putConfigInCache(ConfigInterface $config)
 {
     $configId = $config->getId();
     if ($this->isDebug && $configId instanceof FieldConfigId) {
         if ($configId->getFieldType() === null) {
             // undefined field type can cause unpredictable logical bugs
             throw new \LogicException(sprintf('A field config "%s::%s" with undefined field type cannot be cached.' . ' It seems that there is some critical bug in entity config core functionality.' . ' Please contact ORO team if you see this error.', $configId->getClassName(), $configId->getFieldName()));
         }
     }
     return $this->cache->save($this->buildConfigCacheKey($config->getId()), $config);
 }
开发者ID:xamin123,项目名称:platform,代码行数:16,代码来源:ConfigCache.php

示例10: prepareRelations

 /**
  * @param ConfigInterface $config
  * @param ClassMetadataBuilder $cmBuilder
  */
 protected function prepareRelations(ConfigInterface $config, ClassMetadataBuilder $cmBuilder)
 {
     if ($config->is('relation')) {
         foreach ($config->get('relation') as $relation) {
             /** @var FieldConfigId $fieldId */
             if ($relation['assign'] && ($fieldId = $relation['field_id'])) {
                 /** @var FieldConfigId $targetFieldId */
                 $targetFieldId = $relation['target_field_id'];
                 $targetFieldName = $targetFieldId ? ExtendConfigDumper::FIELD_PREFIX . $targetFieldId->getFieldName() : null;
                 $fieldName = ExtendConfigDumper::FIELD_PREFIX . $fieldId->getFieldName();
                 $defaultName = ExtendConfigDumper::DEFAULT_PREFIX . $fieldId->getFieldName();
                 switch ($fieldId->getFieldType()) {
                     case 'manyToOne':
                         $builder = $cmBuilder->createManyToOne($fieldName, $relation['target_entity']);
                         if ($targetFieldName) {
                             $builder->inversedBy($targetFieldName);
                         }
                         $builder->addJoinColumn($fieldName . '_id', 'id', true, false, 'SET NULL');
                         $builder->cascadeDetach();
                         $builder->build();
                         break;
                     case 'oneToMany':
                         /** create 1:* */
                         $builder = $cmBuilder->createOneToMany($fieldName, $relation['target_entity']);
                         $builder->mappedBy($targetFieldName);
                         $builder->cascadeDetach();
                         $builder->build();
                         /** create 1:1 default */
                         $builder = $cmBuilder->createOneToOne($defaultName, $relation['target_entity']);
                         $builder->addJoinColumn($defaultName . '_id', 'id', true, false, 'SET NULL');
                         $builder->build();
                         break;
                     case 'manyToMany':
                         if ($relation['owner']) {
                             $builder = $cmBuilder->createManyToMany($fieldName, $relation['target_entity']);
                             if ($targetFieldName) {
                                 $builder->inversedBy($targetFieldName);
                             }
                             $builder->setJoinTable(ExtendHelper::generateManyToManyJoinTableName($fieldId, $relation['target_entity']));
                             $builder->build();
                             $builder = $cmBuilder->createOneToOne($defaultName, $relation['target_entity']);
                             $builder->addJoinColumn($defaultName . '_id', 'id', true, false, 'SET NULL');
                             $builder->build();
                         } else {
                             $cmBuilder->addInverseManyToMany($fieldName, $relation['target_entity'], $targetFieldName);
                         }
                         break;
                 }
             }
         }
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:56,代码来源:DoctrineSubscriber.php

示例11: saveConfig

 /**
  * @param ConfigInterface $config
  * @param bool            $localCacheOnly
  *
  * @return bool
  *
  * @throws \InvalidArgumentException
  */
 public function saveConfig(ConfigInterface $config, $localCacheOnly = false)
 {
     $configId = $config->getId();
     if ($this->isDebug && $configId instanceof FieldConfigId && null === $configId->getFieldType()) {
         // undefined field type can cause unpredictable logical bugs
         throw new \InvalidArgumentException(sprintf('A field config "%s::%s" with undefined field type cannot be cached.' . ' It seems that there is some critical bug in entity config core functionality.' . ' Please contact ORO team if you see this error.', $configId->getClassName(), $configId->getFieldName()));
     }
     $cacheKey = $this->buildConfigCacheKey($configId);
     $cacheEntry = isset($this->localCache[$cacheKey]) ? $this->localCache[$cacheKey] : $this->fetchConfig($cacheKey, $configId);
     $cacheEntry[$configId->getScope()] = $config;
     $this->localCache[$cacheKey] = $cacheEntry;
     return $localCacheOnly ? true : $this->pushConfig($cacheKey, $cacheEntry);
 }
开发者ID:northdakota,项目名称:platform,代码行数:21,代码来源:ConfigCache.php

示例12: build

 /**
  * {@inheritdoc}
  */
 public function build(ClassMetadataBuilder $metadataBuilder, ConfigInterface $extendConfig)
 {
     $className = $extendConfig->getId()->getClassName();
     $indices = $extendConfig->get('index');
     // TODO: need to be changed to fieldName => columnName
     // TODO: should be done in scope https://magecore.atlassian.net/browse/BAP-3940
     foreach ($indices as $columnName => $enabled) {
         $fieldConfig = $this->extendConfigProvider->getConfig($className, $columnName);
         if ($enabled && !$fieldConfig->is('state', ExtendScope::STATE_NEW)) {
             $indexName = $this->nameGenerator->generateIndexNameForExtendFieldVisibleInGrid($className, $columnName);
             $metadataBuilder->addIndex([$columnName], $indexName);
         }
     }
 }
开发者ID:ramunasd,项目名称:platform,代码行数:17,代码来源:IndexMetadataBuilder.php

示例13: getMissingTranslationKeys

 /**
  * @param ConfigInterface $config
  *
  * @return array
  */
 protected function getMissingTranslationKeys(ConfigInterface $config)
 {
     $keys = ['label'];
     if ($config->getId() instanceof EntityConfigId) {
         $keys[] = 'plural_label';
     }
     $missingTranslationKeys = [];
     foreach ($keys as $key) {
         $transKey = $config->get($key);
         if (!$this->getTranslator()->hasTrans($transKey)) {
             $missingTranslationKeys[] = $transKey;
         }
     }
     return $missingTranslationKeys;
 }
开发者ID:northdakota,项目名称:platform,代码行数:20,代码来源:ConfigTranslationTest.php

示例14: computeChanges

 /**
  * @param ConfigInterface $config
  * @param ConfigManager   $configManager
  *
  * @return ConfigLogDiff
  */
 protected function computeChanges(ConfigInterface $config, ConfigManager $configManager)
 {
     $configId = $config->getId();
     $internalValues = $configManager->getProvider($configId->getScope())->getPropertyConfig()->getNotAuditableValues($configId);
     $changes = array_diff_key($configManager->getConfigChangeSet($config), $internalValues);
     if (empty($changes)) {
         return null;
     }
     $diff = new ConfigLogDiff();
     $diff->setScope($configId->getScope());
     $diff->setDiff($changes);
     $diff->setClassName($configId->getClassName());
     if ($configId instanceof FieldConfigId) {
         $diff->setFieldName($configId->getFieldName());
     }
     return $diff;
 }
开发者ID:northdakota,项目名称:platform,代码行数:23,代码来源:AuditManager.php

示例15: getMissingTranslationKeys

 /**
  * @param ConfigInterface $config
  *
  * @return array
  */
 protected function getMissingTranslationKeys(ConfigInterface $config)
 {
     $keys = ['label'];
     if ($config->getId() instanceof EntityConfigId) {
         $keys[] = 'plural_label';
     }
     $missingTranslationKeys = [];
     foreach ($keys as $key) {
         $transKey = $config->get($key);
         if (!$this->getTranslator()->hasTrans($transKey)) {
             $configId = $config->getId();
             if ($configId instanceof FieldConfigId) {
                 $transKey .= sprintf(' [Entity: %s; Field: %s]', $configId->getClassName(), $configId->getFieldName());
             } else {
                 $transKey .= sprintf(' [Entity: %s]', $configId->getClassName());
             }
             $missingTranslationKeys[] = $transKey;
         }
     }
     return $missingTranslationKeys;
 }
开发者ID:Maksold,项目名称:platform,代码行数:26,代码来源:ConfigTranslationTest.php


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