class BlogPostRepository extends TranslatableRepository implements AbstractBlockElementRepositoryInterface

Class BlogPostRepository is injected as alligator.blog_post_repository service. BlogPostRepository is used for crud operation for managed entity.

Use this class to work with database.

Traits

Trait JQGridTrait

Constants

TRANSLATION_WALKER_HINT

ALIAS

Alias for blog post

CATEGORY_ALIAS

Alias for blog post category entity

BLOG_POST_BLOCKS_RESULT_CACHE

Key for caching blog post blocks

Properties

protected string $defaultLocale from TranslatableRepository

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

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

Returns translated results for given locale

array
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

remove(mixed $entity)

Remove entity

bool
removeArray(array $arrayOfEntities)

Remove entities provided as array

edit(PrimaryKeyInterface $entity)

Sets default locale to entity and merge

mixed
getAll()

Find all entities depending on locale

mixed
getByPrimaryKey(PrimaryKeyInterface $entity)

Find entity by primary key

QueryBuilder
getById(int $id)

Find entity by id

QueryBuilder|array
getGroupFromDB(array $array)

Find group od entities

EntityManager
getManager()

Singleton

mixed
saveCollection(array $array)

Persist collection

array
getLanguagesForIds(array $ids)

Find all locales for custom ids of 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 blog post

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

string
getParentAlias()

Alias for current blog post parent

string
getImageAlias()

Alias for image

string
getCommentAlias()

Alias for blog comment

string
getBlogCategoryAlias()

Alias for blog category

string
getTableName()

Return table name of blog post entity

object
saveBlogPost(BlogPost $blogPost)

Persist new blog post

array
findAllCustomForFrontend(int $page, int $offset)

Find all blog posts using pagination

array
countPostsPagination()

Count all visible blog posts

array
countPostsPaginationByCategory(int $id, int|null $lft = null, int|null $rgt = null)

Count all visible blog posts for blog category

array
findAllCustomForFrontendByCategory(int $page, int $offset, int $categoryId, int|null $lft = null, int|null $rgt = null)

Find all blog post for blog category using pagination

mixed
editBlogPost(BlogPost $blogPost, bool $isNew)

Merge blog post

array
findOneBySlugCustomForSingleBlog(mixed $slug, string|null $locale = null)

Find blog post by slug

mixed
findThreeByIdCustomForSingleBlog(int $blogPostId, string $locale)

Find previous and next blog posts

mixed
findPrevNextCustomForIds(int $prevId, int $nextId)

Find blog posts for provided ids

array
getAllBlogPosts(array $blogPostIds)

Find all blog posts for provided array of ids

mixed
deleteBlogPosts(array $entities)

Remove blog post from array

array
getLastNPosts(int $maxResult, string|null $locale = null)

Find $maxResult number of last blog posts

array
getPostsSlugs()

Find all blog post slugs

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

array
getIsotopeCategories(int $id, string $locale, object $additionalData)

Find all blog posts for provided blog category parent id

array
findAllPosts()

Find all blog posts

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

mixed 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

mixed

array 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

array

in TranslatableRepository at line 102
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

in TranslatableRepository at line 115
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

in TranslatableRepository at line 130
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

in TranslatableRepository at line 142
PrimaryKeyInterface save(PrimaryKeyInterface $entity)

Parameters

PrimaryKeyInterface $entity

Return Value

PrimaryKeyInterface

Exceptions

Exception

in TranslatableRepository at line 172
remove(mixed $entity)

Remove entity

Parameters

mixed $entity

Exceptions

Exception

in TranslatableRepository at line 200
bool removeArray(array $arrayOfEntities)

Remove entities provided as array

Parameters

array $arrayOfEntities

Return Value

bool

Exceptions

Exception

in TranslatableRepository at line 228
PrimaryKeyInterface edit(PrimaryKeyInterface $entity)

Sets default locale to entity and merge

Parameters

PrimaryKeyInterface $entity

Return Value

PrimaryKeyInterface

Exceptions

Exception

in TranslatableRepository at line 253
mixed getAll()

Find all entities depending on locale

Return Value

mixed

in TranslatableRepository at line 270
mixed getByPrimaryKey(PrimaryKeyInterface $entity)

Find entity by primary key

Parameters

PrimaryKeyInterface $entity

Return Value

mixed

Exceptions

NoResultException
NonUniqueResultException

in TranslatableRepository at line 291
QueryBuilder getById(int $id)

Find entity by id

Parameters

int $id

Return Value

