\App\Site\ModelsNews

News Model

Summary

Methods
Properties
Constants
exposeToIndexer()
getRewrite()
getFrontendUrl()
postPersist()
preRemove()
getTranslations()
getPageTitle()
getRewritePrefix()
getOwner()
getWebsite()
__construct()
hydrateStatementResult()
select()
all()
totalNum()
paginate()
paginateByStatement()
where()
defaultTableName()
fill()
isLoaded()
isNew()
checkLoaded()
reset()
load()
loadMultiple()
loadByCondition()
loadMultipleByCondition()
new()
loadBy()
postLoad()
__get()
__set()
__isset()
__unset()
__call()
getData()
getIterator()
offsetSet()
offsetExists()
offsetUnset()
offsetGet()
current()
key()
next()
rewind()
valid()
save()
persist()
prePersist()
delete()
remove()
postRemove()
setIsFirstSave()
isFirstSave()
getDbRow()
setDbRow()
setTableName()
getChangedData()
getTranslator()
getContainer()
getApp()
getLog()
getTemplates()
getDebugbar()
getDb()
getPdo()
getSchema()
getEventManager()
getWebRouter()
getCrudRouter()
getRouters()
getUtils()
getSiteData()
getAssets()
getGuzzle()
getImagine()
getMailer()
getSesMailer()
getSmtpMailer()
getCache()
getHtmlRenderer()
getIcons()
getElasticsearch()
getEnv()
getRequest()
getAppRouteInfo()
getAppWebsite()
requestUrl()
getDate()
getId()
getWebsiteId()
getUrl()
getLocale()
getTitle()
getContent()
getUserId()
getCreatedAt()
getUpdatedAt()
setId()
setWebsiteId()
setUrl()
setLocale()
setTitle()
setContent()
setDate()
setUserId()
setCreatedAt()
setUpdatedAt()
$table_name
$translators
ITEMS_PER_PAGE
getModelName()
getTableName()
getModelBasicWhere()
setOriginalData()
getOriginalData()
getService()
$rewriteObj
$websiteModel
$db_row
$is_first_save
$loadedObjects
$container
N/A
checkDbName()
$original_data
N/A

Constants

ITEMS_PER_PAGE

ITEMS_PER_PAGE = 50

Properties

$table_name

$table_name : string

Type

string — table name

$translators

$translators : array

Type

array — translators

$rewriteObj

$rewriteObj : \App\Site\Models\Rewrite|null

Type

Rewrite|null — rewrite object

$websiteModel

$websiteModel : \App\Site\Models\Website

Type

Website

$db_row

$db_row : \LessQL\Row

Type

\LessQL\Row — database row

$is_first_save

$is_first_save : bool

Type

bool — first save flag

$loadedObjects

$loadedObjects : array

Type

array — objects cache

$container

$container : \Psr\Container\ContainerInterface

Type

\Psr\Container\ContainerInterface — container

$original_data

$original_data : array|null

Type

array|null — original model data

Methods

exposeToIndexer()

exposeToIndexer() : string[]

{@inheritdocs}

Returns

string[] —

getRewrite()

getRewrite() : \App\Site\Models\Rewrite

gets object rewrite model

Throws

\Exception

Returns

\App\Site\Models\Rewrite —

getFrontendUrl()

getFrontendUrl() : string

gets frontend url for object

Throws

\Exception

Returns

string —

postPersist()

postPersist() : self

post persist hook

Returns

self —

preRemove()

preRemove() : self

pre remove hook

Returns

self —

getTranslations()

getTranslations() : array

returns object translations urls

Throws

\Exception

Returns

array —

getPageTitle()

getPageTitle() : string

return page title

Returns

string —

getRewritePrefix()

getRewritePrefix() : string

{@inheritdocs}

Returns

string —

getOwner()

getOwner() : \App\Site\Models\User

gets owner

Throws

