當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Common\DatagridConfiguration類代碼示例

本文整理匯總了PHP中Oro\Bundle\DataGridBundle\Datagrid\Common\DatagridConfiguration的典型用法代碼示例。如果您正苦於以下問題:PHP DatagridConfiguration類的具體用法?PHP DatagridConfiguration怎麽用?PHP DatagridConfiguration使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了DatagridConfiguration類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: visitMetadata

 /**
  * {@inheritdoc}
  */
 public function visitMetadata(DatagridConfiguration $config, MetadataObject $data)
 {
     $currentViewId = $this->getCurrentViewId($config->getName());
     $this->setDefaultParams($config->getName());
     $data->offsetAddToArray('initialState', ['gridView' => self::DEFAULT_VIEW_ID]);
     $data->offsetAddToArray('state', ['gridView' => $currentViewId]);
     $allLabel = null;
     if (isset($config['options'], $config['options']['gridViews'], $config['options']['gridViews']['allLabel'])) {
         $allLabel = $this->translator->trans($config['options']['gridViews']['allLabel']);
     }
     /** @var AbstractViewsList $list */
     $list = $config->offsetGetOr(self::VIEWS_LIST_KEY, false);
     $systemGridView = new View(self::DEFAULT_VIEW_ID);
     $systemGridView->setDefault($this->getDefaultViewId($config->getName()) === null);
     $gridViews = ['choices' => [['label' => $allLabel, 'value' => self::DEFAULT_VIEW_ID]], 'views' => [$systemGridView->getMetadata()]];
     if ($list !== false) {
         $configuredGridViews = $list->getMetadata();
         $configuredGridViews['views'] = array_merge($gridViews['views'], $configuredGridViews['views']);
         $configuredGridViews['choices'] = array_merge($gridViews['choices'], $configuredGridViews['choices']);
         $gridViews = $configuredGridViews;
     }
     if ($this->eventDispatcher->hasListeners(GridViewsLoadEvent::EVENT_NAME)) {
         $event = new GridViewsLoadEvent($config->getName(), $gridViews);
         $this->eventDispatcher->dispatch(GridViewsLoadEvent::EVENT_NAME, $event);
         $gridViews = $event->getGridViews();
     }
     $gridViews['gridName'] = $config->getName();
     $gridViews['permissions'] = $this->getPermissions();
     $data->offsetAddToArray('gridViews', $gridViews);
 }
開發者ID:ramunasd,項目名稱:platform,代碼行數:33,代碼來源:GridViewsExtension.php

示例2: configure

 /**
  * {@inheritdoc}
  */
 public function configure(DatagridConfiguration $configuration)
 {
     $attributes = $configuration->offsetGet(self::SOURCE_KEY)[self::USEABLE_ATTRIBUTES_KEY];
     $attributes = $attributes === null ? [] : $attributes;
     $displayedFilters = [];
     foreach ($attributes as $attributeCode => $attribute) {
         if (!$attribute['useableAsGridFilter']) {
             continue;
         }
         $attributeType = $attribute['attributeType'];
         $attributeTypeConf = $this->registry->getConfiguration($attributeType);
         if (!$attributeTypeConf || !isset($attributeTypeConf['filter'])) {
             throw new \LogicException(sprintf('Attribute type %s must be configured to allow grid filter on attribute %s', $attributeType, $attributeCode));
         }
         $filterConfig = $attributeTypeConf['filter'];
         $filterConfig = $filterConfig + [ProductFilterUtility::DATA_NAME_KEY => $attributeCode, 'label' => $attribute['label'], 'enabled' => AttributeTypes::IDENTIFIER === $attributeType, 'order' => $attribute['sortOrder'], 'group' => $attribute['group'], 'groupOrder' => $attribute['groupOrder']];
         if (AttributeTypes::METRIC === $attributeType) {
             $filterConfig['family'] = $attribute['metricFamily'];
         }
         $displayedFilters[$attributeCode] = $filterConfig;
     }
     $this->sortFilters($displayedFilters);
     $filters = $configuration->offsetGet(FilterConfiguration::FILTERS_KEY);
     foreach ($displayedFilters as $attributeCode => $filterConfig) {
         $filters['columns'][$attributeCode] = $filterConfig;
     }
     $configuration->offsetSet(FilterConfiguration::FILTERS_KEY, $filters);
 }
開發者ID:abdeldayem,項目名稱:pim-community-dev,代碼行數:31,代碼來源:FiltersConfigurator.php

