forked from vinkla/extended-acf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFilterBy.php
48 lines (37 loc) · 1.08 KB
/
FilterBy.php
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
44
45
46
47
48
<?php
/**
* Copyright (c) Vincent Klaiber
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @see https://github.com/vinkla/extended-acf
*/
declare(strict_types=1);
namespace Extended\ACF\Fields\Settings;
use InvalidArgumentException;
trait FilterBy
{
/**
* @param string[] $postStatus draft, future, pending, private, publish
* @throws \InvalidArgumentException
*/
public function postStatus(array $postStatus): static
{
if (count(array_diff($postStatus, ['draft', 'future', 'pending', 'private', 'publish'])) > 0) {
throw new InvalidArgumentException('Invalid argument post status.');
}
$this->settings['post_status'] = $postStatus;
return $this;
}
public function postTypes(array $postTypes): static
{
$this->settings['post_type'] = $postTypes;
return $this;
}
public function taxonomies(array $taxonomies): static
{
$this->settings['taxonomy'] = $taxonomies;
return $this;
}
}