| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\Framework\Foundation; |
| 4 |
|
| 5 |
trait SetGetAttributesTrait |
| 6 |
{ |
| 7 |
/** |
| 8 |
* Dynamic getter for application |
| 9 |
* @param string $key |
| 10 |
* @return mixed |
| 11 |
*/ |
| 12 |
public function __get($key) |
| 13 |
{ |
| 14 |
return $this->make($key); |
| 15 |
} |
| 16 |
|
| 17 |
/** |
| 18 |
* Dynamic setter for application |
| 19 |
* @param string $key |
| 20 |
* @param mixed $value |
| 21 |
*/ |
| 22 |
public function __set($key, $value) |
| 23 |
{ |
| 24 |
$this[$key] = $value; |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* Getter for retrieving plugin's base file path |
| 29 |
* @return string |
| 30 |
*/ |
| 31 |
public function getBaseFile() |
| 32 |
{ |
| 33 |
return $this->baseFile; |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Get application's main config |
| 38 |
* @return array |
| 39 |
*/ |
| 40 |
public function getAppConfig() |
| 41 |
{ |
| 42 |
return $this->appConfig; |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Get application's providers |
| 47 |
* @param string $type [core|plugin] |
| 48 |
* @return array |
| 49 |
*/ |
| 50 |
public function getProviders($type = null) |
| 51 |
{ |
| 52 |
$providers = $this->getAppConfig()['providers']; |
| 53 |
|
| 54 |
return $type ? $providers[$type] : $providers; |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* Get plugin name |
| 59 |
* @return string |
| 60 |
*/ |
| 61 |
public function getName() |
| 62 |
{ |
| 63 |
return $this->getAppConfig()['plugin_name']; |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Get plugin slug |
| 68 |
* @return string |
| 69 |
*/ |
| 70 |
public function getSlug() |
| 71 |
{ |
| 72 |
return $this->appConfig['plugin_slug']; |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* Get plugin version |
| 77 |
* @return string |
| 78 |
*/ |
| 79 |
public function getVersion() |
| 80 |
{ |
| 81 |
return $this->appConfig['plugin_version']; |
| 82 |
} |
| 83 |
|
| 84 |
/** |
| 85 |
* Get plugin root namespace |
| 86 |
* @return string |
| 87 |
*/ |
| 88 |
public function getNamespace() |
| 89 |
{ |
| 90 |
return $this->getAppConfig()['autoload']['namespace']; |
| 91 |
} |
| 92 |
|
| 93 |
/** |
| 94 |
* Get plugin text domain |
| 95 |
* @return string |
| 96 |
*/ |
| 97 |
public function getTextDomain() |
| 98 |
{ |
| 99 |
return $this->appConfig['plugin_text_domain'] |
| 100 |
? $this->appConfig['plugin_text_domain'] |
| 101 |
: $this->appConfig['plugin_slug']; |
| 102 |
} |
| 103 |
|
| 104 |
/** |
| 105 |
* Get application evironment |
| 106 |
* @return string |
| 107 |
*/ |
| 108 |
public function getEnv() |
| 109 |
{ |
| 110 |
if (isset($this->getAppConfig()['env'])) { |
| 111 |
return $this->getAppConfig()['env']; |
| 112 |
} |
| 113 |
} |
| 114 |
} |