小编Man*_*olo的帖子

例外:合并筛选器仅适用于"HerzultForumBundle:Topic:new.html.twig"中的数组或哈希值

我正在通过添加更多语言来改进我的Web应用程序.我按照本教程完成了它:https://coderwall.com/p/eiqd_g

一切似乎工作正常,但现在我已经发现,当试图在论坛上创建一个新帖子(HerzultForumBundle)时,我得到了上述异常.

我可以在调试器中看到:

在第8422行的kernel.root_dir/cache/dev/classes.php中

function twig_array_merge($arr1, $arr2)
{
    if (!is_array($arr1) || !is_array($arr2)) {
        throw new Twig_Error_Runtime('The merge filter only works with arrays or hashes.');
    }
    return array_merge($arr1, $arr2);
}
Run Code Online (Sandbox Code Playgroud)

twig_array_merge(null,数组( '_区域设置'=> 'EN')) 在kernel.root_dir /高速缓存的/ dev /枝条/ C7/1/9188032d83474dae4ab5fad0cdaf278f4614c031cf7a5531428c5812bd57.php在线路200

            echo ">
            \t        <a href=\"";
            // line 81
            echo twig_escape_filter($this->env, $this->env->getExtension('routing')->getPath($this->getAttribute($this->getAttribute((isset($context["app"]) ? $context["app"] : $this->getContext($context, "app")), "request"), "get", array(0 => "_route"), "method"), twig_array_merge($this->getAttribute($this->getAttribute((isset($context["app"]) ? $context["app"] : $this->getContext($context, "app")), "request"), "get", array(0 => "_route_params"), "method"), array("_locale" => (isset($context["locale"]) …
Run Code Online (Sandbox Code Playgroud)

php internationalization symfony

2
推荐指数
1
解决办法
2555
查看次数

如何在<img>标签上重叠CSS背景?

我在<img>标签内有一个<a>标签:

<a href="urlPage" class="contain-video">
  <img src="urlImage" />
</a>
Run Code Online (Sandbox Code Playgroud)

<a>标签具有"包含视频"类,所以我想在重叠的实际图像的背景图像:

//css file
.contain-video img {
    background: url('images/contain-video.png') no-repeat !important;
    z-index: 1;
}
Run Code Online (Sandbox Code Playgroud)

但是没有显示背景图像.任何想法如何实现它?

html css image

2
推荐指数
1
解决办法
1698
查看次数

将ContainerInterface作为参数传递时出错

为什么我在尝试获取时遇到此错误ContainerInterface:

ERROR - exception 'ErrorException' with message 'Catchable Fatal Error: Argument 5 passed to Project\InvitationsBundle\Invitations::__construct() must implement interface Symfony\Component\DependencyInjection\ContainerInterface, none given, called in /www/project/app/cache/dev/appDevDebugProjectContainer.php on line 1709 and defined in /www/project/src/Project/InvitationsBundle/Invitations.php line 23' 
Run Code Online (Sandbox Code Playgroud)

添加ContainerInterface到构造方法时出现错误:

<?php

namespace Pro\InvitationsBundle;

use Pro\CommunityBundle\Entity\Community;
use Pro\InvitationsBundle\Entity\Invitation;
use Doctrine\Bundle\DoctrineBundle\Registry;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Pro\UserBundle\Entity\User;
use Symfony\Component\DependencyInjection\ContainerInterface;

class Invitations
{
    private $mailer;
    private $translator;
    private $templating;
    private $doctrine;
    private $container;


    function __construct(\Swift_Mailer $mailer, TranslatorInterface $translator, EngineInterface $templating,
        Registry $doctrine, ContainerInterface $container)
    { …
Run Code Online (Sandbox Code Playgroud)

php service containers symfony

2
推荐指数
1
解决办法
3984
查看次数

npm 发布命令是否提交更改?

我可以在https://docs.npmjs.com/getting-started/publishing-npm-packages看到,它npm version <update_type>改变了版本号package.json(如果你有一个带有这个版本号的标签,也可以添加到你的 git 存储库中)。然后,npm publish提交更改并更新包。

我在 Github 中有一个存储库,它在NPM 中发布。

问题是:我必须在npm version <update_type>或之前明确提交我的更改npm publish,还是会npm publish处理它。

这是我现在如何进行的一个例子:

  • 做一些改变

  • 执行以下命令:

git add .

git commit -m "Message"

npm version minor

npm publish

这是我不确定是否有效:

  • 做一些改变

  • 执行以下命令:

npm version minor

npm publish

编辑:

事实上,如果我npm version minor之前没有提交更改就执行,我会收到这个错误:

npm 错误!Git 工作目录不干净。

所以答案是:是的,我必须在npm version <update_type>.

git github node.js npm

2
推荐指数
1
解决办法
1637
查看次数

如果从原始源无法获得JQuery,如何从自己的服务器加载?

我正在尝试加载JQuery //ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js:

<script src="{{ asset('//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js') }}"></script>
Run Code Online (Sandbox Code Playgroud)

如果收到该文件,则获取该文件.如果没有,从自己的服务器获取文件:

<script><window.jQuery || document.write('<script src="{{ asset("../app/Resources/public/js/vendor/jquery-1.9.1.min.js") }}"><\/script>')</script>
Run Code Online (Sandbox Code Playgroud)

但它给了我一个语法错误.我试图改变报价,但不起作用:

<script><window.jQuery || document.write('<script src="{{ asset(\"../app/Resources/public/js/vendor/jquery-1.9.1.min.js\") }}"><\/script>')</script>
Run Code Online (Sandbox Code Playgroud)

它再次给了我一个语法错误.我究竟做错了什么?

javascript jquery assets symfony twig

1
推荐指数
1
解决办法
4458
查看次数

如何在twig文件中添加许可证注释?

我在所有文件(js,css,php,...)中添加了许可文本,但是在尝试在.html.twig文件中添加文本时遇到了麻烦.我试过以下代码:

<!--
Itransformer.es is an online application to transform images
Copyright (C) 2013  Manolo Salsas

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty …
Run Code Online (Sandbox Code Playgroud)

html comments symfony twig

1
推荐指数
1
解决办法
752
查看次数

使用$ this-> templating-> render()在电子邮件正文中嵌入图像

我正在使用方法中的下一个代码发送一种电子邮件:

    $message = \Swift_Message::newInstance('smtp.gmail.com', 465, 'ssl')
        ->setSubject($this->translator->trans("Invitación a la comunidad %community%", array(
            '%community%' => $community->getNiceName()
        )))
        ->setFrom('manolez@gmail.com', 'contact') // TODO DRY
        ->setTo($email)
        ->setReplyTo($inviter->getEmail(), $inviter->getFullName())
        ->setContentType('text/html')
        ->setBody($this->templating->render(
            'ProInvitationsBundle:Invitations:inviteEmail.html.twig',
            array('community' => $community, 'inviter' => $inviter)));
Run Code Online (Sandbox Code Playgroud)

我想在身体上嵌入一个图像,所以我可以这样做:

    $message = \Swift_Message::newInstance('smtp.gmail.com', 465, 'ssl')
        ->setSubject($this->translator->trans("Invitación a la comunidad %community%", array(
            '%community%' => $community->getNiceName()
        )))
        ->setFrom('manolez@gmail.com', 'contact') // TODO DRY
        ->setTo($email)
        ->setReplyTo($inviter->getEmail(), $inviter->getFullName())
        ->setContentType('text/html')
        ->setBody('<html><head></head><body>Here is an image <img src="' .
             $message->embed(Swift_Image::fromPath('http://site.tld/logo.png')) .
         '" alt="Image" />' .
         '  Rest of message' .
         ' </body></html>');
Run Code Online (Sandbox Code Playgroud)

但是这样,$message …

image swiftmailer symfony

1
推荐指数
1
解决办法
5797
查看次数

Cypher中的这个运算符(=〜)是什么意思?

=~Neo4j docs中找不到这个operator(),但他们在这个例子中使用它:

MATCH (user)-[:friend]->(follower)
WHERE user.name IN ['Joe', 'John', 'Sara', 'Maria', 'Steve'] AND follower.name =~ 'S.*'
RETURN user, follower.name
Run Code Online (Sandbox Code Playgroud)

知道这意味着什么吗?

neo4j cypher

1
推荐指数
1
解决办法
670
查看次数

CSS 圆弧的末端

我正在尝试围绕 CSS 样式的文本绘制一个动画弧,它看起来像一个圆形图标。

由于它可以是弧形或圆形(因为里面的圆形图标会隐藏它的内部部分),因此有几种仅使用 CSS 的解决方案,例如thisthis

但我希望这条线的末端是圆形的。像这样的东西:

在此处输入图片说明

我不确定这是否可能。有任何想法吗?

css

1
推荐指数
1
解决办法
1253
查看次数

如何将带数字的字符串转换为具有整数元素的数组?

我有一个这样的字符串:'3,6,43,8'.

我可以轻松地将它转换为数组:

$newArray = explode( ',', $string );
Run Code Online (Sandbox Code Playgroud)

但由于我需要数组中的整数元素,我应该将每个数组元素转换为整数:

foreach( $newArray as $key => $sNumber ) {
    $newArray[ $key ] = intval( $sNumber );
}
Run Code Online (Sandbox Code Playgroud)

有没有办法直接将数组元素转换为整数而不是字符串?

php arrays

0
推荐指数
1
解决办法
157
查看次数

如何使用!important标签取消左或右规则?

我需要取消leftCSS文件中的规则并将其替换为margin-left:

.aClass {
    left: 5px;
} 
Run Code Online (Sandbox Code Playgroud)

要覆盖的规则:

.aClass {
    left: none !important;
    margin-left: 5px;
}
Run Code Online (Sandbox Code Playgroud)

left: none似乎什么都不做,left: 0正在重新定位图层.那么如何取消left规则呢?我不应该覆盖原始规则,因为它是插件的一部分,可以更新覆盖现有文件.

html css

0
推荐指数
1
解决办法
96
查看次数

无法结账主分公司

我一直在一个分支机构工作,有一些代码来改进应用程序.既然我已经完成了,我想将这个分支与master分支合并,但我不能.我首先尝试像这样检查主分支:

$ git checkout master
Run Code Online (Sandbox Code Playgroud)

但我得到这个错误:

error: The following untracked working tree files would be overwritten by checkout:
vendor/bin/doctrine
vendor/bin/doctrine.php
...
Run Code Online (Sandbox Code Playgroud)

但供应商目录包含在.gitignore文件中.如果我做:

$ git status
Run Code Online (Sandbox Code Playgroud)

我明白了:

# On branch mejoras_contralador
nothing to commit (working directory clean)
Run Code Online (Sandbox Code Playgroud)

在此之后,我会这样做:

$ git merge branch
Run Code Online (Sandbox Code Playgroud)

如何避免这个错误?

git git-checkout

-1
推荐指数
1
解决办法
3936
查看次数