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


PHP ConfigInterface::has方法代码示例

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


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

示例1: 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

示例2: 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

示例3: checkSchema

 /**
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  *
  * @param ConfigInterface $extendConfig
  * @param array|null $aliases
  * @param array|null $skippedOrigins
  */
 protected function checkSchema(ConfigInterface $extendConfig, $aliases, array $skippedOrigins = null)
 {
     $extendProvider = $this->em->getExtendConfigProvider();
     $className = $extendConfig->getId()->getClassName();
     $doctrine = [];
     $entityName = $className;
     if (ExtendHelper::isCustomEntity($className)) {
         $type = 'Custom';
         $tableName = $extendConfig->get('table');
         if (!$tableName) {
             $tableName = $this->nameGenerator->generateCustomEntityTableName($className);
         }
         $doctrine[$entityName] = ['type' => 'entity', 'table' => $tableName];
         // add 'id' field only for Custom entity without inheritance
         if (!$extendConfig->has('inherit')) {
             $doctrine[$entityName]['fields'] = ['id' => ['type' => 'integer', 'id' => true, 'generator' => ['strategy' => 'AUTO']]];
         }
     } else {
         $type = 'Extend';
         $entityName = $extendConfig->get('extend_class');
         $doctrine[$entityName] = ['type' => 'mappedSuperclass', 'fields' => []];
     }
     $schema = $extendConfig->get('schema');
     $properties = [];
     $relationProperties = $schema ? $schema['relation'] : [];
     $defaultProperties = [];
     $addRemoveMethods = [];
     $fieldConfigs = $extendProvider->filter($this->createOriginFilterCallback($skippedOrigins), $className, true);
     foreach ($fieldConfigs as $fieldConfig) {
         $this->checkFields($entityName, $fieldConfig, $relationProperties, $defaultProperties, $properties, $doctrine);
         $extendProvider->persist($fieldConfig);
     }
     $relations = $extendConfig->get('relation', false, []);
     foreach ($relations as &$relation) {
         if (!$relation['field_id']) {
             continue;
         }
         $relation['assign'] = true;
         if ($relation['field_id']->getFieldType() !== RelationType::MANY_TO_ONE) {
             $fieldName = $relation['field_id']->getFieldName();
             $addRemoveMethods[$fieldName]['self'] = $fieldName;
             if ($relation['target_field_id']) {
                 $addRemoveMethods[$fieldName]['target'] = $relation['target_field_id']->getFieldName();
                 $addRemoveMethods[$fieldName]['is_target_addremove'] = $relation['field_id']->getFieldType() === RelationType::MANY_TO_MANY;
             }
         }
         $this->updateRelationValues($relation['target_entity'], $relation['field_id']);
     }
     $extendConfig->set('relation', $relations);
     $schema = ['class' => $className, 'entity' => $entityName, 'type' => $type, 'property' => $properties, 'relation' => $relationProperties, 'default' => $defaultProperties, 'addremove' => $addRemoveMethods, 'doctrine' => $doctrine];
     if ($type == 'Extend') {
         $parentClassName = get_parent_class($className);
         if ($parentClassName == $entityName) {
             $parentClassName = $aliases[$entityName];
         }
         $schema['parent'] = $parentClassName;
         $schema['inherit'] = get_parent_class($parentClassName);
     } elseif ($extendConfig->has('inherit')) {
         $schema['inherit'] = $extendConfig->get('inherit');
     }
     $extendConfig->set('schema', $schema);
     $extendProvider->persist($extendConfig);
 }
开发者ID:nmallare,项目名称:platform,代码行数:71,代码来源:ExtendConfigDumper.php

示例4: isApplicableField

 /**
  * @param ConfigInterface         $extendConfig
  * @param ConfigProviderInterface $extendConfigProvider
  *
  * @return bool
  */
 protected function isApplicableField(ConfigInterface $extendConfig, ConfigProviderInterface $extendConfigProvider)
 {
     return !$extendConfig->is('is_deleted') && $extendConfig->is('owner', ExtendScope::OWNER_CUSTOM) && !$extendConfig->is('state', ExtendScope::STATE_NEW) && !in_array($extendConfig->getId()->getFieldType(), ['ref-one', 'ref-many']) && (!$extendConfig->has('target_entity') || !$extendConfigProvider->getConfig($extendConfig->get('target_entity'))->is('is_deleted'));
 }
