当前位置: 首页>>代码示例>>PHP>>正文


PHP Query::setHint方法代码示例

本文整理汇总了PHP中Doctrine\ORM\Query::setHint方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::setHint方法的具体用法?PHP Query::setHint怎么用?PHP Query::setHint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ORM\Query的用法示例。


在下文中一共展示了Query::setHint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: applyTranslatorGedmoHints

 /**
  * @param Query $query
  */
 protected function applyTranslatorGedmoHints(Query &$query)
 {
     if (BELCEBUR_GEDMO_TRANSLATION_LOCALE !== 'BELCEBUR_GEDMO_TRANSLATION_LOCALE') {
         $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, $this->gedmoWalker);
         $query->setHint(TranslatableListener::HINT_TRANSLATABLE_LOCALE, BELCEBUR_GEDMO_TRANSLATION_LOCALE);
         $query->setHint(TranslatableListener::HINT_FALLBACK, TRUE);
     }
 }
开发者ID:Belcebur,项目名称:BelceburBasic,代码行数:11,代码来源:EntityRepositoryTranslatable.php

示例2: setTranslatableQueryHints

 /**
  * @param Query $query
  * @param string $locale
  * @throws \Exception
  */
 protected function setTranslatableQueryHints(Query $query, $locale)
 {
     if (!class_exists('Gedmo\\Translatable\\TranslatableListener')) {
         throw new \Exception('"Translatable" extension missing. "stof/doctrine-extensions-bundle" needs to be installed');
     }
     $query->setHint(\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
     $query->setHint(\Gedmo\Translatable\TranslatableListener::HINT_TRANSLATABLE_LOCALE, $locale);
     $query->setHint(\Gedmo\Translatable\TranslatableListener::HINT_FALLBACK, 1);
 }
开发者ID:byteworks-ch,项目名称:AstinaLabelsBundle,代码行数:14,代码来源:TranslatedLabelSearch.php

示例3: apply

 /**
  * {@inheritdoc}
  */
 public function apply($fromAlias, $fromIdentifier, $resourcePrefix, array $requesterIdentifiers, $mask, array $orX = [])
 {
     $this->query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'AlexDpy\\Acl\\Database\\Filter\\DoctrineOrmAclWalker');
     $this->query->setHint('acl_permissions_table_name', $this->getAclSchema()->getPermissionsTableName());
     $this->query->setHint('acl_resource_prefix', $resourcePrefix);
     $this->query->setHint('acl_requester_identifiers', $requesterIdentifiers);
     $this->query->setHint('acl_mask', $mask);
     $this->query->setHint('acl_from_alias', $fromAlias);
     $this->query->setHint('acl_from_identifier', $fromIdentifier);
     $this->query->setHint('acl_or_x', $orX);
     return $this->query;
 }
开发者ID:alexdpy,项目名称:acl,代码行数:15,代码来源:DoctrineOrmAclFilter.php

示例4: apply

 /**
  * Apply ACL filter
  *
  * @param  QueryBuilder | Query   $query
  * @param  array                  $permissions
  * @param  string | UserInterface $identity
  * @param  string                 $alias
  * @param  array|Query|QueryBuilder $extraCriteria
  *
  * @return Query
  */
 public function apply($query, array $permissions = array('VIEW'), $identity = null, $alias = null, $extraCriteria = false)
 {
     if (null === $identity) {
         $token = $this->securityContext->getToken();
         $identity = $token->getUser();
     }
     $query->setHint(static::HINT_ACL_EXTRA_CRITERIA, $this->getExtraCriteria($extraCriteria));
     if ($query instanceof QueryBuilder) {
         $query = $this->cloneQuery($query->getQuery());
     } elseif ($query instanceof Query) {
         $query = $this->cloneQuery($query);
     } else {
         throw new \Exception();
     }
     $maskBuilder = new MaskBuilder();
     foreach ($permissions as $permission) {
         $mask = constant(get_class($maskBuilder) . '::MASK_' . strtoupper($permission));
         $maskBuilder->add($mask);
     }
     $entity = $this->getEntityFromAlias($query, $alias);
     $metadata = $entity['metadata'];
     $alias = $entity['alias'];
     $table = $metadata->getQuotedTableName($this->em->getConnection()->getDatabasePlatform());
     $aclQuery = $this->getExtraQuery($this->getClasses($metadata), $this->getIdentifiers($identity), $maskBuilder->get());
     $hintAclMetadata = false !== $query->getHint('acl.metadata') ? $query->getHint('acl.metadata') : array();
     $hintAclMetadata[] = array('query' => $aclQuery, 'table' => $table, 'alias' => $alias);
     $query->setHint('acl.metadata', $hintAclMetadata);
     $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, $this->aclWalker);
     return $query;
 }
