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


PHP Provider\ConfigProvider类代码示例

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


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

示例1: ensureHierarchyInitialized

 /**
  * Makes sure the class hierarchy was loaded
  */
 protected function ensureHierarchyInitialized()
 {
     if (null === $this->hierarchy) {
         $this->hierarchy = [];
         $entityConfigs = $this->extendConfigProvider->getConfigs();
         foreach ($entityConfigs as $entityConfig) {
             if ($entityConfig->in('state', [ExtendScope::STATE_NEW, ExtendScope::STATE_DELETE])) {
                 continue;
             }
             if ($entityConfig->is('is_deleted')) {
                 continue;
             }
             $className = $entityConfig->getId()->getClassName();
             $parents = [];
             $this->loadParents($parents, $className);
             if (empty($parents)) {
                 continue;
             }
             // remove proxies if they are in list of parents
             $parents = array_filter($parents, function ($parentClassName) {
                 return strpos($parentClassName, ExtendHelper::ENTITY_NAMESPACE) !== 0;
             });
             if (empty($parents)) {
                 continue;
             }
             $this->hierarchy[$className] = $parents;
         }
     }
 }
开发者ID:northdakota,项目名称:platform,代码行数:32,代码来源:EntityHierarchyProvider.php

示例2: generateEntityManagerProxies

 /**
  * Generate doctrine proxy classes for extended entities for the given entity manager
  *
  * @param EntityManager $em
  */
 protected function generateEntityManagerProxies(EntityManager $em)
 {
     $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));
         }
         $metadataFactory = $em->getMetadataFactory();
         $proxyFactory = $em->getProxyFactory();
         $extendConfigs = $this->extendConfigProvider->getConfigs(null, true);
         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:Maksold,项目名称:platform,代码行数:31,代码来源:EntityProxyGenerator.php

示例3: resolve

 /**
  * {@inheritdoc}
  */
 public function resolve(Route $route, RouteCollectionAccessor $routes)
 {
     if ($route->getOption('group') !== self::ROUTE_GROUP) {
         return;
     }
     if ($this->hasAttribute($route, self::ACTIVITY_PLACEHOLDER)) {
         $activities = array_map(function (ConfigInterface $config) {
             // convert to entity alias
             return $this->entityAliasResolver->getPluralAlias($config->getId()->getClassName());
         }, $this->groupingConfigProvider->filter(function (ConfigInterface $config) {
             // filter activity entities
             $groups = $config->get('groups');
             return !empty($groups) && in_array(ActivityScope::GROUP_ACTIVITY, $groups, true);
         }));
         if (!empty($activities)) {
             $activities = $this->adjustRoutes($route, $routes, $activities);
             if (!empty($activities)) {
                 $route->setRequirement(self::ACTIVITY_ATTRIBUTE, implode('|', $activities));
             }
         }
         $this->completeRouteRequirements($route);
     } elseif ($this->hasAttribute($route, self::ENTITY_PLACEHOLDER)) {
         $this->completeRouteRequirements($route);
     }
 }
开发者ID:northdakota,项目名称:platform,代码行数:28,代码来源:ActivityAssociationRouteOptionsResolver.php

示例4: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (empty($options['data_class'])) {
         return;
     }
     $className = $options['data_class'];
     if (!$this->doctrineHelper->isManageableEntity($className)) {
         return;
     }
     if (!$this->entityConfigProvider->hasConfig($className)) {
         return;
     }
     $uniqueKeys = $this->entityConfigProvider->getConfig($className)->get('unique_key');
     if (empty($uniqueKeys)) {
         return;
     }
     /* @var \Symfony\Component\Validator\Mapping\ClassMetadata $validatorMetadata */
     $validatorMetadata = $this->validator->getMetadataFor($className);
     foreach ($uniqueKeys['keys'] as $uniqueKey) {
         $fields = $uniqueKey['key'];
         $labels = array_map(function ($fieldName) use($className) {
             $label = $this->entityConfigProvider->getConfig($className, $fieldName)->get('label');
             return $this->translator->trans($label);
         }, $fields);
         $constraint = new UniqueEntity(['fields' => $fields, 'errorPath' => '', 'message' => $this->translator->transChoice('oro.entity.validation.unique_field', sizeof($fields), ['%field%' => implode(', ', $labels)])]);
         $validatorMetadata->addConstraint($constraint);
     }
 }