示例3: visitMetadata

 /**
  * {@inheritDoc}
  */
 public function visitMetadata(DatagridConfiguration $config, MetadataObject $data)
 {
     $params = $this->getParameters()->get(ParameterBag::ADDITIONAL_PARAMETERS, []);
     $currentView = isset($params[self::VIEWS_PARAM_KEY]) ? $params[self::VIEWS_PARAM_KEY] : null;
     $data->offsetAddToArray('initialState', ['gridView' => '__all__']);
     $data->offsetAddToArray('state', ['gridView' => $currentView]);
     $allLabel = null;
     if (isset($config['options']) && isset($config['options']['gridViews']) && isset($config['options']['gridViews']['allLabel'])) {
         $allLabel = $this->translator->trans($config['options']['gridViews']['allLabel']);
     }
     /** @var AbstractViewsList $list */
     $list = $config->offsetGetOr(self::VIEWS_LIST_KEY, false);
     $gridViews = ['choices' => [['label' => $allLabel, 'value' => '__all__']], 'views' => [(new View('__all__'))->getMetadata()]];
     if ($list !== false) {
         $configuredGridViews = $list->getMetadata();
         $configuredGridViews['views'] = array_merge($gridViews['views'], $configuredGridViews['views']);
         $configuredGridViews['choices'] = array_merge($gridViews['choices'], $configuredGridViews['choices']);
         $gridViews = $configuredGridViews;
     }
     if ($this->eventDispatcher->hasListeners(GridViewsLoadEvent::EVENT_NAME)) {
         $event = new GridViewsLoadEvent($config->getName(), $gridViews);
         $this->eventDispatcher->dispatch(GridViewsLoadEvent::EVENT_NAME, $event);
         $gridViews = $event->getGridViews();
     }
     $gridViews['gridName'] = $config->getName();
     $gridViews['permissions'] = $this->getPermissions();
     $data->offsetSet('gridViews', $gridViews);
 }
開發者ID:northdakota,項目名稱:platform,代碼行數:31,代碼來源:GridViewsExtension.php

示例4: visitDatasource

 /**
  * {@inheritDoc}
  */
 public function visitDatasource(DatagridConfiguration $config, DatasourceInterface $datasource)
 {
     $entityName = $config->offsetGetByPath(self::EXTEND_ENTITY_CONFIG_PATH);
     $fields = $this->getDynamicFields($entityName);
     if ($datasource instanceof OrmDatasource && !empty($fields)) {
         /** @var QueryBuilder $qb */
         $qb = $datasource->getQueryBuilder();
         $fromParts = $qb->getDQLPart('from');
         $alias = false;
         foreach ($fromParts as $fromPart) {
             if ($fromPart->getFrom() == $entityName) {
                 $alias = $fromPart->getAlias();
             }
         }
         if ($alias === false) {
             // add entity if it not exists in from clause
             $alias = ExtendConfigDumper::FIELD_PREFIX . 'o';
             $qb->from($entityName, $alias);
         }
         foreach ($fields as $field) {
             $fn = ExtendConfigDumper::FIELD_PREFIX . $field->getFieldName();
             $qb->addSelect(sprintf('%s.%s', $alias, $fn));
             // set real "data name" for filters and sorters
             $config->offsetSetByPath(sprintf('%s[%s][%s]', OrmSorterConfiguration::COLUMNS_PATH, $fn, PropertyInterface::DATA_NAME_KEY), sprintf('%s.%s', $alias, $fn));
             $config->offsetSetByPath(sprintf('%s[%s][%s]', FilterConfiguration::COLUMNS_PATH, $fn, FilterUtility::DATA_NAME_KEY), sprintf('%s.%s', $alias, $fn));
         }
     }
 }
開發者ID:ashutosh-srijan,項目名稱:findit_akeneo,代碼行數:31,代碼來源:ExtendExtension.php

示例5: let

 function let(DatagridConfiguration $configuration, ConfigurationRegistry $registry)
 {
     $registry->getConfiguration('pim_catalog_identifier')->willReturn(['column' => ['identifier_config']]);
     $registry->getConfiguration('pim_catalog_text')->willReturn(['column' => ['text_config']]);
     $configuration->offsetGetByPath(sprintf('[%s]', FormatterConfiguration::COLUMNS_KEY))->willReturn(['family' => ['family_config']]);
     $this->beConstructedWith($registry);
 }
開發者ID:abdeldayem,項目名稱:pim-community-dev,代碼行數:7,代碼來源:ColumnsConfiguratorSpec.php

