PHP code example of emaphp / magento2-module-vuewidget
1. Go to this page and download the library: Download emaphp/magento2-module-vuewidget 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/ */
emaphp / magento2-module-vuewidget example snippets
// File: Block/Widget/VueBlockExample.php
namespace Vue\Widget\Block\Widget;
use Magento\Framework\View\Element\Template;
use Magento\Widget\Block\BlockInterface;
use Vue\Widget\Logger\Logger;
class VueBlockExample extends Template implements BlockInterface {
protected $logger;
public function __construct(
Template\Context $context,
Logger $logger,
array $data = []
) {
$this->logger = $logger;
parent::__construct($context, $data);
}
public function getCustomerName() {
$this->logger->debug('Getting customer name...');
return 'Guest';
}
}
// File: Block/Widget/DataProviderExample.php
namespace Vue\Widget\Block\Widget;
use Magento\Framework\View\Element\Template;
use Magento\Widget\Block\BlockInterface;
use Vue\Widget\Logger\Logger;
class DataProviderExample extends Template implements BlockInterface {
public function __construct(
Template\Context $context,
Logger $logger,
array $data = []
) {
$this->logger = $logger;
parent::__construct($context, $data);
}
public function getCategories() {
return [
'Pants',
'T-Shirts',
'Shoes',
'Ties'
];
}
public function getAuthor() {
return [
'name' => "Emma",
'role' => "Developer",
'github' => "https://github.com/emaphp",
];
}
}