當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ProxyQueryInterface::getRootEntities方法代碼示例

本文整理匯總了PHP中Sonata\AdminBundle\Datagrid\ProxyQueryInterface::getRootEntities方法的典型用法代碼示例。如果您正苦於以下問題:PHP ProxyQueryInterface::getRootEntities方法的具體用法?PHP ProxyQueryInterface::getRootEntities怎麽用?PHP ProxyQueryInterface::getRootEntities使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sonata\AdminBundle\Datagrid\ProxyQueryInterface的用法示例。


在下文中一共展示了ProxyQueryInterface::getRootEntities方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: filter

 /**
  * {@inheritdoc}
  */
 public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
 {
     if (!$data || !is_array($data) || !array_key_exists('value', $data)) {
         return;
     }
     $data['value'] = trim($data['value']);
     if (strlen($data['value']) == 0) {
         return;
     }
     $data['type'] = !isset($data['type']) ? ChoiceType::TYPE_CONTAINS : $data['type'];
     $operator = $this->getOperator((int) $data['type']);
     if (!$operator) {
         $operator = 'LIKE';
     }
     $entities = $queryBuilder->getRootEntities();
     $classMetadata = $this->listener->getTranslatableMetadata(current($entities));
     $transMetadata = $this->listener->getTranslatableMetadata($classMetadata->targetEntity);
     // Add inner join
     if (!$this->hasJoin($queryBuilder, $alias)) {
         $parameterName = $this->getNewParameterName($queryBuilder);
         $queryBuilder->innerJoin(sprintf('%s.%s', $alias, $classMetadata->translations->name), 'trans', Expr\Join::WITH, sprintf('trans.%s = :%s', $transMetadata->locale->name, $parameterName));
         $queryBuilder->setParameter($parameterName, $this->listener->getCurrentLocale());
     }
     // c.name > '1' => c.name OPERATOR :FIELDNAME
     $parameterName = $this->getNewParameterName($queryBuilder);
     $this->applyWhere($queryBuilder, sprintf('%s.%s %s :%s', 'trans', $field, $operator, $parameterName));
     if ($data['type'] == ChoiceType::TYPE_EQUAL) {
         $queryBuilder->setParameter($parameterName, $data['value']);
     } else {
         $queryBuilder->setParameter($parameterName, sprintf($this->getOption('format'), $data['value']));
     }
 }
開發者ID:alli-govender,項目名稱:doctrine-translatable-bundle,代碼行數:35,代碼來源:TranslatableFilter.php


注:本文中的Sonata\AdminBundle\Datagrid\ProxyQueryInterface::getRootEntities方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。