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


PHP ConfigProvider::hasConfig方法代码示例

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


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

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

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

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

示例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();
     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

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

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

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

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

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

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

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

示例12: hasActivityAssociation

 /**
  * Indicates whether the given entity type can be associated with the given activity or not
  *
  * @param string $entityClass
  * @param string $activityEntityClass
  *
  * @return bool
  */
 public function hasActivityAssociation($entityClass, $activityEntityClass)
 {
     if (!$this->activityConfigProvider->hasConfig($entityClass)) {
         return false;
     }
     $activityClassNames = $this->activityConfigProvider->getConfig($entityClass)->get('activities');
     return !empty($activityClassNames) && in_array($activityEntityClass, $activityClassNames);
 }
开发者ID:xamin123,项目名称:platform,代码行数:16,代码来源:ActivityManager.php

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

示例14: getOwnerType

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

示例15: getWorkflowDefinitionPermissions

 /**
  * @param ResultRecordInterface $record
  * @return array
  */
 public function getWorkflowDefinitionPermissions(ResultRecordInterface $record)
 {
     $isActiveWorkflow = false;
     $relatedEntity = $record->getValue('entityClass');
     if ($this->configProvider->hasConfig($relatedEntity)) {
         $config = $this->configProvider->getConfig($relatedEntity);
         $isActiveWorkflow = $record->getValue('name') == $config->get('active_workflow');
     }
     $isSystem = $record->getValue('system');
     return array('activate' => !$isActiveWorkflow, 'clone' => true, 'deactivate' => $isActiveWorkflow, 'delete' => !$isSystem, 'update' => !$isSystem, 'view' => true);
 }
开发者ID:Maksold,项目名称:platform,代码行数:15,代码来源:ActionPermissionProvider.php


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