\DI\DependencyException
\DI\NotFoundException

Returns

\App\Site\Models\User —

getWebsite()

getWebsite() : \App\Site\Models\Website

gets website

Throws

\DI\DependencyException
\DI\NotFoundException

Returns

\App\Site\Models\Website —

__construct()

__construct(\Psr\Container\ContainerInterface  $container) : mixed

constructor

Parameters

\Psr\Container\ContainerInterface $container

Returns

mixed —

hydrateStatementResult()

hydrateStatementResult(\Psr\Container\ContainerInterface  $container, \LessQL\Result  $stmt) : array

returns an array of models, starting from a statement Result

Parameters

\Psr\Container\ContainerInterface $container
\LessQL\Result $stmt

Throws

\DI\DependencyException
\DI\NotFoundException

Returns

array —

select()

select(\Psr\Container\ContainerInterface  $container, array  $options = []) : \PDOStatement

basic select statement

Parameters

\Psr\Container\ContainerInterface $container
array $options

Returns

\PDOStatement —

all()

all(\Psr\Container\ContainerInterface  $container, array  $condition = [], array  $order = []) : array

returns all found items

Parameters

\Psr\Container\ContainerInterface $container
array $condition
array $order

Throws

\DI\DependencyException
\DI\NotFoundException

Returns

array —

totalNum()

totalNum(\Psr\Container\ContainerInterface  $container, array  $condition = []) : int

gets total number of elements

Parameters

\Psr\Container\ContainerInterface $container
array $condition

Returns

int —

paginate()

paginate(\Psr\Container\ContainerInterface  $container, \Symfony\Component\HttpFoundation\Request  $request, int  $page_size = self::ITEMS_PER_PAGE, array  $condition = [], array  $order = []) : array

return subset of found items (useful for paginate)

Parameters

\Psr\Container\ContainerInterface $container
\Symfony\Component\HttpFoundation\Request $request
int $page_size
array $condition
array $order

Throws

\DI\DependencyException
\DI\NotFoundException

Returns

array —

paginateByStatement()

paginateByStatement(\Psr\Container\ContainerInterface  $container, \Symfony\Component\HttpFoundation\Request  $request, \LessQL\Result  $stmt, int  $page_size = self::ITEMS_PER_PAGE) : array

return subset of found items (useful for paginate)

Parameters

\Psr\Container\ContainerInterface $container
\Symfony\Component\HttpFoundation\Request $request
\LessQL\Result $stmt
int $page_size

Throws

\DI\DependencyException
\DI\NotFoundException

Returns

array —

where()

where(\Psr\Container\ContainerInterface  $container, array|string  $condition, array  $order = []) : array

finds elements

Parameters

\Psr\Container\ContainerInterface $container
array|string $condition
array $order

Throws

\DI\DependencyException
\DI\NotFoundException

Returns

array —

defaultTableName()

defaultTableName() : string

gets model table name

Returns

string —

fill()

fill(int|\LessQL\Row  $id) : self

fills empty model with data

Parameters

int|\LessQL\Row $id

Throws

\App\Base\Exceptions\InvalidValueException
\Degami\Basics\Exceptions\BasicException

Returns

self —

isLoaded()

isLoaded() : bool

checks if model is loaded

Returns

bool —

isNew()

isNew() : bool

checks if model is new

Returns

bool —

checkLoaded()

checkLoaded() : self

ensures model is loaded

Throws

\Exception

Returns

self —

reset()

reset() : self

resets model

Throws

\Degami\Basics\Exceptions\BasicException

Returns

self —

load()

load(\Psr\Container\ContainerInterface  $container, int  $id, bool  $reset = false) : self

loads model by id

Parameters

\Psr\Container\ContainerInterface $container
int $id
bool $reset

Returns

self —

loadMultiple()

loadMultiple(\Psr\Container\ContainerInterface  $container, array  $ids, bool  $reset = false) : array

