本文整理汇总了PHP中Oro\Bundle\EntityConfigBundle\Config\ConfigManager::hasConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigManager::hasConfig方法的具体用法?PHP ConfigManager::hasConfig怎么用?PHP ConfigManager::hasConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\EntityConfigBundle\Config\ConfigManager
的用法示例。
在下文中一共展示了ConfigManager::hasConfig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEntityAlias
/**
* {@inheritdoc}
*/
public function getEntityAlias($entityClass)
{
if ($this->configManager->hasConfig($entityClass)) {
// check for enums
$enumCode = $this->configManager->getProvider('enum')->getConfig($entityClass)->get('code');
if ($enumCode) {
$entityAlias = $this->getEntityAliasFromConfig($entityClass);
if (null !== $entityAlias) {
return $entityAlias;
}
return $this->createEntityAlias(str_replace('_', '', $enumCode));
}
// check for dictionaries
$groups = $this->configManager->getProvider('grouping')->getConfig($entityClass)->get('groups');
if (!empty($groups) && in_array(GroupingScope::GROUP_DICTIONARY, $groups, true)) {
// delegate aliases generation to default provider
return null;
}
// exclude hidden entities
if ($this->configManager->isHiddenModel($entityClass)) {
return false;
}
// check for custom entities
if (ExtendHelper::isCustomEntity($entityClass)) {
$entityAlias = $this->getEntityAliasFromConfig($entityClass);
if (null !== $entityAlias) {
return $entityAlias;
}
return $this->createEntityAlias('Extend' . ExtendHelper::getShortClassName($entityClass));
}
}
return null;
}
示例2: getEntityChoiceList
/**
* @param string $entityClassName
* @param string $relationType
*
* @return array
*/
protected function getEntityChoiceList($entityClassName, $relationType)
{
/** @var EntityConfigId[] $entityIds */
$entityIds = $this->targetEntityClass ? [$this->configManager->getId('extend', $this->targetEntityClass)] : $this->configManager->getIds('extend');
if (in_array($relationType, [RelationTypeBase::ONE_TO_MANY, RelationTypeBase::MANY_TO_MANY], true)) {
$entityIds = array_filter($entityIds, function (EntityConfigId $configId) {
$config = $this->configManager->getConfig($configId);
return $config->is('is_extend');
});
}
$entityIds = array_filter($entityIds, function (EntityConfigId $configId) {
$config = $this->configManager->getConfig($configId);
return !$config->is('state', ExtendScope::STATE_NEW) && ($this->targetEntityClass || !$config->is('is_deleted'));
});
$choices = [];
foreach ($entityIds as $entityId) {
$className = $entityId->getClassName();
if (!$this->configManager->hasConfig($className, 'id') && !ExtendHelper::isCustomEntity($className)) {
// @todo: temporary ignore entities that don't have PK with name 'id'
// remove this in https://magecore.atlassian.net/browse/BAP-9713
continue;
}
if ($className !== $entityClassName) {
$entityConfig = $this->configManager->getProvider('entity')->getConfig($className);
$choices[$className] = $entityConfig->get('label');
}
}
return $choices;
}
示例3: getObjects
/**
* Returns objects extracted from simple search
*
* @param User $user
* @param string $entityClass
* @param string $searchString
* @param int $offset
* @param int $maxResults
*
* @return array
*/
protected function getObjects(User $user, $entityClass, $searchString, $offset, $maxResults)
{
$objects = [];
if (!$this->configManager->hasConfig($entityClass)) {
return $objects;
}
$classNames = $this->shareScopeProvider->getClassNamesBySharingScopeConfig($entityClass);
if (!$classNames) {
return $objects;
}
$tables = [];
foreach ($classNames as $className) {
$metadata = $this->em->getClassMetadata($className);
$tables[] = $metadata->getTableName();
}
$searchResults = $this->indexer->simpleSearch($searchString, $offset, $maxResults, $tables);
list($userIds, $buIds, $orgIds) = $this->getIdsByClass($searchResults, $user);
if ($orgIds) {
$organizations = $this->em->getRepository('OroOrganizationBundle:Organization')->getEnabledOrganizations($orgIds);
$objects = array_merge($objects, $organizations);
}
if ($buIds) {
$businessUnits = $this->em->getRepository('OroOrganizationBundle:BusinessUnit')->getBusinessUnits($buIds);
$objects = array_merge($objects, $businessUnits);
}
if ($userIds) {
$users = $this->em->getRepository('OroUserBundle:User')->findUsersByIds($userIds);
$objects = array_merge($objects, $users);
}
return $objects;
}
示例4: getGroupedResults
/**
* Returns grouped search results
*
* @param string $string
* @return array
*/
public function getGroupedResults($string)
{
$search = $this->getResults($string);
// empty key array contains all data
$result = array('' => array('count' => 0, 'class' => '', 'config' => array(), 'icon' => '', 'label' => ''));
/** @var $item Item */
foreach ($search->getElements() as $item) {
$config = $item->getEntityConfig();
$alias = $config['alias'];
if (!isset($result[$alias])) {
$group = array('count' => 0, 'class' => $item->getEntityName(), 'config' => $config, 'icon' => '', 'label' => '');
if (!empty($group['class']) && $this->configManager->hasConfig($group['class'])) {
$entityConfigId = new EntityConfigId('entity', $group['class']);
$entityConfig = $this->configManager->getConfig($entityConfigId);
if ($entityConfig->has('plural_label')) {
$group['label'] = $this->translator->trans($entityConfig->get('plural_label'));
}
if ($entityConfig->has('icon')) {
$group['icon'] = $entityConfig->get('icon');
}
}
$result[$alias] = $group;
}
$result[$alias]['count']++;
$result['']['count']++;
}
uasort($result, function ($first, $second) {
if ($first['label'] == $second['label']) {
return 0;
}
return $first['label'] > $second['label'] ? 1 : -1;
});
return $result;
}
示例5: writeItem
/**
* @param FieldConfigModel $configModel
* @return array
*/
protected function writeItem(FieldConfigModel $configModel)
{
$className = $configModel->getEntity()->getClassName();
$fieldName = $configModel->getFieldName();
$state = ExtendScope::STATE_UPDATE;
if (!$this->configManager->hasConfig($className, $fieldName)) {
$this->configManager->createConfigFieldModel($className, $fieldName, $configModel->getType());
$state = ExtendScope::STATE_NEW;
}
$translations = [];
foreach ($this->configManager->getProviders() as $provider) {
$scope = $provider->getScope();
$data = $configModel->toArray($scope);
if (!$data) {
continue;
}
$translations = array_merge($translations, $this->processData($provider, $provider->getConfig($className, $fieldName), $data, $state));
}
$this->setExtendData($className, $fieldName, $state);
$this->updateEntityState($className);
if ($state === ExtendScope::STATE_UPDATE && in_array($configModel->getType(), ['enum', 'multiEnum'], true)) {
$this->setEnumData($configModel->toArray('enum'), $className, $fieldName);
}
return $translations;
}
示例6: getClassConfigValue
/**
* @param string $className The entity class name
* @param string $attrName The entity config attribute name
* @param string $scope The entity config scope name
*
* @return mixed
*/
public function getClassConfigValue($className, $attrName, $scope = 'entity')
{
if (!$this->configManager->hasConfig($className)) {
return null;
}
$entityConfig = new EntityConfigId($scope, $className);
return $this->configManager->getConfig($entityConfig)->get($attrName);
}
示例7: isActivityAssociationAccessible
/**
* Check if an association between a given entity type and activity type is ready to be used in a business logic.
* It means that the association should exist and should not be marked as deleted.
*
* @param string $entityClass The target entity class
* @param string $activityClass The activity entity class
*
* @return bool
*/
protected function isActivityAssociationAccessible($entityClass, $activityClass)
{
$associationName = ExtendHelper::buildAssociationName($entityClass, ActivityScope::ASSOCIATION_KIND);
if (!$this->configManager->hasConfig($activityClass, $associationName)) {
return false;
}
return ExtendHelper::isFieldAccessible($this->configManager->getFieldConfig('extend', $activityClass, $associationName));
}
示例8: isAttachmentAssociationAccessible
/**
* Check if an association between a given entity type and attachments is ready to be used in a business logic.
* It means that the association should exist and should not be marked as deleted.
*
* @param string $entityClass The target entity class
*
* @return bool
*/
protected function isAttachmentAssociationAccessible($entityClass)
{
$associationName = ExtendHelper::buildAssociationName($entityClass);
if (!$this->configManager->hasConfig(self::ATTACHMENT_ENTITY, $associationName)) {
return false;
}
return ExtendHelper::isFieldAccessible($this->configManager->getFieldConfig('extend', self::ATTACHMENT_ENTITY, $associationName));
}
示例9: isIgnoredRelation
/**
* {@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')));
}
示例10: getGridName
/**
* @param $className
*
* @return null|string
*/
public function getGridName($className)
{
$className = $this->entityClassNameHelper->resolveEntityClass($className);
if (!$this->configManager->hasConfig($className)) {
return null;
}
return $this->configManager->getProvider('security')->getConfig($className)->get('share_grid');
}
示例11: isExtendEntity
/**
* @param string $className
*
* @return bool
*/
protected function isExtendEntity($className)
{
$result = false;
if ($this->configManager->hasConfig($className)) {
$extendProvider = $this->configManager->getProvider('extend');
$result = $extendProvider->getConfig($className)->is('is_extend');
}
return $result;
}
示例12: isMultiEnumField
/**
* @param string $className
* @param string $fieldName
*
* @return bool
*/
protected function isMultiEnumField($className, $fieldName)
{
if ($this->configManager->hasConfig($className, $fieldName)) {
/** @var FieldConfigId $fieldId */
$fieldId = $this->configManager->getId('extend', $className, $fieldName);
if ($fieldId->getFieldType() === 'multiEnum') {
return true;
}
}
return false;
}
示例13: isIgnoredRelation
/**
* {@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;
}
示例14: getMetadataFor
/**
* {@inheritdoc}
*/
public function getMetadataFor($object)
{
$metadata = [];
if ($object instanceof EntityManagerAwareInterface) {
$entityFQCN = $object->getManager()->getMetadata()->name;
$metadata['entity'] = [];
$metadata['entity']['phpType'] = $entityFQCN;
if ($this->cm->hasConfig($entityFQCN)) {
$config = $this->cm->getConfig(new EntityConfigId('entity', $entityFQCN));
$metadata['entity']['label'] = $this->translator->trans($config->get('label'));
$metadata['entity']['pluralLabel'] = $this->translator->trans($config->get('plural_label'));
$metadata['entity']['description'] = $this->translator->trans($config->get('description'));
}
}
return $metadata;
}
示例15: isApplicableTarget
/**
* @param string $targetClassName
* @param string $activityClassName
*
* @return bool
*/
public function isApplicableTarget($targetClassName, $activityClassName)
{
if (!isset($this->providers[$activityClassName]) || !$this->configManager->hasConfig($targetClassName)) {
return false;
}
return $this->providers[$activityClassName]->isApplicableTarget($this->configManager->getId('entity', $targetClassName), $this->configManager);
}