本文整理汇总了PHP中Oro\Bundle\EntityConfigBundle\Provider\ConfigProvider::persist方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigProvider::persist方法的具体用法?PHP ConfigProvider::persist怎么用?PHP ConfigProvider::persist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\EntityConfigBundle\Provider\ConfigProvider
的用法示例。
在下文中一共展示了ConfigProvider::persist方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventListener(FormEvents::POST_SUBMIT, function () use($options) {
/** @var FieldConfigId $fieldConfigId */
$fieldConfigId = $options['config_id'];
$entityConfig = $this->extendConfigProvider->getConfig($fieldConfigId->getClassName());
if ($entityConfig->is('state', ExtendScope::STATE_ACTIVE) && !$this->hasRelation($entityConfig, $this->getRelationKey($fieldConfigId))) {
$entityConfig->set('state', ExtendScope::STATE_UPDATE);
$this->extendConfigProvider->persist($entityConfig);
$this->extendConfigProvider->flush();
}
});
}
示例2: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventListener(FormEvents::POST_SUBMIT, function () use($options) {
/** @var FieldConfigId $configId */
$configId = $options['config_id'];
$relationKey = ExtendHelper::buildRelationKey($configId->getClassName(), $configId->getFieldName(), 'manyToOne', 'Oro\\Bundle\\AttachmentBundle\\Entity\\File');
/** @var Config $entityExtendConfig */
$entityExtendConfig = $this->extendConfigProvider->getConfig($configId->getClassName());
if ($this->isApplicable($entityExtendConfig, $relationKey)) {
if ($entityExtendConfig->is('state', ExtendScope::STATE_ACTIVE)) {
$entityExtendConfig->set('state', ExtendScope::STATE_UPDATE);
$this->extendConfigProvider->persist($entityExtendConfig);
$this->extendConfigProvider->flush();
}
}
});
}
示例3: createTargetRelation
protected function createTargetRelation(Config $fieldConfig, $relationKey)
{
$selfEntityClass = $fieldConfig->getId()->getClassName();
$targetEntityClass = $fieldConfig->get('target_entity');
$selfConfig = $this->extendConfigProvider->getConfig($selfEntityClass);
$selfRelations = $selfConfig->get('relation');
$selfRelationConfig =& $selfRelations[$relationKey];
$selfRelationConfig['field_id'] = $fieldConfig;
$targetConfig = $this->extendConfigProvider->getConfig($targetEntityClass);
$targetRelations = $targetConfig->get('relation');
$targetRelationConfig =& $targetRelations[$relationKey];
$targetRelationConfig['target_field_id'] = $fieldConfig;
$selfConfig->set('relation', $selfRelations);
$targetConfig->set('relation', $targetRelations);
$this->extendConfigProvider->persist($targetConfig);
}
示例4: updateRelationValues
/**
* @param string $targetClass
* @param FieldConfigId $fieldId
*/
protected function updateRelationValues($targetClass, FieldConfigId $fieldId)
{
$targetConfig = $this->configProvider->getConfig($targetClass);
$relations = $targetConfig->get('relation', false, []);
$schema = $targetConfig->get('schema', false, []);
foreach ($relations as &$relation) {
if ($relation['target_field_id'] == $fieldId) {
if ($relation['owner']) {
$relation['assign'] = true;
}
/** @var FieldConfigId $relationFieldId */
$relationFieldId = $relation['field_id'];
if ($relationFieldId) {
$schema['relation'][$relationFieldId->getFieldName()] = $relationFieldId->getFieldName();
}
}
}
$targetConfig->set('relation', $relations);
$targetConfig->set('schema', $schema);
$this->configProvider->persist($targetConfig);
}
示例5: updateStateValues
/**
* @param ConfigInterface $extendConfig
*
* @return bool
*/
protected function updateStateValues(ConfigInterface $extendConfig)
{
$hasChanges = false;
$className = $extendConfig->getId()->getClassName();
$fieldConfigs = $this->configProvider->getConfigs($className, true);
if ($extendConfig->is('state', ExtendScope::STATE_DELETE)) {
// mark entity as deleted
if (!$extendConfig->is('is_deleted')) {
$extendConfig->set('is_deleted', true);
$this->configProvider->persist($extendConfig);
$hasChanges = true;
}
// mark all fields as deleted
foreach ($fieldConfigs as $fieldConfig) {
if (!$fieldConfig->is('is_deleted')) {
$fieldConfig->set('is_deleted', true);
$this->configProvider->persist($fieldConfig);
$hasChanges = true;
}
}
} elseif (!$extendConfig->is('state', ExtendScope::STATE_ACTIVE)) {
$hasNotActiveFields = false;
foreach ($fieldConfigs as $fieldConfig) {
if (!$fieldConfig->is('state', ExtendScope::STATE_DELETE) && !$fieldConfig->is('state', ExtendScope::STATE_ACTIVE)) {
$hasNotActiveFields = true;
break;
}
}
// Set entity state to active if all fields are active or deleted
if (!$hasNotActiveFields) {
$extendConfig->set('state', ExtendScope::STATE_ACTIVE);
$this->configProvider->persist($extendConfig);
}
$hasChanges = true;
}
if ($hasChanges) {
$this->configProvider->flush();
}
}
示例6: testPersistFlush
public function testPersistFlush()
{
$this->configProvider->persist($this->entityConfig);
$this->configProvider->flush();
}