loads multiple models by id

Parameters

\Psr\Container\ContainerInterface $container
array $ids
bool $reset

Throws

\DI\DependencyException
\DI\NotFoundException

Returns

array —

loadByCondition()

loadByCondition(\Psr\Container\ContainerInterface  $container, array  $condition) : self|null

loads model by condition

Parameters

\Psr\Container\ContainerInterface $container
array $condition

Throws

\Degami\Basics\Exceptions\BasicException
\DI\DependencyException
\DI\NotFoundException

Returns

self|null —

loadMultipleByCondition()

loadMultipleByCondition(\Psr\Container\ContainerInterface  $container, array  $condition, bool  $reset = false) : array

loads multiple models by condition

Parameters

\Psr\Container\ContainerInterface $container
array $condition
bool $reset

Throws

\DI\DependencyException
\DI\NotFoundException

Returns

array —

new()

new(\Psr\Container\ContainerInterface  $container, array  $initial_data = []) : static

gets new empty model

Parameters

\Psr\Container\ContainerInterface $container
array $initial_data

Throws

\App\Base\Exceptions\InvalidValueException
\Degami\Basics\Exceptions\BasicException

Returns

static —

loadBy()

loadBy(\Psr\Container\ContainerInterface  $container, string  $field, mixed  $value) : self

loads model by field - value pair

Parameters

\Psr\Container\ContainerInterface $container
string $field
mixed $value

Throws

\Degami\Basics\Exceptions\BasicException
\DI\DependencyException
\DI\NotFoundException

Returns

self —

postLoad()

postLoad() : self

post load hook

Returns

self —

__get()

__get( $key) : mixed

{@inheritdocs}

Parameters

$key

Returns

mixed —

__set()

__set( $key,  $value) : \App\Base\Abstracts\Models\BaseModel

{@inheritdocs}

Parameters

$key
$value

Returns

\App\Base\Abstracts\Models\BaseModel —

__isset()

__isset( $name) : bool

{@inheritdocs}

Parameters

$name

Returns

bool —

__unset()

__unset( $name) : mixed

{@inheritdocs}

Parameters

$name

Returns

mixed —

__call()

__call(string  $name, mixed  $arguments) : mixed

{@inheritdocs}

Parameters

string $name
mixed $arguments

Throws

\App\Base\Exceptions\InvalidValueException

Returns

mixed —

getData()

getData(null  $column = null) : mixed

gets model's data

Parameters

null $column

Returns

mixed —

getIterator()

getIterator() : mixed

{@inheritdocs}

Returns

mixed —

offsetSet()

offsetSet( $offset,  $value) : \App\Base\Abstracts\Models\BaseModel

{@inheritdocs}

Parameters

$offset
$value

Returns

\App\Base\Abstracts\Models\BaseModel —

offsetExists()

offsetExists( $offset) : bool

{@inheritdocs}

Parameters

$offset

Returns

bool —

offsetUnset()

offsetUnset( $offset) : mixed

{@inheritdocs}

Parameters

$offset

Returns

mixed —

offsetGet()

offsetGet( $offset) : mixed

{@inheritdocs}

Parameters

$offset

Returns

mixed —

current()

current() : mixed

{@inheritdocs}

Returns

mixed —

key()

key() : mixed

{@inheritdocs}

Returns

mixed —

next()

next() : mixed

{@inheritdocs}

Returns

mixed —

rewind()

rewind() : mixed

{@inheritdocs}

Returns

mixed —

valid()

valid() : mixed

{@inheritdocs}

Returns

mixed —

save()

save() : mixed

saves model on db

Returns

mixed —

persist()

persist() : self

saves model on db

Throws

\Degami\Basics\Exceptions\BasicException

Returns

self —

prePersist()

prePersist() : self

pre persist hook

Returns

self —

delete()

delete() : mixed

removes model from db

Returns

mixed —

remove()

remove() : self

