aimeos /
aimeos-base
| 1 | <?php |
||||
| 2 | |||||
| 3 | /** |
||||
| 4 | * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0 |
||||
| 5 | * @copyright Aimeos (aimeos.org), 2019-2026 |
||||
| 6 | * @package Base |
||||
| 7 | * @subpackage View |
||||
| 8 | */ |
||||
| 9 | |||||
| 10 | |||||
| 11 | namespace Aimeos\Base\View\Helper\Link; |
||||
| 12 | |||||
| 13 | |||||
| 14 | /** |
||||
| 15 | * View helper class for building URLs in a simple way |
||||
| 16 | * |
||||
| 17 | * @package Base |
||||
| 18 | * @subpackage View |
||||
| 19 | */ |
||||
| 20 | class Standard |
||||
| 21 | extends \Aimeos\Base\View\Helper\Base |
||||
| 22 | implements \Aimeos\Base\View\Helper\Link\Iface |
||||
| 23 | { |
||||
| 24 | /** |
||||
| 25 | * Returns the URL for the given parameter |
||||
| 26 | * |
||||
| 27 | * @param string $cfgkey Prefix of the configuration key for the URL settings |
||||
| 28 | * @param array $params Associative list of parameters that should be part of the URL |
||||
| 29 | * @param array $config Associated list of additional configuration |
||||
| 30 | * @param string[] $fragments Trailing URL fragment that are not relevant to identify the resource |
||||
| 31 | * @return string Complete URL that can be used in the template |
||||
| 32 | */ |
||||
| 33 | public function transform( string $cfgkey, array $params = [], $config = [], array $fragments = [] ) : string |
||||
| 34 | { |
||||
| 35 | $view = $this->view(); |
||||
| 36 | $cntl = $action = null; |
||||
| 37 | |||||
| 38 | if( count( $parts = explode( '/', $cfgkey ) ) > 4 ) |
||||
| 39 | { |
||||
| 40 | $list = array_slice( $parts, 2 ); |
||||
| 41 | $cntl = array_shift( $list ); |
||||
| 42 | $action = array_shift( $list ); |
||||
| 43 | } |
||||
| 44 | |||||
| 45 | $target = $view->config( $cfgkey . '/target' ); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 46 | $cntl = $view->config( $cfgkey . '/controller', $cntl ? ucfirst( $cntl ) : null ); |
||||
| 47 | $action = $view->config( $cfgkey . '/action', $action ); |
||||
| 48 | $config = array_replace( $view->config( $cfgkey . '/config', [] ), $config ); |
||||
| 49 | $filter = $view->config( $cfgkey . '/filter', [] ); |
||||
| 50 | |||||
| 51 | $params = array_diff_key( $params, array_flip( $filter ) ); |
||||
| 52 | |||||
| 53 | return $view->url( $target, $cntl, $action, $params, $fragments, $config ); |
||||
|
0 ignored issues
–
show
The method
url() does not exist on Aimeos\Base\View\Iface. Since you implemented __call, consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 54 | } |
||||
| 55 | } |
||||
| 56 |