• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Provider\ConfigProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了ConfigProvider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: getFieldLabel

 /**
  * Gets translated field name by its name
  *
  * @param string $className
  * @param string $fieldName
  *
  * @return string
  */
 protected function getFieldLabel($className, $fieldName)
 {
     if (!$this->entityConfigProvider->hasConfig($className, $fieldName)) {
         return $fieldName;
     }
     $fieldLabel = $this->entityConfigProvider->getConfig($className, $fieldName)->get('label');
     return $this->translator->trans($fieldLabel);
 }
开发者ID:ramunasd,项目名称:platform,代码行数:16,代码来源:EmailTemplateSyntaxValidator.php


示例14: testCreateEntityMetadataByClass

 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testCreateEntityMetadataByClass()
 {
     $this->doctrineHelper->expects($this->once())->method('getMetadataFor')->with(self::CLASS_NAME)->will($this->returnValue($this->classMetadata));
     $this->entityExtendConfigProvider->expects($this->any())->method('getConfigs')->with(static::CLASS_NAME)->will($this->returnValue([]));
     $this->classMetadata->name = static::CLASS_NAME;
     $this->classMetadata->expects($this->any())->method('getIdentifierFieldNames')->will($this->returnValue(['id']));
     // Test creation of entity metadata
     $entityMetadataCallIndex = 0;
     $entityMetadata = $this->createEntityMetadata();
     $metadataFactoryCallIndex = 0;
     $this->metadataFactory->expects($this->at($metadataFactoryCallIndex++))->method('createEntityMetadata')->with([], $this->isType('array'))->will($this->returnValue($entityMetadata));
     // Test adding doctrine fields
     $doctrineFieldNames = ['id', 'foo_field', 'bar_field'];
     $doctrineFieldNamesWithoutId = ['foo_field', 'bar_field'];
     $idFieldNames = ['id'];
     $this->classMetadata->expects($this->any())->method('getIdentifierFieldNames')->will($this->returnValue($idFieldNames));
     $this->classMetadata->expects($this->any())->method('getFieldNames')->will($this->returnValue($doctrineFieldNames));
     $this->classMetadata->expects($this->any())->method('getFieldMapping')->will($this->returnCallback(function ($fieldName) {
         return ['fieldName' => $fieldName];
     }));
     foreach ($doctrineFieldNamesWithoutId as $fieldName) {
         $fieldMapping = ['fieldName' => $fieldName];
         $fieldMetadata = $this->createFieldMetadata();
         $this->metadataFactory->expects($this->at($metadataFactoryCallIndex++))->method('createFieldMetadata')->with(['field_name' => $fieldName], $fieldMapping)->will($this->returnValue($fieldMetadata));
         $entityMetadata->expects($this->at($entityMetadataCallIndex++))->method('addFieldMetadata')->with($fieldMetadata);
     }
     // Test adding doctrine associations
     $associationMappings = ['foo_association' => ['foo' => 'bar'], 'bar_association' => ['bar' => 'baz']];
     $this->classMetadata->expects($this->any())->method('getAssociationNames')->will($this->returnValue(array_keys($associationMappings)));
     $this->classMetadata->expects($this->any())->method('getAssociationMapping')->will($this->returnCallback(function ($association) use($associationMappings) {
         return $associationMappings[$association];
     }));
     foreach ($associationMappings as $fieldName => $associationMapping) {
         $fieldMetadata = $this->createFieldMetadata();
         $this->metadataFactory->expects($this->at($metadataFactoryCallIndex++))->method('createFieldMetadata')->with(['field_name' => $fieldName], $associationMapping)->will($this->returnValue($fieldMetadata));
         $entityMetadata->expects($this->at($entityMetadataCallIndex++))->method('addFieldMetadata')->with($fieldMetadata);
     }
     // Test adding doctrine inverse associations
     $allMetadata = [self::CLASS_NAME => $this->classMetadata, 'Namespace\\FooEntity' => $fooClassMetadata = $this->createClassMetadata(), 'Namespace\\BarEntity' => $barClassMetadata = $this->createClassMetadata(), 'Namespace\\FooBarEntity' => $fooBarClassMetadata = $this->createClassMetadata()];
     $expectedClassesData = ['Namespace\\FooEntity' => ['associationMappings' => ['foo_association' => ['foo' => 'bar', 'type' => ClassMetadataInfo::ONE_TO_MANY]], 'expectedFields' => ['foo_association' => ['field_name' => 'Namespace_FooEntity_foo_association', 'merge_modes' => [MergeModes::UNITE], 'source_field_name' => 'foo_association', 'source_class_name' => 'Namespace\\FooEntity']]], 'Namespace\\BarEntity' => ['associationMappings' => ['bar_association' => ['bar' => 'baz', 'type' => ClassMetadataInfo::ONE_TO_MANY], 'skipped_many_to_many' => ['type' => ClassMetadataInfo::MANY_TO_MANY], 'skipped_mapped_by' => ['mappedBy' => self::CLASS_NAME]], 'expectedFields' => ['bar_association' => ['field_name' => 'Namespace_BarEntity_bar_association', 'merge_modes' => [MergeModes::UNITE], 'source_field_name' => 'bar_association', 'source_class_name' => 'Namespace\\BarEntity']]], 'Namespace\\FooBarEntity' => ['associationMappings' => ['bar_association' => ['bar' => 'baz', 'type' => ClassMetadataInfo::ONE_TO_ONE]], 'expectedFields' => ['bar_association' => ['field_name' => 'Namespace_FooBarEntity_bar_association', 'merge_modes' => [MergeModes::REPLACE], 'source_field_name' => 'bar_association', 'source_class_name' => 'Namespace\\FooBarEntity']]]];
     $this->doctrineHelper->expects($this->once())->method('getAllMetadata')->will($this->returnValue(array_values($allMetadata)));
     foreach ($expectedClassesData as $className => $expectedData) {
         $metadata = $allMetadata[$className];
         $metadata->expects($this->once())->method('getName')->will($this->returnValue($className));
         $metadata->expects($this->once())->method('getAssociationsByTargetClass')->with(self::CLASS_NAME)->will($this->returnValue($expectedData['associationMappings']));
         foreach ($expectedData['expectedFields'] as $fieldName => $expectedOptions) {
             $expectedAssociationMapping = $expectedData['associationMappings'][$fieldName];
             $expectedAssociationMapping['mappedBySourceEntity'] = false;
             $fieldMetadata = $this->createFieldMetadata();
             $this->metadataFactory->expects($this->at($metadataFactoryCallIndex++))->method('createFieldMetadata')->with($expectedOptions, $expectedAssociationMapping)->will($this->returnValue($fieldMetadata));
             $entityMetadata->expects($this->at($entityMetadataCallIndex++))->method('addFieldMetadata')->with($fieldMetadata);
         }
     }
     // Test event dispatcher
     $this->eventDispatcher->expects($this->once())->method('dispatch')->with(MergeEvents::BUILD_METADATA, new EntityMetadataEvent($entityMetadata));
     $this->assertEquals($entityMetadata, $this->metadataBuilder->createEntityMetadataByClass(self::CLASS_NAME));
 }
