Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

AssetExtension.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 1.93 KiB


01  <?php
02   
03  /*
04   * This file is part of the Symfony package.
05   *
06   * (c) Fabien Potencier <fabien@symfony.com>
07   *
08   * For the full copyright and license information, please view the LICENSE
09   * file that was distributed with this source code.
10   */
11   
12  namespace Symfony\Bridge\Twig\Extension;
13   
14  use Symfony\Component\Asset\Packages;
15  use Twig\Extension\AbstractExtension;
16  use Twig\TwigFunction;
17   
18  /**
19   * Twig extension for the Symfony Asset component.
20   *
21   * @author Fabien Potencier <fabien@symfony.com>
22   */
23  class AssetExtension extends AbstractExtension
24  {
25      private $packages;
26   
27      public function __construct(Packages $packages)
28      {
29          $this->packages = $packages;
30      }
31   
32      /**
33       * {@inheritdoc}
34       */
35      public function getFunctions()
36      {
37          return [
38              new TwigFunction('asset', [$this, 'getAssetUrl']),
39              new TwigFunction('asset_version', [$this, 'getAssetVersion']),
40          ];
41      }
42   
43      /**
44       * Returns the public url/path of an asset.
45       *
46       * If the package used to generate the path is an instance of
47       * UrlPackage, you will always get a URL and not a path.
48       *
49       * @param string $path        A public path
50       * @param string $packageName The name of the asset package to use
51       *
52       * @return string The public path of the asset
53       */
54      public function getAssetUrl($path, $packageName = null)
55      {
56          return $this->packages->getUrl($path, $packageName);
57      }
58   
59      /**
60       * Returns the version of an asset.
61       *
62       * @param string $path        A public path
63       * @param string $packageName The name of the asset package to use
64       *
65       * @return string The asset version
66       */
67      public function getAssetVersion($path, $packageName = null)
68      {
69          return $this->packages->getVersion($path, $packageName);
70      }
71   
72      /**
73       * Returns the name of the extension.
74       *
75       * @return string The extension name
76       */
77      public function getName()
78      {
79          return 'asset';
80      }
81  }
82