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


PHP ConfigManager::getProvider方法代码示例

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


在下文中一共展示了ConfigManager::getProvider方法的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: 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

示例4: 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

示例5: getFieldConfigValue

 /**
  * @param string $className The entity class name
  * @param string $fieldName The entity field name
  * @param string $attrName  The entity config attribute name
  * @param string $scope     The entity config scope name
  * @return array
  */
 public function getFieldConfigValue($className, $fieldName, $attrName, $scope = 'entity')
 {
     if (!$this->configManager->hasConfig($className, $fieldName)) {
         return null;
     }
     return $this->configManager->getProvider($scope)->getConfig($className, $fieldName)->get($attrName);
 }
开发者ID:northdakota,项目名称:platform,代码行数:14,代码来源:ConfigExtension.php

示例6: getActivityContext

 /**
  * Returns the context for the given activity class and id
  *
  * @param string $class The FQCN of the activity entity
  * @param        $id
  *
  * @return array
  */
 public function getActivityContext($class, $id)
 {
     $currentUser = $this->securityTokenStorage->getToken()->getUser();
     $userClass = ClassUtils::getClass($currentUser);
     $entity = $this->doctrineHelper->getEntity($class, $id);
     $result = [];
     if (!$entity || !$entity instanceof ActivityInterface) {
         return $result;
     }
     $targets = $entity->getActivityTargetEntities();
     $entityProvider = $this->configManager->getProvider('entity');
     foreach ($targets as $target) {
         $targetClass = ClassUtils::getClass($target);
         $targetId = $target->getId();
         if ($userClass === $targetClass && $currentUser->getId() === $targetId) {
             continue;
         }
         $item = [];
         $config = $entityProvider->getConfig($targetClass);
         $safeClassName = $this->entityClassNameHelper->getUrlSafeClassName($targetClass);
         $item = $this->prepareItemTitle($item, $targetClass, $target, $targetId);
         $item['activityClassAlias'] = $this->entityAliasResolver->getPluralAlias($class);
         $item['entityId'] = $id;
         $item['targetId'] = $targetId;
         $item['targetClassName'] = $safeClassName;
         $item['icon'] = $config->get('icon');
         $item['link'] = $this->getContextLink($targetClass, $targetId);
         $item = $this->dispatchContextTitle($item, $targetClass);
         $result[] = $item;
     }
     return $result;
 }
开发者ID:woei66,项目名称:platform,代码行数:40,代码来源:ActivityContextApiEntityManager.php

示例7: 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

示例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: isApplicableField

 /**
  * {@inheritdoc}
  */
 public function isApplicableField($className, $fieldName)
 {
     $fieldModel = $this->configManager->getConfigFieldModel($className, $fieldName);
     if (!$fieldModel) {
         // this serializer works with non configurable entities as well
         return true;
     }
     if ($fieldModel->getMode() === ConfigModelManager::MODE_HIDDEN) {
         // exclude hidden fields
         return false;
     }
     $extendConfigProvider = $this->configManager->getProvider('extend');
     $extendConfig = $extendConfigProvider->getConfig($className, $fieldName);
     if (!$this->allowExtendedFields && $extendConfig->is('is_extend')) {
         // exclude extended fields if it is requested
         return false;
     }
     if ($extendConfig->is('is_deleted') || $extendConfig->is('state', ExtendScope::STATE_NEW)) {
         // exclude deleted and not created yet fields
         return false;
     }
     if ($extendConfig->has('target_entity') && $extendConfigProvider->getConfig($extendConfig->get('target_entity'))->is('is_deleted')) {
         // exclude associations with deleted custom entities
         return false;
     }
     return true;
 }
开发者ID:hugeval,项目名称:platform,代码行数:30,代码来源:ExtendEntityFieldFilter.php

示例10: onNavigationConfigure

 /**
  * @param ConfigureMenuEvent $event
  */
 public function onNavigationConfigure(ConfigureMenuEvent $event)
 {
     $menu = $event->getMenu();
     $children = array();
     $entitiesMenuItem = $menu->getChild('system_tab')->getChild('entities_list');
     if ($entitiesMenuItem) {
         /** @var ConfigProvider $entityConfigProvider */
         $entityConfigProvider = $this->configManager->getProvider('entity');
         /** @var ConfigProvider $entityExtendProvider */
         $entityExtendProvider = $this->configManager->getProvider('extend');
         $extendConfigs = $entityExtendProvider->getConfigs();
         foreach ($extendConfigs as $extendConfig) {
             if ($this->checkAvailability($extendConfig)) {
                 $config = $entityConfigProvider->getConfig($extendConfig->getId()->getClassname());
                 if (!class_exists($config->getId()->getClassName()) || !$this->securityFacade->hasLoggedUser() || !$this->securityFacade->isGranted('VIEW', 'entity:' . $config->getId()->getClassName())) {
                     continue;
                 }
                 $children[$config->get('label')] = array('label' => $this->translator->trans($config->get('label')), 'options' => array('route' => 'oro_entity_index', 'routeParameters' => array('entityName' => str_replace('\\', '_', $config->getId()->getClassName())), 'extras' => array('safe_label' => true, 'routes' => array('oro_entity_*'))));
             }
         }
         sort($children);
         foreach ($children as $child) {
             $entitiesMenuItem->addChild($child['label'], $child['options']);
         }
     }
 }
开发者ID:ramunasd,项目名称:platform,代码行数:29,代码来源:NavigationListener.php

示例11: 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

示例12: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('fieldName', 'text', array('label' => 'Field Name', 'block' => 'type'));
     $entityProvider = $this->configManager->getProvider('entity');
     $extendProvider = $this->configManager->getProvider('extend');
     $entityConfig = $extendProvider->getConfig($options['class_name']);
     if ($entityConfig->is('relation')) {
         $types = array();
         foreach ($entityConfig->get('relation') as $relationKey => $relation) {
             $fieldId = $relation['field_id'];
             $targetFieldId = $relation['target_field_id'];
             if (!$relation['assign'] || !$targetFieldId) {
                 continue;
             }
             if ($fieldId && $extendProvider->hasConfigById($fieldId) && !$extendProvider->getConfigById($fieldId)->is('state', ExtendManager::STATE_DELETED)) {
                 continue;
             }
             $entityLabel = $entityProvider->getConfig($targetFieldId->getClassName())->get('label');
             $fieldLabel = $entityProvider->getConfigById($targetFieldId)->get('label');
             $key = $relationKey . '||' . ($fieldId ? $fieldId->getFieldName() : '');
             $types[$key] = 'Relation (' . $entityLabel . ') ' . $fieldLabel;
         }
         $this->types = array_merge($this->types, $types);
     }
     $builder->add('type', 'choice', array('choices' => $this->types, 'empty_value' => 'Please choice type...', 'block' => 'type'));
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:29,代码来源:FieldType.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->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

示例14: getExtendConfigProvider

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

示例15: 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


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