class NodeRepository extends EntityRepository (View source)

NodeRepository

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, Translation $translation = null, 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 additional 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.

QueryBuilder
getCountContextualQueryWithTranslation(array $criteria, Translation $translation = null, 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.

filterByTranslation(array $criteria, QueryBuilder $qb, Translation|null $translation = null)

Create filters according to any translation criteria OR argument.

filterByTag(array $criteria, QueryBuilder $qb)

Add a tag filtering to queryBuilder.

filterByCriteria(array $criteria, QueryBuilder $qb)

Reimplementing findBy features… with extra things.

applyFilterByCriteria(array $criteria, Query $finalQuery)

Bind parameters to generated query.

applyTranslationByTag(Query $finalQuery, Translation $translation = null)

Bind translation parameter to final query.

array
findByWithTranslation(array $criteria, array $orderBy = null, integer|null $limit = null, integer|null $offset = null, Translation $translation = null, AuthorizationChecker $authorizationChecker = null)

Just like the findBy method but with a given Translation and optional AuthorizationChecker.

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

Just like the findBy method but with relational criteria.

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

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

Node|null
findOneByWithTranslation(array $criteria, Translation $translation = null, AuthorizationChecker $authorizationChecker = null)

Just like the findOneBy method but with a given Translation and optional AuthorizationChecker.

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

Just like the findOneBy method but with relational criteria.

Node|null
findWithTranslation(integer $nodeId, Translation $translation, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Find one Node with its Id and a given translation.

string
alterQueryWithAuthorizationChecker(string $txtQuery, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Modify DQL query string to support node status according to security context.

Node|null
findWithDefaultTranslation(integer $nodeId, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Find one Node with its Id and the default translation.

Node|null
findByNodeNameWithTranslation(string $nodeName, Translation $translation, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Find one Node with its nodeName and a given translation.

Node|null
findByNodeNameWithDefaultTranslation(string $nodeName, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Find one Node with its nodeName and the default translation.

Node|null
findHomeWithTranslation(Translation $translation = null, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Find the Home node with a given translation.

Node|null
findHomeWithDefaultTranslation(AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Find the Home node with the default translation.

array
getChildrenWithTranslation(Node $node, Translation $translation, AuthorizationChecker $authorizationChecker = null, bool $preview = false) deprecated

No description

array
findByParentWithTranslation(Translation $translation, Node $parent = null, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

No description

array
findByParentWithDefaultTranslation(Node $parent = null, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

No description

Node|null
findOneWithUrlAlias(UrlAlias $urlAlias, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

No description

Node|null
findOneWithAliasAndAvailableTranslation($urlAliasAlias, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

No description

QueryBuilder
alterQueryBuilderWithAuthorizationChecker(QueryBuilder $qb, AuthorizationChecker $authorizationChecker = null, bool $preview = false, string $prefix = 'n')

No description

bool
exists($nodeName)

No description

array|null
findByNodeAndField(Node $node, NodeTypeField $field, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

No description

array|null
findByNodeAndFieldName(Node $node, $fieldName, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

No description

array|null
findByNodeAndFieldAndTranslation(Node $node, NodeTypeField $field, Translation $translation, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

No description

array|null
findByNodeAndFieldNameAndTranslation(Node $node, $fieldName, Translation $translation, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

No description

array
findByReverseNodeAndField(Node $node, NodeTypeField $field, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

No description

array
findByReverseNodeAndFieldName(Node $node, string $fieldName, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

No description

array|null
findByReverseNodeAndFieldAndTranslation(Node $node, NodeTypeField $field, Translation $translation, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

No description

array|null
findByReverseNodeAndFieldNameAndTranslation(Node $node, $fieldName, Translation $translation, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

No description

array
findAllOffspringIdByNode(Node $node)

No description

array|null
findAllNodeParentsBy(Node $node, array $criteria, array $orderBy = null, integer $limit = null, integer $offset = null, Translation $translation = null, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

Find all node’ parents with criteria and ordering.

array
findAllParentsIdByNode(Node $node)

No description

array
findAvailableTranslationForNode(Node $node)

No description

array
findUnavailableTranslationForNode(Node $node)

No description

array
findAvailableTranslationIdForNode(Node $node)

No description

array

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, Translation $translation = null, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Just like the countBy method but with relational criteria.

Parameters

Criteria|mixed|array $criteria or array
Translation $translation
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 additional 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 QueryBuilder getCountContextualQueryWithTranslation(array $criteria, Translation $translation = null, 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
Translation $translation
AuthorizationChecker $authorizationChecker
boolean $preview

Return Value

QueryBuilder

protected filterByTranslation(array $criteria, QueryBuilder $qb, Translation|null $translation = null)

Create filters according to any translation criteria OR argument.

Parameters

array $criteria
QueryBuilder $qb
Translation|null $translation

protected filterByTag(array $criteria, QueryBuilder $qb)

Add a tag filtering to queryBuilder.

Parameters

array $criteria
QueryBuilder $qb

protected filterByCriteria(array $criteria, QueryBuilder $qb)

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 can filter with translations relation, examples:

  • translation => $object
  • translation.locale => 'fr_FR'

Parameters

array $criteria
QueryBuilder $qb

protected applyFilterByCriteria(array $criteria, Query $finalQuery)

Bind parameters to generated query.

Parameters

array $criteria
Query $finalQuery

protected applyTranslationByTag(Query $finalQuery, Translation $translation = null)

Bind translation parameter to final query.

Parameters

Query $finalQuery
Translation $translation

array findByWithTranslation(array $criteria, array $orderBy = null, integer|null $limit = null, integer|null $offset = null, Translation $translation = null, AuthorizationChecker $authorizationChecker = null)

Just like the findBy method but with a given Translation and optional AuthorizationChecker.

If no translation nor authorizationChecker is given, the vanilla findBy method will be called instead.

Parameters

array $criteria
array $orderBy
integer|null $limit
integer|null $offset
Translation $translation
AuthorizationChecker $authorizationChecker

Return Value

array

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

Just like the findBy method but with relational criteria.

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 can filter with translations relation, examples:

  • translation => $object
  • translation.locale => 'fr_FR'

Or filter by tags:

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

Parameters

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

Return Value

array|Paginator

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

Create a securized 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
array $orderBy
integer|null $limit
integer|null $offset
Translation $translation
AuthorizationChecker $authorizationChecker
boolean $preview

Return Value

QueryBuilder

Node|null findOneByWithTranslation(array $criteria, Translation $translation = null, AuthorizationChecker $authorizationChecker = null)

Just like the findOneBy method but with a given Translation and optional AuthorizationChecker.

If no translation nor authorizationChecker is given, the vanilla findOneBy method will be called instead.

Parameters

array $criteria
Translation $translation
AuthorizationChecker $authorizationChecker

Return Value

Node|null

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

Just like the findOneBy method but with relational criteria.

Parameters

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

Return Value

null|Node

Node|null findWithTranslation(integer $nodeId, Translation $translation, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Find one Node with its Id and a given translation.

Parameters

integer $nodeId
Translation $translation
AuthorizationChecker $authorizationChecker When not null, only PUBLISHED node will be request or with a lower status
boolean $preview

Return Value

Node|null

protected string alterQueryWithAuthorizationChecker(string $txtQuery, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Modify DQL query string to support node status according to security context.

A not null authorizationChecker will always filter node.status to PUBLISHED or lower.

Parameters

string $txtQuery
AuthorizationChecker $authorizationChecker
boolean $preview

Return Value

string

Node|null findWithDefaultTranslation(integer $nodeId, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Find one Node with its Id and the default translation.

Parameters

integer $nodeId
AuthorizationChecker $authorizationChecker When not null, only PUBLISHED node will be request or with a lower status
boolean $preview

Return Value

Node|null

Node|null findByNodeNameWithTranslation(string $nodeName, Translation $translation, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Find one Node with its nodeName and a given translation.

Parameters

string $nodeName
Translation $translation
AuthorizationChecker $authorizationChecker When not null, only PUBLISHED node will be request or with a lower status
boolean $preview

Return Value

Node|null

Node|null findByNodeNameWithDefaultTranslation(string $nodeName, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Find one Node with its nodeName and the default translation.

Parameters

string $nodeName
AuthorizationChecker $authorizationChecker When not null, only PUBLISHED node will be request or with a lower status
boolean $preview

Return Value

Node|null

Node|null findHomeWithTranslation(Translation $translation = null, AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Find the Home node with a given translation.

Parameters

Translation $translation
AuthorizationChecker $authorizationChecker When not null, only PUBLISHED node will be request or with a lower status
boolean $preview

Return Value

Node|null

Node|null findHomeWithDefaultTranslation(AuthorizationChecker $authorizationChecker = null, boolean $preview = false)

Find the Home node with the default translation.

Parameters

AuthorizationChecker $authorizationChecker When not null, only PUBLISHED node will be request or with a lower status
boolean $preview

Return Value

Node|null

array getChildrenWithTranslation(Node $node, Translation $translation, AuthorizationChecker $authorizationChecker = null, bool $preview = false) deprecated

deprecated Use findByParentWithTranslation instead

Parameters

Node $node
Translation $translation
AuthorizationChecker $authorizationChecker
bool $preview

Return Value

array

array findByParentWithTranslation(Translation $translation, Node $parent = null, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

Parameters

Translation $translation
Node $parent
AuthorizationChecker $authorizationChecker
bool $preview

Return Value

array

array findByParentWithDefaultTranslation(Node $parent = null, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

Parameters

Node $parent
AuthorizationChecker $authorizationChecker
bool $preview

Return Value

array

Node|null findOneWithUrlAlias(UrlAlias $urlAlias, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

Parameters

UrlAlias $urlAlias
AuthorizationChecker $authorizationChecker
bool $preview

Return Value

Node|null

Exceptions

NonUniqueResultException

Node|null findOneWithAliasAndAvailableTranslation($urlAliasAlias, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

Parameters

$urlAliasAlias
AuthorizationChecker $authorizationChecker
bool $preview

Return Value

Node|null

Exceptions

NonUniqueResultException

protected QueryBuilder alterQueryBuilderWithAuthorizationChecker(QueryBuilder $qb, AuthorizationChecker $authorizationChecker = null, bool $preview = false, string $prefix = 'n')

Parameters

QueryBuilder $qb
AuthorizationChecker $authorizationChecker
bool $preview
string $prefix

Return Value

QueryBuilder

bool exists($nodeName)

Parameters

$nodeName

Return Value

bool

array|null findByNodeAndField(Node $node, NodeTypeField $field, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

Parameters

Node $node
NodeTypeField $field
AuthorizationChecker $authorizationChecker
bool $preview

Return Value

array|null

array|null findByNodeAndFieldName(Node $node, $fieldName, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

Parameters

Node $node
$fieldName
AuthorizationChecker $authorizationChecker
bool $preview

Return Value

array|null

array|null findByNodeAndFieldAndTranslation(Node $node, NodeTypeField $field, Translation $translation, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

Parameters

Node $node
NodeTypeField $field
Translation $translation
AuthorizationChecker $authorizationChecker
bool $preview

Return Value

array|null

array|null findByNodeAndFieldNameAndTranslation(Node $node, $fieldName, Translation $translation, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

Parameters

Node $node
$fieldName
Translation $translation
AuthorizationChecker $authorizationChecker
bool $preview

Return Value

array|null

array findByReverseNodeAndField(Node $node, NodeTypeField $field, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

Parameters

Node $node
NodeTypeField $field
AuthorizationChecker $authorizationChecker
bool $preview

Return Value

array

array findByReverseNodeAndFieldName(Node $node, string $fieldName, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

Parameters

Node $node
string $fieldName
AuthorizationChecker $authorizationChecker
bool $preview

Return Value

array

array|null findByReverseNodeAndFieldAndTranslation(Node $node, NodeTypeField $field, Translation $translation, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

Parameters

Node $node
NodeTypeField $field
Translation $translation
AuthorizationChecker $authorizationChecker
bool $preview

Return Value

array|null

array|null findByReverseNodeAndFieldNameAndTranslation(Node $node, $fieldName, Translation $translation, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

Parameters

Node $node
$fieldName
Translation $translation
AuthorizationChecker $authorizationChecker
bool $preview

Return Value

array|null

array findAllOffspringIdByNode(Node $node)

Parameters

Node $node

Return Value

array

array|null findAllNodeParentsBy(Node $node, array $criteria, array $orderBy = null, integer $limit = null, integer $offset = null, Translation $translation = null, AuthorizationChecker $authorizationChecker = null, bool $preview = false)

Find all node’ parents with criteria and ordering.

Parameters

Node $node
array $criteria
array $orderBy
integer $limit
integer $offset
Translation $translation
AuthorizationChecker $authorizationChecker
bool $preview

Return Value

array|null

array findAllParentsIdByNode(Node $node)

Parameters

Node $node

Return Value

array

array findAvailableTranslationForNode(Node $node)

Parameters

Node $node

Return Value

array

array findUnavailableTranslationForNode(Node $node)

Parameters

Node $node

Return Value

array

array findAvailableTranslationIdForNode(Node $node)

Parameters

Node $node

Return Value

array

array findUnavailableTranslationIdForNode(Node $node)

Parameters

Node $node

Return Value

array