本文整理汇总了PHP中Oro\Bundle\EntityConfigBundle\Config\ConfigInterface::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigInterface::getId方法的具体用法?PHP ConfigInterface::getId怎么用?PHP ConfigInterface::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\EntityConfigBundle\Config\ConfigInterface
的用法示例。
在下文中一共展示了ConfigInterface::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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]]);
}
}
示例5: 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);
}
示例6: 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;
}
示例7: 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);
}
示例8: 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);
}
}
}
示例9: isDisabledItem
/**
* @param array $config
*
* @return bool
*/
protected function isDisabledItem(array $config)
{
$createOnly = isset($config['options']['create_only']) && $config['options']['create_only'];
// disable config attribute if its value cannot be changed
if ($createOnly && $this->configModel->getId()) {
return true;
}
// disable field config attribute if its value cannot be changed for some field types
// an attribute marked as create only should not be disabled on create field page
if ($this->config->getId() instanceof FieldConfigId && !empty($config['options']['immutable_type']) && in_array($this->config->getId()->getFieldType(), $config['options']['immutable_type'], true) && (!$createOnly || $this->configModel->getId())) {
return true;
}
return false;
}
示例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: 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;
}
示例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: apply
/**
* {@inheritdoc}
*/
protected function apply(ConfigInterface $config)
{
$configId = $config->getId();
$className = $configId->getClassName();
if ($configId instanceof FieldConfigId) {
$fieldName = $configId->getFieldName();
if (!isset($this->initialStates['fields'][$className][$fieldName])) {
return true;
}
$initialState = $this->initialStates['fields'][$className][$fieldName];
} else {
if (!isset($this->initialStates['entities'][$className])) {
return true;
}
$initialState = $this->initialStates['entities'][$className];
}
if ($initialState === ExtendScope::STATE_ACTIVE) {
return true;
}
if ($initialState === ExtendScope::STATE_DELETE && !$config->is('state', ExtendScope::STATE_DELETE)) {
return true;
}
return false;
}
示例15: createTargetRelation
/**
* @param ConfigInterface $fieldConfig
* @param string $relationKey
*/
protected function createTargetRelation(ConfigInterface $fieldConfig, $relationKey)
{
/** @var FieldConfigId $fieldConfigId */
$fieldConfigId = $fieldConfig->getId();
$selfFieldId = new FieldConfigId('extend', $fieldConfigId->getClassName(), $fieldConfigId->getFieldName(), $this->fieldTypeHelper->getUnderlyingType($fieldConfigId->getFieldType()));
$targetEntityClass = $fieldConfig->get('target_entity');
$selfConfig = $this->extendConfigProvider->getConfig($selfFieldId->getClassName());
$selfRelations = $selfConfig->get('relation');
$selfRelationConfig =& $selfRelations[$relationKey];
$selfRelationConfig['field_id'] = $selfFieldId;
$targetConfig = $this->extendConfigProvider->getConfig($targetEntityClass);
$targetRelations = $targetConfig->get('relation');
$targetRelationConfig =& $targetRelations[$relationKey];
$targetRelationConfig['target_field_id'] = $selfFieldId;
$selfConfig->set('relation', $selfRelations);
$targetConfig->set('relation', $targetRelations);
$this->extendConfigProvider->persist($targetConfig);
}