core/model/modx/processors/element/plugin/duplicate.class.php
Duplicate a plugin
- Package
- modx
- $id
- integer
The ID of the plugin
- $name
- string
The new name of the duplicated plugin
- Subpackage
- processors.element.plugin
\modPluginDuplicateProcessor
Duplicate a plugin
{@inheritdoc}
- Parent(s)
- \modElementDuplicateProcessor < \modObjectDuplicateProcessor < \modObjectProcessor < \modProcessor
- $id
- integer
The ID of the plugin
- $name
- string
The new name of the duplicated plugin
Properties
boolean
$checkSavePermission= 'true'
true
Details- Type
- boolean
- Inherited_from
- \modObjectDuplicateProcessor::$$checkSavePermission
- Inherited_from
- \modElementDuplicateProcessor::$$checkSavePermission
string
$classKey= ''modPlugin''
'modPlugin'
Details- Type
- string
array
$languageTopics= 'array('plugin')'
array('plugin')
Details- Type
- array
\modX
$modx= 'null'
A reference to the modX object.
Inherited from: \modProcessor::$$modx\modObjectProcessor::$$modx\modObjectDuplicateProcessor::$$modx\modElementDuplicateProcessor::$$modxnull
Details- Type
- \modX
- Inherited_from
- \modProcessor::$$modx
- Inherited_from
- \modObjectProcessor::$$modx
- Inherited_from
- \modObjectDuplicateProcessor::$$modx
- Inherited_from
- \modElementDuplicateProcessor::$$modx
$nameField= ''name''
'name'
Details- Type
- n/a
- Inherited_from
- \modObjectDuplicateProcessor::$$nameField
- Inherited_from
- \modElementDuplicateProcessor::$$nameField
\xPDOObject
$newObject= ''
- Type
- \xPDOObject
- Inherited_from
- \modObjectDuplicateProcessor::$$newObject
- Inherited_from
- \modElementDuplicateProcessor::$$newObject
\xPDOObject|\modAccessibleObject
$object= ''
- Type
- \xPDOObject | \modAccessibleObject
- Inherited_from
- \modObjectProcessor::$$object
- Inherited_from
- \modObjectDuplicateProcessor::$$object
- Inherited_from
- \modElementDuplicateProcessor::$$object
string
$objectType= ''plugin''
'plugin'
Details- Type
- string
string
$path= ''''
The absolute path to this processor
Inherited from: \modProcessor::$$path\modObjectProcessor::$$path\modObjectDuplicateProcessor::$$path\modElementDuplicateProcessor::$$path''
Details- Type
- string
- Inherited_from
- \modProcessor::$$path
- Inherited_from
- \modObjectProcessor::$$path
- Inherited_from
- \modObjectDuplicateProcessor::$$path
- Inherited_from
- \modElementDuplicateProcessor::$$path
string
$permission= ''new_plugin''
'new_plugin'
Details- Type
- string
string
$primaryKeyField= ''id''
'id'
Details- Type
- string
- Inherited_from
- \modObjectProcessor::$$primaryKeyField
- Inherited_from
- \modObjectDuplicateProcessor::$$primaryKeyField
- Inherited_from
- \modElementDuplicateProcessor::$$primaryKeyField
array
$properties= 'array()'
The array of properties being passed to this processor
Inherited from: \modProcessor::$$properties\modObjectProcessor::$$properties\modObjectDuplicateProcessor::$$properties\modElementDuplicateProcessor::$$propertiesarray()
Details- Type
- array
- Inherited_from
- \modProcessor::$$properties
- Inherited_from
- \modObjectProcessor::$$properties
- Inherited_from
- \modObjectDuplicateProcessor::$$properties
- Inherited_from
- \modElementDuplicateProcessor::$$properties
Methods
__construct(
\modX $modx, array $properties
=
array()
)
:
void
Creates a modProcessor object.
Inherited from: \modProcessor::__construct()\modObjectProcessor::__construct()\modObjectDuplicateProcessor::__construct()\modElementDuplicateProcessor::__construct()Name | Type | Description |
---|---|---|
$modx | \modX | A reference to the modX instance |
$properties | array | An array of properties |
_decodeLiterals(
string $string
)
:
string
Decodes strings encoded by _encodeLiterals to restore JavaScript literals.
Inherited from: \modProcessor::_decodeLiterals()\modObjectProcessor::_decodeLiterals()\modObjectDuplicateProcessor::_decodeLiterals()\modElementDuplicateProcessor::_decodeLiterals()Name | Type | Description |
---|---|---|
$string | string | The JSON-encoded string with encoded literals. |
Type | Description |
---|---|
string | The JSON-encoded string with literals restored. |
- Access
- protected
_encodeLiterals(
mixed $value, integer | string $key
)
:
void
Encodes certain JavaScript literal strings for later decoding.
Inherited from: \modProcessor::_encodeLiterals()\modObjectProcessor::_encodeLiterals()\modObjectDuplicateProcessor::_encodeLiterals()\modElementDuplicateProcessor::_encodeLiterals()Name | Type | Description |
---|---|---|
$value | mixed | &$value A reference to the value to be encoded if it is identified as a literal. |
$key | integer | string | The array key corresponding to the value. |
- Access
- protected
addFieldError(
string $key, string $message
=
''
)
:
mixed
Add an error to the field
Inherited from: \modProcessor::addFieldError()\modObjectProcessor::addFieldError()\modObjectDuplicateProcessor::addFieldError()\modElementDuplicateProcessor::addFieldError()Name | Type | Description |
---|---|---|
$key | string | |
$message | string |
Type | Description |
---|---|
mixed |
afterSave(
)
:
boolean
Run any logic after the object has been duplicated
Type | Description |
---|---|
boolean |
alreadyExists(
string $name
)
:
boolean
Check to see if an object already exists with that name
Inherited from: \modObjectDuplicateProcessor::alreadyExists()\modElementDuplicateProcessor::alreadyExists()Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
boolean |
beforeSave(
)
:
boolean
Run any logic before the object has been duplicated. May return false to prevent duplication.
Inherited from: \modObjectDuplicateProcessor::beforeSave()\modElementDuplicateProcessor::beforeSave()Type | Description |
---|---|
boolean |
beforeSet(
)
:
boolean
Override in your derivative class to do functionality before the fields are set on the object
Inherited from: \modObjectDuplicateProcessor::beforeSet()\modElementDuplicateProcessor::beforeSet()Type | Description |
---|---|
boolean |
checkPermissions(
)
:
boolean
Return true here to allow access to this processor.
Inherited from: \modObjectProcessor::checkPermissions()\modObjectDuplicateProcessor::checkPermissions()\modElementDuplicateProcessor::checkPermissions()Type | Description |
---|---|
boolean |
failure(
string $msg
=
'', mixed $object
=
null
)
:
array | string
Return a failure message from the processor.
Inherited from: \modProcessor::failure()\modObjectProcessor::failure()\modObjectDuplicateProcessor::failure()\modElementDuplicateProcessor::failure()Name | Type | Description |
---|---|---|
$msg | string | |
$object | mixed |
Type | Description |
---|---|
array | string |
getInstance(
\modX $modx, string $className, array $properties
=
array()
)
:
\The
Return the proper instance of the derived class. This can be used to override how MODX loads a processor class; for example, when handling derivative classes with class_key settings.
Inherited from: \modProcessor::getInstance()\modObjectProcessor::getInstance()\modObjectDuplicateProcessor::getInstance()\modElementDuplicateProcessor::getInstance()Name | Type | Description |
---|---|---|
$modx | \modX | A reference to the modX object. |
$className | string | The name of the class that is being requested. |
$properties | array | An array of properties being run with the processor |
Type | Description |
---|---|
\The | class specified by $className |
- Static
getLanguageTopics(
)
:
array
Load a collection of Language Topics for this processor.
Inherited from: \modObjectProcessor::getLanguageTopics()\modObjectDuplicateProcessor::getLanguageTopics()\modElementDuplicateProcessor::getLanguageTopics()Override this in your derivative class to provide the array of topics to load.
Type | Description |
---|---|
array |
getNewName(
)
:
string
Get the new name for the duplicate
Inherited from: \modObjectDuplicateProcessor::getNewName()\modElementDuplicateProcessor::getNewName()Type | Description |
---|---|
string |
getProperties(
)
:
array
Get an array of properties for this processor
Inherited from: \modProcessor::getProperties()\modObjectProcessor::getProperties()\modObjectDuplicateProcessor::getProperties()\modElementDuplicateProcessor::getProperties()Type | Description |
---|---|
array |
getProperty(
string $k, mixed $default
=
null
)
:
mixed
Get a specific property.
Inherited from: \modProcessor::getProperty()\modObjectProcessor::getProperty()\modObjectDuplicateProcessor::getProperty()\modElementDuplicateProcessor::getProperty()Name | Type | Description |
---|---|---|
$k | string | |
$default | mixed |
Type | Description |
---|---|
mixed |
hasErrors(
)
:
boolean
Return whether or not the processor has errors
Inherited from: \modProcessor::hasErrors()\modObjectProcessor::hasErrors()\modObjectDuplicateProcessor::hasErrors()\modElementDuplicateProcessor::hasErrors()Type | Description |
---|---|
boolean |
initialize(
)
:
boolean
Can be used to provide custom methods prior to processing. Return true to tell MODX that the Processor initialized successfully. If you return anything else, MODX will output that return value as an error message.
Inherited from: \modObjectDuplicateProcessor::initialize()\modElementDuplicateProcessor::initialize()Type | Description |
---|---|
boolean |
logManagerAction(
)
:
void
Log a manager action
Inherited from: \modObjectDuplicateProcessor::logManagerAction()\modElementDuplicateProcessor::logManagerAction()outputArray(
array $array, mixed $count
=
false
)
:
string
Return arrays of objects (with count) converted to JSON.
Inherited from: \modProcessor::outputArray()\modObjectProcessor::outputArray()\modObjectDuplicateProcessor::outputArray()\modElementDuplicateProcessor::outputArray()The JSON result includes two main elements, total and results. This format is used for list results.
Name | Type | Description |
---|---|---|
$array | array | An array of data objects. |
$count | mixed | The total number of objects. Used for pagination. |
Type | Description |
---|---|
string | The JSON output. |
- Access
- public
process(
)
:
mixed
Run the processor and return the result. Override this in your derivative class to provide custom functionality.
Inherited from: \modObjectDuplicateProcessor::process()\modElementDuplicateProcessor::process()Used here for pre-2.2-style processors.
Type | Description |
---|---|
mixed |
processEventResponse(
array | string $response, string $separator
=
"\n"
)
:
string
Processes a response from a Plugin Event invocation
Inherited from: \modProcessor::processEventResponse()\modObjectProcessor::processEventResponse()\modObjectDuplicateProcessor::processEventResponse()\modElementDuplicateProcessor::processEventResponse()Name | Type | Description |
---|---|---|
$response | array | string | The response generated by the invokeEvent call |
$separator | string | The separator for each event response |
Type | Description |
---|---|
string | The processed response. |
run(
)
:
\modProcessorResponse
Run the processor, returning a modProcessorResponse object.
Inherited from: \modProcessor::run()\modObjectProcessor::run()\modObjectDuplicateProcessor::run()\modElementDuplicateProcessor::run()Type | Description |
---|---|
\modProcessorResponse |
setCheckbox(
string $k, boolean $force
=
false
)
:
int | null
Special helper method for handling checkboxes. Only set value if passed or $force is true, and check for a not empty value or string 'false'.
Inherited from: \modProcessor::setCheckbox()\modObjectProcessor::setCheckbox()\modObjectDuplicateProcessor::setCheckbox()\modElementDuplicateProcessor::setCheckbox()Name | Type | Description |
---|---|---|
$k | string | |
$force | boolean |
Type | Description |
---|---|
int | null |
setDefaultProperties(
array $properties
=
array()
)
:
array
Sets default properties that only are set if they don't already exist in the request
Inherited from: \modProcessor::setDefaultProperties()\modObjectProcessor::setDefaultProperties()\modObjectDuplicateProcessor::setDefaultProperties()\modElementDuplicateProcessor::setDefaultProperties()Name | Type | Description |
---|---|---|
$properties | array |
Type | Description |
---|---|
array | The newly merged properties array |
setNewName(
string $name
)
:
string
Set the new name to the new object
Inherited from: \modObjectDuplicateProcessor::setNewName()\modElementDuplicateProcessor::setNewName()Name | Type | Description |
---|---|---|
$name | string |
Type | Description |
---|---|
string |
setPath(
string $path
)
:
void
Set the path of the processor
Inherited from: \modProcessor::setPath()\modObjectProcessor::setPath()\modObjectDuplicateProcessor::setPath()\modElementDuplicateProcessor::setPath()Name | Type | Description |
---|---|---|
$path | string | The absolute path |
setProperties(
array $properties
)
:
void
Set the runtime properties for the processor
Inherited from: \modProcessor::setProperties()\modObjectProcessor::setProperties()\modObjectDuplicateProcessor::setProperties()\modElementDuplicateProcessor::setProperties()Name | Type | Description |
---|---|---|
$properties | array | The properties, in array and key-value form, to run on this processor |
setProperty(
string $k, mixed $v
)
:
void
Set a property value
Inherited from: \modProcessor::setProperty()\modObjectProcessor::setProperty()\modObjectDuplicateProcessor::setProperty()\modElementDuplicateProcessor::setProperty()Name | Type | Description |
---|---|---|
$k | string | |
$v | mixed |
success(
string $msg
=
'', mixed $object
=
null
)
:
array | string
Return a success message from the processor.
Inherited from: \modProcessor::success()\modObjectProcessor::success()\modObjectDuplicateProcessor::success()\modElementDuplicateProcessor::success()Name | Type | Description |
---|---|---|
$msg | string | |
$object | mixed |
Type | Description |
---|---|
array | string |
toJSON(
mixed $data
)
:
string
Converts PHP to JSON with JavaScript literals left in-tact.
Inherited from: \modProcessor::toJSON()\modObjectProcessor::toJSON()\modObjectDuplicateProcessor::toJSON()\modElementDuplicateProcessor::toJSON()JSON does not allow JavaScript literals, but this function encodes certain identifiable literals and decodes them back into literals after modX::toJSON() formats the data.
Name | Type | Description |
---|---|---|
$data | mixed | The PHP data to be converted. |
Type | Description |
---|---|
string | The extended JSON-encoded string. |
- Access
- public
unsetProperty(
string $key
)
:
void
Completely unset a property from the properties array
Inherited from: \modProcessor::unsetProperty()\modObjectProcessor::unsetProperty()\modObjectDuplicateProcessor::unsetProperty()\modElementDuplicateProcessor::unsetProperty()Name | Type | Description |
---|---|---|
$key | string |