Refactor value handling in multiple classes to simplify JSON decoding process
This commit is contained in:
@@ -14,17 +14,7 @@ class Scontainers
|
||||
public static function container_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania kontenera wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( $id = \admin\factory\Scontainers::container_save( $values['id'], $values['title'], $values['text'], $values['status'], $values['show_title'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Kontener został zapisany.', 'id' => $id ];
|
||||
|
||||
Reference in New Issue
Block a user