removes model from db

Throws

\Degami\Basics\Exceptions\BasicException

Returns

self —

postRemove()

postRemove() : self

post remove hook

Returns

self —

setIsFirstSave()

setIsFirstSave( $is_first_save) : $this

sets is first save flag

Parameters

$is_first_save

Returns

$this —

isFirstSave()

isFirstSave() : bool

is first save flag

Returns

bool —

getDbRow()

getDbRow() : \LessQL\Row

Returns

\LessQL\Row —

database row

setDbRow()

setDbRow(mixed  $db_row) : self

Parameters

mixed $db_row

Returns

self —

setTableName()

setTableName(mixed  $table_name) : self

Parameters

mixed $table_name

Returns

self —

getChangedData()

getChangedData() : array|null

gets model's changed data

Returns

array|null —

getTranslator()

getTranslator(string|null  $locale_code = null) : \Fisharebest\Localization\Translator

gets translator

Parameters

string|null $locale_code

Throws

\DI\DependencyException
\DI\NotFoundException

Returns

\Fisharebest\Localization\Translator —

getContainer()

getContainer() : \Psr\Container\ContainerInterface

gets container object

Returns

\Psr\Container\ContainerInterface —

getApp()

getApp() : \App\App

gets app object

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\App\App —

getLog()

getLog() : \Monolog\Logger

gets log object

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\Monolog\Logger —

getTemplates()

getTemplates() : \League\Plates\Engine

gets plates engine object

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\League\Plates\Engine —

getDebugbar()

getDebugbar() : \DebugBar\StandardDebugBar

gets debugbar object

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\DebugBar\StandardDebugBar —

getDb()

getDb() : \LessQL\Database

gets db object

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\LessQL\Database —

getPdo()

getPdo() : \PDO

gets PDO object

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\PDO —

getSchema()

getSchema() : \Degami\SqlSchema\Schema

gets schema object

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\Degami\SqlSchema\Schema —

getEventManager()

getEventManager() : \Gplanchat\EventManager\SharedEventEmitter

gets events manager service

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\Gplanchat\EventManager\SharedEventEmitter —

getWebRouter()

getWebRouter() : \App\Site\Routing\Web

gets routing service

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\App\Site\Routing\Web —

getCrudRouter()

getCrudRouter() : \App\Site\Routing\Crud

gets crud service

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\App\Site\Routing\Crud —

getRouters()

getRouters() : array

gets routers

Throws

\Degami\Basics\Exceptions\BasicException

Returns

array —

getUtils()

getUtils() : \App\Base\Tools\Utils\Globals

gets global utils service

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\App\Base\Tools\Utils\Globals —

getSiteData()

getSiteData() : \App\Base\Tools\Utils\SiteData

gets site data service

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\App\Base\Tools\Utils\SiteData —

getAssets()

getAssets() : \App\Base\Tools\Assets\Manager

gets assets manager

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\App\Base\Tools\Assets\Manager —

getGuzzle()

getGuzzle() : \GuzzleHttp\Client

gets guzzle service

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\GuzzleHttp\Client —

getImagine()

getImagine() : \Imagine\Gd\Imagine

gets imagine service

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\Imagine\Gd\Imagine —

getMailer()

getMailer() : \App\Base\Tools\Utils\Mailer

gets mailer service

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\App\Base\Tools\Utils\Mailer —

getSesMailer()

getSesMailer() : \Aws\Ses\SesClient

gets SES mailer service

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\Aws\Ses\SesClient —

getSmtpMailer()

getSmtpMailer() : \Swift_Mailer

gets SMTP mailer service

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\Swift_Mailer —

getCache()

getCache() : \App\Base\Tools\Cache\Manager

get cache manager

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\App\Base\Tools\Cache\Manager —

getHtmlRenderer()

getHtmlRenderer() : \App\Base\Tools\Utils\HtmlPartsRenderer

