core/model/modx/processors/resource/create.class.php
Creates a resource.
- Package
- modx
- $pagetitle
- string
The page title.
- $content
- string
The HTML content. Used in conjunction with $ta.
- $template
- integer
(optional) The modTemplate to use with this resource. Defaults to 0, or a blank template.
- $parent
- integer
(optional) The parent resource ID. Defaults to 0.
- $class_key
- string
(optional) The class key. Defaults to modDocument.
- $menuindex
- integer
(optional) The menu order. Defaults to 0.
- $variablesmodified
- string
(optional) A collection of modified TVs. Along with $tv1, $tv2, etc.
- $context_key
- string
(optional) The context in which this resource is located. Defaults to web.
- $alias
- string
(optional) The alias for FURLs that this resource is designated to.
- $content_type
- integer
(optional) The content type. Defaults to text/html.
- $published
- boolean
(optional) The published status.
- $pub_date
- string
(optional) The date on which this resource should become published.
- $unpub_date
- string
(optional) The date on which this resource should become unpublished.
- $publishedon
- string
(optional) The date this resource was published. Defaults to time()
- $publishedby
- integer
(optional) The modUser who published this resource. Defaults to the current user.
- $resource_groups
- \json
(optional) A JSON array of resource groups to assign this resource to.
- $hidemenu
- boolean
(optional) If true, The resource will not show up in menu builders.
- $isfolder
- boolean
(optional) Whether or not the resource is a container of resources.
- $richtext
- boolean
(optional) If true, MODX will render the available RTE for editing this resource.
- $donthit
- boolean
(optional) (deprecated) If true, MODX will not log visits on this resource.
- $cacheable
- boolean
(optional) If false, the resource will not be cached.
- $searchable
- boolean
(optional) If false, the resource will not appear in searches.
- $syncsite
- boolean
(optional) If false, will not empty the cache on save.
- Subpackage
- processors.resource
\modResourceCreateProcessor
Creates a resource.
{@inheritdoc}
- Parent(s)
- \modObjectCreateProcessor < \modObjectProcessor < \modProcessor
- $pagetitle
- string
The page title.
- $content
- string
The HTML content. Used in conjunction with $ta.
- $template
- integer
(optional) The modTemplate to use with this resource. Defaults to 0, or a blank template.
- $parent
- integer
(optional) The parent resource ID. Defaults to 0.
- $class_key
- string
(optional) The class key. Defaults to modDocument.
- $menuindex
- integer
(optional) The menu order. Defaults to 0.
- $variablesmodified
- string
(optional) A collection of modified TVs. Along with $tv1, $tv2, etc.
- $context_key
- string
(optional) The context in which this resource is located. Defaults to web.
- $alias
- string
(optional) The alias for FURLs that this resource is designated to.
- $content_type
- integer
(optional) The content type. Defaults to text/html.
- $published
- boolean
(optional) The published status.
- $pub_date
- string
(optional) The date on which this resource should become published.
- $unpub_date
- string
(optional) The date on which this resource should become unpublished.
- $publishedon
- string
(optional) The date this resource was published. Defaults to time()
- $publishedby
- integer
(optional) The modUser who published this resource. Defaults to the current user.
- $resource_groups
- \json
(optional) A JSON array of resource groups to assign this resource to.
- $hidemenu
- boolean
(optional) If true, The resource will not show up in menu builders.
- $isfolder
- boolean
(optional) Whether or not the resource is a container of resources.
- $richtext
- boolean
(optional) If true, MODX will render the available RTE for editing this resource.
- $donthit
- boolean
(optional) (deprecated) If true, MODX will not log visits on this resource.
- $cacheable
- boolean
(optional) If false, the resource will not be cached.
- $searchable
- boolean
(optional) If false, the resource will not appear in searches.
- $syncsite
- boolean
(optional) If false, will not empty the cache on save.
Properties

string
$afterSaveEvent= ''OnDocFormSave''
'OnDocFormSave'Details- Type
- string

string
$beforeSaveEvent= ''OnBeforeDocFormSave''
'OnBeforeDocFormSave'Details- Type
- string

string
$classKey= ''modResource''
'modResource'Details- Type
- string

array
$languageTopics= 'array('resource')'
array('resource')Details- Type
- array

\modX
$modx= 'null'
A reference to the modX object.
Inherited from: \modProcessor::$$modx\modObjectProcessor::$$modx\modObjectCreateProcessor::$$modxnullDetails- Type
- \modX
- Inherited_from
- \modProcessor::$$modx
- Inherited_from
- \modObjectProcessor::$$modx
- Inherited_from
- \modObjectCreateProcessor::$$modx

string
$objectType= ''resource''
'resource'Details- Type
- string

