本文整理汇总了PHP中Oro\Bundle\EntityConfigBundle\Config\ConfigInterface::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigInterface::get方法的具体用法?PHP ConfigInterface::get怎么用?PHP ConfigInterface::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\EntityConfigBundle\Config\ConfigInterface
的用法示例。
在下文中一共展示了ConfigInterface::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
}
}
}
示例2: 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);
}
示例3: 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;
}
}
}
}
示例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;
}
示例5: 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]]);
}
}
示例6: 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());
}
}
}
示例7: 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;
}
}
}
}
}
示例8: build
/**
* {@inheritdoc}
*/
public function build(ClassMetadataBuilder $metadataBuilder, ConfigInterface $extendConfig)
{
$relations = $extendConfig->get('relation', false, []);
$schema = $extendConfig->get('schema', false, []);
foreach ($relations as $relationKey => $relation) {
/** @var FieldConfigId $fieldId */
$fieldId = $relation['field_id'];
if ($fieldId && isset($schema['relation'][$fieldId->getFieldName()])) {
switch ($fieldId->getFieldType()) {
case RelationType::MANY_TO_ONE:
$this->buildManyToOneRelation($metadataBuilder, $fieldId, $relation);
break;
case RelationType::ONE_TO_MANY:
$this->buildOneToManyRelation($metadataBuilder, $fieldId, $relation, $relationKey);
break;
case RelationType::MANY_TO_MANY:
$this->buildManyToManyRelation($metadataBuilder, $fieldId, $relation);
break;
}
}
}
}
示例9: 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);
}
}
}
示例10: 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;
}
示例11: getHasAssignedExpression
/**
* @return string
*/
protected function getHasAssignedExpression()
{
$entityConfig = $this->configManager->getProvider('extend')->getConfig($this->relationConfig->getId()->getClassName());
$relations = $entityConfig->get('relation');
$relation = $relations[$this->relationConfig->get('relation_key')];
$fieldName = ExtendConfigDumper::FIELD_PREFIX . $relation['target_field_id']->getFieldName();
if (null === $this->hasAssignedExpression) {
$entityAlias = 'ce';
$compOperator = $this->relationConfig->getId()->getFieldType() == 'oneToMany' ? '=' : 'MEMBER OF';
if ($this->getRelation()->getId()) {
$this->hasAssignedExpression = "CASE WHEN " . "(:relation {$compOperator} {$entityAlias}.{$fieldName} OR {$entityAlias}.id IN (:data_in)) AND " . "{$entityAlias}.id NOT IN (:data_not_in) " . "THEN true ELSE false END";
} else {
$this->hasAssignedExpression = "CASE WHEN " . "{$entityAlias}.id IN (:data_in) AND {$entityAlias}.id NOT IN (:data_not_in) " . "THEN true ELSE false END";
}
}
return $this->hasAssignedExpression;
}
示例12: 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;
}
示例13: processData
/**
* @param ConfigProvider $provider
* @param ConfigInterface $config
* @param array $data
* @param string $state
* @return array
*/
protected function processData(ConfigProvider $provider, ConfigInterface $config, array $data, $state)
{
if ($provider->getScope() === 'enum' && $config->get('enum_code')) {
return [];
}
$translatable = $provider->getPropertyConfig()->getTranslatableValues($config->getId());
$translations = [];
foreach ($data as $code => $value) {
if (in_array($code, $translatable, true)) {
// check if a label text was changed
$labelKey = $config->get($code);
if ($state === ExtendScope::STATE_NEW || !$this->translationHelper->isTranslationEqual($labelKey, $value)) {
$translations[$labelKey] = $value;
}
// replace label text with label name in $value variable
$value = $labelKey;
}
$config->set($code, $value);
}
$this->configManager->persist($config);
return $translations;
}
示例14: getInitialElements
/**
* @param object[] $entities
* @param object|null $defaultEntity
* @param ConfigInterface $extendConfig
*
* @return array
*/
protected function getInitialElements($entities, $defaultEntity, ConfigInterface $extendConfig)
{
$result = [];
foreach ($entities as $entity) {
$extraData = [];
foreach ($extendConfig->get('target_grid') as $fieldName) {
$label = $this->configManager->getProvider('entity')->getConfig($extendConfig->get('target_entity'), $fieldName)->get('label');
$extraData[] = ['label' => $this->translator->trans($label), 'value' => FieldAccessor::getValue($entity, $fieldName)];
}
$title = [];
foreach ($extendConfig->get('target_title') as $fieldName) {
$title[] = FieldAccessor::getValue($entity, $fieldName);
}
/**
* If using ExtendExtension with a form that only updates part of
* of the entity, we need to make sure an ID is present. An ID
* isn't present when a PHP-based Validation Constraint is fired.
*/
if (null !== $entity->getId()) {
$result[] = ['id' => $entity->getId(), 'label' => implode(' ', $title), 'link' => $this->router->generate('oro_entity_detailed', ['id' => $entity->getId(), 'entityName' => str_replace('\\', '_', $extendConfig->getId()->getClassName()), 'fieldName' => $extendConfig->getId()->getFieldName()]), 'extraData' => $extraData, 'isDefault' => $defaultEntity != null && $defaultEntity->getId() == $entity->getId()];
}
}
return $result;
}
示例15: ensureReverseRelationCompleted
/**
* Makes sure that both source and target entities know about a reverse relation
*
* @param ConfigInterface $fieldConfig
*/
protected function ensureReverseRelationCompleted(ConfigInterface $fieldConfig)
{
/** @var FieldConfigId $fieldConfigId */
$fieldConfigId = $fieldConfig->getId();
$relationKey = $fieldConfig->get('relation_key');
$selfConfig = $this->extendConfigProvider->getConfig($fieldConfigId->getClassName());
$selfRelations = $selfConfig->get('relation', false, []);
if (isset($selfRelations[$relationKey]['field_id']) && $selfRelations[$relationKey]['field_id']) {
return;
}
$targetConfig = $this->extendConfigProvider->getConfig($fieldConfig->get('target_entity'));
$targetRelations = $targetConfig->get('relation', false, []);
if (!isset($targetRelations[$relationKey])) {
return;
}
$selfFieldId = new FieldConfigId('extend', $fieldConfigId->getClassName(), $fieldConfigId->getFieldName(), $this->fieldTypeHelper->getUnderlyingType($fieldConfigId->getFieldType()));
$selfRelations[$relationKey]['field_id'] = $selfFieldId;
$targetRelations[$relationKey]['target_field_id'] = $selfFieldId;
$selfConfig->set('relation', $selfRelations);
$targetConfig->set('relation', $targetRelations);
$this->configManager->persist($selfConfig);
$this->configManager->persist($targetConfig);
}