• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

miaoxing / article / 5558674748

pending completion
5558674748

push

github

semantic-release-bot
chore(release): publish

See CHANGELOG.md for more details.

26 of 66 branches covered (39.39%)

185 of 302 relevant lines covered (61.26%)

5.34 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

55.0
/pages/api/admin/articles/index.php
1
<?php
2

3
use Miaoxing\Article\Service\ArticleModel;
4
use Miaoxing\Plugin\BaseController;
5
use Miaoxing\Services\Page\CollGetTrait;
6
use Miaoxing\Services\Page\PostToPatchTrait;
7
use Miaoxing\Services\Service\IndexAction;
8

9
return new class () extends BaseController {
10✔
10
    use CollGetTrait;
11
    use PostToPatchTrait;
12

13
    protected $include = [
14
        'category',
15
    ];
16

17
    public function get()
18
    {
19
        return IndexAction::new()
3✔
20
            ->beforeFind(function (ArticleModel $models) {
2✔
21
                $models->setDefaultSortColumn(['sort', 'id']);
3✔
22
            })
3✔
23
            ->afterFind(function (ArticleModel $models, $req) {
2✔
24
                // @experimental 指定编号排序
25
                if ('id' !== $req['sortField']) {
3✔
26
                    return;
3✔
27
                }
28

29
                $ids = (array) ($req['search']['id'] ?? []);
×
30
                if (!$ids) {
×
31
                    return;
×
32
                }
33

34
                $iterator = $models->getIterator();
×
35
                $iterator->uasort(function ($article1, $article2) use ($ids) {
36
                    $pos1 = array_search($article1->id, $ids, true);
×
37
                    $pos2 = array_search($article2->id, $ids, true);
×
38
                    return $pos1 - $pos2;
×
39
                });
×
40
                $models->fromArray($iterator);
×
41
            })
3✔
42
            ->exec($this);
3✔
43
    }
44
};
10✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc