PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.23
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.23
1.10.25 1.10.24 1.10.23 1.10.22 1.10.21 1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 All 169 releases
woocommerce-pos / vendor / mustache / mustache / src / Loader / CascadingLoader.php

CascadingLoader.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.23, at vendor/mustache/mustache/src/Loader/CascadingLoader.php

73 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of Mustache.php.
5 *
6 * (c) 2010-2026 Justin Hileman
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Mustache\Loader;
13
14 use Mustache\Exception\UnknownTemplateException;
15 use Mustache\Loader;
16
17 /**
18 * A Mustache Template cascading loader implementation, which delegates to other
19 * Loader instances.
20 */
21 class CascadingLoader implements Loader
22 {
23 private $loaders;
24
25 /**
26 * Construct a CascadingLoader with an array of loaders.
27 *
28 * $loader = new CascadingLoader([
29 * new InlineLoader(__FILE__, __COMPILER_HALT_OFFSET__),
30 * new FilesystemLoader(__DIR__.'/templates')
31 * ]);
32 *
33 * @param Loader[] $loaders
34 */
35 public function __construct(array $loaders = [])
36 {
37 $this->loaders = [];
38 foreach ($loaders as $loader) {
39 $this->addLoader($loader);
40 }
41 }
42
43 /**
44 * Add a Loader instance.
45 */
46 public function addLoader(Loader $loader)
47 {
48 $this->loaders[] = $loader;
49 }
50
51 /**
52 * Load a Template by name.
53 *
54 * @throws UnknownTemplateException If a template file is not found
55 *
56 * @param string $name
57 *
58 * @return string Mustache Template source
59 */
60 public function load($name)
61 {
62 foreach ($this->loaders as $loader) {
63 try {
64 return $loader->load($name);
65 } catch (UnknownTemplateException $e) {
66 // do nothing, check the next loader.
67 }
68 }
69
70 throw new UnknownTemplateException($name);
71 }
72 }
73