vendor/uvdesk/core-framework/Services/UVDeskService.php line 158

Open in your IDE?
  1. <?php
  2. namespace Webkul\UVDesk\CoreFrameworkBundle\Services;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Symfony\Component\HttpFoundation\RequestStack;
  5. use Symfony\Component\DependencyInjection\ContainerInterface;
  6. use Webkul\UVDesk\SupportCenterBundle\Entity\KnowledgebaseWebsite;
  7. use Webkul\UVDesk\CoreFrameworkBundle\Services\UserService;
  8. class UVDeskService
  9. {
  10.     protected $container;
  11.     protected $requestStack;
  12.     protected $entityManager;
  13.     private $avoidArray = [
  14.         '!',
  15.         '@',
  16.         '#',
  17.         '$',
  18.         '%',
  19.         '^',
  20.         '&',
  21.         '*',
  22.         '(',
  23.         ')',
  24.         '_',
  25.         '+',
  26.         '-',
  27.         '=',
  28.         '/',
  29.         '\\',
  30.         ':',
  31.         '{',
  32.         '}',
  33.         '[',
  34.         ']',
  35.         '<',
  36.         '>',
  37.         '.',
  38.         '?',
  39.         ';',
  40.         '"',
  41.         '\'',
  42.         ',',
  43.         '|',
  44.         '1',
  45.         '2',
  46.         '3',
  47.         '4',
  48.         '5',
  49.         '6',
  50.         '7',
  51.         '8',
  52.         '9',
  53.         '0',
  54.         ' true ',
  55.         ' false ',
  56.         ' do ',
  57.         ' did ',
  58.         ' is ',
  59.         ' are ',
  60.         ' am ',
  61.         ' was ',
  62.         ' were ',
  63.         ' has ',
  64.         ' have ',
  65.         ' had ',
  66.         ' will ',
  67.         ' would ',
  68.         ' shall ',
  69.         ' should ',
  70.         ' must ',
  71.         ' can ',
  72.         ' could ',
  73.         ' not ',
  74.         ' never ',
  75.         ' neither ',
  76.         ' either ',
  77.         ' the ',
  78.         ' a ',
  79.         ' an ',
  80.         ' this ',
  81.         ' that ',
  82.         ' here ',
  83.         ' there ',
  84.         ' then ',
  85.         ' when ',
  86.         ' since ',
  87.         ' he ',
  88.         ' him ',
  89.         ' himself ',
  90.         ' she ',
  91.         ' her ',
  92.         ' herself ',
  93.         ' i ',
  94.         ' me ',
  95.         ' myself ',
  96.         ' mine ',
  97.         ' you ',
  98.         ' your ',
  99.         ' yourself ',
  100.         ' ur ',
  101.         ' we ',
  102.         ' ourself ',
  103.         ' it ',
  104.         ' its ',
  105.         ' for ',
  106.         ' from ',
  107.         ' on ',
  108.         ' and ',
  109.         ' in ',
  110.         ' be ',
  111.         ' to ',
  112.         ' or ',
  113.         ' of ',
  114.         ' with ',
  115.         ' what ',
  116.         ' why ',
  117.         ' where ',
  118.         ' who ',
  119.         ' whom ',
  120.         ' which ',
  121.         ' a ',
  122.         ' b ',
  123.         ' c ',
  124.         ' d ',
  125.         ' e ',
  126.         ' f ',
  127.         ' g ',
  128.         ' h ',
  129.         ' i ',
  130.         ' j ',
  131.         ' k ',
  132.         ' l ',
  133.         ' m ',
  134.         ' n ',
  135.         ' o ',
  136.         ' p ',
  137.         ' q ',
  138.         ' r ',
  139.         ' s ',
  140.         ' t ',
  141.         ' u ',
  142.         ' v ',
  143.         ' w ',
  144.         ' x ',
  145.         ' y ',
  146.         ' z ',
  147.         '  ',
  148.     ];
  149.     public function __construct(ContainerInterface $containerRequestStack $requestStackEntityManagerInterface $entityManagerUserService $userService)
  150.     {
  151.         $this->container $container;
  152.         $this->requestStack $requestStack;
  153.         $this->entityManager $entityManager;
  154.         $this->userService $userService;
  155.     }
  156.     public function updatesLocales($locales)
  157.     {
  158.         $fileTranslation $this->container->get('kernel')->getProjectDir() . '/config/packages/translation.yaml';
  159.         $fileServices $this->container->get('kernel')->getProjectDir() . '/config/services.yaml';
  160.         // get file content and index
  161.         $fileTrans file($fileTranslation);
  162.         $fileServs file($fileServices);
  163.         foreach ($fileTrans as $index => $content) {
  164.             if (false !== strpos($content'default_locale')) {
  165.                 list($helpdesk_panel_locales$helpdesk_panel_text) = array($index$content);
  166.             }
  167.             if (false !== strpos($content'- ')) {
  168.                 list($helpdesk_panel_locales_fallback$helpdesk_panel_text_fallback) = array($index$content);
  169.             }
  170.         }
  171.         foreach ($fileServs as $indexs => $contents) {
  172.             if (false !== strpos($contents'locale')) {
  173.                 list($helpdesk_services_locales$helpdesk_services_text) = array($indexs$contents);
  174.             }
  175.         }
  176.         // save updated data in a variable ($updatedFileContent)
  177.         $updatedFileContent $fileTrans;
  178.         $updatedServicesFileContent $fileServs;
  179.         $updatedlocales = (null !== $helpdesk_panel_locales) ? substr($helpdesk_panel_text0strpos($helpdesk_panel_text'default_locale') + strlen('default_locale: ')) . $locales PHP_EOL '';
  180.         $updatedlocales_fallback = (null !== $helpdesk_panel_locales_fallback) ? substr($helpdesk_panel_text_fallback0strpos($helpdesk_panel_text_fallback'- ') + strlen('- ')) . $locales PHP_EOL '';
  181.         $updatedServiceslocales = (null !== $helpdesk_services_locales) ? substr($helpdesk_services_text0strpos($helpdesk_services_text'locale') + strlen('locale: ')) . $locales PHP_EOL '';
  182.         $updatedFileContent[$helpdesk_panel_locales] = $updatedlocales;
  183.         $updatedFileContent[$helpdesk_panel_locales_fallback] = $updatedlocales_fallback;
  184.         $updatedServicesFileContent[$helpdesk_services_locales] = $updatedServiceslocales;
  185.         // flush updated content in file
  186.         $status file_put_contents($fileTranslation$updatedFileContent);
  187.         $status1 file_put_contents($fileServices$updatedServicesFileContent);
  188.         return true;
  189.     }
  190.     public function getLocalesList()
  191.     {
  192.         $translator $this->container->get('translator');
  193.         return  [
  194.             'en'    => $translator->trans("English"),
  195.             'fr'    => $translator->trans("French"),
  196.             'it'    => $translator->trans("Italian"),
  197.             'ar'    => $translator->trans("Arabic"),
  198.             'de'    => $translator->trans("German"),
  199.             'es'    => $translator->trans("Spanish"),
  200.             'tr'    => $translator->trans("Turkish"),
  201.             'da'    => $translator->trans("Danish"),
  202.             'zh'    => $translator->trans("Chinese"),
  203.             'pl'    => $translator->trans("Polish"),
  204.             'he'    => $translator->trans("Hebrew"),
  205.             'pt_BR' => $translator->trans("Portuguese"),
  206.         ];
  207.     }
  208.     public function getActiveLocales()
  209.     {
  210.         $localesList $this->getLocalesList();
  211.         $activeLocales $this->container->getParameter("app_locales");
  212.         $explodeActiveLocales explode("|"$activeLocales);
  213.         return $explodeActiveLocales;
  214.     }
  215.     public function getLocales()
  216.     {
  217.         $localesList $this->getLocalesList();
  218.         $explodeActiveLocales $this->getActiveLocales();
  219.         $listingActiveLocales = array();
  220.         foreach ($explodeActiveLocales as $key => $value) {
  221.             $listingActiveLocales[$value] = $localesList[$value];
  222.         }
  223.         return $listingActiveLocales;
  224.     }
  225.     public function getDefaultLangauge()
  226.     {
  227.         return $this->container->getParameter("kernel.default_locale");
  228.     }
  229.     public function getTimezones()
  230.     {
  231.         return \DateTimeZone::listIdentifiers();
  232.     }
  233.     public function getPrivileges()
  234.     {
  235.         $agentPrivilegeCollection = [];
  236.         // $agentPrivilegeCollection = $this->entityManager->getRepository('UserBundle:AgentPrivilege')->findAll();
  237.         return $agentPrivilegeCollection;
  238.     }
  239.     public function getLocaleUrl($locale)
  240.     {
  241.         $request $this->requestStack->getCurrentRequest();
  242.         return str_replace('/' $request->getLocale() . '/''/' $locale '/'$request->getRequestUri());
  243.     }
  244.     public function buildPaginationQuery(array $query = [])
  245.     {
  246.         $params = array();
  247.         $query['page'] = "replacePage";
  248.         if (isset($query['domain'])) unset($query['domain']);
  249.         if (isset($query['_locale'])) unset($query['_locale']);
  250.         foreach ($query as $key => $value) {
  251.             $params[] = !isset($value) ? $key $key '/' str_replace('%2F''/'rawurlencode($value));
  252.         }
  253.         $http_query implode('/'$params);
  254.         if (isset($query['new'])) {
  255.             $http_query str_replace('new/1''new'$http_query);
  256.         } elseif (isset($query['unassigned'])) {
  257.             $http_query str_replace('unassigned/1''unassigned'$http_query);
  258.         } elseif (isset($query['notreplied'])) {
  259.             $http_query str_replace('notreplied/1''notreplied'$http_query);
  260.         } elseif (isset($query['mine'])) {
  261.             $http_query str_replace('mine/1''mine'$http_query);
  262.         } elseif (isset($query['starred'])) {
  263.             $http_query str_replace('starred/1''starred'$http_query);
  264.         } elseif (isset($query['trashed'])) {
  265.             $http_query str_replace('trashed/1''trashed'$http_query);
  266.         }
  267.         return $http_query;
  268.     }
  269.     public function getEntityManagerResult($entity$callFunction$args false$extraPrams false)
  270.     {
  271.         if ($extraPrams)
  272.             return $this->entityManager->getRepository($entity)
  273.                 ->$callFunction($args$extraPrams);
  274.         else
  275.             return $this->entityManager->getRepository($entity)
  276.                 ->$callFunction($args);
  277.     }
  278.     public function getValidBroadcastMessage($msg$format 'Y-m-d H:i:s')
  279.     {
  280.         $broadcastMessage = !empty($msg) ? json_decode($msgtrue) : false;
  281.         if (
  282.             ! empty($broadcastMessage)
  283.             && isset($broadcastMessage['isActive'])
  284.             && $broadcastMessage['isActive']
  285.         ) {
  286.             $timezone = new \DateTimeZone('Asia/Kolkata');
  287.             $nowTimestamp date('U');
  288.             if (array_key_exists('from'$broadcastMessage) && ($fromDateTime \DateTime::createFromFormat($format$broadcastMessage['from'], $timezone))) {
  289.                 $fromTimeStamp $fromDateTime->format('U');
  290.                 if ($nowTimestamp $fromTimeStamp) {
  291.                     return false;
  292.                 }
  293.             }
  294.             if (array_key_exists('to'$broadcastMessage) && ($toDateTime \DateTime::createFromFormat($format$broadcastMessage['to'], $timezone))) {
  295.                 $toTimeStamp $toDateTime->format('U');;
  296.                 if ($nowTimestamp $toTimeStamp) {
  297.                     return false;
  298.                 }
  299.             }
  300.         } else {
  301.             return false;
  302.         }
  303.         // return valid broadcast message Array
  304.         return $broadcastMessage;
  305.     }
  306.     public function getConfigParameter($param)
  307.     {
  308.         if (
  309.             $param
  310.             && $this->container->hasParameter($param)
  311.         ) {
  312.             return $this->container->getParameter($param);
  313.         } else {
  314.             return false;
  315.         }
  316.     }
  317.     public function isDarkSkin($brandColor)
  318.     {
  319.         $brandColor str_replace('#'''$brandColor);
  320.         if (strlen($brandColor) == 3)
  321.             $brandColor .= $brandColor;
  322.         $chars str_split($brandColor);
  323.         $a2fCount 0;
  324.         foreach ($chars as $key => $char) {
  325.             if (in_array($key, [024]) && in_array(strtoupper($char), ['A''B''C''D''E''F'])) {
  326.                 $a2fCount++;
  327.             }
  328.         }
  329.         if ($a2fCount >= 2)
  330.             return true;
  331.         else
  332.             return false;
  333.     }
  334.     public function getActiveConfiguration($websiteId)
  335.     {
  336.         $configurationRepo $this->entityManager->getRepository(KnowledgebaseWebsite::class);
  337.         $configuration $configurationRepo->findOneBy(['website' => $websiteId'isActive' => 1]);
  338.         return $configuration;
  339.     }
  340.     public function getSupportPrivelegesResources()
  341.     {
  342.         $translator $this->container->get('translator');
  343.         return [
  344.             'ticket' => [
  345.                 'ROLE_AGENT_CREATE_TICKET'                   => $translator->trans('Can create ticket'),
  346.                 'ROLE_AGENT_EDIT_TICKET'                     => $translator->trans('Can edit ticket'),
  347.                 'ROLE_AGENT_DELETE_TICKET'                   => $translator->trans('Can delete ticket'),
  348.                 'ROLE_AGENT_RESTORE_TICKET'                  => $translator->trans('Can restore trashed ticket'),
  349.                 'ROLE_AGENT_ASSIGN_TICKET'                   => $translator->trans('Can assign ticket'),
  350.                 'ROLE_AGENT_ASSIGN_TICKET_GROUP'             => $translator->trans('Can assign ticket group'),
  351.                 'ROLE_AGENT_UPDATE_TICKET_STATUS'            => $translator->trans('Can update ticket status'),
  352.                 'ROLE_AGENT_UPDATE_TICKET_PRIORITY'          => $translator->trans('Can update ticket priority'),
  353.                 'ROLE_AGENT_UPDATE_TICKET_TYPE'              => $translator->trans('Can update ticket type'),
  354.                 'ROLE_AGENT_ADD_NOTE'                        => $translator->trans('Can add internal notes to ticket'),
  355.                 'ROLE_AGENT_EDIT_THREAD_NOTE'                => $translator->trans('Can edit thread/notes'),
  356.                 'ROLE_AGENT_MANAGE_LOCK_AND_UNLOCK_THREAD'   => $translator->trans('Can lock/unlock thread'),
  357.                 'ROLE_AGENT_ADD_COLLABORATOR_TO_TICKET'      => $translator->trans('Can add collaborator to ticket'),
  358.                 'ROLE_AGENT_DELETE_COLLABORATOR_FROM_TICKET' => $translator->trans('Can delete collaborator from ticket'),
  359.                 'ROLE_AGENT_DELETE_THREAD_NOTE'              => $translator->trans('Can delete thread/notes'),
  360.                 'ROLE_AGENT_APPLY_WORKFLOW'                  => $translator->trans('Can apply prepared response on ticket'),
  361.                 'ROLE_AGENT_ADD_TAG'                         => $translator->trans('Can add ticket tags'),
  362.                 'ROLE_AGENT_DELETE_TAG'                      => $translator->trans('Can delete ticket tags')
  363.             ],
  364.             'advanced' => [
  365.                 'ROLE_AGENT_MANAGE_EMAIL_TEMPLATE'         => $translator->trans('Can manage email templates'),
  366.                 'ROLE_AGENT_MANAGE_GROUP'                  => $translator->trans('Can manage groups'),
  367.                 'ROLE_AGENT_MANAGE_SUB_GROUP'              => $translator->trans('Can manage Sub-Groups/ Teams'),
  368.                 'ROLE_AGENT_MANAGE_AGENT'                  => $translator->trans('Can manage agents'),
  369.                 'ROLE_AGENT_MANAGE_AGENT_PRIVILEGE'        => $translator->trans('Can manage agent privileges'),
  370.                 'ROLE_AGENT_MANAGE_TICKET_TYPE'            => $translator->trans('Can manage ticket types'),
  371.                 'ROLE_AGENT_MANAGE_CUSTOMER'               => $translator->trans('Can manage customers'),
  372.                 'ROLE_AGENT_MANAGE_WORKFLOW_MANUAL'        => $translator->trans('Can manage Prepared Responses'),
  373.                 'ROLE_AGENT_MANAGE_WORKFLOW_AUTOMATIC'     => $translator->trans('Can manage Automatic workflow'),
  374.                 'ROLE_AGENT_MANAGE_TAG'                    => $translator->trans('Can manage tags'),
  375.                 'ROLE_AGENT_MANAGE_KNOWLEDGEBASE'          => $translator->trans('Can manage knowledgebase'),
  376.                 'ROLE_AGENT_MANAGE_AGENT_ACTIVITY'         => $translator->trans("Can manage agent activity"),
  377.                 'ROLE_AGENT_MANAGE_MARKETING_ANNOUNCEMENT' => $translator->trans("Can manage marketing announcement"),
  378.                 'ROLE_AGENT_MANAGE_APP'                    => $translator->trans("Can manage apps"),
  379.             ]
  380.         ];
  381.     }
  382.     public function generateCsrfToken($intention)
  383.     {
  384.         $csrf $this->container->get('security.csrf.token_manager');
  385.         return $csrf->getToken($intention)->getValue();
  386.     }
  387.     /**
  388.      * This function will create content text from recived text, which we can use in meta content and as well in searching save like elastic
  389.      * @param  string $text String text
  390.      * @param  no. $length max return length string (which will convert to array)
  391.      * @param  boolean $returnArray what return type required
  392.      * @return string/ array comma seperated/ []
  393.      */
  394.     public function createConentToKeywords($text$length 255$returnArray false)
  395.     {
  396.         //to remove all tags from text, if any tags are in encoded form
  397.         $newText preg_replace('/[\s]+/'' 'str_replace($this->avoidArray' 'strtolower(strip_tags(html_entity_decode(strip_tags($text))))));
  398.         if ($length)
  399.             $newText substr($newText0$length);
  400.         return ($returnArray explode(' '$newText) : str_replace(' '','$newText));
  401.     }
  402.     public function requestHeadersSent()
  403.     {
  404.         return headers_sent() ? true false;
  405.     }
  406.     /**
  407.      * get current prefixes of member panel and knowledgebase
  408.      */
  409.     public function getCurrentWebsitePrefixes()
  410.     {
  411.         $filePath $this->container->get('kernel')->getProjectDir() . '/config/packages/uvdesk.yaml';
  412.         // get file content and index
  413.         $file file($filePath);
  414.         foreach ($file as $index => $content) {
  415.             if (false !== strpos($content'uvdesk_site_path.member_prefix')) {
  416.                 list($member_panel_line$member_panel_text) = array($index$content);
  417.             }
  418.             if (false !== strpos($content'uvdesk_site_path.knowledgebase_customer_prefix')) {
  419.                 list($customer_panel_line$customer_panel_text) = array($index$content);
  420.             }
  421.         }
  422.         $memberPrefix substr($member_panel_textstrpos($member_panel_text'uvdesk_site_path.member_prefix') + strlen('uvdesk_site_path.member_prefix: '));
  423.         $knowledgebasePrefix substr($customer_panel_textstrpos($customer_panel_text'uvdesk_site_path.knowledgebase_customer_prefix') + strlen('uvdesk_site_path.knowledgebase_customer_prefix: '));
  424.         return [
  425.             'memberPrefix'        => trim(preg_replace('/\s\s+/'' '$memberPrefix)),
  426.             'knowledgebasePrefix' => trim(preg_replace('/\s\s+/'' '$knowledgebasePrefix)),
  427.         ];
  428.     }
  429.     /**
  430.      * update your website prefixes
  431.      */
  432.     public function updateWebsitePrefixes($member_panel_prefix$knowledgebase_prefix)
  433.     {
  434.         $filePath $this->container->get('kernel')->getProjectDir() . '/config/packages/uvdesk.yaml';
  435.         $website_prefixes = [
  436.             'member_prefix'   => $member_panel_prefix,
  437.             'customer_prefix' => $knowledgebase_prefix,
  438.         ];
  439.         // get file content and index
  440.         $file file($filePath);
  441.         foreach ($file as $index => $content) {
  442.             if (false !== strpos($content'uvdesk_site_path.member_prefix')) {
  443.                 list($member_panel_line$member_panel_text) = array($index$content);
  444.             }
  445.             if (false !== strpos($content'uvdesk_site_path.knowledgebase_customer_prefix')) {
  446.                 list($customer_panel_line$customer_panel_text) = array($index$content);
  447.             }
  448.         }
  449.         // save updated data in a variable ($updatedFileContent)
  450.         $updatedFileContent $file;
  451.         // get old member-prefix
  452.         $oldMemberPrefix substr($member_panel_textstrpos($member_panel_text'uvdesk_site_path.member_prefix') + strlen('uvdesk_site_path.member_prefix: '));
  453.         $oldMemberPrefix preg_replace('/([\r\n\t])/'''$oldMemberPrefix);
  454.         $updatedPrefixForMember = (null !== $member_panel_line) ? substr($member_panel_text0strpos($member_panel_text'uvdesk_site_path.member_prefix') + strlen('uvdesk_site_path.member_prefix: ')) . $website_prefixes['member_prefix'] . PHP_EOL '';
  455.         $updatedPrefixForCustomer = (null !== $customer_panel_line) ? substr($customer_panel_text0strpos($customer_panel_text'uvdesk_site_path.knowledgebase_customer_prefix') + strlen('uvdesk_site_path.knowledgebase_customer_prefix: ')) . $website_prefixes['customer_prefix'] . PHP_EOL '';
  456.         $updatedFileContent[$member_panel_line] = $updatedPrefixForMember;
  457.         $updatedFileContent[$customer_panel_line] = $updatedPrefixForCustomer;
  458.         // flush updated content in file
  459.         file_put_contents($filePath$updatedFileContent);
  460.         $router $this->container->get('router');
  461.         $knowledgebaseURL $router->generate('helpdesk_knowledgebase');
  462.         $memberLoginURL $router->generate('helpdesk_member_handle_login');
  463.         $memberLoginURL str_replace($oldMemberPrefix$website_prefixes['member_prefix'], $memberLoginURL);
  464.         return $collectionURL = [
  465.             'memberLogin'   => $memberLoginURL,
  466.             'knowledgebase' => $knowledgebaseURL,
  467.         ];
  468.     }
  469.     public static function getTimeFormats()
  470.     {
  471.         return array(
  472.             'm-d-y G:i'    => 'm-d-y G:i (01-15-1991 13:00)',
  473.             'm-d-y h:ia'   => 'm-d-y h:ia (01-15-1991 01:00pm)',
  474.             'd-m-y G:i'    => 'd-m-y G:i (15-01-1991 13:00)',
  475.             'd-m-y h:ia'   => 'd-m-y h:ia (15-01-1991 01:00pm)',
  476.             'd-m G:i'      => 'd-m G:i (15-01 13:00)',
  477.             'd-m h:ia'     => 'd-m h:ia (15-01 01:00pm)',
  478.             'd-M G:i'      => 'd-M G:i (15-Jan 13:00)',
  479.             'd-M h:ia'     => 'd-M h:ia (15-Jan 01:00pm)',
  480.             'D-m G:i'      => 'D-m G:i (Mon-01 13:00)',
  481.             'D-m h:ia'     => 'D-m h:ia (Mon-01 01:00pm)',
  482.             'Y-m-d H:i:sa' => 'Y-m-d H:i:s (1991-01-15 01:00:30pm)',
  483.         );
  484.     }
  485.     public function generateCompleteLocalResourcePathUri($resource)
  486.     {
  487.         $resourceUriComponent parse_url($resource);
  488.         if (!empty($resourceUriComponent['scheme'])) {
  489.             return $resource;
  490.         }
  491.         if (empty($this->completeLocalResourcePathUri)) {
  492.             $router $this->container->get('router');
  493.             $scheme $router->getContext()->getScheme();
  494.             $siteurl $this->container->getParameter('uvdesk.site_url');
  495.             $baseurl "$scheme://$siteurl";
  496.             $urlComponents parse_url($baseurl);
  497.             $completeLocalResourcePathUri "{$urlComponents['scheme']}://{$urlComponents['host']}";
  498.             if (!empty($urlComponents['path'])) {
  499.                 $completeLocalResourcePathUri .= $urlComponents['path'];
  500.             }
  501.             if (substr($completeLocalResourcePathUri, -1) == '/') {
  502.                 $completeLocalResourcePathUri substr($completeLocalResourcePathUri0, -1);
  503.             }
  504.             $this->completeLocalResourcePathUri $completeLocalResourcePathUri;
  505.         }
  506.         if ($resource[0] != '/') {
  507.             $resource "/$resource";
  508.         }
  509.         return $this->completeLocalResourcePathUri $resource;
  510.     }
  511.     public function getAvailableUserAccessScopes($user$userInstance)
  512.     {
  513.         $supportRole $userInstance->getSupportRole();
  514.         $isAdminAccessGranted in_array($supportRole->getId(), [12]) ? true false;
  515.         $availableSupportPrivileges $this->getSupportPrivelegesResources();
  516.         $resolvedAvailableSupportPrivileges = [];
  517.         foreach ($availableSupportPrivileges as $index => $collection) {
  518.             foreach ($collection as $privilegeId => $privilegeDescription) {
  519.                 $resolvedAvailableSupportPrivileges[] = $privilegeId;
  520.             }
  521.         }
  522.         if (false == $isAdminAccessGranted) {
  523.             $assignedUserSupportPrivileges $this->userService->getAssignedUserSupportPrivilegeDetails($user$userInstance);
  524.             $resolvedAssignedUserSupportPrivileges = [];
  525.             foreach ($assignedUserSupportPrivileges as $assignedSupportPrivilege) {
  526.                 foreach ($assignedSupportPrivilege['privileges'] as $privilegeId) {
  527.                     $resolvedAssignedUserSupportPrivileges[] = $privilegeId;
  528.                 }
  529.             }
  530.             return array_map(function ($supportPrivilege) {
  531.                 return strtolower(str_replace('ROLE_AGENT_'''$supportPrivilege));
  532.             }, $resolvedAssignedUserSupportPrivileges);
  533.         }
  534.         return array_map(function ($supportPrivilege) {
  535.             return strtolower(str_replace('ROLE_AGENT_'''$supportPrivilege));
  536.         }, $resolvedAvailableSupportPrivileges);
  537.     }
  538. }