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


PHP Config\ConfigManager类代码示例

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


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

示例1: onBuildBefore

 /**
  * @param BuildBefore $event
  * @return bool
  */
 public function onBuildBefore(BuildBefore $event)
 {
     $datagrid = $event->getDatagrid();
     $config = $event->getConfig();
     $entityClassName = $datagrid->getParameters()->get('class_name');
     $fieldName = $datagrid->getParameters()->get('field_name');
     $entityId = $datagrid->getParameters()->get('id');
     $extendConfigProvider = $this->configManager->getProvider('extend');
     $extendFieldConfig = $extendConfigProvider->getConfig($entityClassName, $fieldName);
     $targetEntityName = $extendFieldConfig->get('target_entity');
     $targetFieldNames = $extendFieldConfig->get('target_grid');
     // build 'assigned' field expression
     if ($entityId) {
         $extendEntityConfig = $extendConfigProvider->getConfig($entityClassName);
         $relations = $extendEntityConfig->get('relation');
         $relation = $relations[$extendFieldConfig->get('relation_key')];
         $targetFieldName = $relation['target_field_id']->getFieldName();
         $fieldType = $extendFieldConfig->getId()->getFieldType();
         $operator = $fieldType == 'oneToMany' ? '=' : 'MEMBER OF';
         $whenExpr = '(:relation ' . $operator . ' o.' . $targetFieldName . ' OR o.id IN (:data_in))' . ' AND o.id NOT IN (:data_not_in)';
     } else {
         $whenExpr = 'o.id IN (:data_in) AND o.id NOT IN (:data_not_in)';
     }
     $assignedExpr = "CASE WHEN " . $whenExpr . " THEN true ELSE false END";
     // build a query skeleton
     $query = ['select' => ['o.id', $assignedExpr . ' as assigned'], 'from' => [['table' => $targetEntityName, 'alias' => 'o']]];
     $config->offsetSetByPath('[source][query]', $query);
     // enable AdditionalFieldsExtension to add all other fields
     $config->offsetSetByPath('[options][entity_name]', $targetEntityName);
     $config->offsetSetByPath('[options][additional_fields]', $targetFieldNames);
 }
开发者ID:xamin123,项目名称:platform,代码行数:35,代码来源:EntityRelationGridListener.php

示例2: getEntityAlias

 /**
  * {@inheritdoc}
  */
 public function getEntityAlias($entityClass)
 {
     if ($this->configManager->hasConfig($entityClass)) {
         // check for enums
         $enumCode = $this->configManager->getProvider('enum')->getConfig($entityClass)->get('code');
         if ($enumCode) {
             $entityAlias = $this->getEntityAliasFromConfig($entityClass);
             if (null !== $entityAlias) {
                 return $entityAlias;
             }
             return $this->createEntityAlias(str_replace('_', '', $enumCode));
         }
         // check for dictionaries
         $groups = $this->configManager->getProvider('grouping')->getConfig($entityClass)->get('groups');
         if (!empty($groups) && in_array(GroupingScope::GROUP_DICTIONARY, $groups, true)) {
             // delegate aliases generation to default provider
             return null;
         }
         // exclude hidden entities
         if ($this->configManager->isHiddenModel($entityClass)) {
             return false;
         }
         // check for custom entities
         if (ExtendHelper::isCustomEntity($entityClass)) {
             $entityAlias = $this->getEntityAliasFromConfig($entityClass);
             if (null !== $entityAlias) {
                 return $entityAlias;
             }
             return $this->createEntityAlias('Extend' . ExtendHelper::getShortClassName($entityClass));
         }
     }
     return null;
 }
开发者ID:antrampa,项目名称:platform,代码行数:36,代码来源:ExtendEntityAliasProvider.php

