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


PHP ConfigProvider::getConfig方法代码示例

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


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

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

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

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

示例4: 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();
     $className = ClassUtils::getClass($entity);
     if ($this->configProvider->hasConfig($className)) {
         $accessor = PropertyAccess::createPropertyAccessor();
         $config = $this->configProvider->getConfig($className);
         $ownerType = $config->get('owner_type');
         $ownerFieldName = $config->get('owner_field_name');
         // set default owner for organization and user owning entities
         if ($ownerType && in_array($ownerType, [OwnershipType::OWNER_TYPE_ORGANIZATION, OwnershipType::OWNER_TYPE_USER]) && !$accessor->getValue($entity, $ownerFieldName)) {
             $owner = null;
             if (OwnershipType::OWNER_TYPE_USER == $ownerType) {
                 $owner = $user;
             } elseif (OwnershipType::OWNER_TYPE_ORGANIZATION == $ownerType && $token instanceof OrganizationContextTokenInterface) {
                 $owner = $token->getOrganizationContext();
             }
             $accessor->setValue($entity, $ownerFieldName, $owner);
         }
         //set organization
         $this->setDefaultOrganization($token, $config, $entity);
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:37,代码来源:RecordOwnerDataListener.php

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

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

示例7: isShareEnabled

 /**
  * Checks if the entity can be shared
  *
  * @param object $entity
  * @return bool
  */
 public function isShareEnabled($entity)
 {
     if (null === $entity || !is_object($entity)) {
         return false;
     }
     $className = ClassUtils::getClass($entity);
     return $this->securityFacade->isGranted('SHARE', $entity) && $this->configProvider->hasConfig($className) && $this->configProvider->getConfig($className)->get('share_scopes');
 }
开发者ID:kstupak,项目名称:platform,代码行数:14,代码来源:PlaceholderFilter.php

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

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

 /**
  * Returns entity
  *
  * @param string $entityName Entity name. Can be full class name or short form: Bundle:Entity.
  * @return array contains entity details:
  *                           .    'name'          - entity full class name
  *                           .    'label'         - entity label
  *                           .    'plural_label'  - entity plural label
  *                           .    'icon'          - an icon associated with an entity
  */
 public function getEntity($entityName)
 {
     $className = $this->entityClassResolver->getEntityClass($entityName);
     $config = $this->entityConfigProvider->getConfig($className);
     $result = array();
     $this->addEntity($result, $config->getId()->getClassName(), $config->get('label'), $config->get('plural_label'), $config->get('icon'));
     return reset($result);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:18,代码来源:EntityProvider.php

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

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

 /**
  * @param mixed $entity
  * @param bool  $show
  *
  * @return bool
  */
 public function isEntityAuditable($entity, $show)
 {
     if ($show || !is_object($entity)) {
         return $show;
     }
     $className = ClassUtils::getClass($entity);
     return $this->configProvider->hasConfig($className) && $this->configProvider->getConfig($className)->is('auditable');
 }
开发者ID:Maksold,项目名称:platform,代码行数:14,代码来源:AuditableFilter.php

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

示例15: getOwnerType

 /**
  * @param $entity
  * @return string
  */
 public function getOwnerType($entity)
 {
     $ownerClassName = ClassUtils::getRealClass(get_class($entity));
     if (!$this->configProvider->hasConfig($ownerClassName)) {
         return;
     }
     $config = $this->configProvider->getConfig($ownerClassName)->all();
     return $config['owner_type'];
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:13,代码来源:OwnerTypeExtension.php


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