承接 digitaladapt/magento-vigilant-form-kit 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

digitaladapt/magento-vigilant-form-kit

Composer 安装命令:

composer require digitaladapt/magento-vigilant-form-kit

包简介

Magento Module for VigilantForm.

README 文档

README

Magento Module for VigilantForm.

So what is this?

A Magento Module to make it easy to push form submissions into an instance of VigilantForm.

So how is it used?

First you add the library:

composer require digitaladapt/magento-vigilant-form-kit

Then setup a config file vigilantform.json in the root of your Magento installation: website and form_title will default to hostname and "submit" respectively.

{
  "url":          "<SERVER_URL>",
  "clientId":     "<CLIENT_ID>",
  "secret":       "<CLIENT_SECRET>",
  "prefix":       null,
  "honeypot":     null,
  "sequence":     null,
  "script_src":   null,
  "script_class": null,
  "website":      null,
  "form_title":   null
}

Then use dependency injection to get the \VigilantForm\MagentoKit\VigilantFormMagentoKit class into whatever block or controller which has the form you want to validate.

// SomeBlock.php
<?php

namespace SomeVendor\SomeModule\Block;

class SomeBlock extends \Magento\Framework\View\Element\Template
{
    protected $vfmk;

    public function __construct(\VigilantForm\MagentoKit\VigilantFormMagentoKit $vfmk)
    {
        $this->vfmk = $vfmk;
    }

    public function getVFMK()
    {
        return $this->vfmk;
    }
}

Within the form template you call generateHoneypot() within the html form:

// some_block.phtml
<?php /** @var \SomeVendor\SomeModule\Block\SomeBlock $block */ ?>
<form>
<?php echo $block->getVFMK()->generateHoneypot(); ?>
</form>

If a page has multiple forms within a single page, you may call generateHoneypot('form') within the html form, so long as you also call generateHoneypot('code'), after the last form, (this is not required, but can provide a performance boost to page loads):

// some_block.phtml
<?php /** @var \SomeVendor\SomeModule\Block\SomeBlock $block */ ?>
<form>
<?php echo $block->getVFMK()->generateHoneypot('form'); ?>
</form>

<form>
<?php echo $block->getVFMK()->generateHoneypot('form'); ?>
</form>

<?php echo $block->getVFMK()->generateHoneypot('code'); ?>

When handling form submissions, you also dependency inject the VigilantFormMagentoKit class, which has the submitForm() function. If the submission fails to be stored, it will throw an UnexpectedValueException.

    $params = $this->getRequest()->getPost();
    try {
        $this->vfmk->submitForm($params);
    } catch (\UnexpectedValueException $exception) {
        /* do something, in the event failed to store form submission */
    }

Finally, redeploy your Magento website to detect the new module and recompile the dependency injection.

统计信息

  • 总下载量: 599
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-07-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固