Example #1
0
 /**
  * @param PreBuild $event
  */
 public function onPreBuild(PreBuild $event)
 {
     $parameters = $event->getParameters();
     if (!$parameters->has(static::REDIRECT_DATA_KEY)) {
         return;
     }
     $config = $event->getConfig();
     $config->offsetSetByPath(static::PATH_UPDATE_LINK_DIRECT_PARAMS, array_merge($config->offsetGetByPath(static::PATH_UPDATE_LINK_DIRECT_PARAMS, []), [static::REDIRECT_DATA_KEY => $parameters->get(static::REDIRECT_DATA_KEY)]));
 }
 public function onPreBuild(PreBuild $event)
 {
     /** @var \Oro\Bundle\DataGridBundle\Datagrid\Common\DatagridConfiguration $config */
     $config = $event->getConfig();
     if ($config->getName() === 'diamante-my-recent-tickets-widget-grid') {
         $parameters = $event->getParameters();
         $currentUserId = $this->container->get('oro_security.security_facade')->getLoggedUser()->getId();
         $parameters->add(array('userId' => $currentUserId, 'reporterId' => sprintf("oro_%s", $currentUserId)));
     }
     return;
 }
 /**
  * @param PreBuild $event
  */
 public function onPreBuild(PreBuild $event)
 {
     $request = $this->requestStack->getCurrentRequest();
     if (!$request) {
         return;
     }
     $config = $event->getConfig();
     $this->addSubscribersFilter($config);
     $requestParameters = $request->query->get('magento-customers-grid', false);
     if ($requestParameters && !empty($requestParameters['_filter']['isSubscriber'])) {
         $this->addNewsletterSubscribers($config);
     }
 }
 /**
  * Apply marketing list grid mixin.
  *
  * @param PreBuild $event
  */
 public function onPreBuild(PreBuild $event)
 {
     $config = $event->getConfig();
     $parameters = $event->getParameters();
     $gridName = $config->getName();
     if (!$this->isApplicable($gridName, $parameters)) {
         return;
     }
     $gridMixin = $parameters->get(self::MIXIN);
     if (empty($this->appliedFor[$gridName . $gridMixin])) {
         $this->dataGridConfigurationHelper->extendConfiguration($config, $gridMixin);
         $this->appliedFor[$gridName . $gridMixin] = true;
     }
 }
 /**
  * Add fields that are not mentioned in aggregate functions to GROUP BY.
  *
  * @param PreBuild $event
  */
 public function onPreBuild(PreBuild $event)
 {
     $config = $event->getConfig();
     $parameters = $event->getParameters();
     $gridName = $config->offsetGetByPath(self::PATH_NAME);
     if (!$this->isApplicable($gridName, $parameters)) {
         return;
     }
     $selects = $config->offsetGetByPath(self::PATH_SELECT, []);
     $groupBy = $config->offsetGetByPath(self::PATH_GROUPBY);
     $groupBy = $this->groupByHelper->getGroupByFields($groupBy, $selects);
     if ($groupBy) {
         $config->offsetSetByPath(self::PATH_GROUPBY, implode(',', $groupBy));
     }
 }
Example #6
0
 /**
  * @param PreBuild $event
  */
 public function onPreBuild(PreBuild $event)
 {
     $parameters = $event->getParameters();
     $config = $event->getConfig();
     if (!$this->isApplicable($config, $parameters)) {
         return;
     }
     $gridName = $config->getName();
     $mixins = $this->getMixins($config, $parameters);
     foreach ($mixins as $mixin) {
         if (empty($this->appliedFor[$gridName . $mixin])) {
             $this->mixinConfigurationHelper->extendConfiguration($config, $mixin);
             $this->appliedFor[$gridName . $mixin] = true;
         }
     }
 }
 /**
  * @param PreBuild $event
  */
 public function onPreBuild(PreBuild $event)
 {
     $config = $event->getConfig();
     $parameters = $event->getParameters();
     $gridName = $config->offsetGetByPath(self::PATH_NAME);
     if (!$this->isApplicable($gridName, $parameters)) {
         return;
     }
     $emailCampaignId = $parameters->get('emailCampaign');
     $emailCampaign = $this->registry->getRepository('OroCRMCampaignBundle:EmailCampaign')->find($emailCampaignId);
     if ($emailCampaign->isSent()) {
         $config->offsetUnsetByPath(self::PATH_DATAGRID_WHERE);
         $mixin = self::MIXIN_SENT_NAME;
     } else {
         $mixin = self::MIXIN_UNSENT_NAME;
     }
     $parameters->set(MixinListener::GRID_MIXIN, $mixin);
 }
 /**
  * @param PreBuild $event
  */
 public function onPreBuild(PreBuild $event)
 {
     $config = $event->getConfig();
     $parameters = $event->getParameters();
     $gridName = $config->offsetGetByPath('[name]');
     if (!$this->isApplicable($gridName, $parameters)) {
         return;
     }
     $selects = $config->offsetGetByPath('[source][query][select]', []);
     $groupBy = [];
     foreach ($selects as $select) {
         preg_match('/([^\\s]+)\\s+as\\s+c\\d+$/i', $select, $parts);
         if (!empty($parts[1])) {
             $groupBy[] = $parts[1];
         }
     }
     if (empty($groupBy)) {
         return;
     }
     if ($existingGroupBy = $config->offsetGetByPath(self::PATH_GROUPBY)) {
         $groupBy[] = $existingGroupBy;
     }
     $config->offsetSetByPath(self::PATH_GROUPBY, implode(', ', $groupBy));
 }
 /**
  * @param PreBuild $event
  */
 protected function addFilterByCategory(PreBuild $event)
 {
     $categoryId = $this->requestProductHandler->getCategoryId();
     if (!$categoryId) {
         return;
     }
     /** @var CategoryRepository $repo */
     $repo = $this->doctrine->getRepository($this->dataClass);
     /** @var Category $category */
     $category = $repo->find($categoryId);
     if (!$category) {
         return;
     }
     $includeSubcategoriesChoice = $this->requestProductHandler->getIncludeSubcategoriesChoice();
     $productCategoryIds = [$categoryId];
     if ($includeSubcategoriesChoice) {
         $productCategoryIds = array_merge($repo->getChildrenIds($category), $productCategoryIds);
     }
     $config = $event->getConfig();
     $config->offsetSetByPath('[source][query][where][and]', ['productCategory.id IN (:productCategoryIds)']);
     $config->offsetSetByPath(DatasourceBindParametersListener::DATASOURCE_BIND_PARAMETERS_PATH, ['productCategoryIds']);
     $event->getParameters()->set('productCategoryIds', $productCategoryIds);
     $this->addCategoryJoin($event->getConfig());
 }