本文整理匯總了PHP中Oro\Bundle\DataGridBundle\Datagrid\Common\DatagridConfiguration::getName方法的典型用法代碼示例。如果您正苦於以下問題:PHP DatagridConfiguration::getName方法的具體用法?PHP DatagridConfiguration::getName怎麽用?PHP DatagridConfiguration::getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Oro\Bundle\DataGridBundle\Datagrid\Common\DatagridConfiguration
的用法示例。
在下文中一共展示了DatagridConfiguration::getName方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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: build
/**
* Create, configure and build datagrid
*
* @param DatagridConfiguration $config
*
* @return DatagridInterface
*/
public function build(DatagridConfiguration $config)
{
$class = $config->offsetGetByPath(self::BASE_DATAGRID_CLASS_PATH, $this->baseDatagridClass);
$name = $config->getName();
/** @var Acceptor $acceptor */
$acceptor = new $this->acceptorClass($config);
/** @var DatagridInterface $datagrid */
$datagrid = new $class($name, $acceptor);
$event = new BuildBefore($datagrid, $config);
$this->eventDispatcher->dispatch(BuildBefore::NAME, $event);
// duplicate event dispatch with grid name
$this->eventDispatcher->dispatch(BuildBefore::NAME . '.' . $name, $event);
$this->buildDataSource($datagrid, $config);
foreach ($this->extensions as $extension) {
if ($extension->isApplicable($config)) {
$acceptor->addExtension($extension);
}
}
$acceptor->processConfiguration();
$event = new BuildAfter($datagrid);
$this->eventDispatcher->dispatch(BuildAfter::NAME, $event);
// duplicate event dispatch with grid name
$this->eventDispatcher->dispatch(BuildAfter::NAME . '.' . $name, $event);
return $datagrid;
}
示例4: 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;
}
示例5: isApplicable
/**
* {@inheritDoc}
*/
public function isApplicable(DatagridConfiguration $config)
{
$list = $config->offsetGetOr(self::VIEWS_LIST_KEY, false);
if ($list !== false && !$list instanceof AbstractViewsList) {
throw new InvalidTypeException(sprintf('Invalid type for path "%s.%s". Expected AbstractViewsList, but got %s.', $config->getName(), self::VIEWS_LIST_KEY, gettype($list)));
}
return $list !== false;
}
示例6: processConfigs
/**
* {@inheritDoc}
*/
public function processConfigs(DatagridConfiguration $config)
{
$totalRows = $this->validateConfiguration(new Configuration(), ['totals' => $config->offsetGetByPath(Configuration::TOTALS_PATH)]);
if (!empty($totalRows)) {
foreach ($totalRows as $rowName => $rowConfig) {
$this->mergeTotals($totalRows, $rowName, $rowConfig, $config->getName());
}
$config->offsetSetByPath(Configuration::TOTALS_PATH, $totalRows);
}
}
示例7: visitMetadata
/**
* {@inheritDoc}
*/
public function visitMetadata(DatagridConfiguration $config, MetadataObject $data)
{
$currentUser = $this->getCurrentUser();
if (!$currentUser) {
return;
}
$gridName = $config->getName();
$gridViews = $this->getGridViewRepository()->findGridViews($this->aclHelper, $currentUser, $gridName);
/** Set default columns data to initial state from config */
$this->setInitialStateColumnsOrder($config, $data);
/** Set default columns data to metadata */
$this->setColumnsOrder($config, $data);
if (!$gridViews) {
$this->setStateColumnsOrder($config, $data);
}
/** Update columns data from url if exists */
$urlColumnsData = $this->updateColumnsDataFromUrl($config, $data);
if (!$gridViews) {
return;
}
$newGridView = $this->createNewGridView($config, $data);
$currentState = $data->offsetGet('state');
/** Get columns data from config */
$columnsData = $this->getColumnsWithOrder($config);
/** Get columns data from grid view */
$gridViewColumnsData = null;
if (isset($currentState['gridView'])) {
foreach ($gridViews as $gridView) {
if ((int) $currentState['gridView'] === $gridView->getId()) {
/** Get columns state from current view */
$gridViewColumnsData = $gridView->getColumnsData();
/** Get columns data from current view */
$columnsData = $gridViewColumnsData;
break;
}
}
}
/** Get columns data from config or current view if no data in URL */
if (!empty($urlColumnsData)) {
if ($this->columnsHelper->compareColumnsData($gridViewColumnsData, $urlColumnsData)) {
$columnsData = $gridViewColumnsData;
} else {
$columnsData = $urlColumnsData;
}
}
/** Save current columns state or restore to default view __all__ setting config columns data */
$this->setState($data, $columnsData);
/** Set config columns data */
$this->setGridViewDefaultOrder($data, $newGridView->getColumnsData());
}
示例8: 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;
}
示例9: it_configures_mass_actions
public function it_configures_mass_actions(BuildBefore $event, DatagridConfiguration $datagridConfig, ActionInterface $indexAction, ActionFactory $actionFactory, ActionInterface $action1, ActionInterface $action2)
{
$action1->implement('Pim\\Bundle\\CustomEntityBundle\\Action\\GridActionInterface');
$action2->implement('Pim\\Bundle\\CustomEntityBundle\\Action\\GridActionInterface');
$actionFactory->getAction('entity', 'action1')->willReturn($action1);
$actionFactory->getAction('entity', 'action2')->willReturn($action2);
$action1->getGridActionOptions()->willReturn(['action1_key1' => 'action1_value1']);
$datagridConfig->getName()->willReturn('entity');
$indexAction->getMassActions()->willReturn(['action1', 'action2']);
$indexAction->getRowActions()->willReturn([]);
$indexAction->getOptions()->willReturn([]);
$datagridConfig->offsetGetByPath('[extends]')->willReturn('custom_entity');
$datagridConfig->offsetGetByPath('[properties]')->willReturn([]);
$datagridConfig->offsetGetByPath('[actions]')->willReturn([]);
$datagridConfig->offsetGetByPath('[source]')->willReturn([]);
$datagridConfig->offsetGetByPath('[mass_actions]')->willReturn(['action2' => []]);
$datagridConfig->offsetSetByPath("[source]", ["entity" => "entity_class", "type" => "pim_custom_entity"])->shouldBeCalled();
$datagridConfig->offsetSetByPath("[actions]", [])->shouldBeCalled();
$datagridConfig->offsetSetByPath("[properties]", ['id' => []])->shouldBeCalled();
$datagridConfig->offsetSetByPath("[mass_actions]", ["action2" => [], "action1" => ["action1_key1" => "action1_value1"]])->shouldBeCalled();
$this->buildBefore($event);
}
示例10: isApplicable
/**
* {@inheritdoc}
*/
public function isApplicable(DatagridConfiguration $config)
{
return !$this->applied && static::SUPPORTED_GRID === $config->getName() && ($token = $this->tokenStorage->getToken()) && $token->getUser() instanceof AccountUser;
}
示例11: getColumnsWithOrder
/**
* @param DatagridConfiguration $config
* @param bool $default
*
* @return array
*/
protected function getColumnsWithOrder(DatagridConfiguration $config, $default = false)
{
if (!$default) {
$params = $this->getParameters()->get(ParameterBag::ADDITIONAL_PARAMETERS, []);
$defaultGridView = $this->getDefaultGridView($config->getName());
if (isset($params['view']) && $defaultGridView && $params['view'] === $defaultGridView->getId()) {
return $defaultGridView->getColumnsData();
}
}
$columnsData = $config->offsetGet(self::COLUMNS_PATH);
$columnsOrder = $this->columnsHelper->buildColumnsOrder($columnsData);
$columns = $this->applyColumnsOrderAndRender($columnsData, $columnsOrder);
return $columns;
}
示例12: isApplicable
/**
* {@inheritdoc}
*/
public function isApplicable(DatagridConfiguration $config)
{
return !$this->applied && static::SUPPORTED_GRID === $config->getName() && $this->request && $this->request->get(self::ACCOUNT_KEY);
}