PHP code example of vaersaagod / linkmate
1. Go to this page and download the library: Download vaersaagod/linkmate 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/ */
vaersaagod / linkmate example snippets
use craft\commerce\elements\Product;
use vaersaagod\linkmate\LinkMate as LinkPlugin;
use vaersaagod\linkmate\events\LinkTypeEvent;
use vaersaagod\linkmate\models\ElementLinkType;
use yii\base\Event;
/**
* Custom module class.
*/
class Module extends \yii\base\Module
{
public function init() {
parent::init();
Event::on(
LinkPlugin::class,
LinkPlugin::EVENT_REGISTER_LINK_TYPES,
function(LinkTypeEvent $event) {
$event->linkTypes['product'] = new ElementLinkType(Product::class);
}
);
}
}