class NodesSourcesRepository extends StatusAwareRepository (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 bool $isPreview from EntityRepository
protected Container $container from EntityRepository
protected array $searchableTypes Doctrine column types that can be search with LIKE feature. from EntityRepository

Methods

__construct(EntityManager $em, ClassMetadata $class, Container $container, bool $isPreview = false)

No description

Container
getContainer()

No description

setContainer(Container $container)

No description

mixed
get(string $serviceName)

No description

bool
has(string $serviceName)

No description

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)

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.

setDisplayingNotPublishedNodes(bool $displayNotPublishedNodes)

No description

setDisplayingAllNodesStatuses(bool $displayAllNodesStatuses)

Switch repository to disable any security on Node status. To use ONLY in order to view deleted and archived nodes.

bool
isBackendUserWithPreview()

No description

QueryBuilder
alterQueryBuilderWithAuthorizationChecker(QueryBuilder $qb, string $prefix = EntityRepository::NODE_ALIAS)

No description

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.

QueryBuilder
getContextualQuery(array $criteria, array $orderBy = null, integer|null $limit = null, integer|null $offset = null)

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

QueryBuilder
getCountContextualQueryWithTranslation(array $criteria)

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)

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

findOneBy(array $criteria, array $orderBy = null)

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)

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

__construct(EntityManager $em, ClassMetadata $class, Container $container, bool $isPreview = false)

Parameters

EntityManager $em
ClassMetadata $class
Container $container
bool $isPreview

Container getContainer()

Return Value

Container

ContainerAwareInterface setContainer(Container $container)

Parameters

Container $container

Return Value

ContainerAwareInterface

mixed get(string $serviceName)

Parameters

string $serviceName

Return Value

mixed

bool has(string $serviceName)

Parameters

string $serviceName

Return Value

bool true if the service is defined, false otherwise

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)

Just like the countBy method but with relational criteria.

Parameters

Criteria|mixed|array $criteria or array

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

bool isDisplayingNotPublishedNodes()

Return Value

bool

StatusAwareRepository setDisplayingNotPublishedNodes(bool $displayNotPublishedNodes)

Parameters

bool $displayNotPublishedNodes

Return Value

StatusAwareRepository

bool isDisplayingAllNodesStatuses()

Return Value

bool

StatusAwareRepository setDisplayingAllNodesStatuses(bool $displayAllNodesStatuses)

Switch repository to disable any security on Node status. To use ONLY in order to view deleted and archived nodes.

Parameters

bool $displayAllNodesStatuses

Return Value

StatusAwareRepository

protected bool isBackendUserWithPreview()

Return Value

bool

protected QueryBuilder alterQueryBuilderWithAuthorizationChecker(QueryBuilder $qb, string $prefix = EntityRepository::NODE_ALIAS)

Parameters

QueryBuilder $qb
string $prefix

Return Value

QueryBuilder

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 QueryBuilder getContextualQuery(array $criteria, array $orderBy = null, integer|null $limit = null, integer|null $offset = null)

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

Return Value

QueryBuilder

protected QueryBuilder getCountContextualQueryWithTranslation(array $criteria)

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

Return Value

QueryBuilder

array|Paginator findBy(array $criteria, array $orderBy = null, integer $limit = null, integer $offset = null)

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

Return Value

array|Paginator

null|NodesSources findOneBy(array $criteria, array $orderBy = null)

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

Parameters

array $criteria
array $orderBy

Return Value

null|NodesSources

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)

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

Parameters

$textQuery
int $limit
array $nodeTypes
bool $onlyVisible

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