Resource Storage

This package is used to store responses generated by the Form Synergy PHP web API as a resource. Furthermore.

Creating a resource storage

                            
use \FormSynergy\Init as FS;

/**
 * Create a new resource storage for 'example'
 */
$resource = FS::Resource('example');
 
                            

Store data within a resource

                            
use \FormSynergy\Init as FS;

/**
 * Create a new resource storage for 'website'
 */
$resource = FS::Resource('website');

 
/**
 * Store website data within the same resource
 */
$resources->Store('website')->Data($array);

 
                            

Finding data

                            
use \FormSynergy\Init as FS;

/**
 * Create a new resource storage for 'example'
 */
$resource = FS::Resource('example');

 
/**
 * Store example data within the same resource
 */
$example_data [
    'main' => [
        'label' => 'Test label',
        'children' => [
            'properties' => [
                'a' => 'This is a',
                'b' => 'This is b'
            ]
        ]
    ]
];

$resources->Store('data')->Data($example_data);

/**
 * Finding data
 */
$main = $resource->Find('main')->In('data');

$children = $resource->Find('children')->In('data');

$properties = $resource->Find('children', 'properties')->In('data');

$a = $resource->Find('children', 'properties')->In('data')['a'];

$b = $resource->Find('children', 'properties')->In('data')['b'];
 

                            

Update data

                            
use \FormSynergy\Init as FS;

/**
 * Create a new resource storage for 'website'
 */
 $resource = FS::Resource('website');

 
/**
 * Store website data within the same resource
 */
$array = [
    'domain' => 'https://example.formsynergy.com/',
    'name' => 'Form Synergy Example',
    'proto' => 'https',
    'indexpage' => '/'
];

 $resources->Store('website')->Data($array);


/**
 * Update website.
 */
 $verification = [
     'verified' => 'yes'
 ];
 $resources->Update('website')->Data($verification);
                            

Storing modules

                            
use \FormSynergy\Init as FS;

/**
 * Create a new resource storage for 'example'
 */
$resource = FS::Resource('example');

/**
 * Important notes regarding localized modules
 * They need to be stored with the module id as file name.
 * The html contents are base64 encoded.
 */

// Use the StoreModule method to store html files. 
$resource->StoreModule(
        $module['moduleid'], 
        base64_decode( $module['html']) 
);