/**
  * The main function for executing the command.
  */
 public function execute()
 {
     // Retrieve the values from the request
     $umbrellaId = $_REQUEST['umbrellaId'];
     // Retrieve other important values and objects
     $username = \Current_User::getUsername();
     $permissions = \AppSync\UmbrellaAdminFactory::getUmbrellaAdmin($username, $umbrellaId);
     // If the permissions array is empty then the user does not have permission to use this command
     // throw an error back to the front end.
     if (sizeof($permissions) == 0) {
         echo '<div style="display: none;">User does not have permission to access this data.</div>';
         exit;
     }
     // Attempt to retrieve the portals and do a fuzzy search of them for the searchString
     try {
         $portals = \AppSync\PortalFactory::getPortals();
         $searchString = $_REQUEST['searchString'];
         $umbrella = $_REQUEST['umbrellaId'];
         $portList = $this->portalFuzzySearch($searchString, $umbrella, $portals);
         echo $this->encodePortals($portList);
     } catch (\Exception $e) {
         echo '<div style="display: none;">' . $e->getMessage() . '</div>';
     }
     exit;
 }
 public function execute()
 {
     try {
         $portals = \AppSync\PortalFactory::getPortals();
         $searchString = $_REQUEST['searchString'];
         $umbrella = $_REQUEST['umbrellaId'];
         $portList = $this->portalFuzzySearch($searchString, $umbrella, $portals);
         echo $this->encodePortals($portList);
     } catch (Exception $e) {
         echo '<div style="display: none;">' . $e->getMessage() . '</div>';
     }
     exit;
 }