示例3: setDefaultOptions

 /**
  * Options:
  * - grid_name - name of grid that will be used for entity selection
  * - grid_parameters - parameters need to be passed to grid request
  * - grid_render_parameters - render parameters need to be set for grid rendering
  * - existing_entity_grid_id - grid row field name used as entity identifier
  * - create_enabled - enables new entity creation
  * - create_acl - ACL resource used to determine that create is allowed, by default CREATE for entity used
  * - create_form_route - route name for creation form
  * - create_form_route_parameters - route parameters for create_form_route_parameters
  *
  * {@inheritDoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(['existing_entity_grid_id' => 'id', 'create_enabled' => true, 'create_acl' => null, 'create_form_route' => null, 'create_form_route_parameters' => [], 'grid_name' => null, 'grid_parameters' => [], 'grid_render_parameters' => []]);
     $resolver->setNormalizers(['create_enabled' => function (Options $options, $createEnabled) {
         $createRouteName = $options->get('create_form_route');
         $createEnabled = $createEnabled && !empty($createRouteName);
         if ($createEnabled) {
             $aclName = $options->get('create_acl');
             if (empty($aclName)) {
                 $aclObjectName = 'Entity:' . $options->get('entity_class');
                 $createEnabled = $this->securityFacade->isGranted('CREATE', $aclObjectName);
             } else {
                 $createEnabled = $this->securityFacade->isGranted($aclName);
             }
         }
         return $createEnabled;
     }, 'grid_name' => function (Options $options, $gridName) {
         if (!empty($gridName)) {
             return $gridName;
         }
         $formConfig = $this->configManager->getProvider('form')->getConfig($options->get('entity_class'));
         if ($formConfig->has('grid_name')) {
             return $formConfig->get('grid_name');
         }
         throw new InvalidConfigurationException('The option "grid_name" must be set.');
     }]);
 }
开发者ID:xamin123,项目名称:platform,代码行数:40,代码来源:OroEntitySelectOrCreateInlineType.php

示例4: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $configModel = $options['config_model'];
     $data = array();
     if ($configModel instanceof FieldConfigModel) {
         $className = $configModel->getEntity()->getClassName();
         $fieldName = $configModel->getFieldName();
         $fieldType = $configModel->getType();
         $configType = PropertyConfigContainer::TYPE_FIELD;
     } else {
         $className = $configModel->getClassName();
         $fieldName = null;
         $fieldType = null;
         $configType = PropertyConfigContainer::TYPE_ENTITY;
     }
     foreach ($this->configManager->getProviders() as $provider) {
         if ($provider->getPropertyConfig()->hasForm($configType, $fieldType)) {
             $config = $provider->getConfig($className, $fieldName);
             $builder->add($provider->getScope(), new ConfigScopeType($provider->getPropertyConfig()->getFormItems($configType, $fieldType), $config, $this->configManager, $configModel), array('block_config' => (array) $provider->getPropertyConfig()->getFormBlockConfig($configType)));
             $data[$provider->getScope()] = $config->all();
         }
     }
     if ($fieldType == 'optionSet') {
         $data['extend']['set_options'] = $this->configManager->getEntityManager()->getRepository(OptionSet::ENTITY_NAME)->findOptionsByField($configModel->getId());
     }
     $builder->setData($data);
     $builder->addEventSubscriber(new ConfigSubscriber($this->configManager));
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:31,代码来源:ConfigType.php

示例5: getEntityChoiceList

 protected function getEntityChoiceList($entityClassName, $relationType)
 {
     $choices = array();
     $extendEntityConfig = $this->configManager->getProvider('extend');
     /** @var EntityConfigId[] $entityIds */
     $entityIds = $this->targetEntity ? array($extendEntityConfig->getId($this->targetEntity)) : $extendEntityConfig->getIds();
     if (in_array($relationType, array(RelationTypeBase::ONE_TO_MANY, RelationTypeBase::MANY_TO_MANY))) {
         $entityIds = array_filter($entityIds, function (EntityConfigId $configId) {
             $config = $this->configManager->getConfig($configId);
             return $config->is('is_extend');
         });
     }
     $entityIds = array_filter($entityIds, function (EntityConfigId $configId) {
         $config = $this->configManager->getConfig($configId);
         return $config->is('is_extend', false) || !$config->is('state', ExtendScope::STATE_NEW);
     });
     foreach ($entityIds as $entityId) {
         $className = $entityId->getClassName();
         if ($className != $entityClassName) {
             $entityConfig = $this->configManager->getProvider('entity')->getConfig($className);
             $choices[$className] = new ChoiceListItem($entityConfig->get('label'), array('data-icon' => $entityConfig->get('icon')));
         }
     }
     return $choices;
 }
