Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F13143585
WithUndo.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
WithUndo.php
View Options
<?php
namespace
AuthGrove\Undo
;
/**
* Trait offering an implementation for Undoable for default UndoStore
* parameters.
*/
trait
WithUndo
{
/**
* Undoes a destructive operation.
*
* @param UndoStore $store
* @param string $storeHash
* @param mixed $restored The stored instance, to be able to further interact with it after undo
* @return bool true if the operation is undone successfully; otherwise, false
*/
public
static
function
undo
(
UndoStore
$store
,
$storeHash
,
&
$restored
)
{
// Ensures we undo the operation required by the user
if
(!
$store
->
isSameControlHash
(
$storeHash
))
{
return
false
;
}
if
(!
$store
->
checkIntegrity
())
{
return
false
;
}
$restored
=
$store
->
restoreState
(
$return
);
return
(
bool
)
$return
;
}
/**
* Prepares an undo store, ie a glass coffin with a serialized copy of our
* instance and instructions how to undo the destructive operation.
*
* @return UndoStore
*/
public
function
prepareUndoStore
()
{
return
new
UndoStore
(
$this
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Nov 21, 16:43 (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3166567
Default Alt Text
WithUndo.php (1 KB)
Attached To
Mode
rGROVE Auth Grove
Attached
Detach File
Event Timeline
Log In to Comment