@@ -26,13 +26,13 @@ |
||
| 26 | 26 | use SuperClosure\Serializer; |
| 27 | 27 | |
| 28 | 28 | class ClosureJob extends QueuedJob { |
| 29 | - protected function run($serializedCallable) { |
|
| 30 | - $serializer = new Serializer(); |
|
| 31 | - $callable = $serializer->unserialize($serializedCallable); |
|
| 32 | - if (is_callable($callable)) { |
|
| 33 | - $callable(); |
|
| 34 | - } else { |
|
| 35 | - throw new \InvalidArgumentException('Invalid serialized callable'); |
|
| 36 | - } |
|
| 37 | - } |
|
| 29 | + protected function run($serializedCallable) { |
|
| 30 | + $serializer = new Serializer(); |
|
| 31 | + $callable = $serializer->unserialize($serializedCallable); |
|
| 32 | + if (is_callable($callable)) { |
|
| 33 | + $callable(); |
|
| 34 | + } else { |
|
| 35 | + throw new \InvalidArgumentException('Invalid serialized callable'); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -25,12 +25,12 @@ |
||
| 25 | 25 | use OCP\IUser; |
| 26 | 26 | |
| 27 | 27 | trait FileAccess { |
| 28 | - protected function setupFS(IUser $user){ |
|
| 29 | - \OC_Util::setupFS($user->getUID()); |
|
| 30 | - } |
|
| 28 | + protected function setupFS(IUser $user){ |
|
| 29 | + \OC_Util::setupFS($user->getUID()); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - protected function getUserFolder(IUser $user) { |
|
| 33 | - $this->setupFS($user); |
|
| 34 | - return \OC::$server->getUserFolder($user->getUID()); |
|
| 35 | - } |
|
| 32 | + protected function getUserFolder(IUser $user) { |
|
| 33 | + $this->setupFS($user); |
|
| 34 | + return \OC::$server->getUserFolder($user->getUID()); |
|
| 35 | + } |
|
| 36 | 36 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | use OCP\IUser; |
| 26 | 26 | |
| 27 | 27 | trait FileAccess { |
| 28 | - protected function setupFS(IUser $user){ |
|
| 28 | + protected function setupFS(IUser $user) { |
|
| 29 | 29 | \OC_Util::setupFS($user->getUID()); |
| 30 | 30 | } |
| 31 | 31 | |
@@ -29,12 +29,12 @@ |
||
| 29 | 29 | * Wrap a command in the background job interface |
| 30 | 30 | */ |
| 31 | 31 | class CommandJob extends QueuedJob { |
| 32 | - protected function run($serializedCommand) { |
|
| 33 | - $command = unserialize($serializedCommand); |
|
| 34 | - if ($command instanceof ICommand) { |
|
| 35 | - $command->handle(); |
|
| 36 | - } else { |
|
| 37 | - throw new \InvalidArgumentException('Invalid serialized command'); |
|
| 38 | - } |
|
| 39 | - } |
|
| 32 | + protected function run($serializedCommand) { |
|
| 33 | + $command = unserialize($serializedCommand); |
|
| 34 | + if ($command instanceof ICommand) { |
|
| 35 | + $command->handle(); |
|
| 36 | + } else { |
|
| 37 | + throw new \InvalidArgumentException('Invalid serialized command'); |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | 40 | } |
@@ -114,8 +114,7 @@ discard block |
||
| 114 | 114 | public function append( $key, $value ) { |
| 115 | 115 | if( array_key_exists( $key, $this->vars )) { |
| 116 | 116 | $this->vars[$key][] = $value; |
| 117 | - } |
|
| 118 | - else{ |
|
| 117 | + } else{ |
|
| 119 | 118 | $this->vars[$key] = array( $value ); |
| 120 | 119 | } |
| 121 | 120 | } |
@@ -130,8 +129,7 @@ discard block |
||
| 130 | 129 | $data = $this->fetchPage(); |
| 131 | 130 | if( $data === false ) { |
| 132 | 131 | return false; |
| 133 | - } |
|
| 134 | - else{ |
|
| 132 | + } else{ |
|
| 135 | 133 | print $data; |
| 136 | 134 | return true; |
| 137 | 135 | } |
@@ -31,161 +31,161 @@ |
||
| 31 | 31 | use OCP\Defaults; |
| 32 | 32 | |
| 33 | 33 | class Base { |
| 34 | - private $template; // The template |
|
| 35 | - private $vars; // Vars |
|
| 36 | - |
|
| 37 | - /** @var \OCP\IL10N */ |
|
| 38 | - private $l10n; |
|
| 39 | - |
|
| 40 | - /** @var Defaults */ |
|
| 41 | - private $theme; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @param string $template |
|
| 45 | - * @param string $requestToken |
|
| 46 | - * @param \OCP\IL10N $l10n |
|
| 47 | - * @param Defaults $theme |
|
| 48 | - */ |
|
| 49 | - public function __construct($template, $requestToken, $l10n, $theme ) { |
|
| 50 | - $this->vars = array(); |
|
| 51 | - $this->vars['requesttoken'] = $requestToken; |
|
| 52 | - $this->l10n = $l10n; |
|
| 53 | - $this->template = $template; |
|
| 54 | - $this->theme = $theme; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @param string $serverRoot |
|
| 59 | - * @param string|false $app_dir |
|
| 60 | - * @param string $theme |
|
| 61 | - * @param string $app |
|
| 62 | - * @return string[] |
|
| 63 | - */ |
|
| 64 | - protected function getAppTemplateDirs($theme, $app, $serverRoot, $app_dir) { |
|
| 65 | - // Check if the app is in the app folder or in the root |
|
| 66 | - if( file_exists($app_dir.'/templates/' )) { |
|
| 67 | - return [ |
|
| 68 | - $serverRoot.'/themes/'.$theme.'/apps/'.$app.'/templates/', |
|
| 69 | - $app_dir.'/templates/', |
|
| 70 | - ]; |
|
| 71 | - } |
|
| 72 | - return [ |
|
| 73 | - $serverRoot.'/themes/'.$theme.'/'.$app.'/templates/', |
|
| 74 | - $serverRoot.'/'.$app.'/templates/', |
|
| 75 | - ]; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * @param string $serverRoot |
|
| 80 | - * @param string $theme |
|
| 81 | - * @return string[] |
|
| 82 | - */ |
|
| 83 | - protected function getCoreTemplateDirs($theme, $serverRoot) { |
|
| 84 | - return [ |
|
| 85 | - $serverRoot.'/themes/'.$theme.'/core/templates/', |
|
| 86 | - $serverRoot.'/core/templates/', |
|
| 87 | - ]; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * Assign variables |
|
| 92 | - * @param string $key key |
|
| 93 | - * @param array|bool|integer|string $value value |
|
| 94 | - * @return bool |
|
| 95 | - * |
|
| 96 | - * This function assigns a variable. It can be accessed via $_[$key] in |
|
| 97 | - * the template. |
|
| 98 | - * |
|
| 99 | - * If the key existed before, it will be overwritten |
|
| 100 | - */ |
|
| 101 | - public function assign( $key, $value) { |
|
| 102 | - $this->vars[$key] = $value; |
|
| 103 | - return true; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Appends a variable |
|
| 108 | - * @param string $key key |
|
| 109 | - * @param mixed $value value |
|
| 110 | - * @return boolean|null |
|
| 111 | - * |
|
| 112 | - * This function assigns a variable in an array context. If the key already |
|
| 113 | - * exists, the value will be appended. It can be accessed via |
|
| 114 | - * $_[$key][$position] in the template. |
|
| 115 | - */ |
|
| 116 | - public function append( $key, $value ) { |
|
| 117 | - if( array_key_exists( $key, $this->vars )) { |
|
| 118 | - $this->vars[$key][] = $value; |
|
| 119 | - } |
|
| 120 | - else{ |
|
| 121 | - $this->vars[$key] = array( $value ); |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * Prints the proceeded template |
|
| 127 | - * @return bool |
|
| 128 | - * |
|
| 129 | - * This function proceeds the template and prints its output. |
|
| 130 | - */ |
|
| 131 | - public function printPage() { |
|
| 132 | - $data = $this->fetchPage(); |
|
| 133 | - if( $data === false ) { |
|
| 134 | - return false; |
|
| 135 | - } |
|
| 136 | - else{ |
|
| 137 | - print $data; |
|
| 138 | - return true; |
|
| 139 | - } |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * Process the template |
|
| 144 | - * |
|
| 145 | - * @param array|null $additionalParams |
|
| 146 | - * @return string This function processes the template. |
|
| 147 | - * |
|
| 148 | - * This function processes the template. |
|
| 149 | - */ |
|
| 150 | - public function fetchPage($additionalParams = null) { |
|
| 151 | - return $this->load($this->template, $additionalParams); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * doing the actual work |
|
| 156 | - * |
|
| 157 | - * @param string $file |
|
| 158 | - * @param array|null $additionalParams |
|
| 159 | - * @return string content |
|
| 160 | - * |
|
| 161 | - * Includes the template file, fetches its output |
|
| 162 | - */ |
|
| 163 | - protected function load($file, $additionalParams = null) { |
|
| 164 | - // Register the variables |
|
| 165 | - $_ = $this->vars; |
|
| 166 | - $l = $this->l10n; |
|
| 167 | - $theme = $this->theme; |
|
| 168 | - |
|
| 169 | - if(!is_null($additionalParams)) { |
|
| 170 | - $_ = array_merge( $additionalParams, $this->vars ); |
|
| 171 | - foreach ($_ as $var => $value) { |
|
| 172 | - ${$var} = $value; |
|
| 173 | - } |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - // Include |
|
| 177 | - ob_start(); |
|
| 178 | - try { |
|
| 179 | - include $file; |
|
| 180 | - $data = ob_get_contents(); |
|
| 181 | - } catch (\Exception $e) { |
|
| 182 | - @ob_end_clean(); |
|
| 183 | - throw $e; |
|
| 184 | - } |
|
| 185 | - @ob_end_clean(); |
|
| 186 | - |
|
| 187 | - // Return data |
|
| 188 | - return $data; |
|
| 189 | - } |
|
| 34 | + private $template; // The template |
|
| 35 | + private $vars; // Vars |
|
| 36 | + |
|
| 37 | + /** @var \OCP\IL10N */ |
|
| 38 | + private $l10n; |
|
| 39 | + |
|
| 40 | + /** @var Defaults */ |
|
| 41 | + private $theme; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @param string $template |
|
| 45 | + * @param string $requestToken |
|
| 46 | + * @param \OCP\IL10N $l10n |
|
| 47 | + * @param Defaults $theme |
|
| 48 | + */ |
|
| 49 | + public function __construct($template, $requestToken, $l10n, $theme ) { |
|
| 50 | + $this->vars = array(); |
|
| 51 | + $this->vars['requesttoken'] = $requestToken; |
|
| 52 | + $this->l10n = $l10n; |
|
| 53 | + $this->template = $template; |
|
| 54 | + $this->theme = $theme; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @param string $serverRoot |
|
| 59 | + * @param string|false $app_dir |
|
| 60 | + * @param string $theme |
|
| 61 | + * @param string $app |
|
| 62 | + * @return string[] |
|
| 63 | + */ |
|
| 64 | + protected function getAppTemplateDirs($theme, $app, $serverRoot, $app_dir) { |
|
| 65 | + // Check if the app is in the app folder or in the root |
|
| 66 | + if( file_exists($app_dir.'/templates/' )) { |
|
| 67 | + return [ |
|
| 68 | + $serverRoot.'/themes/'.$theme.'/apps/'.$app.'/templates/', |
|
| 69 | + $app_dir.'/templates/', |
|
| 70 | + ]; |
|
| 71 | + } |
|
| 72 | + return [ |
|
| 73 | + $serverRoot.'/themes/'.$theme.'/'.$app.'/templates/', |
|
| 74 | + $serverRoot.'/'.$app.'/templates/', |
|
| 75 | + ]; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * @param string $serverRoot |
|
| 80 | + * @param string $theme |
|
| 81 | + * @return string[] |
|
| 82 | + */ |
|
| 83 | + protected function getCoreTemplateDirs($theme, $serverRoot) { |
|
| 84 | + return [ |
|
| 85 | + $serverRoot.'/themes/'.$theme.'/core/templates/', |
|
| 86 | + $serverRoot.'/core/templates/', |
|
| 87 | + ]; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * Assign variables |
|
| 92 | + * @param string $key key |
|
| 93 | + * @param array|bool|integer|string $value value |
|
| 94 | + * @return bool |
|
| 95 | + * |
|
| 96 | + * This function assigns a variable. It can be accessed via $_[$key] in |
|
| 97 | + * the template. |
|
| 98 | + * |
|
| 99 | + * If the key existed before, it will be overwritten |
|
| 100 | + */ |
|
| 101 | + public function assign( $key, $value) { |
|
| 102 | + $this->vars[$key] = $value; |
|
| 103 | + return true; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Appends a variable |
|
| 108 | + * @param string $key key |
|
| 109 | + * @param mixed $value value |
|
| 110 | + * @return boolean|null |
|
| 111 | + * |
|
| 112 | + * This function assigns a variable in an array context. If the key already |
|
| 113 | + * exists, the value will be appended. It can be accessed via |
|
| 114 | + * $_[$key][$position] in the template. |
|
| 115 | + */ |
|
| 116 | + public function append( $key, $value ) { |
|
| 117 | + if( array_key_exists( $key, $this->vars )) { |
|
| 118 | + $this->vars[$key][] = $value; |
|
| 119 | + } |
|
| 120 | + else{ |
|
| 121 | + $this->vars[$key] = array( $value ); |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * Prints the proceeded template |
|
| 127 | + * @return bool |
|
| 128 | + * |
|
| 129 | + * This function proceeds the template and prints its output. |
|
| 130 | + */ |
|
| 131 | + public function printPage() { |
|
| 132 | + $data = $this->fetchPage(); |
|
| 133 | + if( $data === false ) { |
|
| 134 | + return false; |
|
| 135 | + } |
|
| 136 | + else{ |
|
| 137 | + print $data; |
|
| 138 | + return true; |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * Process the template |
|
| 144 | + * |
|
| 145 | + * @param array|null $additionalParams |
|
| 146 | + * @return string This function processes the template. |
|
| 147 | + * |
|
| 148 | + * This function processes the template. |
|
| 149 | + */ |
|
| 150 | + public function fetchPage($additionalParams = null) { |
|
| 151 | + return $this->load($this->template, $additionalParams); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * doing the actual work |
|
| 156 | + * |
|
| 157 | + * @param string $file |
|
| 158 | + * @param array|null $additionalParams |
|
| 159 | + * @return string content |
|
| 160 | + * |
|
| 161 | + * Includes the template file, fetches its output |
|
| 162 | + */ |
|
| 163 | + protected function load($file, $additionalParams = null) { |
|
| 164 | + // Register the variables |
|
| 165 | + $_ = $this->vars; |
|
| 166 | + $l = $this->l10n; |
|
| 167 | + $theme = $this->theme; |
|
| 168 | + |
|
| 169 | + if(!is_null($additionalParams)) { |
|
| 170 | + $_ = array_merge( $additionalParams, $this->vars ); |
|
| 171 | + foreach ($_ as $var => $value) { |
|
| 172 | + ${$var} = $value; |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + // Include |
|
| 177 | + ob_start(); |
|
| 178 | + try { |
|
| 179 | + include $file; |
|
| 180 | + $data = ob_get_contents(); |
|
| 181 | + } catch (\Exception $e) { |
|
| 182 | + @ob_end_clean(); |
|
| 183 | + throw $e; |
|
| 184 | + } |
|
| 185 | + @ob_end_clean(); |
|
| 186 | + |
|
| 187 | + // Return data |
|
| 188 | + return $data; |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | 191 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @param \OCP\IL10N $l10n |
| 47 | 47 | * @param Defaults $theme |
| 48 | 48 | */ |
| 49 | - public function __construct($template, $requestToken, $l10n, $theme ) { |
|
| 49 | + public function __construct($template, $requestToken, $l10n, $theme) { |
|
| 50 | 50 | $this->vars = array(); |
| 51 | 51 | $this->vars['requesttoken'] = $requestToken; |
| 52 | 52 | $this->l10n = $l10n; |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | protected function getAppTemplateDirs($theme, $app, $serverRoot, $app_dir) { |
| 65 | 65 | // Check if the app is in the app folder or in the root |
| 66 | - if( file_exists($app_dir.'/templates/' )) { |
|
| 66 | + if (file_exists($app_dir.'/templates/')) { |
|
| 67 | 67 | return [ |
| 68 | 68 | $serverRoot.'/themes/'.$theme.'/apps/'.$app.'/templates/', |
| 69 | 69 | $app_dir.'/templates/', |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * If the key existed before, it will be overwritten |
| 100 | 100 | */ |
| 101 | - public function assign( $key, $value) { |
|
| 101 | + public function assign($key, $value) { |
|
| 102 | 102 | $this->vars[$key] = $value; |
| 103 | 103 | return true; |
| 104 | 104 | } |
@@ -113,12 +113,12 @@ discard block |
||
| 113 | 113 | * exists, the value will be appended. It can be accessed via |
| 114 | 114 | * $_[$key][$position] in the template. |
| 115 | 115 | */ |
| 116 | - public function append( $key, $value ) { |
|
| 117 | - if( array_key_exists( $key, $this->vars )) { |
|
| 116 | + public function append($key, $value) { |
|
| 117 | + if (array_key_exists($key, $this->vars)) { |
|
| 118 | 118 | $this->vars[$key][] = $value; |
| 119 | 119 | } |
| 120 | - else{ |
|
| 121 | - $this->vars[$key] = array( $value ); |
|
| 120 | + else { |
|
| 121 | + $this->vars[$key] = array($value); |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
@@ -130,10 +130,10 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public function printPage() { |
| 132 | 132 | $data = $this->fetchPage(); |
| 133 | - if( $data === false ) { |
|
| 133 | + if ($data === false) { |
|
| 134 | 134 | return false; |
| 135 | 135 | } |
| 136 | - else{ |
|
| 136 | + else { |
|
| 137 | 137 | print $data; |
| 138 | 138 | return true; |
| 139 | 139 | } |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | $l = $this->l10n; |
| 167 | 167 | $theme = $this->theme; |
| 168 | 168 | |
| 169 | - if(!is_null($additionalParams)) { |
|
| 170 | - $_ = array_merge( $additionalParams, $this->vars ); |
|
| 169 | + if (!is_null($additionalParams)) { |
|
| 170 | + $_ = array_merge($additionalParams, $this->vars); |
|
| 171 | 171 | foreach ($_ as $var => $value) { |
| 172 | 172 | ${$var} = $value; |
| 173 | 173 | } |
@@ -24,23 +24,23 @@ |
||
| 24 | 24 | namespace OC\Template; |
| 25 | 25 | |
| 26 | 26 | class ResourceNotFoundException extends \LogicException { |
| 27 | - protected $resource; |
|
| 28 | - protected $webPath; |
|
| 27 | + protected $resource; |
|
| 28 | + protected $webPath; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @param string $resource |
|
| 32 | - * @param string $webPath |
|
| 33 | - */ |
|
| 34 | - public function __construct($resource, $webPath) { |
|
| 35 | - parent::__construct('Resource not found'); |
|
| 36 | - $this->resource = $resource; |
|
| 37 | - $this->webPath = $webPath; |
|
| 38 | - } |
|
| 30 | + /** |
|
| 31 | + * @param string $resource |
|
| 32 | + * @param string $webPath |
|
| 33 | + */ |
|
| 34 | + public function __construct($resource, $webPath) { |
|
| 35 | + parent::__construct('Resource not found'); |
|
| 36 | + $this->resource = $resource; |
|
| 37 | + $this->webPath = $webPath; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @return string |
|
| 42 | - */ |
|
| 43 | - public function getResourcePath() { |
|
| 44 | - return $this->webPath . '/' . $this->resource; |
|
| 45 | - } |
|
| 40 | + /** |
|
| 41 | + * @return string |
|
| 42 | + */ |
|
| 43 | + public function getResourcePath() { |
|
| 44 | + return $this->webPath . '/' . $this->resource; |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -41,6 +41,6 @@ |
||
| 41 | 41 | * @return string |
| 42 | 42 | */ |
| 43 | 43 | public function getResourcePath() { |
| 44 | - return $this->webPath . '/' . $this->resource; |
|
| 44 | + return $this->webPath.'/'.$this->resource; |
|
| 45 | 45 | } |
| 46 | 46 | } |
@@ -26,37 +26,37 @@ |
||
| 26 | 26 | namespace OC\Template; |
| 27 | 27 | |
| 28 | 28 | class TemplateFileLocator { |
| 29 | - protected $dirs; |
|
| 30 | - private $path; |
|
| 29 | + protected $dirs; |
|
| 30 | + private $path; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @param string[] $dirs |
|
| 34 | - */ |
|
| 35 | - public function __construct( $dirs ) { |
|
| 36 | - $this->dirs = $dirs; |
|
| 37 | - } |
|
| 32 | + /** |
|
| 33 | + * @param string[] $dirs |
|
| 34 | + */ |
|
| 35 | + public function __construct( $dirs ) { |
|
| 36 | + $this->dirs = $dirs; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @param string $template |
|
| 41 | - * @return string |
|
| 42 | - * @throws \Exception |
|
| 43 | - */ |
|
| 44 | - public function find( $template ) { |
|
| 45 | - if ($template === '') { |
|
| 46 | - throw new \InvalidArgumentException('Empty template name'); |
|
| 47 | - } |
|
| 39 | + /** |
|
| 40 | + * @param string $template |
|
| 41 | + * @return string |
|
| 42 | + * @throws \Exception |
|
| 43 | + */ |
|
| 44 | + public function find( $template ) { |
|
| 45 | + if ($template === '') { |
|
| 46 | + throw new \InvalidArgumentException('Empty template name'); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - foreach($this->dirs as $dir) { |
|
| 50 | - $file = $dir.$template.'.php'; |
|
| 51 | - if (is_file($file)) { |
|
| 52 | - $this->path = $dir; |
|
| 53 | - return $file; |
|
| 54 | - } |
|
| 55 | - } |
|
| 56 | - throw new \Exception('template file not found: template:'.$template); |
|
| 57 | - } |
|
| 49 | + foreach($this->dirs as $dir) { |
|
| 50 | + $file = $dir.$template.'.php'; |
|
| 51 | + if (is_file($file)) { |
|
| 52 | + $this->path = $dir; |
|
| 53 | + return $file; |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | + throw new \Exception('template file not found: template:'.$template); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - public function getPath() { |
|
| 60 | - return $this->path; |
|
| 61 | - } |
|
| 59 | + public function getPath() { |
|
| 60 | + return $this->path; |
|
| 61 | + } |
|
| 62 | 62 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * @param string[] $dirs |
| 34 | 34 | */ |
| 35 | - public function __construct( $dirs ) { |
|
| 35 | + public function __construct($dirs) { |
|
| 36 | 36 | $this->dirs = $dirs; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -41,12 +41,12 @@ discard block |
||
| 41 | 41 | * @return string |
| 42 | 42 | * @throws \Exception |
| 43 | 43 | */ |
| 44 | - public function find( $template ) { |
|
| 44 | + public function find($template) { |
|
| 45 | 45 | if ($template === '') { |
| 46 | 46 | throw new \InvalidArgumentException('Empty template name'); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - foreach($this->dirs as $dir) { |
|
| 49 | + foreach ($this->dirs as $dir) { |
|
| 50 | 50 | $file = $dir.$template.'.php'; |
| 51 | 51 | if (is_file($file)) { |
| 52 | 52 | $this->path = $dir; |
@@ -24,5 +24,5 @@ |
||
| 24 | 24 | namespace OC\Hooks; |
| 25 | 25 | |
| 26 | 26 | abstract class BasicEmitter implements Emitter { |
| 27 | - use EmitterTrait; |
|
| 27 | + use EmitterTrait; |
|
| 28 | 28 | } |
@@ -32,19 +32,19 @@ |
||
| 32 | 32 | * @package OC\Hooks |
| 33 | 33 | */ |
| 34 | 34 | interface Emitter { |
| 35 | - /** |
|
| 36 | - * @param string $scope |
|
| 37 | - * @param string $method |
|
| 38 | - * @param callable $callback |
|
| 39 | - * @return void |
|
| 40 | - */ |
|
| 41 | - public function listen($scope, $method, callable $callback); |
|
| 35 | + /** |
|
| 36 | + * @param string $scope |
|
| 37 | + * @param string $method |
|
| 38 | + * @param callable $callback |
|
| 39 | + * @return void |
|
| 40 | + */ |
|
| 41 | + public function listen($scope, $method, callable $callback); |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @param string $scope optional |
|
| 45 | - * @param string $method optional |
|
| 46 | - * @param callable $callback optional |
|
| 47 | - * @return void |
|
| 48 | - */ |
|
| 49 | - public function removeListener($scope = null, $method = null, callable $callback = null); |
|
| 43 | + /** |
|
| 44 | + * @param string $scope optional |
|
| 45 | + * @param string $method optional |
|
| 46 | + * @param callable $callback optional |
|
| 47 | + * @return void |
|
| 48 | + */ |
|
| 49 | + public function removeListener($scope = null, $method = null, callable $callback = null); |
|
| 50 | 50 | } |
@@ -31,35 +31,35 @@ |
||
| 31 | 31 | * @package OC\Hooks |
| 32 | 32 | */ |
| 33 | 33 | abstract class ForwardingEmitter extends BasicEmitter { |
| 34 | - /** |
|
| 35 | - * @var \OC\Hooks\Emitter[] array |
|
| 36 | - */ |
|
| 37 | - private $forwardEmitters = array(); |
|
| 34 | + /** |
|
| 35 | + * @var \OC\Hooks\Emitter[] array |
|
| 36 | + */ |
|
| 37 | + private $forwardEmitters = array(); |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @param string $scope |
|
| 41 | - * @param string $method |
|
| 42 | - * @param callable $callback |
|
| 43 | - */ |
|
| 44 | - public function listen($scope, $method, callable $callback) { |
|
| 45 | - parent::listen($scope, $method, $callback); |
|
| 46 | - foreach ($this->forwardEmitters as $emitter) { |
|
| 47 | - $emitter->listen($scope, $method, $callback); |
|
| 48 | - } |
|
| 49 | - } |
|
| 39 | + /** |
|
| 40 | + * @param string $scope |
|
| 41 | + * @param string $method |
|
| 42 | + * @param callable $callback |
|
| 43 | + */ |
|
| 44 | + public function listen($scope, $method, callable $callback) { |
|
| 45 | + parent::listen($scope, $method, $callback); |
|
| 46 | + foreach ($this->forwardEmitters as $emitter) { |
|
| 47 | + $emitter->listen($scope, $method, $callback); |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @param \OC\Hooks\Emitter $emitter |
|
| 53 | - */ |
|
| 54 | - protected function forward(Emitter $emitter) { |
|
| 55 | - $this->forwardEmitters[] = $emitter; |
|
| 51 | + /** |
|
| 52 | + * @param \OC\Hooks\Emitter $emitter |
|
| 53 | + */ |
|
| 54 | + protected function forward(Emitter $emitter) { |
|
| 55 | + $this->forwardEmitters[] = $emitter; |
|
| 56 | 56 | |
| 57 | - //forward all previously connected hooks |
|
| 58 | - foreach ($this->listeners as $key => $listeners) { |
|
| 59 | - list($scope, $method) = explode('::', $key, 2); |
|
| 60 | - foreach ($listeners as $listener) { |
|
| 61 | - $emitter->listen($scope, $method, $listener); |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - } |
|
| 57 | + //forward all previously connected hooks |
|
| 58 | + foreach ($this->listeners as $key => $listeners) { |
|
| 59 | + list($scope, $method) = explode('::', $key, 2); |
|
| 60 | + foreach ($listeners as $listener) { |
|
| 61 | + $emitter->listen($scope, $method, $listener); |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | 65 | } |