小编got*_*oto的帖子

gitignore不会忽略.idea目录

使用phpStorm IDE处理Symfony2项目,我添加了几个文件到git ignore但是一个文件尽管被添加到git ignore总是出现....我已经尝试了多次但它总是在那里

.gitignore文件:

/app/config/parameters.yml
/bin/
/build/
/composer.phar
/vendor/
/web/bundles/
/app/bootstrap.php.cache
/app/cache/*
!app/cache/.gitkeep
/app/config/parameters.yml
/app/logs/*
!app/logs/.gitkeep
/app/phpunit.xml

#IDE metadata
**.idea/**

#Bash files
run.sh
Run Code Online (Sandbox Code Playgroud)

并且git不会忽略的是.idea文件夹/文件:

On branch develop
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   .idea/workspace.xml

no changes added to commit (use "git add" and/or "git commit -a")
Run Code Online (Sandbox Code Playgroud)

知道为什么git不会忽略像我在gitignore中指定的整个目录......?

git gitignore

25
推荐指数
3
解决办法
3万
查看次数

symfony 4:如何从RootDir获取"/ public"

我在该public文件夹下有一个图像.
如何在symfony4中获取我的图像目录?
在symfony 3中,它相当于:

$webPath = $this->get('kernel')->getRootDir() . '/../web/';
Run Code Online (Sandbox Code Playgroud)

symfony symfony4

12
推荐指数
5
解决办法
2万
查看次数

TypeError:无法使用ReactJs读取webpack-cli中未定义的属性'presetToOptions'

我正在研究ReactJS应用程序并进行了配置"webpack": "^2.7.0", "webpack-cli": "^2.0.9"但是从cmd运行webpack时出现以下错误.

const statsPresetToOptions = require("webpack").Stats.presetToOptions;
                                                                             ^

TypeError: Cannot read property 'presetToOptions' of undefined
    at processOptions (F:\reactJs_weather\React-Weather-App\node_modules\webpack-cli\bin\webpack.js:284:57)
Run Code Online (Sandbox Code Playgroud)

你有什么主意吗?

reactjs webpack

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

选择输入中的所有文本,焦点

我希望在将焦点放在元素上时选择所有文本.

我用了

$('.class-focusin').focusin(function(e) {
    $(this).select();
});
Run Code Online (Sandbox Code Playgroud)

但这不是我想要的完美行为.当我在两个字符之间单击时,输入值不会被选中,中间有一个光标.我想要在chrome浏览器中使用url栏的行为:单击并将光标替换为值选择

随意测试我的问题:http: //jsfiddle.net/XS6s2/8/

我希望文本能够在选择后接收光标.选择的答案,下面肯定是我想要的,谢谢

javascript jquery

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

形式实体按换算值排序

我有一个实体类别,其中有一个代码。此代码是内部代码,我们将其翻译成每种语言。例如,想象一下:

Categories:
---- id:1 Code: "Bread"
---- id:2 Code: "Butter"
Run Code Online (Sandbox Code Playgroud)

我有一个带有表单域实体的表单。我想按翻译后的标签订购。

以英语为例,它将显示

Bread
Butter
Run Code Online (Sandbox Code Playgroud)

但是以法语为例,顺序是不同的

Beurre (butter)
Pain (bread)
Run Code Online (Sandbox Code Playgroud)

所以我不能使用实体字段的orderBy。

我有一个手工制作的解决方案,非常脏:我使用带有翻译标签的选择字段

$categories_translated =array();
$categories= $this->em->getRepository('MyRepo')->findAll();
foreach($categories as $category){
    $categories_translated[$category->getId()]= $this->translator->trans($category);
}
asort($categories_translated);//sorted 

//then later
$builder->add('category','choice',array( 'choices' => $choices_technologies) )
Run Code Online (Sandbox Code Playgroud)

您是否有适当的方法来执行此操作?

symfony

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

使用 Eloquent 关系获取表名

class SampleELoq extends Model
{
    use SoftDeletes;

    public function conditionFields() {
       return $this->belongsToMany('App\EloquentModel\ConditionField');
    }
}
Run Code Online (Sandbox Code Playgroud)

nameSpace 是 SampleELoq 的命名空间

$Eloq = $nameSpace::find(1);

$table = with(new $nameSpace->conditionFields)->getTable();

print_r(Schema::getColumnListing($table));
Run Code Online (Sandbox Code Playgroud)

我怎样才能获得conditionFields的表名?

php laravel-5.2

4
推荐指数
3
解决办法
3609
查看次数

单元测试期间连接太多

我有一个像很多测试类的项目

class MyTest extends BaseTestCase
{
    public function __construct() 
    {
        parent::__construct();
        $this->em = $this->get('doctrine')->getManager();
    }
    public function setUp() {

        $this->init();

        //load sql data for the tests
        $path = $this->get('kernel')->locateResource('@Bundle/Data/Test.sql');
        $content_file_sql_data = file_get_contents($path);
        $stmt = $this->em->getConnection()->prepare($content_file_sql_data);
        $stmt->execute();
        $stmt->closeCursor();
    }
        /*
         *   Then we do a lot of tests using the database
         */
}
Run Code Online (Sandbox Code Playgroud)

