Properties

$revisionEnabled

$revisionEnabled : boolean

Type

boolean

$username

$username : string

The username should be unique and mandatory.

It is also used as login name and main identifier (key).

Type

string

$password

$password : string

The password is stored encrypted in the (database) storage.

Type

string

$email

$email : string

Type

string

$active

$active : boolean

Objects are active by default

Type

boolean

$roles

$roles : array<mixed,string>

Type

array<mixed,string>

$lastLoginDate

$lastLoginDate : \DateTime|null

The date of the latest (successful) login

Type

\DateTime|null

$lastLoginIp

$lastLoginIp : string

Type

string

$lastPasswordDate

$lastPasswordDate : \DateTime|null

The date of the latest password change

Type

\DateTime|null

$lastPasswordIp

$lastPasswordIp : string

Type

string

$loginToken

$loginToken : string

If the login token is set (not empty), then the user should be prompted to reset his password after login / enter the token to continue

Type

string

$position

$position : integer

The position is used for ordering lists

Type

integer

$created

$created : \DateTime

Object creation date (set automatically on save)

Type

\DateTime

$createdBy

$createdBy : mixed

Type

mixed

$lastModified

$lastModified : \DateTime

Object last modified date (set automatically on save and update)

Type

\DateTime

$lastModifiedBy

$lastModifiedBy : mixed

Type

mixed

$modelFactory

$modelFactory : \Charcoal\Factory\FactoryInterface

Type

\Charcoal\Factory\FactoryInterface

$objectRevisionClass

$objectRevisionClass : string

The class name of the object revision model.

Must be a fully-qualified PHP namespace and an implementation of \Charcoal\Object\ObjectRevisionInterface. Used by the model factory.

Type

string

Methods

key()

key() : string

IndexableTrait > key()

Returns

string

setUsername()

setUsername(string  $username) : \Charcoal\User\User

Force a lowercase username

Parameters

string $username

The username (also the login name).

Throws

\InvalidArgumentException

If the username is not a string.

Returns

\Charcoal\User\User —

Chainable

username()

username() : string

The username is also used as login name and main identifier (key).

Returns

string

setEmail()

setEmail(string  $email) : \Charcoal\User\User

Parameters

string $email

The user email.

Throws

\InvalidArgumentException

If the email is not a string.

Returns

\Charcoal\User\User —

Chainable

email()

email() : string

Returns

string

setPassword()

setPassword(string|null  $password) : \Charcoal\User\UserInterface

Parameters

string|null $password

The user password. Encrypted in storage.

Throws

\InvalidArgumentException

If the password is not a string (or null, to reset).

Returns

\Charcoal\User\UserInterface

Chainable

password()

password() : string

Returns

string

setActive()

setActive(boolean  $active) : \Charcoal\Object\Content

Parameters

boolean $active

The active flag.

Returns

\Charcoal\Object\Content

Chainable

active()

active() : boolean

Returns

boolean

setRoles()

setRoles(string|array<mixed,string>|null  $roles) : \Charcoal\User\AbstractUser

Parameters

string|array<mixed,string>|null $roles

The ACL roles this user belongs to.

Throws

\InvalidArgumentException

If the roles argument is invalid.

Returns

\Charcoal\User\AbstractUser

Chainable

roles()

roles() : array<mixed,string>

Returns

array<mixed,string>

setLastLoginDate()

setLastLoginDate(string|\DateTimeInterface|null  $lastLoginDate) : \Charcoal\User\AbstractUser

Parameters

string|\DateTimeInterface|null $lastLoginDate

The last login date.

Throws

\InvalidArgumentException

If the ts is not a valid date/time.

Returns

\Charcoal\User\AbstractUser

Chainable

lastLoginDate()

lastLoginDate() : \DateTimeInterface|null

Returns

\DateTimeInterface|null

setLastLoginIp()

setLastLoginIp(string|integer|null  $ip) : \Charcoal\User\UserInterface

Parameters

string|integer|null $ip

The last login IP address.

Throws

\InvalidArgumentException

If the IP is not an IP string, an integer, or null.

Returns

\Charcoal\User\UserInterface

Chainable

lastLoginIp()

lastLoginIp() : string

Get the last login IP in x.x.x.x format

Returns

string

setLastPasswordDate()

setLastPasswordDate(string|\DateTimeInterface|null  $lastPasswordDate) : \Charcoal\User\UserInterface

Parameters

string|\DateTimeInterface|null $lastPasswordDate

The last password date.

Throws

\InvalidArgumentException

If the passsword date is not a valid DateTime.

Returns

\Charcoal\User\UserInterface

Chainable

lastPasswordDate()

lastPasswordDate() : \DateTimeInterface|null

Returns

\DateTimeInterface|null

setLastPasswordIp()

setLastPasswordIp(integer|string|null  $ip) : \Charcoal\User\UserInterface

Parameters

integer|string|null $ip

The last password IP.

Throws

\InvalidArgumentException

If the IP is not null, an integer or an IP string.

Returns

\Charcoal\User\UserInterface

Chainable

lastPasswordIp()

lastPasswordIp() : string

Get the last password change IP in x.x.x.x format

Returns

string

setLoginToken()

setLoginToken(string  $token) : \Charcoal\User\UserInterface

Parameters

string $token

The login token.

Throws

\InvalidArgumentException

If the token is not a string.

Returns

\Charcoal\User\UserInterface

Chainable

loginToken()

loginToken() : string

Returns

string

saveToSession()

saveToSession() : \Charcoal\User\UserInterface

Throws

\Exception

If trying to save a user to session without a ID.

Returns

