-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Task]: Remove system/admin settings remnants (#37)
* fix: create separate service for default key bindings * fix: service name * Remove legacy code and implement fallback in helper * Set default user to null --------- Co-authored-by: mattamon <matthias.schuhmayer@pimcore.com>
- Loading branch information
Showing
4 changed files
with
71 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\AdminBundle\Helper; | ||
|
||
use Pimcore; | ||
use Pimcore\Bundle\AdminBundle\Security\User\User as UserProxy; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class User | ||
{ | ||
protected const DEFAULT_KEY_BINDINGS = 'default_key_bindings'; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @return string | ||
*/ | ||
public static function getDefaultKeyBindings(Pimcore\Model\User|UserProxy|null $user = null): string | ||
{ | ||
if(method_exists($user, 'getKeyBindings') && $user->getKeyBindings()) { | ||
return $user->getKeyBindings(); | ||
} | ||
|
||
$defaultKeyBindings = []; | ||
$container = Pimcore::getContainer(); | ||
$userConfig = $container->getParameter('pimcore_admin.user'); | ||
// make sure the default key binding node is in the config | ||
if (is_array($userConfig) && array_key_exists(self::DEFAULT_KEY_BINDINGS, $userConfig)) { | ||
$defaultKeyBindingsConfig = $userConfig[self::DEFAULT_KEY_BINDINGS]; | ||
if (!empty($defaultKeyBindingsConfig)) { | ||
foreach ($defaultKeyBindingsConfig as $keys) { | ||
$defaultKeyBinding = []; | ||
// we do not check if the keys are empty because key is required | ||
foreach ($keys as $index => $value) { | ||
if ($index === 'key') { | ||
$value = ord($value); | ||
} | ||
$defaultKeyBinding[$index] = $value; | ||
} | ||
$defaultKeyBindings[] = $defaultKeyBinding; | ||
} | ||
} | ||
} | ||
return json_encode($defaultKeyBindings); | ||
} | ||
} |