开发者ID:xamin123,项目名称:platform,代码行数:10,代码来源:DynamicFieldsExtension.php

示例5: createSelfRelation

 /**
  * @param ConfigInterface $fieldConfig
  */
 protected function createSelfRelation(ConfigInterface $fieldConfig)
 {
     /** @var FieldConfigId $fieldConfigId */
     $fieldConfigId = $fieldConfig->getId();
     $targetEntityClass = $fieldConfig->get('target_entity');
     $selfFieldId = new FieldConfigId('extend', $fieldConfigId->getClassName(), $fieldConfigId->getFieldName(), $this->fieldTypeHelper->getUnderlyingType($fieldConfigId->getFieldType()));
     $selfConfig = $this->extendConfigProvider->getConfig($selfFieldId->getClassName());
     $relationKey = ExtendHelper::buildRelationKey($selfFieldId->getClassName(), $selfFieldId->getFieldName(), $selfFieldId->getFieldType(), $targetEntityClass);
     /**
      * in case of oneToMany relation
      * automatically create target field (type: manyToOne)
      */
     $targetFieldId = false;
     $owner = true;
     $targetOwner = false;
     if (in_array($selfFieldId->getFieldType(), RelationType::$toManyRelations)) {
         $classNameArray = explode('\\', $selfFieldId->getClassName());
         $relationFieldName = strtolower(array_pop($classNameArray)) . '_' . $selfFieldId->getFieldName();
         if ($selfFieldId->getFieldType() === RelationType::ONE_TO_MANY) {
             $owner = false;
             $targetOwner = true;
         }
         $targetFieldId = new FieldConfigId('extend', $targetEntityClass, $relationFieldName, ExtendHelper::getReverseRelationType($selfFieldId->getFieldType()));
     }
     $selfRelationConfig = ['assign' => false, 'field_id' => $selfFieldId, 'owner' => $owner, 'target_entity' => $targetEntityClass, 'target_field_id' => $targetFieldId];
     if ($fieldConfig->has('cascade')) {
         $selfRelationConfig['cascade'] = $fieldConfig->get('cascade');
     }
     $selfRelations = $selfConfig->get('relation') ?: [];
     $selfRelations[$relationKey] = $selfRelationConfig;
     $selfConfig->set('relation', $selfRelations);
     $this->extendConfigProvider->persist($selfConfig);
     $targetConfig = $this->extendConfigProvider->getConfig($targetEntityClass);
     $targetRelationConfig = ['assign' => false, 'field_id' => $targetFieldId, 'owner' => $targetOwner, 'target_entity' => $selfFieldId->getClassName(), 'target_field_id' => $selfFieldId];
     $targetRelations = $targetConfig->get('relation') ?: [];
     $targetRelations[$relationKey] = $targetRelationConfig;
     $targetConfig->set('relation', $targetRelations);
     $fieldConfig->set('relation_key', $relationKey);
     $this->extendConfigProvider->persist($targetConfig);
 }
开发者ID:northdakota,项目名称:platform,代码行数:43,代码来源:RelationEntityConfigDumperExtension.php

示例6: updateConfigValues

 /**
  * Updates values of the given config based on the given default values and $force flag
  *
  * @param ConfigInterface $config
  * @param array           $defaultValues
  * @param bool            $force
  *
  * @return bool  TRUE if at least one config value was updated; otherwise, FALSE
  */
 protected function updateConfigValues(ConfigInterface $config, array $defaultValues, $force)
 {
     $hasChanges = false;
     foreach ($defaultValues as $code => $value) {
         if (!$config->has($code) || $force) {
             $config->set($code, $value);
             $hasChanges = true;
         }
     }
     return $hasChanges;
 }
开发者ID:Maksold,项目名称:platform,代码行数:20,代码来源:ConfigManager.php

示例7: isApplicableField

 /**
  * @param ConfigInterface $extendConfig
  *
  * @return bool
  */
 protected function isApplicableField(ConfigInterface $extendConfig)
 {
     return !$extendConfig->is('is_deleted') && $extendConfig->is('owner', ExtendScope::OWNER_CUSTOM) && !$extendConfig->is('state', ExtendScope::STATE_NEW) && !in_array($extendConfig->getId()->getFieldType(), RelationType::$toAnyRelations) && (!$extendConfig->has('target_entity') || !$this->extendConfigProvider->getConfig($extendConfig->get('target_entity'))->is('is_deleted'));
 }
