123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace OC\Share20;
- use OCP\Share\IAttributes;
- class ShareAttributes implements IAttributes {
-
- private $attributes;
- public function __construct() {
- $this->attributes = [];
- }
-
- public function setAttribute($scope, $key, $enabled) {
- if (!\array_key_exists($scope, $this->attributes)) {
- $this->attributes[$scope] = [];
- }
- $this->attributes[$scope][$key] = $enabled;
- return $this;
- }
-
- public function getAttribute($scope, $key) {
- if (\array_key_exists($scope, $this->attributes) &&
- \array_key_exists($key, $this->attributes[$scope])) {
- return $this->attributes[$scope][$key];
- }
- return null;
- }
-
- public function toArray() {
- $result = [];
- foreach ($this->attributes as $scope => $keys) {
- foreach ($keys as $key => $enabled) {
- $result[] = [
- "scope" => $scope,
- "key" => $key,
- "enabled" => $enabled
- ];
- }
- }
- return $result;
- }
- }
|