class DeclarationCategoryRepository extends CategoryTranslatableRepository implements AbstractBlockElementRepositoryInterface

Class DeclarationCategoryRepository is injected as empire_declaration_plugin.declaration_category_repository service. DeclarationCategoryRepository is used for crud operation for entity.

Use this class to work with database.

Traits

Trait JQGridTrait
Trait EmpireNestedTreeRepositoryTrait contains methods for work with tree structure. Should be included in repository that extends NestedTreeRepository

Constants

TRANSLATION_WALKER_HINT

DECLARATION_CATEGORY_BLOCKS_RESULT_CACHE

Define key for caching declarations for block elements

ALIAS

Alias for entity

Properties

protected string $defaultLocale from CategoryTranslatableRepository

Methods

setDefaultLocale(string $locale)

Sets default locale

QueryBuilder
getOneOrNullResult(QueryBuilder $qb, string $locale = null, string $hydrationMode = null)

Returns translated one (or null if not found) result for given locale

QueryBuilder
getResult(QueryBuilder $qb, string $locale = null, int $hydrationMode = AbstractQuery::HYDRATE_OBJECT)

Returns translated results for given locale

mixed
getArrayResult(QueryBuilder $qb, string $locale = null)

Returns translated array results for given locale

QueryBuilder
getSingleResult(QueryBuilder $qb, string $locale = null, string $hydrationMode = null)

Returns translated single result for given locale

array
getScalarResult(QueryBuilder $qb, string $locale = null)

Returns translated scalar result for given locale

QueryBuilder
getSingleScalarResult(QueryBuilder $qb, string $locale = null)

Returns translated single scalar result for given locale

save(PrimaryKeyInterface $entity)

Persist new entity to database

remove(mixed $entity)

Remove entity from database

QueryBuilder
getAll()

Find all entities ordered by id descending

QueryBuilder
getByPrimaryKey(PrimaryKeyInterface $entity, mixed $param = null)

Find entity by primary key

mixed
getById(int $id)

Find entity by id

QueryBuilder|array
getGroupFromDB(mixed $array)

Find entities for provided array of entities

EntityManager
getManager()

Singleton

mixed
saveCollection(array $array)

Persist array of new entities

Query
getTranslatedQuery(QueryBuilder $qb, string $locale = null)

Returns translated Doctrine query instance

startTransaction()

Begins transaction over database

commitTransaction()

Commit transaction over database

rollbackTransaction()

Rollback transaction over database

string
getAlias()

No description

jQGridJoinFields(QueryBuilder $qb, JQGridWrapper $jqGridWrapper)

All joins used in select.

jQGridGroupByFields(QueryBuilder $qb, JQGridWrapper $jqGridWrapper)

Should contain group by which jqgrid uses.

array
findAllForJQGRID(int $page, int $offset, array $sortParams, array $additionalParams, JQGridWrapper $jqGridWrapper)

JQGrid function

array
searchForJQGRID(array $searchParams, array $sortParams, bool $isCountSearch = false, array $additionalParams = array(), JQGridWrapper $jqGridWrapper = null)

JQGrid function

array
hasRootCategory()

Find root node

string
getParentAlias()

No description

string
getItemAlias()

No description

array
getAllCategories()

Find all categories(as array)

editFields(DeclarationCategory $category)

Updating existed Declaration category

object
changePosition(DeclarationCategory $category, null|DeclarationCategory $oldParent)

Change position of category

updateNumberOfItemsForVisibleItems(DeclarationCategory $entity)

Query for visible declarations/children nodes and update corresponding fields on category

saveEntity(DeclarationCategory $category)

Persist new entity

object
saveTreeCategory(DeclarationCategory $category)

Persist new declaration category

updateNumberOfKids(DeclarationCategory $entity)

Update number of visible child nodes for provided category

array
getAllTreeCategoriesForDelete(array $ids)

Find all categories that match provided ids

array
getImagesIdsForDelete(array $categoryId)

Function that returns ids of all images that categories 'children' contains

int
deleteTreeCategories(array $objects)

if you want not to delete subcategories use $this->removeFromTree($cat); method

updateNumberOfItemsForArrayForVisibleItems(mixed $array)

Update number of visible child nodes for category that match provided ids

array|string
getCatsForMainFrontEnd(array|null $options = null, string|null $locale = null)

Generate html for frontend

array|string
getCategoryTree(array $options, string|null $locale = null)

Generate html for frontend

string|null
getLanguageForId(int $id)

Find language locale for category that match provided id. NULL on missing category

array
getEntitiesForBlockElementsExtension(array $ids)

