src/Charcoal/Admin/ServiceProvider/AdminServiceProvider.php
protected function registerViewExtensions(Container $container)
    {
        if (!isset($container['view/mustache/helpers'])) {
            $container['view/mustache/helpers'] = function () {
                return [];
            };
        }

        /**
         * Extend helpers for the Mustache Engine
         *
         * @return array
         */
        $container->extend('view/mustache/helpers', function (array $helpers, Container $container) {
            $adminUrl = $container['admin/base-url'];

            $urls = [
                /**
                 * Alias of "siteUrl"
                 *
                 * @return UriInterface|null
                 */
                'adminUrl'     => $adminUrl,
                /**
                 * Prepend the administration-area URI to the given path.
                 *
                 * @see    \Charcoal\App\ServiceProvider\AppServiceProvider::registerViewServices()
                 * @param  string $uri A URI path to wrap.
                 * @return UriInterface|null
                 */
                'withAdminUrl' => function ($uri, LambdaHelper $helper = null) use ($adminUrl) {
                    if ($helper) {
                        $uri = $helper->render($uri);
                    }

                    $uri = strval($uri);
                    if ($uri === '') {
                        $uri = $adminUrl->withPath('');
                    } else {
                        $parts = parse_url($uri);
                        if (!isset($parts['scheme'])) {
                            if (!in_array($uri[0], ['/', '#', '?'])) {
                                $path  = isset($parts['path']) ? ltrim($parts['path'], '/') : '';
                                $query = isset($parts['query']) ? $parts['query'] : '';
                                $hash  = isset($parts['fragment']) ? $parts['fragment'] : '';

                                return $adminUrl->withPath($path)
                                                ->withQuery($query)
                                                ->withFragment($hash);
                            }
                        }
                    }

                    return $uri;
                }
            ];

            return array_merge($helpers, $urls);
        });
    }
protected function registerViewExtensions(Container $container)
    {
        if (!isset($container['view/mustache/helpers'])) {
            $container['view/mustache/helpers'] = function () {
                return [];
            };
        }

        /**
         * Extend helpers for the Mustache Engine
         *
         * @return array
         */
        $container->extend('view/mustache/helpers', function (array $helpers, Container $container) {
            $adminUrl = $container['admin/base-url'];

            $urls = [
                /**
                 * Alias of "siteUrl"
                 *
                 * @return UriInterface|null
                 */
                'adminUrl'     => $adminUrl,
                /**
                 * Prepend the administration-area URI to the given path.
                 *
                 * @see    \Charcoal\App\ServiceProvider\AppServiceProvider::registerViewServices()
                 * @param  string $uri A URI path to wrap.
                 * @return UriInterface|null
                 */
                'withAdminUrl' => function ($uri, LambdaHelper $helper = null) use ($adminUrl) {
                    if ($helper) {
                        $uri = $helper->render($uri);
                    }

                    $uri = strval($uri);
                    if ($uri === '') {
                        $uri = $adminUrl->withPath('');
                    } else {
                        $parts = parse_url($uri);
                        if (!isset($parts['scheme'])) {
                            if (!in_array($uri[0], ['/', '#', '?'])) {
                                $path  = isset($parts['path']) ? ltrim($parts['path'], '/') : '';
                                $query = isset($parts['query']) ? $parts['query'] : '';
                                $hash  = isset($parts['fragment']) ? $parts['fragment'] : '';

                                return $adminUrl->withPath($path)
                                                ->withQuery($query)
                                                ->withFragment($hash);
                            }
                        }
                    }

                    return $uri;
                }
            ];

            return array_merge($helpers, $urls);
        });
    }
protected function registerViewExtensions ( Container $ container ) { if ( ! isset ( $ container [ 'view/mustache/helpers' ] ) ) { $ container [ 'view/mustache/helpers' ] = function ( ) { return [ ] ; } ; } /**
         * Extend helpers for the Mustache Engine
         *
         * @return array
         */ $ container -> extend ( 'view/mustache/helpers' , function ( array $ helpers , Container $ container ) { $ adminUrl = $ container [ 'admin/base-url' ] ; $ urls = [ /**
                 * Alias of "siteUrl"
                 *
                 * @return UriInterface|null
                 */ 'adminUrl' => $ adminUrl , /**
                 * Prepend the administration-area URI to the given path.
                 *
                 * @see    \Charcoal\App\ServiceProvider\AppServiceProvider::registerViewServices()
                 * @param  string $uri A URI path to wrap.
                 * @return UriInterface|null
                 */ 'withAdminUrl' => function ( $ uri , LambdaHelper $ helper = null ) use ( $ adminUrl ) { if ( $ helper ) { $ uri = $ helper -> render ( $ uri ) ; } $ uri = strval ( $ uri ) ; if ( $ uri === '' ) { $ uri = $ adminUrl -> withPath ( '' ) ; } else { $ parts = parse_url ( $ uri ) ; if ( ! isset ( $ parts [ 'scheme' ] ) ) { if ( ! in_array ( $ uri [ 0 ] , [ '/' , '#' , '?' ] ) ) { $ path = isset ( $ parts [ 'path' ] ) ? ltrim ( $ parts [ 'path' ] , '/' ) : '' ; $ query = isset ( $ parts [ 'query' ] ) ? $ parts [ 'query' ] : '' ; $ hash = isset ( $ parts [ 'fragment' ] ) ? $ parts [ 'fragment' ] : '' ; return $ adminUrl -> withPath ( $ path ) -> withQuery ( $ query ) -> withFragment ( $ hash ) ; } } } return $ uri ; } ] ; return array_merge ( $ helpers , $ urls ) ; } ) ; }
Registers view extensions.

@param  Container $container The Pimple DI container.
@return void
Registers view extensions .