本文整理汇总了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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
}
}
}
示例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));
}
示例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');
}
示例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));
}
示例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);
}
示例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');
}
示例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));
}
示例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);
}
示例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);
}
示例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'];
}
示例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');
}
示例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);
}