Get entities from database by ids Tis method is used to for block elements extension Make sure you order data by ids - ids is array of elements and it is sorted by priority - so add this to select -> ' FIELD('.$this->getAlias().'.id'.', '.implode(', ', $ids).') AS sort_col'); - and order by this field Also make sure you cache this data -> qb->useQueryCache(true)->useResultCache(true, 3600)

array
getEntityNamesForIds(array $ids)

Get id and name (field must be name so change it in select) of entity Used in event for block element edit Make sure you order data by ids - ids is array of elements and it is sorted by priority - so add this to select -> ' FIELD('.$this->getAlias().'.id'.', '.implode(', ', $ids).') AS sort_col'); - and order by this field

deleteResultCaches()

delete all cached results

Details

setDefaultLocale(string $locale)

Sets default locale

Parameters

string $locale

QueryBuilder getOneOrNullResult(QueryBuilder $qb, string $locale = null, string $hydrationMode = null)

Returns translated one (or null if not found) result for given locale

Parameters

QueryBuilder $qb A Doctrine query builder instance
string $locale A locale name
string $hydrationMode A Doctrine results hydration mode

Return Value

QueryBuilder

Exceptions

NonUniqueResultException

QueryBuilder getResult(QueryBuilder $qb, string $locale = null, int $hydrationMode = AbstractQuery::HYDRATE_OBJECT)

Returns translated results for given locale

Parameters

QueryBuilder $qb A Doctrine query builder instance
string $locale A locale name
int $hydrationMode A Doctrine results hydration mode

Return Value

QueryBuilder

mixed getArrayResult(QueryBuilder $qb, string $locale = null)

Returns translated array results for given locale

Parameters

QueryBuilder $qb A Doctrine query builder instance
string $locale A locale name

Return Value

mixed

QueryBuilder getSingleResult(QueryBuilder $qb, string $locale = null, string $hydrationMode = null)

Returns translated single result for given locale

Parameters

QueryBuilder $qb A Doctrine query builder instance
string $locale A locale name
string $hydrationMode A Doctrine results hydration mode

Return Value

QueryBuilder

Exceptions

NoResultException
NonUniqueResultException

array getScalarResult(QueryBuilder $qb, string $locale = null)

Returns translated scalar result for given locale

Parameters

QueryBuilder $qb A Doctrine query builder instance
string $locale A locale name

Return Value

array

QueryBuilder getSingleScalarResult(QueryBuilder $qb, string $locale = null)

Returns translated single scalar result for given locale

Parameters

QueryBuilder $qb A Doctrine query builder instance
string $locale A locale name

Return Value

QueryBuilder

Exceptions

NonUniqueResultException

PrimaryKeyInterface save(PrimaryKeyInterface $entity)

Persist new entity to database

Parameters

PrimaryKeyInterface $entity

Return Value

PrimaryKeyInterface

Exceptions

Exception

remove(mixed $entity)

Remove entity from database

Parameters

mixed $entity

Exceptions

Exception

PrimaryKeyInterface edit(PrimaryKeyInterface $entity)

Merge entity

Parameters

PrimaryKeyInterface $entity

Return Value

PrimaryKeyInterface

Exceptions

Exception

QueryBuilder getAll()

Find all entities ordered by id descending

Return Value

QueryBuilder

QueryBuilder getByPrimaryKey(PrimaryKeyInterface $entity, mixed $param = null)

Find entity by primary key

Parameters

PrimaryKeyInterface $entity
mixed $param

Return Value

QueryBuilder

Exceptions

NoResultException
NonUniqueResultException

mixed getById(int $id)

Find entity by id

Parameters

int $id

Return Value

mixed

Exceptions

NoResultException
NonUniqueResultException

QueryBuilder|array getGroupFromDB(mixed $array)

Find entities for provided array of entities

Parameters

mixed $array

Return Value

QueryBuilder|array

EntityManager getManager()

Singleton

Return Value

EntityManager

mixed saveCollection(array $array)

Persist array of new entities

Parameters

array $array

Return Value

mixed

Exceptions

Exception

protected Query getTranslatedQuery(QueryBuilder $qb, string $locale = null)

Returns translated Doctrine query instance

Parameters

QueryBuilder $qb A Doctrine query builder instance
string $locale A locale name

Return Value

Query

protected startTransaction()

Begins transaction over database

protected commitTransaction()

Commit transaction over database

protected rollbackTransaction()

Rollback transaction over database

at line 49
string getAlias()

Return Value

string

in JQGridTrait at line 27
jQGridJoinFields(QueryBuilder $qb, JQGridWrapper $jqGridWrapper)

All joins used in select.

Override in the repository class if needed. Should do nothing otherwise

Parameters

QueryBuilder $qb
JQGridWrapper $jqGridWrapper

