mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-15 06:09:58 +08:00
implement ArrayAccess interface for plugins
This commit is contained in:
parent
043dabaccf
commit
33b89db7f5
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use ArrayAccess;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
@ -12,7 +13,7 @@ use Illuminate\Contracts\Support\Arrayable;
|
||||
* @property string $title
|
||||
* @property array $author
|
||||
*/
|
||||
class Plugin implements Arrayable
|
||||
class Plugin implements Arrayable, ArrayAccess
|
||||
{
|
||||
/**
|
||||
* The directory of this plugin.
|
||||
@ -182,6 +183,51 @@ class Plugin implements Arrayable
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given option option exists.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public function offsetExists($key)
|
||||
{
|
||||
return Arr::has($this->packageInfo, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a option option.
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function offsetGet($key)
|
||||
{
|
||||
return $this->packageInfoAttribute($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a option option.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($key, $value)
|
||||
{
|
||||
return Arr::set($this->packageInfo, $key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset a option option.
|
||||
*
|
||||
* @param string $key
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($key)
|
||||
{
|
||||
unset($this->packageInfo[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an array result for the object.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user