src/AclInlineCkEditorBundle/Controller/DefaultController.php line 14

Open in your IDE?
  1. <?php
  2. namespace AclInlineCkEditorBundle\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  4. use Pimcore\Model\WebsiteSetting;
  5. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  6. class DefaultController extends Controller
  7. {
  8.     /**
  9.      * @Route("/")
  10.      */
  11.     public function indexAction()
  12.     {
  13.         return $this->redirectToRoute("pimcore_admin_index");
  14.     }
  15.     /**
  16.      * @Route("/replaceTextConfig", name="replace_text_config", methods={"GET"})
  17.      */
  18.     public function replaceTextAction()
  19.     {
  20.         $replaceSettings WebsiteSetting::getByName('replaceValue'null);
  21.         if (!$replaceSettings) {
  22.             return $this->json([]);
  23.         }
  24.         $formattedValues = [];
  25.         if ($values $replaceSettings->getData()) {
  26.             $a explode(','$values);
  27.             foreach ($a as $result) {
  28.                 $b explode('-'$result);
  29.                 $key $this->transformUnicode(trim($b[0]));
  30.                 if (count($b) > 1) {
  31.                     $value $b[1];
  32.                 } else {
  33.                     $value "";
  34.                 }
  35.                 $formattedValues[$key] = $value;
  36.             }
  37.         }
  38.         return $this->json($formattedValues);
  39.     }
  40.     public function transformUnicode(string $data): ?string
  41.     {
  42.         $newChar "%" str_replace("+"""$data);
  43.         $newChar strtolower($newChar);
  44.         $newChar preg_replace('/%u([0-9A-F]+)/''&#x$1;'$newChar);
  45.         return html_entity_decode($newCharENT_COMPAT'UTF-8');
  46.     }
  47. }