/** * {@inheritdoc} */ public function isIgnoredRelation(ClassMetadata $metadata, $associationName) { if (!$this->configManager->hasConfig($metadata->name, $associationName)) { return false; } $extendFieldConfig = $this->configManager->getFieldConfig('extend', $metadata->name, $associationName); return !ExtendHelper::isFieldAccessible($extendFieldConfig) || $this->configManager->isHiddenModel($metadata->name, $associationName) || $extendFieldConfig->has('target_entity') && !ExtendHelper::isEntityAccessible($this->configManager->getEntityConfig('extend', $extendFieldConfig->get('target_entity'))); }
/** * Checks whether attachments are enabled for a given entity type. * * @param string $entityClass The target entity class * @param bool $accessible Whether an association with the target entity should be checked * to be ready to use in a business logic. * It means that the association should exist and should not be marked as deleted. * * @return bool */ public function isAttachmentAssociationEnabled($entityClass, $accessible = true) { if (!$this->configManager->hasConfig($entityClass)) { return false; } if (!$this->configManager->getEntityConfig('attachment', $entityClass)->is('enabled')) { return false; } return !$accessible || $this->isAttachmentAssociationAccessible($entityClass); }
/** * Checks whether a given entity type has at least one enabled activity association. * * @param string $entityClass The target entity class * * @return bool */ public function hasActivityAssociations($entityClass) { if (!$this->configManager->hasConfig($entityClass)) { return false; } $activities = $this->configManager->getEntityConfig('activity', $entityClass)->get('activities', false, []); foreach ($activities as $activityClass) { if ($this->isActivityAssociationAccessible($entityClass, $activityClass)) { return true; } } return false; }
/** * {@inheritdoc} */ public function isIgnoredRelation(ClassMetadata $metadata, $associationName) { if (!$this->configManager->hasConfig($metadata->name, $associationName)) { return false; } $groups = $this->configManager->getEntityConfig('grouping', $metadata->name)->get('groups'); if (empty($groups) || !in_array(ActivityScope::GROUP_ACTIVITY, $groups, true)) { return false; } $mapping = $metadata->getAssociationMapping($associationName); if (!$mapping['isOwningSide'] || !($mapping['type'] & ClassMetadata::MANY_TO_MANY)) { return false; } $activityAssociationName = ExtendHelper::buildAssociationName($mapping['targetEntity'], ActivityScope::ASSOCIATION_KIND); return $associationName === $activityAssociationName; }
/** * Gets configuration data for the given entity or field. * * @param ConfigIdInterface $configId * * @return ConfigInterface */ public function getConfigById(ConfigIdInterface $configId) { $className = $configId->getClassName(); if ($configId instanceof FieldConfigId) { return $this->configManager->getFieldConfig($this->scope, $className, $configId->getFieldName()); } elseif ($className) { return $this->configManager->getEntityConfig($this->scope, $className); } else { return $this->configManager->createEntityConfig($this->scope); } }
/** * {@inheritdoc} */ public function isIgnoredRelation(ClassMetadata $metadata, $associationName) { if (!$this->configManager->hasConfig($metadata->name, $associationName)) { return false; } $extendFieldConfig = $this->configManager->getFieldConfig('extend', $metadata->name, $associationName); if (!ExtendHelper::isFieldAccessible($extendFieldConfig)) { return true; } if ($this->excludeHiddenFields && $this->configManager->isHiddenModel($metadata->name, $associationName)) { return true; } if ($extendFieldConfig->has('target_entity')) { $targetEntity = $extendFieldConfig->get('target_entity'); if (!ExtendHelper::isEntityAccessible($this->configManager->getEntityConfig('extend', $targetEntity))) { return true; } if ($this->excludeHiddenEntities && $this->configManager->isHiddenModel($targetEntity)) { return true; } } return false; }
/** * @param string $entityClass * @param int $pageType * * @return bool */ protected function isAllowedOnPage($entityClass, $pageType) { return ActivityScope::isAllowedOnPage($pageType, $this->configManager->getEntityConfig('activity', $entityClass)->get(ActivityScope::SHOW_ON_PAGE)); }
/** * @param string $className * * @return ConfigInterface */ protected function getEntityConfig($className) { return $this->configManager->getEntityConfig('extend', $className); }
/** * @param $className * * @return array */ protected function getConfigForClass($className) { return $this->configManager->getEntityConfig('activity', $className)->getValues(); }