它们都扩展了我的BaseTestCase:

abstract class BaseTestCase extends \PHPUnit_Framework_TestCase {

protected $_container;
protected $kernel;

public function __construct() {

  parent::__construct();
  $this->kernel = new \AppKernel("test", true);
  $this->kernel->boot();
  $this->_container = $this->kernel->getContainer();

  $this->init();
}

//empty …
Run Code Online (Sandbox Code Playgroud)

phpunit automated-tests symfony

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

使用唯一键更新实体 - 插入而不是更新

我的服务中有这个方法:

public function updateCountry($p_entity) {   


    var_dump($p_entity->getId());    //return 3 (as expected)
    var_dump(get_class($p_entity) ); //return Country (as expected)

    $this->em->persist($p_entity);
    $this->em->flush();
}
Run Code Online (Sandbox Code Playgroud)

我叫它

$country = $em->getRepository('blabla')->find(3);
$my_service->updateCountry($country);
Run Code Online (Sandbox Code Playgroud)

但生成的请求是

Doctrine\DBAL\DBALException:执行'INSERT INTO country(code,label,created_at,updated_at)VALUES(?,?,?,?)'时出现异常,其中params ["EN","England","201 3- 08-23 00:00:00",null]:

我有一个独特的学说约束

这是我的country.orm.yml

To\Bundle\Entity\Country:
    type: entity
    table: country
    repositoryClass: To\Bundle\Entity\CountryRepository

    fields:
         id:
             type: integer
             id: true
             generator:
                 strategy: AUTO
         code:
             type: string
             length: 255
             unique: true
             nullable: false
Run Code Online (Sandbox Code Playgroud)

为什么我生成了插入请求而不是更新请求?

symfony doctrine-orm

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

Twig动态替换关键字

我想知道为什么这不起作用

{% set what = 'hate' %}
{% set byValue = 'like' %}
{{ 'I hate twig'|replace( { what : byValue } ) }} 
Run Code Online (Sandbox Code Playgroud)

应该会显示I like twig吧?

twig

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

没有认可的卡票

我在我的Web应用程序中有一个REST api,我从另一个webapp生成了cas票证.

该webapp实习生用于cas20proxyticketvalidator验证票证.因此,我也在Cas20ProxyTicketValidator我的自定义过滤器中使用来验证票证.

但它总是给我以下错误:

ticket = ST-148008-jWXKeEdHkxmuktvYqXF6-cas
org.jasig.cas.client.validation.TicketValidationException:
                ticket 'ST-148008-jWXKeEdHkxmuktvYqXF6-cas' not recognized

        at org.jasig.cas.client.validation.Cas20ServiceTicketValidator.parseResponseFromServer(Cas20ServiceTicketValidat
or.java:86)
        at org.jasig.cas.client.validation.AbstractUrlBasedTicketValidator.validate(AbstractUrlBasedTicketValidator.java
:217)
Run Code Online (Sandbox Code Playgroud)

为什么我的机票无法识别?

cas single-sign-on

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