开发者ID:ramunasd,项目名称:platform,代码行数:31,代码来源:UniqueEntityExtension.php

示例5: validate

 /**
  * @param string          $dataClass Parent entity class name
  * @param File|Attachment $entity    File entity
  * @param string          $fieldName Field name where new file/image field was added
  *
  * @return \Symfony\Component\Validator\ConstraintViolationListInterface
  */
 public function validate($dataClass, $entity, $fieldName = '')
 {
     /** @var Config $entityAttachmentConfig */
     if ($fieldName === '') {
         $entityAttachmentConfig = $this->attachmentConfigProvider->getConfig($dataClass);
         $mimeTypes = $this->getMimeArray($entityAttachmentConfig->get('mimetypes'));
         if (!$mimeTypes) {
             $mimeTypes = array_merge($this->getMimeArray($this->config->get('oro_attachment.upload_file_mime_types')), $this->getMimeArray($this->config->get('oro_attachment.upload_image_mime_types')));
         }
     } else {
         $entityAttachmentConfig = $this->attachmentConfigProvider->getConfig($dataClass, $fieldName);
         /** @var FieldConfigId $fieldConfigId */
         $fieldConfigId = $entityAttachmentConfig->getId();
         if ($fieldConfigId->getFieldType() === 'file') {
             $configValue = 'upload_file_mime_types';
         } else {
             $configValue = 'upload_image_mime_types';
         }
         $mimeTypes = $this->getMimeArray($this->config->get('oro_attachment.' . $configValue));
     }
     $fileSize = $entityAttachmentConfig->get('maxsize') * 1024 * 1024;
     foreach ($mimeTypes as $id => $value) {
         $mimeTypes[$id] = trim($value);
     }
     return $this->validator->validate($entity->getFile(), [new FileConstraint(['maxSize' => $fileSize, 'mimeTypes' => $mimeTypes])]);
 }
开发者ID:ramunasd,项目名称:platform,代码行数:33,代码来源:ConfigFileValidator.php

