\Content\Model\EntityContent

Represents a single "content" within "contents" table.

Summary

Methods
Properties
Constants
parentLocale()
hasTranslation()
setDefaults()
isAccessible()
isAccessible()
$id
$content_type_id
$translation_for
$promote
$sticky
$comment_status
$status
$created_by
$modified_by
$content_type_slug
$slug
$title
$description
$language
$type
$url
$roles
$author
No constants found
_getType()
_getUrl()
_getAuthor()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$id

$id : integer

Type

integer

$content_type_id

$content_type_id : integer

Type

integer

$translation_for

$translation_for : integer

Type

integer

$promote

$promote : integer

Type

integer

$sticky

$sticky : integer

Type

integer

$comment_status

$comment_status : integer

Type

integer

$status

$status : integer

Type

integer

$created_by

$created_by : integer

Type

integer

$modified_by

$modified_by : integer

Type

integer

$content_type_slug

$content_type_slug : string

Type

string

$slug

$slug : string

Type

string

$title

$title : string

Type

string

$description

$description : string

Type

string

$language

$language : string

Type

string

$type

$type : string

Type

string

$url

$url : string

Type

string

$roles

$roles : array

Type

array

$author

$author : \User\Model\Entity\User

Type

\User\Model\Entity\User

Methods

parentLocale()

parentLocale() : mixed

Gets the parent content for which this content is a translation of.

Returns

mixed —

The parent content if exists, null otherwise

hasTranslation()

hasTranslation(string|null $locale) : mixed

Find if this content has a translation to the given locale code.

Parameters

string|null $locale

Locale code for which look for translations, if not given current language code will be used

Throws

\Content\Model\Entity\Cake\Error\FatalErrorException

When if any of the required properties is not present in this entity

Returns

mixed —

Translation entity if exists, null otherwise

setDefaults()

setDefaults(boolean|\Content\Model\Entity\ContentType $type) : void

Set defaults content settings based on parent content type.

You can provide a ContentType entity to fetch defaults values. By default if none is provided it automatically fetches the information from the corresponding Content Type.

Parameters

boolean|\Content\Model\Entity\ContentType $type

False for auto fetch or a ContentType entity to extract information from

Throws

\Content\Model\Entity\Cake\Error\FatalErrorException

When content type was not found for this content content.

isAccessible()

isAccessible(array|null $roles) : boolean

Whether this entity can be accessed by current user.

Parameters

array|null $roles

Array list of roles to checks against to, or NULL to automatically use entity's "roles" property

Returns

boolean —

False if user has no permissions to see this entity due to role restrictions, true otherwise

isAccessible()

isAccessible(array|null $roles) : boolean

Parameters

array|null $roles

Returns

boolean

_getType()

_getType() : string

Gets content type.

As Content Types are not dependent of Contents (deleting a content_type won't remove all contents of that type). Some times we found contents without content_type, in that cases, if no content_type is found --unknow-- will be returned.

Returns

string

_getUrl()

_getUrl() : string

Gets content's details page URL.

Content's details URL's follows the syntax below:

http://example.com/[content-type-slug]/[content-slug].html

Example:

http://example.com/blog-article/my-first-article.html

Returns

string

_getAuthor()

_getAuthor() : \User\Model\Entity\User

Gets content's author as an User entity.

Returns

\User\Model\Entity\User