Properties

$targetModel

$targetModel : \Charcoal\Model\ModelInterface|null

The model to alter.

Type

\Charcoal\Model\ModelInterface|null

$relatedModels

$relatedModels : array<mixed,\Charcoal\Model\ModelInterface>|null

The related models to update.

Type

array<mixed,\Charcoal\Model\ModelInterface>|null

$relatedProperties

$relatedProperties : array<mixed,\Charcoal\Property\PropertyInterface>|null

The related model properties to update.

Type

array<mixed,\Charcoal\Property\PropertyInterface>|null

$modelFactory

$modelFactory : \Charcoal\Factory\FactoryInterface

Type

\Charcoal\Factory\FactoryInterface

Methods

setDependencies()

setDependencies(\Pimple\Container  $container) : void

Parameters

\Pimple\Container $container

Pimple DI container.

run()

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

Run the script.

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

start()

start() : self

Execute the prime directive.

Returns

self

defaultArguments()

defaultArguments() : array

Retrieve the script's supported arguments.

Returns

array

parentArguments()

parentArguments() : array

Retrieve the script's parent arguments.

Useful for specialty classes extending this one that might not want options for selecting specific objects.

Returns

array

setTargetModel()

setTargetModel(string|\Charcoal\Model\ModelInterface  $model) : self

Set the model to alter.

Parameters

string|\Charcoal\Model\ModelInterface $model

An object model.

Throws

\InvalidArgumentException

If the given argument is not a model.

Returns

self

targetModel()

targetModel() : \Charcoal\Model\ModelInterface

Retrieve the model to alter.

Throws

\RuntimeException

If a target model has not been defined.

Returns

\Charcoal\Model\ModelInterface

setRelatedModels()

setRelatedModels(string|array  $models) : self

Set the related models to update.

Parameters

string|array $models

One or more object models.

Throws

\InvalidArgumentException

If the given argument is not a model.

Returns

self

relatedModels()

relatedModels() : array<mixed,\Charcoal\Model\ModelInterface>|null

Retrieve the related models to update.

Returns

array<mixed,\Charcoal\Model\ModelInterface>|null

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.

propertyToInput()

propertyToInput(\Charcoal\Property\PropertyInterface  $prop) : mixed

Parameters

\Charcoal\Property\PropertyInterface $prop

The property to retrieve input from.

Returns

mixed

init()

init() : void

prepareProperties()

prepareProperties(string  $oldKey, string  $newKey, \Charcoal\Property\IdProperty|null  $oldProp = null, \Charcoal\Property\IdProperty|null  $newProp = null) : array<mixed,\Charcoal\Property\IdProperty>

Retrieve the old and new ID properties.

Parameters

string $oldKey

The previous key.

string $newKey

The new key.

\Charcoal\Property\IdProperty|null $oldProp

If provided, then it is filled with an instance of IdProperty.

\Charcoal\Property\IdProperty|null $newProp

If provided, then it is filled with an instance of IdProperty.

Returns

array<mixed,\Charcoal\Property\IdProperty>

labelFromMode()

labelFromMode(string|\Charcoal\Property\IdProperty  $mode) : string

Retrieve a label for the ID's mode.

Parameters

string|\Charcoal\Property\IdProperty $mode

The mode or property to resolve.

Throws

\UnexpectedValueException

If the ID mode is invalid.

Returns

string

describeConversion()

describeConversion(\Charcoal\Property\IdProperty  $prop) : self

Describe what we are converting to.

Parameters

\Charcoal\Property\IdProperty $prop

The property to analyse.

Returns

self

propertyField()

propertyField(\Charcoal\Property\IdProperty  $prop) : \Charcoal\Property\PropertyField

Retrieve the given property's field.

Parameters

\Charcoal\Property\IdProperty $prop

The property to retrieve the field from.

Returns

\Charcoal\Property\PropertyField

convertIdField()

convertIdField(\Charcoal\Property\IdProperty  $newProp, \Charcoal\Property\PropertyField  $newField, \Charcoal\Property\IdProperty  $oldProp, \Charcoal\Property\PropertyField  $oldField) : self