示例6: onNavigationConfigure

 /**
  * @param ConfigureMenuEvent $event
  */
 public function onNavigationConfigure(ConfigureMenuEvent $event)
 {
     /** @var ItemInterface $reportsMenuItem */
     $reportsMenuItem = $event->getMenu()->getChild('reports_tab');
     if ($reportsMenuItem && $this->securityFacade->hasLoggedUser()) {
         $qb = $this->em->getRepository('OroReportBundle:Report')->createQueryBuilder('report')->orderBy('report.name', 'ASC');
         $reports = $this->aclHelper->apply($qb)->execute();
         if (!empty($reports)) {
             $this->addDivider($reportsMenuItem);
             $reportMenuData = [];
             foreach ($reports as $report) {
                 $config = $this->entityConfigProvider->getConfig($report->getEntity());
                 if ($this->checkAvailability($config)) {
                     $entityLabel = $config->get('plural_label');
                     if (!isset($reportMenuData[$entityLabel])) {
                         $reportMenuData[$entityLabel] = [];
                     }
                     $reportMenuData[$entityLabel][$report->getId()] = $report->getName();
                 }
             }
             ksort($reportMenuData);
             $this->buildReportMenu($reportsMenuItem, $reportMenuData);
         }
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:28,代码来源:NavigationListener.php

示例7: process

 /**
  * {@inheritdoc}
  */
 public function process(ContextInterface $context)
 {
     /** @var ConfigContext $context */
     $definition = $context->getResult();
     if (empty($definition)) {
         // an entity configuration does not exist
         return;
     }
     $entityClass = $context->getClassName();
     if (!isset($definition[ConfigUtil::LABEL])) {
         $entityName = $this->entityClassNameProvider->getEntityClassName($entityClass);
         if ($entityName) {
             $definition[ConfigUtil::LABEL] = $entityName;
         }
     }
     if (!isset($definition[ConfigUtil::PLURAL_LABEL])) {
         $entityPluralName = $this->entityClassNameProvider->getEntityClassPluralName($entityClass);
         if ($entityPluralName) {
             $definition[ConfigUtil::PLURAL_LABEL] = $entityPluralName;
         }
     }
     if (!isset($definition[ConfigUtil::DESCRIPTION]) && $this->entityConfigProvider->hasConfig($entityClass)) {
         $definition[ConfigUtil::DESCRIPTION] = new Label($this->entityConfigProvider->getConfig($entityClass)->get('description'));
     }
     $context->setResult($definition);
 }
开发者ID:Maksold,项目名称:platform,代码行数:29,代码来源:SetDescriptionForEntity.php

示例8: isAttachmentAssociationEnabled

 /**
  * Checks if the entity can has notes
  *
  * @param object $entity
  * @return bool
  */
 public function isAttachmentAssociationEnabled($entity)
 {
     if (null === $entity || !is_object($entity)) {
         return false;
     }
     $className = ClassUtils::getClass($entity);
     return $this->attachmentConfigProvider->hasConfig($className) && $this->attachmentConfigProvider->getConfig($className)->is('enabled') && $this->entityConfigProvider->hasConfig(AttachmentScope::ATTACHMENT, ExtendHelper::buildAssociationName($className));
 }
开发者ID:northdakota,项目名称:platform,代码行数:14,代码来源:AttachmentConfig.php

示例9: isApplicable

 /**
  * Checks if the entity can have comments
  *
  * @param object|null $entity
  *
  * @return bool
  */
 public function isApplicable($entity)
 {
     if (!is_object($entity) || !$this->doctrineHelper->isManageableEntity($entity) || !$this->securityFacade->isGranted('oro_comment_view')) {
         return false;
     }
     $className = ClassUtils::getClass($entity);
     return $this->commentConfigProvider->hasConfig($className) && $this->commentConfigProvider->getConfig($className)->is('enabled') && $this->entityConfigProvider->hasConfig(Comment::ENTITY_NAME, ExtendHelper::buildAssociationName($className));
 }
开发者ID:Maksold,项目名称:platform,代码行数:15,代码来源:CommentPlaceholderFilter.php

示例10: supports

 /**
  * {@inheritdoc}
  */
 public function supports(array $schema)
 {
     if (!$this->groupingConfigProvider->hasConfig($schema['class'])) {
         return false;
     }
     $groups = $this->groupingConfigProvider->getConfig($schema['class'])->get('groups');
     return !empty($groups) && in_array(ActivityScope::GROUP_ACTIVITY, $groups);
 }
开发者ID:xamin123,项目名称:platform,代码行数:11,代码来源:ActivityEntityGeneratorExtension.php

示例11: addEntities

 /**
  * Adds entities to $result
  *
  * @param array $result
  */
 protected function addEntities(array &$result)
 {
     // only configurable entities are supported
     $configs = $this->entityConfigProvider->getConfigs();
     foreach ($configs as $config) {
         $this->addEntity($result, $config->getId()->getClassName(), $config->get('label'), $config->get('plural_label'), $config->get('icon'));
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:13,代码来源:EntityProvider.php

示例12: isNoteAssociationEnabled

 /**
  * Checks if the entity can has notes
  *
  * @param object $entity
  * @return bool
  */
 public function isNoteAssociationEnabled($entity)
 {
     if (null === $entity || !is_object($entity)) {
         return false;
     }
     $className = ClassUtils::getClass($entity);
     return $this->noteConfigProvider->hasConfig($className) && $this->noteConfigProvider->getConfig($className)->is('enabled') && $this->entityConfigProvider->hasConfig(Note::ENTITY_NAME, ExtendHelper::buildAssociationName($className));
 }
开发者ID:xamin123,项目名称:platform,代码行数:14,代码来源:PlaceholderFilter.php

示例13: testGetFields

 /**
  * @param array $fields
  * @param array $configValues
  * @param array $expected
  *
  * @dataProvider fieldsDataProvider
  */
 public function testGetFields(array $fields, array $configValues, array $expected)
 {
     $entity = new \StdClass();
     foreach ($fields as $field) {
         /** @var ConfigInterface $field */
         $fieldId = $field->getId();
         /** @var FieldConfigId $fieldId */
         $fieldName = $fieldId->getFieldName();
         $entity->{$fieldName} = $fieldName;
     }
     $this->configProvider->expects($this->once())->method('filter')->will($this->returnValue($fields));
     $config = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface');
     $this->configProvider->expects($this->any())->method('getConfigById')->will($this->returnValue($config));
     foreach ($configValues as $key => $configValue) {
         $config->expects($this->at($key))->method('get')->will($this->returnCallback(function ($value, $strict, $default) use($configValue) {
             if (!is_null($configValue)) {
                 return $configValue;
             }
             return $default;
         }));
     }
     $this->dispatcher->expects($this->exactly(sizeof($fields)))->method('dispatch');
     $rows = $this->extension->getFields($entity);
     $this->assertEquals(json_encode($expected), json_encode($rows));
 }
开发者ID:Maksold,项目名称:platform,代码行数:32,代码来源:DynamicFieldsExtensionTest.php

示例14: prePersist

 /**
  * Handle prePersist.
  *
  * @param LifecycleEventArgs $args
  * @throws \LogicException when getOwner method isn't implemented for entity with ownership type
  */
 public function prePersist(LifecycleEventArgs $args)
 {
     $token = $this->getSecurityContext()->getToken();
     if (!$token) {
         return;
     }
     $user = $token->getUser();
     if (!$user) {
         return;
     }
     $entity = $args->getEntity();
     if ($this->configProvider->hasConfig(get_class($entity))) {
         $config = $this->configProvider->getConfig(get_class($entity));
         $ownerType = $config->get('owner_type');
         if ($ownerType && $ownerType !== OwnershipType::OWNER_TYPE_NONE) {
             if (!method_exists($entity, 'getOwner')) {
                 throw new \LogicException(sprintf('Method getOwner must be implemented for %s entity', get_class($entity)));
             }
             if (!$entity->getOwner()) {
                 /**
                  * Automatically set current user as record owner
                  */
                 if (OwnershipType::OWNER_TYPE_USER == $ownerType && method_exists($entity, 'setOwner')) {
                     $entity->setOwner($user);
                 }
             }
         }
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:35,代码来源:RecordOwnerDataListener.php

示例15: getEntityChoiceList

 protected function getEntityChoiceList($entityClassName, $relationType)
 {
     $configManager = $this->configProvider->getConfigManager();
     $choices = array();
     if ($this->targetEntity) {
         $entityIds = array($this->configProvider->getId($this->targetEntity));
     } else {
         $entityIds = $configManager->getIds('extend');
     }
     if (in_array($relationType, array('oneToMany', 'manyToMany'))) {
         $entityIds = array_filter($entityIds, function (EntityConfigId $configId) use($configManager) {
             $config = $configManager->getConfig($configId);
             return $config->is('is_extend');
         });
     }
     $entityIds = array_filter($entityIds, function (EntityConfigId $configId) use($configManager) {
         $config = $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) {
             list($moduleName, $entityName) = ConfigHelper::getModuleAndEntityNames($className);
             $choices[$className] = $moduleName . ':' . $entityName;
         }
     }
     return $choices;
 }
开发者ID:xamin123,项目名称:platform,代码行数:28,代码来源:TargetType.php


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