本文整理汇总了PHP中Oro\Bundle\DataGridBundle\Datagrid\Common\DatagridConfiguration类的典型用法代码示例。如果您正苦于以下问题:PHP DatagridConfiguration类的具体用法?PHP DatagridConfiguration怎么用?PHP DatagridConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DatagridConfiguration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: isApplicable
/**
* {@inheritDoc}
*/
public function isApplicable(DatagridConfiguration $config)
{
$filters = $config->offsetGetByPath(Configuration::COLUMNS_PATH);
if ($filters === null) {
return false;
}
$type = $config->offsetGetByPath(Builder::DATASOURCE_TYPE_PATH);
return $type == CombinedUsersDatasource::TYPE || $type == CombinedAuditDatasource::TYPE;
}
开发者ID:gitter-badger,项目名称:diamantedesk-application,代码行数:12,代码来源:CombinedDatasourceFilterExtension.php
示例17: visitMetadata
/**
* {@inheritDoc}
*/
public function visitMetadata(DatagridConfiguration $config, MetadataObject $data)
{
$defaultPage = 1;
$defaultPerPage = $config->offsetGetByPath(ToolbarExtension::PAGER_DEFAULT_PER_PAGE_OPTION_PATH, 10);
$initialState = ['currentPage' => $defaultPage, 'pageSize' => $defaultPerPage];
$state = ['currentPage' => $this->getOr(PagerInterface::PAGE_PARAM, $defaultPage), 'pageSize' => $this->getOr(PagerInterface::PER_PAGE_PARAM, $defaultPerPage)];
$data->offsetAddToArray('initialState', $initialState);
$data->offsetAddToArray('state', $state);
}
开发者ID:xamin123,项目名称:platform,代码行数:12,代码来源:OrmPagerExtension.php
示例18: apply
/**
* {@inheritdoc}
*/
public function apply(DatasourceInterface $datasource, DatagridConfiguration $configuration)
{
$qb = $datasource->getQueryBuilder();
$joinAlias = 'selectCompleteness';
$util = new CompletenessJoin($qb);
$locale = $configuration->offsetGetByPath('[source][locale_code]');
$scope = $configuration->offsetGetByPath('[source][scope_code]');
$util->addJoins($joinAlias, $locale, $scope);
$qb->addSelect($joinAlias . '.ratio AS ratio');
}
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:13,代码来源:CompletenessSelector.php
示例19: apply
/**
* {@inheritdoc}
*/
public function apply(DatasourceInterface $datasource, DatagridConfiguration $configuration)
{
if ($this->applied === false) {
$rootAlias = $datasource->getQueryBuilder()->getRootAlias();
$path = sprintf('[source][%s]', ContextConfigurator::DISPLAYED_ATTRIBUTES_KEY);
$attributeIds = $configuration->offsetGetByPath($path);
$datasource->getQueryBuilder()->leftJoin($rootAlias . '.values', 'values', 'WITH', 'values.attribute IN (:attributeIds) ' . 'AND (values.locale = :dataLocale OR values.locale IS NULL) ' . 'AND (values.scope = :scopeCode OR values.scope IS NULL)')->addSelect('values')->leftJoin('values.attribute', 'attribute')->addSelect('attribute')->setParameter('attributeIds', $attributeIds);
}
$this->applied = true;
}
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:13,代码来源:BaseSelector.php
示例20: addConfigElement
/**
* @param DatagridConfiguration $config
* @param string $path
* @param mixed $element
* @param mixed $key
*/
protected function addConfigElement(DatagridConfiguration $config, $path, $element, $key = null)
{
$select = $config->offsetGetByPath($path);
if ($key) {
$select[$key] = $element;
} else {
$select[] = $element;
}
$config->offsetSetByPath($path, $select);
}
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:16,代码来源:DatagridListener.php
注:本文中的Oro\Bundle\DataGridBundle\Datagrid\Common\DatagridConfiguration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论