开发者ID:nmallare,项目名称:platform,代码行数:25,代码来源:TargetType.php

示例6: testFlush

 public function testFlush()
 {
     $model = new EntityConfigModel(self::ENTITY_CLASS);
     $entityConfigId = new EntityConfigId('entity', self::ENTITY_CLASS);
     $entityConfig = new Config($entityConfigId);
     $entityConfig->set('icon', 'test_icon');
     $entityConfig->set('label', 'test_label');
     $entityPropertyConfig = new PropertyConfigContainer(['entity' => ['items' => ['icon' => [], 'label' => ['options' => ['indexed' => true]]]]]);
     $this->entityConfigProvider->expects($this->once())->method('getPropertyConfig')->will($this->returnValue($entityPropertyConfig));
     $testConfigId = new EntityConfigId('test', self::ENTITY_CLASS);
     $testConfig = new Config($testConfigId);
     $testConfig->set('attr1', 'test_attr1');
     $testPropertyConfig = new PropertyConfigContainer(['entity' => ['items' => ['attr1' => []]]]);
     $this->testConfigProvider->expects($this->once())->method('getPropertyConfig')->will($this->returnValue($testPropertyConfig));
     $this->modelManager->expects($this->once())->method('getEntityModel')->with($entityConfigId->getClassName())->will($this->returnValue($model));
     $em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $this->modelManager->expects($this->any())->method('getEntityManager')->will($this->returnValue($em));
     $this->setFlushExpectations($em, [$model]);
     $this->eventDispatcher->expects($this->at(2))->method('dispatch')->with(Events::PRE_FLUSH, new PreFlushConfigEvent(['entity' => $entityConfig, 'test' => $testConfig], $this->configManager));
     $this->configManager->persist($entityConfig);
     $this->configManager->persist($testConfig);
     $this->configManager->flush();
     $this->assertEquals(['icon' => 'test_icon', 'label' => 'test_label'], $model->toArray('entity'));
     $this->assertEquals(['attr1' => 'test_attr1'], $model->toArray('test'));
     $this->assertCount(3, $model->getIndexedValues());
     $this->assertEquals('entity_config', $model->getIndexedValues()[0]->getScope());
     $this->assertEquals('module_name', $model->getIndexedValues()[0]->getCode());
     $this->assertEquals('entity_config', $model->getIndexedValues()[1]->getScope());
     $this->assertEquals('entity_name', $model->getIndexedValues()[1]->getCode());
     $this->assertEquals('entity', $model->getIndexedValues()[2]->getScope());
     $this->assertEquals('label', $model->getIndexedValues()[2]->getCode());
 }
开发者ID:Maksold,项目名称:platform,代码行数:32,代码来源:FlushConfigManagerTest.php

