\Charcoal\Admin\Action\ObjectLoadAction

Action: Load one or more objects from storage.

Required Parameters

  • obj_type (string) — The object type, as an identifier for a \Charcoal\Model\ModelInterface.

Optional Parameters

  • obj_id (mixed) — The object ID to load.

Response

  • success (boolean) — TRUE if the object(s) was/were loaded, FALSE in case of any error.
  • collection (Charcoal\Model\Collection) — One or more of the requested objects, if any.

HTTP Status Codes

  • 200 — Successful; Object(s) loaded, if any
  • 400 — Client error; Invalid request data
  • 500 — Server error; Object(s) could not be loaded, if any

Summary

Methods
Properties
Constants
__construct()
setDependencies()
init()
siteName()
authRequired()
isAuthenticated()
getAuthenticatedUser()
results()
adminUrl()
setBaseUrl()
baseUrl()
hasFeedbacks()
numFeedbacks()
feedbacks()
addFeedback()
clearFeedback()
run()
objCollection()
collectionLoader()
objType()
setObjType()
No public properties found
No constants found
setModelFactory()
modelFactory()
setSiteName()
validateCaptcha()
resolveFeedbackLevel()
loadObjectCollection()
setCollectionLoader()
$adminConfig
$appConfig
$feedbacks
$objType
$objCollection
N/A
No private methods found
$siteName
$modelFactory
$collectionLoader
N/A

Properties

$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

$objType

$objType : string

Type

string

$objCollection

$objCollection : \Charcoal\Model\Collection

Type

\Charcoal\Model\Collection

$siteName

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

The name of the project.

Type

\Charcoal\Translator\Translation|string|null

$modelFactory

$modelFactory : \Charcoal\Admin\Action\Object\FactoryInterface

Store the factory instance for the current class.

Type

\Charcoal\Admin\Action\Object\FactoryInterface

$collectionLoader

$collectionLoader : \Charcoal\Loader\CollectionLoader

Store the collection loader for the current class.

Type

\Charcoal\Loader\CollectionLoader

Methods

__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

run()

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

Parameters

\Psr\Http\Message\RequestInterface $request

The request options.

\Psr\Http\Message\ResponseInterface $response

The response to return.

Throws

\UnexpectedValueException

If "obj_id" is passed as $request option.

Returns

\Psr\Http\Message\ResponseInterface

objCollection()

objCollection() : array

Returns

array —

The object collection parsed as array

collectionLoader()

collectionLoader() : \Charcoal\Loader\CollectionLoader

Retrieve the model collection loader.

Throws

\RuntimeException

If the collection loader was not previously set.

Returns

\Charcoal\Loader\CollectionLoader

objType()

objType() : string

Returns

string —

The object type as string.

setObjType()

setObjType(string  $objType) : self

Parameters

string $objType

The object type as string.

Throws

\InvalidArgumentException

If the object type is not a string.

Returns

self

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.

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.

loadObjectCollection()

loadObjectCollection(string  $objType) : \Charcoal\Model\Collection

Load Object Collection

Parameters

string $objType

The object type as string.

Returns

\Charcoal\Model\Collection

setCollectionLoader()

setCollectionLoader(\Charcoal\Loader\CollectionLoader  $loader) : self

Set a model collection loader.

Parameters

\Charcoal\Loader\CollectionLoader $loader

The collection loader.

Returns

self