Add postPersist to listener. Add fieldDump function to user. #330
This commit is contained in:
parent
eb0fd34eec
commit
485865901a
2 changed files with 27 additions and 6 deletions
|
|
@ -309,4 +309,8 @@ class User extends BaseUser implements Serializable
|
|||
{
|
||||
return $this->partners_created;
|
||||
}
|
||||
|
||||
public function fieldDump()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,20 @@ abstract class EntityListener
|
|||
$this->log_db = $log_db;
|
||||
}
|
||||
|
||||
public function postPersist($object, LifecycleEventArgs $args)
|
||||
{
|
||||
$event_time = new DateTime();
|
||||
|
||||
// get user for logging
|
||||
$user = $this->token_storage->getToken()->getUser();
|
||||
$username = $user->getUsername();
|
||||
|
||||
$obj_class = preg_replace('/.*\\\\/', '', get_class($object));
|
||||
$log_message = $obj_class . ' with id ' . $object->getID() . ' created.';
|
||||
|
||||
error_log($log_message);
|
||||
}
|
||||
|
||||
public function onFlush(OnFlushEventArgs $args)
|
||||
{
|
||||
$em = $args->getEntityManager();
|
||||
|
|
@ -45,7 +59,10 @@ abstract class EntityListener
|
|||
// get objects for creation
|
||||
foreach ($created_entities as $created_entity)
|
||||
{
|
||||
$log_message = 'Object with id ' . $created_entity->getID() . ' created.';
|
||||
$obj_class = preg_replace('/.*\\\\/', '', get_class($created_entity));
|
||||
$log_message = $obj_class . ' with id ' . $created_entity->getUsername() . ' created.';
|
||||
|
||||
error_log($log_message);
|
||||
}
|
||||
|
||||
// get updated fields. This doesn't include lists of other entities.
|
||||
|
|
@ -75,11 +92,11 @@ abstract class EntityListener
|
|||
$log_message = 'Object with id ' . $deleted_id . ' deleted.';
|
||||
}
|
||||
|
||||
$this->log_db->writePoints([new Point(
|
||||
'User',
|
||||
'Action',
|
||||
['status' => 'success']
|
||||
)]);
|
||||
//$this->log_db->writePoints([new Point(
|
||||
// 'User',
|
||||
// 'Action',
|
||||
// ['status' => 'success']
|
||||
//)]);
|
||||
|
||||
// TODO: find a way to get the list of "old" items, compare with list of updated items
|
||||
// so we can find out what was added/removed
|
||||
|
|
|
|||
Loading…
Reference in a new issue