class BlogCategoryRepository extends CategoryTranslatableRepository implements AbstractBlockElementRepositoryInterface

Class BlogCategoryRepository is injected as alligator.blog_category_repository service. BlogCategoryRepository is used for crud operation for managed 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

ALIAS

Alias for BlogCategory

JOIN_WITH_POSTS_ALIAS

Alias for BlogPost

IMAGE_ALIAS

Alias for Image

BLOG_CATEGORY_BLOCKS_RESULT_CACHE

Key for caching BlogCategory blocks

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()

Alias for BlogCategory

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
getPostAlias()

Alias for BlogPost

object
saveBlogCategory(BlogCategory $blogCategory)

Persist new BlogCategory, returns code 200 if successful edit, otherwise 304

object
editFields(BlogCategory $blogCategory)

Merge BlogCategory

persistRoot(BlogCategory $category)

Persist new BlogCategory as root

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

Change position of node and update visibility of child nodes

updateNumberOfPostsForVisibleItems(BlogCategory $entity)

Update number of visible items, including child nodes, for specific BlogCategory

updateNumberOfPostsForArrayForVisibleItems(array $array)

Update number of visible items, including child nodes, for array of blog category

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

Find blog category tree structure. If $frontend param is TRUE, root node is not included

array
getAllBlogCategoriesForDelete(array $blogCategoriesId)

Find all BlogCategory for provided array of ids

array
getImagesIdsForDelete(array $categoryId)

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

int
deleteBlogCategories(array $blogCategories)

Removes BlogCategory from provided array. If you want not to delete subcategories use $this->removeFromTree($cat); method

mixed
getNewsFromDB(int $itemNumber, string|null $locale = null)

Find BlogCategory with related BlogPosts

array
getCategoriesSlugs()

Find all BlogCategory slugs

array
getEntitiesForBlockElementsExtension(array $params)

Find BlogCategory with related BlogPost for provided array of ids

mixed
findCategoryBySlug(string $slug, string|null $locale = null)

Find BlogCategory with its children from provided slug

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 67
string getAlias()

Alias for BlogCategory

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 77
string getPostAlias()

Alias for BlogPost

Return Value

string

at line 88
object saveBlogCategory(BlogCategory $blogCategory)

Persist new BlogCategory, returns code 200 if successful edit, otherwise 304

Parameters

BlogCategory $blogCategory

Return Value

object Returns code 200 if successful edit, otherwise 304

at line 114
object editFields(BlogCategory $blogCategory)

Merge BlogCategory

Parameters

BlogCategory $blogCategory

Return Value

object

at line 142
persistRoot(BlogCategory $category)

Persist new BlogCategory as root

Parameters

BlogCategory $category

at line 154
object changePosition(BlogCategory $category, BlogCategory|null $oldParent)

Change position of node and update visibility of child nodes

Parameters

BlogCategory $category
BlogCategory|null $oldParent

Return Value

object

at line 185
updateNumberOfPostsForVisibleItems(BlogCategory $entity)

Update number of visible items, including child nodes, for specific BlogCategory

Parameters

BlogCategory $entity

Exceptions

ORMException

at line 209
updateNumberOfPostsForArrayForVisibleItems(array $array)

Update number of visible items, including child nodes, for array of blog category

Parameters

array $array

Exceptions

ORMException

See also

BlogCategory

at line 247
array|string getCategoryTree(array $options, string|null $locale = null, bool $frontend = false)

Find blog category tree structure. If $frontend param is TRUE, root node is not included

Parameters

array $options
string|null $locale
bool $frontend

Return Value

array|string

See also

BlogCategory

at line 281
array getAllBlogCategoriesForDelete(array $blogCategoriesId)

Find all BlogCategory for provided array of ids

Parameters

array $blogCategoriesId

Return Value

array

See also

BlogCategory

at line 301
array getImagesIdsForDelete(array $categoryId)

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

Parameters

array $categoryId

Return Value

array

at line 321
int deleteBlogCategories(array $blogCategories)

Removes BlogCategory from provided array. If you want not to delete subcategories use $this->removeFromTree($cat); method

Parameters

array $blogCategories

Return Value

int

Exceptions

ORMException

at line 355
mixed getNewsFromDB(int $itemNumber, string|null $locale = null)

Find BlogCategory with related BlogPosts

Parameters

int $itemNumber
string|null $locale

Return Value

mixed

See also

BlogCategory
BlogPost

at line 381
array getCategoriesSlugs()

Find all BlogCategory slugs

Return Value

array

at line 400
array getEntitiesForBlockElementsExtension(array $params)

Find BlogCategory with related BlogPost for provided array of ids

Parameters

array $params

Return Value

array

See also

BlogCategory
BlogPost

at line 427
mixed findCategoryBySlug(string $slug, string|null $locale = null)

Find BlogCategory with its children from provided slug

Parameters

string $slug
string|null $locale

Return Value

mixed

Exceptions

NoResultException
NonUniqueResultException

at line 452
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 470
deleteResultCaches()

Delete all cached results