QueryBuilder

Exceptions

NoResultException
NonUniqueResultException

in TranslatableRepository at line 307
QueryBuilder|array getGroupFromDB(array $array)

Find group od entities

Parameters

array $array Objects

Return Value

QueryBuilder|array

in TranslatableRepository at line 332
EntityManager getManager()

Singleton

Return Value

EntityManager

in TranslatableRepository at line 352
mixed saveCollection(array $array)

Persist collection

Parameters

array $array

Return Value

mixed

Exceptions

Exception

in TranslatableRepository at line 379
array getLanguagesForIds(array $ids)

Find all locales for custom ids of entities

Parameters

array $ids

Return Value

array

in TranslatableRepository at line 396
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

in TranslatableRepository at line 404
protected startTransaction()

Begins transaction over database

in TranslatableRepository at line 412
protected commitTransaction()

Commit transaction over database

in TranslatableRepository at line 420
protected rollbackTransaction()

Rollback transaction over database

at line 62
string getAlias()

Alias for blog post

Return Value

string

See also

BlogPost

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

at line 73
string getParentAlias()

Alias for current blog post parent

Return Value

string

See also

BlogPost

at line 85
string getImageAlias()

Alias for image

Return Value

string

See also

Image

at line 96
string getCommentAlias()

Alias for blog comment

Return Value

string

See also

BlogComment

at line 107
string getBlogCategoryAlias()

Alias for blog category

Return Value

string

See also

BlogCategory

at line 118
string getTableName()

Return table name of blog post entity

Return Value

string

See also

BlogPost

at line 129
object saveBlogPost(BlogPost $blogPost)

Persist new blog post

Parameters

BlogPost $blogPost

Return Value

object

at line 151
array findAllCustomForFrontend(int $page, int $offset)

Find all blog posts using pagination

Parameters

int $page
int $offset

Return Value

array

at line 187
array countPostsPagination()

Count all visible blog posts

Return Value

array

See also

BlogPost

at line 207
array countPostsPaginationByCategory(int $id, int|null $lft = null, int|null $rgt = null)

Count all visible blog posts for blog category

Parameters

int $id
int|null $lft
int|null $rgt

Return Value

array

See also

BlogPost
BlogCategory

at line 240
array findAllCustomForFrontendByCategory(int $page, int $offset, int $categoryId, int|null $lft = null, int|null $rgt = null)

Find all blog post for blog category using pagination

Parameters

int $page
int $offset
int $categoryId
int|null $lft
int|null $rgt

Return Value

array

See also

BlogPost
BlogCategory

at line 287
mixed editBlogPost(BlogPost $blogPost, bool $isNew)

Merge blog post

Parameters

BlogPost $blogPost
bool $isNew

Return Value

mixed

at line 312
array findOneBySlugCustomForSingleBlog(mixed $slug, string|null $locale = null)

Find blog post by slug

Parameters

mixed $slug
string|null $locale

Return Value

array

at line 350
mixed findThreeByIdCustomForSingleBlog(int $blogPostId, string $locale)

Find previous and next blog posts

Parameters

int $blogPostId
string $locale

Return Value

mixed

See also

BlogPost

at line 377
mixed findPrevNextCustomForIds(int $prevId, int $nextId)

Find blog posts for provided ids

Parameters

int $prevId
int $nextId

Return Value

mixed

Exceptions

NoResultException
NonUniqueResultException

See also

BlogPost

at line 414
array getAllBlogPosts(array $blogPostIds)

Find all blog posts for provided array of ids

Parameters

array $blogPostIds

Return Value

array

See also

BlogPost

at line 440
mixed deleteBlogPosts(array $entities)

Remove blog post from array

Parameters

array $entities

Return Value

mixed

Exceptions

ORMException
OptimisticLockException

See also

BlogPost

at line 461
array getLastNPosts(int $maxResult, string|null $locale = null)

Find $maxResult number of last blog posts

Parameters

int $maxResult
string|null $locale

Return Value

array

See also

BlogPost

at line 498
array getPostsSlugs()

Find all blog post slugs

Return Value

array

See also

BlogPost

at line 511
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 554
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 572
deleteResultCaches()

Delete all cached results

at line 588
array getIsotopeCategories(int $id, string $locale, object $additionalData)

Find all blog posts for provided blog category parent id

Parameters

int $id
string $locale
object $additionalData

Return Value

array

See also

BlogPost
BlogCategory

at line 620
array findAllPosts()

Find all blog posts

Return Value

array

See also

BlogPost