示例7: getConfiguration

 /**
  * {@inheritdoc}
  */
 public function getConfiguration()
 {
     $configuration = parent::getConfiguration();
     $className = $this->source->getEntity();
     $metadata = $this->configManager->getEntityMetadata($className);
     if (!$metadata || empty($metadata->routeView)) {
         return $configuration;
     }
     $fromPart = $configuration->offsetGetByPath('[source][query][from]');
     $entityAlias = null;
     $doctrineMetadata = $this->doctrine->getManagerForClass($className)->getClassMetadata($className);
     $identifiers = $doctrineMetadata->getIdentifier();
     $primaryKey = array_shift($identifiers);
     foreach ($fromPart as $piece) {
         if ($piece['table'] == $className) {
             $entityAlias = $piece['alias'];
             break;
         }
     }
     if (!$entityAlias || !$primaryKey || count($identifiers) > 1 || !$this->isActionSupported($primaryKey)) {
         return $configuration;
     }
     $viewAction = ['view' => ['type' => 'navigate', 'label' => 'oro.report.datagrid.view', 'acl_resource' => 'VIEW;entity:' . $className, 'icon' => 'eye-open', 'link' => 'view_link', 'rowAction' => true]];
     $properties = [$primaryKey => null, 'view_link' => ['type' => 'url', 'route' => $metadata->routeView, 'params' => [$primaryKey]]];
     $configuration->offsetAddToArrayByPath('[source][query][select]', ["{$entityAlias}.{$primaryKey}"]);
     $configuration->offsetAddToArrayByPath('[properties]', $properties);
     $configuration->offsetAddToArrayByPath('[actions]', $viewAction);
     return $configuration;
 }
开发者ID:xamin123,项目名称:platform,代码行数:32,代码来源:BaseReportConfigurationBuilder.php

示例8: generateProxies

 /**
  * Generate doctrine proxy classes for extended entities
  */
 public function generateProxies()
 {
     $em = $this->configManager->getEntityManager();
     $isAutoGenerated = $em->getConfiguration()->getAutoGenerateProxyClasses();
     if (!$isAutoGenerated) {
         $proxyDir = $em->getConfiguration()->getProxyDir();
         if (!empty($this->cacheDir) && $this->kernelCacheDir !== $this->cacheDir && strpos($proxyDir, $this->kernelCacheDir) === 0) {
             $proxyDir = $this->cacheDir . substr($proxyDir, strlen($this->kernelCacheDir));
         }
         $extendConfigProvider = $this->configManager->getProvider('extend');
         $extendConfigs = $extendConfigProvider->getConfigs(null, true);
         $metadataFactory = $em->getMetadataFactory();
         $proxyFactory = $em->getProxyFactory();
         foreach ($extendConfigs as $extendConfig) {
             if (!$extendConfig->is('is_extend')) {
                 continue;
             }
             if ($extendConfig->in('state', [ExtendScope::STATE_NEW])) {
                 continue;
             }
             $entityClass = $extendConfig->getId()->getClassName();
             $proxyFileName = $proxyDir . DIRECTORY_SEPARATOR . '__CG__' . str_replace('\\', '', $entityClass) . '.php';
             $metadata = $metadataFactory->getMetadataFor($entityClass);
             $proxyFactory->generateProxyClasses([$metadata], $proxyDir);
             clearstatcache(true, $proxyFileName);
         }
     }
 }
开发者ID:northdakota,项目名称:platform,代码行数:31,代码来源:EntityProxyGenerator.php

示例9: getObjects

 /**
  * Returns objects extracted from simple search
  *
  * @param User $user
  * @param string $entityClass
  * @param string $searchString
  * @param int $offset
  * @param int $maxResults
  *
  * @return array
  */
 protected function getObjects(User $user, $entityClass, $searchString, $offset, $maxResults)
 {
     $objects = [];
     if (!$this->configManager->hasConfig($entityClass)) {
         return $objects;
     }
     $classNames = $this->shareScopeProvider->getClassNamesBySharingScopeConfig($entityClass);
     if (!$classNames) {
         return $objects;
     }
     $tables = [];
     foreach ($classNames as $className) {
         $metadata = $this->em->getClassMetadata($className);
         $tables[] = $metadata->getTableName();
     }
     $searchResults = $this->indexer->simpleSearch($searchString, $offset, $maxResults, $tables);
     list($userIds, $buIds, $orgIds) = $this->getIdsByClass($searchResults, $user);
     if ($orgIds) {
         $organizations = $this->em->getRepository('OroOrganizationBundle:Organization')->getEnabledOrganizations($orgIds);
         $objects = array_merge($objects, $organizations);
     }
     if ($buIds) {
         $businessUnits = $this->em->getRepository('OroOrganizationBundle:BusinessUnit')->getBusinessUnits($buIds);
         $objects = array_merge($objects, $businessUnits);
     }
     if ($userIds) {
         $users = $this->em->getRepository('OroUserBundle:User')->findUsersByIds($userIds);
         $objects = array_merge($objects, $users);
     }
     return $objects;
 }
