@@ -32,54 +32,54 @@ |
||
| 32 | 32 | |
| 33 | 33 | class CapabilitiesManager { |
| 34 | 34 | |
| 35 | - /** @var \Closure[] */ |
|
| 36 | - private $capabilities = array(); |
|
| 35 | + /** @var \Closure[] */ |
|
| 36 | + private $capabilities = array(); |
|
| 37 | 37 | |
| 38 | - /** @var ILogger */ |
|
| 39 | - private $logger; |
|
| 38 | + /** @var ILogger */ |
|
| 39 | + private $logger; |
|
| 40 | 40 | |
| 41 | - public function __construct(ILogger $logger) { |
|
| 42 | - $this->logger = $logger; |
|
| 43 | - } |
|
| 41 | + public function __construct(ILogger $logger) { |
|
| 42 | + $this->logger = $logger; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Get an array of al the capabilities that are registered at this manager |
|
| 45 | + /** |
|
| 46 | + * Get an array of al the capabilities that are registered at this manager |
|
| 47 | 47 | * |
| 48 | - * @param bool $public get public capabilities only |
|
| 49 | - * @throws \InvalidArgumentException |
|
| 50 | - * @return array |
|
| 51 | - */ |
|
| 52 | - public function getCapabilities(bool $public = false) : array { |
|
| 53 | - $capabilities = []; |
|
| 54 | - foreach($this->capabilities as $capability) { |
|
| 55 | - try { |
|
| 56 | - $c = $capability(); |
|
| 57 | - } catch (QueryException $e) { |
|
| 58 | - $this->logger->error('CapabilitiesManager: {message}', ['app' => 'core', 'message' => $e->getMessage()]); |
|
| 59 | - continue; |
|
| 60 | - } |
|
| 48 | + * @param bool $public get public capabilities only |
|
| 49 | + * @throws \InvalidArgumentException |
|
| 50 | + * @return array |
|
| 51 | + */ |
|
| 52 | + public function getCapabilities(bool $public = false) : array { |
|
| 53 | + $capabilities = []; |
|
| 54 | + foreach($this->capabilities as $capability) { |
|
| 55 | + try { |
|
| 56 | + $c = $capability(); |
|
| 57 | + } catch (QueryException $e) { |
|
| 58 | + $this->logger->error('CapabilitiesManager: {message}', ['app' => 'core', 'message' => $e->getMessage()]); |
|
| 59 | + continue; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - if ($c instanceof ICapability) { |
|
| 63 | - if(!$public || $c instanceof IPublicCapability) { |
|
| 64 | - $capabilities = array_replace_recursive($capabilities, $c->getCapabilities()); |
|
| 65 | - } |
|
| 66 | - } else { |
|
| 67 | - throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface'); |
|
| 68 | - } |
|
| 69 | - } |
|
| 62 | + if ($c instanceof ICapability) { |
|
| 63 | + if(!$public || $c instanceof IPublicCapability) { |
|
| 64 | + $capabilities = array_replace_recursive($capabilities, $c->getCapabilities()); |
|
| 65 | + } |
|
| 66 | + } else { |
|
| 67 | + throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface'); |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - return $capabilities; |
|
| 72 | - } |
|
| 71 | + return $capabilities; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * In order to improve lazy loading a closure can be registered which will be called in case |
|
| 76 | - * capabilities are actually requested |
|
| 77 | - * |
|
| 78 | - * $callable has to return an instance of OCP\Capabilities\ICapability |
|
| 79 | - * |
|
| 80 | - * @param \Closure $callable |
|
| 81 | - */ |
|
| 82 | - public function registerCapability(\Closure $callable) { |
|
| 83 | - $this->capabilities[] = $callable; |
|
| 84 | - } |
|
| 74 | + /** |
|
| 75 | + * In order to improve lazy loading a closure can be registered which will be called in case |
|
| 76 | + * capabilities are actually requested |
|
| 77 | + * |
|
| 78 | + * $callable has to return an instance of OCP\Capabilities\ICapability |
|
| 79 | + * |
|
| 80 | + * @param \Closure $callable |
|
| 81 | + */ |
|
| 82 | + public function registerCapability(\Closure $callable) { |
|
| 83 | + $this->capabilities[] = $callable; |
|
| 84 | + } |
|
| 85 | 85 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | -declare(strict_types=1); |
|
| 24 | +declare(strict_types = 1); |
|
| 25 | 25 | |
| 26 | 26 | namespace OC; |
| 27 | 27 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | public function getCapabilities(bool $public = false) : array { |
| 53 | 53 | $capabilities = []; |
| 54 | - foreach($this->capabilities as $capability) { |
|
| 54 | + foreach ($this->capabilities as $capability) { |
|
| 55 | 55 | try { |
| 56 | 56 | $c = $capability(); |
| 57 | 57 | } catch (QueryException $e) { |
@@ -60,11 +60,11 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | if ($c instanceof ICapability) { |
| 63 | - if(!$public || $c instanceof IPublicCapability) { |
|
| 63 | + if (!$public || $c instanceof IPublicCapability) { |
|
| 64 | 64 | $capabilities = array_replace_recursive($capabilities, $c->getCapabilities()); |
| 65 | 65 | } |
| 66 | 66 | } else { |
| 67 | - throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface'); |
|
| 67 | + throw new \InvalidArgumentException('The given Capability ('.get_class($c).') does not implement the ICapability interface'); |
|
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |