Download the PHP package dd/evolutioncms-snippets-ddobjecttools without Composer
On this page you can find all versions of the php package dd/evolutioncms-snippets-ddobjecttools. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download dd/evolutioncms-snippets-ddobjecttools
More information about dd/evolutioncms-snippets-ddobjecttools
Files in dd/evolutioncms-snippets-ddobjecttools
Download dd/evolutioncms-snippets-ddobjecttools
More information about dd/evolutioncms-snippets-ddobjecttools
Files in dd/evolutioncms-snippets-ddobjecttools
Vendor dd
Package evolutioncms-snippets-ddobjecttools
Short Description Tools for modifying objects.
License
Homepage https://code.divandesign.ru/modx/ddobjecttools
Package evolutioncms-snippets-ddobjecttools
Short Description Tools for modifying objects.
License
Homepage https://code.divandesign.ru/modx/ddobjecttools
Please rate this library. Is it a good library?
Informations about the package evolutioncms-snippets-ddobjecttools
(MODX)EvolutionCMS.snippets.ddObjectTools
Tools for modifying objects.
Requires
- PHP >= 5.6
- (MODX)EvolutionCMS >= 1.1
- (MODX)EvolutionCMS.libraries.ddTools >= 0.62
Installation
Using (MODX)EvolutionCMS.libraries.ddInstaller
Just run the following PHP code in your sources or Console:
- If
ddObjectTools
is not exist on your site,ddInstaller
will just install it. - If
ddObjectTools
is already exist on your site,ddInstaller
will check it version and update it if needed.
Manually
1. Elements → Snippets: Create a new snippet with the following data
- Snippet name:
ddObjectTools
. - Description:
<b>1.0</b> Tools for modifying objects.
. - Category:
Core
. - Parse DocBlock:
no
. - Snippet code (php): Insert content of the
ddObjectTools_snippet.php
file from the archive.
2. Elements → Manage Files
- Create a new folder
assets/snippets/ddObjectTools/
. - Extract the archive to the folder (except
ddObjectTools_snippet.php
).
Parameters description
-
sourceObject
- Description: Source object or array.
- Valid values:
stringJsonObject
— as JSONstringJsonArray
— as JSONstringHjsonObject
— as HJSONstringHjsonArray
— as HJSONstringQueryFormatted
— as Query string- It can also be set as a native PHP object or array (e. g. for calls through
$modx->runSnippet
):array
object
- Default value:
'{}'
-
extend
- Description: Merge the contents of two or more objects / arrays together into
sourceObject
(it will receive the new properties). - Valid values:
stringJsonObject
— as JSONstringHjsonObject
— as HJSONstringQueryFormatted
— as Query string- It can also be set as a native PHP object or array (e. g. for calls through
$modx->runSnippet
):arrayAssociative
object
- Default value: —
- Description: Merge the contents of two or more objects / arrays together into
-
extend->objects
- Description: Objects or arrays to merge. Moreover, objects can extend arrays and vice versa.
- Valid values:
array
stringJsonArray
— as JSONstringHjsonArray
— as HJSONstringQueryFormatted
— as Query string
- Required
-
extend->objects[i]
- Description: An object or array containing additional properties to merge in.
- Valid values:
object
array
- Required
-
extend->deep
- Description: If true, the merge becomes recursive (aka “deep copy”).
- Valid values:
boolean
- Default value:
true
-
extend->overwriteWithEmpty
- Description: Overwrite fields with empty values.
The following values are considered to be empty:''
— an empty string[]
— an empty array(object) []
— an empty objectNULL
- Valid values:
boolean
- Default value:
true
- Description: Overwrite fields with empty values.
-
getPropValue
- Description: This parameter allows you to return required property of an object.
- Valid values:
string
— just name of a property or array index / key to return, use asgetPropValue->name
in this case- An object of additional parameters:
stringJsonObject
— as JSONstringHjsonObject
— as HJSONstringQueryFormatted
— as Query string- It can also be set as native PHP object or array (e. g. for calls through
\DDTools\Snippet::runSnippet
or$modx->runSnippet
):arrayAssociative
object
- Default value: —
-
getPropValue->name
- Description: Object property name or array index / key to return.
You can also use'.'
to get nested properties (see\DDTools\ObjectTools::getPropValue
for more info). - Valid values:
string
- Required
- Description: Object property name or array index / key to return.
-
getPropValue->notFoundResult
- Description: What will be returned when the property is not found.
- Valid values:
mixed
- Default value:
null
outputter
- Description: Output format (when result is an object or array).
Values are case insensitive (the following values are equal:'stringjsonauto'
,'stringJsonAuto'
,'STRINGJSONAUTO'
, etc). - Valid values:
- The snippet can return object as string:
'stringJsonAuto'
—stringJsonObject
orstringJsonArray
depends on result object'stringJsonObject'
'stringJsonArray'
'stringQueryFormatted'
— Query string
- The snippet can also return object as a native PHP object or array (it is convenient to call through
\DDTools\Snippet
).'objectAuto'
—stdClass
orarray
depends on result object'objectStdClass'
—stdClass
'objectArray'
—array
- The snippet can return object as string:
- Default value:
'stringJsonAuto'
- Description: Output format (when result is an object or array).
Examples
All examples are written using HJSON, but if you want you can use vanilla JSON instead.
Merge the contents of two or more objects together into the first object (the extend
parameter)
Returns:
Get an object property
Returns: Chuck
.
Custom results when the property is not found
Returns: forever alive
.
Get an array element
Returns: Queen
.
Convert a JSON object to an array
Returns:
Run the snippet through \DDTools\Snippet::runSnippet
without DB and eval
Links
All versions of evolutioncms-snippets-ddobjecttools with dependencies
PHP Build Version
Package Version
The package dd/evolutioncms-snippets-ddobjecttools contains the following files
Loading the files please wait ....