PHP code example of jeyroik / extas-repo-toolkit

1. Go to this page and download the library: Download jeyroik/extas-repo-toolkit library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jeyroik / extas-repo-toolkit example snippets


return [
    //...,
    'tables' => [
        "my_entities" => [
            "namespace" => "repositories",
            "item_class" => "\\myvendor\\components\\myentities\\MyEntity",
            "pk" => "id",
            "code" => [
                
            ]
        ],
    ]
];

use extas\components\repositories\tools\RepoItem
return [
    //...,
    'tables' => [
        "my_entities" => [
            "namespace" => "repositories",
            "item_class" => "\\myvendor\\components\\myentities\\MyEntity",
            "pk" => "id",
            "code" => [
                // if your item implements extas\interfaces\IHaveUUID, if not, please use ::setUuid($item, 'id_field_name')
                "create-before" => '\\' . RepoItem::class . '::setId($item);'
            ]
        ],
    ]
];

use extas\components\repositories\tools\RepoItem
return [
    //...,
    'tables' => [
        "my_entities" => [
            "namespace" => "repositories",
            "item_class" => "\\myvendor\\components\\myentities\\MyEntity",
            "pk" => "id",
            "code" => [
                "create-before" => '\\' . RepoItem::class . '::throwIfExist($this, $item, [\'fieldName\']);'
            ]
        ],
    ]
];

use extas\components\repositories\tools\RepoItem
return [
    //...,
    'tables' => [
        "my_entities" => [
            "namespace" => "repositories",
            "item_class" => "\\myvendor\\components\\myentities\\MyEntity",
            "pk" => "id",
            "code" => [
                "create-before" => '\\' . RepoItem::class . '::

use extas\components\repositories\tools\RepoItem
return [
    //...,
    'tables' => [
        "my_entities" => [
            "namespace" => "repositories",
            "item_class" => "\\myvendor\\components\\myentities\\MyEntity",
            "pk" => "id",
            "code" => [
                "create-before" => '\\' . RepoItem::class . '::sha1($item, [\'fieldName\']);'
            ]
        ],
    ]
];

use extas\components\repositories\tools\RepoItem
return [
    //...,
    'tables' => [
        "my_entities" => [
            "namespace" => "repositories",
            "item_class" => "\\myvendor\\components\\myentities\\MyEntity",
            "pk" => "id",
            "code" => [
                // openssl with key encrypting is used by default, you can determ another way by passing third param
                // see Encryption section below
                "create-before" => '\\' . RepoItem::class . '::encrypt($item, [\'fieldName\']);',
                "one-after" => '\\' . RepoItem::class . '::decrypt($item, [\'fieldName\'])'
            ]
        ],
    ]
];

use extas\components\repositories\tools\RepoItem
return [
    //...,
    'tables' => [
        "my_entities" => [
            "namespace" => "repositories",
            "item_class" => "\\myvendor\\components\\myentities\\MyEntity",
            "pk" => "id",
            "code" => [
                "create-before" => '\\' . RepoItem::class . '::multiple($this, $item, [\'setId\' => '',...]);'
            ]
        ],
    ]
];

//resources/multicheck.php
/*
 * @var IItem $item
 * @var IRepository $this
 */

return RepoItem::multiple($this, $item, [
    'setId' => ['field1'],
    '[
        "my_entities" => [
            "namespace" => "repositories",
            "item_class" => "\\myvendor\\components\\myentities\\MyEntity",
            "pk" => "id",
            "code" => [
                "create-before" => Injector::get('/resources/multicheck')
            ]
        ],
    ]
];