本文整理汇总了PHP中Oro\Bundle\DataGridBundle\Datagrid\Common\DatagridConfiguration::offsetGetOr方法的典型用法代码示例。如果您正苦于以下问题:PHP DatagridConfiguration::offsetGetOr方法的具体用法?PHP DatagridConfiguration::offsetGetOr怎么用?PHP DatagridConfiguration::offsetGetOr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\DataGridBundle\Datagrid\Common\DatagridConfiguration
的用法示例。
在下文中一共展示了DatagridConfiguration::offsetGetOr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
/**
* Create, configure and build datagrid
*
* @param DatagridConfiguration $config
* @param ParameterBag $parameters
*
* @return DatagridInterface
*/
public function build(DatagridConfiguration $config, ParameterBag $parameters)
{
/**
* @TODO: should be refactored in BAP-6849
*/
$minified = $parameters->get(ParameterBag::MINIFIED_PARAMETERS);
if (is_array($minified) && array_key_exists('g', $minified) && is_array($minified['g'])) {
$gridParams = [];
foreach ($minified['g'] as $gridParamName => $gridParamValue) {
$gridParams[$gridParamName] = $gridParamValue;
}
$parameters->add($gridParams);
}
/**
* @TODO: should be refactored in BAP-6826
*/
$event = new PreBuild($config, $parameters);
$this->eventDispatcher->dispatch(PreBuild::NAME, $event);
$class = $config->offsetGetByPath(self::BASE_DATAGRID_CLASS_PATH, $this->baseDatagridClass);
$name = $config->getName();
/** @var DatagridInterface $datagrid */
$datagrid = new $class($name, $config, $parameters);
$datagrid->setScope($config->offsetGetOr('scope'));
$event = new BuildBefore($datagrid, $config);
$this->eventDispatcher->dispatch(BuildBefore::NAME, $event);
$acceptor = $this->createAcceptor($config, $parameters);
$datagrid->setAcceptor($acceptor);
$this->buildDataSource($datagrid, $config);
$acceptor->processConfiguration();
$event = new BuildAfter($datagrid);
$this->eventDispatcher->dispatch(BuildAfter::NAME, $event);
return $datagrid;
}
示例2: 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);
}
示例3: visitMetadata
/**
* {@inheritDoc}
*/
public function visitMetadata(DatagridConfiguration $config, MetadataObject $data)
{
$params = $this->getRequestParams()->get(RequestParameters::ADDITIONAL_PARAMETERS);
$currentView = isset($params[self::VIEWS_PARAM_KEY]) ? $params[self::VIEWS_PARAM_KEY] : null;
$data->offsetAddToArray('state', ['gridView' => $currentView]);
/** @var AbstractViewsList $list */
$list = $config->offsetGetOr(self::VIEWS_LIST_KEY, false);
if ($list !== false) {
$data->offsetSet('gridViews', $list->getMetadata());
}
}
示例4: visitMetadata
/**
* {@inheritDoc}
*/
public function visitMetadata(DatagridConfiguration $config, MetadataObject $data)
{
// get only columns here because columns will be represented on frontend
$columns = $config->offsetGetOr(Configuration::COLUMNS_KEY, []);
$propertiesMetadata = [];
foreach ($columns as $name => $fieldConfig) {
$fieldConfig = PropertyConfiguration::createNamed($name, $fieldConfig);
$metadata = $this->getPropertyObject($fieldConfig)->getMetadata();
// translate label on backend
$metadata['label'] = $this->translator->trans($metadata['label']);
$propertiesMetadata[] = $metadata;
}
$data->offsetAddToArray('columns', $propertiesMetadata);
}
示例5: getActionsMetadata
/**
* @param DatagridConfiguration $config
* @return array
*/
protected function getActionsMetadata(DatagridConfiguration $config)
{
$actionsMetadata = [];
$actions = $config->offsetGetOr(static::ACTION_KEY, []);
foreach ($actions as $name => $action) {
$action = $this->getActionObject($name, $action);
if ($action !== false) {
$metadata = $action->getOptions()->toArray([], static::$excludeParams);
$metadata['label'] = isset($metadata['label']) ? $this->translator->trans($metadata['label']) : null;
$actionsMetadata[$action->getName()] = $metadata;
}
}
return $actionsMetadata;
}
示例6: visitMetadata
/**
* {@inheritDoc}
*/
public function visitMetadata(DatagridConfiguration $config, MetadataObject $data)
{
$actionsMetadata = [];
$actions = $config->offsetGetOr(static::ACTION_KEY, []);
foreach ($actions as $name => $action) {
$action = $this->getActionObject($name, $action);
if ($action !== false) {
$metadata = $action->getOptions()->toArray([], static::$excludeParams);
$metadata['label'] = isset($metadata['label']) ? $this->translator->trans($metadata['label']) : null;
$actionsMetadata[$action->getName()] = $metadata;
}
}
$data->offsetAddToArray(static::METADATA_ACTION_KEY, $actionsMetadata);
}
示例7: build
/**
* Create, configure and build datagrid
*
* @param DatagridConfiguration $config
* @param ParameterBag $parameters
*
* @return DatagridInterface
*/
public function build(DatagridConfiguration $config, ParameterBag $parameters)
{
$event = new PreBuild($config, $parameters);
$this->eventDispatcher->dispatch(PreBuild::NAME, $event);
$class = $config->offsetGetByPath(self::BASE_DATAGRID_CLASS_PATH, $this->baseDatagridClass);
$name = $config->getName();
/** @var DatagridInterface $datagrid */
$datagrid = new $class($name, $config, $parameters);
$datagrid->setScope($config->offsetGetOr('scope'));
$event = new BuildBefore($datagrid, $config);
$this->eventDispatcher->dispatch(BuildBefore::NAME, $event);
$acceptor = $this->createAcceptor($config, $parameters);
$datagrid->setAcceptor($acceptor);
$this->buildDataSource($datagrid, $config);
$acceptor->processConfiguration();
$event = new BuildAfter($datagrid);
$this->eventDispatcher->dispatch(BuildAfter::NAME, $event);
return $datagrid;
}
示例8: 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);
}
示例9: 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);
}
示例10: 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);
}
示例11: isApplicable
/**
* {@inheritDoc}
*/
public function isApplicable(DatagridConfiguration $config)
{
$columns = $config->offsetGetOr(self::COLUMNS_PATH, []);
$this->processConfigs($config);
return count($columns) > 0;
}
示例12: processConfigs
/**
* {@inheritdoc}
*/
public function processConfigs(DatagridConfiguration $config)
{
$actions = $config->offsetGetOr(static::MASS_ACTION_KEY, []);
$actions['delete'] = $this->getMassDeleteActionConfig($config);
$config->offsetSet(static::MASS_ACTION_KEY, $actions);
}
示例13: visitMetadata
/**
* {@inheritDoc}
*/
public function visitMetadata(DatagridConfiguration $config, MetadataObject $data)
{
$data->offsetSet(Configuration::BASE_CONFIG_KEY, $config->offsetGetOr(Configuration::BASE_CONFIG_KEY, []));
}
示例14: isApplicable
/**
* {@inheritDoc}
*/
public function isApplicable(DatagridConfiguration $config)
{
$massActions = $config->offsetGetOr(static::ACTION_KEY, []);
return !empty($massActions);
}
示例15: getMixins
/**
* @param DatagridConfiguration $config
* @param ParameterBag $parameters
*
* @return string[]
*/
protected function getMixins(DatagridConfiguration $config, ParameterBag $parameters)
{
$mixins = (array) $config->offsetGetOr(self::MIXINS, []);
$mixins = array_merge($mixins, (array) $parameters->get(self::GRID_MIXIN, []));
return $mixins;
}