开发者ID:Codenetz,项目名称:AclBundle,代码行数:41,代码来源:AclFilter.php

示例5: addHint

 /**
  * Adds a hint to a query object
  *
  * @param Query  $query
  * @param string $name
  * @param mixed  $value
  *
  * @return bool TRUE if the hint is added; otherwise, FALSE
  */
 public function addHint(Query $query, $name, $value)
 {
     $result = false;
     if ($name === Query::HINT_CUSTOM_TREE_WALKERS) {
         $walkers = $query->getHint(Query::HINT_CUSTOM_TREE_WALKERS);
         if (false === $walkers) {
             $walkers = [$value];
             $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, $walkers);
             $result = true;
         } elseif (!in_array($value, $walkers, true)) {
             $walkers[] = $value;
             $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, $walkers);
             $result = true;
         }
     } elseif ($name === Query::HINT_CUSTOM_OUTPUT_WALKER) {
         if ($query->getHint($name) !== $value) {
             $query->setHint($name, $value);
             $result = true;
         }
     } else {
         $query->setHint($name, $value);
         $result = true;
     }
     return $result;
 }
开发者ID:Maksold,项目名称:platform,代码行数:34,代码来源:QueryHintResolver.php

示例6: __construct

 /**
  * @param \Doctrine\ORM\Query $query          The Doctrine Query
  * @param array               $fields         Fields to export
  * @param string              $dateTimeFormat
  */
 public function __construct(Query $query, array $fields, $dateTimeFormat = 'r')
 {
     $this->query = clone $query;
     $this->query->setParameters($query->getParameters());
     foreach ($query->getHints() as $name => $value) {
         $this->query->setHint($name, $value);
     }
     $this->propertyAccessor = PropertyAccess::createPropertyAccessor();
     $this->propertyPaths = array();
     foreach ($fields as $name => $field) {
         if (is_string($name) && is_string($field)) {
             $this->propertyPaths[$name] = new PropertyPath($field);
         } else {
             $this->propertyPaths[$field] = new PropertyPath($field);
         }
     }
     $this->dateTimeFormat = $dateTimeFormat;
 }
开发者ID:LamaDelRay,项目名称:test_symf,代码行数:23,代码来源:DoctrineORMQuerySourceIterator.php

示例7: updateQuery

 /**
  * Updates the configured query object with the where-clause and query-hints.
  *
  * @param string $prependQuery Prepends this string to the where-clause
  *                             (" WHERE " or " AND " for example)
  *
  * @return self
  */
 public function updateQuery($prependQuery = ' WHERE ')
 {
     $whereCase = $this->getWhereClause($prependQuery);
     if ('' !== $whereCase) {
         $this->query->setDQL($this->query->getDQL() . $whereCase);
         $this->query->setHint($this->getQueryHintName(), $this->getQueryHintValue());
     }
     return $this;
 }
开发者ID:rollerworks,项目名称:search-doctrine-orm,代码行数:17,代码来源:WhereBuilder.php

示例8: addCustomTreeWalker

 /**
  * Add a custom TreeWalker $walker class name to
  * be included in the CustomTreeWalker hint list
  * of the given $query
  *
  * @param Query $query
  * @param string $walker
  * @return void
  */
 public static function addCustomTreeWalker(Query $query, $walker)
 {
     $customTreeWalkers = $query->getHint(Query::HINT_CUSTOM_TREE_WALKERS);
     if ($customTreeWalkers !== false && is_array($customTreeWalkers)) {
         $customTreeWalkers = array_merge($customTreeWalkers, array($walker));
     } else {
         $customTreeWalkers = array($walker);
     }
     $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, $customTreeWalkers);
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:19,代码来源:Helper.php

示例9: __construct

 /**
  * @param \Doctrine\ORM\Query $query          The Doctrine Query
  * @param array               $fields         Fields to export
  * @param string              $dateTimeFormat
  */
 public function __construct(Query $query, array $fields, $dateTimeFormat = 'r')
 {
     $this->query = clone $query;
     $this->query->setParameters($query->getParameters());
     foreach ($query->getHints() as $name => $value) {
         $this->query->setHint($name, $value);
     }
     // Note : will be deprecated in Symfony 3.0, conserved for 2.2 compatibility
     // Use createPropertyAccessor() for 3.0
     // @see Symfony\Component\PropertyAccess\PropertyAccess
     $this->propertyAccessor = PropertyAccess::getPropertyAccessor();
     $this->propertyPaths = array();
     foreach ($fields as $name => $field) {
         if (is_string($name) && is_string($field)) {
             $this->propertyPaths[$name] = new PropertyPath($field);
         } else {
             $this->propertyPaths[$field] = new PropertyPath($field);
         }
     }
     $this->dateTimeFormat = $dateTimeFormat;
 }
