Skip to content

Commit

Permalink
Version 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronef committed Apr 27, 2021
2 parents 495e624 + 0e782bd commit e5913a8
Show file tree
Hide file tree
Showing 8 changed files with 408 additions and 165 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
# (MODX)EvolutionCMS.snippets.ddStash changelog


## Version 1.3 (2021-04-28)
* \* Attention! PHP >= 5.6 is required.
* \* Attention! (MODX)EvolutionCMS.libraries.ddTools >= 0.49.1 is required.
* \+ Parameters → `save`: Can also be set as [HJSON](https://hjson.github.io/) or as a native PHP object or array (e. g. for calls through `$modx->runSnippet`).
* \+ You can just call `\DDTools\Snippet::runSnippet` to run the snippet without DB and eval (see README → Examples).
* \+ `\ddStash\Snippet`: The new class. All snippet code was moved here.
* \* README:
* \* Documentation:
* \+ Installation → Using (MODX)EvolutionCMS.libraries.ddInstaller.
* \* Examples: Fixed wrong JSON format.
* \+ Links.
* \* Composer.json:
* \+ `homepage`.
* \+ `support`
* \+ `authors`.
* \* `require` → `dd/evolutioncms-libraries-ddtools`: Fixed outdated name.


## Version 1.2.1 (2020-05-08)
* \* When you try to get non existent elements, an empty string will be returned.

Expand Down
20 changes: 19 additions & 1 deletion CHANGELOG_ru.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
# (MODX)EvolutionCMS.snippets.ddStash changelog


## Version 1.2.1 (2020-05-08)
## Версия 1.3 (2021-04-28)
* \* Внимание! Требуется PHP >= 5.6.
* \* Внимание! Требуется (MODX)EvolutionCMS.libraries.ddTools >= 0.49.1.
* \+ Параметры → `save`: Также может быть задан, как [HJSON](https://hjson.github.io/) или как нативный PHP объект или массив (например, для вызовов через `$modx->runSnippet`).
* \+ Запустить сниппет без DB и eval можно через `\DDTools\Snippet::runSnippet` (см. примеры в README).
* \+ `\ddStash\Snippet`: Новый класс. Весь код сниппета перенесён туда.
* \* README:
* \* Документация:
* \+ Установка → Используя (MODX)EvolutionCMS.libraries.ddInstaller.
* \* Примеры: Исправлен некорректный формат JSON.
* \+ Ссылки.
* \* Composer.json:
* \+ `homepage`.
* \+ `support`
* \+ `authors`.
* \* `require` → `dd/evolutioncms-libraries-ddtools`: Исправлено устаревшее название библиотеки.


## Версия 1.2.1 (2020-05-08)
* \* При попытке получить несуществующий элемент будет возвращена пустая строка.


Expand Down
84 changes: 73 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,68 @@ Save data as [JSON](https://en.wikipedia.org/wiki/JSON) or [Query string](https:

## Requires

* PHP >= 5.4
* PHP >= 5.6
* [(MODX)EvolutionCMS](https://github.com/evolution-cms/evolution) >= 1.1
* [(MODX)EvolutionCMS.libraries.ddTools](http://code.divandesign.biz/modx/ddtools) >= 0.34
* [(MODX)EvolutionCMS.libraries.ddTools](http://code.divandesign.biz/modx/ddtools) >= 0.49.1


## Documentation


### Installation

Elements → Snippets: Create a new snippet with the following data:

#### Manually


##### 1. Elements → Snippets: Create a new snippet with the following data

1. Snippet name: `ddStash`.
2. Description: `<b>1.2.1</b> Save data as JSON or QueryString, then extend if needed and use it later without database queries.`.
2. Description: `<b>1.3</b> Save data as JSON or QueryString, then extend if needed and use it later without database queries.`.
3. Category: `Core`.
4. Parse DocBlock: `no`.
5. Snippet code (php): Insert content of the `ddStash_snippet.php` file from the archive.


###### 2. Elements → Manage Files

1. Create a new folder `assets/snippets/ddStash/`.
2. Extract the archive to the folder (except `ddStash_snippet.php`).


#### Using [(MODX)EvolutionCMS.libraries.ddInstaller](https://github.com/DivanDesign/EvolutionCMS.libraries.ddInstaller)

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

```php
//Include (MODX)EvolutionCMS.libraries.ddInstaller
require_once(
$modx->getConfig('base_path') .
'assets/libs/ddInstaller/require.php'
);

//Install (MODX)EvolutionCMS.snippets.ddStash
\DDInstaller::install([
'url' => 'https://github.com/DivanDesign/EvolutionCMS.snippets.ddStash',
'type' => 'snippet'
]);
```

* If `ddStash` is not exist on your site, `ddInstaller` will just install it.
* If `ddStash` is already exist on your site, `ddInstaller` will check it version and update it if needed.


### Parameters description

* `save`
* Desctription: Data to save in stash. Nested objects are supported too, see examples below.
* Valid values:
* `stirngJsonObject` — as [JSON](https://en.wikipedia.org/wiki/JSON)
* `stringJsonObject` — as [JSON](https://en.wikipedia.org/wiki/JSON)
* `stringHjsonObject` — as [HJSON](https://hjson.github.io/)
* `stringQueryFormated` — as [Query string](https://en.wikipedia.org/wiki/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: —

* `save_extendExisting`
Expand Down Expand Up @@ -312,9 +348,9 @@ Returns:

```json
{
"firstName" => "Nikola",
"lastName" => "",
"discipline" => "Electrical engineering"
"firstName": "Nikola",
"lastName": "",
"discipline": "Electrical engineering"
}
```

Expand Down Expand Up @@ -348,11 +384,37 @@ Returns:

```json
{
"firstName" => "Nikola",
"lastName" => "Tesla",
"discipline" => "Electrical engineering"
"firstName": "Nikola",
"lastName": "Tesla",
"discipline": "Electrical engineering"
}
```


#### Run the snippet through `\DDTools\Snippet::runSnippet` without DB and eval

```php
//Include (MODX)EvolutionCMS.libraries.ddTools
require_once(
$modx->getConfig('base_path') .
'assets/libs/ddTools/modx.ddtools.class.php'
);

//Run (MODX)EvolutionCMS.snippets.ddStash
\DDTools\Snippet::runSnippet([
'name' => 'ddStash',
'params' => [
'get' => 'userData.firstName'
]
]);
```


## Links

* [Home page](https://code.divandesign.biz/modx/ddstash)
* [Telegram chat](https://t.me/dd_code)
* [Packagist](https://packagist.org/packages/dd/evolutioncms-snippets-ddstash)


<link rel="stylesheet" type="text/css" href="https://DivanDesign.ru/assets/files/ddMarkdown.css" />
86 changes: 74 additions & 12 deletions README_ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,68 @@

## Использует

* PHP >= 5.4
* PHP >= 5.6
* [(MODX)EvolutionCMS](https://github.com/evolution-cms/evolution) >= 1.1
* [(MODX)EvolutionCMS.libraries.ddTools](http://code.divandesign.biz/modx/ddtools) >= 0.34
* [(MODX)EvolutionCMS.libraries.ddTools](http://code.divandesign.biz/modx/ddtools) >= 0.49.1


## Документация


### Установка

Элементы → Сниппеты: Создайте новый сниппет со следующими параметрами:

#### Вручную


##### 1. Элементы → Сниппеты: Создайте новый сниппет со следующими параметрами

1. Название сниппета: `ddStash`.
2. Описание: `<b>1.2.1</b> Сохраняйте данные в формате JSON или QueryString, затем расширяйте по необходимости и используйте позже без запросов к базе данных.`.
2. Описание: `<b>1.3</b> Сохраняйте данные в формате JSON или QueryString, затем расширяйте по необходимости и используйте позже без запросов к базе данных.`.
3. Категория: `Core`.
4. Анализировать DocBlock: `no`.
5. Код сниппета (php): Вставьте содержимое файла `ddStash_snippet.php` из архива.


##### 2. Элементы → Управление файлами

1. Создайте новую папку `assets/snippets/ddStash/`.
2. Извлеките содержимое архива в неё (кроме файла `ddStash_snippet.php`).


#### Используя [(MODX)EvolutionCMS.libraries.ddInstaller](https://github.com/DivanDesign/EvolutionCMS.libraries.ddInstaller)

Просто вызовите следующий код в своих исходинках или модуле [Console](https://github.com/vanchelo/MODX-Evolution-Ajax-Console):

```php
//Подключение (MODX)EvolutionCMS.libraries.ddInstaller
require_once(
$modx->getConfig('base_path') .
'assets/libs/ddInstaller/require.php'
);

//Установка (MODX)EvolutionCMS.snippets.ddStash
\DDInstaller::install([
'url' => 'https://github.com/DivanDesign/EvolutionCMS.snippets.ddStash',
'type' => 'snippet'
]);
```

* Если `ddStash` отсутствует на вашем сайте, `ddInstaller` просто установит его.
* Если `ddStash` уже есть на вашем сайте, `ddInstaller` проверит его версию и обновит, если нужно.


### Описание параметров

* `save`
* Описание: Сохранить данные в хранилище для последующего использования. Вложенные объекты также поддерживаются, см. примеры ниже.
* Допустимые значения:
* `stirngJsonObject` — в виде [JSON](https://ru.wikipedia.org/wiki/JSON)
* `stringQueryFormated` — в виде [Query string](https://ru.wikipedia.org/wiki/Query_string)
* `stringJsonObject` — в виде [JSON](https://ru.wikipedia.org/wiki/JSON)
* `stringHjsonObject` — в виде [HJSON](https://hjson.github.io/)
* `stringQueryFormated` — в виде [Query string](https://en.wikipedia.org/wiki/Query_string)
* Также может быть задан, как нативный PHP объект или массив (например, для вызовов через `$modx->runSnippet`).
* `arrayAssociative`
* `object`
* Значение по умолчанию: —

* `save_extendExisting`
Expand Down Expand Up @@ -312,9 +348,9 @@

```json
{
"firstName" => "Никола",
"lastName" => "",
"discipline" => "Электротехника"
"firstName": "Никола",
"lastName": "",
"discipline": "Электротехника"
}
```

Expand Down Expand Up @@ -348,11 +384,37 @@

```json
{
"firstName" => "Никола",
"lastName" => "Тесла",
"discipline" => "Электротехника"
"firstName": "Никола",
"lastName": "Тесла",
"discipline": "Электротехника"
}
```


#### Запустить сниппет через `\DDTools\Snippet::runSnippet` без DB и eval

```php
//Подключение (MODX)EvolutionCMS.libraries.ddTools
require_once(
$modx->getConfig('base_path') .
'assets/libs/ddTools/modx.ddtools.class.php'
);

//Запуск (MODX)EvolutionCMS.snippets.ddStash
\DDTools\Snippet::runSnippet([
'name' => 'ddStash',
'params' => [
'get' => 'userData.firstName'
]
]);
```


## Ссылки

* [Home page](https://code.divandesign.biz/modx/ddstash)
* [Telegram chat](https://t.me/dd_code)
* [Packagist](https://packagist.org/packages/dd/evolutioncms-snippets-ddstash)


<link rel="stylesheet" type="text/css" href="https://DivanDesign.ru/assets/files/ddMarkdown.css" />
24 changes: 21 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dd/evolutioncms-snippets-ddstash",
"type": "modxevo-snippet",
"version": "1.2.1",
"version": "1.3.0",
"description": "Save data as JSON or QueryString, then extend if needed and use it later without database queries.",
"keywords": [
"modx",
Expand All @@ -13,8 +13,26 @@
"ddstash",
"stash"
],
"homepage": "https://code.divandesign.biz/modx/ddstash",
"support": {
"chat": "https://t.me/dd_code"
},
"authors": [
{
"name": "DD Group",
"email": "[email protected]",
"homepage": "https://code.divandesign.biz",
"role": "Owner"
},
{
"name": "Ilyas Ronef",
"email": "[email protected]",
"homepage": "https://ronef.ru",
"role": "Developer"
}
],
"require": {
"php": ">=5.4.0",
"dd/modxevo-library-ddtools": ">=0.34.0"
"php": ">=5.6.0",
"dd/evolutioncms-libraries-ddtools": ">=0.49.1"
}
}
Loading

0 comments on commit e5913a8

Please sign in to comment.