1
0

adding kirby3-janitor

This commit is contained in:
Philip Wagner
2024-10-14 14:22:24 +02:00
parent b0db09492d
commit 94fbb996f0
204 changed files with 27855 additions and 4 deletions

View 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);
}
}

View 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));
}
}

View 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);
}
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace League\CLImate\Settings;
interface SettingsInterface
{
/**
* @return void
*/
public function add();
}