PHP code example of salesrender / plugin-component-info
1. Go to this page and download the library: Download salesrender/plugin-component-info 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/ */
salesrender / plugin-component-info example snippets
public function __construct(string $type)
public function __construct(string $name, string $email, string $hostname = null)
use SalesRender\Plugin\Components\Info\Info;
use SalesRender\Plugin\Components\Info\PluginType;
use SalesRender\Plugin\Components\Info\Developer;
Info::config(
new PluginType(PluginType::MACROS),
'Excel Export',
'This plugin can be used for exporting your orders to Excel',
[
'class' => 'exporter',
'entity' => 'order',
],
new Developer(
'Example Company',
'[email protected]',
'example.com',
)
);
use SalesRender\Plugin\Components\Info\Info;
use SalesRender\Plugin\Components\Info\PluginType;
use SalesRender\Plugin\Components\Info\Developer;
use SalesRender\Plugin\Components\Translations\Translator;
Info::config(
new PluginType(PluginType::LOGISTIC),
fn() => Translator::get('info', 'Example logistic'),
fn() => Translator::get('info', 'Example **logistic** description'),
[
'class' => 'delivery',
'entity' => 'order',
'currency' => ['RUB'],
'codename' => 'SR_LOGISTIC_EXAMPLE',
],
new Developer(
'Example company',
'[email protected]',
'example.com',
)
);
use SalesRender\Plugin\Components\Info\Info;
use SalesRender\Plugin\Components\Info\PluginType;
use SalesRender\Plugin\Components\Info\Developer;
use SalesRender\Plugin\Components\Translations\Translator;
Info::config(
new PluginType(PluginType::CHAT),
fn() => Translator::get('info', 'Example chat plugin'),
fn() => Translator::get('info', 'This plugin created only for demo purposes'),
[
'contactType' => 'telegram',
'capabilities' => [
'subject' => true,
'typing' => false,
'messages' => [
'formats' => ['text'],
'incoming' => true,
'outgoing' => true,
'writeFirst' => true,
'statuses' => ['sent', 'delivered', 'read', 'error'],
],
'attachments' => ['image', 'file'],
],
],
new Developer(
'LEADVERTEX',
'[email protected]',
'salesrender.com',
)
);
use SalesRender\Plugin\Components\Info\Info;
use SalesRender\Plugin\Components\Info\PluginType;
use SalesRender\Plugin\Components\Info\Developer;
use SalesRender\Plugin\Components\Translations\Translator;
Info::config(
new PluginType(PluginType::PBX),
fn() => Translator::get('info', 'Plugin name'),
fn() => Translator::get('info', 'Plugin markdown description'),
[
'class' => 'SIP',
'entity' => 'UNSPECIFIED',
'currency' => 'USD',
'pricing' => [
'encryption' => '0.01',
'record' => '0.005',
],
'codename' => 'SR_PBX_EXAMPLE',
],
new Developer(
'Your (company) name',
'[email protected]',
'example.com',
)
);
use SalesRender\Plugin\Components\Info\Info;
$info = Info::getInstance();
// Get individual fields
echo $info->getName(); // "Excel Export" (or resolved callable result)
echo $info->getDescription(); // "This plugin can be used for..."
echo $info->getType()->get(); // "MACROS"
// Get extra data
$extra = $info->getExtra();
// Get developer info
$developer = $info->getDeveloper();
echo $developer->getName(); // "Example Company"
echo $developer->getEmail(); // "[email protected]"
echo $developer->getHostname(); // "example.com"
// Serialize to JSON (used by the /info endpoint)
echo json_encode($info);