\Charcoal\Admin\Action\ObjectRevertRevisionAction

Action: Restore Object Revision

Required Parameters

  • obj_type (string) — The object type, as an identifier for a \Charcoal\Model\ModelInterface.
  • obj_id (mixed) — The object ID to revert
  • rev_num (integer) — The object's revision to restore the object to

Response

  • success (boolean) — TRUE if the object was properly restored, FALSE in case of any error.

HTTP Status Codes

  • 200 — Successful; Revision has been restored
  • 400 — Client error; Invalid request data
  • 500 — Server error; Revision could not be restored

Summary

Methods
Properties
Constants
setObjType()
objType()
setObjId()
objId()
objIdWithSlashes()
setObjBaseClass()
objBaseClass()
proto()
hasObj()
obj()
__construct()
setDependencies()
init()
siteName()
authRequired()
isAuthenticated()
getAuthenticatedUser()
results()
adminUrl()
setBaseUrl()
baseUrl()
hasFeedbacks()
numFeedbacks()
feedbacks()
addFeedback()
clearFeedback()
revNum()
run()
No public properties found
No constants found
setModelFactory()
modelFactory()
createOrLoadObj()
cloneObj()
createObjFromBluePrint()
createObj()
loadObj()
validateObjType()
validateObjBaseClass()
setSiteName()
validateCaptcha()
resolveFeedbackLevel()
setRevNum()
$objType
$objId
$objBaseClass
$obj
$adminConfig
$appConfig
$feedbacks
$revNum
N/A
No private methods found
$modelFactory
$siteName
N/A

Properties

$objType

$objType : string|null

Type

string|null

$objId

$objId : string|\Charcoal\Admin\Ui\numeric|null

Type

string|\Charcoal\Admin\Ui\numeric|null

$objBaseClass

$objBaseClass : string

Type

string

$obj

$obj : \Charcoal\Model\ModelInterface

Type

\Charcoal\Model\ModelInterface

$adminConfig

$adminConfig : \Charcoal\Admin\Config

Store a reference to the admin configuration.

Type

\Charcoal\Admin\Config

$appConfig

$appConfig : \Charcoal\App\Config

Store a reference to the application configuration.

Type

\Charcoal\App\Config

$feedbacks

$feedbacks : array

Collection of feedback.

Type

array

$revNum

$revNum : integer|null

The revision number to restore.

Type

integer|null

$modelFactory

$modelFactory : \Charcoal\Factory\FactoryInterface

Store the model factory.

Type

\Charcoal\Factory\FactoryInterface

$siteName

$siteName : \Charcoal\Translator\Translation|string|null

The name of the project.

Type

\Charcoal\Translator\Translation|string|null

Methods

setObjType()

setObjType(string  $objType) : \Charcoal\Admin\Ui\ObjectContainerInterface

Set the object type.

Parameters

string $objType

The object type.

Throws

\InvalidArgumentException

If provided argument is not of type 'string'.

Returns

\Charcoal\Admin\Ui\ObjectContainerInterface

Chainable

objType()

objType() : string|null

Retrieve the object type.

Returns

string|null

setObjId()

setObjId(string|\Charcoal\Admin\Ui\numeric  $objId) : \Charcoal\Admin\Ui\ObjectContainerInterface

Set the object ID.

Parameters

string|\Charcoal\Admin\Ui\numeric $objId

The object ID to load.

Throws

\InvalidArgumentException

If provided argument is not of type 'scalar'.

Returns

\Charcoal\Admin\Ui\ObjectContainerInterface

Chainable

objId()

objId() : string|\Charcoal\Admin\Ui\numeric|null

Retrieve the object ID.

Returns

string|\Charcoal\Admin\Ui\numeric|null

objIdWithSlashes()

objIdWithSlashes() : string

Retrieve the object ID and addslashes.

Used in template/charcoal/admin/template/form/js.mustache to prevent problems with ID with single or double quotes.

Returns

string —

Escaped ID.

setObjBaseClass()

setObjBaseClass(string  $objBaseClass) : \Charcoal\Admin\Ui\ObjectContainerInterface

Parameters

string $objBaseClass

The base class.

Throws

\InvalidArgumentException

If provided argument is not of type 'string'.

Returns

\Charcoal\Admin\Ui\ObjectContainerInterface

Chainable

objBaseClass()

objBaseClass() : string|null

Returns

string|null

proto()

proto() : \Charcoal\Model\ModelInterface

Retrieve a singleton of the {self::$objType} for prototyping.

Throws

\RuntimeException

If the class has no object type.

Returns

\Charcoal\Model\ModelInterface

hasObj()

hasObj() : boolean

Determine if the class has a concrete object.

Returns

boolean

obj()

obj() : \Charcoal\Model\ModelInterface

Retrieve the object.

Returns

\Charcoal\Model\ModelInterface

__construct()

__construct(array  $data = null) 

Parameters

array $data

Optional.

setDependencies()

setDependencies(\Pimple\Container  $container) : void

Dependencies

Parameters

\Pimple\Container $container

DI Container.

init()

init(\Psr\Http\Message\RequestInterface  $request) : boolean

Template's init method is called automatically from `charcoal-app`'s Template Route.