开发者ID:northdakota,项目名称:platform,代码行数:9,代码来源:ExtendFieldTypeGuesser.php

示例8: checkSchema

 /**
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  *
  * @param ConfigInterface $extendConfig
  * @param ConfigProvider  $configProvider
  * @param array|null      $aliases
  * @param callable|null   $filter function (ConfigInterface $config) : bool
  */
 protected function checkSchema(ConfigInterface $extendConfig, ConfigProvider $configProvider, $aliases, $filter = null)
 {
     $className = $extendConfig->getId()->getClassName();
     $doctrine = [];
     $entityName = $className;
     if (ExtendHelper::isCustomEntity($className)) {
         $type = 'Custom';
         $tableName = $extendConfig->get('table');
         if (!$tableName) {
             $tableName = $this->nameGenerator->generateCustomEntityTableName($className);
         }
         $doctrine[$entityName] = ['type' => 'entity', 'table' => $tableName];
         // add 'id' field only for Custom entity without inheritance
         if (!$extendConfig->has('inherit')) {
             $doctrine[$entityName]['fields'] = ['id' => ['type' => 'integer', 'id' => true, 'generator' => ['strategy' => 'AUTO']]];
         }
     } else {
         $type = 'Extend';
         $entityName = $extendConfig->get('extend_class');
         $doctrine[$entityName] = ['type' => 'mappedSuperclass', 'fields' => []];
     }
     $schema = $extendConfig->get('schema', false, []);
     $properties = isset($schema['property']) && null !== $filter ? $schema['property'] : [];
     $relationProperties = isset($schema['relation']) && null !== $filter ? $schema['relation'] : [];
     $defaultProperties = isset($schema['default']) && null !== $filter ? $schema['default'] : [];
     $addRemoveMethods = isset($schema['addremove']) && null !== $filter ? $schema['addremove'] : [];
     $fieldConfigs = null === $filter ? $configProvider->getConfigs($className, true) : $configProvider->filter($filter, $className, true);
     foreach ($fieldConfigs as $fieldConfig) {
         $this->updateFieldState($fieldConfig);
         $this->checkFieldSchema($entityName, $fieldConfig, $relationProperties, $defaultProperties, $properties, $doctrine);
     }
     $relations = $extendConfig->get('relation', false, []);
     foreach ($relations as $relation) {
         /** @var FieldConfigId $fieldId */
         $fieldId = $relation['field_id'];
         if (!$fieldId) {
             continue;
         }
         $fieldName = $fieldId->getFieldName();
         $isDeleted = $configProvider->hasConfig($fieldId->getClassName(), $fieldName) ? $configProvider->getConfig($fieldId->getClassName(), $fieldName)->is('is_deleted') : false;
         if (!isset($relationProperties[$fieldName])) {
             $relationProperties[$fieldName] = [];
             if ($isDeleted) {
                 $relationProperties[$fieldName]['private'] = true;
             }
         }
         if (!$isDeleted && $fieldId->getFieldType() !== RelationType::MANY_TO_ONE) {
             $addRemoveMethods[$fieldName]['self'] = $fieldName;
             /** @var FieldConfigId $targetFieldId */
             $targetFieldId = $relation['target_field_id'];
             if ($targetFieldId) {
                 $fieldType = $fieldId->getFieldType();
                 $addRemoveMethods[$fieldName]['target'] = $targetFieldId->getFieldName();
                 $addRemoveMethods[$fieldName]['is_target_addremove'] = $fieldType === RelationType::MANY_TO_MANY;
             }
         }
     }
     $schema = ['class' => $className, 'entity' => $entityName, 'type' => $type, 'property' => $properties, 'relation' => $relationProperties, 'default' => $defaultProperties, 'addremove' => $addRemoveMethods, 'doctrine' => $doctrine];
     if ($type === 'Extend') {
         $parentClassName = get_parent_class($className);
         if ($parentClassName === $entityName) {
             $parentClassName = $aliases[$entityName];
         }
         $schema['parent'] = $parentClassName;
         $schema['inherit'] = get_parent_class($parentClassName);
     } elseif ($extendConfig->has('inherit')) {
         $schema['inherit'] = $extendConfig->get('inherit');
     }
     $extendConfig->set('schema', $schema);
     $this->configManager->persist($extendConfig);
 }
开发者ID:Maksold,项目名称:platform,代码行数:81,代码来源:ExtendConfigDumper.php


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