public function LinkStatusHandlerBase::handle in Link checker 8
Handles a status code of link.
Parameters
\Drupal\linkchecker\LinkCheckerLinkInterface $link: The link.
\Psr\Http\Message\ResponseInterface $response: The response of link checking.
Overrides LinkStatusHandlerInterface::handle
File
- src/
Plugin/ LinkStatusHandlerBase.php, line 107
Class
- LinkStatusHandlerBase
- Base class for Link status handler plugins.
Namespace
Drupal\linkchecker\PluginCode
public function handle(LinkCheckerLinkInterface $link, ResponseInterface $response) {
$this
->switchSession();
$entity = $link
->getParentEntity();
// Fields could be translatable.
// We should work with translation only.
if ($entity instanceof TranslatableInterface) {
if ($entity
->hasTranslation($link
->getParentEntityLangcode())) {
$entity = $entity
->getTranslation($link
->getParentEntityLangcode());
$this
->doHandle($link, $response, $entity);
}
}
else {
$this
->doHandle($link, $response, $entity);
}
$this
->switchSessionBack();
}