For admin templates, initializations is:

  • to start a session, if necessary
  • to authenticate
  • to initialize the template data with $_GET

Parameters

\Psr\Http\Message\RequestInterface $request

The request to initialize.

Returns

boolean

siteName()

siteName() : \Charcoal\Translator\Translation|string|null

Retrieve the name of the project.

Returns

\Charcoal\Translator\Translation|string|null

authRequired()

authRequired() : boolean

Authentication is required by default.

Reimplement and change to false in templates that do not require authentication.

Returns

boolean

isAuthenticated()

isAuthenticated() : boolean

Determine if the current user is authenticated.

Returns

boolean

getAuthenticatedUser()

getAuthenticatedUser() : \Charcoal\User\UserInterface|null

Retrieve the currently authenticated user.

Returns

\Charcoal\User\UserInterface|null

results()

results() : array

Default response stub.

Returns

array

adminUrl()

adminUrl() : \Charcoal\Admin\UriInterface|string

Retrieve the base URI of the administration area.

Returns

\Charcoal\Admin\UriInterface|string

setBaseUrl()

setBaseUrl(\Charcoal\Admin\UriInterface|string  $uri) : self

Set the base URI of the application.

Parameters

\Charcoal\Admin\UriInterface|string $uri

The base URI.

Returns

self

baseUrl()

baseUrl() : \Charcoal\Admin\UriInterface|string

Retrieve the base URI of the application.

Returns

\Charcoal\Admin\UriInterface|string

hasFeedbacks()

hasFeedbacks() : boolean

Determine if there's feedback.

Returns

boolean

numFeedbacks()

numFeedbacks() : integer

Count feedback.

Returns

integer

feedbacks()

feedbacks(string|null  $level = null) : array

Retrieve the feedback collection.

Optionally retrieve only the feedback for the given level.

Parameters

string|null $level

Optional level to filter collection.

Throws

\InvalidArgumentException

If the feedback level is invalid.

Returns

array

addFeedback()

addFeedback(string  $level, mixed  $message) : \Charcoal\Admin\Ui\FeedbackContainerTrait

Add feedback.

Parameters

string $level

The feedback level.

mixed $message

The feedback message.

Returns

\Charcoal\Admin\Ui\FeedbackContainerTrait

Chainable

revNum()

revNum() : integer|null

Retrieve the revision number to restore.

Returns

integer|null

run()

run(\Psr\Http\Message\RequestInterface  $request, \Psr\Http\Message\ResponseInterface  $response) : \Psr\Http\Message\ResponseInterface

Parameters

\Psr\Http\Message\RequestInterface $request

A PSR-7 compatible Request instance.

\Psr\Http\Message\ResponseInterface $response

A PSR-7 compatible Response instance.

Returns

\Psr\Http\Message\ResponseInterface

setModelFactory()

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

Parameters

\Charcoal\Factory\FactoryInterface $factory

The factory used to create models.

Returns

\Charcoal\Admin\AdminScript

Chainable

modelFactory()

modelFactory() : \Charcoal\Factory\FactoryInterface

Returns

\Charcoal\Factory\FactoryInterface —

The model factory.

createOrLoadObj()

createOrLoadObj() : \Charcoal\Model\ModelInterface

Create or load the object.

Returns

\Charcoal\Model\ModelInterface

cloneObj()

cloneObj() : \Charcoal\Model\ModelInterface

Throws

\Exception

If the object is not valid.

Returns

\Charcoal\Model\ModelInterface

createObjFromBluePrint()

createObjFromBluePrint() : \Charcoal\Model\ModelInterface

Throws

\Exception

If the object is not valid.

Returns

\Charcoal\Model\ModelInterface

createObj()

createObj() : \Charcoal\Model\ModelInterface

Throws

\Exception

If the object is not valid.

Returns

\Charcoal\Model\ModelInterface

loadObj()

loadObj() : \Charcoal\Model\ModelInterface

Returns

\Charcoal\Model\ModelInterface —

The loaded object

validateObjType()

validateObjType() : boolean

Throws

\RuntimeException

If the object is invalid.

Returns

boolean

validateObjBaseClass()

validateObjBaseClass(mixed  $obj) : boolean

Parameters

mixed $obj

Object to validate.

Returns

boolean

setSiteName()

setSiteName(string  $name) : \Charcoal\Admin\AdminAction

Set the name of the project.

Parameters

string $name

Name of the project.

Returns

\Charcoal\Admin\AdminAction

Chainable

validateCaptcha()

validateCaptcha(string  $response) : boolean

Parameters

string $response

The captcha value (response) to validate.

Throws

\RuntimeException

If Google reCAPTCHA is not configured.

Returns

boolean

resolveFeedbackLevel()

resolveFeedbackLevel(string  $level) : string

Resolve the given feedback level.

Parameters

string $level

The feedback level.

Returns

string —

The level.

setRevNum()

setRevNum(integer  $revNum) : \Charcoal\Admin\Ui\ObjectContainerInterface

Set the revision number to restore.

Parameters

integer $revNum

The revision number to load.

Throws

\InvalidArgumentException

If the given revision is invalid.

Returns

\Charcoal\Admin\Ui\ObjectContainerInterface

Chainable