-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathHelpers.php
executable file
·107 lines (92 loc) · 2.61 KB
/
Helpers.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
namespace WebDevEtc\BlogEtc;
use Gate;
use Session;
use WebDevEtc\BlogEtc\Gates\GateTypes;
class Helpers
{
/**
* What key to use for the session::flash / pull / has.
*/
public const FLASH_MESSAGE_SESSION_KEY = 'WEBDEVETC_FLASH';
public static function hasAdminGateAccess(): bool
{
return Gate::allows(GateTypes::MANAGE_BLOG_ADMIN);
}
public static function hasCommentGateAccess(): bool
{
return Gate::allows(GateTypes::ADD_COMMENT);
}
/**
* @deprecated use pullFlashedMessage() instead
*/
public static function pull_flashed_message(): ?string
{
return self::pullFlashedMessage();
}
/**
* return the flashed message. Use with ::has_flashed_message() if you need to check if it has a value...
*
* @return string
*/
public static function pullFlashedMessage(): ?string
{
return Session::pull(self::FLASH_MESSAGE_SESSION_KEY);
}
/**
* @deprecated use hasFlashedMessage() instead
*/
public static function has_flashed_message(): bool
{
return self::hasFlashedMessage();
}
/**
* Is there a flashed message?
*/
public static function hasFlashedMessage(): bool
{
return Session::has(self::FLASH_MESSAGE_SESSION_KEY);
}
//## Depreciated methods:
/**
* @deprecated use flashMessage() instead
*/
public static function flash_message(string $message): void
{
self::flashMessage($message);
}
/**
* Set a new flash message - used in the BlogEtc Admin panel to flash messages to user
* such as 'post created'.
*/
public static function flashMessage(string $message): void
{
Session::flash(self::FLASH_MESSAGE_SESSION_KEY, $message);
}
/**
* @deprecated use rssHtmlTag() instead
*/
public static function rss_html_tag(): string
{
return self::rssHtmlTag();
}
/**
* Use this in your blade/template files, within <head> to auto insert the links to rss feed.
*/
public static function rssHtmlTag(): string
{
return '<link rel="alternate" type="application/atom+xml" title="Atom RSS Feed" href="'
.e(route('blogetc.feed')).'?type=atom" />'
.'<link rel="alternate" type="application/rss+xml" title="XML RSS Feed" href="'
.e(route('blogetc.feed')).'?type=rss" />';
}
/**
* This method is depreciated. Just use the config() directly.
*
* @deprecated
*/
public static function image_sizes(): array
{
return config('blogetc.image_sizes');
}
}