开发者ID:serialken,项目名称:BugTracker,代码行数:26,代码来源:DoctrineORMQuerySourceIterator.php

示例10: setHint

 public function setHint(\Doctrine\ORM\Query $query)
 {
     return $query->setHint(\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
 }
开发者ID:birko,项目名称:MiniShopGoogle,代码行数:4,代码来源:ProductCategoryRepository.php

示例11: appendTreeWalker

 /**
  * Appends a custom tree walker to the tree walkers hint.
  *
  * @param Query $query
  * @param string $walkerClass
  */
 private function appendTreeWalker(Query $query, $walkerClass)
 {
     $hints = $query->getHint(Query::HINT_CUSTOM_TREE_WALKERS);
     if ($hints === false) {
         $hints = array();
     }
     $hints[] = $walkerClass;
     $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, $hints);
 }
开发者ID:ratehub,项目名称:doctrine2,代码行数:15,代码来源:Paginator.php

示例12: getAllowedEntityIds

 /**
  * Returns valid IDs for a specific entity with ACL restrictions for current user applied
  *
  * @param PermissionDefinition $permissionDef
  *
  * @throws InvalidArgumentException
  *
  * @return array
  */
 public function getAllowedEntityIds(PermissionDefinition $permissionDef)
 {
     $rootEntity = $permissionDef->getEntity();
     if (empty($rootEntity)) {
         throw new InvalidArgumentException("You have to provide an entity class name!");
     }
     $builder = new MaskBuilder();
     foreach ($permissionDef->getPermissions() as $permission) {
         $mask = constant(get_class($builder) . '::MASK_' . strtoupper($permission));
         $builder->add($mask);
     }
     $query = new Query($this->em);
     $query->setHint('acl.mask', $builder->get());
     $query->setHint('acl.root.entity', $rootEntity);
     $sql = $this->getPermittedAclIdsSQLForUser($query);
     $rsm = new ResultSetMapping();
     $rsm->addScalarResult('id', 'id');
     $nativeQuery = $this->em->createNativeQuery($sql, $rsm);
     $transform = function ($item) {
         return $item['id'];
     };
     $result = array_map($transform, $nativeQuery->getScalarResult());
     return $result;
 }
开发者ID:axelvnk,项目名称:KunstmaanBundlesCMS,代码行数:33,代码来源:AclHelper.php

示例13: setQueryHints

 /**
  * Sets hints for result query
  *
  * @param Query $query
  */
 protected function setQueryHints(Query $query)
 {
     if (!empty($this->queryHints)) {
         foreach ($this->queryHints as $name => $value) {
             if (defined("Doctrine\\ORM\\Query::{$name}")) {
                 $name = constant("Doctrine\\ORM\\Query::{$name}");
             }
             $query->setHint($name, $value);
         }
     }
 }
开发者ID:nmallare,项目名称:platform,代码行数:16,代码来源:OrmDatasource.php

示例14: setTranslatableHint

 /**
  * Add hints to the query
  *
  * @param Query       $query  Query
  * @param string|null $locale Lecale to which fallback
  *
  * @return Query
  */
 public function setTranslatableHint(Query $query, $locale = null)
 {
     $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
     $query->setHint(TranslatableListener::HINT_INNER_JOIN, false);
     $query->setHint(TranslatableListener::HINT_TRANSLATABLE_LOCALE, $locale);
     $query->setHint(TranslatableListener::HINT_FALLBACK, true);
     return $query;
 }
开发者ID:alvsgithub,项目名称:Newscoop,代码行数:16,代码来源:TopicRepository.php

示例15: addHintToQuery

 /**
  * Adds a Query hint to a Query Object
  * @param \Doctrine\ORM\Query $query
  * @return \Doctrine\ORM\Query 
  */
 public function addHintToQuery(\Doctrine\ORM\Query $query)
 {
     return $query->setHint($this->getConfiguration()->GetQueryHintName(), $this->getConfiguration()->GetQueryHintValue());
 }
开发者ID:alifuk,项目名称:mrafi,代码行数:9,代码来源:Manager.php


注:本文中的Doctrine\ORM\Query::setHint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。