class NodesSourcesRepository extends EntityRepository (View source)

EntityRepository that implements search engine query with Solr.

Constants

NODE_ALIAS

Alias for DQL and Query builder representing Node relation.

NODESSOURCES_ALIAS

Alias for DQL and Query builder representing NodesSources relation.

TRANSLATION_ALIAS

Alias for DQL and Query builder representing Translation relation.

TAG_ALIAS

Alias for DQL and Query builder representing Tag relation.

Properties

protected array $searchableTypes Doctrine column types that can be search with LIKE feature. from EntityRepository

Methods

string
buildComparison(mixed $value, string $prefix, string $key, string $baseKey, QueryBuilder $qb)

Build a query comparison.

QueryBuilder
directComparison(array $criteria, QueryBuilder $qb, string $alias)

Direct bind parameters without preparation.

QueryBuilder
prepareComparisons(array $criteria, QueryBuilder $qb, string $alias)

No description

applyComparisons(array $criteria, Query $finalQuery)

No description

QueryBuilder
singleDirectComparison(string $key, mixed $value, QueryBuilder $qb, string $alias)

Direct bind one single parameter without preparation.

Func
directExprIn(QueryBuilder $qb, string $name, string $key, array $value)

No description

applyComparison(string $key, mixed $value, Query $finalQuery)

Bind classic parameters to your query.

