forked from statamic/cms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPublish.php
56 lines (45 loc) · 1.2 KB
/
Publish.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
49
50
51
52
53
54
55
56
<?php
namespace Statamic\Actions;
use Statamic\Contracts\Entries\Entry;
use Statamic\Facades\User;
class Publish extends Action
{
public static function title()
{
return __('Publish');
}
public function visibleTo($item)
{
return $item instanceof Entry && ! $item->published();
}
public function visibleToBulk($items)
{
if ($items->whereInstanceOf(Entry::class)->count() !== $items->count()) {
return false;
}
if ($items->filter->published()->count() === $items->count()) {
return false;
}
return true;
}
public function authorize($user, $entry)
{
return $user->can('publish', $entry);
}
public function confirmationText()
{
/** @translation */
return 'Are you sure you want to publish this entry?|Are you sure you want to publish these :count entries?';
}
public function buttonText()
{
/** @translation */
return 'Publish Entry|Publish :count Entries';
}
public function run($entries, $values)
{
$entries->each(function ($entry) {
$entry->publish(['user' => User::current()]);
});
}
}