小编Dou*_*oug的帖子

jQuery UI Sortable,如何确定更新事件中的当前位置和新位置?

我有:

<ul id="sortableList">
     <li>item 1</li>
     <li>item 2</li>
     <li>item 3</li>
</ul>
Run Code Online (Sandbox Code Playgroud)

我已连接到update: function(event, ui) { }但不知道如何获得元素的原始和新位置.如果我将项目3移动到项目1之上,我希望原始位置为2(基于0的索引)并且项目3的新位置为0.

jquery-ui jquery-ui-sortable

43
推荐指数
5
解决办法
4万
查看次数

处理Heroku/ClearDB auto增量主键策略

使用Heroku运行ClearDB作为MySQL层,主键以10的倍数自动递增.因此,例如,第一个插入可以是4然后是14,24,34等.我完全接受他们的推理,所以这不是问题.

我的问题是,你如何在你的代码中处理这个问题.例如,假设我有一个status由4行组成的表,

     id | name
     1  | Active
     2  | Retired
     3  | Banned
     4  | Awaiting Mod
Run Code Online (Sandbox Code Playgroud)

然后在我的应用程序中我使用:

   if($status['id'] == 1){
     //do something
   }else{
     // do something else
   }
Run Code Online (Sandbox Code Playgroud)

显然,由于PK的增加方式,这将会中断.处理这类情况的最佳做法是什么?例如,我不能检查14,因为没有什么可以说编号策略不会改为12,22,32等.

我应该按名称进行检查,例如,if($status['name'] == 'Active')或者我int是否需要在表中添加新列?我知道int在SQL中查询要快得多string.

那么,处理这个问题的正常方法是什么?

php mysql sql heroku cleardb

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

API 平台:过滤自定义数据提供者

我目前在 API 平台中使用外部 API 源 (Stripe) 时尝试过滤结果时遇到问题。

我需要做的是返回指定客户的订阅列表。因此,访问http://localhost/api/subscriptions?customer=123foo将返回与该客户匹配的所有记录。

现在,下面的代码由于 ORM\Filter 而引发错误,并且没有它也能正常工作,因为实际过滤是在 Stripes API 上执行的,而不是由我执行,但是,我真的希望 Swagger-API GUI 具有过滤器盒子。

简而言之,当使用外部数据源时,如何让实体中的注释显示 Swagger UI 中的可搜索字段。

我拥有的是如下实体(出于示例目的而简化):

<?php

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiProperty;
use Symfony\Component\Serializer\Annotation\Groups;

use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Annotation\ApiFilter;

/**
 * Subscriptions allow you to charge a customer on a recurring basis. A subscription ties a customer to a particular plan you've created.
 * @ApiResource()
 * @ApiFilter(SearchFilter::class, properties={"customer": "exact"})
 * @package App\Entity
 */
class Subscription
{
     /**
     * Unique identifier for the …
Run Code Online (Sandbox Code Playgroud)

php symfony swagger api-platform.com

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

过滤一对多集合

我目前正在尝试过滤我的 OneToMany 集合结果,但运气不佳。

我已尝试按照此处文档中的说明设置过滤器,但无济于事。使用以下代码,我只能选择在Foos集合/api/foos <- 上进行过滤的选项 <- 即使将分页设置为每页 1,此请求实际上也不会在应用过滤器后完成。

图像

图像

我希望/需要它位于/api/foos/1?bar.isRetired=false并返回 1 'Bar' 和许多 'foos' 的结果,但其中 'foo.isRetired = false'

例子

// config/packages/api_filters.yaml
services:
    filters.retired_filter:
            parent: 'api_platform.doctrine.orm.boolean_filter'
            arguments: [ { bars.isRetired: ~ } ]
            tags: [ 'api_platform.filter' ]


// src/Entity/Foo.php

/* @ApiResource(attributes={"filters"={"filters.retired_filter"}}) */
class Foo
{
    private $id;
    private $name;
    /** @ORM\OneToMany(targetEntity="Bars", mappedBy="foo") */
    private $bars;
    public function __construct(){
        $this->bars = new ArrayCollection();
    }
}

// src/Entity/Bar.php

/* @ApiResource() */
class Bar
{
    private $id;
    private …
Run Code Online (Sandbox Code Playgroud)

symfony doctrine-orm api-platform.com

5
推荐指数
0
解决办法
421
查看次数

无法运行ckeditor:install

以下是此处的文档:http://symfony.com/doc/current/bundles/IvoryCKEditorBundle/installation.html

我目前输入了命令:

composer require egeloen/ckeditor-bundle

目前解决的问题

使用版本^ 5.0 for egeloen/ckeditor-bundle

之后,我将新包输入我的AppKernel并转到运行命令:

php bin/console ckeditor:install

不幸的是,这会导致此错误:

[Symfony\Component\Console\Exception\CommandNotFoundException]
"ckeditor"命名空间中没有定义命令.

使用Symfony 3.3-dev,Ckeditor-bundle(5.0.3)

php ckeditor symfony

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