本文整理汇总了PHP中Oro\Bundle\DataGridBundle\Datagrid\Common\DatagridConfiguration::offsetSet方法的典型用法代码示例。如果您正苦于以下问题:PHP DatagridConfiguration::offsetSet方法的具体用法?PHP DatagridConfiguration::offsetSet怎么用?PHP DatagridConfiguration::offsetSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\DataGridBundle\Datagrid\Common\DatagridConfiguration
的用法示例。
在下文中一共展示了DatagridConfiguration::offsetSet方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processConfigs
/**
* Validate configs nad fill default values
*
* @param DatagridConfiguration $config
*/
public function processConfigs(DatagridConfiguration $config)
{
$configItems = $config->offsetGetOr(Configuration::BASE_CONFIG_KEY, []);
$configuration = new Configuration(Configuration::BASE_CONFIG_KEY);
$normalizedConfigItems = $this->validateConfiguration($configuration, [Configuration::BASE_CONFIG_KEY => $configItems]);
$isGranted = $this->securityFacade->isGranted('EDIT', 'entity:' . $configItems['entity_name']);
//according to ACL disable inline editing for the whole grid
if (!$isGranted) {
$normalizedConfigItems[Configuration::CONFIG_KEY_ENABLE] = false;
}
// replace config values by normalized, extra keys passed directly
$resultConfigItems = array_replace_recursive($configItems, $normalizedConfigItems);
if (is_null($resultConfigItems['save_api_accessor']['default_route_parameters']['className'])) {
$resultConfigItems['save_api_accessor']['default_route_parameters']['className'] = $this->entityClassNameHelper->getUrlSafeClassName($configItems['entity_name']);
}
$config->offsetSet(Configuration::BASE_CONFIG_KEY, $resultConfigItems);
//add inline editing where it is possible, do not use ACL, because additional parameters for columns needed
$columns = $config->offsetGetOr(FormatterConfiguration::COLUMNS_KEY, []);
$blackList = $configuration->getBlackList();
foreach ($columns as $columnName => &$column) {
if (!in_array($columnName, $blackList)) {
$newColumn = $this->guesser->getColumnOptions($columnName, $configItems['entity_name'], $column);
//frontend type key must not be replaced with default value
$typeKey = PropertyInterface::FRONTEND_TYPE_KEY;
if (!empty($newColumn[$typeKey])) {
$column[$typeKey] = $newColumn[$typeKey];
}
$column = array_replace_recursive($newColumn, $column);
}
}
$config->offsetSet(FormatterConfiguration::COLUMNS_KEY, $columns);
}
示例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: processConfigs
/**
* Validate configs nad fill default values
*
* @param DatagridConfiguration $config
*/
public function processConfigs(DatagridConfiguration $config)
{
$columns = $config->offsetGetOr(Configuration::COLUMNS_KEY, []);
$properties = $config->offsetGetOr(Configuration::PROPERTIES_KEY, []);
// validate extension configuration and normalize by setting default values
$columnsNormalized = $this->validateConfigurationByType($columns, Configuration::COLUMNS_KEY);
$propertiesNormalized = $this->validateConfigurationByType($properties, Configuration::PROPERTIES_KEY);
// replace config values by normalized, extra keys passed directly
$config->offsetSet(Configuration::COLUMNS_KEY, array_replace_recursive($columns, $columnsNormalized))->offsetSet(Configuration::PROPERTIES_KEY, array_replace_recursive($properties, $propertiesNormalized));
}
示例4:
function it_configures_datagrid_filters(DatagridConfiguration $configuration, $registry)
{
$attributes = ['sku' => ['code' => 'sku', 'label' => 'Sku', 'useableAsGridFilter' => 1, 'attributeType' => 'pim_catalog_identifier', 'sortOrder' => 1, 'group' => 'General', 'groupOrder' => 1], 'name' => ['code' => 'name', 'label' => 'Name', 'useableAsGridFilter' => 1, 'attributeType' => 'pim_catalog_text', 'sortOrder' => 2, 'group' => 'General', 'groupOrder' => 1]];
$attributesConf = [ContextConfigurator::USEABLE_ATTRIBUTES_KEY => $attributes];
$configuration->offsetGet(ContextConfigurator::SOURCE_KEY)->willReturn($attributesConf);
$configuration->offsetGet(FilterConfiguration::FILTERS_KEY)->willReturn([]);
$registry->getConfiguration('pim_catalog_identifier')->willReturn(['filter' => ['identifier_config']]);
$registry->getConfiguration('pim_catalog_text')->willReturn(['filter' => ['text_config']]);
$expectedConf = ['sku' => [0 => 'identifier_config', 'data_name' => 'sku', 'label' => 'Sku', 'enabled' => true, 'order' => 1, 'group' => 'General', 'groupOrder' => 1], 'name' => [0 => 'text_config', 'data_name' => 'name', 'label' => 'Name', 'enabled' => false, 'order' => 2, 'group' => 'General', 'groupOrder' => 1]];
$configuration->offsetSet(FilterConfiguration::FILTERS_KEY, ['columns' => $expectedConf])->shouldBeCalled();
$this->configure($configuration);
}
示例5: addEntityConfigProperties
/**
* @param DatagridConfiguration $config
* @param $itemType
*/
protected function addEntityConfigProperties(DatagridConfiguration $config, $itemType)
{
// configure properties from config providers
$properties = $config->offsetGetOr(Configuration::PROPERTIES_KEY, []);
$columns = $config->offsetGetByPath(self::PATH_COLUMNS, []);
$actions = [];
$providers = $this->configManager->getProviders();
foreach ($providers as $provider) {
$gridActions = $provider->getPropertyConfig()->getGridActions($itemType);
if (!empty($gridActions)) {
$this->prepareProperties($gridActions, $columns, $properties, $actions);
}
}
if (count($actions)) {
$config->offsetSet(ActionExtension::ACTION_CONFIGURATION_KEY, $this->getActionConfigurationClosure($actions));
}
$config->offsetSet(Configuration::PROPERTIES_KEY, $properties);
}
示例6: addEntityConfigProperties
/**
* @param DatagridConfiguration $config
* @param $itemType
*/
protected function addEntityConfigProperties(DatagridConfiguration $config, $itemType)
{
// configure properties from config providers
$properties = $config->offsetGetOr(Configuration::PROPERTIES_KEY, []);
$filters = [];
$actions = [];
$providers = $this->configManager->getProviders();
foreach ($providers as $provider) {
$gridActions = $provider->getPropertyConfig()->getGridActions($itemType);
$this->prepareProperties($gridActions, $properties, $actions, $filters);
// TODO: check if this neccessary for field config grid
if (static::GRID_NAME == 'entityconfig-grid' && $provider->getPropertyConfig()->getUpdateActionFilter()) {
$filters['update'] = $provider->getPropertyConfig()->getUpdateActionFilter();
}
}
if (count($filters)) {
$config->offsetSet(ActionExtension::ACTION_CONFIGURATION_KEY, $this->getActionConfigurationClosure($filters, $actions));
}
$config->offsetSet(Configuration::PROPERTIES_KEY, $properties);
}