本文整理匯總了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();
}