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