我正在尝试将此jquery插件注册到Bower.
该bower.json文件如下所示:
{
"name": "domajax",
"version": "2.1.0",
"homepage": "http://domajax.com",
"description": "Domajax is a free jQuery plugin that give you tools to add ajax calls within your application, without a piece of javascript.",
"main": [
"js/jquery.domajax.js"
],
"keywords": [
"domajax",
"ajax",
"jquery",
"plugin",
"javascript",
"dom",
"html"
],
"authors": [
"Alain Tiemblo"
],
"repository": {
"type": "git",
"url": "git://github.com/ninsuo/domajax.git"
},
"bugs": "https://github.com/ninsuo/domajax/issues",
"license": "MIT",
"ignore": ["./!(js/jquery.domajax.js)"],
"dependencies": {
"jquery": ">=1.7",
"jquery.ui": "*",
"json2-js": "*"
}
}
Run Code Online (Sandbox Code Playgroud)
您可以看到main …
我尝试为我的登录表单创建一个身份验证器,但由于一些不明原因,我总是没有记录.
[2016-10-05 18:54:53] security.INFO: Guard authentication successful! {"token":"[object] (Symfony\\Component\\Security\\Guard\\Token\\PostAuthenticationGuardToken: PostAuthenticationGuardToken(user=\"test@test.test\", authenticated=true, roles=\"ROLE_USER\"))","authenticator":"AppBundle\\Security\\Authenticator\\FormLoginAuthenticator"} []
[2016-10-05 18:54:54] security.INFO: An AuthenticationException was thrown; redirecting to authentication entry point. {"exception":"[object] (Symfony\\Component\\Security\\Core\\Exception\\AuthenticationExpiredException(code: 0): at /space/products/insurance/vendor/symfony/symfony/src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php:86)"} []
[2016-10-05 18:54:54] security.INFO: The security token was removed due to an AccountStatusException. {"exception":"[object] (Symfony\\Component\\Security\\Core\\Exception\\AuthenticationExpiredException(code: 0): at /space/products/insurance/vendor/symfony/symfony/src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php:86)"} []
Run Code Online (Sandbox Code Playgroud)
我不理解这个"AuthenticationExpiredException",因为我没有任何无状态,也没有在我的应用程序中任何方式的任何过期.
这个问题对任何人都有用吗?
编辑1
经过一段时间,看起来我因为{{ is_granted('ROLE_USER') }}在Twig中而未被记录.反正不明白为什么.
编辑2
如果我在onAuthenticationSuccess身份验证器的方法上转储我的安全令牌,authenticated = true.
但是,如果我在重定向或访问新页面后转储()我的安全令牌,'authenticated' = false.
为什么我的身份验证没有存储.
app/config/security.yml
security:
encoders:
AppBundle\Security\User\Member:
algorithm: bcrypt
cost: 12
providers:
members:
id: …Run Code Online (Sandbox Code Playgroud) 今天早上,我收到了一条新的Twig_Extensions版本的通知!好极了!
在将它整合到twigfiddle之前,我想看到变化.这主要是使用class_alias函数添加对名称空间的支持,然后添加仅包含旧版本的PSR-4对应类.
但是每个新的(命名空间)类都是这样实现的:
<?php
namespace Twig\Extensions;
require __DIR__.'/../lib/Twig/Extensions/Extension/Text.php';
if (\false) {
class TextExtension extends \Twig_Extensions_Extension_Text
{
}
}
Run Code Online (Sandbox Code Playgroud)
这种符号是什么意思?
我已经有一个找到2个数字的GCD的函数.
function getGCDBetween($a, $b)
{
while ($b != 0)
{
$m = $a % $b;
$a = $b;
$b = $m;
}
return $a;
}
Run Code Online (Sandbox Code Playgroud)
但现在,我想扩展此功能以找到N点的GCD.有什么建议吗?
首先,我是Symfony 2的完全noobie.问题听起来很简单,如果我尝试将一些上下文放入为什么以及如何需要它,它将开始变得混乱.
从本质上说我已经创建了一个表格,其中我手动过程,验证和使用学说等我手动创建一个控制器动作内的形式插入(它动态地建立从检索到的值从另一个对象).我假设可能有更好的方法来做到这一点,但由于我是Symfony的新手和拖网的日子,我看不到任何我需要做的解决方案.
因此,我不是简单地针对类/实体等构建表单,因此我将手动需要添加CSRF令牌或某种保护.
在正常情况下,您将创建FormType并配置默认选项以具有csrf_protection.然后一个简单的例子:
{{ form_widget(form._token) }}
Run Code Online (Sandbox Code Playgroud)
并且csrf令牌在那里.
由于我正在动态构建表单,因此我不确定如何为表单手动创建csrf令牌.有没有人有没有课程创建表单和添加csrf保护的经验?
亲切的问候Paul Pounder
我想在PHP中创建类似于加载器的东西,所以我使用了这段代码:
<?php
$x=1;
while($x<=100) {
echo "Loading: $x %<br>";
$x++;
}
?>
Run Code Online (Sandbox Code Playgroud)
这样它将显示从"加载1%"到"加载100%".但是,这将导致所有出现的一个在新线出现后不会消失.因此,我想知道如何使新行显示并且旧的消失,并且这在页面加载后开始,因此用户将能够观看实际加载的加载器从1%到100%.
更新:我知道我应该使用JS和/或Ajax来实现它,我只是想知道是否有办法在PHP中也这样做:)
我的目标是使用来自同一类对象的数据对托管实体执行更新,但不受Doctrine管理.
如果可以在替换属性时执行"简单更新",这将是很酷的,但实际上,如果我清理一个ArrayCollection,旧的数据似乎不会被删除(即使我清除了小提琴的所有引用ArrayCollection或者如果orphanRemoval设置为true).
但是让我们进入一个具体的例子.我有这个实体有很多OneToOne/OneToMany关系来代表一个小提琴.我可以使用Symfony2命令导入小提琴样本(以前从其他环境导出为json).
如果样本已存在,我该如何正确更新?
我使用以下代码(简化)构建我的实体:
$fiddle = new Fiddle();
$fiddle->setHash($this->get($json, 'hash'));
$fiddle->setRevision($this->get($json, 'revision'));
$context = $fiddle->getContext();
$context->setFormat($this->get($json, 'context', 'format'));
$context->setContent($this->get($json, 'context', 'content'));
$fiddle->clearTemplates();
$jsonTemplates = $this->get($json, 'templates') ? : array ();
foreach ($jsonTemplates as $jsonTemplate)
{
$template = new FiddleTemplate();
$template->setFilename($this->get($jsonTemplate, 'filename'));
$template->setContent($this->get($jsonTemplate, 'content'));
$template->setIsMain($this->get($jsonTemplate, 'is-main'));
$fiddle->addTemplate($template);
}
// ...
Run Code Online (Sandbox Code Playgroud)
如果它已经存在,我现在可以在删除后保留我的实体:
$check = $this
->getContainer()
->get('doctrine')
->getRepository('FuzAppBundle:Fiddle')
->getFiddle($fiddle->getHash(), $fiddle->getRevision());
if (!is_null($check->getId()))
{
$em->remove($check);
$em->flush();
}
$em->persist($fiddle); …Run Code Online (Sandbox Code Playgroud) 我正在构建一个jQuery插件来管理表单集合.该插件旨在补充add,remove,move up和move down按钮来改变该集合.
集合的根节点始终包含选择器,例如.collection.
一个按钮可以,只要它有是任何.add类
我实现min和max选项,因此add和remove按钮相应消失.当我尝试管理表单集合时,我的问题出现了:如何仅选择add引用正确集合的按钮?
要简化问题,请查看以下HTML代码:
<div class="collection">
<div>something</div>
<div>something</div>
<div>
<div class="add">+</div>
</div>
<div>something</div>
<div class="collection">
<div>something</div>
<div>something</div>
<div>
<div class="add">+</div>
</div>
<div>something</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
请记住,按钮可以是任意深度的:集合是由用户构建的,我不知道dom中的按钮在哪里.顺便说一下,它比.collection我所知道的要深.
如何选择所有add按钮直到第二个.collection,但不是更进一步?
对于那些有兴趣,这个插件是可用的(但在积极的开发)这里.
如何在symfony模板中拥有全局变量?我确实读过这个, 但我更喜欢从数据库中获取参数,我认为这个服务将在启动之前加载,然后才能从db中获取任何内容.是否有可能这样做?
我正在尝试在我的主导航中构建一个语言切换器,这是由KNPMenuBundle创建的.翻译是使用JMSTranslationBundle完成的.两者都很好.
我想用我的菜单构建器创建一个语言切换器,但是生成正确的路径会让我感到头痛.
这是我的服务:
class MenuService
{
private $factory;
private $translator;
private $router;
public function __construct(FactoryInterface $factory, Translator $translator, Router $router)
{
$this->factory = $factory;
$this->translator = $translator;
$this->router = $router;
}
public function createMainMenu(RequestStack $requestStack, array $languages)
{
// Language Switcher - $languages === ['en', 'de']
$request = $requestStack->getCurrentRequest();
$routeName = $request->get('_route');
$menu->addChild('menu.language', array(
'uri' => '#',
'label' => '<i class=\'fa fa-flag-checkered\'></i> '.$this->translator->trans('menu.language.main'),
'extras' => array('safe_label' => true)
))
->setAttribute('class', 'dropdown singleDrop')
->setChildrenAttribute('class', 'dropdown-menu dropdown-menu-left')
; …Run Code Online (Sandbox Code Playgroud)