Convert a primary key column from one format to another.

Parameters

\Charcoal\Property\IdProperty $newProp

The new ID property.

\Charcoal\Property\PropertyField $newField

The new ID field.

\Charcoal\Property\IdProperty $oldProp

The previous ID property.

\Charcoal\Property\PropertyField $oldField

The previous ID field.

Throws

\InvalidArgumentException

If the new property does not implement the proper mode.

Returns

self

syncRelatedFields()

syncRelatedFields(\Charcoal\Property\IdProperty  $newProp, \Charcoal\Property\PropertyField  $newField, \Charcoal\Property\IdProperty  $oldProp, \Charcoal\Property\PropertyField  $oldField) : self

Sync the new primary keys to related models.

Parameters

\Charcoal\Property\IdProperty $newProp

The new ID property.

\Charcoal\Property\PropertyField $newField

The new ID field.

\Charcoal\Property\IdProperty $oldProp

The previous ID property.

\Charcoal\Property\PropertyField $oldField

The previous ID field.

Throws

\InvalidArgumentException

If the new property does not implement the proper mode.

Returns

self

resolveRelatedModel()

resolveRelatedModel(string  $pattern) : array

Resolve the given related model.

Parameters

string $pattern

A 'model:property' identifier.

Throws

\InvalidArgumentException

If the identifier is invalid.

Returns

array —

Returns an array containing a ModelInterface and a property identifier.

booleanInput()

booleanInput(\Charcoal\Property\PropertyInterface  $prop) : \League\CLImate\TerminalObject\Dynamic\Input

Get a CLI input from a boolean property.

Parameters

\Charcoal\Property\PropertyInterface $prop

The property to retrieve input from.

Returns

\League\CLImate\TerminalObject\Dynamic\Input

passwordInput()

passwordInput(\Charcoal\Property\PropertyInterface  $prop) : \League\CLImate\TerminalObject\Dynamic\Input

Get a CLI password input (hidden) from a password property.

Parameters

\Charcoal\Property\PropertyInterface $prop

The property to retrieve input from.

Returns

\League\CLImate\TerminalObject\Dynamic\Input

fetchTargetRows()

fetchTargetRows() : array|\Traversable

Retrieve the target model's rows.

Returns

array|\Traversable

describeCount()

describeCount(array|\Traversable  $rows = null) : boolean

Describe the given count.

Parameters

array|\Traversable $rows

The target model's existing rows.

Throws

\InvalidArgumentException

If the given argument is not iterable.

Returns

boolean

insertNewField()

insertNewField(\Charcoal\Property\PropertyField  $field, \Charcoal\Property\IdProperty  $prop) : self

Insert the given field.

Parameters

\Charcoal\Property\PropertyField $field

The new ID field.

\Charcoal\Property\IdProperty $prop

The new ID property.

Returns

self

dropPrimaryKey()

dropPrimaryKey(\Charcoal\Property\PropertyField  $field, \Charcoal\Property\IdProperty  $prop) : self

Drop the primary key from the given field.

Parameters

\Charcoal\Property\PropertyField $field

The previous ID field.

\Charcoal\Property\IdProperty $prop

The previous ID property.

Returns

self

applyPrimaryKey()

applyPrimaryKey(\Charcoal\Property\PropertyField  $field, \Charcoal\Property\IdProperty  $prop) : self

Set the given field as the primary key.

Parameters

\Charcoal\Property\PropertyField $field

The new ID field.

\Charcoal\Property\IdProperty $prop

The new ID property.

Returns

self

renameColumn()

renameColumn(\Charcoal\Property\PropertyField  $field, string  $from, string  $to) : self

Rename the given field.

Parameters

\Charcoal\Property\PropertyField $field

The field to rename.

string $from

The original field key.

string $to

The new field key.

Returns

self

removeColumn()

removeColumn(\Charcoal\Property\PropertyField  $field) : self

Remove the given field.

Parameters

\Charcoal\Property\PropertyField $field

The field to remove.

Returns

self