\Charcoal\User\UserInterface

Chainable

login()

login() : boolean

Log in the user (in session)

Called when the authentication is successful.

Returns

boolean —

Success / Failure

logLogin()

logLogin() : boolean

Returns

boolean

loginFailed()

loginFailed(string  $username) : void

Failed authentication callback

Parameters

string $username

The failed username.

logLoginFailed()

logLoginFailed(string  $username) : boolean

Parameters

string $username

The username to log failure.

Returns

boolean

logout()

logout() : boolean

Empties the session var associated to the session key.

Returns

boolean —

Logged out or not.

resetPassword()

resetPassword(string  $plainPassword) : \Charcoal\User\UserInterface

Reset the password.

Encrypt the password and re-save the object in the database. Also updates the last password date & ip.

Parameters

string $plainPassword

The plain (non-encrypted) password to reset to.

Throws

\InvalidArgumentException

If the plain password is not a string.

Returns

\Charcoal\User\UserInterface

Chainable

getAuthenticated()

getAuthenticated(\Charcoal\Factory\FactoryInterface  $factory) : \Charcoal\User\UserInterface|null

Get the currently authenticated user (from session)

Return null if there is no current user in logged into

Parameters

\Charcoal\Factory\FactoryInterface $factory

The factory to create the user object with.

Throws

\Exception

If the user from session is invalid.

Returns

\Charcoal\User\UserInterface|null

setDependencies()

setDependencies(\Pimple\Container  $container) : void

Dependencies

Parameters

\Pimple\Container $container

DI Container.

modelFactory()

modelFactory() : \Charcoal\Factory\FactoryInterface

Retrieve the object model factory.

Returns

\Charcoal\Factory\FactoryInterface

setPosition()

setPosition(integer  $position) : \Charcoal\Object\Content

Parameters

integer $position

The position (for ordering purpose).

Throws

\InvalidArgumentException

If the position is not an integer (or numeric integer string).

Returns

\Charcoal\Object\Content

Chainable

position()

position() : integer

Returns

integer

setCreated()

setCreated(\DateTimeInterface|string|null  $created) : \Charcoal\Object\Content

Parameters

\DateTimeInterface|string|null $created

The date/time at object's creation.

Throws

\InvalidArgumentException

If the date/time is invalid.

Returns

\Charcoal\Object\Content

Chainable

created()

created() : \DateTimeInterface|null

Returns

\DateTimeInterface|null

setCreatedBy()

setCreatedBy(mixed  $createdBy) : \Charcoal\Object\Content

Parameters

mixed $createdBy

The creator of the content object.

Returns

\Charcoal\Object\Content

Chainable

createdBy()

createdBy() : mixed

Returns

mixed

setLastModified()

setLastModified(\DateTimeInterface|string|null  $lastModified) : \Charcoal\Object\Content

Parameters

\DateTimeInterface|string|null $lastModified

The last modified date/time.

Throws

\InvalidArgumentException

If the date/time is invalid.

Returns

\Charcoal\Object\Content

Chainable

lastModified()

lastModified() : \DateTimeInterface

Returns

\DateTimeInterface

setLastModifiedBy()

setLastModifiedBy(mixed  $lastModifiedBy) : \Charcoal\Object\Content

Parameters

mixed $lastModifiedBy

The last modification's username.

Returns

\Charcoal\Object\Content

Chainable

lastModifiedBy()

lastModifiedBy() : mixed

Returns

mixed

preSave()

preSave() : boolean

StorableTrait > preSavƒe(): Called automatically before saving the object to source.

For content object, set the created and lastModified properties automatically

Returns

boolean

preUpdate()

preUpdate(array  $properties = null) : boolean

StorableTrait > preUpdate(): Called automatically before updating the object to source.

For content object, set the lastModified property automatically.

Parameters

array $properties

The properties (ident) set for update.

Returns

boolean

setRevisionEnabled()

setRevisionEnabled(boolean  $enabled) : \Charcoal\Object\RevisionableInterface

Parameters

boolean $enabled

The (revision) enabled flag.

Returns

\Charcoal\Object\RevisionableInterface

Chainable

revisionEnabled()

revisionEnabled() : boolean

Returns

boolean

objectRevisionClass()

objectRevisionClass() : string

Retrieve the class name of the object revision model.

Returns

string

revisionNum()

revisionNum(integer  $revNum) : \Charcoal\Object\ObjectRevision

Parameters

integer $revNum

The revision number.

Returns

\Charcoal\Object\ObjectRevision

allRevisions()

allRevisions(callable  $callback = null) : array

Retrieves all revisions for the current objet

Parameters

callable $callback

Optional object callback.

Returns

array

revertToRevision()

revertToRevision(integer  $revNum) : boolean

Parameters

integer $revNum

The revision number to revert to.

Throws

\InvalidArgumentException

If revision number is invalid.

Returns

boolean —

Success / Failure.

sessionKey()

sessionKey() : string

Returns

string

setModelFactory()

setModelFactory(\Charcoal\Factory\FactoryInterface  $factory) : \Charcoal\Object\AdminScript

Parameters

\Charcoal\Factory\FactoryInterface $factory

The factory used to create models.

Returns

\Charcoal\Object\AdminScript —

Chainable

setObjectRevisionClass()

setObjectRevisionClass(string  $className) : \Charcoal\Object\AbstractPropertyDisplay

Set the class name of the object revision model.

Parameters

string $className

The class name of the object revision model.

Throws

\InvalidArgumentException

If the class name is not a string.

Returns

\Charcoal\Object\AbstractPropertyDisplay —

Chainable