Page Menu
Home
Code
Search
Configure Global Search
Log In
Files
F210928
TryAutoSelect.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
TryAutoSelect.php
View Options
<?php
namespace
Zed\Engines\Perso\Events
;
use
Zed\Models\Objects\Perso
;
class
TryAutoSelect
extends
BaseEvent
{
/**
* @var Perso[]
*/
private
array
$persos
;
public
function
isTriggered
():
bool
{
return
!
$this
->
selector
->
hasPerso
;
}
public
function
handle
()
:
void
{
$this
->
persos
=
Perso
::
get_persos
(
$this
->
getDatabase
(),
$this
->
selector
->
user
);
$count
=
count
(
$this
->
persos
);
if
(
$count
===
0
)
{
$this
->
askUserToCreatePerso
();
}
elseif
(
$count
===
1
)
{
$this
->
autoselect
();
}
else
{
$this
->
askUserToSelectPerso
();
}
}
private
function
askUserToCreatePerso
()
:
never
{
$this
->
selector
->
smarty
->
display
(
"perso_create.tpl"
);
exit
;
}
private
function
autoselect
()
:
void
{
$this
->
selector
->
selectAndSetPerso
(
$this
->
persos
[
0
]);
}
private
function
askUserToSelectPerso
()
:
never
{
$this
->
selector
->
smarty
->
assign
(
"PERSOS"
,
$this
->
persos
)
->
display
(
"perso_select.tpl"
);
$_SESSION
[
'UserWithSeveralPersos'
]
=
true
;
exit
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 16, 14:27 (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
21428
Default Alt Text
TryAutoSelect.php (1 KB)
Attached To
rZED Zed
Event Timeline
Log In to Comment