public function getMentions($text) {
    $mentions = [];
    $config_names = $this->mentionTypes;

    foreach ($config_names as $config_name) {
      $settings = $this->config->get('mentions.mentions_type.' . $config_name);
      $input_settings = [
        'prefix' => $settings->get('input.prefix'),
        'suffix' => $settings->get('input.suffix'),
        'entity_type' => $settings->get('input.entity_type'),
        'value' => $settings->get('input.inputvalue'),
      ];
      $this->inputSettings[$config_name] = $input_settings;

      if (!isset($input_settings['entity_type']) || empty($this->settings['mentions_filter'][$config_name])) {
        continue;
      }

      $output_settings = [
        'value' => $settings->get('output.outputvalue'),
        'renderlink' => (bool) $settings->get('output.renderlink'),
        'rendertextbox' => $settings->get('output.renderlinktextbox'),
      ];
      $this->outputSettings[$config_name] = $output_settings;
      $mention_type = $settings->get('mention_type');
      $mention = $this->mentionsManager->createInstance($mention_type);

      if ($mention instanceof MentionsPluginInterface) {
        $pattern = '/(?:' . preg_quote($input_settings['prefix']) . ')([a-zA-Z0-9_]+)' . preg_quote($input_settings['suffix']) . '/';
        preg_match_all($pattern, $text, $matches, PREG_SET_ORDER);

        foreach ($matches as $match) {
          $target = $mention->targetCallback($match[1], $input_settings);

          if ($target !== FALSE) {
            $mentions[$match[0]] = [
              'type' => $mention_type,
              'source' => [
                'string' => $match[0],
                'match' => $match[1],
              ],
              'target' => $target,
              'config_name' => $config_name,
            ];
          }
        }
      }
    }

    return $mentions;
  }
public function getMentions($text) {
    $mentions = [];
    $config_names = $this->mentionTypes;

    foreach ($config_names as $config_name) {
      $settings = $this->config->get('mentions.mentions_type.' . $config_name);
      $input_settings = [
        'prefix' => $settings->get('input.prefix'),
        'suffix' => $settings->get('input.suffix'),
        'entity_type' => $settings->get('input.entity_type'),
        'value' => $settings->get('input.inputvalue'),
      ];
      $this->inputSettings[$config_name] = $input_settings;

      if (!isset($input_settings['entity_type']) || empty($this->settings['mentions_filter'][$config_name])) {
        continue;
      }

      $output_settings = [
        'value' => $settings->get('output.outputvalue'),
        'renderlink' => (bool) $settings->get('output.renderlink'),
        'rendertextbox' => $settings->get('output.renderlinktextbox'),
      ];
      $this->outputSettings[$config_name] = $output_settings;
      $mention_type = $settings->get('mention_type');
      $mention = $this->mentionsManager->createInstance($mention_type);

      if ($mention instanceof MentionsPluginInterface) {
        $pattern = '/(?:' . preg_quote($input_settings['prefix']) . ')([a-zA-Z0-9_]+)' . preg_quote($input_settings['suffix']) . '/';
        preg_match_all($pattern, $text, $matches, PREG_SET_ORDER);

        foreach ($matches as $match) {
          $target = $mention->targetCallback($match[1], $input_settings);

          if ($target !== FALSE) {
            $mentions[$match[0]] = [
              'type' => $mention_type,
              'source' => [
                'string' => $match[0],
                'match' => $match[1],
              ],
              'target' => $target,
              'config_name' => $config_name,
            ];
          }
        }
      }
    }

    return $mentions;
  }
public function getMentions ( $ text ) { $ mentions = [ ] ; $ config_names = $ this -> mentionTypes ; foreach ( $ config_names as $ config_name ) { $ settings = $ this -> config -> get ( 'mentions.mentions_type.' . $ config_name ) ; $ input_settings = [ 'prefix' => $ settings -> get ( 'input.prefix' ) , 'suffix' => $ settings -> get ( 'input.suffix' ) , 'entity_type' => $ settings -> get ( 'input.entity_type' ) , 'value' => $ settings -> get ( 'input.inputvalue' ) , ] ; $ this -> inputSettings [ $ config_name ] = $ input_settings ; if ( ! isset ( $ input_settings [ 'entity_type' ] ) || empty ( $ this -> settings [ 'mentions_filter' ] [ $ config_name ] ) ) { continue ; } $ output_settings = [ 'value' => $ settings -> get ( 'output.outputvalue' ) , 'renderlink' => ( bool ) $ settings -> get ( 'output.renderlink' ) , 'rendertextbox' => $ settings -> get ( 'output.renderlinktextbox' ) , ] ; $ this -> outputSettings [ $ config_name ] = $ output_settings ; $ mention_type = $ settings -> get ( 'mention_type' ) ; $ mention = $ this -> mentionsManager -> createInstance ( $ mention_type ) ; if ( $ mention instanceof MentionsPluginInterface ) { $ pattern = '/(?:' . preg_quote ( $ input_settings [ 'prefix' ] ) . ')([a-zA-Z0-9_]+)' . preg_quote ( $ input_settings [ 'suffix' ] ) . '/' ; preg_match_all ( $ pattern , $ text , $ matches , PREG_SET_ORDER ) ; foreach ( $ matches as $ match ) { $ target = $ mention -> targetCallback ( $ match [ 1 ] , $ input_settings ) ; if ( $ target !== FALSE ) { $ mentions [ $ match [ 0 ] ] = [ 'type' => $ mention_type , 'source' => [ 'string' => $ match [ 0 ] , 'match' => $ match [ 1 ] , ] , 'target' => $ target , 'config_name' => $ config_name , ] ; } } } } return $ mentions ; }
Gets the mentions in text.

@param string $text
The text to find mentions in.

@return array
A list of mentions.
Gets the mentions in text .