Schemes

Introduction to Schemes

In Venddor IO, a scheme acts as a structured blueprint outlining specific object configurations. Schemes cater to a variety of objects, ranging from blocks and settings to promotions and more. These schemas are securely housed within the 'schemas' directory (...app/schemas).

Modules can both enhance and modify a scheme in full or in segments. For more detailed insights, refer to our dedicated section.

What's a Scheme?

At its core, a scheme outlines a data structure. This structure is then leveraged by another entity, which then orchestrates actions as defined by the scheme. To illustrate, 'exim' (export/import) is not strictly tied to any specific item (like a product or page). Rather, all its export/import data is meticulously defined by a scheme.

Classifications of Schemes

Schemes in Venddor IO can be grouped into three distinct types: data arrays, XML-structures, and a series of functions. It's important to note that these cannot coexist in a single script.

Data Array

Here, a scheme returns a structured array. For instance:

app/schemas/permissions/admin.php

app/schemas/clone/objects.php

app/schemas/sharing/schema.php

return array(
    'layouts' => array(
         'checked_by_default' => true,
        'function' => 'fn_clone_layouts'
    ),
    // Further code
);

XML-structure

This scheme is essentially a text file. Its content is read through the fn_get_contents function. Currently, this approach is deemed outdated and isn't a staple in the core of Venddor IO.

<menu>
    <items>
        ...
    </items>
</menu>

Set of Functions

In schemes of this type, functions are defined and described. Typically, a function-based scheme complements a data array scheme. In such cases, there's no need for separate invocation of this scheme. For stand-alone function schemes (like actions in settings), it's pulled in normally via fn_get_schema("settings", "actions.functions").

function fn_some_scheme_func1($params)
{
   ...
}

Augmenting Schemes

Schemes can be expanded using two primary methods - utilizing modules or employing editing tags.

Modules

For module-based expansion, replicate the directory and file hierarchy of the original scheme within the module's folder. Append the .post suffix to the filename. For clarity, if the main file path is:

app/schemas/permissions/admin.php

The extending file's path would be:

app/addons/seo/schemas/permissions/admin.post.php

During the extension phase, the $schema variable is passed, already filled with data from the main scheme. This script then interacts with this variable and returns it.

// $schema already has the main scheme's data
$schema['news'] = array(
    'modes' => array(
        'manage' => array(
            'permissions' => 'manage_news'
        )
    )
);
return $schema;

Editing Tags

Editing tags enable scheme augmentation based on Venddor IO editions. To achieve this, you'd generate a schema_[PRODUCT_EDITION] file in the schema directory. The $schema variable plays a role here as well, and the script finally returns it.

Retrieving Scheme Data

Harness the fn_get_schema function to obtain data:

function fn_get_schema($schema_dir, $name, $type = 'php', $force_addon_init = false)

When invoking this function, it constructs the entire scheme tree, inclusive of module-related schemes.

$menu = fn_get_schema('menu', 'menu', 'php');

In essence, Venddor IO's scheme system, with its structured approach, ensures developers have the necessary tools and flexibility to customize and extend functionalities seamlessly.