integer
countBy(Criteria|mixed|array $criteria, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Just like the countBy method but with relational criteria.

classicLikeComparison(string $pattern, QueryBuilder $qb, string $alias = "obj")

Create a LIKE comparison with entity texts colunms.

QueryBuilder
createSearchBy(string $pattern, QueryBuilder $qb, array $criteria = [], string $alias = "obj")

Create a Criteria object from a search pattern and additionnal fields.

array|Paginator
searchBy(string $pattern, array $criteria = [], array $orders = [], integer $limit = null, integer $offset = null)

No description

int
countSearchBy(string $pattern, array $criteria = [])

No description

buildTagFiltering(array $criteria, QueryBuilder $qb, string $nodeAlias = 'n')

No description

applyFilterByTag(array $criteria, Query $finalQuery)

Bind tag parameters to final query

boolean
hasJoinedNode(QueryBuilder $qb, string $alias)

Ensure that node table is joined only once.

boolean
hasJoinedNodesSources(QueryBuilder $qb, string $alias)

Ensure that nodes_sources table is joined only once.

filterByTag(array $criteria, QueryBuilder $qb, boolean $joinedNode)

Add a tag filtering to queryBuilder.

filterByCriteria(array $criteria, QueryBuilder $qb, boolean $joinedNode = false, boolean $joinedNodeType = false)

Reimplementing findBy features… with extra things.

applyFilterByCriteria(array $criteria, Query $finalQuery)

Bind parameters to generated query.

bool
filterByAuthorizationChecker(array $criteria, QueryBuilder $qb, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

No description

QueryBuilder
getContextualQuery(array $criteria, array $orderBy = null, integer|null $limit = null, integer|null $offset = null, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Create a securized query with node.published = true if user is not a Backend user.

QueryBuilder
getCountContextualQueryWithTranslation(array $criteria, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Create a securized count query with node.published = true if user is not a Backend user and if authorizationChecker is defined.

array|Paginator
findBy(array $criteria, array $orderBy = null, integer $limit = null, integer $offset = null, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

A secure findBy with which user must be a backend user to see unpublished nodes.

findOneBy(array $criteria, array $orderBy = null, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

A secure findOneBy with which user must be a backend user to see unpublished nodes.

array
findBySearchQuery(string $query, integer $limit = 25)

Search nodes sources by using Solr search engine.

array
findBySearchQueryAndTranslation(string $query, Translation $translation, int $limit = 25)

Search nodes sources by using Solr search engine and a specific translation.

array
findByTextQuery($textQuery, int $limit, array $nodeTypes = [], bool $onlyVisible = false, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

Search Nodes-Sources using LIKE condition on title meta-title, meta-keywords, meta-description.

Paginator
findByLatestUpdated(integer $maxResult = 5)

Find latest updated NodesSources using Log table.

findParent(NodesSources $nodeSource)

Get node-source parent according to its translation.

mixed|null
findOneByNodeAndTranslation(Node $node, Translation $translation)

No description

Details

protected string buildComparison(mixed $value, string $prefix, string $key, string $baseKey, QueryBuilder $qb)

Build a query comparison.

Parameters

mixed $value
string $prefix The prefix should always end with a dot
string $key
string $baseKey
QueryBuilder $qb

Return Value

string

protected QueryBuilder directComparison(array $criteria, QueryBuilder $qb, string $alias)

Direct bind parameters without preparation.

Parameters

array $criteria
QueryBuilder $qb
string $alias

Return Value

QueryBuilder

protected QueryBuilder prepareComparisons(array $criteria, QueryBuilder $qb, string $alias)

Parameters

array $criteria
QueryBuilder $qb
string $alias

Return Value

QueryBuilder

protected applyComparisons(array $criteria, Query $finalQuery)

Parameters

array $criteria
Query $finalQuery

protected QueryBuilder singleDirectComparison(string $key, mixed $value, QueryBuilder $qb, string $alias)

Direct bind one single parameter without preparation.

Parameters

string $key
mixed $value
QueryBuilder $qb
string $alias

Return Value

QueryBuilder

protected Func directExprIn(QueryBuilder $qb, string $name, string $key, array $value)

Parameters

QueryBuilder $qb &$qb
string $name
string $key
array $value

Return Value

Func

protected applyComparison(string $key, mixed $value, Query $finalQuery)

Bind classic parameters to your query.

Parameters

string $key
mixed $value
Query $finalQuery

integer countBy(Criteria|mixed|array $criteria, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Just like the countBy method but with relational criteria.

Parameters

Criteria|mixed|array $criteria or array
AuthorizationChecker $authorizationChecker
boolean $preview

Return Value

integer

protected classicLikeComparison(string $pattern, QueryBuilder $qb, string $alias = "obj")

Create a LIKE comparison with entity texts colunms.

Parameters

string $pattern
QueryBuilder $qb
string $alias

protected QueryBuilder createSearchBy(string $pattern, QueryBuilder $qb, array $criteria = [], string $alias = "obj")

Create a Criteria object from a search pattern and additionnal fields.

Parameters

string $pattern Search pattern
QueryBuilder $qb QueryBuilder to pass
array $criteria Additionnal criteria
string $alias SQL query table alias

Return Value

QueryBuilder

array|Paginator searchBy(string $pattern, array $criteria = [], array $orders = [], integer $limit = null, integer $offset = null)

Parameters

string $pattern Search pattern
array $criteria Additionnal criteria
array $orders
integer $limit
integer $offset

Return Value

array|Paginator

int countSearchBy(string $pattern, array $criteria = [])

Parameters

string $pattern Search pattern
array $criteria Additionnal criteria

Return Value

int

protected buildTagFiltering(array $criteria, QueryBuilder $qb, string $nodeAlias = 'n')

Parameters

array $criteria &$criteria
QueryBuilder $qb
string $nodeAlias

protected applyFilterByTag(array $criteria, Query $finalQuery)

Bind tag parameters to final query

Parameters

array $criteria
Query $finalQuery

protected boolean hasJoinedNode(QueryBuilder $qb, string $alias)

Ensure that node table is joined only once.

Parameters

QueryBuilder $qb
string $alias

Return Value

boolean

protected boolean hasJoinedNodesSources(QueryBuilder $qb, string $alias)

Ensure that nodes_sources table is joined only once.

Parameters

QueryBuilder $qb
string $alias

Return Value

boolean

protected filterByTag(array $criteria, QueryBuilder $qb, boolean $joinedNode)

Add a tag filtering to queryBuilder.

Parameters

array $criteria
QueryBuilder $qb
boolean $joinedNode

protected filterByCriteria(array $criteria, QueryBuilder $qb, boolean $joinedNode = false, boolean $joinedNodeType = false)

Reimplementing findBy features… with extra things.

  • key => array('<=', $value)
  • key => array('<', $value)
  • key => array('>=', $value)
  • key => array('>', $value)
  • key => array('BETWEEN', $value, $value)
  • key => array('LIKE', $value)
  • key => array('NOT IN', $array)
  • key => 'NOT NULL'

You even can filter with node fields, examples:

  • node.published => true
  • node.nodeName => 'page1'

Parameters

array $criteria
QueryBuilder $qb
boolean $joinedNode
boolean $joinedNodeType

protected applyFilterByCriteria(array $criteria, Query $finalQuery)

Bind parameters to generated query.

Parameters

array $criteria
Query $finalQuery

protected bool filterByAuthorizationChecker(array $criteria, QueryBuilder $qb, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

Parameters

array $criteria
QueryBuilder $qb
AuthorizationChecker $authorizationChecker
bool $preview

Return Value

bool

protected QueryBuilder getContextualQuery(array $criteria, array $orderBy = null, integer|null $limit = null, integer|null $offset = null, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Create a securized query with node.published = true if user is not a Backend user.

Parameters

array $criteria
array $orderBy
integer|null $limit
integer|null $offset
AuthorizationChecker $authorizationChecker
boolean $preview

Return Value

QueryBuilder

protected QueryBuilder getCountContextualQueryWithTranslation(array $criteria, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Create a securized count query with node.published = true if user is not a Backend user and if authorizationChecker is defined.

This method allows to pre-filter Nodes with a given translation.

Parameters

array $criteria
AuthorizationChecker $authorizationChecker
boolean $preview

Return Value

QueryBuilder

array|Paginator findBy(array $criteria, array $orderBy = null, integer $limit = null, integer $offset = null, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

A secure findBy with which user must be a backend user to see unpublished nodes.

Reimplementing findBy features… with extra things.

  • key => array('<=', $value)
  • key => array('<', $value)
  • key => array('>=', $value)
  • key => array('>', $value)
  • key => array('BETWEEN', $value, $value)
  • key => array('LIKE', $value)
  • key => array('NOT IN', $array)
  • key => 'NOT NULL'

You even can filter with node fields, examples:

  • node.published => true
  • node.nodeName => 'page1'

Or filter by tags:

  • tags => $tag1
  • tags => [$tag1, $tag2]
  • tags => [$tag1, $tag2], tagExclusive => true

Parameters

array $criteria
array $orderBy
integer $limit
integer $offset
AuthorizationChecker $authorizationChecker
boolean $preview

Return Value

array|Paginator

NodesSources|null findOneBy(array $criteria, array $orderBy = null, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

A secure findOneBy with which user must be a backend user to see unpublished nodes.

Parameters

array $criteria
array $orderBy
AuthorizationChecker $authorizationChecker
boolean $preview

Return Value

NodesSources|null

array findBySearchQuery(string $query, integer $limit = 25)

Search nodes sources by using Solr search engine.

Parameters

string $query Solr query string (for example: text:Lorem Ipsum)
integer $limit Result number to fetch (default: all)

Return Value

array

array findBySearchQueryAndTranslation(string $query, Translation $translation, int $limit = 25)

Search nodes sources by using Solr search engine and a specific translation.

Parameters

string $query Solr query string (for example: text:Lorem Ipsum)
Translation $translation Current translation
int $limit

Return Value

array

array findByTextQuery($textQuery, int $limit, array $nodeTypes = [], bool $onlyVisible = false, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

Search Nodes-Sources using LIKE condition on title meta-title, meta-keywords, meta-description.

Parameters

$textQuery
int $limit
array $nodeTypes
bool $onlyVisible
AuthorizationChecker $authorizationChecker
bool $preview

Return Value

array

Paginator findByLatestUpdated(integer $maxResult = 5)

Find latest updated NodesSources using Log table.

Parameters

integer $maxResult

Return Value

Paginator

NodesSources|null findParent(NodesSources $nodeSource)

Get node-source parent according to its translation.

Parameters

NodesSources $nodeSource

Return Value

NodesSources|null

mixed|null findOneByNodeAndTranslation(Node $node, Translation $translation)

Parameters

Node $node
Translation $translation

Return Value

mixed|null

Exceptions

NonUniqueResultException