in JQGridTrait at line 42
jQGridGroupByFields(QueryBuilder $qb, JQGridWrapper $jqGridWrapper)

Should contain group by which jqgrid uses.

Override in the repository class if needed. Should do nothing otherwise

Parameters

QueryBuilder $qb
JQGridWrapper $jqGridWrapper

in JQGridTrait at line 61
array findAllForJQGRID(int $page, int $offset, array $sortParams, array $additionalParams, JQGridWrapper $jqGridWrapper)

JQGrid function

Parameters

int $page
int $offset
array $sortParams
array $additionalParams
JQGridWrapper $jqGridWrapper

Return Value

array

in JQGridTrait at line 94
array searchForJQGRID(array $searchParams, array $sortParams, bool $isCountSearch = false, array $additionalParams = array(), JQGridWrapper $jqGridWrapper = null)

JQGrid function

Parameters

array $searchParams
array $sortParams
bool $isCountSearch
array $additionalParams
JQGridWrapper $jqGridWrapper

Return Value

array

array hasRootCategory()

Find root node

Return Value

array

at line 57
string getParentAlias()

Return Value

string Alias for parent category to use in queries

at line 65
string getItemAlias()

Return Value

string Alias for item to use in queries

at line 75
array getAllCategories()

Find all categories(as array)

Return Value

array

at line 91
stdClass editFields(DeclarationCategory $category)

Updating existed Declaration category

Parameters

DeclarationCategory $category

Return Value

stdClass Containing persisted entity, response code, status and message

at line 133
object changePosition(DeclarationCategory $category, null|DeclarationCategory $oldParent)

Change position of category

Parameters

DeclarationCategory $category
null|DeclarationCategory $oldParent

Return Value

object

at line 177
updateNumberOfItemsForVisibleItems(DeclarationCategory $entity)

Query for visible declarations/children nodes and update corresponding fields on category

Parameters

DeclarationCategory $entity

Exceptions

ORMException

at line 212
DeclarationCategory saveEntity(DeclarationCategory $category)

Persist new entity

Parameters

DeclarationCategory $category

Return Value

DeclarationCategory

Exceptions

ORMException
OptimisticLockException

at line 229
object saveTreeCategory(DeclarationCategory $category)

Persist new declaration category

Parameters

DeclarationCategory $category

Return Value

object Containing persisted entity, response code, status and message

Exceptions

Exception

at line 269
DeclarationCategory updateNumberOfKids(DeclarationCategory $entity)

Update number of visible child nodes for provided category

Parameters

DeclarationCategory $entity

Return Value

DeclarationCategory

Exceptions

Exception

at line 302
array getAllTreeCategoriesForDelete(array $ids)

Find all categories that match provided ids

Parameters

array $ids

Return Value

array

at line 321
array getImagesIdsForDelete(array $categoryId)

Function that returns ids of all images that categories 'children' contains

Parameters

array $categoryId

Return Value

array

Exceptions

ORMException

at line 342
int deleteTreeCategories(array $objects)

if you want not to delete subcategories use $this->removeFromTree($cat); method

Parameters

array $objects

Return Value

int

Exceptions

ORMException

at line 374
updateNumberOfItemsForArrayForVisibleItems(mixed $array)

Update number of visible child nodes for category that match provided ids

Parameters

mixed $array

Exceptions

ORMException

at line 412
array|string getCatsForMainFrontEnd(array|null $options = null, string|null $locale = null)

Generate html for frontend

Parameters

array|null $options
string|null $locale

Return Value

array|string

at line 508
array|string getCategoryTree(array $options, string|null $locale = null)

Generate html for frontend

Parameters

array $options
string|null $locale

Return Value

array|string

at line 526
string|null getLanguageForId(int $id)

Find language locale for category that match provided id. NULL on missing category

Parameters

int $id

Return Value

string|null

Exceptions

NonUniqueResultException

at line 547
array getEntitiesForBlockElementsExtension(array $ids)

Get entities from database by ids Tis method is used to for block elements extension Make sure you order data by ids - ids is array of elements and it is sorted by priority - so add this to select -> ' FIELD('.$this->getAlias().'.id'.', '.implode(', ', $ids).') AS sort_col'); - and order by this field Also make sure you cache this data -> qb->useQueryCache(true)->useResultCache(true, 3600)

Parameters

array $ids

Return Value

array

at line 575
array getEntityNamesForIds(array $ids)

Get id and name (field must be name so change it in select) of entity Used in event for block element edit Make sure you order data by ids - ids is array of elements and it is sorted by priority - so add this to select -> ' FIELD('.$this->getAlias().'.id'.', '.implode(', ', $ids).') AS sort_col'); - and order by this field

Parameters

array $ids

Return Value

array

at line 593
deleteResultCaches()

delete all cached results