定制 polifonic/twig-validator-extension 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

polifonic/twig-validator-extension

Composer 安装命令:

composer require polifonic/twig-validator-extension

包简介

A Twig extension to validate objects inside a Twig template

README 文档

README

A simple Twig extension that adds a valid filter to be used in twig templates.

With this filter you can test if objects are valid inside a twig template and generate the appropriate markup based on the result.

Installation

Add the package to your app's composer.json:

	"require": {

	    "polifonic/twig-validator-extension": "^1.0",
	}

As a Twig Extension

Create an instance of TwigValidatorExtension and add it to the Twig environment just like any other twig extension.

The TwigValidatorExtension constructor needs to be passed a validator (an instance of Symfony\Component\Validator\Validator\ValidatorInterface).

use Polifonic\Twig\Extension\Validator\TwigValidatorExtension;

$validator = ...;

$twig = new Twig_Environment($loader);

$twig->addExtension(new TwigValidatorExtension($validator));

As a Symfony bundle

The package includes a Symfony bundle named TwigValidatorBundle. This bundle will automatically add the TwigValidatorExtension to twig.

Enable the TwigValidatorBundle symfony bundle by adding it to your app's kernel:

# app/AppKernel.php

public function regsiterBundles()
{
	$bundles = array(
		...
        new Polifonic\Twig\Extension\Validator\Symfony\TwigValidatorBundle(),
	);
}

Usage

{% if object|valid %}...{% endif %}

With validation groups:

{% if object|valid([ "group1", "group2" ]) %}...{% endif %}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-10-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固