PluginProbe
Elementor Website Builder – more than just a page builder / 3.26.0-dev5
Elementor Website Builder – more than just a page builder v3.26.0-dev5
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / vendor_prefixed / php-di / php-di / src / Definition / Source / DefinitionFile.php

DefinitionFile.php in Elementor Website Builder – more than just a page builder 3.26.0-dev5, at vendor_prefixed/php-di/php-di/src/Definition/Source/DefinitionFile.php

57 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare (strict_types=1);
4 namespace ElementorDeps\DI\Definition\Source;
5
6 /**
7 * Reads DI definitions from a file returning a PHP array.
8 *
9 * @author Matthieu Napoli <matthieu@mnapoli.fr>
10 */
11 class DefinitionFile extends DefinitionArray
12 {
13 /**
14 * @var bool
15 */
16 private $initialized = \false;
17 /**
18 * File containing definitions, or null if the definitions are given as a PHP array.
19 * @var string|null
20 */
21 private $file;
22 /**
23 * @param string $file File in which the definitions are returned as an array.
24 */
25 public function __construct($file, Autowiring $autowiring = null)
26 {
27 // Lazy-loading to improve performances
28 $this->file = $file;
29 parent::__construct([], $autowiring);
30 }
31 public function getDefinition(string $name)
32 {
33 $this->initialize();
34 return parent::getDefinition($name);
35 }
36 public function getDefinitions() : array
37 {
38 $this->initialize();
39 return parent::getDefinitions();
40 }
41 /**
42 * Lazy-loading of the definitions.
43 */
44 private function initialize()
45 {
46 if ($this->initialized === \true) {
47 return;
48 }
49 $definitions = (require $this->file);
50 if (!\is_array($definitions)) {
51 throw new \Exception("File {$this->file} should return an array of definitions");
52 }
53 $this->addDefinitions($definitions);
54 $this->initialized = \true;
55 }
56 }
57