src/View/Helper/FormLinksFactory.php
<?php /** * This file is part of the mimmi20/laminas-form-element-links package. * * Copyright (c) 2021-2025, Thomas Mueller <mimmi20@live.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ declare(strict_types = 1); namespace Mimmi20\Form\Links\View\Helper; use Laminas\I18n\View\Helper\Translate;use Laminas\View\Helper\EscapeHtml;use Laminas\View\HelperPluginManager;use Psr\Container\ContainerExceptionInterface;use Psr\Container\ContainerInterface; use function assert;use function get_debug_type;use function sprintf; final class FormLinksFactory{ /** @throws ContainerExceptionInterface */ public function __invoke(ContainerInterface $container): FormLinks { $plugin = $container->get(HelperPluginManager::class); assert( $plugin instanceof HelperPluginManager, sprintf( '$plugin should be an Instance of %s, but was %s', HelperPluginManager::class, get_debug_type($plugin), ), ); $translator = null; if ($plugin->has(Translate::class)) { $translator = $plugin->get(Translate::class); assert($translator instanceof Translate); } $escapeHtml = $plugin->get(EscapeHtml::class); assert($escapeHtml instanceof EscapeHtml); return new FormLinks($escapeHtml, $translator); }}