TaxonomyParent.php
960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace ACP\Editing\Service\Taxonomy;
use AC;
use ACP\Editing\PaginatedOptions;
use ACP\Editing\Service\BasicStorage;
use ACP\Editing\Storage;
use ACP\Editing\View;
use ACP\Helper\Select;
class TaxonomyParent extends BasicStorage implements PaginatedOptions {
/**
* @var string
*/
private $taxonomy;
public function __construct( $taxonomy ) {
parent::__construct( new Storage\Taxonomy\TaxonomyParent( $taxonomy ) );
$this->taxonomy = $taxonomy;
}
public function get_paginated_options( $search, $page, $id = null ) {
$entities = new Select\Entities\Taxonomy( [
'search' => $search,
'page' => $page,
'exclude_tree' => $id,
'taxonomy' => $this->taxonomy,
] );
return new AC\Helper\Select\Options\Paginated(
$entities,
new Select\Formatter\TermName( $entities )
);
}
public function get_view( string $context ): ?View {
return ( new View\AjaxSelect() )->set_clear_button( true );
}
}