string
$path= ''''
The absolute path to this processor
Inherited from: \modProcessor::$$path\modObjectProcessor::$$path\modObjectCreateProcessor::$$path''Details- Type
- string
- Inherited_from
- \modProcessor::$$path
- Inherited_from
- \modObjectProcessor::$$path
- Inherited_from
- \modObjectCreateProcessor::$$path

string
$permission= ''new_document''
'new_document'Details- Type
- string

string
$primaryKeyField= ''id''
'id'Details- Type
- string
- Inherited_from
- \modObjectProcessor::$$primaryKeyField
- Inherited_from
- \modObjectCreateProcessor::$$primaryKeyField

array
$properties= 'array()'
The array of properties being passed to this processor
Inherited from: \modProcessor::$$properties\modObjectProcessor::$$properties\modObjectCreateProcessor::$$propertiesarray()Details- Type
- array
- Inherited_from
- \modProcessor::$$properties
- Inherited_from
- \modObjectProcessor::$$properties
- Inherited_from
- \modObjectCreateProcessor::$$properties
Methods

__construct(
\modX $modx, array $properties
=
array()
)
:
voidCreates a modProcessor object.
Inherited from: \modProcessor::__construct()\modObjectProcessor::__construct()\modObjectCreateProcessor::__construct()| Name | Type | Description |
|---|---|---|
| $modx | \modX | A reference to the modX instance |
| $properties | array | An array of properties |

_decodeLiterals(
string $string
)
:
stringDecodes strings encoded by _encodeLiterals to restore JavaScript literals.
Inherited from: \modProcessor::_decodeLiterals()\modObjectProcessor::_decodeLiterals()\modObjectCreateProcessor::_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
)
:
voidEncodes certain JavaScript literal strings for later decoding.
Inherited from: \modProcessor::_encodeLiterals()\modObjectProcessor::_encodeLiterals()\modObjectCreateProcessor::_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
=
''
)
:
mixedAdd an error to the field
Inherited from: \modProcessor::addFieldError()\modObjectProcessor::addFieldError()\modObjectCreateProcessor::addFieldError()| Name | Type | Description |
|---|---|---|
| $key | string | |
| $message | string |
| Type | Description |
|---|---|
| mixed |

addTemplateVariables(
)
:
arrayAdd Template Variables to the Resource object
| Type | Description |
|---|---|
| array |

afterSave(
)
:
mixedOverride in your derivative class to do functionality before save() is run
| Type | Description |
|---|---|
| mixed |

beforeSave(
)
:
mixedOverride in your derivative class to do functionality after save() is run
| Type | Description |
|---|---|
| mixed |

beforeSet(
)
:
array | stringProcess the form and create the Resource
| Type | Description |
|---|---|
| array | string |

checkForAllowableCreateToken(
)
:
booleanCheck if new resource token posted from manager
| Type | Description |
|---|---|
| boolean |

checkIfSiteStart(
)
:
booleanQuick check to make sure it's not site_start, if so, publish if not published to prevent site error
| Type | Description |
|---|---|
| boolean |

checkParentPermissions(
)
:
boolean | stringMake sure parent exists and user can add_children to the parent
| Type | Description |
|---|---|
| boolean | string |

checkPermissions(
)
:
booleanReturn true here to allow access to this processor.
Inherited from: \modObjectProcessor::checkPermissions()\modObjectCreateProcessor::checkPermissions()| Type | Description |
|---|---|
| boolean |

doesAlreadyExist(
array $criteria
)
:
int| Name | Type | Description |
|---|---|---|
| $criteria | array |
| Type | Description |
|---|---|
| int |

failure(
string $msg
=
'', mixed $object
=
null
)
:
array | stringReturn a failure message from the processor.
Inherited from: \modProcessor::failure()\modObjectProcessor::failure()\modObjectCreateProcessor::failure()| Name | Type | Description |
|---|---|---|
| $msg | string | |
| $object | mixed |
| Type | Description |
|---|---|
| array | string |

fireBeforeSaveEvent(
)
:
booleanInvoke OnBeforeDocFormSave event, and allow non-empty responses to prevent save
| Type | Description |
|---|---|
| boolean |

getInstance(
\modX $modx, $className, array $properties
=
array()
)
:
\modProcessorAllow for Resources to use derivative classes for their processors
| Name | Type | Description |
|---|---|---|
| $modx | \modX | |
| $className | ||
| $properties | array |
| Type | Description |
|---|---|
| \modProcessor |
- Static

getLanguageTopics(
)
:
arrayLoad a collection of Language Topics for this processor.
Inherited from: \modObjectProcessor::getLanguageTopics()\modObjectCreateProcessor::getLanguageTopics()Override this in your derivative class to provide the array of topics to load.
| Type | Description |
|---|---|
| array |

getProperties(
)
:
arrayGet an array of properties for this processor
Inherited from: \modProcessor::getProperties()\modObjectProcessor::getProperties()\modObjectCreateProcessor::getProperties()| Type | Description |
|---|---|
| array |

getProperty(
string $k, mixed $default
=
null
)
:
mixedGet a specific property.
Inherited from: \modProcessor::getProperty()\modObjectProcessor::getProperty()\modObjectCreateProcessor::getProperty()| Name | Type | Description |
|---|---|---|
| $k | string | |
| $default | mixed |
| Type | Description |
|---|---|
| mixed |

getWorkingContext(
)
:
\modContextGet the working Context for the Resource
| Type | Description |
|---|---|
| \modContext |

hasErrors(
)
:
booleanReturn whether or not the processor has errors
Inherited from: \modProcessor::hasErrors()\modObjectProcessor::hasErrors()\modObjectCreateProcessor::hasErrors()| Type | Description |
|---|---|
| boolean |

initialize(
)
:
string | \modResourceCreate the modResource object for manipulation
| Type | Description |
|---|---|
| string | \modResource |

logManagerAction(
)
:
voidLog the removal manager action
Inherited from: \modObjectCreateProcessor::logManagerAction()
outputArray(
array $array, mixed $count
=
false
)
:
stringReturn arrays of objects (with count) converted to JSON.
Inherited from: \modProcessor::outputArray()\modObjectProcessor::outputArray()\modObjectCreateProcessor::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

prepareAlias(
)
:
stringClean and prepare the alias, automatically generating it if the option is set
| Type | Description |
|---|---|
| string |

process(
)
:
mixedProcess the Object create processor Run the processor and return the result. Override this in your derivative class to provide custom functionality.
Inherited from: \modObjectCreateProcessor::process()Used here for pre-2.2-style processors.
| Type | Description |
|---|---|
| mixed |

processEventResponse(
array | string $response, string $separator
=
"\n"
)
:
stringProcesses a response from a Plugin Event invocation
Inherited from: \modProcessor::processEventResponse()\modObjectProcessor::processEventResponse()\modObjectCreateProcessor::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(
)
:
\modProcessorResponseRun the processor, returning a modProcessorResponse object.
Inherited from: \modProcessor::run()\modObjectProcessor::run()\modObjectCreateProcessor::run()| Type | Description |
|---|---|
| \modProcessorResponse |

setCheckbox(
string $k, boolean $force
=
false
)
:
int | nullSpecial 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()\modObjectCreateProcessor::setCheckbox()| Name | Type | Description |
|---|---|---|
| $k | string | |
| $force | boolean |
| Type | Description |
|---|---|
| int | null |

setDefaultProperties(
array $properties
=
array()
)
:
arraySets default properties that only are set if they don't already exist in the request
Inherited from: \modProcessor::setDefaultProperties()\modObjectProcessor::setDefaultProperties()\modObjectCreateProcessor::setDefaultProperties()| Name | Type | Description |
|---|---|---|
| $properties | array |
| Type | Description |
|---|---|
| array | The newly merged properties array |

setFieldDefaults(
)
:
mixedSet defaults for the fields if values are not passed
| Type | Description |
|---|---|
| mixed |

setMenuIndex(
)
:
intSet the menu index on the Resource, incrementing if not set
| Type | Description |
|---|---|
| int |

setParentToContainer(
)
:
booleanUpdate parent to be a container if user has save permission
| Type | Description |
|---|---|
| boolean |

setPath(
string $path
)
:
voidSet the path of the processor
Inherited from: \modProcessor::setPath()\modObjectProcessor::setPath()\modObjectCreateProcessor::setPath()| Name | Type | Description |
|---|---|---|
| $path | string | The absolute path |

setProperties(
array $properties
)
:
voidSet the runtime properties for the processor
Inherited from: \modProcessor::setProperties()\modObjectProcessor::setProperties()\modObjectCreateProcessor::setProperties()| Name | Type | Description |
|---|---|---|
| $properties | array | The properties, in array and key-value form, to run on this processor |

setProperty(
string $k, mixed $v
)
:
voidSet a property value
Inherited from: \modProcessor::setProperty()\modObjectProcessor::setProperty()\modObjectCreateProcessor::setProperty()| Name | Type | Description |
|---|---|---|
| $k | string | |
| $v | mixed |

success(
string $msg
=
'', mixed $object
=
null
)
:
array | stringReturn a success message from the processor.
Inherited from: \modProcessor::success()\modObjectProcessor::success()\modObjectCreateProcessor::success()| Name | Type | Description |
|---|---|---|
| $msg | string | |
| $object | mixed |
| Type | Description |
|---|---|
| array | string |

toJSON(
mixed $data
)
:
stringConverts PHP to JSON with JavaScript literals left in-tact.
Inherited from: \modProcessor::toJSON()\modObjectProcessor::toJSON()\modObjectCreateProcessor::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
)
:
voidCompletely unset a property from the properties array
Inherited from: \modProcessor::unsetProperty()\modObjectProcessor::unsetProperty()\modObjectCreateProcessor::unsetProperty()| Name | Type | Description |
|---|---|---|
| $key | string |