Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getEmoji example
$this
->options =
$options
;
if
(
\
count
(
$this
->options
[
'blocks'
]
??
[
]
)
> self::MAX_BLOCKS
)
{
throw
new
LogicException
(
sprintf
(
'Maximum number of "blocks" has been reached (%d).', self::MAX_BLOCKS
)
)
;
}
}
public
static
function
fromNotification
(
Notification
$notification
)
: self
{
$options
=
new
self
(
)
;
$options
->
iconEmoji
(
$notification
->
getEmoji
(
)
)
;
$options
->
block
(
(
new
SlackSectionBlock
(
)
)
->
text
(
$notification
->
getSubject
(
)
)
)
;
if
(
$notification
->
getContent
(
)
)
{
$options
->
block
(
(
new
SlackSectionBlock
(
)
)
->
text
(
$notification
->
getContent
(
)
)
)
;
}
if
(
$exception
=
$notification
->
getExceptionAsString
(
)
)
{
$options
->
block
(
new
SlackDividerBlock
(
)
)
;
$options
->
block
(
(
new
SlackSectionBlock
(
)
)
->
text
(
$exception
)
)
;
}
return
$options
;
}
private
array
$options
=
[
]
;
public
function
__construct
(
array
$options
=
[
]
)
{
$this
->options =
$options
;
}
public
static
function
fromNotification
(
Notification
$notification
)
: self
{
$options
=
new
self
(
)
;
$text
=
$notification
->
getEmoji
(
)
.' *'.
$notification
->
getSubject
(
)
.'* ';
if
(
$notification
->
getContent
(
)
)
{
$text
.= "\r\n".
$notification
->
getContent
(
)
;
}
if
(
$exception
=
$notification
->
getExceptionAsString
(
)
)
{
$text
.= "\r\n".'```'.
$exception
.'```';
}
$options
->
text
(
$text
)
;
$this
->stack =
$stack
;
$this
->mapper =
$mapper
;
}
public
function
notify
(
Notification
$notification
, RecipientInterface
$recipient
, string
$transportName
= null
)
: void
{
if
(
null ===
$request
=
$this
->stack->
getCurrentRequest
(
)
)
{
return
;
}
$message
=
$notification
->
getSubject
(
)
;
if
(
$notification
->
getEmoji
(
)
)
{
$message
=
$notification
->
getEmoji
(
)
.' '.
$message
;
}
$request
->
getSession
(
)
->
getFlashBag
(
)
->
add
(
$this
->mapper->
flashMessageTypeFromImportance
(
$notification
->
getImportance
(
)
)
,
$message
)
;
}
public
function
supports
(
Notification
$notification
, RecipientInterface
$recipient
)
: bool
{
return
true;
}
}
public
function
__construct
(
private
array
$options
=
[
]
)
{
}
public
static
function
fromNotification
(
Notification
$notification
)
: self
{
$options
=
new
self
(
)
;
$options
->
setTitle
(
$notification
->
getSubject
(
)
)
;
$options
->
setMessage
(
$notification
->
getContent
(
)
)
;
$options
->
setStringPriority
(
$notification
->
getImportance
(
)
)
;
$options
->
addTag
(
$notification
->
getEmoji
(
)
)
;
return
$options
;
}
public
function
toArray
(
)
: array
{
return
$this
->options;
}
public
function
getRecipientId
(
)
: ?string
{