Skip to content

Commit 1dc2c0f

Browse files
committed
Version 0.6
2 parents 9060ff1 + ed4cd3e commit 1dc2c0f

7 files changed

Lines changed: 44 additions & 23 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# (MODX)EvolutionCMS.snippets.ddObjectTools changelog
22

33

4+
## Version 0.6 (2023-03-08)
5+
* \+ Parameters → `extend->objects`: Can also be set as [JSON](https://en.wikipedia.org/wiki/JSON), [HJSON](https://hjson.github.io/) or [Query string](https://en.wikipedia.org/wiki/Query_string).
6+
7+
48
## Version 0.5 (2021-11-08)
59
* \* Attention! (MODX)EvolutionCMS.libraries.ddTools >= 0.51 is required.
610
* \+ Parameters → `outputter`: The new parameter. Allows to forcibly convert the snippet result into a JSON object/array or URL-encoded query string if needed.

CHANGELOG_ru.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# (MODX)EvolutionCMS.snippets.ddObjectTools changelog
22

33

4+
## Версия 0.6 (2023-03-08)
5+
* \+ Параметры → `extend->objects`: Также может быть задан, как [JSON](https://ru.wikipedia.org/wiki/JSON), [HJSON](https://hjson.github.io/) или [Query string](https://en.wikipedia.org/wiki/Query_string).
6+
7+
48
## Версия 0.5 (2021-11-08)
59
* \* Внимание! Требуется (MODX)EvolutionCMS.libraries.ddTools >= 0.51.
610
* \+ Параметры → `outputter`: Новый параметр. Позволяет принудительно преобразовать результат сниппета в JSON объект/массив или URL-кодированную строку запроса, если это необходимо.

README.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,29 @@ Tools for modifying objects.
1010
* [(MODX)EvolutionCMS.libraries.ddTools](https://code.divandesign.biz/modx/ddtools) >= 0.51
1111

1212

13-
## Documentation
1413

14+
## Installation
1515

16-
### Installation
1716

17+
### Manually
1818

19-
#### Manually
2019

21-
22-
##### 1. Elements → Snippets: Create a new snippet with the following data
20+
#### 1. Elements → Snippets: Create a new snippet with the following data
2321

2422
1. Snippet name: `ddObjectTools`.
25-
2. Description: `<b>0.5</b> Tools for modifying objects.`.
23+
2. Description: `<b>0.6</b> Tools for modifying objects.`.
2624
3. Category: `Core`.
2725
4. Parse DocBlock: `no`.
2826
5. Snippet code (php): Insert content of the `ddObjectTools_snippet.php` file from the archive.
2927

3028

31-
##### 2. Elements → Manage Files
29+
#### 2. Elements → Manage Files
3230

3331
1. Create a new folder `assets/snippets/ddObjectTools/`.
3432
2. Extract the archive to the folder (except `ddObjectTools_snippet.php`).
3533

3634

37-
#### Using [(MODX)EvolutionCMS.libraries.ddInstaller](https://github.com/DivanDesign/EvolutionCMS.libraries.ddInstaller)
35+
### Using [(MODX)EvolutionCMS.libraries.ddInstaller](https://github.com/DivanDesign/EvolutionCMS.libraries.ddInstaller)
3836

3937
Just run the following PHP code in your sources or [Console](https://github.com/vanchelo/MODX-Evolution-Ajax-Console):
4038

@@ -56,7 +54,7 @@ require_once(
5654
* If `ddObjectTools` is already exist on your site, `ddInstaller` will check it version and update it if needed.
5755

5856

59-
### Parameters description
57+
## Parameters description
6058

6159
* `sourceObject`
6260
* Desctription: Source object or array.
@@ -84,7 +82,11 @@ require_once(
8482

8583
* `extend->objects`
8684
* Desctription: Objects or arrays to merge. Moreover, objects can extend arrays and vice versa.
87-
* Valid values: `array`
85+
* Valid values:
86+
* `array`
87+
* `stringJsonArray` — as [JSON](https://en.wikipedia.org/wiki/JSON)
88+
* `stringHjsonArray` — as [HJSON](https://hjson.github.io/)
89+
* `stringQueryFormated` — as [Query string](https://en.wikipedia.org/wiki/Query_string)
8890
* **Required**
8991

9092
* `extend->objects[i]`
@@ -125,10 +127,10 @@ require_once(
125127
* Default value: `'jsonAuto'`
126128

127129

128-
### Examples
130+
## Examples
129131

130132

131-
#### Merge the contents of two or more objects together into the first object (the `extend` parameter)
133+
### Merge the contents of two or more objects together into the first object (the `extend` parameter)
132134

133135
```
134136
[[ddObjectTools?
@@ -168,7 +170,7 @@ Returns:
168170
```
169171

170172

171-
#### Get an object property
173+
### Get an object property
172174

173175
```
174176
[[ddObjectTools?
@@ -183,7 +185,7 @@ Returns:
183185
Returns: `Chuck`.
184186

185187

186-
#### Get an array element
188+
### Get an array element
187189

188190
```
189191
[[ddObjectTools?
@@ -199,7 +201,7 @@ Returns: `Chuck`.
199201
Returns: `Queen`.
200202

201203

202-
#### Convert a JSON object to an array
204+
### Convert a JSON object to an array
203205

204206
```
205207
[[ddObjectTools?
@@ -221,7 +223,7 @@ Returns:
221223
```
222224

223225

224-
#### Run the snippet through `\DDTools\Snippet::runSnippet` without DB and eval
226+
### Run the snippet through `\DDTools\Snippet::runSnippet` without DB and eval
225227

226228
```php
227229
//Include (MODX)EvolutionCMS.libraries.ddTools

README_ru.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
##### 1. Элементы → Сниппеты: Создайте новый сниппет со следующими параметрами
2323

2424
1. Название сниппета: `ddObjectTools`.
25-
2. Описание: `<b>0.5</b> Tools for modifying objects.`.
25+
2. Описание: `<b>0.6</b> Tools for modifying objects.`.
2626
3. Категория: `Core`.
2727
4. Анализировать DocBlock: `no`.
2828
5. Код сниппета (php): Вставьте содержимое файла `ddObjectTools_snippet.php` из архива.
@@ -84,7 +84,11 @@ require_once(
8484

8585
* `extend->objects`
8686
* Описание: Объекты или массивы для объединения. Кроме того, объекты могут расширять массивы и наоборот.
87-
* Допустимые значения: `array`
87+
* Допустимые значения:
88+
* `array`
89+
* `stringJsonArray` — в виде [JSON](https://ru.wikipedia.org/wiki/JSON)
90+
* `stringHjsonArray` — в виде [HJSON](https://hjson.github.io/)
91+
* `stringQueryFormated` — в виде [Query string](https://en.wikipedia.org/wiki/Query_string)
8892
* **Обязателен**
8993

9094
* `extend->objects[i]`

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "dd/evolutioncms-snippets-ddobjecttools",
33
"type": "modxevo-snippet",
4-
"version": "0.5.0",
4+
"version": "0.6.0",
55
"description": "Tools for modifying objects.",
66
"keywords": [
77
"modx",

ddObjectTools_snippet.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
/**
33
* ddObjectTools
4-
* @version 0.5 (2021-11-08)
4+
* @version 0.6 (2023-03-08)
55
*
66
* @see README.md
77
*
88
* @link https://code.divandesign.biz/modx/ddobjecttools
99
*
10-
* @copyright 2020–2021 DD Group {@link https://DivanDesign.biz }
10+
* @copyright 2020–2023 DD Group {@link https://DivanDesign.biz }
1111
*/
1212

1313
//Include (MODX)EvolutionCMS.libraries.ddTools

src/Snippet.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class Snippet extends \DDTools\Snippet {
55
protected
6-
$version = '0.5.0',
6+
$version = '0.6.0',
77

88
$params = [
99
//Defaults
@@ -20,7 +20,7 @@ class Snippet extends \DDTools\Snippet {
2020

2121
/**
2222
* run
23-
* @version 1.0 (2021-04-28)
23+
* @version 1.1 (2023-03-08)
2424
*
2525
* @return {string}
2626
*/
@@ -37,6 +37,13 @@ public function run(){
3737

3838
//If is valid
3939
if (!empty($this->params->extend)){
40+
if (!is_array($this->params->extend['objects'])){
41+
$this->params->extend['objects'] = \DDTools\ObjectTools::convertType([
42+
'object' => $this->params->extend['objects'],
43+
'type' => 'objectArray'
44+
]);
45+
}
46+
4047
array_unshift(
4148
$this->params->extend['objects'],
4249
$this->params->sourceObject

0 commit comments

Comments
 (0)