示例6: applyACL

 /**
  * Add user limitation
  *
  * @param DatagridConfiguration $config
  * @param string                $accessLevel
  * @param User                  $user
  * @param Organization          $organization
  *
  * @throws \Exception
  */
 protected function applyACL(DatagridConfiguration $config, $accessLevel, User $user, Organization $organization)
 {
     $where = $config->offsetGetByPath('[source][query][where][and]', []);
     /** todo: refactor this check usages */
     if ($accessLevel == AccessLevel::BASIC_LEVEL) {
         $where = array_merge($where, ['u.id = ' . $user->getId()]);
     } elseif ($accessLevel == AccessLevel::GLOBAL_LEVEL) {
         $leftJoins = $config->offsetGetByPath('[source][query][join][inner]', []);
         $leftJoins[] = ['join' => 'u.organizations', 'alias' => 'org'];
         $config->offsetSetByPath('[source][query][join][inner]', $leftJoins);
         $where = array_merge($where, ['org.id in (' . $organization->getId() . ')']);
     } elseif ($accessLevel !== AccessLevel::SYSTEM_LEVEL) {
         $resultBuIds = [];
         if ($accessLevel == AccessLevel::LOCAL_LEVEL) {
             $resultBuIds = $this->treeProvider->getTree()->getUserBusinessUnitIds($user->getId(), $organization->getId());
         } elseif ($accessLevel == AccessLevel::DEEP_LEVEL) {
             $resultBuIds = $this->treeProvider->getTree()->getUserSubordinateBusinessUnitIds($user->getId(), $organization->getId());
         }
         $leftJoins = $config->offsetGetByPath('[source][query][join][inner]', []);
         $leftJoins[] = ['join' => 'u.businessUnits', 'alias' => 'bu'];
         $config->offsetSetByPath('[source][query][join][inner]', $leftJoins);
         $where = array_merge($where, ['bu.id in (' . implode(', ', $resultBuIds) . ')']);
     }
     if (count($where)) {
         $config->offsetSetByPath('[source][query][where][and]', $where);
     }
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:37,代碼來源:OwnerUserGridListener.php

示例7: isApplicable

 /**
  * @param DatagridConfiguration $config
  *
  * @return bool
  */
 public function isApplicable(DatagridConfiguration $config)
 {
     $columns = $config->offsetGetByPath(Configuration::COLUMNS_PATH);
     $type = $config->offsetGetByPath(Builder::DATASOURCE_TYPE_PATH);
     $isApplicable = ($type == CombinedAuditDatasource::TYPE || $type == CombinedUsersDatasource::TYPE) && is_array($columns);
     return $isApplicable;
 }
開發者ID:gitter-badger,項目名稱:diamantedesk-application,代碼行數:12,代碼來源:CombinedDatasourceSorterExtension.php

示例8: visitDatasource

 /**
  * {@inheritdoc}
  */
 public function visitDatasource(DatagridConfiguration $config, DatasourceInterface $datasource)
 {
     /** @var QueryBuilder $qb */
     $qb = $datasource->getQueryBuilder();
     $ds = new GroupingOrmFilterDatasourceAdapter($qb);
     $filters = $config->offsetGetByPath('[source][query_config][filters]');
     $this->restrictionBuilder->buildRestrictions($filters, $ds);
 }
開發者ID:xamin123,項目名稱:platform,代碼行數:11,代碼來源:OrmDatasourceExtension.php

示例9: buildReferenceData

 /**
  * Build references data
  *
  * @param DatasourceInterface   $dataSource
  * @param DatagridConfiguration $configuration
  */
 protected function buildReferenceData(DatasourceInterface $dataSource, DatagridConfiguration $configuration)
 {
     $source = $configuration->offsetGet('source');
     $qb = $dataSource->getQueryBuilder();
     foreach ($configuration->offsetGet('columns') as $column => $config) {
         $this->buildQueryBuilder($qb, $source, $column);
     }
 }
開發者ID:umpirsky,項目名稱:pim-community-dev,代碼行數:14,代碼來源:ReferenceDataSelector.php

示例10: getEntityRootAlias

 /**
  * @param DatagridConfiguration $config
  *
  * @return null
  */
 public function getEntityRootAlias(DatagridConfiguration $config)
 {
     $from = $config->offsetGetByPath('[source][query][from]');
     if ($from) {
         return $from[0]['alias'];
     }
     return null;
 }
開發者ID:ramunasd,項目名稱:platform,代碼行數:13,代碼來源:GridConfigurationHelper.php

示例11: visitDatasource

 /**
  * {@inheritDoc}
  */
 public function visitDatasource(DatagridConfiguration $config, DatasourceInterface $datasource)
 {
     $defaultPerPage = $config->offsetGetByPath(ToolbarExtension::PAGER_DEFAULT_PER_PAGE_OPTION_PATH, 10);
     $this->pager->setQuery($datasource->getQuery());
     $this->pager->setPage($this->getOr(self::PAGE_PARAM, 1));
     $this->pager->setMaxPerPage($this->getOr(self::PER_PAGE_PARAM, $defaultPerPage));
     $this->pager->init();
 }
開發者ID:ashutosh-srijan,項目名稱:findit_akeneo,代碼行數:11,代碼來源:SearchPagerExtension.php

示例12: let

 function let(DatagridConfiguration $configuration, ConfigurationRegistry $registry, ProductManager $manager)
 {
     $attributes = ['sku' => ['code' => 'sku', 'attributeType' => 'pim_catalog_identifier'], 'name' => ['code' => 'name', 'attributeType' => 'pim_catalog_text']];
     $configuration->offsetGetByPath(sprintf('[source][%s]', ContextConfigurator::USEABLE_ATTRIBUTES_KEY))->willReturn($attributes);
     $configuration->offsetGetByPath(sprintf('[%s]', FormatterConfiguration::COLUMNS_KEY))->willReturn(['family' => ['family_config'], 'sku' => [], 'name' => []]);
     $registry->getConfiguration('pim_catalog_identifier')->willReturn(['column' => ['identifier_config'], 'sorter' => 'flexible_field']);
     $this->beConstructedWith($registry, $manager);
 }
開發者ID:javiersantos,項目名稱:pim-community-dev,代碼行數:8,代碼來源:SortersConfiguratorSpec.php

示例13: processConfigs

 /**
  * {@inheritdoc}
  */
 public function processConfigs(DatagridConfiguration $config)
 {
     $pagination = $config->offsetGetByPath(self::ENTITY_PAGINATION_PATH);
     if ($pagination !== null && !is_bool($pagination)) {
         throw new \LogicException('Entity pagination is not boolean');
     }
     $config->offsetSetByPath(self::ENTITY_PAGINATION_PATH, (bool) $pagination);
 }
開發者ID:ramunasd,項目名稱:platform,代碼行數:11,代碼來源:EntityPaginationExtension.php

示例14: visitResult

 /**
  * {@inheritdoc}
  *
  * Gets stored SQL and parameters prepared by
  * Oro\Bundle\DataGridBundle\EventListener\StoreSqlListener
  * and puts them into metadata of ResultsObject
  */
 public function visitResult(DatagridConfiguration $config, ResultsObject $result)
 {
     $value = $config->offsetGetByPath(self::STORED_SQL_PATH);
     if ($value) {
         $result->offsetAddToArray('metadata', [self::DISPLAY_SQL_QUERY => true]);
         $result->offsetAddToArrayByPath(self::STORED_SQL_PATH, $value);
     }
 }
開發者ID:startupz,項目名稱:platform-1,代碼行數:15,代碼來源:StoreSqlExtension.php

示例15:

 function it_cannot_handle_misconfigured_attribute_type(DatagridConfiguration $configuration, $registry)
 {
     $attributes = ['sku' => ['code' => 'sku', 'label' => 'Sku', 'useableAsGridFilter' => 1, 'attributeType' => 'pim_catalog_identifier', 'sortOrder' => 2, 'group' => 'Foo', 'groupOrder' => 3], 'name' => ['code' => 'name', 'label' => 'Name', 'useableAsGridFilter' => 1, 'attributeType' => 'pim_catalog_text', 'sortOrder' => 4, 'group' => 'Bar', 'groupOrder' => 5]];
     $attributesConf = [ContextConfigurator::USEABLE_ATTRIBUTES_KEY => $attributes];
     $configuration->offsetGet(ContextConfigurator::SOURCE_KEY)->willReturn($attributesConf);
     $registry->getConfiguration('pim_catalog_identifier')->willReturn(['filter' => ['identifier_config']]);
     $registry->getConfiguration('pim_catalog_text')->willReturn([]);
     $this->shouldThrow('\\LogicException')->duringConfigure($configuration);
 }
開發者ID:abdeldayem,項目名稱:pim-community-dev,代碼行數:9,代碼來源:FiltersConfiguratorSpec.php


注:本文中的Oro\Bundle\DataGridBundle\Datagrid\Common\DatagridConfiguration類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。