gets html renderer service

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\App\Base\Tools\Utils\HtmlPartsRenderer —

getIcons()

getIcons() : \Feather\Icons

gets icons service

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\Feather\Icons —

getElasticsearch()

getElasticsearch() : \ElasticSearch\Client

gets elasticsearch service

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\ElasticSearch\Client —

getEnv()

getEnv(string  $variable, mixed  $default = null) : mixed

gets env variable

Parameters

string $variable
mixed $default

Throws

\Degami\Basics\Exceptions\BasicException

Returns

mixed —

getRequest()

getRequest() : \Symfony\Component\HttpFoundation\Request

gets current request object

Throws

\Degami\Basics\Exceptions\BasicException

Returns

\Symfony\Component\HttpFoundation\Request —

getAppRouteInfo()

getAppRouteInfo() : \App\Site\Routing\RouteInfo|null

gets route info

Returns

\App\Site\Routing\RouteInfo|null —

getAppWebsite()

getAppWebsite() : \App\Site\Models\Website|null

gets current website

Returns

\App\Site\Models\Website|null —

requestUrl()

requestUrl(string  $url, string  $method = 'GET', array  $options = []) : string|bool

executes an http request

Parameters

string $url
string $method
array $options

Throws

\Exception
\GuzzleHttp\Exception\GuzzleException

Returns

string|bool —

getDate()

getDate() : string

gets formatted Date

Throws

\Exception

Returns

string —

getId()

getId() 

Returns

getWebsiteId()

getWebsiteId() 

Returns

getUrl()

getUrl() 

Returns

getLocale()

getLocale() 

Returns

getTitle()

getTitle() 

Returns

getContent()

getContent() 

Returns

getUserId()

getUserId() 

Returns

getCreatedAt()

getCreatedAt() 

Returns

getUpdatedAt()

getUpdatedAt() 

Returns

setId()

setId(int  $id) 

Parameters

int $id

Returns

setWebsiteId()

setWebsiteId(int  $website_id) 

Parameters

int $website_id

Returns

setUrl()

setUrl(string  $url) 

Parameters

string $url

Returns

setLocale()

setLocale(string  $locale) 

Parameters

string $locale

Returns

setTitle()

setTitle(string  $title) 

Parameters

string $title

Returns

setContent()

setContent(string  $content) 

Parameters

string $content

Returns

setDate()

setDate(\DateTime  $date) 

Parameters

\DateTime $date

Returns

setUserId()

setUserId(int  $user_id) 

Parameters

int $user_id

Returns

setCreatedAt()

setCreatedAt(\DateTime  $created_at) 

Parameters

\DateTime $created_at

Returns

setUpdatedAt()

setUpdatedAt(\DateTime  $updated_at) 

Parameters

\DateTime $updated_at

Returns

getModelName()

getModelName() : string

gets object model name

Returns

string —

getTableName()

getTableName() : string

gets table name

Returns

string —

getModelBasicWhere()

getModelBasicWhere(\Psr\Container\ContainerInterface  $container, array  $condition = [], array  $order = []) : \LessQL\Result

gets basic where statement for model

Parameters

\Psr\Container\ContainerInterface $container
array $condition
array $order

Returns

\LessQL\Result —

setOriginalData()

setOriginalData(array|null  $original_data) : $this

sets model's original data

Parameters

array|null $original_data

Returns

$this —

getOriginalData()

getOriginalData(null  $key = null) : mixed

gets model's original data

Parameters

null $key

Returns

mixed —

getService()

getService(string  $service_key) : mixed

gets registered service

Parameters

string $service_key

Throws

\Degami\Basics\Exceptions\BasicException

Returns

mixed —

checkDbName()

checkDbName(\LessQL\Row  $db_row) : self

checks if Row object is from correct table

Parameters

\LessQL\Row $db_row

Throws

\App\Base\Exceptions\InvalidValueException

Returns

self —