PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 1.2.4
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v1.2.4
6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 3.6.66 All 195 releases
fluentform / framework / Foundation / FacadeLoaderTrait.php

FacadeLoaderTrait.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 1.2.4, at framework/Foundation/FacadeLoaderTrait.php

58 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 namespace FluentForm\Framework\Foundation;
4
5 trait FacadeLoaderTrait
6 {
7 /**
8 * Register facade/alias loader
9 * @return void
10 */
11 protected function registerAppFacadeLoader()
12 {
13 $this->isFacadeLoaderRegistered = true;
14 spl_autoload_register([$this, 'aliasLoader'], true, false);
15 }
16
17 /**
18 * Facad/Alias loader
19 * @param [type] $class [description]
20 * @return [type] [description]
21 */
22 protected function aliasLoader($class)
23 {
24 $namespace = $this->getNamespace();
25 if ($namespace == substr($class, 0, strlen($namespace))) {
26 $parts = explode('\\', $class);
27 if (count($parts) == 2) {
28 if (array_key_exists($parts[1], static::$container['facades'])) {
29 $containerKey = static::$container['facades'][$facade = $parts[1]];
30 $path = $this->storagePath().'framework/facades/';
31 if (!file_exists($file = $path.$facade.'.php')) {
32 if (!file_exists($path)) {
33 mkdir($path, 0777, true);
34 }
35 file_put_contents($file, $this->getFileData($facade, $containerKey));
36 }
37 include $file;
38 }
39 }
40 }
41 }
42
43 /**
44 * Retrieve facade file content
45 * @param string $alias
46 * @param string $key
47 * @return string
48 */
49 protected function getFileData($alias, $key)
50 {
51 return str_replace(
52 ['DummyNamespace', 'DummyClass', 'DummyKey'],
53 [$this->getNamespace(), $alias, $key],
54 file_get_contents($this->frameworkPath().'Foundation/Facade.stub')
55 );
56 }
57 }
58