Вопрос по $templater

-OZ-

Проверенные
Сообщения
107
Реакции
35
Баллы
19,525
Друзья, подскажите, пожалуйста, как можно заменить в этом фрагменте вызов кнопки на вызов ссылки?
return $templater->button($text, $options);
 
Некий плагин рендерит кнопку.
PHP:
 public static function renderIgnoreButton($value, array $params, Templater $templater)
    {
        $params = array_replace([
            'entity' => null,
            'userKey' => 'user_id',
            'contentType' => null
        ], $params);

        if (!($params['entity'] instanceof Entity)) {
            throw new \InvalidArgumentException('Invalid entity.');
        }
        $entity = $params['entity'];

        if (!\XF::visitor()->user_id) {
            return null;
        }

        $visitorId = \XF::visitor()->user_id;
        if ($params['userKey'] !== null) {
            $userId = $entity->getValue($params['userKey']);
            if ($userId == $visitorId) {
                return null;
            }
        }

        $contentType = self::getContentType($entity, $params);
        $contentId = $entity->getEntityId();

        if ($contentType === Listener::CONTENT_TYPE_FORUM
            && Listener::isDisabledNode($contentId)
        ) {
            return null;
        }

        $ignoreLink = \XF::app()
            ->router('public')
            ->buildLink(
                'misc/ignore-content',
                null,
                [
                    'content_type' => $contentType,
                    'content_id' => $contentId
                ]
            );

        $options = [
            'href' => $ignoreLink,
            'class' => 'menu-linkRow',
            'data-xf-click' => $contentType === Listener::CONTENT_TYPE_FORUM ? 'overlay' : 'switch'
        ];

        $ignoreContent = $entity->getRelation('IgnoreContent');
        /** @var Ignore|null $ignored */
        $ignored = $ignoreContent[$visitorId];
      
        if ($ignored) {
            $text = \XF::phrase('ignore_content.unignore');
        } else {
            $text = \XF::phrase('ignore_content.ignore');
        }

        return $templater->button($text, $options);
    }
Насколько я понимаю, рендер производится через вызов $templater->button($text, $options);
Соответственно, как можно сделать вместо кнопки ссылку?
 
Последнее редактирование:
Последнее редактирование:
.начнем с того, что этот плагин неправильно вообще обращается к этому методу, потому что ко всем методам templater нужно обращаться через fn
Бог с ним. Как сделать правильно?))
 
Современный облачный хостинг провайдер | Aéza
Назад
Сверху Снизу