我用树枝过滤器url_encode编码了url参数。
// app.request.query.get("date") output 01/04/2016
href="{{ path('page', {date: app.request.query.get("date")|url_encode}) }}">
Run Code Online (Sandbox Code Playgroud)
网址中的哪个输出
date=01%252F04%252F2016
Run Code Online (Sandbox Code Playgroud)
因此,在具有url参数的请求页面中
{{ app.request.query.get("date") }}
Run Code Online (Sandbox Code Playgroud)
显示01%2F04%2F2016但我想拥有01/04/2016
我尝试使用原始过滤器,还做了一个树枝扩展:
<?php
namespace SE\AppBundle\Twig;
class htmlEntityDecodeExtension extends \Twig_Extension
{
public function getFilters()
{
return array(
new \Twig_SimpleFilter('html_entity_decode', array($this, 'htmlEntityDecode'))
);
}
public function htmlEntityDecode($html)
{
$html = html_entity_decode($html);
return $html;
}
public function getName()
{
return 'html_entity_decode_extension';
}
}
Run Code Online (Sandbox Code Playgroud)
但是即使这样,它仍然会显示01%2F04%2F2016
在我的控制器方法中,我得到了相同的结果:
echo html_entity_decode($request->query->get('date'));
Run Code Online (Sandbox Code Playgroud)
正确的方法是什么?
更新:
日期来自“文本”类型的输入。不,这是一个带有数字和/的简单字符串。
所以我创建了一个自定义插件并实现了单元测试。
到目前为止,添加 WooCommerce 依赖项和私有插件依赖项(Iconic Plugin)很容易。
问题是 Iconic 插件依赖于 WooCommerce。在每次测试时,它都认为 WooCommerce 未激活。
因此,它无法正确实例化。
标志性插件
class Iconic_Private_Plugin() {
/**
* Constructor
*/
public function __construct() {
public $bar;
if ( ! Iconic_Private_Core_Helpers::is_plugin_active( 'woocommerce/woocommerce.php' ) && ! Iconic_Private_Core_Helpers::is_plugin_active( 'woocommerce-old/woocommerce.php' ) ) {
return;
// It stops right here!!!
}
$this->bar = "foo"; // Not assigned!!!
}
}
global $iconic_private_plugin; // Methods can be accessed from global variable $iconic_private_plugin.
$iconic_private_plugin = new Iconic_Private_Plugin();
Run Code Online (Sandbox Code Playgroud)
这是我通过 bash 命令、引导程序和单元测试所做的事情。
安装-wp-tests.sh
install_dependencies() {
WP_SITE_URL="http://localhost:8080"
WP_PLUGIN_DIR=$(pwd)
WP_DB_DATA="$WP_PLUGIN_DIR/tests/data/db.sql"
cd "$WP_CORE_DIR" …Run Code Online (Sandbox Code Playgroud) 您好,我需要在测试阶段保护我的应用程序。
我读过这篇关于从基本身份验证中排除一个网址的文章
但我想排除 2 个网址:
/API/*
/oauth/v2/令牌
因此,除了这两个公开的 url 之外,整个应用程序都将受到保护。否则我无法访问我的 api 路由。
我现在的 .htaccess 是:
# Protect the app with password
AuthUserFile /home/master/public_html/web/.htpasswd
AuthName "Protected"
AuthType Basic
Require valid-user
Run Code Online (Sandbox Code Playgroud)
所以我猜我应该需要某种排序或正则表达式:
SetEnvIf Request_URI ^/api/ noauth=1
Run Code Online (Sandbox Code Playgroud)
我怎样才能有像 OR 条件?
我需要清理管理员端,以满足我的客户需求.
我正在使用Sonata的NewsBundle,我实际上不需要使用评论,所以我想从管理员端删除它.至少从菜单上看.有没有办法在配置中禁用它?我没有在文档中找到任何关于此的提示.
这里是我想不再看到它的特定区域:


顺便说一句,菜单可能由KnpMenu生成
正如 web 官方文档中提到的:
要从文档中删除特定字段,请在更新文档时使用 FieldValue.delete() 方法:
var cityRef = db.collection('cities').doc('BJ');
// Remove the 'capital' field from the document
var removeCapital = cityRef.update({
capital: firebase.firestore.FieldValue.delete()
});
Run Code Online (Sandbox Code Playgroud)
我找不到实际使用 angularfire2 (5.0.0-rc.3) 的方法
constructor(private firestore: AngularFirestore) {}
[...]
const cityRef = this.firestore.doc(`cities/BJ`);
cityRef.update({
capital: this.firestore.FieldValue.delete()
});
Run Code Online (Sandbox Code Playgroud)
无法读取未定义的属性“删除”