开发者ID:kstupak,项目名称:platform,代码行数:42,代码来源:SecurityIndexer.php

示例10: getExtendConfigProvider

 /**
  * @return ConfigProvider
  */
 protected function getExtendConfigProvider()
 {
     if (!$this->extendConfigProvider) {
         $this->extendConfigProvider = $this->configManager->getProvider('extend');
     }
     return $this->extendConfigProvider;
 }
开发者ID:Maksold,项目名称:platform,代码行数:10,代码来源:ApplicableEntitiesType.php

示例11: postSubmit

 /**
  * POST_SUBMIT event handler
  *
  * @param FormEvent $event
  */
 public function postSubmit(FormEvent $event)
 {
     $form = $event->getForm();
     $options = $form->getConfig()->getOptions();
     /** @var ConfigIdInterface $configId */
     $configId = $options['config_id'];
     if (!$form->isValid()) {
         return;
     }
     // change the entity state to "Requires update" if the attribute has "require_schema_update" option
     // and the value of the attribute was changed
     $configProvider = $this->configManager->getProvider($configId->getScope());
     if ($configProvider->getPropertyConfig()->isSchemaUpdateRequired($form->getName(), $configId)) {
         $newVal = $form->getData();
         $oldVal = $this->configManager->getConfig($configId)->get($form->getName());
         if ($this->isSchemaUpdateRequired($newVal, $oldVal)) {
             $extendConfigProvider = $this->configManager->getProvider('extend');
             $extendConfig = $extendConfigProvider->getConfig($configId->getClassName());
             if ($extendConfig->is('state', ExtendScope::STATE_ACTIVE)) {
                 $extendConfig->set('state', ExtendScope::STATE_UPDATE);
                 $this->configManager->persist($extendConfig);
             }
         }
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:30,代码来源:AbstractConfigType.php

示例12: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     $vars = ['configs' => $options['configs']];
     if ($form->getData()) {
         $data = $form->getParent()->getData();
         $fieldConfig = $this->cm->getProvider('extend')->getConfig($data, $form->getName());
         if ($form->getData()) {
             /** @var ConverterInterface|EntitySelectHandler $converter */
             $converter = $options['converter'];
             $result = [];
             if ($converter instanceof EntitySelectHandler) {
                 $converter->initForEntity($fieldConfig->getId()->getClassName(), $fieldConfig->get('target_field'));
             }
             if (isset($options['configs']['multiple']) && $options['configs']['multiple']) {
                 foreach ($form->getData() as $item) {
                     $result[] = $converter->convertItem($item);
                 }
             } else {
                 $result[] = $converter->convertItem($form->getData());
             }
             $vars['attr'] = ['data-selected-data' => json_encode($result)];
         }
     }
     $view->vars = array_replace_recursive($view->vars, $vars);
 }
开发者ID:ramunasd,项目名称:platform,代码行数:28,代码来源:EntitySelectType.php

示例13: preUpdate

 /**
  * {@inheritdoc}
  */
 public function preUpdate()
 {
     $extendConfigProvider = $this->configManager->getProvider('extend');
     $entityConfigs = $extendConfigProvider->getConfigs();
     foreach ($entityConfigs as $entityConfig) {
         if (!$entityConfig->is('is_extend')) {
             continue;
         }
         $fieldConfigs = $extendConfigProvider->getConfigs($entityConfig->getId()->getClassName());
         foreach ($fieldConfigs as $fieldConfig) {
             if (!$fieldConfig->is('state', ExtendScope::STATE_NEW)) {
                 continue;
             }
             /** @var FieldConfigId $fieldConfigId */
             $fieldConfigId = $fieldConfig->getId();
             if (in_array($fieldConfigId->getFieldType(), ['file', 'image'])) {
                 // create a relation
                 $relationKey = $this->relationBuilder->addManyToOneRelation($entityConfig, 'Oro\\Bundle\\AttachmentBundle\\Entity\\File', $fieldConfigId->getFieldName(), 'id', ['importexport' => ['process_as_scalar' => true]], $fieldConfigId->getFieldType());
                 // set cascade persist
                 $relations = $entityConfig->get('relation');
                 $cascade = isset($relations[$relationKey]['cascade']) ? $relations[$relationKey]['cascade'] : [];
                 $cascade[] = 'persist';
                 $relations[$relationKey]['cascade'] = $cascade;
                 $entityConfig->set('relation', $relations);
                 $extendConfigProvider->persist($entityConfig);
             }
         }
     }
 }
开发者ID:xamin123,项目名称:platform,代码行数:32,代码来源:FileEntityConfigDumperExtension.php

示例14: runActivityLists

 /**
  * @param LoggerInterface $logger
  * @param bool            $dryRun
  */
 protected function runActivityLists(LoggerInterface $logger, $dryRun = false)
 {
     // @todo: this workaround should be removed in BAP-9156
     $this->configManager->clear();
     $targetEntities = $this->provider->getTargetEntityClasses(false);
     $toSchema = clone $this->schema;
     $hasSchemaChanges = false;
     foreach ($targetEntities as $targetEntity) {
         $associationName = ExtendHelper::buildAssociationName($targetEntity, ActivityListEntityConfigDumperExtension::ASSOCIATION_KIND);
         $relationTableName = $this->nameGenerator->generateManyToManyJoinTableName(ActivityListEntityConfigDumperExtension::ENTITY_CLASS, $associationName, $targetEntity);
         if (!$toSchema->hasTable($relationTableName)) {
             $hasSchemaChanges = true;
             $this->activityListExtension->addActivityListAssociation($toSchema, $this->metadataHelper->getTableNameByEntityClass($targetEntity));
         }
     }
     if ($hasSchemaChanges) {
         $comparator = new Comparator();
         $platform = $this->connection->getDatabasePlatform();
         $schemaDiff = $comparator->compare($this->schema, $toSchema);
         $queries = $schemaDiff->toSql($platform);
         foreach ($queries as $query) {
             $this->logQuery($logger, $query);
             if (!$dryRun) {
                 $this->connection->executeQuery($query);
             }
         }
     }
 }
开发者ID:woei66,项目名称:platform,代码行数:32,代码来源:ActivityListMigrationQuery.php

示例15: preUpdate

 /**
  * {@inheritdoc}
  */
 public function preUpdate()
 {
     $extendConfigProvider = $this->configManager->getProvider('extend');
     $entityConfigs = $extendConfigProvider->getConfigs();
     foreach ($entityConfigs as $entityConfig) {
         if (!$entityConfig->is('is_extend')) {
             continue;
         }
         $fieldConfigs = $extendConfigProvider->getConfigs($entityConfig->getId()->getClassName());
         foreach ($fieldConfigs as $fieldConfig) {
             if (!$fieldConfig->in('state', [ExtendScope::STATE_NEW, ExtendScope::STATE_UPDATE])) {
                 continue;
             }
             /** @var FieldConfigId $fieldConfigId */
             $fieldConfigId = $fieldConfig->getId();
             if (in_array($fieldConfigId->getFieldType(), ['file', 'image'])) {
                 $cascade = $fieldConfig->get('cascade', false, []);
                 if (!in_array('persist', $cascade, true)) {
                     $cascade[] = 'persist';
                 }
                 $this->relationBuilder->addManyToOneRelation($entityConfig, 'Oro\\Bundle\\AttachmentBundle\\Entity\\File', $fieldConfigId->getFieldName(), 'id', ['extend' => ['cascade' => $cascade], 'importexport' => ['process_as_scalar' => true]], $fieldConfigId->getFieldType());
             }
         }
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:28,代码来源:FileEntityConfigDumperExtension.php


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