开发者ID:startupz,项目名称:platform-1,代码行数:60,代码来源:MetadataBuilderTest.php


示例15: build

 /**
  * @param ClassMetadataBuilder $metadataBuilder
  * @param string               $className
  */
 public function build(ClassMetadataBuilder $metadataBuilder, $className)
 {
     $extendConfig = $this->extendConfigProvider->getConfig($className);
     foreach ($this->builders as $builder) {
         if ($builder->supports($extendConfig)) {
             $builder->build($metadataBuilder, $extendConfig);
         }
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:13,代码来源:ExtendMetadataBuilder.php


示例16: testIsNoteAssociationEnabled

 public function testIsNoteAssociationEnabled()
 {
     $config = new Config(new EntityConfigId('note', static::TEST_ENTITY_REFERENCE));
     $config->set('enabled', true);
     $this->noteConfigProvider->expects($this->once())->method('hasConfig')->with(static::TEST_ENTITY_REFERENCE)->will($this->returnValue(true));
     $this->noteConfigProvider->expects($this->once())->method('getConfig')->with(static::TEST_ENTITY_REFERENCE)->will($this->returnValue($config));
     $this->entityConfigProvider->expects($this->once())->method('hasConfig')->with(Note::ENTITY_NAME, ExtendHelper::buildAssociationName(static::TEST_ENTITY_REFERENCE))->will($this->returnValue(true));
     $this->assertTrue($this->filter->isNoteAssociationEnabled(new TestEntity(1)));
 }
开发者ID:Maksold,项目名称:platform,代码行数:9,代码来源:PlaceholderFilterTest.php


示例17: prepareConfigProvider

 protected function prepareConfigProvider(array $configValues, $className)
 {
     /** @var \PHPUnit_Framework_MockObject_MockObject|ConfigIdInterface $configId */
     $configId = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Config\\Id\\ConfigIdInterface');
     $entityConfig = new Config($configId);
     $entityConfig->setValues($configValues);
     $this->configProvider->expects($this->once())->method('hasConfig')->with($this->equalTo($className))->will($this->returnValue(true));
     $this->configProvider->expects($this->once())->method('getConfig')->with($this->equalTo($className))->will($this->returnValue($entityConfig));
 }
开发者ID:paulstoica,项目名称:platform,代码行数:9,代码来源:OwnerTypeExtensionTest.php


示例18: getTagEntitiesStatistic

 /**
  * @param Tag $tag
  *
  * @return array ['' => [count], $alias => [count, icon, label, class => true]]
  */
 public function getTagEntitiesStatistic(Tag $tag)
 {
     $groupedResult = $this->getGroupedTagEntities($tag);
     return array_reduce($groupedResult, function ($result, array $entityResult) {
         $result['']['count'] += $entityResult['cnt'];
         $entityClass = $entityResult['entityClass'];
         $alias = $this->entityAliasResolver->getAlias($entityClass);
         $result[$alias] = ['count' => $entityResult['cnt'], 'icon' => $this->entityConfigProvider->getConfig($entityClass)->get('icon'), 'label' => $this->entityConfigProvider->getConfig($entityClass)->get('plural_label'), 'class' => true];
         return $result;
     }, ['' => ['count' => 0]]);
 }
开发者ID:Maksold,项目名称:platform,代码行数:16,代码来源:StatisticProvider.php


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


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Tools\ExtendHelper类代码示例发布时间:2022-05-23
下一篇:
PHP Utils\ServiceLink类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap