adding kirby3-janitor
This commit is contained in:
22
vendor/league/climate/src/Settings/Art.php
vendored
Normal file
22
vendor/league/climate/src/Settings/Art.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace League\CLImate\Settings;
|
||||
|
||||
class Art implements SettingsInterface
|
||||
{
|
||||
/**
|
||||
* An array of valid art directories
|
||||
* @var array[] $dirs
|
||||
*/
|
||||
public $dirs = [];
|
||||
|
||||
/**
|
||||
* Add directories of art
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$this->dirs = array_merge($this->dirs, func_get_args());
|
||||
$this->dirs = array_filter($this->dirs);
|
||||
$this->dirs = array_values($this->dirs);
|
||||
}
|
||||
}
|
||||
84
vendor/league/climate/src/Settings/Manager.php
vendored
Normal file
84
vendor/league/climate/src/Settings/Manager.php
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace League\CLImate\Settings;
|
||||
|
||||
class Manager
|
||||
{
|
||||
/**
|
||||
* An array of settings that have been... set
|
||||
*
|
||||
* @var array $settings
|
||||
*/
|
||||
protected $settings = [];
|
||||
|
||||
/**
|
||||
* Check and see if the requested setting is a valid, registered setting
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function exists($name)
|
||||
{
|
||||
return class_exists($this->getPath($name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a setting
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function add($name, $value)
|
||||
{
|
||||
$setting = $this->getPath($name);
|
||||
$key = $this->getClassName($name);
|
||||
|
||||
// If the current key doesn't exist in the settings array, set it up
|
||||
if (!array_key_exists($name, $this->settings)) {
|
||||
$this->settings[$key] = new $setting();
|
||||
}
|
||||
|
||||
$this->settings[$key]->add($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the requested setting if it exists
|
||||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
if (array_key_exists($key, $this->settings)) {
|
||||
return $this->settings[$key];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the short name for the requested settings class
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getPath($name)
|
||||
{
|
||||
return 'League\CLImate\Settings\\' . $this->getClassName($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the short class name for the setting
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getClassName($name)
|
||||
{
|
||||
return ucwords(str_replace('add_', '', $name));
|
||||
}
|
||||
}
|
||||
32
vendor/league/climate/src/Settings/SettingsImporter.php
vendored
Normal file
32
vendor/league/climate/src/Settings/SettingsImporter.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace League\CLImate\Settings;
|
||||
|
||||
trait SettingsImporter
|
||||
{
|
||||
/**
|
||||
* Dictates any settings that a class may need access to
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function settings()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Import the setting into the class
|
||||
*
|
||||
* @param \League\CLImate\Settings\SettingsInterface $setting
|
||||
*/
|
||||
public function importSetting($setting)
|
||||
{
|
||||
$short_name = basename(str_replace('\\', '/', get_class($setting)));
|
||||
|
||||
$method = 'importSetting' . $short_name;
|
||||
|
||||
if (method_exists($this, $method)) {
|
||||
$this->$method($setting);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
vendor/league/climate/src/Settings/SettingsInterface.php
vendored
Normal file
11
vendor/league/climate/src/Settings/SettingsInterface.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace League\CLImate\Settings;
|
||||
|
||||
interface SettingsInterface
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function add();
|
||||
}
|
||||
Reference in New Issue
Block a user