Commit a4b23e811d08175f8c2c7440db89d4a00bff066a
0 parents
Exists in
master
and in
1 other branch
Primeiro commit
Showing
194 changed files
with
19750 additions
and
0 deletions
Show diff stats
Too many changes.
To preserve performance only 100 of 194 files displayed.
| 1 | +++ a/MdWsSeiRest.php | |
| ... | ... | @@ -0,0 +1,120 @@ |
| 1 | +<? | |
| 2 | +/** | |
| 3 | + * Eduardo Romao | |
| 4 | + * | |
| 5 | + * 26/03/2017 - criado por ejushiro@gmail.com | |
| 6 | + * | |
| 7 | + */ | |
| 8 | + | |
| 9 | +class MdWsSeiRest extends SeiIntegracao{ | |
| 10 | + | |
| 11 | + public function __construct(){ | |
| 12 | + } | |
| 13 | + | |
| 14 | + public function getNome(){ | |
| 15 | + return 'Módulo de provisionamento de serviços REST do SEI'; | |
| 16 | + } | |
| 17 | + | |
| 18 | + public function getVersao() { | |
| 19 | + return '1.0.0'; | |
| 20 | + } | |
| 21 | + | |
| 22 | + public function getInstituicao(){ | |
| 23 | + return 'wssei'; | |
| 24 | + } | |
| 25 | + | |
| 26 | + public function inicializar($strVersaoSEI){ | |
| 27 | + if (substr($strVersaoSEI, 0, 2) != '3.'){ | |
| 28 | + die('Módulo "'.$this->getNome().'" ('.$this->getVersao().') não e compatível com esta versão do SEI ('.$strVersaoSEI.').'); | |
| 29 | + } | |
| 30 | + } | |
| 31 | + | |
| 32 | + public function montarBotaoControleProcessos(){ | |
| 33 | + return array(); | |
| 34 | + } | |
| 35 | + | |
| 36 | + public function montarIconeControleProcessos($arrObjProcedimentoAPI){ | |
| 37 | + return array(); | |
| 38 | + } | |
| 39 | + | |
| 40 | + public function montarIconeAcompanhamentoEspecial($arrObjProcedimentoAPI){ | |
| 41 | + return array(); | |
| 42 | + } | |
| 43 | + | |
| 44 | + public function montarIconeProcesso(ProcedimentoAPI $objProcedimentoAPI){ | |
| 45 | + return array(); | |
| 46 | + } | |
| 47 | + | |
| 48 | + public function montarBotaoProcesso(ProcedimentoAPI $objProcedimentoAPI){ | |
| 49 | + return array(); | |
| 50 | + } | |
| 51 | + | |
| 52 | + public function montarIconeDocumento(ProcedimentoAPI $objProcedimentoAPI, $arrObjDocumentoAPI){ | |
| 53 | + return array(); | |
| 54 | + } | |
| 55 | + | |
| 56 | + public function montarBotaoDocumento(ProcedimentoAPI $objProcedimentoAPI, $arrObjDocumentoAPI){ | |
| 57 | + return array(); | |
| 58 | + } | |
| 59 | + | |
| 60 | + public function alterarIconeArvoreDocumento(ProcedimentoAPI $objProcedimentoAPI, $arrObjDocumentoAPI){ | |
| 61 | + return array(); | |
| 62 | + } | |
| 63 | + | |
| 64 | + public function montarMenuPublicacoes(){ | |
| 65 | + return array(); | |
| 66 | + } | |
| 67 | + | |
| 68 | + public function montarMenuUsuarioExterno(){ | |
| 69 | + return array(); | |
| 70 | + } | |
| 71 | + | |
| 72 | + public function montarAcaoControleAcessoExterno($arrObjAcessoExternoAPI){ | |
| 73 | + return array(); | |
| 74 | + } | |
| 75 | + | |
| 76 | + public function montarAcaoDocumentoAcessoExternoAutorizado($arrObjDocumentoAPI){ | |
| 77 | + return array(); | |
| 78 | + } | |
| 79 | + | |
| 80 | + public function montarAcaoProcessoAnexadoAcessoExternoAutorizado($arrObjProcedimentoAPI){ | |
| 81 | + return array(); | |
| 82 | + } | |
| 83 | + | |
| 84 | + public function montarBotaoAcessoExternoAutorizado(ProcedimentoAPI $objProcedimentoAPI){ | |
| 85 | + return array(); | |
| 86 | + } | |
| 87 | + | |
| 88 | + public function montarBotaoControleAcessoExterno(){ | |
| 89 | + return array(); | |
| 90 | + } | |
| 91 | + | |
| 92 | + public function processarControlador($strAcao){ | |
| 93 | + return false; | |
| 94 | + } | |
| 95 | + | |
| 96 | + public function processarControladorAjax($strAcao){ | |
| 97 | + return null; | |
| 98 | + } | |
| 99 | + | |
| 100 | + public function processarControladorPublicacoes($strAcao){ | |
| 101 | + return false; | |
| 102 | + } | |
| 103 | + | |
| 104 | + public function processarControladorExterno($strAcao){ | |
| 105 | + return false; | |
| 106 | + } | |
| 107 | + | |
| 108 | + public function verificarAcessoProtocolo($arrObjProcedimentoAPI, $arrObjDocumentoAPI){ | |
| 109 | + return null; | |
| 110 | + } | |
| 111 | + | |
| 112 | + public function verificarAcessoProtocoloExterno($arrObjProcedimentoAPI, $arrObjDocumentoAPI){ | |
| 113 | + return null; | |
| 114 | + } | |
| 115 | + | |
| 116 | + public function montarMensagemProcesso(ProcedimentoAPI $objProcedimentoAPI){ | |
| 117 | + return null; | |
| 118 | + } | |
| 119 | +} | |
| 120 | +?> | |
| 0 | 121 | \ No newline at end of file | ... | ... |
| 1 | +++ a/composer.lock | |
| ... | ... | @@ -0,0 +1,307 @@ |
| 1 | +{ | |
| 2 | + "_readme": [ | |
| 3 | + "This file locks the dependencies of your project to a known state", | |
| 4 | + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", | |
| 5 | + "This file is @generated automatically" | |
| 6 | + ], | |
| 7 | + "content-hash": "4fed3f4a9903f9831848f1f17fe73591", | |
| 8 | + "packages": [ | |
| 9 | + { | |
| 10 | + "name": "container-interop/container-interop", | |
| 11 | + "version": "1.2.0", | |
| 12 | + "source": { | |
| 13 | + "type": "git", | |
| 14 | + "url": "https://github.com/container-interop/container-interop.git", | |
| 15 | + "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8" | |
| 16 | + }, | |
| 17 | + "dist": { | |
| 18 | + "type": "zip", | |
| 19 | + "url": "https://api.github.com/repos/container-interop/container-interop/zipball/79cbf1341c22ec75643d841642dd5d6acd83bdb8", | |
| 20 | + "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8", | |
| 21 | + "shasum": "" | |
| 22 | + }, | |
| 23 | + "require": { | |
| 24 | + "psr/container": "^1.0" | |
| 25 | + }, | |
| 26 | + "type": "library", | |
| 27 | + "autoload": { | |
| 28 | + "psr-4": { | |
| 29 | + "Interop\\Container\\": "src/Interop/Container/" | |
| 30 | + } | |
| 31 | + }, | |
| 32 | + "notification-url": "https://packagist.org/downloads/", | |
| 33 | + "license": [ | |
| 34 | + "MIT" | |
| 35 | + ], | |
| 36 | + "description": "Promoting the interoperability of container objects (DIC, SL, etc.)", | |
| 37 | + "homepage": "https://github.com/container-interop/container-interop", | |
| 38 | + "time": "2017-02-14T19:40:03+00:00" | |
| 39 | + }, | |
| 40 | + { | |
| 41 | + "name": "nikic/fast-route", | |
| 42 | + "version": "v1.2.0", | |
| 43 | + "source": { | |
| 44 | + "type": "git", | |
| 45 | + "url": "https://github.com/nikic/FastRoute.git", | |
| 46 | + "reference": "b5f95749071c82a8e0f58586987627054400cdf6" | |
| 47 | + }, | |
| 48 | + "dist": { | |
| 49 | + "type": "zip", | |
| 50 | + "url": "https://api.github.com/repos/nikic/FastRoute/zipball/b5f95749071c82a8e0f58586987627054400cdf6", | |
| 51 | + "reference": "b5f95749071c82a8e0f58586987627054400cdf6", | |
| 52 | + "shasum": "" | |
| 53 | + }, | |
| 54 | + "require": { | |
| 55 | + "php": ">=5.4.0" | |
| 56 | + }, | |
| 57 | + "type": "library", | |
| 58 | + "autoload": { | |
| 59 | + "psr-4": { | |
| 60 | + "FastRoute\\": "src/" | |
| 61 | + }, | |
| 62 | + "files": [ | |
| 63 | + "src/functions.php" | |
| 64 | + ] | |
| 65 | + }, | |
| 66 | + "notification-url": "https://packagist.org/downloads/", | |
| 67 | + "license": [ | |
| 68 | + "BSD-3-Clause" | |
| 69 | + ], | |
| 70 | + "authors": [ | |
| 71 | + { | |
| 72 | + "name": "Nikita Popov", | |
| 73 | + "email": "nikic@php.net" | |
| 74 | + } | |
| 75 | + ], | |
| 76 | + "description": "Fast request router for PHP", | |
| 77 | + "keywords": [ | |
| 78 | + "router", | |
| 79 | + "routing" | |
| 80 | + ], | |
| 81 | + "time": "2017-01-19T11:35:12+00:00" | |
| 82 | + }, | |
| 83 | + { | |
| 84 | + "name": "pimple/pimple", | |
| 85 | + "version": "v3.0.2", | |
| 86 | + "source": { | |
| 87 | + "type": "git", | |
| 88 | + "url": "https://github.com/silexphp/Pimple.git", | |
| 89 | + "reference": "a30f7d6e57565a2e1a316e1baf2a483f788b258a" | |
| 90 | + }, | |
| 91 | + "dist": { | |
| 92 | + "type": "zip", | |
| 93 | + "url": "https://api.github.com/repos/silexphp/Pimple/zipball/a30f7d6e57565a2e1a316e1baf2a483f788b258a", | |
| 94 | + "reference": "a30f7d6e57565a2e1a316e1baf2a483f788b258a", | |
| 95 | + "shasum": "" | |
| 96 | + }, | |
| 97 | + "require": { | |
| 98 | + "php": ">=5.3.0" | |
| 99 | + }, | |
| 100 | + "type": "library", | |
| 101 | + "extra": { | |
| 102 | + "branch-alias": { | |
| 103 | + "dev-master": "3.0.x-dev" | |
| 104 | + } | |
| 105 | + }, | |
| 106 | + "autoload": { | |
| 107 | + "psr-0": { | |
| 108 | + "Pimple": "src/" | |
| 109 | + } | |
| 110 | + }, | |
| 111 | + "notification-url": "https://packagist.org/downloads/", | |
| 112 | + "license": [ | |
| 113 | + "MIT" | |
| 114 | + ], | |
| 115 | + "authors": [ | |
| 116 | + { | |
| 117 | + "name": "Fabien Potencier", | |
| 118 | + "email": "fabien@symfony.com" | |
| 119 | + } | |
| 120 | + ], | |
| 121 | + "description": "Pimple, a simple Dependency Injection Container", | |
| 122 | + "homepage": "http://pimple.sensiolabs.org", | |
| 123 | + "keywords": [ | |
| 124 | + "container", | |
| 125 | + "dependency injection" | |
| 126 | + ], | |
| 127 | + "time": "2015-09-11T15:10:35+00:00" | |
| 128 | + }, | |
| 129 | + { | |
| 130 | + "name": "psr/container", | |
| 131 | + "version": "1.0.0", | |
| 132 | + "source": { | |
| 133 | + "type": "git", | |
| 134 | + "url": "https://github.com/php-fig/container.git", | |
| 135 | + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" | |
| 136 | + }, | |
| 137 | + "dist": { | |
| 138 | + "type": "zip", | |
| 139 | + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", | |
| 140 | + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", | |
| 141 | + "shasum": "" | |
| 142 | + }, | |
| 143 | + "require": { | |
| 144 | + "php": ">=5.3.0" | |
| 145 | + }, | |
| 146 | + "type": "library", | |
| 147 | + "extra": { | |
| 148 | + "branch-alias": { | |
| 149 | + "dev-master": "1.0.x-dev" | |
| 150 | + } | |
| 151 | + }, | |
| 152 | + "autoload": { | |
| 153 | + "psr-4": { | |
| 154 | + "Psr\\Container\\": "src/" | |
| 155 | + } | |
| 156 | + }, | |
| 157 | + "notification-url": "https://packagist.org/downloads/", | |
| 158 | + "license": [ | |
| 159 | + "MIT" | |
| 160 | + ], | |
| 161 | + "authors": [ | |
| 162 | + { | |
| 163 | + "name": "PHP-FIG", | |
| 164 | + "homepage": "http://www.php-fig.org/" | |
| 165 | + } | |
| 166 | + ], | |
| 167 | + "description": "Common Container Interface (PHP FIG PSR-11)", | |
| 168 | + "homepage": "https://github.com/php-fig/container", | |
| 169 | + "keywords": [ | |
| 170 | + "PSR-11", | |
| 171 | + "container", | |
| 172 | + "container-interface", | |
| 173 | + "container-interop", | |
| 174 | + "psr" | |
| 175 | + ], | |
| 176 | + "time": "2017-02-14T16:28:37+00:00" | |
| 177 | + }, | |
| 178 | + { | |
| 179 | + "name": "psr/http-message", | |
| 180 | + "version": "1.0.1", | |
| 181 | + "source": { | |
| 182 | + "type": "git", | |
| 183 | + "url": "https://github.com/php-fig/http-message.git", | |
| 184 | + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" | |
| 185 | + }, | |
| 186 | + "dist": { | |
| 187 | + "type": "zip", | |
| 188 | + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", | |
| 189 | + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", | |
| 190 | + "shasum": "" | |
| 191 | + }, | |
| 192 | + "require": { | |
| 193 | + "php": ">=5.3.0" | |
| 194 | + }, | |
| 195 | + "type": "library", | |
| 196 | + "extra": { | |
| 197 | + "branch-alias": { | |
| 198 | + "dev-master": "1.0.x-dev" | |
| 199 | + } | |
| 200 | + }, | |
| 201 | + "autoload": { | |
| 202 | + "psr-4": { | |
| 203 | + "Psr\\Http\\Message\\": "src/" | |
| 204 | + } | |
| 205 | + }, | |
| 206 | + "notification-url": "https://packagist.org/downloads/", | |
| 207 | + "license": [ | |
| 208 | + "MIT" | |
| 209 | + ], | |
| 210 | + "authors": [ | |
| 211 | + { | |
| 212 | + "name": "PHP-FIG", | |
| 213 | + "homepage": "http://www.php-fig.org/" | |
| 214 | + } | |
| 215 | + ], | |
| 216 | + "description": "Common interface for HTTP messages", | |
| 217 | + "homepage": "https://github.com/php-fig/http-message", | |
| 218 | + "keywords": [ | |
| 219 | + "http", | |
| 220 | + "http-message", | |
| 221 | + "psr", | |
| 222 | + "psr-7", | |
| 223 | + "request", | |
| 224 | + "response" | |
| 225 | + ], | |
| 226 | + "time": "2016-08-06T14:39:51+00:00" | |
| 227 | + }, | |
| 228 | + { | |
| 229 | + "name": "slim/slim", | |
| 230 | + "version": "3.7.0", | |
| 231 | + "source": { | |
| 232 | + "type": "git", | |
| 233 | + "url": "https://github.com/slimphp/Slim.git", | |
| 234 | + "reference": "4254e40d81559e35cdf856bcbaca5f3af468b7ef" | |
| 235 | + }, | |
| 236 | + "dist": { | |
| 237 | + "type": "zip", | |
| 238 | + "url": "https://api.github.com/repos/slimphp/Slim/zipball/4254e40d81559e35cdf856bcbaca5f3af468b7ef", | |
| 239 | + "reference": "4254e40d81559e35cdf856bcbaca5f3af468b7ef", | |
| 240 | + "shasum": "" | |
| 241 | + }, | |
| 242 | + "require": { | |
| 243 | + "container-interop/container-interop": "^1.1", | |
| 244 | + "nikic/fast-route": "^1.0", | |
| 245 | + "php": ">=5.5.0", | |
| 246 | + "pimple/pimple": "^3.0", | |
| 247 | + "psr/http-message": "^1.0" | |
| 248 | + }, | |
| 249 | + "provide": { | |
| 250 | + "psr/http-message-implementation": "1.0" | |
| 251 | + }, | |
| 252 | + "require-dev": { | |
| 253 | + "phpunit/phpunit": "^4.0", | |
| 254 | + "squizlabs/php_codesniffer": "^2.5" | |
| 255 | + }, | |
| 256 | + "type": "library", | |
| 257 | + "autoload": { | |
| 258 | + "psr-4": { | |
| 259 | + "Slim\\": "Slim" | |
| 260 | + } | |
| 261 | + }, | |
| 262 | + "notification-url": "https://packagist.org/downloads/", | |
| 263 | + "license": [ | |
| 264 | + "MIT" | |
| 265 | + ], | |
| 266 | + "authors": [ | |
| 267 | + { | |
| 268 | + "name": "Rob Allen", | |
| 269 | + "email": "rob@akrabat.com", | |
| 270 | + "homepage": "http://akrabat.com" | |
| 271 | + }, | |
| 272 | + { | |
| 273 | + "name": "Josh Lockhart", | |
| 274 | + "email": "hello@joshlockhart.com", | |
| 275 | + "homepage": "https://joshlockhart.com" | |
| 276 | + }, | |
| 277 | + { | |
| 278 | + "name": "Gabriel Manricks", | |
| 279 | + "email": "gmanricks@me.com", | |
| 280 | + "homepage": "http://gabrielmanricks.com" | |
| 281 | + }, | |
| 282 | + { | |
| 283 | + "name": "Andrew Smith", | |
| 284 | + "email": "a.smith@silentworks.co.uk", | |
| 285 | + "homepage": "http://silentworks.co.uk" | |
| 286 | + } | |
| 287 | + ], | |
| 288 | + "description": "Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs", | |
| 289 | + "homepage": "https://slimframework.com", | |
| 290 | + "keywords": [ | |
| 291 | + "api", | |
| 292 | + "framework", | |
| 293 | + "micro", | |
| 294 | + "router" | |
| 295 | + ], | |
| 296 | + "time": "2016-12-20T20:30:47+00:00" | |
| 297 | + } | |
| 298 | + ], | |
| 299 | + "packages-dev": [], | |
| 300 | + "aliases": [], | |
| 301 | + "minimum-stability": "stable", | |
| 302 | + "stability-flags": [], | |
| 303 | + "prefer-stable": false, | |
| 304 | + "prefer-lowest": false, | |
| 305 | + "platform": [], | |
| 306 | + "platform-dev": [] | |
| 307 | +} | ... | ... |
No preview for this file type
| 1 | +++ a/controlador_ws.php | |
| ... | ... | @@ -0,0 +1,104 @@ |
| 1 | +<? | |
| 2 | +/** | |
| 3 | + * Controlador (API v1) de servicos REST usando o framework Slim | |
| 4 | + */ | |
| 5 | + | |
| 6 | +require_once dirname(__FILE__).'/../../SEI.php'; | |
| 7 | +require_once dirname(__FILE__).'/vendor/autoload.php'; | |
| 8 | + | |
| 9 | +class TokenValidationMiddleware{ | |
| 10 | + public function __invoke($request, $response, $next) | |
| 11 | + { | |
| 12 | + /** @var $request Slim\Http\Request */ | |
| 13 | + /** @var $response Slim\Http\Response */ | |
| 14 | + $token = $request->getHeader('token'); | |
| 15 | + | |
| 16 | + if(!$token){ | |
| 17 | + return $response->withJson(array('sucesso' => false, 'mensagem' => 'Acesso negado!'), 401); | |
| 18 | + } | |
| 19 | + $rn = new MdWsSeiUsuarioRN(); | |
| 20 | + $result = $rn->autenticarToken($token[0]); | |
| 21 | + if(!$result['sucesso']){ | |
| 22 | + var_dump($result); | |
| 23 | + return $response->withJson($result, 403); | |
| 24 | + } | |
| 25 | + $response = $next($request, $response); | |
| 26 | + return $response; | |
| 27 | + } | |
| 28 | +} | |
| 29 | + | |
| 30 | +$config = array( | |
| 31 | + 'settings' => array( | |
| 32 | + 'determineRouteBeforeAppMiddleware' => true, | |
| 33 | + 'displayErrorDetails' => true | |
| 34 | + ) | |
| 35 | +); | |
| 36 | + | |
| 37 | +$app = new \Slim\App($config); | |
| 38 | +/** | |
| 39 | + * Grupo para a versao v1 de servicos REST | |
| 40 | + */ | |
| 41 | +$app->group('/v1',function(){ | |
| 42 | + /** | |
| 43 | + * Grupo de autenticacao <publico> | |
| 44 | + */ | |
| 45 | + $this->post('/autenticar', function($request, $response, $args){ | |
| 46 | + var_dump(111);exit; | |
| 47 | + $rn = new MdWsSeiUsuarioRN(); | |
| 48 | + $usuarioDTO = new UsuarioDTO(); | |
| 49 | + $usuarioDTO->setStrSigla($request->getParam('usuario')); | |
| 50 | + $usuarioDTO->setStrSenha($request->getParam('senha')); | |
| 51 | + | |
| 52 | + return $response->withJSON($rn->autenticar($usuarioDTO)); | |
| 53 | + }); | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * Grupo de controlador de anotacao | |
| 57 | + */ | |
| 58 | + $this->group('/anotacao', function(){ | |
| 59 | + $this->post('/', function($request, $response, $args){ | |
| 60 | + $rn = new MdWsSeiAnotacaoRN(); | |
| 61 | + $dto = $rn->encapsulaAnotacao($request->getParams()); | |
| 62 | + return $response->withJSON($rn->cadastrarAnotacao($dto)); | |
| 63 | + })->setName('v1_anotacao_cadastrar'); | |
| 64 | + | |
| 65 | + })->add( new TokenValidationMiddleware()); | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * Grupo de controlador de bloco | |
| 69 | + */ | |
| 70 | + $this->group('/bloco', function(){ | |
| 71 | + $this->get('/listar/bloco/unidade/{unidade}', function($request, $response, $args){ | |
| 72 | + /** @var $request Slim\Http\Request */ | |
| 73 | + $rn = new MdWsSeiBlocoRN(); | |
| 74 | + $dto = new UnidadeDTO(); | |
| 75 | + $dto->setNumIdUnidade($request->getAttribute('route')->getArgument('unidade')); | |
| 76 | + $dto->setNumMaxRegistrosRetorno($request->getParam('limit')); | |
| 77 | + $dto->setNumPaginaAtual($request->getParam('start')); | |
| 78 | + return $response->withJSON($rn->listarBlocoUnidade($dto)); | |
| 79 | + }); | |
| 80 | + $this->get('/listar/bloco/documentos/{bloco}', function($request, $response, $args){ | |
| 81 | + var_dump(111);exit; | |
| 82 | + /** @var $request Slim\Http\Request */ | |
| 83 | + $rn = new MdWsSeiBlocoRN(); | |
| 84 | + $dto = new BlocoDTO(); | |
| 85 | + $dto->setNumIdBloco($request->getAttribute('route')->getArgument('bloco')); | |
| 86 | + $dto->setNumMaxRegistrosRetorno($request->getParam('limit')); | |
| 87 | + $dto->setNumPaginaAtual($request->getParam('start')); | |
| 88 | + return $response->withJSON($rn->listarDocumentosBloco($dto)); | |
| 89 | + }); | |
| 90 | + | |
| 91 | + })->add( new TokenValidationMiddleware()); | |
| 92 | +}); | |
| 93 | + | |
| 94 | + | |
| 95 | +$app->run(); | |
| 96 | +$c = $app->getContainer(); | |
| 97 | +$c['errorHandler'] = function ($c) { | |
| 98 | + return function ($request, $response, $exception) use ($c) { | |
| 99 | + var_dump($exception);exit; | |
| 100 | + return $c['response']->withStatus(500) | |
| 101 | + ->withHeader('Content-Type', 'text/html') | |
| 102 | + ->write('Something went wrong!'); | |
| 103 | + }; | |
| 104 | +}; | ... | ... |
| 1 | +++ a/dto/MdWsSeiProcessoDTO.php | |
| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | +<? | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Class MdWsSeiProcessoDTO | |
| 5 | + * DTO somente para encapsulamento de dados. | |
| 6 | + * OBS: Nao estou usando API pois em modulos do SEI o autoload nao carrega as API's. | |
| 7 | + */ | |
| 8 | +class MdWsSeiProcessoDTO extends InfraDTO{ | |
| 9 | + | |
| 10 | + public function getStrNomeTabela() | |
| 11 | + { | |
| 12 | + throw new InfraException('DTO nao utilizavel para consulta!'); | |
| 13 | + } | |
| 14 | + | |
| 15 | + public function montar(){ | |
| 16 | + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Template'); | |
| 17 | + $this->adicionarAtributo(InfraDTO::$PREFIXO_NUM, 'IdAtividade'); | |
| 18 | + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'Valor'); | |
| 19 | + } | |
| 20 | + | |
| 21 | +} | ... | ... |
| 1 | +++ a/dto/MdWsSeiProtocoloDTO.php | |
| ... | ... | @@ -0,0 +1,52 @@ |
| 1 | +<? | |
| 2 | + | |
| 3 | +class MdWsSeiProtocoloDTO extends ProtocoloDTO{ | |
| 4 | + CONST SIN_TIPO_BUSCA_M = 'M'; | |
| 5 | + CONST SIN_TIPO_BUSCA_G = 'G'; | |
| 6 | + | |
| 7 | + public function montar(){ | |
| 8 | + parent::montar(); | |
| 9 | + | |
| 10 | + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_NUM, | |
| 11 | + 'idGrupoAcompanhamentoProcedimento', | |
| 12 | + 'id_grupo_acompanhamento', | |
| 13 | + 'acompanhamento'); | |
| 14 | + | |
| 15 | + | |
| 16 | + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_NUM, | |
| 17 | + 'IdUsuarioGeradorAcompanhamento', | |
| 18 | + 'id_usuario_gerador', | |
| 19 | + 'acompanhamento'); | |
| 20 | + | |
| 21 | + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_DTH, | |
| 22 | + 'GeracaoAcompanhamento', | |
| 23 | + 'dth_geracao', | |
| 24 | + 'acompanhamento'); | |
| 25 | + | |
| 26 | + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_NUM, | |
| 27 | + 'IdUsuarioAtribuicaoAtividade', | |
| 28 | + 'id_usuario_atribuicao', | |
| 29 | + 'atividade'); | |
| 30 | + | |
| 31 | + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_STR, | |
| 32 | + 'SinCienciaProcedimento', | |
| 33 | + 'p2.sin_ciencia', | |
| 34 | + 'procedimento p2'); | |
| 35 | + | |
| 36 | + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_DTH, | |
| 37 | + 'AberturaAtividade', | |
| 38 | + 'dth_abertura', | |
| 39 | + 'atividade'); | |
| 40 | + | |
| 41 | + $this->adicionarAtributoTabelaRelacionada(InfraDTO::$PREFIXO_NUM, | |
| 42 | + 'IdUnidadeAtividade', | |
| 43 | + 'id_unidade', | |
| 44 | + 'atividade'); | |
| 45 | + | |
| 46 | + $this->adicionarAtributo(InfraDTO::$PREFIXO_STR, 'SinTipoBusca'); | |
| 47 | + | |
| 48 | + $this->configurarFK('IdProtocolo', 'procedimento p2', 'p2.id_procedimento', InfraDTO::$TIPO_FK_OBRIGATORIA); | |
| 49 | + $this->configurarFK('IdProtocolo', 'acompanhamento', 'id_protocolo'); | |
| 50 | + } | |
| 51 | + | |
| 52 | +} | ... | ... |
| 1 | +++ a/rn/MdWsSeiAcompanhamentoRN.php | |
| ... | ... | @@ -0,0 +1,63 @@ |
| 1 | +<? | |
| 2 | +require_once dirname(__FILE__).'/../../../SEI.php'; | |
| 3 | + | |
| 4 | +class MdWsSeiAcompanhamentoRN extends InfraRN { | |
| 5 | + | |
| 6 | + protected function inicializarObjInfraIBanco(){ | |
| 7 | + return BancoSEI::getInstance(); | |
| 8 | + } | |
| 9 | + | |
| 10 | + public function encapsulaAcompanhamento(array $post){ | |
| 11 | + $acompanhamentoDTO = new AcompanhamentoDTO(); | |
| 12 | + | |
| 13 | + if (isset($post['protocolo'])){ | |
| 14 | + $acompanhamentoDTO->setDblIdProtocolo($post['protocolo']); | |
| 15 | + } | |
| 16 | + if (isset($post['unidade'])){ | |
| 17 | + $acompanhamentoDTO->setNumIdUnidade($post['unidade']); | |
| 18 | + } | |
| 19 | + | |
| 20 | + if (isset($post['grupo'])){ | |
| 21 | + $acompanhamentoDTO->setNumIdGrupoAcompanhamento($post['grupo']); | |
| 22 | + } | |
| 23 | + if (isset($post['usuario'])){ | |
| 24 | + $acompanhamentoDTO->setNumIdUsuarioGerador($post['usuario']); | |
| 25 | + } | |
| 26 | + if (isset($post['observacao'])){ | |
| 27 | + $acompanhamentoDTO->setStrObservacao($post['observacao']); | |
| 28 | + } | |
| 29 | + | |
| 30 | + return $acompanhamentoDTO; | |
| 31 | + | |
| 32 | + } | |
| 33 | + | |
| 34 | + protected function cadastrarAcompanhamentoControlado(AcompanhamentoDTO $acompanhamentoDTO){ | |
| 35 | + try{ | |
| 36 | + $acompanhamentoRN = new AcompanhamentoRN(); | |
| 37 | + $acompanhamentoDTO->setDthGeracao(InfraData::getStrDataHoraAtual()); | |
| 38 | + $pesquisaDTO = new AcompanhamentoDTO(); | |
| 39 | + $pesquisaDTO->setOrdNumIdAcompanhamento(InfraDTO::$TIPO_ORDENACAO_DESC); | |
| 40 | + $pesquisaDTO->setNumMaxRegistrosRetorno(1); | |
| 41 | + $pesquisaDTO->retNumIdAcompanhamento(); | |
| 42 | + $result = $acompanhamentoRN->listar($pesquisaDTO); | |
| 43 | + $numIdAcompanhamento = 1; | |
| 44 | + if(!empty($result)){ | |
| 45 | + $pesquisaDTO = end($result); | |
| 46 | + $numIdAcompanhamento = $pesquisaDTO->getNumIdAcompanhamento()+1; | |
| 47 | + } | |
| 48 | + $acompanhamentoDTO->setNumIdAcompanhamento($numIdAcompanhamento); | |
| 49 | + $acompanhamentoRN->cadastrar($acompanhamentoDTO); | |
| 50 | + | |
| 51 | + return array ( | |
| 52 | + "sucesso" => true, | |
| 53 | + "mensagem" => 'Acompanhamento realizado com sucesso!' | |
| 54 | + ); | |
| 55 | + }catch (Exception $e){ | |
| 56 | + return array ( | |
| 57 | + "sucesso" => false, | |
| 58 | + "mensagem" => $e->getMessage(), | |
| 59 | + "exception" => $e | |
| 60 | + ); | |
| 61 | + } | |
| 62 | + } | |
| 63 | +} | |
| 0 | 64 | \ No newline at end of file | ... | ... |
| 1 | +++ a/rn/MdWsSeiAnotacaoRN.php | |
| ... | ... | @@ -0,0 +1,71 @@ |
| 1 | +<? | |
| 2 | +require_once dirname(__FILE__).'/../../../SEI.php'; | |
| 3 | + | |
| 4 | +class MdWsSeiAnotacaoRN extends InfraRN { | |
| 5 | + | |
| 6 | + protected function inicializarObjInfraIBanco(){ | |
| 7 | + return BancoSEI::getInstance(); | |
| 8 | + } | |
| 9 | + | |
| 10 | + public function encapsulaAnotacao(array $post){ | |
| 11 | + $anotacaoDTO = new AnotacaoDTO(); | |
| 12 | + if (isset($post['descricao'])) { | |
| 13 | + $anotacaoDTO->setStrDescricao($post['descricao']); | |
| 14 | + } | |
| 15 | + | |
| 16 | + | |
| 17 | + if (isset($post['protocolo'])) { | |
| 18 | + $anotacaoDTO->setDblIdProtocolo($post['protocolo']); | |
| 19 | + } | |
| 20 | + | |
| 21 | + if (isset($post['unidade'])) { | |
| 22 | + $anotacaoDTO->setNumIdUnidade($post['unidade']); | |
| 23 | + } | |
| 24 | + | |
| 25 | + if (isset($post['usuario'])) { | |
| 26 | + $anotacaoDTO->setNumIdUsuario($post['usuario']); | |
| 27 | + } | |
| 28 | + | |
| 29 | + $anotacaoDTO->setDthAnotacao(InfraData::getStrDataHoraAtual()); | |
| 30 | + | |
| 31 | + if (isset($post['prioridade'])) { | |
| 32 | + $anotacaoDTO->setStrSinPrioridade( | |
| 33 | + ($post['prioridade']) ? 'S' : 'N' | |
| 34 | + ); | |
| 35 | + } | |
| 36 | + $anotacaoDTO->setStrStaAnotacao('U'); | |
| 37 | + | |
| 38 | + return $anotacaoDTO; | |
| 39 | + } | |
| 40 | + | |
| 41 | + protected function cadastrarAnotacaoControlado(AnotacaoDTO $anotacaoDTO){ | |
| 42 | + try{ | |
| 43 | + $anotacaoRN = new AnotacaoRN(); | |
| 44 | + if(!$anotacaoDTO->getDblIdProtocolo()){ | |
| 45 | + throw new InfraException('Protocolo não informado.'); | |
| 46 | + } | |
| 47 | + $anotacaoConsulta = new AnotacaoDTO(); | |
| 48 | + $anotacaoConsulta->setDblIdProtocolo($anotacaoDTO->getDblIdProtocolo()); | |
| 49 | + $anotacaoConsulta->setNumMaxRegistrosRetorno(1); | |
| 50 | + $anotacaoConsulta->retNumIdAnotacao(); | |
| 51 | + $ret = $anotacaoRN->listar($anotacaoConsulta); | |
| 52 | + if($ret){ | |
| 53 | + $anotacaoDTO->setNumIdAnotacao($ret[0]->getNumIdAnotacao()); | |
| 54 | + $anotacaoRN->alterar($anotacaoDTO); | |
| 55 | + }else{ | |
| 56 | + $anotacaoRN->cadastrar($anotacaoDTO); | |
| 57 | + } | |
| 58 | + return array ( | |
| 59 | + "sucesso" => true, | |
| 60 | + "mensagem" => 'Anotação cadastrada com sucesso!' | |
| 61 | + ); | |
| 62 | + }catch (Exception $e){ | |
| 63 | + return array ( | |
| 64 | + "sucesso" => false, | |
| 65 | + "mensagem" => $e->getMessage(), | |
| 66 | + "exception" => $e | |
| 67 | + ); | |
| 68 | + } | |
| 69 | + } | |
| 70 | + | |
| 71 | +} | |
| 0 | 72 | \ No newline at end of file | ... | ... |
| 1 | +++ a/rn/MdWsSeiAssinanteRN.php | |
| ... | ... | @@ -0,0 +1,48 @@ |
| 1 | +<? | |
| 2 | +require_once dirname(__FILE__).'/../../../SEI.php'; | |
| 3 | + | |
| 4 | +class MdWsSeiAssinanteRN extends InfraRN { | |
| 5 | + | |
| 6 | + protected function inicializarObjInfraIBanco(){ | |
| 7 | + return BancoSEI::getInstance(); | |
| 8 | + } | |
| 9 | + | |
| 10 | + /** | |
| 11 | + * Retorna todas as funcoes/cargos cadastrados | |
| 12 | + * @param AssinanteDTO $assinanteDTO | |
| 13 | + * @info Para retornar a consulta paginada e necessario passar dentro do DTO os parametros: | |
| 14 | + * - setNumMaxRegistrosRetorno - maximo de registros por pagina (limit) | |
| 15 | + * - setNumPaginaAtual - pagina atual (offset) | |
| 16 | + * @return array | |
| 17 | + */ | |
| 18 | + protected function listarAssinanteConectado(AssinanteDTO $assinanteDTO){ | |
| 19 | + try{ | |
| 20 | + $result = array(); | |
| 21 | + $assinanteDTO->retNumIdAssinante(); | |
| 22 | + $assinanteDTO->retStrCargoFuncao(); | |
| 23 | + $assinanteDTO->setOrdStrCargoFuncao(InfraDTO::$TIPO_ORDENACAO_ASC); | |
| 24 | + $assinanteRN = new AssinanteRN(); | |
| 25 | + $ret = $assinanteRN->pesquisar($assinanteDTO); | |
| 26 | + /** @var AssinanteDTO $assinDTO */ | |
| 27 | + foreach($ret as $assinDTO){ | |
| 28 | + $result[] = array( | |
| 29 | + 'id' => $assinDTO->getNumIdAssinante(), | |
| 30 | + 'nome' => $assinDTO->getStrCargoFuncao(), | |
| 31 | + ); | |
| 32 | + } | |
| 33 | + | |
| 34 | + return array( | |
| 35 | + 'sucesso' => true, | |
| 36 | + 'data' => $result, | |
| 37 | + 'total' => $assinanteDTO->getNumTotalRegistros() | |
| 38 | + ); | |
| 39 | + }catch (Exception $e){ | |
| 40 | + return array( | |
| 41 | + 'sucesso' => false, | |
| 42 | + 'mensagem' => $e->getMessage(), | |
| 43 | + 'exception' => $e | |
| 44 | + ); | |
| 45 | + } | |
| 46 | + } | |
| 47 | + | |
| 48 | +} | |
| 0 | 49 | \ No newline at end of file | ... | ... |
| 1 | +++ a/rn/MdWsSeiAtividadeRN.php | |
| ... | ... | @@ -0,0 +1,175 @@ |
| 1 | +<? | |
| 2 | +require_once dirname(__FILE__).'/../../../SEI.php'; | |
| 3 | + | |
| 4 | +class MdWsSeiAtividadeRN extends InfraRN { | |
| 5 | + | |
| 6 | + protected function inicializarObjInfraIBanco(){ | |
| 7 | + return BancoSEI::getInstance(); | |
| 8 | + } | |
| 9 | + | |
| 10 | + private function traduzirTemplate(AtividadeDTO $atividadeDTO, ProtocoloDTO $protocoloDTO) { | |
| 11 | + $arrParameters = ['DOCUMENTO', 'DOCUMENTOS', 'NIVEL_ACESSO', 'GRAU_SIGILO', 'HIPOTESE_LEGAL', 'DATA_AUTUACAO', 'TIPO_CONFERENCIA', | |
| 12 | + 'PROCESSO', 'USUARIO', 'USUARIOS', 'UNIDADE', 'BLOCO', 'DATA_HORA', 'USUARIO_ANULACAO', 'INTERESSADO', 'LOCALIZADOR', 'ANEXO', | |
| 13 | + 'USUARIO_EXTERNO_NOME', 'USUARIO_EXTERNO_SIGLA', 'DATA', 'DESTINATARIO_NOME', 'DESTINATARIO_EMAIL', 'DATA_VALIDADE', 'DIAS_VALIDADE', | |
| 14 | + 'MOTIVO', 'VEICULO', 'TIPO']; | |
| 15 | + | |
| 16 | + $strTemplate = $atividadeDTO->getStrNomeTarefa(); | |
| 17 | + | |
| 18 | + if ($strTemplate) { | |
| 19 | + foreach($arrParameters as $parameter) { | |
| 20 | + $parameter = '@' . $parameter . '@'; | |
| 21 | + | |
| 22 | + $restrito = 'não restrito'; | |
| 23 | + | |
| 24 | + $nome = ($atividadeDTO->getNumIdUsuarioOrigem())? $atividadeDTO->getStrNomeUsuarioOrigem() : null; | |
| 25 | + $sigla = ($atividadeDTO->getNumIdUsuarioOrigem())? $atividadeDTO->getStrSiglaUsuarioOrigem() : null; | |
| 26 | + $usuarioAnulacao = ($atividadeDTO->getNumIdUsuarioConclusao())? $atividadeDTO->getStrNomeUsuarioConclusao() : null; | |
| 27 | + $unidade = $atividadeDTO->getStrSiglaUnidade(); | |
| 28 | + $dataHora = ' '.$atividadeDTO->getDthAbertura(); | |
| 29 | + | |
| 30 | + if ($protocoloDTO->getStrStaNivelAcessoLocal() == 1) { | |
| 31 | + $restrito = 'restrito'; | |
| 32 | + } | |
| 33 | + | |
| 34 | + if('@DOCUMENTO@' == $parameter) { | |
| 35 | + $strTemplate = str_replace($parameter, $protocoloDTO->getStrProtocoloFormatado(), $strTemplate); | |
| 36 | + } elseif ('@DOCUMENTOS@' == $parameter) { | |
| 37 | + $strTemplate = str_replace($parameter, '', $strTemplate); | |
| 38 | + } elseif ('@NIVEL_ACESSO@' == $parameter) { | |
| 39 | + $strTemplate = str_replace($parameter, $restrito, $strTemplate); | |
| 40 | + } elseif ('@GRAU_SIGILO@' == $parameter) { | |
| 41 | + $strTemplate = str_replace($parameter, '', $strTemplate); | |
| 42 | + } elseif ('@HIPOTESE_LEGAL@' == $parameter) { | |
| 43 | + $strTemplate = str_replace($parameter, '', $strTemplate); | |
| 44 | + } elseif ('@DATA_AUTUACAO@' == $parameter) { | |
| 45 | + $strTemplate = str_replace($parameter, $dataHora, $strTemplate); | |
| 46 | + } elseif ('@TIPO_CONFERENCIA@' == $parameter) { | |
| 47 | + $strTemplate = str_replace($parameter, '', $strTemplate); | |
| 48 | + } elseif ('@PROCESSO@' == $parameter) { | |
| 49 | + $strTemplate = str_replace($parameter, $protocoloDTO->getStrProtocoloFormatado(), $strTemplate); | |
| 50 | + } elseif ('@USUARIO@' == $parameter) { | |
| 51 | + $strTemplate = str_replace($parameter, $nome, $strTemplate); | |
| 52 | + } elseif ('@USUARIOS@' == $parameter) { | |
| 53 | + $strTemplate = str_replace($parameter, '', $strTemplate); | |
| 54 | + } elseif ('@UNIDADE@' == $parameter) { | |
| 55 | + $strTemplate = str_replace($parameter, $unidade, $strTemplate); | |
| 56 | + } elseif ('@BLOCO@' == $parameter) { | |
| 57 | + $blocoRN = new BlocoRN(); | |
| 58 | + $blocoDTO = new BlocoDTO(); | |
| 59 | + $blocoDTO->setNumIdUnidade($atividadeDTO->getNumIdUnidade()); | |
| 60 | + $blocoDTO->setNumMaxRegistrosRetorno(1); | |
| 61 | + $blocoDTO->retStrDescricao(); | |
| 62 | + $blocoResult = $blocoRN->listarRN1277($blocoDTO); | |
| 63 | + if (!empty($blocoResult)) { | |
| 64 | + $bloco = $blocoResult[0]; | |
| 65 | + $strTemplate = str_replace($parameter, $bloco->getStrDescricao(), $strTemplate); | |
| 66 | + } | |
| 67 | + } elseif ('@DATA_HORA@' == $parameter) { | |
| 68 | + $strTemplate = str_replace($parameter, $dataHora, $strTemplate); | |
| 69 | + } elseif ('@DATA@' == $parameter) { | |
| 70 | + $strTemplate = str_replace($parameter, $dataHora, $strTemplate); | |
| 71 | + } elseif ('@USUARIO_ANULACAO@' == $parameter) { | |
| 72 | + $strTemplate = str_replace($parameter, $usuarioAnulacao, $strTemplate); | |
| 73 | + } elseif ('@INTERESSADO@' == $parameter) { | |
| 74 | + $strTemplate = str_replace($parameter, '', $strTemplate); | |
| 75 | + } elseif ('@LOCALIZADOR@' == $parameter) { | |
| 76 | + $strTemplate = str_replace($parameter, '', $strTemplate); | |
| 77 | + } elseif ('@ANEXO@' == $parameter) { | |
| 78 | + $strTemplate = str_replace($parameter, '', $strTemplate); | |
| 79 | + } elseif ('@USUARIO_EXTERNO_NOME@' == $parameter) { | |
| 80 | + $strTemplate = str_replace($parameter, $nome, $strTemplate); | |
| 81 | + } elseif ('@USUARIO_EXTERNO_SIGLA@' == $parameter) { | |
| 82 | + $strTemplate = str_replace($parameter, $sigla, $strTemplate); | |
| 83 | + } elseif ('@DESTINATARIO_NOME@' == $parameter) { | |
| 84 | + $strTemplate = str_replace($parameter, '', $strTemplate); | |
| 85 | + } elseif ('@DESTINATARIO_EMAIL@' == $parameter) { | |
| 86 | + $strTemplate = str_replace($parameter, '', $strTemplate); | |
| 87 | + } elseif ('@DATA_VALIDADE@' == $parameter) { | |
| 88 | + $strTemplate = str_replace($parameter, '', $strTemplate); | |
| 89 | + } elseif ('@DIAS_VALIDADE@' == $parameter) { | |
| 90 | + $strTemplate = str_replace($parameter, '', $strTemplate); | |
| 91 | + } elseif ('@MOTIVO@' == $parameter) { | |
| 92 | + $strTemplate = str_replace($parameter, '', $strTemplate); | |
| 93 | + } elseif ('@VEICULO@' == $parameter) { | |
| 94 | + $strTemplate = str_replace($parameter, '', $strTemplate); | |
| 95 | + } elseif ('@TIPO@' == $parameter) { | |
| 96 | + $strTemplate = str_replace($parameter, '', $strTemplate); | |
| 97 | + } | |
| 98 | + } | |
| 99 | + } | |
| 100 | + | |
| 101 | + return $strTemplate; | |
| 102 | + } | |
| 103 | + | |
| 104 | + /** | |
| 105 | + * Para efetuar a paginacao e necessario passar dentro do AtividadeDTO os parametros abaixo: | |
| 106 | + * -- setNumPaginaAtual($offset) | |
| 107 | + * -- setNumMaxRegistrosRetorno($limit) | |
| 108 | + * @param AtividadeDTO $atividadeDTO | |
| 109 | + * @return array | |
| 110 | + * @throws InfraException | |
| 111 | + */ | |
| 112 | + protected function listarAtividadesProcessoConectado(AtividadeDTO $atividadeDTO){ | |
| 113 | + try{ | |
| 114 | + if(!$atividadeDTO->isSetDblIdProtocolo()){ | |
| 115 | + throw new InfraException('O protocolo deve ser informado!'); | |
| 116 | + } | |
| 117 | + if(!$atividadeDTO->isSetNumIdUnidade()){ | |
| 118 | + $atividadeDTO->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual()); | |
| 119 | + } | |
| 120 | + $protocoloRN = new ProtocoloRN(); | |
| 121 | + $protocoloDTO = new ProtocoloDTO(); | |
| 122 | + $protocoloDTO->setDblIdProtocolo($atividadeDTO->getDblIdProtocolo()); | |
| 123 | + $protocoloDTO->retStrStaNivelAcessoLocal(); | |
| 124 | + $protocoloDTO->retStrProtocoloFormatado(); | |
| 125 | + $resultProtocolo = $protocoloRN->listarRN0668($protocoloDTO); | |
| 126 | + $protocoloDTO = $resultProtocolo[0]; | |
| 127 | + | |
| 128 | + $atividadeDTO->retDblIdProtocolo(); | |
| 129 | + $atividadeDTO->retNumIdUnidade(); | |
| 130 | + $atividadeDTO->retDthAbertura(); | |
| 131 | + $atividadeDTO->retStrNomeTarefa(); | |
| 132 | + $atividadeDTO->retNumIdAtividade(); | |
| 133 | + $atividadeDTO->retNumIdUsuarioOrigem(); | |
| 134 | + $atividadeDTO->retStrSiglaUsuarioOrigem(); | |
| 135 | + $atividadeDTO->retStrSiglaUnidade(); | |
| 136 | + $atividadeDTO->retStrNomeUsuarioOrigem(); | |
| 137 | + $atividadeDTO->retNumIdUsuarioConclusao(); | |
| 138 | + $atividadeDTO->retStrNomeUsuarioConclusao(); | |
| 139 | + $atividadeRN = new AtividadeRN(); | |
| 140 | + $result = $atividadeRN->listarRN0036($atividadeDTO); | |
| 141 | + if (!empty($result)) { | |
| 142 | + foreach($result as $value) { | |
| 143 | + $dateTime = explode(' ', $value->getDthAbertura()); | |
| 144 | + $informacao = $this->traduzirTemplate($value, $protocoloDTO); | |
| 145 | + $arrayResult[] = [ | |
| 146 | + "id" => $value->getNumIdAtividade(), | |
| 147 | + "atributos" => [ | |
| 148 | + "idProcesso" => $value->getDblIdProtocolo(), | |
| 149 | + "usuario" => ($value->getNumIdUsuarioOrigem())? $value->getStrSiglaUsuarioOrigem() : null, | |
| 150 | + "data" => $dateTime[0], | |
| 151 | + "hora" => $dateTime[1], | |
| 152 | + "unidade" => $value->getStrSiglaUnidade(), | |
| 153 | + "informacao" => $informacao | |
| 154 | + ] | |
| 155 | + ]; | |
| 156 | + } | |
| 157 | + } | |
| 158 | + | |
| 159 | + return array( | |
| 160 | + 'sucesso' => true, | |
| 161 | + 'data' => $arrayResult, | |
| 162 | + 'total' => $atividadeDTO->getNumTotalRegistros() | |
| 163 | + ); | |
| 164 | + }catch (Exception $e){ | |
| 165 | + return array( | |
| 166 | + 'sucesso' => false, | |
| 167 | + 'mensagem' => $e->getMessage(), | |
| 168 | + 'exception' => $e | |
| 169 | + ); | |
| 170 | + } | |
| 171 | + } | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | +} | |
| 0 | 176 | \ No newline at end of file | ... | ... |
| 1 | +++ a/rn/MdWsSeiBlocoRN.php | |
| ... | ... | @@ -0,0 +1,253 @@ |
| 1 | +<? | |
| 2 | +require_once dirname(__FILE__).'/../../../SEI.php'; | |
| 3 | + | |
| 4 | +class MdWsSeiBlocoRN extends InfraRN { | |
| 5 | + | |
| 6 | + protected function inicializarObjInfraIBanco(){ | |
| 7 | + return BancoSEI::getInstance(); | |
| 8 | + } | |
| 9 | + | |
| 10 | + /** | |
| 11 | + * Consultar Blocos | |
| 12 | + * @param UnidadeDTO $unidadeDTO | |
| 13 | + * @return array | |
| 14 | + */ | |
| 15 | + protected function listarBlocoUnidadeConectado(UnidadeDTO $unidadeDTO){ | |
| 16 | + try{ | |
| 17 | + $result = array(); | |
| 18 | + $blocoDTOConsulta = new BlocoDTO(); | |
| 19 | + if(!$unidadeDTO->getNumMaxRegistrosRetorno()){ | |
| 20 | + $blocoDTOConsulta->setNumMaxRegistrosRetorno(10); | |
| 21 | + }else{ | |
| 22 | + $blocoDTOConsulta->setNumMaxRegistrosRetorno($unidadeDTO->getNumMaxRegistrosRetorno()); | |
| 23 | + } | |
| 24 | + if(is_null($unidadeDTO->getNumPaginaAtual())){ | |
| 25 | + $blocoDTOConsulta->setNumPaginaAtual(0); | |
| 26 | + }else{ | |
| 27 | + $blocoDTOConsulta->setNumPaginaAtual($unidadeDTO->getNumPaginaAtual()); | |
| 28 | + } | |
| 29 | + if(!$unidadeDTO->isSetNumIdUnidade()){ | |
| 30 | + $blocoDTOConsulta->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual()); | |
| 31 | + }else{ | |
| 32 | + $blocoDTOConsulta->setNumIdUnidade($unidadeDTO->getNumIdUnidade()); | |
| 33 | + } | |
| 34 | + | |
| 35 | + $blocoRN = new BlocoRN(); | |
| 36 | + $blocoDTOConsulta->setNumIdUnidadeRelBlocoUnidade($unidadeDTO->getNumIdUnidade()); | |
| 37 | + $blocoDTOConsulta->setNumIdUnidade($unidadeDTO->getNumIdUnidade()); | |
| 38 | + $blocoDTOConsulta->adicionarCriterio( | |
| 39 | + array('StaTipo', 'StaEstado'), | |
| 40 | + array(InfraDTO::$OPER_IGUAL, InfraDTO::$OPER_IN), | |
| 41 | + array('A', array('D', 'C', 'R', 'A')), | |
| 42 | + InfraDTO::$OPER_LOGICO_AND | |
| 43 | + ); | |
| 44 | + $blocoDTOConsulta->retNumIdBloco(); | |
| 45 | + $blocoDTOConsulta->retNumIdUnidade(); | |
| 46 | + $blocoDTOConsulta->retStrSiglaUnidade(); | |
| 47 | + $blocoDTOConsulta->retStrStaEstado(); | |
| 48 | + $blocoDTOConsulta->retStrDescricao(); | |
| 49 | + $blocoDTOConsulta->setOrdNumIdBloco(InfraDTO::$TIPO_ORDENACAO_DESC); | |
| 50 | + $ret = $blocoRN->listarRN1277($blocoDTOConsulta); | |
| 51 | + /** @var BlocoDTO $blocoDTO */ | |
| 52 | + foreach($ret as $blocoDTO){ | |
| 53 | + $arrUnidades[] = array( | |
| 54 | + 'idUnidade' => $blocoDTO->getNumIdUnidade(), | |
| 55 | + 'unidade' => $blocoDTO->getStrSiglaUnidade() | |
| 56 | + ); | |
| 57 | + $result[] = array( | |
| 58 | + 'id' => $blocoDTO->getNumIdBloco(), | |
| 59 | + 'atributos' => array( | |
| 60 | + 'idBloco' => $blocoDTO->getNumIdBloco(), | |
| 61 | + 'idUnidade' => $blocoDTO->getNumIdUnidade(), | |
| 62 | + 'siglaUnidade' => $blocoDTO->getStrSiglaUnidade(), | |
| 63 | + 'estado' => $blocoDTO->getStrStaEstado(), | |
| 64 | + 'descricao' => $blocoDTO->getStrDescricao(), | |
| 65 | + 'unidades' => $arrUnidades | |
| 66 | + ) | |
| 67 | + ); | |
| 68 | + } | |
| 69 | + return array( | |
| 70 | + 'sucesso' => true, | |
| 71 | + 'data' => $result, | |
| 72 | + 'total' => !$result ? 0 : $blocoDTOConsulta->getNumTotalRegistros() | |
| 73 | + ); | |
| 74 | + }catch (Exception $e){ | |
| 75 | + return array( | |
| 76 | + 'sucesso' => false, | |
| 77 | + 'mensagem' => $e->getMessage(), | |
| 78 | + 'exception' => $e | |
| 79 | + ); | |
| 80 | + } | |
| 81 | + } | |
| 82 | + | |
| 83 | + /** | |
| 84 | + * Consultar Documentos por Bloco | |
| 85 | + * @param BlocoDTO $blocoDTOConsulta | |
| 86 | + * @return array | |
| 87 | + */ | |
| 88 | + protected function listarDocumentosBlocoConectado(BlocoDTO $blocoDTOConsulta){ | |
| 89 | + try{ | |
| 90 | + if(!$blocoDTOConsulta->getNumIdBloco()){ | |
| 91 | + throw new InfraException('Bloco nao informado.'); | |
| 92 | + } | |
| 93 | + $relBlocoProtocoloRN = new RelBlocoProtocoloRN(); | |
| 94 | + $relBlocoProtocoloDTOConsulta = new RelBlocoProtocoloDTO(); | |
| 95 | + if($blocoDTOConsulta->getNumMaxRegistrosRetorno()){ | |
| 96 | + $relBlocoProtocoloDTOConsulta->setNumMaxRegistrosRetorno($blocoDTOConsulta->getNumMaxRegistrosRetorno()); | |
| 97 | + }else{ | |
| 98 | + $relBlocoProtocoloDTOConsulta->setNumMaxRegistrosRetorno(10); | |
| 99 | + } | |
| 100 | + if(!is_null($blocoDTOConsulta->getNumPaginaAtual())){ | |
| 101 | + $relBlocoProtocoloDTOConsulta->setNumPaginaAtual($blocoDTOConsulta->getNumPaginaAtual()); | |
| 102 | + }else{ | |
| 103 | + $relBlocoProtocoloDTOConsulta->setNumPaginaAtual(0); | |
| 104 | + } | |
| 105 | + $result = array(); | |
| 106 | + $relBlocoProtocoloDTOConsulta->setNumIdBloco($blocoDTOConsulta->getNumIdBloco()); | |
| 107 | + $relBlocoProtocoloDTOConsulta->setOrdNumIdBloco(InfraDTO::$TIPO_ORDENACAO_DESC); | |
| 108 | + $relBlocoProtocoloDTOConsulta->retDblIdProtocolo(); | |
| 109 | + $relBlocoProtocoloDTOConsulta->retStrAnotacao(); | |
| 110 | + $arrRelProtocolo = $relBlocoProtocoloRN->listarRN1291($relBlocoProtocoloDTOConsulta); | |
| 111 | + if($arrRelProtocolo){ | |
| 112 | + $anexoRN = new AnexoRN(); | |
| 113 | + $assinaturaRN = new AssinaturaRN(); | |
| 114 | + $protocoloRN = new ProtocoloRN(); | |
| 115 | + /** @var RelBlocoProtocoloDTO $relBlocoProtocoloDTO */ | |
| 116 | + foreach($arrRelProtocolo as $relBlocoProtocoloDTO){ | |
| 117 | + $relProtocoloProtocoloRN = new RelProtocoloProtocoloRN(); | |
| 118 | + $relProtocoloProtocoloDTOConsulta = new RelProtocoloProtocoloDTO(); | |
| 119 | + $relProtocoloProtocoloDTOConsulta->adicionarCriterio( | |
| 120 | + array('IdProtocolo1', 'IdProtocolo2'), | |
| 121 | + array(InfraDTO::$OPER_IGUAL, InfraDTO::$OPER_IGUAL), | |
| 122 | + array($relBlocoProtocoloDTO->getDblIdProtocolo(), $relBlocoProtocoloDTO->getDblIdProtocolo()), | |
| 123 | + InfraDTO::$OPER_LOGICO_OR | |
| 124 | + ); | |
| 125 | + $relProtocoloProtocoloDTOConsulta->retTodos(); | |
| 126 | + $arrProtocoloProtocolo = $relProtocoloProtocoloRN->listarRN0187($relProtocoloProtocoloDTOConsulta); | |
| 127 | + if($arrProtocoloProtocolo){ | |
| 128 | + $arrResultAssinatura = array(); | |
| 129 | + /** @var RelProtocoloProtocoloDTO $relProtocoloProtocoloDTO */ | |
| 130 | + foreach($arrProtocoloProtocolo as $relProtocoloProtocoloDTO){ | |
| 131 | + $protocoloDTO = new ProtocoloDTO(); | |
| 132 | + $protocoloDTO->setDblIdProtocolo($relProtocoloProtocoloDTO->getDblIdProtocolo1()); | |
| 133 | + $protocoloDTO->retTodos(); | |
| 134 | + $protocoloDTO->retStrNomeTipoProcedimentoProcedimento(); | |
| 135 | + $protocoloDTO = $protocoloRN->consultarRN0186($protocoloDTO); | |
| 136 | + $assinaturaDTOConsulta = new AssinaturaDTO(); | |
| 137 | + $assinaturaDTOConsulta->setDblIdProcedimentoDocumento($protocoloDTO->getDblIdProtocolo()); | |
| 138 | + $assinaturaDTOConsulta->setDblIdDocumento($protocoloDTO->getDblIdProtocolo()); | |
| 139 | + $assinaturaDTOConsulta->retStrNome(); | |
| 140 | + $assinaturaDTOConsulta->retStrTratamento(); | |
| 141 | + $arrAssinatura = $assinaturaRN->listarRN1323($assinaturaDTOConsulta); | |
| 142 | + /** @var AssinaturaDTO $assinaturaDTO */ | |
| 143 | + foreach($arrAssinatura as $assinaturaDTO){ | |
| 144 | + $arrResultAssinatura[] = array( | |
| 145 | + 'nome' => $assinaturaDTO->getStrNome(), | |
| 146 | + 'cargo' => $assinaturaDTO->getStrTratamento() | |
| 147 | + ); | |
| 148 | + } | |
| 149 | + $anexoDTOConsulta = new AnexoDTO(); | |
| 150 | + $anexoDTOConsulta->retTodos(); | |
| 151 | + $anexoDTOConsulta->setDblIdProtocolo($protocoloDTO->getDblIdProtocolo()); | |
| 152 | + $anexoDTOConsulta->setStrSinAtivo('S'); | |
| 153 | + $anexoDTOConsulta->setNumMaxRegistrosRetorno(1); | |
| 154 | + $retAnexo = $anexoRN->listarRN0218($anexoDTOConsulta); | |
| 155 | + $mimetype = null; | |
| 156 | + if($retAnexo){ | |
| 157 | + $mimetype = $retAnexo[0]->getStrNome(); | |
| 158 | + $mimetype = substr($mimetype, strrpos($mimetype, '.')+1); | |
| 159 | + } | |
| 160 | + $result[] = array( | |
| 161 | + 'id' => $protocoloDTO->getDblIdProtocolo(), | |
| 162 | + 'atributos' => array( | |
| 163 | + 'idDocumento' => $protocoloDTO->getDblIdProtocolo(), | |
| 164 | + 'mimeType' => ($mimetype)?$mimetype:'html', | |
| 165 | + 'data' => $protocoloDTO->getDtaGeracao(), | |
| 166 | + 'numero' => $protocoloDTO->getStrProtocoloFormatado(), | |
| 167 | + 'numeroProcesso' => $protocoloDTO->getStrProtocoloFormatado(), | |
| 168 | + 'tipo' => $protocoloDTO->getStrNomeTipoProcedimentoProcedimento(), | |
| 169 | + 'assinaturas' => $arrResultAssinatura | |
| 170 | + ), | |
| 171 | + 'anotacao' => $relBlocoProtocoloDTO->getStrAnotacao() | |
| 172 | + ); | |
| 173 | + } | |
| 174 | + } | |
| 175 | + } | |
| 176 | + } | |
| 177 | + | |
| 178 | + return array( | |
| 179 | + 'sucesso' => true, | |
| 180 | + 'data' => $result, | |
| 181 | + 'total' => $relBlocoProtocoloDTOConsulta->getNumTotalRegistros() | |
| 182 | + ); | |
| 183 | + }catch (Exception $e){ | |
| 184 | + return array( | |
| 185 | + 'sucesso' => false, | |
| 186 | + 'mensagem' => $e->getMessage(), | |
| 187 | + 'exception' => $e | |
| 188 | + ); | |
| 189 | + } | |
| 190 | + } | |
| 191 | + | |
| 192 | + /** | |
| 193 | + * Metodo publico que cadastra a anotacao em um bloco | |
| 194 | + * @param array $post | |
| 195 | + * @return array | |
| 196 | + */ | |
| 197 | + public function cadastrarAnotacaoBlocoFromRequest(array $post){ | |
| 198 | + $relBlocoProtocoloDTO = new RelBlocoProtocoloDTO(); | |
| 199 | + if($post['protocolo']){ | |
| 200 | + $relBlocoProtocoloDTO->setDblIdProtocolo($post['protocolo']); | |
| 201 | + } | |
| 202 | + if($post['bloco']){ | |
| 203 | + $relBlocoProtocoloDTO->setNumIdBloco($post['bloco']); | |
| 204 | + } | |
| 205 | + if($post['anotacao']){ | |
| 206 | + $relBlocoProtocoloDTO->setStrAnotacao($post['anotacao']); | |
| 207 | + } | |
| 208 | + | |
| 209 | + return $this->cadastrarAnotacaoBloco($relBlocoProtocoloDTO); | |
| 210 | + } | |
| 211 | + | |
| 212 | + /** | |
| 213 | + * Cadastrar Anotacao documento do Bloco | |
| 214 | + * @param RelBlocoProtocoloDTO $relBlocoProtocoloDTOParam | |
| 215 | + * @return array | |
| 216 | + */ | |
| 217 | + protected function cadastrarAnotacaoBlocoControlado(RelBlocoProtocoloDTO $relBlocoProtocoloDTOParam){ | |
| 218 | + try{ | |
| 219 | + if(!$relBlocoProtocoloDTOParam->isSetNumIdBloco()){ | |
| 220 | + throw new InfraException('O bloco deve ser informado.'); | |
| 221 | + } | |
| 222 | + if(!$relBlocoProtocoloDTOParam->isSetNumIdBloco()){ | |
| 223 | + throw new InfraException('O protocolo deve ser informado.'); | |
| 224 | + } | |
| 225 | + if(!$relBlocoProtocoloDTOParam->isSetStrAnotacao()){ | |
| 226 | + throw new InfraException('A anotacao deve ser informada.'); | |
| 227 | + } | |
| 228 | + $relBlocoProtocoloDTO = new RelBlocoProtocoloDTO(); | |
| 229 | + $relBlocoProtocoloDTO->setNumIdBloco($relBlocoProtocoloDTOParam->getNumIdBloco()); | |
| 230 | + $relBlocoProtocoloDTO->setDblIdProtocolo($relBlocoProtocoloDTOParam->getDblIdProtocolo()); | |
| 231 | + $relBlocoProtocoloDTO->retTodos(); | |
| 232 | + $relBlocoProtocoloRN = new RelBlocoProtocoloRN(); | |
| 233 | + $relBlocoProtocoloDTO = $relBlocoProtocoloRN->consultarRN1290($relBlocoProtocoloDTO); | |
| 234 | + if(!$relBlocoProtocoloDTO){ | |
| 235 | + throw new InfraException('Documento nao encontrado no bloco informado.'); | |
| 236 | + } | |
| 237 | + $relBlocoProtocoloDTO->setStrAnotacao($relBlocoProtocoloDTOParam->getStrAnotacao()); | |
| 238 | + $relBlocoProtocoloRN->alterarRN1288($relBlocoProtocoloDTO); | |
| 239 | + | |
| 240 | + return array( | |
| 241 | + 'sucesso' => true, | |
| 242 | + 'mensagem' => 'Anotação realizada com sucesso.' | |
| 243 | + ); | |
| 244 | + }catch (Exception $e){ | |
| 245 | + return array( | |
| 246 | + 'sucesso' => false, | |
| 247 | + 'mensagem' => $e->getMessage(), | |
| 248 | + 'exception' => $e | |
| 249 | + ); | |
| 250 | + } | |
| 251 | + } | |
| 252 | + | |
| 253 | +} | |
| 0 | 254 | \ No newline at end of file | ... | ... |
| 1 | +++ a/rn/MdWsSeiDocumentoRN.php | |
| ... | ... | @@ -0,0 +1,252 @@ |
| 1 | +<? | |
| 2 | +require_once dirname(__FILE__).'/../../../SEI.php'; | |
| 3 | + | |
| 4 | +class MdWsSeiDocumentoRN extends InfraRN { | |
| 5 | + | |
| 6 | + CONST NOME_ATRIBUTO_ANDAMENTO_DOCUMENTO = 'DOCUMENTO'; | |
| 7 | + | |
| 8 | + protected function inicializarObjInfraIBanco(){ | |
| 9 | + return BancoSEI::getInstance(); | |
| 10 | + } | |
| 11 | + | |
| 12 | + /** | |
| 13 | + * Metodo simplificado (abstraido) de assinatura de documentos | |
| 14 | + * @param array $arrIdDocumento | |
| 15 | + * @param $idOrgao | |
| 16 | + * @param $strCargoFuncao | |
| 17 | + * @param $siglaUsuario | |
| 18 | + * @param $senhaUsuario | |
| 19 | + * @param $idUsuario | |
| 20 | + * @return array | |
| 21 | + */ | |
| 22 | + public function apiAssinarDocumentos(array $arrIdDocumento, $idOrgao, $strCargoFuncao, $siglaUsuario, $senhaUsuario, $idUsuario){ | |
| 23 | + $arrDocumentoDTO = array(); | |
| 24 | + foreach($arrIdDocumento as $dblIdDocumento){ | |
| 25 | + $documentoDTO = new DocumentoDTO(); | |
| 26 | + $documentoDTO->setDblIdDocumento($dblIdDocumento); | |
| 27 | + $arrDocumentoDTO[] = $documentoDTO; | |
| 28 | + } | |
| 29 | + $assinaturaDTO = new AssinaturaDTO(); | |
| 30 | + $assinaturaDTO->setStrSiglaUsuario($siglaUsuario); | |
| 31 | + $assinaturaDTO->setStrSenhaUsuario($senhaUsuario); | |
| 32 | + $assinaturaDTO->setNumIdUsuario($idUsuario); | |
| 33 | + $assinaturaDTO->setNumIdOrgaoUsuario($idOrgao); | |
| 34 | + $assinaturaDTO->setStrCargoFuncao($strCargoFuncao); | |
| 35 | + $assinaturaDTO->setArrObjDocumentoDTO($arrDocumentoDTO); | |
| 36 | + return $this->assinarDocumento($assinaturaDTO); | |
| 37 | + } | |
| 38 | + | |
| 39 | + /** | |
| 40 | + * Metodo simplificado (abstraido) de assinatura de documento | |
| 41 | + * @param array $arrIdDocumento | |
| 42 | + * @param $idOrgao | |
| 43 | + * @param $strCargoFuncao | |
| 44 | + * @param $siglaUsuario | |
| 45 | + * @param $senhaUsuario | |
| 46 | + * @param $idUsuario | |
| 47 | + * @return array | |
| 48 | + */ | |
| 49 | + public function apiAssinarDocumento($idDocumento, $idOrgao, $strCargoFuncao, $siglaUsuario, $senhaUsuario, $idUsuario){ | |
| 50 | + $arrDocumentoDTO = array(); | |
| 51 | + $documentoDTO = new DocumentoDTO(); | |
| 52 | + $documentoDTO->setDblIdDocumento($idDocumento); | |
| 53 | + $arrDocumentoDTO[] = $documentoDTO; | |
| 54 | + $assinaturaDTO = new AssinaturaDTO(); | |
| 55 | + $assinaturaDTO->setStrSiglaUsuario($siglaUsuario); | |
| 56 | + $assinaturaDTO->setStrSenhaUsuario($senhaUsuario); | |
| 57 | + $assinaturaDTO->setNumIdUsuario($idUsuario); | |
| 58 | + $assinaturaDTO->setNumIdOrgaoUsuario($idOrgao); | |
| 59 | + $assinaturaDTO->setStrCargoFuncao($strCargoFuncao); | |
| 60 | + $assinaturaDTO->setArrObjDocumentoDTO($arrDocumentoDTO); | |
| 61 | + return $this->assinarDocumento($assinaturaDTO); | |
| 62 | + } | |
| 63 | + | |
| 64 | + /** | |
| 65 | + * Realizar Assinatura Eletrônica | |
| 66 | + * @param AssinaturaDTO $assinaturaDTO | |
| 67 | + * @return array | |
| 68 | + */ | |
| 69 | + public function assinarDocumentoControlado(AssinaturaDTO $assinaturaDTO){ | |
| 70 | + try{ | |
| 71 | + $assinaturaDTO->setStrStaFormaAutenticacao(AssinaturaRN::$TA_SENHA); | |
| 72 | + $assinaturaDTO->setNumIdContextoUsuario(null); | |
| 73 | + $documentoRN = new DocumentoRN(); | |
| 74 | + $documentoRN->assinarInterno($assinaturaDTO); | |
| 75 | + return array( | |
| 76 | + 'sucesso' => true, | |
| 77 | + 'mensagem' => 'Documento em bloco assinado com sucesso.' | |
| 78 | + ); | |
| 79 | + }catch (Exception $e){ | |
| 80 | + return array( | |
| 81 | + 'sucesso' => false, | |
| 82 | + 'mensagem' => $e->getMessage(), | |
| 83 | + 'exception' => $e | |
| 84 | + ); | |
| 85 | + } | |
| 86 | + } | |
| 87 | + | |
| 88 | + /** | |
| 89 | + * @param DocumentoDTO $documentoDTO | |
| 90 | + * id documento obrigatorio | |
| 91 | + * @return array | |
| 92 | + */ | |
| 93 | + protected function darCienciaControlado(DocumentoDTO $documentoDTO){ | |
| 94 | + try{ | |
| 95 | + $documentoRN = new DocumentoRN(); | |
| 96 | + if(!$documentoDTO->getDblIdDocumento()){ | |
| 97 | + throw new InfraException('O documento não foi informado.'); | |
| 98 | + } | |
| 99 | + $documentoRN->darCiencia($documentoDTO); | |
| 100 | + return array( | |
| 101 | + 'sucesso' => true, | |
| 102 | + 'mensagem' => 'Ciência documento realizado com sucesso.' | |
| 103 | + ); | |
| 104 | + }catch (Exception $e){ | |
| 105 | + return array( | |
| 106 | + 'sucesso' => false, | |
| 107 | + 'mensagem' => $e->getMessage(), | |
| 108 | + 'exception' => $e | |
| 109 | + ); | |
| 110 | + } | |
| 111 | + } | |
| 112 | + | |
| 113 | + protected function downloadAnexoConectado(ProtocoloDTO $protocoloDTO){ | |
| 114 | + try{ | |
| 115 | + if(!$protocoloDTO->isSetDblIdProtocolo() || !$protocoloDTO->getDblIdProtocolo()){ | |
| 116 | + throw new InfraException('O protocolo deve ser informado!'); | |
| 117 | + } | |
| 118 | + $documentoDTO = new DocumentoDTO(); | |
| 119 | + $documentoDTO->setDblIdProtocoloProtocolo($protocoloDTO->getDblIdProtocolo()); | |
| 120 | + $documentoDTO->retStrConteudo(); | |
| 121 | + $documentoDTO->retStrConteudoAssinatura(); | |
| 122 | + $documentoBD = new DocumentoRN(); | |
| 123 | + $resultDocumento = $documentoBD->listarRN0008($documentoDTO); | |
| 124 | + | |
| 125 | + if(!empty($resultDocumento)){ | |
| 126 | + $documento = $resultDocumento[0]; | |
| 127 | + if ($documento->getStrConteudo()) { | |
| 128 | + $html = $documento->getStrConteudo() . $documento->getStrConteudoAssinatura(); | |
| 129 | + return ["html" => $html]; | |
| 130 | + } | |
| 131 | + } | |
| 132 | + | |
| 133 | + $anexoDTO = new AnexoDTO(); | |
| 134 | + $anexoDTO->retNumIdAnexo(); | |
| 135 | + $anexoDTO->retDthInclusao(); | |
| 136 | + $anexoDTO->retDthInclusao(); | |
| 137 | + $anexoDTO->retStrNome(); | |
| 138 | + $anexoDTO->retStrHash(); | |
| 139 | + $anexoDTO->setDblIdProtocolo($protocoloDTO->getDblIdProtocolo()); | |
| 140 | + $anexoDTO->setStrSinAtivo('S'); | |
| 141 | + $anexoRN = new AnexoRN(); | |
| 142 | + $resultAnexo = $anexoRN->listarRN0218($anexoDTO); | |
| 143 | + if(empty($resultAnexo)){ | |
| 144 | + throw new InfraException('Documento não encontrado!'); | |
| 145 | + } | |
| 146 | + $anexo = $resultAnexo[0]; | |
| 147 | + SeiINT::download($anexo); | |
| 148 | + }catch (Exception $e){ | |
| 149 | + return array( | |
| 150 | + 'sucesso' => false, | |
| 151 | + 'mensagem' => $e->getMessage(), | |
| 152 | + 'exception' => $e | |
| 153 | + ); | |
| 154 | + } | |
| 155 | + } | |
| 156 | + | |
| 157 | + /** | |
| 158 | + * Listar Ciencias realizadas em um Documento | |
| 159 | + * @param MdWsSeiProcessoDTO $mdWsSeiProcessoDTOParam | |
| 160 | + * *valor = protocoloformatado? | |
| 161 | + * @return array | |
| 162 | + */ | |
| 163 | + protected function listarCienciaDocumentoConectado(MdWsSeiProcessoDTO $mdWsSeiProcessoDTOParam){ | |
| 164 | + try{ | |
| 165 | + if(!$mdWsSeiProcessoDTOParam->isSetStrValor()){ | |
| 166 | + throw new InfraException('Número do documento não informado.'); | |
| 167 | + } | |
| 168 | + | |
| 169 | + $result = array(); | |
| 170 | + $atributoAndamentoDTOConsulta = new AtributoAndamentoDTO(); | |
| 171 | + $atributoAndamentoDTOConsulta->retTodos(); | |
| 172 | + $atributoAndamentoDTOConsulta->retDthAberturaAtividade(); | |
| 173 | + $atributoAndamentoDTOConsulta->retStrSiglaUsuarioOrigemAtividade(); | |
| 174 | + $atributoAndamentoDTOConsulta->retStrSiglaUnidadeOrigemAtividade(); | |
| 175 | + $atributoAndamentoDTOConsulta->setNumIdTarefaAtividade(TarefaRN::$TI_DOCUMENTO_CIENCIA); | |
| 176 | + $atributoAndamentoDTOConsulta->setStrValor($mdWsSeiProcessoDTOParam->getStrValor()); | |
| 177 | + $atributoAndamentoDTOConsulta->setStrNome(self::NOME_ATRIBUTO_ANDAMENTO_DOCUMENTO); | |
| 178 | + $atributoAndamentoRN = new AtributoAndamentoRN(); | |
| 179 | + $ret = $atributoAndamentoRN->listarRN1367($atributoAndamentoDTOConsulta); | |
| 180 | + $tarefaDTO = new TarefaDTO(); | |
| 181 | + $tarefaDTO->retStrNome(); | |
| 182 | + $tarefaDTO->setNumIdTarefa($atributoAndamentoDTOConsulta->getNumIdTarefaAtividade()); | |
| 183 | + $tarefaRN = new TarefaRN(); | |
| 184 | + $tarefaDTO = $tarefaRN->consultar($tarefaDTO); | |
| 185 | + $mdWsSeiProcessoRN = new MdWsSeiProcessoRN(); | |
| 186 | + /** @var AtributoAndamentoDTO $atributoAndamentoDTO */ | |
| 187 | + foreach($ret as $atributoAndamentoDTO){ | |
| 188 | + $mdWsSeiProcessoDTO = new MdWsSeiProcessoDTO(); | |
| 189 | + $mdWsSeiProcessoDTO->setNumIdAtividade($atributoAndamentoDTO->getNumIdAtividade()); | |
| 190 | + $mdWsSeiProcessoDTO->setStrTemplate($tarefaDTO->getStrNome()); | |
| 191 | + $result[] = array( | |
| 192 | + 'data' => $atributoAndamentoDTO->getDthAberturaAtividade(), | |
| 193 | + 'unidade' => $atributoAndamentoDTO->getStrSiglaUnidadeOrigemAtividade(), | |
| 194 | + 'nome' => $atributoAndamentoDTO->getStrSiglaUsuarioOrigemAtividade(), | |
| 195 | + 'descricao' => $mdWsSeiProcessoRN->traduzirTemplate($mdWsSeiProcessoDTO) | |
| 196 | + ); | |
| 197 | + } | |
| 198 | + | |
| 199 | + return array( | |
| 200 | + 'sucesso' => true, | |
| 201 | + 'data' => $result | |
| 202 | + ); | |
| 203 | + }catch (Exception $e){ | |
| 204 | + return array( | |
| 205 | + 'sucesso' => false, | |
| 206 | + 'mensagem' => $e->getMessage(), | |
| 207 | + 'exception' => $e | |
| 208 | + ); | |
| 209 | + } | |
| 210 | + } | |
| 211 | + | |
| 212 | + /** | |
| 213 | + * Listar assinaturas do documento | |
| 214 | + * @param DocumentoDTO $documentoDTOParam | |
| 215 | + * @return array | |
| 216 | + */ | |
| 217 | + protected function listarAssinaturasDocumentoConectado(DocumentoDTO $documentoDTOParam){ | |
| 218 | + try{ | |
| 219 | + if(!$documentoDTOParam->isSetDblIdDocumento()){ | |
| 220 | + throw new InfraException('O documento não foi informado.'); | |
| 221 | + } | |
| 222 | + | |
| 223 | + $result = array(); | |
| 224 | + $assinaturaDTOConsulta = new AssinaturaDTO(); | |
| 225 | + $assinaturaDTOConsulta->retTodos(); | |
| 226 | + $assinaturaDTOConsulta->retStrSiglaUnidade(); | |
| 227 | + $assinaturaDTOConsulta->setDblIdDocumento($documentoDTOParam->getDblIdDocumento()); | |
| 228 | + $assinaturaRN = new AssinaturaRN(); | |
| 229 | + $ret = $assinaturaRN->listarRN1323($assinaturaDTOConsulta); | |
| 230 | + /** @var AssinaturaDTO $assinaturaDTO */ | |
| 231 | + foreach($ret as $assinaturaDTO){ | |
| 232 | + $result[] = array( | |
| 233 | + 'nome' => $assinaturaDTO->getStrNome(), | |
| 234 | + 'cargo' => $assinaturaDTO->getStrTratamento(), | |
| 235 | + 'unidade' => $assinaturaDTO->getStrSiglaUnidade() | |
| 236 | + ); | |
| 237 | + } | |
| 238 | + | |
| 239 | + return array( | |
| 240 | + 'sucesso' => true, | |
| 241 | + 'data' => $result | |
| 242 | + ); | |
| 243 | + }catch (Exception $e){ | |
| 244 | + return array( | |
| 245 | + 'sucesso' => false, | |
| 246 | + 'mensagem' => $e->getMessage(), | |
| 247 | + 'exception' => $e | |
| 248 | + ); | |
| 249 | + } | |
| 250 | + } | |
| 251 | + | |
| 252 | +} | |
| 0 | 253 | \ No newline at end of file | ... | ... |
| 1 | +++ a/rn/MdWsSeiGrupoAcompanhamentoRN.php | |
| ... | ... | @@ -0,0 +1,55 @@ |
| 1 | +<? | |
| 2 | +require_once dirname(__FILE__).'/../../../SEI.php'; | |
| 3 | + | |
| 4 | +class MdWsSeiGrupoAcompanhamentoRN extends InfraRN { | |
| 5 | + | |
| 6 | + protected function inicializarObjInfraIBanco(){ | |
| 7 | + return BancoSEI::getInstance(); | |
| 8 | + } | |
| 9 | + | |
| 10 | + /** | |
| 11 | + * Retorna todos os grupos de acompanhamento | |
| 12 | + * @param OrgaoDTO $orgaoDTO | |
| 13 | + * @info para paginacao e necessario informar dentro do DTO os parametros abaixo: | |
| 14 | + * - setNumMaxRegistrosRetorno | |
| 15 | + * - setNumPaginaAtual | |
| 16 | + * @return array | |
| 17 | + */ | |
| 18 | + protected function listarGrupoAcompanhamentoConectado(GrupoAcompanhamentoDTO $grupoAcompanhamentoDTO){ | |
| 19 | + try{ | |
| 20 | + $result = array(); | |
| 21 | + $grupoAcompanhamentoRN = new GrupoAcompanhamentoRN(); | |
| 22 | + if(!$grupoAcompanhamentoDTO->isRetNumIdGrupoAcompanhamento()){ | |
| 23 | + $grupoAcompanhamentoDTO->retNumIdGrupoAcompanhamento(); | |
| 24 | + } | |
| 25 | + if(!$grupoAcompanhamentoDTO->isRetStrNome()){ | |
| 26 | + $grupoAcompanhamentoDTO->retStrNome(); | |
| 27 | + } | |
| 28 | + if(!$grupoAcompanhamentoDTO->isSetNumIdUnidade()){ | |
| 29 | + $grupoAcompanhamentoDTO->setNumIdUnidade(SessaoSEI::getInstance()->getNumIdUnidadeAtual()); | |
| 30 | + } | |
| 31 | + $ret = $grupoAcompanhamentoRN->listar($grupoAcompanhamentoDTO); | |
| 32 | + /** @var GrupoAcompanhamentoDTO $grupDTO */ | |
| 33 | + foreach($ret as $grupDTO){ | |
| 34 | + $result[] = array( | |
| 35 | + 'id' => $grupDTO->getNumIdGrupoAcompanhamento(), | |
| 36 | + 'nome' => $grupDTO->getStrNome() | |
| 37 | + ); | |
| 38 | + } | |
| 39 | + | |
| 40 | + | |
| 41 | + return array( | |
| 42 | + 'sucesso' => true, | |
| 43 | + 'data' => $result, | |
| 44 | + 'total' => $grupoAcompanhamentoDTO->getNumTotalRegistros() | |
| 45 | + ); | |
| 46 | + }catch (Exception $e){ | |
| 47 | + return array( | |
| 48 | + 'sucesso' => false, | |
| 49 | + 'mensagem' => $e->getMessage(), | |
| 50 | + 'exception' => $e | |
| 51 | + ); | |
| 52 | + } | |
| 53 | + } | |
| 54 | + | |
| 55 | +} | |
| 0 | 56 | \ No newline at end of file | ... | ... |
| 1 | +++ a/rn/MdWsSeiObservacaoRN.php | |
| ... | ... | @@ -0,0 +1,51 @@ |
| 1 | +<? | |
| 2 | +require_once dirname(__FILE__).'/../../../SEI.php'; | |
| 3 | + | |
| 4 | +class MdWsSeiObservacaoRN extends InfraRN { | |
| 5 | + | |
| 6 | + protected function inicializarObjInfraIBanco(){ | |
| 7 | + return BancoSEI::getInstance(); | |
| 8 | + } | |
| 9 | + | |
| 10 | + public function encapsulaObservacao(array $post){ | |
| 11 | + $observacaoDTO = new ObservacaoDTO(); | |
| 12 | + $observacaoDTO->setStrIdxObservacao(null); | |
| 13 | + if (isset($post['unidade'])) { | |
| 14 | + $observacaoDTO->setNumIdUnidade($post['unidade']); | |
| 15 | + } | |
| 16 | + | |
| 17 | + if (isset($post['descricao'])) { | |
| 18 | + $observacaoDTO->setStrDescricao($post['descricao']); | |
| 19 | + } | |
| 20 | + | |
| 21 | + if (isset($post['protocolo'])) { | |
| 22 | + $observacaoDTO->setDblIdProtocolo($post['protocolo']); | |
| 23 | + } | |
| 24 | + | |
| 25 | + return $observacaoDTO; | |
| 26 | + } | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * Metodo que cria uma observacao | |
| 30 | + * @param ObservacaoDTO $observacaoDTO | |
| 31 | + * @info metodo auxiliar encapsulaObservacao para facilitar encapsulamento | |
| 32 | + * @return array | |
| 33 | + */ | |
| 34 | + protected function criarObservacaoControlado(ObservacaoDTO $observacaoDTO){ | |
| 35 | + try{ | |
| 36 | + $observacaoRN = new ObservacaoRN(); | |
| 37 | + $observacaoRN->cadastrarRN0222($observacaoDTO); | |
| 38 | + | |
| 39 | + return array( | |
| 40 | + 'sucesso' => true, | |
| 41 | + 'mensagem' => 'Observação cadastrada com sucesso!' | |
| 42 | + ); | |
| 43 | + }catch (Exception $e){ | |
| 44 | + return array( | |
| 45 | + 'sucesso' => false, | |
| 46 | + 'mensagem' => $e->getMessage(), | |
| 47 | + 'exception' => $e | |
| 48 | + ); | |
| 49 | + } | |
| 50 | + } | |
| 51 | +} | |
| 0 | 52 | \ No newline at end of file | ... | ... |
| 1 | +++ a/rn/MdWsSeiOrgaoRN.php | |
| ... | ... | @@ -0,0 +1,59 @@ |
| 1 | +<? | |
| 2 | +require_once dirname(__FILE__).'/../../../SEI.php'; | |
| 3 | + | |
| 4 | +class MdWsSeiOrgaoRN extends InfraRN { | |
| 5 | + | |
| 6 | + protected function inicializarObjInfraIBanco(){ | |
| 7 | + return BancoSEI::getInstance(); | |
| 8 | + } | |
| 9 | + | |
| 10 | + /** | |
| 11 | + * Retorna todos os orgaos ativos cadastrados | |
| 12 | + * @param OrgaoDTO $orgaoDTO | |
| 13 | + * @info para páginacao e necessário informar dentro do DTO os parametros abaixo: | |
| 14 | + * - setNumMaxRegistrosRetorno | |
| 15 | + * - setNumPaginaAtual | |
| 16 | + * @return array | |
| 17 | + */ | |
| 18 | + protected function listarOrgaoConectado(OrgaoDTO $orgaoDTO){ | |
| 19 | + try{ | |
| 20 | + $result = array(); | |
| 21 | + $orgaoRN = new OrgaoRN(); | |
| 22 | + if(!$orgaoDTO->isRetNumIdOrgao()){ | |
| 23 | + $orgaoDTO->retNumIdOrgao(); | |
| 24 | + } | |
| 25 | + if(!$orgaoDTO->isRetStrSigla()){ | |
| 26 | + $orgaoDTO->retStrSigla(); | |
| 27 | + } | |
| 28 | + if(!$orgaoDTO->isRetStrDescricao()){ | |
| 29 | + $orgaoDTO->retStrDescricao(); | |
| 30 | + } | |
| 31 | + if(!$orgaoDTO->isSetStrSinAtivo()){ | |
| 32 | + $orgaoDTO->setStrSinAtivo('S'); | |
| 33 | + } | |
| 34 | + $ret = $orgaoRN->listarRN1353($orgaoDTO); | |
| 35 | + /** @var OrgaoDTO $orgDTO */ | |
| 36 | + foreach($ret as $orgDTO){ | |
| 37 | + $result[] = array( | |
| 38 | + 'id' => $orgDTO->getNumIdOrgao(), | |
| 39 | + 'sigla' => $orgDTO->getStrSigla(), | |
| 40 | + 'descricao' => $orgDTO->getStrDescricao() | |
| 41 | + ); | |
| 42 | + } | |
| 43 | + | |
| 44 | + | |
| 45 | + return array( | |
| 46 | + 'sucesso' => true, | |
| 47 | + 'data' => $result, | |
| 48 | + 'total' => $orgaoDTO->getNumTotalRegistros() | |
| 49 | + ); | |
| 50 | + }catch (Exception $e){ | |
| 51 | + return array( | |
| 52 | + 'sucesso' => false, | |
| 53 | + 'mensagem' => $e->getMessage(), | |
| 54 | + 'exception' => $e | |
| 55 | + ); | |
| 56 | + } | |
| 57 | + } | |
| 58 | + | |
| 59 | +} | |
| 0 | 60 | \ No newline at end of file | ... | ... |
| 1 | +++ a/rn/MdWsSeiProcedimentoRN.php | |
| ... | ... | @@ -0,0 +1,447 @@ |
| 1 | +<? | |
| 2 | +require_once dirname(__FILE__).'/../../../SEI.php'; | |
| 3 | + | |
| 4 | +class MdWsSeiProcedimentoRN extends InfraRN { | |
| 5 | + | |
| 6 | + protected function inicializarObjInfraIBanco(){ | |
| 7 | + return BancoSEI::getInstance(); | |
| 8 | + } | |
| 9 | + | |
| 10 | + /** | |
| 11 | + * @param $protocolo | |
| 12 | + * @return array | |
| 13 | + */ | |
| 14 | + protected function removerSobrestamentoProcessoControlado(ProcedimentoDTO $procedimentoDTOParam){ | |
| 15 | + try{ | |
| 16 | + if(!$procedimentoDTOParam->getDblIdProcedimento()){ | |
| 17 | + throw new InfraException('Procedimento não informado.'); | |
| 18 | + } | |
| 19 | + $seiRN = new SeiRN(); | |
| 20 | + $entradaRemoverSobrestamentoProcessoAPI = new EntradaRemoverSobrestamentoProcessoAPI(); | |
| 21 | + $entradaRemoverSobrestamentoProcessoAPI->setIdProcedimento($procedimentoDTOParam->getDblIdProcedimento()); | |
| 22 | + | |
| 23 | + $seiRN->removerSobrestamentoProcesso($entradaRemoverSobrestamentoProcessoAPI); | |
| 24 | + | |
| 25 | + return array( | |
| 26 | + 'sucesso' => true, | |
| 27 | + 'mensagem' => 'Sobrestar cancelado com sucesso.' | |
| 28 | + ); | |
| 29 | + }catch (Exception $e){ | |
| 30 | + return array( | |
| 31 | + 'sucesso' => false, | |
| 32 | + 'mensagem' => $e->getMessage(), | |
| 33 | + 'exception' => $e | |
| 34 | + ); | |
| 35 | + } | |
| 36 | + } | |
| 37 | + | |
| 38 | + protected function listarProcedimentoAcompanhamentoConectado(MdWsSeiProtocoloDTO $mdWsSeiProtocoloDTOConsulta) { | |
| 39 | + try{ | |
| 40 | + $usuarioAtribuicaoAtividade = null; | |
| 41 | + $mdWsSeiProtocoloDTO = new MdWsSeiProtocoloDTO(); | |
| 42 | + if($mdWsSeiProtocoloDTOConsulta->isSetNumIdUsuarioAtribuicaoAtividade()){ | |
| 43 | + $mdWsSeiProtocoloDTO->setNumIdUsuarioAtribuicaoAtividade($mdWsSeiProtocoloDTOConsulta->getNumIdUsuarioAtribuicaoAtividade()); | |
| 44 | + $usuarioAtribuicaoAtividade = $mdWsSeiProtocoloDTOConsulta->getNumIdUsuarioAtribuicaoAtividade(); | |
| 45 | + } | |
| 46 | + if(!$mdWsSeiProtocoloDTOConsulta->isSetNumIdUsuarioGeradorAcompanhamento()){ | |
| 47 | + $mdWsSeiProtocoloDTO->setNumIdUsuarioGeradorAcompanhamento(SessaoSEI::getInstance()->getNumIdUsuario()); | |
| 48 | + }else{ | |
| 49 | + $mdWsSeiProtocoloDTO->setNumIdUsuarioGeradorAcompanhamento($mdWsSeiProtocoloDTOConsulta->getNumIdUsuarioGeradorAcompanhamento()); | |
| 50 | + } | |
| 51 | + | |
| 52 | + if(is_null($mdWsSeiProtocoloDTOConsulta->getNumPaginaAtual())){ | |
| 53 | + $mdWsSeiProtocoloDTO->setNumPaginaAtual(0); | |
| 54 | + }else{ | |
| 55 | + $mdWsSeiProtocoloDTO->setNumPaginaAtual($mdWsSeiProtocoloDTOConsulta->getNumPaginaAtual()); | |
| 56 | + } | |
| 57 | + | |
| 58 | + if(!$mdWsSeiProtocoloDTOConsulta->isSetNumMaxRegistrosRetorno()){ | |
| 59 | + $mdWsSeiProtocoloDTO->setNumMaxRegistrosRetorno(10); | |
| 60 | + }else{ | |
| 61 | + $mdWsSeiProtocoloDTO->setNumMaxRegistrosRetorno($mdWsSeiProtocoloDTOConsulta->getNumMaxRegistrosRetorno()); | |
| 62 | + } | |
| 63 | + $protocoloRN = new ProtocoloRN(); | |
| 64 | + $mdWsSeiProtocoloDTOConsulta->retTodos(); | |
| 65 | + $mdWsSeiProtocoloDTOConsulta->retStrSinCienciaProcedimento(); | |
| 66 | + $mdWsSeiProtocoloDTOConsulta->setOrdDthGeracaoAcompanhamento(InfraDTO::$TIPO_ORDENACAO_ASC); | |
| 67 | + $mdWsSeiProtocoloDTOConsulta->retStrNomeTipoProcedimentoProcedimento(); | |
| 68 | + $ret = $protocoloRN->listarRN0668($mdWsSeiProtocoloDTOConsulta); | |
| 69 | + $result = $this->montaRetornoListagemProcessos($ret, $usuarioAtribuicaoAtividade); | |
| 70 | + return array( | |
| 71 | + 'sucesso' => true, | |
| 72 | + 'data' => $result, | |
| 73 | + 'total' => $mdWsSeiProtocoloDTOConsulta->getNumTotalRegistros() | |
| 74 | + ); | |
| 75 | + }catch (Exception $e){ | |
| 76 | + return array( | |
| 77 | + 'sucesso' => false, | |
| 78 | + 'mensagem' => $e->getMessage(), | |
| 79 | + 'exception' => $e | |
| 80 | + ); | |
| 81 | + } | |
| 82 | + } | |
| 83 | + | |
| 84 | + /** | |
| 85 | + * Metodo que lista os processos | |
| 86 | + * @param MdWsSeiProtocoloDTO $mdWsSeiProtocoloDTO | |
| 87 | + * @return array | |
| 88 | + */ | |
| 89 | + protected function listarProcessosConectado(MdWsSeiProtocoloDTO $mdWsSeiProtocoloDTOConsulta){ | |
| 90 | + try{ | |
| 91 | + $mdWsSeiProtocoloDTO = new MdWsSeiProtocoloDTO(); | |
| 92 | + $mdWsSeiProtocoloDTO->setDthConclusaoAtividade(null); | |
| 93 | + $mdWsSeiProtocoloDTO->retDblIdProtocolo(); | |
| 94 | + $mdWsSeiProtocoloDTO->retTodos(); | |
| 95 | + $mdWsSeiProtocoloDTO->retStrNomeTipoProcedimentoProcedimento(); | |
| 96 | + $mdWsSeiProtocoloDTO->retStrSinCienciaProcedimento(); | |
| 97 | + $mdWsSeiProtocoloDTO->setOrdDthAberturaAtividade(InfraDTO::$TIPO_ORDENACAO_ASC); | |
| 98 | + $usuarioAtribuicaoAtividade = null; | |
| 99 | + if($mdWsSeiProtocoloDTO->isSetNumIdUsuarioAtribuicaoAtividade()){ | |
| 100 | + $usuarioAtribuicaoAtividade = $mdWsSeiProtocoloDTO->getNumIdUsuarioAtribuicaoAtividade(); | |
| 101 | + } | |
| 102 | + | |
| 103 | + if(!$mdWsSeiProtocoloDTOConsulta->isSetNumIdUnidadeAtividade()){ | |
| 104 | + throw new InfraException('É obrigatório informar a unidade.'); | |
| 105 | + } | |
| 106 | + $mdWsSeiProtocoloDTO->setNumIdUnidadeAtividade($mdWsSeiProtocoloDTOConsulta->getNumIdUnidadeAtividade()); | |
| 107 | + | |
| 108 | + if($mdWsSeiProtocoloDTOConsulta->isSetNumIdUsuarioAtribuicaoAtividade()){ | |
| 109 | + $mdWsSeiProtocoloDTO->setNumIdUsuarioAtribuicaoAtividade($mdWsSeiProtocoloDTOConsulta->getNumIdUsuarioAtribuicaoAtividade()); | |
| 110 | + } | |
| 111 | + | |
| 112 | + if(!is_null($mdWsSeiProtocoloDTOConsulta->getNumPaginaAtual())){ | |
| 113 | + $mdWsSeiProtocoloDTO->setNumPaginaAtual($mdWsSeiProtocoloDTOConsulta->getNumPaginaAtual()); | |
| 114 | + }else{ | |
| 115 | + $mdWsSeiProtocoloDTO->setNumPaginaAtual(0); | |
| 116 | + } | |
| 117 | + | |
| 118 | + if($mdWsSeiProtocoloDTOConsulta->isSetNumMaxRegistrosRetorno()){ | |
| 119 | + $mdWsSeiProtocoloDTO->setNumMaxRegistrosRetorno($mdWsSeiProtocoloDTOConsulta->getNumMaxRegistrosRetorno()); | |
| 120 | + }else{ | |
| 121 | + $mdWsSeiProtocoloDTO->setNumMaxRegistrosRetorno(10); | |
| 122 | + } | |
| 123 | + if(!$mdWsSeiProtocoloDTOConsulta->isSetNumIdUsuarioAtribuicaoAtividade()){ | |
| 124 | + $mdWsSeiProtocoloDTOConsulta->setNumIdUsuarioAtribuicaoAtividade(SessaoSEI::getInstance()->getNumIdUsuario()); | |
| 125 | + } | |
| 126 | + | |
| 127 | + if($mdWsSeiProtocoloDTOConsulta->getStrSinTipoBusca() == MdWsSeiProtocoloDTO::SIN_TIPO_BUSCA_M){ | |
| 128 | + $mdWsSeiProtocoloDTO->setNumIdUsuarioAtribuicaoAtividade($mdWsSeiProtocoloDTOConsulta->getNumIdUsuarioAtribuicaoAtividade()); | |
| 129 | + }else if($mdWsSeiProtocoloDTOConsulta->getStrSinTipoBusca() == MdWsSeiProtocoloDTO::SIN_TIPO_BUSCA_G){ | |
| 130 | + $mdWsSeiProtocoloDTO->adicionarCriterio( | |
| 131 | + array('StaEstado', 'SinInicialAtividade'), | |
| 132 | + array(InfraDTO::$OPER_DIFERENTE, InfraDTO::$OPER_IGUAL), | |
| 133 | + array(1, 'S'), | |
| 134 | + InfraDTO::$OPER_LOGICO_AND | |
| 135 | + ); | |
| 136 | + }else{ | |
| 137 | + $mdWsSeiProtocoloDTO->adicionarCriterio( | |
| 138 | + array('StaEstado', 'SinInicialAtividade', 'IdTarefaAtividade'), | |
| 139 | + array(InfraDTO::$OPER_DIFERENTE, InfraDTO::$OPER_IGUAL, InfraDTO::$OPER_DIFERENTE), | |
| 140 | + array(1, 'N', 1), | |
| 141 | + array(InfraDTO::$OPER_LOGICO_AND, InfraDTO::$OPER_LOGICO_AND) | |
| 142 | + ); | |
| 143 | + } | |
| 144 | + | |
| 145 | + $protocoloRN = new ProtocoloRN(); | |
| 146 | + $ret = $protocoloRN->listarRN0668($mdWsSeiProtocoloDTO); | |
| 147 | + $result = $this->montaRetornoListagemProcessos($ret, $usuarioAtribuicaoAtividade); | |
| 148 | + return array( | |
| 149 | + 'sucesso' => true, | |
| 150 | + 'data' => $result, | |
| 151 | + 'total' => $mdWsSeiProtocoloDTO->getNumTotalRegistros() | |
| 152 | + ); | |
| 153 | + }catch (Exception $e){ | |
| 154 | + return array( | |
| 155 | + 'sucesso' => false, | |
| 156 | + 'mensagem' => $e->getMessage(), | |
| 157 | + 'exception' => $e | |
| 158 | + ); | |
| 159 | + } | |
| 160 | + | |
| 161 | + } | |
| 162 | + | |
| 163 | + /** | |
| 164 | + * Metodo que monta o retorno da listagem do processo com base no retorno da consulta | |
| 165 | + * @param array $ret | |
| 166 | + * @param null $usuarioAtribuicaoAtividade | |
| 167 | + * @return array | |
| 168 | + */ | |
| 169 | + private function montaRetornoListagemProcessos(array $ret, $usuarioAtribuicaoAtividade = null){ | |
| 170 | + | |
| 171 | + $result = array(); | |
| 172 | + /** @var MdWsSeiProtocoloDTO $protocoloDTO */ | |
| 173 | + foreach($ret as $protocoloDTO){ | |
| 174 | + $usuarioAtribuido = null; | |
| 175 | + $documentoNovo = 'N'; | |
| 176 | + $documentoPublicado = 'N'; | |
| 177 | + $possuiAnotacao = 'N'; | |
| 178 | + $possuiAnotacaoPrioridade = 'N'; | |
| 179 | + $usuarioVisualizacao = 'N'; | |
| 180 | + $tipoVisualizacao = 'N'; | |
| 181 | + $retornoProgramado = 'N'; | |
| 182 | + $retornoAtrasado = 'N'; | |
| 183 | + | |
| 184 | + $atividadeRN = new AtividadeRN(); | |
| 185 | + $atividadeDTOConsulta = new AtividadeDTO(); | |
| 186 | + $atividadeDTOConsulta->setDblIdProtocolo($protocoloDTO->getDblIdProtocolo()); | |
| 187 | + $atividadeDTOConsulta->retTodos(true); | |
| 188 | + $atividadeDTOConsulta->setOrdNumIdAtividade(InfraDTO::$TIPO_ORDENACAO_DESC); | |
| 189 | + $arrAtividades = $atividadeRN->listarRN0036($atividadeDTOConsulta); | |
| 190 | + if($arrAtividades){ | |
| 191 | + /** @var AtividadeDTO $atividadeDTO */ | |
| 192 | + $atividadeDTO = $arrAtividades[0]; | |
| 193 | + $documentoNovo = $atividadeDTO->getNumIdTarefa() == 1 ? 'S' : 'N'; | |
| 194 | + $usuarioAtribuido = $atividadeDTO->getStrNomeUsuarioAtribuicao(); | |
| 195 | + $dadosRetornoProgramado = $this->checaRetornoProgramado($atividadeDTO); | |
| 196 | + $retornoProgramado = $dadosRetornoProgramado['retornoProgramado']; | |
| 197 | + $retornoAtrasado = $dadosRetornoProgramado['expirado']; | |
| 198 | + $tipoVisualizacao = $atividadeDTO->getNumTipoVisualizacao() == 0 ? 'S' : 'N'; | |
| 199 | + if($atividadeDTO->getNumIdUsuarioVisualizacao() == $usuarioAtribuicaoAtividade){ | |
| 200 | + $usuarioVisualizacao = 'S'; | |
| 201 | + } | |
| 202 | + } | |
| 203 | + $documentoRN = new DocumentoRN(); | |
| 204 | + $documentoDTOConsulta = new DocumentoDTO(); | |
| 205 | + $documentoDTOConsulta->setDblIdProcedimento($protocoloDTO->getDblIdProtocolo()); | |
| 206 | + $documentoDTOConsulta->retDblIdDocumento(); | |
| 207 | + $arrDocumentos = $documentoRN->listarRN0008($documentoDTOConsulta); | |
| 208 | + if($arrDocumentos){ | |
| 209 | + $arrIdDocumentos = array(); | |
| 210 | + /** @var DocumentoDTO $documentoDTO */ | |
| 211 | + foreach($arrDocumentos as $documentoDTO){ | |
| 212 | + $arrIdDocumentos[] = $documentoDTO->getDblIdDocumento(); | |
| 213 | + } | |
| 214 | + $publiacaoRN = new PublicacaoRN(); | |
| 215 | + $publicacaoDTO = new PublicacaoDTO(); | |
| 216 | + $publicacaoDTO->retNumIdPublicacao(); | |
| 217 | + $publicacaoDTO->setNumMaxRegistrosRetorno(1); | |
| 218 | + $publicacaoDTO->adicionarCriterio( | |
| 219 | + array('IdDocumento'), | |
| 220 | + array(InfraDTO::$OPER_IN), | |
| 221 | + array($arrIdDocumentos) | |
| 222 | + ); | |
| 223 | + $arrPublicacaoDTO = $publiacaoRN->listarRN1045($publicacaoDTO); | |
| 224 | + $documentoPublicado = count($arrPublicacaoDTO) ? 'S' : 'N'; | |
| 225 | + } | |
| 226 | + | |
| 227 | + $anotacaoRN = new AnotacaoRN(); | |
| 228 | + $anotacaoDTO = new AnotacaoDTO(); | |
| 229 | + $anotacaoDTO->setNumMaxRegistrosRetorno(1); | |
| 230 | + $anotacaoDTO->retNumIdAnotacao(); | |
| 231 | + $anotacaoDTO->setDblIdProtocolo($protocoloDTO->getDblIdProtocolo()); | |
| 232 | + $arrAnotacao = $anotacaoRN->listar($anotacaoDTO); | |
| 233 | + $possuiAnotacao = count($arrAnotacao) ? 'S' : 'N'; | |
| 234 | + $anotacaoDTO->setStrSinPrioridade('S'); | |
| 235 | + $arrAnotacaoPrioridade = $anotacaoRN->listar($anotacaoDTO); | |
| 236 | + $possuiAnotacaoPrioridade = count($arrAnotacaoPrioridade) ? 'S' : 'N'; | |
| 237 | + | |
| 238 | + $result[] = array( | |
| 239 | + 'id' => $protocoloDTO->getDblIdProtocolo(), | |
| 240 | + 'status' => $protocoloDTO->getStrStaProtocolo(), | |
| 241 | + 'atributos' => array( | |
| 242 | + 'idProcedimento' => $protocoloDTO->getDblIdProtocolo(), | |
| 243 | + 'idProtocolo' => $protocoloDTO->getDblIdProtocolo(), | |
| 244 | + 'numero' => $protocoloDTO->getStrProtocoloFormatado(), | |
| 245 | + 'tipoProcesso' => $protocoloDTO->getStrNomeTipoProcedimentoProcedimento(), | |
| 246 | + 'descricao' => $protocoloDTO->getStrDescricao(), | |
| 247 | + 'usuarioAtribuido' => $usuarioAtribuido, | |
| 248 | + 'status' => array( | |
| 249 | + 'documentoSigiloso' => $protocoloDTO->getStrStaGrauSigilo(), | |
| 250 | + 'documentoRestrito' => $protocoloDTO->getStrStaNivelAcessoLocal() == 1 ? 'S' : 'N', | |
| 251 | + 'documentoNovo' => $documentoNovo, | |
| 252 | + 'documentoPublicado' => $documentoPublicado, | |
| 253 | + 'anotacao' => $possuiAnotacao, | |
| 254 | + 'anotacaoPrioridade' => $possuiAnotacaoPrioridade, | |
| 255 | + 'ciencia' => $protocoloDTO->getStrSinCienciaProcedimento(), | |
| 256 | + 'retornoProgramado' => $retornoProgramado, | |
| 257 | + 'retornoAtrasado' => $retornoAtrasado, | |
| 258 | + 'processoAcessadoUsuario' => $tipoVisualizacao, | |
| 259 | + // foi invertido o processoAcessadoUsuario e processoAcessadoUnidade, | |
| 260 | + // pois em todos os outros metodos e igual e somente neste era diferente... | |
| 261 | + 'processoAcessadoUnidade' => $usuarioVisualizacao, | |
| 262 | + ) | |
| 263 | + ) | |
| 264 | + ); | |
| 265 | + } | |
| 266 | + | |
| 267 | + return $result; | |
| 268 | + } | |
| 269 | + | |
| 270 | + private function checaRetornoProgramado($atividade){ | |
| 271 | + $retProgramado = 'N'; | |
| 272 | + $expirado = 'N'; | |
| 273 | + | |
| 274 | + if ($atividade instanceof AtividadeDTO) { | |
| 275 | + $retornoProgramadoRN = new RetornoProgramadoRN(); | |
| 276 | + $retornoProgramadoDTO = new RetornoProgramadoDTO(); | |
| 277 | + $retornoProgramadoDTO->adicionarCriterio( | |
| 278 | + array('IdAtividadeEnvio', 'IdAtividadeRetorno'), | |
| 279 | + array(InfraDTO::$OPER_IGUAL, InfraDTO::$OPER_IGUAL), | |
| 280 | + array($atividade->getNumIdAtividade(), null) | |
| 281 | + ); | |
| 282 | + $retornoProgramadoDTO = $retornoProgramadoRN->consultar($retornoProgramadoDTO); | |
| 283 | + | |
| 284 | + if ($retornoProgramadoDTO) { | |
| 285 | + echo 556; | |
| 286 | + $expirado = ($retornoProgramadoDTO->getDtaProgramada() < new Datetime()); | |
| 287 | + $retProgramado = 'S'; | |
| 288 | + } | |
| 289 | + } | |
| 290 | + | |
| 291 | + return ['retornoProgramado' => $retProgramado, 'expirado' => $expirado]; | |
| 292 | + } | |
| 293 | + | |
| 294 | + | |
| 295 | + /** | |
| 296 | + * Metodo que da ciencia ao processo/procedimento | |
| 297 | + * @param ProcedimentoDTO $procedimentoDTO | |
| 298 | + * @info E obrigatorio informar o id do procedimento | |
| 299 | + * @return array | |
| 300 | + */ | |
| 301 | + protected function darCienciaControlado(ProcedimentoDTO $procedimentoDTO){ | |
| 302 | + try{ | |
| 303 | + if(!$procedimentoDTO->isSetDblIdProcedimento()){ | |
| 304 | + throw new InfraException('E obrigatorio informar o procedimento!'); | |
| 305 | + } | |
| 306 | + | |
| 307 | + $procedimentoRN = new ProcedimentoRN(); | |
| 308 | + $procedimentoRN->darCiencia($procedimentoDTO); | |
| 309 | + | |
| 310 | + return array( | |
| 311 | + 'sucesso' => true, | |
| 312 | + 'mensagem' => 'Ciência processo realizado com sucesso!' | |
| 313 | + ); | |
| 314 | + }catch (Exception $e){ | |
| 315 | + return array( | |
| 316 | + 'sucesso' => false, | |
| 317 | + 'mensagem' => $e->getMessage(), | |
| 318 | + 'exception' => $e | |
| 319 | + ); | |
| 320 | + } | |
| 321 | + } | |
| 322 | + | |
| 323 | + /** | |
| 324 | + * Metodo que conclui o procedimento/processo | |
| 325 | + * @param EntradaConcluirProcessoAPI $entradaConcluirProcessoAPI | |
| 326 | + * @info ele recebe o número do ProtocoloProcedimentoFormatadoPesquisa da tabela protocolo | |
| 327 | + * @return array | |
| 328 | + */ | |
| 329 | + protected function concluirProcessoControlado(EntradaConcluirProcessoAPI $entradaConcluirProcessoAPI){ | |
| 330 | + try{ | |
| 331 | + if(!$entradaConcluirProcessoAPI->getProtocoloProcedimento()){ | |
| 332 | + throw new InfraException('E obrigtorio informar o protocolo do procedimento!'); | |
| 333 | + } | |
| 334 | + | |
| 335 | + $objSeiRN = new SeiRN(); | |
| 336 | + $objSeiRN->concluirProcesso($entradaConcluirProcessoAPI); | |
| 337 | + | |
| 338 | + return array( | |
| 339 | + 'sucesso' => true, | |
| 340 | + 'mensagem' => 'Processo concluído com sucesso!' | |
| 341 | + ); | |
| 342 | + }catch (Exception $e){ | |
| 343 | + return array( | |
| 344 | + 'sucesso' => false, | |
| 345 | + 'mensagem' => $e->getMessage(), | |
| 346 | + 'exception' => $e | |
| 347 | + ); | |
| 348 | + } | |
| 349 | + } | |
| 350 | + | |
| 351 | + /** | |
| 352 | + * Metodo que atribui o processo a uma pessoa | |
| 353 | + * @param EntradaAtribuirProcessoAPI $entradaAtribuirProcessoAPI | |
| 354 | + * @info Os parametros IdUsuario, ProtocoloProcedimento e SinReabrir sao obrigatorios. O parametro ProtocoloProcedimento | |
| 355 | + * recebe o número do ProtocoloProcedimentoFormatadoPesquisa da tabela protocolo | |
| 356 | + * @return array | |
| 357 | + */ | |
| 358 | + protected function atribuirProcessoControlado(EntradaAtribuirProcessoAPI $entradaAtribuirProcessoAPI){ | |
| 359 | + try{ | |
| 360 | + if(!$entradaAtribuirProcessoAPI->getProtocoloProcedimento()){ | |
| 361 | + throw new InfraException('E obrigatorio informar o protocolo do processo!'); | |
| 362 | + } | |
| 363 | + if(!$entradaAtribuirProcessoAPI->getIdUsuario()){ | |
| 364 | + throw new InfraException('E obrigatorio informar o usuário do processo!'); | |
| 365 | + } | |
| 366 | + | |
| 367 | + $objSeiRN = new SeiRN(); | |
| 368 | + $objSeiRN->atribuirProcesso($entradaAtribuirProcessoAPI); | |
| 369 | + | |
| 370 | + return array( | |
| 371 | + 'sucesso' => true, | |
| 372 | + 'mensagem' => 'Processo atribuído com sucesso!' | |
| 373 | + ); | |
| 374 | + }catch (Exception $e){ | |
| 375 | + return array( | |
| 376 | + 'sucesso' => false, | |
| 377 | + 'mensagem' => 'Nao foi possível atribuir o processo!', | |
| 378 | + 'exception' => $e | |
| 379 | + ); | |
| 380 | + } | |
| 381 | + } | |
| 382 | + | |
| 383 | + /** | |
| 384 | + * Encapsula o objeto ENtradaEnviarProcessoAPI para o metodo enviarProcesso | |
| 385 | + * @param array $post | |
| 386 | + * @return EntradaEnviarProcessoAPI | |
| 387 | + */ | |
| 388 | + public function encapsulaEnviarProcessoEntradaEnviarProcessoAPI(array $post){ | |
| 389 | + $entradaEnviarProcessoAPI = new EntradaEnviarProcessoAPI(); | |
| 390 | + if(isset($post['numeroProcesso'])){ | |
| 391 | + $entradaEnviarProcessoAPI->setProtocoloProcedimento($post['numeroProcesso']); | |
| 392 | + } | |
| 393 | + if(isset($post['unidadeDestino'])){ | |
| 394 | + $entradaEnviarProcessoAPI->setUnidadesDestino($post['unidadeDestino']); | |
| 395 | + } | |
| 396 | + if(isset($post['sinManterAbertoUnidade'])){ | |
| 397 | + $entradaEnviarProcessoAPI->setSinManterAbertoUnidade($post['sinManterAbertoUnidade']); | |
| 398 | + } | |
| 399 | + if(isset($post['sinRemoverAnotacao'])){ | |
| 400 | + $entradaEnviarProcessoAPI->setSinRemoverAnotacao($post['sinRemoverAnotacao']); | |
| 401 | + } | |
| 402 | + if(isset($post['sinEnviarEmailNotificacao'])){ | |
| 403 | + $entradaEnviarProcessoAPI->setSinEnviarEmailNotificacao($post['sinEnviarEmailNotificacao']); | |
| 404 | + } | |
| 405 | + if(isset($post['dataRetornoProgramado'])){ | |
| 406 | + $entradaEnviarProcessoAPI->setDataRetornoProgramado($post['dataRetornoProgramado']); | |
| 407 | + } | |
| 408 | + if(isset($post['diasRetornoProgramado'])){ | |
| 409 | + $entradaEnviarProcessoAPI->setDiasRetornoProgramado($post['diasRetornoProgramado']); | |
| 410 | + } | |
| 411 | + if(isset($post['sinDiasUteisRetornoProgramado'])){ | |
| 412 | + $entradaEnviarProcessoAPI->setSinDiasUteisRetornoProgramado($post['sinDiasUteisRetornoProgramado']); | |
| 413 | + } | |
| 414 | + if(isset($post['sinReabrir'])){ | |
| 415 | + $entradaEnviarProcessoAPI->setSinReabrir($post['sinReabrir']); | |
| 416 | + } | |
| 417 | + | |
| 418 | + return $entradaEnviarProcessoAPI; | |
| 419 | + } | |
| 420 | + | |
| 421 | + /** | |
| 422 | + * Metodo que envia o processo para outra unidade | |
| 423 | + * @param EntradaEnviarProcessoAPI $entradaEnviarProcessoAPI | |
| 424 | + * @info Metodo auxiliar para encapsular dados encapsulaEnviarProcessoEntradaEnviarProcessoAPI | |
| 425 | + * @return array | |
| 426 | + */ | |
| 427 | + protected function enviarProcessoControlado(EntradaEnviarProcessoAPI $entradaEnviarProcessoAPI){ | |
| 428 | + try{ | |
| 429 | + $objSeiRN = new SeiRN(); | |
| 430 | + $objSeiRN->enviarProcesso($entradaEnviarProcessoAPI); | |
| 431 | + | |
| 432 | + return array( | |
| 433 | + 'sucesso' => true, | |
| 434 | + 'mensagem' => 'Processo enviado com sucesso!' | |
| 435 | + ); | |
| 436 | + }catch (Exception $e){ | |
| 437 | + return array( | |
| 438 | + 'sucesso' => false, | |
| 439 | + 'mensagem' => 'Nao foi possível enviar o processo!', | |
| 440 | + 'exception' => $e | |
| 441 | + ); | |
| 442 | + } | |
| 443 | + } | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | +} | |
| 0 | 448 | \ No newline at end of file | ... | ... |
| 1 | +++ a/rn/MdWsSeiProcessoRN.php | |
| ... | ... | @@ -0,0 +1,57 @@ |
| 1 | +<? | |
| 2 | +require_once dirname(__FILE__).'/../../../SEI.php'; | |
| 3 | + | |
| 4 | +class MdWsSeiProcessoRN extends InfraRN { | |
| 5 | + | |
| 6 | + protected function inicializarObjInfraIBanco(){ | |
| 7 | + return BancoSEI::getInstance(); | |
| 8 | + } | |
| 9 | + | |
| 10 | + /** | |
| 11 | + * Metodo que traduz o template pelo id da atividade e a string do template | |
| 12 | + * @param MdWsSeiProcessoDTO $mdWsSeiProcessoDTO | |
| 13 | + * @return string | |
| 14 | + */ | |
| 15 | + protected function traduzirTemplateConectado(MdWsSeiProcessoDTO $mdWsSeiProcessoDTO){ | |
| 16 | + $strTemplate = $mdWsSeiProcessoDTO->getStrTemplate(); | |
| 17 | + if ($strTemplate) { | |
| 18 | + $atributoAndamentoRN = new AtributoAndamentoRN(); | |
| 19 | + $atributoAndamentoDTOConsulta = new AtributoAndamentoDTO(); | |
| 20 | + $atributoAndamentoDTOConsulta->retTodos(); | |
| 21 | + $atributoAndamentoDTOConsulta->setNumIdAtividade($mdWsSeiProcessoDTO->getNumIdAtividade()); | |
| 22 | + $ret = $atributoAndamentoRN->listarRN1367($atributoAndamentoDTOConsulta); | |
| 23 | + $atividadeDTO = new AtividadeDTO(); | |
| 24 | + $atividadeDTO->setNumIdAtividade($mdWsSeiProcessoDTO->getNumIdAtividade()); | |
| 25 | + $atividadeDTO->retDblIdProtocolo(); | |
| 26 | + $atividadeRN = new AtividadeRN(); | |
| 27 | + $atividadeDTO = $atividadeRN->consultarRN0033($atividadeDTO); | |
| 28 | + $protocoloDTO = new ProtocoloDTO(); | |
| 29 | + $protocoloDTO->retStrStaGrauSigilo(); | |
| 30 | + $protocoloDTO->setDblIdProtocolo($atividadeDTO->getDblIdProtocolo()); | |
| 31 | + $protocoloRN = new ProtocoloRN(); | |
| 32 | + $protocoloDTO = $protocoloRN->consultarRN0186($protocoloDTO); | |
| 33 | + | |
| 34 | + if ($ret) { | |
| 35 | + /** @var AtributoAndamentoDTO $atributoAndamentoDTO */ | |
| 36 | + foreach($ret as $atributoAndamentoDTO) { | |
| 37 | + $valor = $atributoAndamentoDTO->getStrValor(); | |
| 38 | + | |
| 39 | + if (strripos($valor, '¥')) { | |
| 40 | + $valor = explode('¥', $atributoAndamentoDTO->getStrValor()); | |
| 41 | + $valor = $valor[0]; | |
| 42 | + } | |
| 43 | + | |
| 44 | + $strTemplate = str_replace('@' . $atributoAndamentoDTO->getStrNome() . '@', $valor, $strTemplate); | |
| 45 | + | |
| 46 | + $sigilo = ($protocoloDTO->getStrStaGrauSigilo())? 'sigiloso': 'nao sigiloso'; | |
| 47 | + | |
| 48 | + $strTemplate = str_replace('@GRAU_SIGILO@', $sigilo, $strTemplate); | |
| 49 | + $strTemplate = str_replace('@HIPOTESE_LEGAL@', '', $strTemplate); | |
| 50 | + } | |
| 51 | + } | |
| 52 | + } | |
| 53 | + | |
| 54 | + return $strTemplate; | |
| 55 | + } | |
| 56 | + | |
| 57 | +} | |
| 0 | 58 | \ No newline at end of file | ... | ... |
| 1 | +++ a/rn/MdWsSeiRetornoProgramadoRN.php | |
| ... | ... | @@ -0,0 +1,56 @@ |
| 1 | +<? | |
| 2 | +require_once dirname(__FILE__).'/../../../SEI.php'; | |
| 3 | + | |
| 4 | +class MdWsSeiRetornoProgramadoRN extends InfraRN { | |
| 5 | + | |
| 6 | + protected function inicializarObjInfraIBanco(){ | |
| 7 | + return BancoSEI::getInstance(); | |
| 8 | + } | |
| 9 | + | |
| 10 | + public function encapsulaRetornoProgramado(array $post){ | |
| 11 | + $retornoProgramadoDTO = new RetornoProgramadoDTO(); | |
| 12 | + $retornoProgramadoDTO->setNumIdRetornoProgramado(null); | |
| 13 | + $retornoProgramadoDTO->setDthAlteracao(null); | |
| 14 | + if (isset($post['usuario'])) { | |
| 15 | + $retornoProgramadoDTO->setNumIdUsuario($post['usuario']); | |
| 16 | + } | |
| 17 | + | |
| 18 | + if (isset($post['atividadeEnvio'])) { | |
| 19 | + $retornoProgramadoDTO->setNumIdAtividadeEnvio($post['atividadeEnvio']); | |
| 20 | + } | |
| 21 | + | |
| 22 | + if (isset($post['unidade'])) { | |
| 23 | + $retornoProgramadoDTO->setNumIdUnidade($post['unidade']); | |
| 24 | + } | |
| 25 | + | |
| 26 | + if (isset($post['dtProgramada'])) { | |
| 27 | + $retornoProgramadoDTO->setDtaProgramada($post['dtProgramada']); | |
| 28 | + } | |
| 29 | + | |
| 30 | + return $retornoProgramadoDTO; | |
| 31 | + } | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * Metodo que agenda um retorno programado | |
| 35 | + * @param RetornoProgramadoDTO $retornoProgramadoDTO | |
| 36 | + * @info metodo auxiliar encapsulaRetornoProgramado para facilitar encapsulamento | |
| 37 | + * @return array | |
| 38 | + */ | |
| 39 | + protected function agendarRetornoProgramadoControlado(RetornoProgramadoDTO $retornoProgramadoDTO){ | |
| 40 | + try{ | |
| 41 | + $retornoProgramadoRN = new RetornoProgramadoRN(); | |
| 42 | + $retornoProgramadoRN->cadastrar($retornoProgramadoDTO); | |
| 43 | + | |
| 44 | + return array( | |
| 45 | + 'sucesso' => true, | |
| 46 | + 'mensagem' => 'Retorno Programado agendado com sucesso!' | |
| 47 | + ); | |
| 48 | + }catch (Exception $e){ | |
| 49 | + return array( | |
| 50 | + 'sucesso' => false, | |
| 51 | + 'mensagem' => $e->getMessage(), | |
| 52 | + 'exception' => $e | |
| 53 | + ); | |
| 54 | + } | |
| 55 | + } | |
| 56 | +} | |
| 0 | 57 | \ No newline at end of file | ... | ... |
| 1 | +++ a/rn/MdWsSeiUnidadeRN.php | |
| ... | ... | @@ -0,0 +1,43 @@ |
| 1 | +<? | |
| 2 | +require_once dirname(__FILE__).'/../../../SEI.php'; | |
| 3 | + | |
| 4 | +class MdWsSeiUnidadeRN extends InfraRN { | |
| 5 | + | |
| 6 | + protected function inicializarObjInfraIBanco(){ | |
| 7 | + return BancoSEI::getInstance(); | |
| 8 | + } | |
| 9 | + | |
| 10 | + /** | |
| 11 | + * Retorna todas as unidades cadastradas | |
| 12 | + */ | |
| 13 | + protected function listarUnidadesConectado(){ | |
| 14 | + try{ | |
| 15 | + $unidadeRN = new UnidadeRN(); | |
| 16 | + $unidadeDTO = new UnidadeDTO(); | |
| 17 | + $unidadeDTO->retNumIdUnidade(); | |
| 18 | + $unidadeDTO->retStrSigla(); | |
| 19 | + $unidadeDTO->retStrDescricao(); | |
| 20 | + $ret = $unidadeRN->listarRN0127($unidadeDTO); | |
| 21 | + $result = array(); | |
| 22 | + /** @var UnidadeDTO $unDTO */ | |
| 23 | + foreach($ret as $unDTO){ | |
| 24 | + $result[] = array( | |
| 25 | + 'id' => $unDTO->getNumIdUnidade(), | |
| 26 | + 'sigla' => $unDTO->getStrSigla(), | |
| 27 | + 'descricao' => $unDTO->getStrDescricao() | |
| 28 | + ); | |
| 29 | + } | |
| 30 | + return array( | |
| 31 | + 'sucesso' => true, | |
| 32 | + 'data' => $result | |
| 33 | + ); | |
| 34 | + }catch (Exception $e){ | |
| 35 | + return array( | |
| 36 | + 'sucesso' => false, | |
| 37 | + 'mensagem' => $e->getMessage(), | |
| 38 | + 'exception' => $e | |
| 39 | + ); | |
| 40 | + } | |
| 41 | + } | |
| 42 | + | |
| 43 | +} | |
| 0 | 44 | \ No newline at end of file | ... | ... |
| 1 | +++ a/rn/MdWsSeiUsuarioRN.php | |
| ... | ... | @@ -0,0 +1,215 @@ |
| 1 | +<? | |
| 2 | +require_once dirname(__FILE__).'/../../../SEI.php'; | |
| 3 | + | |
| 4 | +class MdWsSeiUsuarioRN extends InfraRN { | |
| 5 | + | |
| 6 | + CONST TOKEN_SECRET = '<!RWR1YXJkbyBSb23Do28!>'; | |
| 7 | + | |
| 8 | + protected function inicializarObjInfraIBanco(){ | |
| 9 | + return BancoSEI::getInstance(); | |
| 10 | + } | |
| 11 | + | |
| 12 | + /** | |
| 13 | + * Método que retorna o serviço SOAP do SIP | |
| 14 | + * @return SoapClient | |
| 15 | + * @throws InfraException | |
| 16 | + */ | |
| 17 | + private function retornaServicoSip(){ | |
| 18 | + $strWSDL = ConfiguracaoSEI::getInstance()->getValor('SessaoSEI', 'SipWsdl'); | |
| 19 | + try{ | |
| 20 | + if (!InfraUtil::isBolUrlValida($strWSDL)){ | |
| 21 | + if(!@file_get_contents($strWSDL)) { | |
| 22 | + throw new InfraException('Arquivo WSDL '.$strWSDL.' n?o encontrado.'); | |
| 23 | + } | |
| 24 | + } | |
| 25 | + }catch(Exception $e){ | |
| 26 | + throw new InfraException('Falha na conexção com o Sistema de Permissões.',$e); | |
| 27 | + } | |
| 28 | + | |
| 29 | + try{ | |
| 30 | + $objSipWS = new SoapClient($strWSDL, array('encoding'=>'ISO-8859-1')); | |
| 31 | + return $objSipWS; | |
| 32 | + }catch(Exception $e){ | |
| 33 | + throw new InfraException('Erro acessando o Sistema de Permissões.'); | |
| 34 | + } | |
| 35 | + } | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * Método que descriptografa o token | |
| 39 | + * @param $token | |
| 40 | + * @return string | |
| 41 | + */ | |
| 42 | + public function tokenDecode($token){ | |
| 43 | + $fase1 = base64_decode($token); | |
| 44 | + $fase2 = str_replace($this->getSecret(), '', $fase1); | |
| 45 | + $fase3 = base64_decode($fase2); | |
| 46 | + $tokenData = explode('||', $fase3); | |
| 47 | + if(count($tokenData) != 2){ | |
| 48 | + return null; | |
| 49 | + } | |
| 50 | + $tokenData[0] = $this->decriptaSenha($tokenData[0]); | |
| 51 | + $tokenData[1] = $this->decriptaSenha($tokenData[1]); | |
| 52 | + | |
| 53 | + return $tokenData; | |
| 54 | + } | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * Método que criptografa o token | |
| 58 | + * @param $sigla | |
| 59 | + * @param $senha | |
| 60 | + * @return string | |
| 61 | + */ | |
| 62 | + public function tokenEncode($sigla, $senha){ | |
| 63 | + $token = base64_encode($this->getSecret().base64_encode($this->encriptaSenha($sigla).'||'.$this->encriptaSenha($senha))); | |
| 64 | + | |
| 65 | + return $token; | |
| 66 | + } | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * Retorna a chave da criptografia | |
| 70 | + * @return string | |
| 71 | + */ | |
| 72 | + private function getSecret(){ | |
| 73 | + $data = new DateTime(); | |
| 74 | + $strData = $data->format('Ymd'); | |
| 75 | + $secret = sha1(self::TOKEN_SECRET.$strData); | |
| 76 | + return $secret; | |
| 77 | + } | |
| 78 | + | |
| 79 | + /** | |
| 80 | + * Go horse para autenticar usuário... Não ha como instanciar o SessaoSEI por metodos convencionais. | |
| 81 | + * @param stdClass $loginData | |
| 82 | + */ | |
| 83 | + private function setaVariaveisAutenticacao(stdClass $loginData){ | |
| 84 | + $_GET['id_login'] = $loginData->id_login; | |
| 85 | + $_GET['id_sistema'] = $loginData->id_sistema; | |
| 86 | + $_GET['id_usuario'] = $loginData->id_usuario; | |
| 87 | + $_GET['hash_agente'] = SessaoSEI::gerarHashAgente(); | |
| 88 | + $_GET['infra_sip'] = true; | |
| 89 | + $_GET['id_contexto'] = ''; | |
| 90 | + } | |
| 91 | + | |
| 92 | + /** | |
| 93 | + * Método que autentica o usuário pelo token | |
| 94 | + * @param $token | |
| 95 | + * @return bool | |
| 96 | + * @throws InfraException | |
| 97 | + */ | |
| 98 | + public function autenticarToken($token){ | |
| 99 | + try{ | |
| 100 | + | |
| 101 | + $tokenData = $this->tokenDecode($token); | |
| 102 | + if(!$tokenData){ | |
| 103 | + throw new InfraException('Token inválido!'); | |
| 104 | + } | |
| 105 | + | |
| 106 | + $usuarioDTO = new UsuarioDTO(); | |
| 107 | + $usuarioDTO->setStrSigla($tokenData[0]); | |
| 108 | + $usuarioDTO->setStrSenha($tokenData[1]); | |
| 109 | + $result = $this->autenticar($usuarioDTO); | |
| 110 | + if(!$result['sucesso']){ | |
| 111 | + return $result; | |
| 112 | + } | |
| 113 | + $this->setaVariaveisAutenticacao($result['data']); | |
| 114 | + | |
| 115 | + return $result; | |
| 116 | + }catch (Exception $e){ | |
| 117 | + return array( | |
| 118 | + 'sucesso' => false, | |
| 119 | + 'mensagem' => $e->getMessage(), | |
| 120 | + 'exception' => $e | |
| 121 | + ); | |
| 122 | + } | |
| 123 | + } | |
| 124 | + | |
| 125 | + /** | |
| 126 | + * MÈtodo de autenticação de usuários usando SIP | |
| 127 | + * @param UsuarioDTO | |
| 128 | + * @param $sigla | |
| 129 | + * @param $senha | |
| 130 | + * @param $IdOrgao | |
| 131 | + */ | |
| 132 | + protected function autenticarConectado(UsuarioDTO $usuarioDTO){ | |
| 133 | + try{ | |
| 134 | + if(!$usuarioDTO->isSetNumIdOrgao()){ | |
| 135 | + $orgaoRN = new OrgaoRN(); | |
| 136 | + $objOrgaoDTO = new OrgaoDTO(); | |
| 137 | + $objOrgaoDTO->setBolExclusaoLogica(false); | |
| 138 | + $objOrgaoDTO->retNumIdOrgao(); | |
| 139 | + $objOrgaoDTO->setStrSigla(ConfiguracaoSEI::getInstance()->getValor('SessaoSEI', 'SiglaOrgaoSistema')); | |
| 140 | + /** | |
| 141 | + * @var $orgaoCarregdo OrgaoDTO | |
| 142 | + * Orgao da sessao do sistema | |
| 143 | + */ | |
| 144 | + $orgaoCarregdo = $orgaoRN->consultarRN1352($objOrgaoDTO); | |
| 145 | + $usuarioDTO->setNumIdOrgao($orgaoCarregdo->getNumIdOrgao()); | |
| 146 | + } | |
| 147 | + $objSipWs = $this->retornaServicoSip(); | |
| 148 | + $ret = $objSipWs->autenticar( | |
| 149 | + $usuarioDTO->getNumIdOrgao(), | |
| 150 | + null, | |
| 151 | + $usuarioDTO->getStrSigla(), | |
| 152 | + $this->encriptaSenha($usuarioDTO->getStrSenha()), | |
| 153 | + ConfiguracaoSEI::getInstance()->getValor('SessaoSEI', 'SiglaSistema'), | |
| 154 | + ConfiguracaoSEI::getInstance()->getValor('SessaoSEI', 'SiglaOrgaoSistema') | |
| 155 | + ); | |
| 156 | + if(!$ret){ | |
| 157 | + throw new InfraException('Usuário ou senha inválido!'); | |
| 158 | + } | |
| 159 | + return array( | |
| 160 | + 'sucesso' => true, | |
| 161 | + 'data' => $ret, | |
| 162 | + 'token' => $this->tokenEncode($usuarioDTO->getStrSigla(), $usuarioDTO->getStrSenha()) | |
| 163 | + ); | |
| 164 | + }catch (Exception $e){ | |
| 165 | + return array( | |
| 166 | + 'sucesso' => false, | |
| 167 | + 'mensagem' => $e->getMessage(), | |
| 168 | + 'exception' => $e | |
| 169 | + ); | |
| 170 | + } | |
| 171 | + | |
| 172 | + } | |
| 173 | + | |
| 174 | + /** | |
| 175 | + * Retorna a lista de usuários por unidade | |
| 176 | + * @param UsuarioDTO | |
| 177 | + * @param $idUsuario | |
| 178 | + */ | |
| 179 | + protected function listarUsuariosConectado(UsuarioDTO $usuarioDTO){ | |
| 180 | + try{ | |
| 181 | + $objEntradaListarUsuariosAPI = new EntradaListarUsuariosAPI(); | |
| 182 | + $objEntradaListarUsuariosAPI->setIdUsuario($usuarioDTO->getNumIdUsuario()); | |
| 183 | + $objSeiRN = new SeiRN(); | |
| 184 | + $result = $objSeiRN->listarUsuarios($objEntradaListarUsuariosAPI); | |
| 185 | + return array( | |
| 186 | + 'sucesso' => true, | |
| 187 | + 'data' => $result | |
| 188 | + ); | |
| 189 | + }catch(Exception $e){ | |
| 190 | + return array( | |
| 191 | + 'sucesso' => false, | |
| 192 | + 'mensagem' => 'Erro no serviço de listagem de usuários.', | |
| 193 | + 'exception' => $e | |
| 194 | + ); | |
| 195 | + } | |
| 196 | + } | |
| 197 | + | |
| 198 | + private function decriptaSenha($senha){ | |
| 199 | + $decoded = base64_decode($senha); | |
| 200 | + for($i = 0; $i < strlen($decoded); $i++){ | |
| 201 | + $decoded[$i] = ~$decoded[$i]; | |
| 202 | + } | |
| 203 | + | |
| 204 | + return $decoded; | |
| 205 | + } | |
| 206 | + | |
| 207 | + private function encriptaSenha($senha){ | |
| 208 | + for($i = 0; $i < strlen($senha); $i++){ | |
| 209 | + $senha[$i] = ~$senha[$i]; | |
| 210 | + } | |
| 211 | + | |
| 212 | + return base64_encode($senha); | |
| 213 | + } | |
| 214 | + | |
| 215 | +} | |
| 0 | 216 | \ No newline at end of file | ... | ... |
| 1 | +++ a/teste.php | |
| ... | ... | @@ -0,0 +1,284 @@ |
| 1 | +<? | |
| 2 | + | |
| 3 | +require_once __DIR__.'/../../SEI.php'; | |
| 4 | + | |
| 5 | +ini_set('xdebug.var_display_max_depth', 100); | |
| 6 | +ini_set('xdebug.var_display_max_children', 100); | |
| 7 | +ini_set('xdebug.var_display_max_data', 2048); | |
| 8 | + | |
| 9 | + | |
| 10 | +class TesteBloco { | |
| 11 | + | |
| 12 | + public function listarBlocoUnidadeConectado(){ | |
| 13 | + $rn = new MdWsSeiBlocoRN(); | |
| 14 | + $dto = new UnidadeDTO(); | |
| 15 | + $dto->setNumIdUnidade(110000001); | |
| 16 | + var_dump($rn->listarBlocoUnidade($dto)); | |
| 17 | + } | |
| 18 | + | |
| 19 | + public function listarDocumentosBlocoConectado(){ | |
| 20 | + $rn = new MdWsSeiBlocoRN(); | |
| 21 | + $dto = new BlocoDTO(); | |
| 22 | + $dto->setNumIdBloco(1); | |
| 23 | + var_dump($rn->listarDocumentosBloco($dto)); | |
| 24 | + } | |
| 25 | + | |
| 26 | + public function cadastrarAnotacaoBlocoControlado(){ | |
| 27 | + $rn = new MdWsSeiBlocoRN(); | |
| 28 | + $dto = new RelBlocoProtocoloDTO(); | |
| 29 | + $dto->setNumIdBloco(1); | |
| 30 | + $dto->setDblIdProtocolo(4); | |
| 31 | + $dto->setStrAnotacao('Teste'); | |
| 32 | + var_dump($rn->cadastrarAnotacaoBloco($dto)); | |
| 33 | + } | |
| 34 | + | |
| 35 | +} | |
| 36 | + | |
| 37 | +class TesteDocumento { | |
| 38 | + | |
| 39 | + public function listarCienciaDocumentoConectado(){ | |
| 40 | + $rn = new MdWsSeiDocumentoRN(); | |
| 41 | + $dto = new MdWsSeiProcessoDTO(); | |
| 42 | + $dto->setStrValor('0000007'); | |
| 43 | + var_dump($rn->listarCienciaDocumento($dto)); | |
| 44 | + } | |
| 45 | + | |
| 46 | + public function listarAssinaturasDocumentoConectado(){ | |
| 47 | + $rn = new MdWsSeiDocumentoRN(); | |
| 48 | + $dto = new DocumentoDTO(); | |
| 49 | + $dto->setDblIdDocumento(3); | |
| 50 | + var_dump($rn->listarAssinaturasDocumento($dto)); | |
| 51 | + } | |
| 52 | + public function darCienciaControlado(){ | |
| 53 | + $dto = new DocumentoDTO(); | |
| 54 | + $dto->setDblIdDocumento(18); | |
| 55 | + $rn = new MdWsSeiDocumentoRN(); | |
| 56 | + var_dump($rn->darCiencia($dto)); | |
| 57 | + } | |
| 58 | + | |
| 59 | + public function assinarDocumentoControlado(){ | |
| 60 | + $dto = new AssinaturaDTO(); | |
| 61 | + $dto->setStrSenhaUsuario('teste'); | |
| 62 | + $dto->setStrSiglaUsuario('teste'); | |
| 63 | + $dto->setNumIdUsuario(100000001); | |
| 64 | + $dto->setNumIdContextoUsuario(null); | |
| 65 | + $dto->setStrStaFormaAutenticacao(AssinaturaRN::$TA_SENHA); | |
| 66 | + $dto->setStrCargoFuncao('Fiscal de Contrato - Administrativo'); | |
| 67 | + $dto->setNumIdOrgaoUsuario(0); | |
| 68 | + $doc1 = new DocumentoDTO(); | |
| 69 | + $doc1->setDblIdDocumento(19); | |
| 70 | + $doc2 = new DocumentoDTO(); | |
| 71 | + $doc2->setDblIdDocumento(20); | |
| 72 | + $documentos = array( | |
| 73 | + $doc1, | |
| 74 | + $doc2 | |
| 75 | + ); | |
| 76 | + $dto->setArrObjDocumentoDTO($documentos); | |
| 77 | + $rn = new MdWsSeiDocumentoRN(); | |
| 78 | + var_dump($rn->assinarDocumento($dto)); | |
| 79 | + } | |
| 80 | + | |
| 81 | + public function apiAssinarDocumentos(){ | |
| 82 | + $arrDocumentos = array(21, 22); | |
| 83 | + $rn = new MdWsSeiDocumentoRN(); | |
| 84 | + var_dump($rn->apiAssinarDocumentos($arrDocumentos, 0, 'Fiscal de Contrato - Administrativo', 'teste', 'teste', 100000001)); | |
| 85 | + } | |
| 86 | + | |
| 87 | + public function apiAssinarDocumento(){ | |
| 88 | + $rn = new MdWsSeiDocumentoRN(); | |
| 89 | + var_dump($rn->apiAssinarDocumento(22, 0, 'Fiscal de Contrato - Administrativo', 'teste', 'teste', 100000001)); | |
| 90 | + } | |
| 91 | + | |
| 92 | +} | |
| 93 | + | |
| 94 | + | |
| 95 | +class TesteProcedimento { | |
| 96 | + | |
| 97 | + public function removerSobrestamentoProcessoControlado(){ | |
| 98 | + $rn = new MdWsSeiProcedimentoRN(); | |
| 99 | + $dto = new ProcedimentoDTO(); | |
| 100 | + $dto->setDblIdProcedimento(15); | |
| 101 | + var_dump($rn->removerSobrestamentoProcesso($dto)); | |
| 102 | + } | |
| 103 | + | |
| 104 | + //o----- | |
| 105 | + | |
| 106 | + public function concluirProcessoControlado(){ | |
| 107 | + $api = new EntradaConcluirProcessoAPI(); | |
| 108 | + $api->setProtocoloProcedimento('99990000001201762'); | |
| 109 | + $rn = new MdWsSeiProcedimentoRN(); | |
| 110 | + var_dump($rn->concluirProcesso($api)); | |
| 111 | + } | |
| 112 | + | |
| 113 | + public function atribuirProcessoControlado(){ | |
| 114 | + $api = new EntradaAtribuirProcessoAPI(); | |
| 115 | + $api->setProtocoloProcedimento('99990000001201762'); | |
| 116 | + $api->setIdUsuario('100000001'); | |
| 117 | + $rn = new MdWsSeiProcedimentoRN(); | |
| 118 | + var_dump($rn->atribuirProcesso($api)); | |
| 119 | + } | |
| 120 | + | |
| 121 | + public function listarProcedimentoAcompanhamentoConectado(){ | |
| 122 | + $dto = new MdWsSeiProtocoloDTO(); | |
| 123 | + $rn = new MdWsSeiProcedimentoRN(); | |
| 124 | + $dto->setNumIdUsuarioGeradorAcompanhamento('100000001'); | |
| 125 | + //$dto->setNumidGrupoAcompanhamentoProcedimento(1); | |
| 126 | + $dto->setNumPaginaAtual(0); | |
| 127 | + $dto->setNumMaxRegistrosRetorno(10); | |
| 128 | + | |
| 129 | + var_dump($rn->listarProcedimentoAcompanhamento($dto)); | |
| 130 | + } | |
| 131 | + | |
| 132 | + public function listarProcessosConectado(){ | |
| 133 | + $rn = new MdWsSeiProcedimentoRN(); | |
| 134 | + $dto = new MdWsSeiProtocoloDTO(); | |
| 135 | + $dto->setNumIdUsuarioAtribuicaoAtividade('100000001'); | |
| 136 | + $dto->setNumIdUnidadeAtividade('110000001'); | |
| 137 | + $dto->setStrSinTipoBusca(MdWsSeiProtocoloDTO::SIN_TIPO_BUSCA_M); | |
| 138 | + $dto->setNumPaginaAtual(0); | |
| 139 | + $dto->setNumMaxRegistrosRetorno(10); | |
| 140 | + | |
| 141 | + var_dump($rn->listarProcessos($dto)); | |
| 142 | + } | |
| 143 | +} | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | +//o----- | |
| 155 | +class TesteUnidade { | |
| 156 | + | |
| 157 | + public function listarUnidadesConectado(){ | |
| 158 | + $mdUnidade = new MdWsSeiUnidadeRN(); | |
| 159 | + var_dump($mdUnidade->listarUnidades()); | |
| 160 | + } | |
| 161 | +} | |
| 162 | +class TesteOrgao { | |
| 163 | + | |
| 164 | + public function listarOrgaoConectado(){ | |
| 165 | + $orgaoDTO = new OrgaoDTO(); | |
| 166 | + $orgaoDTO->setNumMaxRegistrosRetorno(10); | |
| 167 | + $orgaoDTO->setNumPaginaAtual(0); | |
| 168 | + $mdUnidade = new MdWsSeiOrgaoRN(); | |
| 169 | + var_dump($mdUnidade->listarOrgao($orgaoDTO)); | |
| 170 | + } | |
| 171 | +} | |
| 172 | + | |
| 173 | +class TesteGrupoAcompanhamento { | |
| 174 | + | |
| 175 | + public function listarGrupoAcompanhamentoConectado(){ | |
| 176 | + $dto = new GrupoAcompanhamentoDTO(); | |
| 177 | + $dto->setNumMaxRegistrosRetorno(10); | |
| 178 | + $dto->setNumPaginaAtual(0); | |
| 179 | + $dto->setNumIdUnidade('110000001'); | |
| 180 | + $rn = new MdWsSeiGrupoAcompanhamentoRN(); | |
| 181 | + var_dump($rn->listarGrupoAcompanhamento($dto)); | |
| 182 | + } | |
| 183 | +} | |
| 184 | + | |
| 185 | +class TesteRetornoProgramado { | |
| 186 | + | |
| 187 | + public function agendarRetornoProgramadoControlado(){ | |
| 188 | + $post = array( | |
| 189 | + 'dtProgramada' => '28/09/2017', | |
| 190 | + 'unidade' => '110000001', | |
| 191 | + 'usuario' => '100000001', | |
| 192 | + 'atividadeEnvio' => 1 | |
| 193 | + ); | |
| 194 | + $rn = new MdWsSeiRetornoProgramadoRN(); | |
| 195 | + $dto = $rn->encapsulaRetornoProgramado($post); | |
| 196 | + var_dump($rn->agendarRetornoProgramado($dto)); | |
| 197 | + } | |
| 198 | +} | |
| 199 | + | |
| 200 | + | |
| 201 | +class TesteObservacao { | |
| 202 | + | |
| 203 | + public function criarObservacaoControlado(){ | |
| 204 | + $post = array( | |
| 205 | + 'unidade' => '110000001', | |
| 206 | + 'descricao' => 'dsadsadas dsa', | |
| 207 | + 'protocolo' => 1 | |
| 208 | + ); | |
| 209 | + $rn = new MdWsSeiObservacaoRN(); | |
| 210 | + $dto = $rn->encapsulaObservacao($post); | |
| 211 | + var_dump($rn->criarObservacao($dto)); | |
| 212 | + } | |
| 213 | +} | |
| 214 | + | |
| 215 | + | |
| 216 | +class TesteAnotacao { | |
| 217 | + | |
| 218 | + public function cadastrarAnotacaoControlado(){ | |
| 219 | + $post = array( | |
| 220 | + 'unidade' => '110000001', | |
| 221 | + 'descricao' => 'aaa nov', | |
| 222 | + 'protocolo' => 1, | |
| 223 | + 'usuario' => '100000001', | |
| 224 | + 'prioridade' => 'S' | |
| 225 | + ); | |
| 226 | + $rn = new MdWsSeiAnotacaoRN(); | |
| 227 | + $dto = $rn->encapsulaAnotacao($post); | |
| 228 | + var_dump($rn->cadastrarAnotacao($dto)); | |
| 229 | + } | |
| 230 | +} | |
| 231 | + | |
| 232 | +class TesteUsuario { | |
| 233 | + | |
| 234 | + public function autenticarWSDL(){ | |
| 235 | + $login = 'teste'; | |
| 236 | + $senha = 'teste'; | |
| 237 | + for ($i = 0; $i < strlen($senha); $i++) { | |
| 238 | + $senha[$i] = ~$senha[$i]; | |
| 239 | + } | |
| 240 | + $pass = base64_encode($senha); | |
| 241 | + $soap = new \SoapClient('http://localhost/sip/controlador_ws.php?servico=wsdl', array('encoding'=>'ISO-8859-1')); | |
| 242 | + /* | |
| 243 | + $loginData = $soap->autenticar( | |
| 244 | + 0, | |
| 245 | + null, | |
| 246 | + $login, | |
| 247 | + $pass, | |
| 248 | + ConfiguracaoSEI::getInstance()->getValor('SessaoSEI', 'SiglaSistema'), | |
| 249 | + ConfiguracaoSEI::getInstance()->getValor('SessaoSEI', 'SiglaOrgaoSistema') | |
| 250 | + ); | |
| 251 | + */ | |
| 252 | + //$ret = $soap->validarLogin($loginData->id_login, $loginData->id_sistema, $loginData->id_usuario, $loginData->hash_agente); | |
| 253 | + //var_dump($ret); | |
| 254 | + | |
| 255 | + $b = new MdWsSeiUsuarioRN(); | |
| 256 | + $token = $b->tokenEncode('teste', 'teste'); | |
| 257 | + var_dump($b->autenticarToken($token)); | |
| 258 | + | |
| 259 | + } | |
| 260 | +} | |
| 261 | + | |
| 262 | +class TesteAssinante { | |
| 263 | + | |
| 264 | + public function listarAssinanteConectado(){ | |
| 265 | + $dto = new AssinanteDTO(); | |
| 266 | + $dto->setNumMaxRegistrosRetorno(3); | |
| 267 | + $dto->setNumPaginaAtual(0); | |
| 268 | + $dto->setNumIdUnidade('110000001'); | |
| 269 | + $rn = new MdWsSeiAssinanteRN(); | |
| 270 | + var_dump($rn->listarAssinante($dto)); | |
| 271 | + } | |
| 272 | +} | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | +if($_REQUEST['controller'] && $_REQUEST['action']){ | |
| 277 | + try{ | |
| 278 | + $controller = new $_REQUEST['controller']; | |
| 279 | + echo 'Resposta teste <b>'.$_REQUEST['controller'].'->'.$_REQUEST['action'].'()</b>:'; | |
| 280 | + $controller->$_REQUEST['action'](); | |
| 281 | + }catch (Exception $e){ | |
| 282 | + var_dump($e); | |
| 283 | + } | |
| 284 | +} | |
| 0 | 285 | \ No newline at end of file | ... | ... |
| 1 | +++ a/vendor/composer/ClassLoader.php | |
| ... | ... | @@ -0,0 +1,445 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +/* | |
| 4 | + * This file is part of Composer. | |
| 5 | + * | |
| 6 | + * (c) Nils Adermann <naderman@naderman.de> | |
| 7 | + * Jordi Boggiano <j.boggiano@seld.be> | |
| 8 | + * | |
| 9 | + * For the full copyright and license information, please view the LICENSE | |
| 10 | + * file that was distributed with this source code. | |
| 11 | + */ | |
| 12 | + | |
| 13 | +namespace Composer\Autoload; | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. | |
| 17 | + * | |
| 18 | + * $loader = new \Composer\Autoload\ClassLoader(); | |
| 19 | + * | |
| 20 | + * // register classes with namespaces | |
| 21 | + * $loader->add('Symfony\Component', __DIR__.'/component'); | |
| 22 | + * $loader->add('Symfony', __DIR__.'/framework'); | |
| 23 | + * | |
| 24 | + * // activate the autoloader | |
| 25 | + * $loader->register(); | |
| 26 | + * | |
| 27 | + * // to enable searching the include path (eg. for PEAR packages) | |
| 28 | + * $loader->setUseIncludePath(true); | |
| 29 | + * | |
| 30 | + * In this example, if you try to use a class in the Symfony\Component | |
| 31 | + * namespace or one of its children (Symfony\Component\Console for instance), | |
| 32 | + * the autoloader will first look for the class under the component/ | |
| 33 | + * directory, and it will then fallback to the framework/ directory if not | |
| 34 | + * found before giving up. | |
| 35 | + * | |
| 36 | + * This class is loosely based on the Symfony UniversalClassLoader. | |
| 37 | + * | |
| 38 | + * @author Fabien Potencier <fabien@symfony.com> | |
| 39 | + * @author Jordi Boggiano <j.boggiano@seld.be> | |
| 40 | + * @see http://www.php-fig.org/psr/psr-0/ | |
| 41 | + * @see http://www.php-fig.org/psr/psr-4/ | |
| 42 | + */ | |
| 43 | +class ClassLoader | |
| 44 | +{ | |
| 45 | + // PSR-4 | |
| 46 | + private $prefixLengthsPsr4 = array(); | |
| 47 | + private $prefixDirsPsr4 = array(); | |
| 48 | + private $fallbackDirsPsr4 = array(); | |
| 49 | + | |
| 50 | + // PSR-0 | |
| 51 | + private $prefixesPsr0 = array(); | |
| 52 | + private $fallbackDirsPsr0 = array(); | |
| 53 | + | |
| 54 | + private $useIncludePath = false; | |
| 55 | + private $classMap = array(); | |
| 56 | + private $classMapAuthoritative = false; | |
| 57 | + private $missingClasses = array(); | |
| 58 | + private $apcuPrefix; | |
| 59 | + | |
| 60 | + public function getPrefixes() | |
| 61 | + { | |
| 62 | + if (!empty($this->prefixesPsr0)) { | |
| 63 | + return call_user_func_array('array_merge', $this->prefixesPsr0); | |
| 64 | + } | |
| 65 | + | |
| 66 | + return array(); | |
| 67 | + } | |
| 68 | + | |
| 69 | + public function getPrefixesPsr4() | |
| 70 | + { | |
| 71 | + return $this->prefixDirsPsr4; | |
| 72 | + } | |
| 73 | + | |
| 74 | + public function getFallbackDirs() | |
| 75 | + { | |
| 76 | + return $this->fallbackDirsPsr0; | |
| 77 | + } | |
| 78 | + | |
| 79 | + public function getFallbackDirsPsr4() | |
| 80 | + { | |
| 81 | + return $this->fallbackDirsPsr4; | |
| 82 | + } | |
| 83 | + | |
| 84 | + public function getClassMap() | |
| 85 | + { | |
| 86 | + return $this->classMap; | |
| 87 | + } | |
| 88 | + | |
| 89 | + /** | |
| 90 | + * @param array $classMap Class to filename map | |
| 91 | + */ | |
| 92 | + public function addClassMap(array $classMap) | |
| 93 | + { | |
| 94 | + if ($this->classMap) { | |
| 95 | + $this->classMap = array_merge($this->classMap, $classMap); | |
| 96 | + } else { | |
| 97 | + $this->classMap = $classMap; | |
| 98 | + } | |
| 99 | + } | |
| 100 | + | |
| 101 | + /** | |
| 102 | + * Registers a set of PSR-0 directories for a given prefix, either | |
| 103 | + * appending or prepending to the ones previously set for this prefix. | |
| 104 | + * | |
| 105 | + * @param string $prefix The prefix | |
| 106 | + * @param array|string $paths The PSR-0 root directories | |
| 107 | + * @param bool $prepend Whether to prepend the directories | |
| 108 | + */ | |
| 109 | + public function add($prefix, $paths, $prepend = false) | |
| 110 | + { | |
| 111 | + if (!$prefix) { | |
| 112 | + if ($prepend) { | |
| 113 | + $this->fallbackDirsPsr0 = array_merge( | |
| 114 | + (array) $paths, | |
| 115 | + $this->fallbackDirsPsr0 | |
| 116 | + ); | |
| 117 | + } else { | |
| 118 | + $this->fallbackDirsPsr0 = array_merge( | |
| 119 | + $this->fallbackDirsPsr0, | |
| 120 | + (array) $paths | |
| 121 | + ); | |
| 122 | + } | |
| 123 | + | |
| 124 | + return; | |
| 125 | + } | |
| 126 | + | |
| 127 | + $first = $prefix[0]; | |
| 128 | + if (!isset($this->prefixesPsr0[$first][$prefix])) { | |
| 129 | + $this->prefixesPsr0[$first][$prefix] = (array) $paths; | |
| 130 | + | |
| 131 | + return; | |
| 132 | + } | |
| 133 | + if ($prepend) { | |
| 134 | + $this->prefixesPsr0[$first][$prefix] = array_merge( | |
| 135 | + (array) $paths, | |
| 136 | + $this->prefixesPsr0[$first][$prefix] | |
| 137 | + ); | |
| 138 | + } else { | |
| 139 | + $this->prefixesPsr0[$first][$prefix] = array_merge( | |
| 140 | + $this->prefixesPsr0[$first][$prefix], | |
| 141 | + (array) $paths | |
| 142 | + ); | |
| 143 | + } | |
| 144 | + } | |
| 145 | + | |
| 146 | + /** | |
| 147 | + * Registers a set of PSR-4 directories for a given namespace, either | |
| 148 | + * appending or prepending to the ones previously set for this namespace. | |
| 149 | + * | |
| 150 | + * @param string $prefix The prefix/namespace, with trailing '\\' | |
| 151 | + * @param array|string $paths The PSR-4 base directories | |
| 152 | + * @param bool $prepend Whether to prepend the directories | |
| 153 | + * | |
| 154 | + * @throws \InvalidArgumentException | |
| 155 | + */ | |
| 156 | + public function addPsr4($prefix, $paths, $prepend = false) | |
| 157 | + { | |
| 158 | + if (!$prefix) { | |
| 159 | + // Register directories for the root namespace. | |
| 160 | + if ($prepend) { | |
| 161 | + $this->fallbackDirsPsr4 = array_merge( | |
| 162 | + (array) $paths, | |
| 163 | + $this->fallbackDirsPsr4 | |
| 164 | + ); | |
| 165 | + } else { | |
| 166 | + $this->fallbackDirsPsr4 = array_merge( | |
| 167 | + $this->fallbackDirsPsr4, | |
| 168 | + (array) $paths | |
| 169 | + ); | |
| 170 | + } | |
| 171 | + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { | |
| 172 | + // Register directories for a new namespace. | |
| 173 | + $length = strlen($prefix); | |
| 174 | + if ('\\' !== $prefix[$length - 1]) { | |
| 175 | + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); | |
| 176 | + } | |
| 177 | + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; | |
| 178 | + $this->prefixDirsPsr4[$prefix] = (array) $paths; | |
| 179 | + } elseif ($prepend) { | |
| 180 | + // Prepend directories for an already registered namespace. | |
| 181 | + $this->prefixDirsPsr4[$prefix] = array_merge( | |
| 182 | + (array) $paths, | |
| 183 | + $this->prefixDirsPsr4[$prefix] | |
| 184 | + ); | |
| 185 | + } else { | |
| 186 | + // Append directories for an already registered namespace. | |
| 187 | + $this->prefixDirsPsr4[$prefix] = array_merge( | |
| 188 | + $this->prefixDirsPsr4[$prefix], | |
| 189 | + (array) $paths | |
| 190 | + ); | |
| 191 | + } | |
| 192 | + } | |
| 193 | + | |
| 194 | + /** | |
| 195 | + * Registers a set of PSR-0 directories for a given prefix, | |
| 196 | + * replacing any others previously set for this prefix. | |
| 197 | + * | |
| 198 | + * @param string $prefix The prefix | |
| 199 | + * @param array|string $paths The PSR-0 base directories | |
| 200 | + */ | |
| 201 | + public function set($prefix, $paths) | |
| 202 | + { | |
| 203 | + if (!$prefix) { | |
| 204 | + $this->fallbackDirsPsr0 = (array) $paths; | |
| 205 | + } else { | |
| 206 | + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; | |
| 207 | + } | |
| 208 | + } | |
| 209 | + | |
| 210 | + /** | |
| 211 | + * Registers a set of PSR-4 directories for a given namespace, | |
| 212 | + * replacing any others previously set for this namespace. | |
| 213 | + * | |
| 214 | + * @param string $prefix The prefix/namespace, with trailing '\\' | |
| 215 | + * @param array|string $paths The PSR-4 base directories | |
| 216 | + * | |
| 217 | + * @throws \InvalidArgumentException | |
| 218 | + */ | |
| 219 | + public function setPsr4($prefix, $paths) | |
| 220 | + { | |
| 221 | + if (!$prefix) { | |
| 222 | + $this->fallbackDirsPsr4 = (array) $paths; | |
| 223 | + } else { | |
| 224 | + $length = strlen($prefix); | |
| 225 | + if ('\\' !== $prefix[$length - 1]) { | |
| 226 | + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); | |
| 227 | + } | |
| 228 | + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; | |
| 229 | + $this->prefixDirsPsr4[$prefix] = (array) $paths; | |
| 230 | + } | |
| 231 | + } | |
| 232 | + | |
| 233 | + /** | |
| 234 | + * Turns on searching the include path for class files. | |
| 235 | + * | |
| 236 | + * @param bool $useIncludePath | |
| 237 | + */ | |
| 238 | + public function setUseIncludePath($useIncludePath) | |
| 239 | + { | |
| 240 | + $this->useIncludePath = $useIncludePath; | |
| 241 | + } | |
| 242 | + | |
| 243 | + /** | |
| 244 | + * Can be used to check if the autoloader uses the include path to check | |
| 245 | + * for classes. | |
| 246 | + * | |
| 247 | + * @return bool | |
| 248 | + */ | |
| 249 | + public function getUseIncludePath() | |
| 250 | + { | |
| 251 | + return $this->useIncludePath; | |
| 252 | + } | |
| 253 | + | |
| 254 | + /** | |
| 255 | + * Turns off searching the prefix and fallback directories for classes | |
| 256 | + * that have not been registered with the class map. | |
| 257 | + * | |
| 258 | + * @param bool $classMapAuthoritative | |
| 259 | + */ | |
| 260 | + public function setClassMapAuthoritative($classMapAuthoritative) | |
| 261 | + { | |
| 262 | + $this->classMapAuthoritative = $classMapAuthoritative; | |
| 263 | + } | |
| 264 | + | |
| 265 | + /** | |
| 266 | + * Should class lookup fail if not found in the current class map? | |
| 267 | + * | |
| 268 | + * @return bool | |
| 269 | + */ | |
| 270 | + public function isClassMapAuthoritative() | |
| 271 | + { | |
| 272 | + return $this->classMapAuthoritative; | |
| 273 | + } | |
| 274 | + | |
| 275 | + /** | |
| 276 | + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. | |
| 277 | + * | |
| 278 | + * @param string|null $apcuPrefix | |
| 279 | + */ | |
| 280 | + public function setApcuPrefix($apcuPrefix) | |
| 281 | + { | |
| 282 | + $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; | |
| 283 | + } | |
| 284 | + | |
| 285 | + /** | |
| 286 | + * The APCu prefix in use, or null if APCu caching is not enabled. | |
| 287 | + * | |
| 288 | + * @return string|null | |
| 289 | + */ | |
| 290 | + public function getApcuPrefix() | |
| 291 | + { | |
| 292 | + return $this->apcuPrefix; | |
| 293 | + } | |
| 294 | + | |
| 295 | + /** | |
| 296 | + * Registers this instance as an autoloader. | |
| 297 | + * | |
| 298 | + * @param bool $prepend Whether to prepend the autoloader or not | |
| 299 | + */ | |
| 300 | + public function register($prepend = false) | |
| 301 | + { | |
| 302 | + spl_autoload_register(array($this, 'loadClass'), true, $prepend); | |
| 303 | + } | |
| 304 | + | |
| 305 | + /** | |
| 306 | + * Unregisters this instance as an autoloader. | |
| 307 | + */ | |
| 308 | + public function unregister() | |
| 309 | + { | |
| 310 | + spl_autoload_unregister(array($this, 'loadClass')); | |
| 311 | + } | |
| 312 | + | |
| 313 | + /** | |
| 314 | + * Loads the given class or interface. | |
| 315 | + * | |
| 316 | + * @param string $class The name of the class | |
| 317 | + * @return bool|null True if loaded, null otherwise | |
| 318 | + */ | |
| 319 | + public function loadClass($class) | |
| 320 | + { | |
| 321 | + if ($file = $this->findFile($class)) { | |
| 322 | + includeFile($file); | |
| 323 | + | |
| 324 | + return true; | |
| 325 | + } | |
| 326 | + } | |
| 327 | + | |
| 328 | + /** | |
| 329 | + * Finds the path to the file where the class is defined. | |
| 330 | + * | |
| 331 | + * @param string $class The name of the class | |
| 332 | + * | |
| 333 | + * @return string|false The path if found, false otherwise | |
| 334 | + */ | |
| 335 | + public function findFile($class) | |
| 336 | + { | |
| 337 | + // class map lookup | |
| 338 | + if (isset($this->classMap[$class])) { | |
| 339 | + return $this->classMap[$class]; | |
| 340 | + } | |
| 341 | + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { | |
| 342 | + return false; | |
| 343 | + } | |
| 344 | + if (null !== $this->apcuPrefix) { | |
| 345 | + $file = apcu_fetch($this->apcuPrefix.$class, $hit); | |
| 346 | + if ($hit) { | |
| 347 | + return $file; | |
| 348 | + } | |
| 349 | + } | |
| 350 | + | |
| 351 | + $file = $this->findFileWithExtension($class, '.php'); | |
| 352 | + | |
| 353 | + // Search for Hack files if we are running on HHVM | |
| 354 | + if (false === $file && defined('HHVM_VERSION')) { | |
| 355 | + $file = $this->findFileWithExtension($class, '.hh'); | |
| 356 | + } | |
| 357 | + | |
| 358 | + if (null !== $this->apcuPrefix) { | |
| 359 | + apcu_add($this->apcuPrefix.$class, $file); | |
| 360 | + } | |
| 361 | + | |
| 362 | + if (false === $file) { | |
| 363 | + // Remember that this class does not exist. | |
| 364 | + $this->missingClasses[$class] = true; | |
| 365 | + } | |
| 366 | + | |
| 367 | + return $file; | |
| 368 | + } | |
| 369 | + | |
| 370 | + private function findFileWithExtension($class, $ext) | |
| 371 | + { | |
| 372 | + // PSR-4 lookup | |
| 373 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; | |
| 374 | + | |
| 375 | + $first = $class[0]; | |
| 376 | + if (isset($this->prefixLengthsPsr4[$first])) { | |
| 377 | + $subPath = $class; | |
| 378 | + while (false !== $lastPos = strrpos($subPath, '\\')) { | |
| 379 | + $subPath = substr($subPath, 0, $lastPos); | |
| 380 | + $search = $subPath.'\\'; | |
| 381 | + if (isset($this->prefixDirsPsr4[$search])) { | |
| 382 | + foreach ($this->prefixDirsPsr4[$search] as $dir) { | |
| 383 | + $length = $this->prefixLengthsPsr4[$first][$search]; | |
| 384 | + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { | |
| 385 | + return $file; | |
| 386 | + } | |
| 387 | + } | |
| 388 | + } | |
| 389 | + } | |
| 390 | + } | |
| 391 | + | |
| 392 | + // PSR-4 fallback dirs | |
| 393 | + foreach ($this->fallbackDirsPsr4 as $dir) { | |
| 394 | + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { | |
| 395 | + return $file; | |
| 396 | + } | |
| 397 | + } | |
| 398 | + | |
| 399 | + // PSR-0 lookup | |
| 400 | + if (false !== $pos = strrpos($class, '\\')) { | |
| 401 | + // namespaced class name | |
| 402 | + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) | |
| 403 | + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); | |
| 404 | + } else { | |
| 405 | + // PEAR-like class name | |
| 406 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; | |
| 407 | + } | |
| 408 | + | |
| 409 | + if (isset($this->prefixesPsr0[$first])) { | |
| 410 | + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { | |
| 411 | + if (0 === strpos($class, $prefix)) { | |
| 412 | + foreach ($dirs as $dir) { | |
| 413 | + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { | |
| 414 | + return $file; | |
| 415 | + } | |
| 416 | + } | |
| 417 | + } | |
| 418 | + } | |
| 419 | + } | |
| 420 | + | |
| 421 | + // PSR-0 fallback dirs | |
| 422 | + foreach ($this->fallbackDirsPsr0 as $dir) { | |
| 423 | + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { | |
| 424 | + return $file; | |
| 425 | + } | |
| 426 | + } | |
| 427 | + | |
| 428 | + // PSR-0 include paths. | |
| 429 | + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { | |
| 430 | + return $file; | |
| 431 | + } | |
| 432 | + | |
| 433 | + return false; | |
| 434 | + } | |
| 435 | +} | |
| 436 | + | |
| 437 | +/** | |
| 438 | + * Scope isolated include. | |
| 439 | + * | |
| 440 | + * Prevents access to $this/self from included files. | |
| 441 | + */ | |
| 442 | +function includeFile($file) | |
| 443 | +{ | |
| 444 | + include $file; | |
| 445 | +} | ... | ... |
| 1 | +++ a/vendor/composer/LICENSE | |
| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | + | |
| 2 | +Copyright (c) Nils Adermann, Jordi Boggiano | |
| 3 | + | |
| 4 | +Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 5 | +of this software and associated documentation files (the "Software"), to deal | |
| 6 | +in the Software without restriction, including without limitation the rights | |
| 7 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 8 | +copies of the Software, and to permit persons to whom the Software is furnished | |
| 9 | +to do so, subject to the following conditions: | |
| 10 | + | |
| 11 | +The above copyright notice and this permission notice shall be included in all | |
| 12 | +copies or substantial portions of the Software. | |
| 13 | + | |
| 14 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 15 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 16 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 17 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 18 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 19 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 20 | +THE SOFTWARE. | |
| 21 | + | ... | ... |
| 1 | +++ a/vendor/composer/autoload_files.php | |
| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +// autoload_files.php @generated by Composer | |
| 4 | + | |
| 5 | +$vendorDir = dirname(dirname(__FILE__)); | |
| 6 | +$baseDir = dirname($vendorDir); | |
| 7 | + | |
| 8 | +return array( | |
| 9 | + '253c157292f75eb38082b5acb06f3f01' => $vendorDir . '/nikic/fast-route/src/functions.php', | |
| 10 | +); | ... | ... |
| 1 | +++ a/vendor/composer/autoload_namespaces.php | |
| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +// autoload_namespaces.php @generated by Composer | |
| 4 | + | |
| 5 | +$vendorDir = dirname(dirname(__FILE__)); | |
| 6 | +$baseDir = dirname($vendorDir); | |
| 7 | + | |
| 8 | +return array( | |
| 9 | + 'Pimple' => array($vendorDir . '/pimple/pimple/src'), | |
| 10 | +); | ... | ... |
| 1 | +++ a/vendor/composer/autoload_psr4.php | |
| ... | ... | @@ -0,0 +1,14 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +// autoload_psr4.php @generated by Composer | |
| 4 | + | |
| 5 | +$vendorDir = dirname(dirname(__FILE__)); | |
| 6 | +$baseDir = dirname($vendorDir); | |
| 7 | + | |
| 8 | +return array( | |
| 9 | + 'Slim\\' => array($vendorDir . '/slim/slim/Slim'), | |
| 10 | + 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'), | |
| 11 | + 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'), | |
| 12 | + 'Interop\\Container\\' => array($vendorDir . '/container-interop/container-interop/src/Interop/Container'), | |
| 13 | + 'FastRoute\\' => array($vendorDir . '/nikic/fast-route/src'), | |
| 14 | +); | ... | ... |
| 1 | +++ a/vendor/composer/autoload_real.php | |
| ... | ... | @@ -0,0 +1,70 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +// autoload_real.php @generated by Composer | |
| 4 | + | |
| 5 | +class ComposerAutoloaderInit29a4728604e52c048eac8a5ee4c40a9d | |
| 6 | +{ | |
| 7 | + private static $loader; | |
| 8 | + | |
| 9 | + public static function loadClassLoader($class) | |
| 10 | + { | |
| 11 | + if ('Composer\Autoload\ClassLoader' === $class) { | |
| 12 | + require __DIR__ . '/ClassLoader.php'; | |
| 13 | + } | |
| 14 | + } | |
| 15 | + | |
| 16 | + public static function getLoader() | |
| 17 | + { | |
| 18 | + if (null !== self::$loader) { | |
| 19 | + return self::$loader; | |
| 20 | + } | |
| 21 | + | |
| 22 | + spl_autoload_register(array('ComposerAutoloaderInit29a4728604e52c048eac8a5ee4c40a9d', 'loadClassLoader'), true, true); | |
| 23 | + self::$loader = $loader = new \Composer\Autoload\ClassLoader(); | |
| 24 | + spl_autoload_unregister(array('ComposerAutoloaderInit29a4728604e52c048eac8a5ee4c40a9d', 'loadClassLoader')); | |
| 25 | + | |
| 26 | + $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); | |
| 27 | + if ($useStaticLoader) { | |
| 28 | + require_once __DIR__ . '/autoload_static.php'; | |
| 29 | + | |
| 30 | + call_user_func(\Composer\Autoload\ComposerStaticInit29a4728604e52c048eac8a5ee4c40a9d::getInitializer($loader)); | |
| 31 | + } else { | |
| 32 | + $map = require __DIR__ . '/autoload_namespaces.php'; | |
| 33 | + foreach ($map as $namespace => $path) { | |
| 34 | + $loader->set($namespace, $path); | |
| 35 | + } | |
| 36 | + | |
| 37 | + $map = require __DIR__ . '/autoload_psr4.php'; | |
| 38 | + foreach ($map as $namespace => $path) { | |
| 39 | + $loader->setPsr4($namespace, $path); | |
| 40 | + } | |
| 41 | + | |
| 42 | + $classMap = require __DIR__ . '/autoload_classmap.php'; | |
| 43 | + if ($classMap) { | |
| 44 | + $loader->addClassMap($classMap); | |
| 45 | + } | |
| 46 | + } | |
| 47 | + | |
| 48 | + $loader->register(true); | |
| 49 | + | |
| 50 | + if ($useStaticLoader) { | |
| 51 | + $includeFiles = Composer\Autoload\ComposerStaticInit29a4728604e52c048eac8a5ee4c40a9d::$files; | |
| 52 | + } else { | |
| 53 | + $includeFiles = require __DIR__ . '/autoload_files.php'; | |
| 54 | + } | |
| 55 | + foreach ($includeFiles as $fileIdentifier => $file) { | |
| 56 | + composerRequire29a4728604e52c048eac8a5ee4c40a9d($fileIdentifier, $file); | |
| 57 | + } | |
| 58 | + | |
| 59 | + return $loader; | |
| 60 | + } | |
| 61 | +} | |
| 62 | + | |
| 63 | +function composerRequire29a4728604e52c048eac8a5ee4c40a9d($fileIdentifier, $file) | |
| 64 | +{ | |
| 65 | + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { | |
| 66 | + require $file; | |
| 67 | + | |
| 68 | + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; | |
| 69 | + } | |
| 70 | +} | ... | ... |
| 1 | +++ a/vendor/composer/autoload_static.php | |
| ... | ... | @@ -0,0 +1,75 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +// autoload_static.php @generated by Composer | |
| 4 | + | |
| 5 | +namespace Composer\Autoload; | |
| 6 | + | |
| 7 | +class ComposerStaticInit29a4728604e52c048eac8a5ee4c40a9d | |
| 8 | +{ | |
| 9 | + public static $files = array ( | |
| 10 | + '253c157292f75eb38082b5acb06f3f01' => __DIR__ . '/..' . '/nikic/fast-route/src/functions.php', | |
| 11 | + ); | |
| 12 | + | |
| 13 | + public static $prefixLengthsPsr4 = array ( | |
| 14 | + 'S' => | |
| 15 | + array ( | |
| 16 | + 'Slim\\' => 5, | |
| 17 | + ), | |
| 18 | + 'P' => | |
| 19 | + array ( | |
| 20 | + 'Psr\\Http\\Message\\' => 17, | |
| 21 | + 'Psr\\Container\\' => 14, | |
| 22 | + ), | |
| 23 | + 'I' => | |
| 24 | + array ( | |
| 25 | + 'Interop\\Container\\' => 18, | |
| 26 | + ), | |
| 27 | + 'F' => | |
| 28 | + array ( | |
| 29 | + 'FastRoute\\' => 10, | |
| 30 | + ), | |
| 31 | + ); | |
| 32 | + | |
| 33 | + public static $prefixDirsPsr4 = array ( | |
| 34 | + 'Slim\\' => | |
| 35 | + array ( | |
| 36 | + 0 => __DIR__ . '/..' . '/slim/slim/Slim', | |
| 37 | + ), | |
| 38 | + 'Psr\\Http\\Message\\' => | |
| 39 | + array ( | |
| 40 | + 0 => __DIR__ . '/..' . '/psr/http-message/src', | |
| 41 | + ), | |
| 42 | + 'Psr\\Container\\' => | |
| 43 | + array ( | |
| 44 | + 0 => __DIR__ . '/..' . '/psr/container/src', | |
| 45 | + ), | |
| 46 | + 'Interop\\Container\\' => | |
| 47 | + array ( | |
| 48 | + 0 => __DIR__ . '/..' . '/container-interop/container-interop/src/Interop/Container', | |
| 49 | + ), | |
| 50 | + 'FastRoute\\' => | |
| 51 | + array ( | |
| 52 | + 0 => __DIR__ . '/..' . '/nikic/fast-route/src', | |
| 53 | + ), | |
| 54 | + ); | |
| 55 | + | |
| 56 | + public static $prefixesPsr0 = array ( | |
| 57 | + 'P' => | |
| 58 | + array ( | |
| 59 | + 'Pimple' => | |
| 60 | + array ( | |
| 61 | + 0 => __DIR__ . '/..' . '/pimple/pimple/src', | |
| 62 | + ), | |
| 63 | + ), | |
| 64 | + ); | |
| 65 | + | |
| 66 | + public static function getInitializer(ClassLoader $loader) | |
| 67 | + { | |
| 68 | + return \Closure::bind(function () use ($loader) { | |
| 69 | + $loader->prefixLengthsPsr4 = ComposerStaticInit29a4728604e52c048eac8a5ee4c40a9d::$prefixLengthsPsr4; | |
| 70 | + $loader->prefixDirsPsr4 = ComposerStaticInit29a4728604e52c048eac8a5ee4c40a9d::$prefixDirsPsr4; | |
| 71 | + $loader->prefixesPsr0 = ComposerStaticInit29a4728604e52c048eac8a5ee4c40a9d::$prefixesPsr0; | |
| 72 | + | |
| 73 | + }, null, ClassLoader::class); | |
| 74 | + } | |
| 75 | +} | ... | ... |
| 1 | +++ a/vendor/composer/installed.json | |
| ... | ... | @@ -0,0 +1,303 @@ |
| 1 | +[ | |
| 2 | + { | |
| 3 | + "name": "psr/container", | |
| 4 | + "version": "1.0.0", | |
| 5 | + "version_normalized": "1.0.0.0", | |
| 6 | + "source": { | |
| 7 | + "type": "git", | |
| 8 | + "url": "https://github.com/php-fig/container.git", | |
| 9 | + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" | |
| 10 | + }, | |
| 11 | + "dist": { | |
| 12 | + "type": "zip", | |
| 13 | + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", | |
| 14 | + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", | |
| 15 | + "shasum": "" | |
| 16 | + }, | |
| 17 | + "require": { | |
| 18 | + "php": ">=5.3.0" | |
| 19 | + }, | |
| 20 | + "time": "2017-02-14T16:28:37+00:00", | |
| 21 | + "type": "library", | |
| 22 | + "extra": { | |
| 23 | + "branch-alias": { | |
| 24 | + "dev-master": "1.0.x-dev" | |
| 25 | + } | |
| 26 | + }, | |
| 27 | + "installation-source": "dist", | |
| 28 | + "autoload": { | |
| 29 | + "psr-4": { | |
| 30 | + "Psr\\Container\\": "src/" | |
| 31 | + } | |
| 32 | + }, | |
| 33 | + "notification-url": "https://packagist.org/downloads/", | |
| 34 | + "license": [ | |
| 35 | + "MIT" | |
| 36 | + ], | |
| 37 | + "authors": [ | |
| 38 | + { | |
| 39 | + "name": "PHP-FIG", | |
| 40 | + "homepage": "http://www.php-fig.org/" | |
| 41 | + } | |
| 42 | + ], | |
| 43 | + "description": "Common Container Interface (PHP FIG PSR-11)", | |
| 44 | + "homepage": "https://github.com/php-fig/container", | |
| 45 | + "keywords": [ | |
| 46 | + "PSR-11", | |
| 47 | + "container", | |
| 48 | + "container-interface", | |
| 49 | + "container-interop", | |
| 50 | + "psr" | |
| 51 | + ] | |
| 52 | + }, | |
| 53 | + { | |
| 54 | + "name": "container-interop/container-interop", | |
| 55 | + "version": "1.2.0", | |
| 56 | + "version_normalized": "1.2.0.0", | |
| 57 | + "source": { | |
| 58 | + "type": "git", | |
| 59 | + "url": "https://github.com/container-interop/container-interop.git", | |
| 60 | + "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8" | |
| 61 | + }, | |
| 62 | + "dist": { | |
| 63 | + "type": "zip", | |
| 64 | + "url": "https://api.github.com/repos/container-interop/container-interop/zipball/79cbf1341c22ec75643d841642dd5d6acd83bdb8", | |
| 65 | + "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8", | |
| 66 | + "shasum": "" | |
| 67 | + }, | |
| 68 | + "require": { | |
| 69 | + "psr/container": "^1.0" | |
| 70 | + }, | |
| 71 | + "time": "2017-02-14T19:40:03+00:00", | |
| 72 | + "type": "library", | |
| 73 | + "installation-source": "dist", | |
| 74 | + "autoload": { | |
| 75 | + "psr-4": { | |
| 76 | + "Interop\\Container\\": "src/Interop/Container/" | |
| 77 | + } | |
| 78 | + }, | |
| 79 | + "notification-url": "https://packagist.org/downloads/", | |
| 80 | + "license": [ | |
| 81 | + "MIT" | |
| 82 | + ], | |
| 83 | + "description": "Promoting the interoperability of container objects (DIC, SL, etc.)", | |
| 84 | + "homepage": "https://github.com/container-interop/container-interop" | |
| 85 | + }, | |
| 86 | + { | |
| 87 | + "name": "nikic/fast-route", | |
| 88 | + "version": "v1.2.0", | |
| 89 | + "version_normalized": "1.2.0.0", | |
| 90 | + "source": { | |
| 91 | + "type": "git", | |
| 92 | + "url": "https://github.com/nikic/FastRoute.git", | |
| 93 | + "reference": "b5f95749071c82a8e0f58586987627054400cdf6" | |
| 94 | + }, | |
| 95 | + "dist": { | |
| 96 | + "type": "zip", | |
| 97 | + "url": "https://api.github.com/repos/nikic/FastRoute/zipball/b5f95749071c82a8e0f58586987627054400cdf6", | |
| 98 | + "reference": "b5f95749071c82a8e0f58586987627054400cdf6", | |
| 99 | + "shasum": "" | |
| 100 | + }, | |
| 101 | + "require": { | |
| 102 | + "php": ">=5.4.0" | |
| 103 | + }, | |
| 104 | + "time": "2017-01-19T11:35:12+00:00", | |
| 105 | + "type": "library", | |
| 106 | + "installation-source": "dist", | |
| 107 | + "autoload": { | |
| 108 | + "psr-4": { | |
| 109 | + "FastRoute\\": "src/" | |
| 110 | + }, | |
| 111 | + "files": [ | |
| 112 | + "src/functions.php" | |
| 113 | + ] | |
| 114 | + }, | |
| 115 | + "notification-url": "https://packagist.org/downloads/", | |
| 116 | + "license": [ | |
| 117 | + "BSD-3-Clause" | |
| 118 | + ], | |
| 119 | + "authors": [ | |
| 120 | + { | |
| 121 | + "name": "Nikita Popov", | |
| 122 | + "email": "nikic@php.net" | |
| 123 | + } | |
| 124 | + ], | |
| 125 | + "description": "Fast request router for PHP", | |
| 126 | + "keywords": [ | |
| 127 | + "router", | |
| 128 | + "routing" | |
| 129 | + ] | |
| 130 | + }, | |
| 131 | + { | |
| 132 | + "name": "psr/http-message", | |
| 133 | + "version": "1.0.1", | |
| 134 | + "version_normalized": "1.0.1.0", | |
| 135 | + "source": { | |
| 136 | + "type": "git", | |
| 137 | + "url": "https://github.com/php-fig/http-message.git", | |
| 138 | + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" | |
| 139 | + }, | |
| 140 | + "dist": { | |
| 141 | + "type": "zip", | |
| 142 | + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", | |
| 143 | + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", | |
| 144 | + "shasum": "" | |
| 145 | + }, | |
| 146 | + "require": { | |
| 147 | + "php": ">=5.3.0" | |
| 148 | + }, | |
| 149 | + "time": "2016-08-06T14:39:51+00:00", | |
| 150 | + "type": "library", | |
| 151 | + "extra": { | |
| 152 | + "branch-alias": { | |
| 153 | + "dev-master": "1.0.x-dev" | |
| 154 | + } | |
| 155 | + }, | |
| 156 | + "installation-source": "dist", | |
| 157 | + "autoload": { | |
| 158 | + "psr-4": { | |
| 159 | + "Psr\\Http\\Message\\": "src/" | |
| 160 | + } | |
| 161 | + }, | |
| 162 | + "notification-url": "https://packagist.org/downloads/", | |
| 163 | + "license": [ | |
| 164 | + "MIT" | |
| 165 | + ], | |
| 166 | + "authors": [ | |
| 167 | + { | |
| 168 | + "name": "PHP-FIG", | |
| 169 | + "homepage": "http://www.php-fig.org/" | |
| 170 | + } | |
| 171 | + ], | |
| 172 | + "description": "Common interface for HTTP messages", | |
| 173 | + "homepage": "https://github.com/php-fig/http-message", | |
| 174 | + "keywords": [ | |
| 175 | + "http", | |
| 176 | + "http-message", | |
| 177 | + "psr", | |
| 178 | + "psr-7", | |
| 179 | + "request", | |
| 180 | + "response" | |
| 181 | + ] | |
| 182 | + }, | |
| 183 | + { | |
| 184 | + "name": "pimple/pimple", | |
| 185 | + "version": "v3.0.2", | |
| 186 | + "version_normalized": "3.0.2.0", | |
| 187 | + "source": { | |
| 188 | + "type": "git", | |
| 189 | + "url": "https://github.com/silexphp/Pimple.git", | |
| 190 | + "reference": "a30f7d6e57565a2e1a316e1baf2a483f788b258a" | |
| 191 | + }, | |
| 192 | + "dist": { | |
| 193 | + "type": "zip", | |
| 194 | + "url": "https://api.github.com/repos/silexphp/Pimple/zipball/a30f7d6e57565a2e1a316e1baf2a483f788b258a", | |
| 195 | + "reference": "a30f7d6e57565a2e1a316e1baf2a483f788b258a", | |
| 196 | + "shasum": "" | |
| 197 | + }, | |
| 198 | + "require": { | |
| 199 | + "php": ">=5.3.0" | |
| 200 | + }, | |
| 201 | + "time": "2015-09-11T15:10:35+00:00", | |
| 202 | + "type": "library", | |
| 203 | + "extra": { | |
| 204 | + "branch-alias": { | |
| 205 | + "dev-master": "3.0.x-dev" | |
| 206 | + } | |
| 207 | + }, | |
| 208 | + "installation-source": "dist", | |
| 209 | + "autoload": { | |
| 210 | + "psr-0": { | |
| 211 | + "Pimple": "src/" | |
| 212 | + } | |
| 213 | + }, | |
| 214 | + "notification-url": "https://packagist.org/downloads/", | |
| 215 | + "license": [ | |
| 216 | + "MIT" | |
| 217 | + ], | |
| 218 | + "authors": [ | |
| 219 | + { | |
| 220 | + "name": "Fabien Potencier", | |
| 221 | + "email": "fabien@symfony.com" | |
| 222 | + } | |
| 223 | + ], | |
| 224 | + "description": "Pimple, a simple Dependency Injection Container", | |
| 225 | + "homepage": "http://pimple.sensiolabs.org", | |
| 226 | + "keywords": [ | |
| 227 | + "container", | |
| 228 | + "dependency injection" | |
| 229 | + ] | |
| 230 | + }, | |
| 231 | + { | |
| 232 | + "name": "slim/slim", | |
| 233 | + "version": "3.7.0", | |
| 234 | + "version_normalized": "3.7.0.0", | |
| 235 | + "source": { | |
| 236 | + "type": "git", | |
| 237 | + "url": "https://github.com/slimphp/Slim.git", | |
| 238 | + "reference": "4254e40d81559e35cdf856bcbaca5f3af468b7ef" | |
| 239 | + }, | |
| 240 | + "dist": { | |
| 241 | + "type": "zip", | |
| 242 | + "url": "https://api.github.com/repos/slimphp/Slim/zipball/4254e40d81559e35cdf856bcbaca5f3af468b7ef", | |
| 243 | + "reference": "4254e40d81559e35cdf856bcbaca5f3af468b7ef", | |
| 244 | + "shasum": "" | |
| 245 | + }, | |
| 246 | + "require": { | |
| 247 | + "container-interop/container-interop": "^1.1", | |
| 248 | + "nikic/fast-route": "^1.0", | |
| 249 | + "php": ">=5.5.0", | |
| 250 | + "pimple/pimple": "^3.0", | |
| 251 | + "psr/http-message": "^1.0" | |
| 252 | + }, | |
| 253 | + "provide": { | |
| 254 | + "psr/http-message-implementation": "1.0" | |
| 255 | + }, | |
| 256 | + "require-dev": { | |
| 257 | + "phpunit/phpunit": "^4.0", | |
| 258 | + "squizlabs/php_codesniffer": "^2.5" | |
| 259 | + }, | |
| 260 | + "time": "2016-12-20T20:30:47+00:00", | |
| 261 | + "type": "library", | |
| 262 | + "installation-source": "dist", | |
| 263 | + "autoload": { | |
| 264 | + "psr-4": { | |
| 265 | + "Slim\\": "Slim" | |
| 266 | + } | |
| 267 | + }, | |
| 268 | + "notification-url": "https://packagist.org/downloads/", | |
| 269 | + "license": [ | |
| 270 | + "MIT" | |
| 271 | + ], | |
| 272 | + "authors": [ | |
| 273 | + { | |
| 274 | + "name": "Rob Allen", | |
| 275 | + "email": "rob@akrabat.com", | |
| 276 | + "homepage": "http://akrabat.com" | |
| 277 | + }, | |
| 278 | + { | |
| 279 | + "name": "Josh Lockhart", | |
| 280 | + "email": "hello@joshlockhart.com", | |
| 281 | + "homepage": "https://joshlockhart.com" | |
| 282 | + }, | |
| 283 | + { | |
| 284 | + "name": "Gabriel Manricks", | |
| 285 | + "email": "gmanricks@me.com", | |
| 286 | + "homepage": "http://gabrielmanricks.com" | |
| 287 | + }, | |
| 288 | + { | |
| 289 | + "name": "Andrew Smith", | |
| 290 | + "email": "a.smith@silentworks.co.uk", | |
| 291 | + "homepage": "http://silentworks.co.uk" | |
| 292 | + } | |
| 293 | + ], | |
| 294 | + "description": "Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs", | |
| 295 | + "homepage": "https://slimframework.com", | |
| 296 | + "keywords": [ | |
| 297 | + "api", | |
| 298 | + "framework", | |
| 299 | + "micro", | |
| 300 | + "router" | |
| 301 | + ] | |
| 302 | + } | |
| 303 | +] | ... | ... |
| 1 | +++ a/vendor/container-interop/container-interop/LICENSE | |
| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | +The MIT License (MIT) | |
| 2 | + | |
| 3 | +Copyright (c) 2013 container-interop | |
| 4 | + | |
| 5 | +Permission is hereby granted, free of charge, to any person obtaining a copy of | |
| 6 | +this software and associated documentation files (the "Software"), to deal in | |
| 7 | +the Software without restriction, including without limitation the rights to | |
| 8 | +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | |
| 9 | +the Software, and to permit persons to whom the Software is furnished to do so, | |
| 10 | +subject to the following conditions: | |
| 11 | + | |
| 12 | +The above copyright notice and this permission notice shall be included in all | |
| 13 | +copies or substantial portions of the Software. | |
| 14 | + | |
| 15 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 16 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | |
| 17 | +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | |
| 18 | +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | |
| 19 | +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |
| 20 | +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ... | ... |
| 1 | +++ a/vendor/container-interop/container-interop/README.md | |
| ... | ... | @@ -0,0 +1,148 @@ |
| 1 | +# Container Interoperability | |
| 2 | + | |
| 3 | +[](https://packagist.org/packages/container-interop/container-interop) | |
| 4 | +[](https://packagist.org/packages/container-interop/container-interop) | |
| 5 | + | |
| 6 | +## Deprecation warning! | |
| 7 | + | |
| 8 | +Starting Feb. 13th 2017, container-interop is officially deprecated in favor of [PSR-11](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-11-container.md). | |
| 9 | +Container-interop has been the test-bed of PSR-11. From v1.2, container-interop directly extends PSR-11 interfaces. | |
| 10 | +Therefore, all containers implementing container-interop are now *de-facto* compatible with PSR-11. | |
| 11 | + | |
| 12 | +- Projects implementing container-interop interfaces are encouraged to directly implement PSR-11 interfaces instead. | |
| 13 | +- Projects consuming container-interop interfaces are very strongly encouraged to directly type-hint on PSR-11 interfaces, in order to be compatible with PSR-11 containers that are not compatible with container-interop. | |
| 14 | + | |
| 15 | +Regarding the delegate lookup feature, that is present in container-interop and not in PSR-11, the feature is actually a design pattern. It is therefore not deprecated. Documentation regarding this design pattern will be migrated from this repository into a separate website in the future. | |
| 16 | + | |
| 17 | +## About | |
| 18 | + | |
| 19 | +*container-interop* tries to identify and standardize features in *container* objects (service locators, | |
| 20 | +dependency injection containers, etc.) to achieve interoperability. | |
| 21 | + | |
| 22 | +Through discussions and trials, we try to create a standard, made of common interfaces but also recommendations. | |
| 23 | + | |
| 24 | +If PHP projects that provide container implementations begin to adopt these common standards, then PHP | |
| 25 | +applications and projects that use containers can depend on the common interfaces instead of specific | |
| 26 | +implementations. This facilitates a high-level of interoperability and flexibility that allows users to consume | |
| 27 | +*any* container implementation that can be adapted to these interfaces. | |
| 28 | + | |
| 29 | +The work done in this project is not officially endorsed by the [PHP-FIG](http://www.php-fig.org/), but it is being | |
| 30 | +worked on by members of PHP-FIG and other good developers. We adhere to the spirit and ideals of PHP-FIG, and hope | |
| 31 | +this project will pave the way for one or more future PSRs. | |
| 32 | + | |
| 33 | + | |
| 34 | +## Installation | |
| 35 | + | |
| 36 | +You can install this package through Composer: | |
| 37 | + | |
| 38 | +```json | |
| 39 | +composer require container-interop/container-interop | |
| 40 | +``` | |
| 41 | + | |
| 42 | +The packages adheres to the [SemVer](http://semver.org/) specification, and there will be full backward compatibility | |
| 43 | +between minor versions. | |
| 44 | + | |
| 45 | +## Standards | |
| 46 | + | |
| 47 | +### Available | |
| 48 | + | |
| 49 | +- [`ContainerInterface`](src/Interop/Container/ContainerInterface.php). | |
| 50 | +[Description](docs/ContainerInterface.md) [Meta Document](docs/ContainerInterface-meta.md). | |
| 51 | +Describes the interface of a container that exposes methods to read its entries. | |
| 52 | +- [*Delegate lookup feature*](docs/Delegate-lookup.md). | |
| 53 | +[Meta Document](docs/Delegate-lookup-meta.md). | |
| 54 | +Describes the ability for a container to delegate the lookup of its dependencies to a third-party container. This | |
| 55 | +feature lets several containers work together in a single application. | |
| 56 | + | |
| 57 | +### Proposed | |
| 58 | + | |
| 59 | +View open [request for comments](https://github.com/container-interop/container-interop/labels/RFC) | |
| 60 | + | |
| 61 | +## Compatible projects | |
| 62 | + | |
| 63 | +### Projects implementing `ContainerInterface` | |
| 64 | + | |
| 65 | +- [Acclimate](https://github.com/jeremeamia/acclimate-container): Adapters for | |
| 66 | + Aura.Di, Laravel, Nette DI, Pimple, Symfony DI, ZF2 Service manager, ZF2 | |
| 67 | + Dependency injection and any container using `ArrayAccess` | |
| 68 | +- [Aura.Di](https://github.com/auraphp/Aura.Di) | |
| 69 | +- [auryn-container-interop](https://github.com/elazar/auryn-container-interop) | |
| 70 | +- [Burlap](https://github.com/codeeverything/burlap) | |
| 71 | +- [Chernozem](https://github.com/pyrsmk/Chernozem) | |
| 72 | +- [Data Manager](https://github.com/chrismichaels84/data-manager) | |
| 73 | +- [Disco](https://github.com/bitexpert/disco) | |
| 74 | +- [InDI](https://github.com/idealogica/indi) | |
| 75 | +- [League/Container](http://container.thephpleague.com/) | |
| 76 | +- [Mouf](http://mouf-php.com) | |
| 77 | +- [Njasm Container](https://github.com/njasm/container) | |
| 78 | +- [PHP-DI](http://php-di.org) | |
| 79 | +- [Picotainer](https://github.com/thecodingmachine/picotainer) | |
| 80 | +- [PimpleInterop](https://github.com/moufmouf/pimple-interop) | |
| 81 | +- [Pimple3-ContainerInterop](https://github.com/Sam-Burns/pimple3-containerinterop) (using Pimple v3) | |
| 82 | +- [SitePoint Container](https://github.com/sitepoint/Container) | |
| 83 | +- [Thruster Container](https://github.com/ThrusterIO/container) (PHP7 only) | |
| 84 | +- [Ultra-Lite Container](https://github.com/ultra-lite/container) | |
| 85 | +- [Unbox](https://github.com/mindplay-dk/unbox) | |
| 86 | +- [XStatic](https://github.com/jeremeamia/xstatic) | |
| 87 | +- [Zend\ServiceManager](https://github.com/zendframework/zend-servicemanager) | |
| 88 | +- [Zit](https://github.com/inxilpro/Zit) | |
| 89 | + | |
| 90 | +### Projects implementing the *delegate lookup* feature | |
| 91 | + | |
| 92 | +- [Aura.Di](https://github.com/auraphp/Aura.Di) | |
| 93 | +- [Burlap](https://github.com/codeeverything/burlap) | |
| 94 | +- [Chernozem](https://github.com/pyrsmk/Chernozem) | |
| 95 | +- [InDI](https://github.com/idealogica/indi) | |
| 96 | +- [League/Container](http://container.thephpleague.com/) | |
| 97 | +- [Mouf](http://mouf-php.com) | |
| 98 | +- [Picotainer](https://github.com/thecodingmachine/picotainer) | |
| 99 | +- [PHP-DI](http://php-di.org) | |
| 100 | +- [PimpleInterop](https://github.com/moufmouf/pimple-interop) | |
| 101 | +- [Ultra-Lite Container](https://github.com/ultra-lite/container) | |
| 102 | + | |
| 103 | +### Middlewares implementing `ContainerInterface` | |
| 104 | + | |
| 105 | +- [Alias-Container](https://github.com/thecodingmachine/alias-container): add | |
| 106 | + aliases support to any container | |
| 107 | +- [Prefixer-Container](https://github.com/thecodingmachine/prefixer-container): | |
| 108 | + dynamically prefix identifiers | |
| 109 | +- [Lazy-Container](https://github.com/snapshotpl/lazy-container): lazy services | |
| 110 | + | |
| 111 | +### Projects using `ContainerInterface` | |
| 112 | + | |
| 113 | +The list below contains only a sample of all the projects consuming `ContainerInterface`. For a more complete list have a look [here](http://packanalyst.com/class?q=Interop%5CContainer%5CContainerInterface). | |
| 114 | + | |
| 115 | +| | Downloads | | |
| 116 | +| --- | --- | | |
| 117 | +| [Adroit](https://github.com/bitexpert/adroit) |  | | |
| 118 | +| [Behat](https://github.com/Behat/Behat/pull/974) |  | | |
| 119 | +| [blast-facades](https://github.com/phpthinktank/blast-facades): Minimize complexity and represent dependencies as facades. |  | | |
| 120 | +| [interop.silex.di](https://github.com/thecodingmachine/interop.silex.di): an extension to [Silex](http://silex.sensiolabs.org/) that adds support for any *container-interop* compatible container |  | | |
| 121 | +| [mindplay/walkway](https://github.com/mindplay-dk/walkway): a modular request router |  | | |
| 122 | +| [mindplay/middleman](https://github.com/mindplay-dk/middleman): minimalist PSR-7 middleware dispatcher |  | | |
| 123 | +| [PHP-DI/Invoker](https://github.com/PHP-DI/Invoker): extensible and configurable invoker/dispatcher |  | | |
| 124 | +| [Prophiler](https://github.com/fabfuel/prophiler) |  | | |
| 125 | +| [Silly](https://github.com/mnapoli/silly): CLI micro-framework |  | | |
| 126 | +| [Slim v3](https://github.com/slimphp/Slim) |  | | |
| 127 | +| [Splash](http://mouf-php.com/packages/mouf/mvc.splash-common/version/8.0-dev/README.md) |  | | |
| 128 | +| [Woohoo Labs. Harmony](https://github.com/woohoolabs/harmony): a flexible micro-framework |  | | |
| 129 | +| [zend-expressive](https://github.com/zendframework/zend-expressive) |  | | |
| 130 | + | |
| 131 | + | |
| 132 | +## Workflow | |
| 133 | + | |
| 134 | +Everyone is welcome to join and contribute. | |
| 135 | + | |
| 136 | +The general workflow looks like this: | |
| 137 | + | |
| 138 | +1. Someone opens a discussion (GitHub issue) to suggest an interface | |
| 139 | +1. Feedback is gathered | |
| 140 | +1. The interface is added to a development branch | |
| 141 | +1. We release alpha versions so that the interface can be experimented with | |
| 142 | +1. Discussions and edits ensue until the interface is deemed stable by a general consensus | |
| 143 | +1. A new minor version of the package is released | |
| 144 | + | |
| 145 | +We try to not break BC by creating new interfaces instead of editing existing ones. | |
| 146 | + | |
| 147 | +While we currently work on interfaces, we are open to anything that might help towards interoperability, may that | |
| 148 | +be code, best practices, etc. | ... | ... |
vendor/container-interop/container-interop/composer.json
0 → 100644
| 1 | +++ a/vendor/container-interop/container-interop/composer.json | |
| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | +{ | |
| 2 | + "name": "container-interop/container-interop", | |
| 3 | + "type": "library", | |
| 4 | + "description": "Promoting the interoperability of container objects (DIC, SL, etc.)", | |
| 5 | + "homepage": "https://github.com/container-interop/container-interop", | |
| 6 | + "license": "MIT", | |
| 7 | + "autoload": { | |
| 8 | + "psr-4": { | |
| 9 | + "Interop\\Container\\": "src/Interop/Container/" | |
| 10 | + } | |
| 11 | + }, | |
| 12 | + "require": { | |
| 13 | + "psr/container": "^1.0" | |
| 14 | + } | |
| 15 | +} | ... | ... |
vendor/container-interop/container-interop/docs/ContainerInterface-meta.md
0 → 100644
| 1 | +++ a/vendor/container-interop/container-interop/docs/ContainerInterface-meta.md | |
| ... | ... | @@ -0,0 +1,114 @@ |
| 1 | +# ContainerInterface Meta Document | |
| 2 | + | |
| 3 | +## Introduction | |
| 4 | + | |
| 5 | +This document describes the process and discussions that lead to the `ContainerInterface`. | |
| 6 | +Its goal is to explain the reasons behind each decision. | |
| 7 | + | |
| 8 | +## Goal | |
| 9 | + | |
| 10 | +The goal set by `ContainerInterface` is to standardize how frameworks and libraries make use of a | |
| 11 | +container to obtain objects and parameters. | |
| 12 | + | |
| 13 | +By standardizing such a behavior, frameworks and libraries using the `ContainerInterface` | |
| 14 | +could work with any compatible container. | |
| 15 | +That would allow end users to choose their own container based on their own preferences. | |
| 16 | + | |
| 17 | +It is important to distinguish the two usages of a container: | |
| 18 | + | |
| 19 | +- configuring entries | |
| 20 | +- fetching entries | |
| 21 | + | |
| 22 | +Most of the time, those two sides are not used by the same party. | |
| 23 | +While it is often end users who tend to configure entries, it is generally the framework that fetch | |
| 24 | +entries to build the application. | |
| 25 | + | |
| 26 | +This is why this interface focuses only on how entries can be fetched from a container. | |
| 27 | + | |
| 28 | +## Interface name | |
| 29 | + | |
| 30 | +The interface name has been thoroughly discussed and was decided by a vote. | |
| 31 | + | |
| 32 | +The list of options considered with their respective votes are: | |
| 33 | + | |
| 34 | +- `ContainerInterface`: +8 | |
| 35 | +- `ProviderInterface`: +2 | |
| 36 | +- `LocatorInterface`: 0 | |
| 37 | +- `ReadableContainerInterface`: -5 | |
| 38 | +- `ServiceLocatorInterface`: -6 | |
| 39 | +- `ObjectFactory`: -6 | |
| 40 | +- `ObjectStore`: -8 | |
| 41 | +- `ConsumerInterface`: -9 | |
| 42 | + | |
| 43 | +[Full results of the vote](https://github.com/container-interop/container-interop/wiki/%231-interface-name:-Vote) | |
| 44 | + | |
| 45 | +The complete discussion can be read in [the issue #1](https://github.com/container-interop/container-interop/issues/1). | |
| 46 | + | |
| 47 | +## Interface methods | |
| 48 | + | |
| 49 | +The choice of which methods the interface would contain was made after a statistical analysis of existing containers. | |
| 50 | +The results of this analysis are available [in this document](https://gist.github.com/mnapoli/6159681). | |
| 51 | + | |
| 52 | +The summary of the analysis showed that: | |
| 53 | + | |
| 54 | +- all containers offer a method to get an entry by its id | |
| 55 | +- a large majority name such method `get()` | |
| 56 | +- for all containers, the `get()` method has 1 mandatory parameter of type string | |
| 57 | +- some containers have an optional additional argument for `get()`, but it doesn't have the same purpose between containers | |
| 58 | +- a large majority of the containers offer a method to test if it can return an entry by its id | |
| 59 | +- a majority name such method `has()` | |
| 60 | +- for all containers offering `has()`, the method has exactly 1 parameter of type string | |
| 61 | +- a large majority of the containers throw an exception rather than returning null when an entry is not found in `get()` | |
| 62 | +- a large majority of the containers don't implement `ArrayAccess` | |
| 63 | + | |
| 64 | +The question of whether to include methods to define entries has been discussed in | |
| 65 | +[issue #1](https://github.com/container-interop/container-interop/issues/1). | |
| 66 | +It has been judged that such methods do not belong in the interface described here because it is out of its scope | |
| 67 | +(see the "Goal" section). | |
| 68 | + | |
| 69 | +As a result, the `ContainerInterface` contains two methods: | |
| 70 | + | |
| 71 | +- `get()`, returning anything, with one mandatory string parameter. Should throw an exception if the entry is not found. | |
| 72 | +- `has()`, returning a boolean, with one mandatory string parameter. | |
| 73 | + | |
| 74 | +### Number of parameters in `get()` method | |
| 75 | + | |
| 76 | +While `ContainerInterface` only defines one mandatory parameter in `get()`, it is not incompatible with | |
| 77 | +existing containers that have additional optional parameters. PHP allows an implementation to offer more parameters | |
| 78 | +as long as they are optional, because the implementation *does* satisfy the interface. | |
| 79 | + | |
| 80 | +This issue has been discussed in [issue #6](https://github.com/container-interop/container-interop/issues/6). | |
| 81 | + | |
| 82 | +### Type of the `$id` parameter | |
| 83 | + | |
| 84 | +The type of the `$id` parameter in `get()` and `has()` has been discussed in | |
| 85 | +[issue #6](https://github.com/container-interop/container-interop/issues/6). | |
| 86 | +While `string` is used in all the containers that were analyzed, it was suggested that allowing | |
| 87 | +anything (such as objects) could allow containers to offer a more advanced query API. | |
| 88 | + | |
| 89 | +An example given was to use the container as an object builder. The `$id` parameter would then be an | |
| 90 | +object that would describe how to create an instance. | |
| 91 | + | |
| 92 | +The conclusion of the discussion was that this was beyond the scope of getting entries from a container without | |
| 93 | +knowing how the container provided them, and it was more fit for a factory. | |
| 94 | + | |
| 95 | +## Contributors | |
| 96 | + | |
| 97 | +Are listed here all people that contributed in the discussions or votes, by alphabetical order: | |
| 98 | + | |
| 99 | +- [Amy Stephen](https://github.com/AmyStephen) | |
| 100 | +- [David Negrier](https://github.com/moufmouf) | |
| 101 | +- [Don Gilbert](https://github.com/dongilbert) | |
| 102 | +- [Jason Judge](https://github.com/judgej) | |
| 103 | +- [Jeremy Lindblom](https://github.com/jeremeamia) | |
| 104 | +- [Marco Pivetta](https://github.com/Ocramius) | |
| 105 | +- [Matthieu Napoli](https://github.com/mnapoli) | |
| 106 | +- [Paul M. Jones](https://github.com/pmjones) | |
| 107 | +- [Stephan Hochdörfer](https://github.com/shochdoerfer) | |
| 108 | +- [Taylor Otwell](https://github.com/taylorotwell) | |
| 109 | + | |
| 110 | +## Relevant links | |
| 111 | + | |
| 112 | +- [`ContainerInterface.php`](https://github.com/container-interop/container-interop/blob/master/src/Interop/Container/ContainerInterface.php) | |
| 113 | +- [List of all issues](https://github.com/container-interop/container-interop/issues?labels=ContainerInterface&milestone=&page=1&state=closed) | |
| 114 | +- [Vote for the interface name](https://github.com/container-interop/container-interop/wiki/%231-interface-name:-Vote) | ... | ... |
vendor/container-interop/container-interop/docs/ContainerInterface.md
0 → 100644
| 1 | +++ a/vendor/container-interop/container-interop/docs/ContainerInterface.md | |
| ... | ... | @@ -0,0 +1,158 @@ |
| 1 | +Container interface | |
| 2 | +=================== | |
| 3 | + | |
| 4 | +This document describes a common interface for dependency injection containers. | |
| 5 | + | |
| 6 | +The goal set by `ContainerInterface` is to standardize how frameworks and libraries make use of a | |
| 7 | +container to obtain objects and parameters (called *entries* in the rest of this document). | |
| 8 | + | |
| 9 | +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", | |
| 10 | +"SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be | |
| 11 | +interpreted as described in [RFC 2119][]. | |
| 12 | + | |
| 13 | +The word `implementor` in this document is to be interpreted as someone | |
| 14 | +implementing the `ContainerInterface` in a dependency injection-related library or framework. | |
| 15 | +Users of dependency injections containers (DIC) are referred to as `user`. | |
| 16 | + | |
| 17 | +[RFC 2119]: http://tools.ietf.org/html/rfc2119 | |
| 18 | + | |
| 19 | +1. Specification | |
| 20 | +----------------- | |
| 21 | + | |
| 22 | +### 1.1 Basics | |
| 23 | + | |
| 24 | +- The `Interop\Container\ContainerInterface` exposes two methods : `get` and `has`. | |
| 25 | + | |
| 26 | +- `get` takes one mandatory parameter: an entry identifier. It MUST be a string. | |
| 27 | + A call to `get` can return anything (a *mixed* value), or throws an exception if the identifier | |
| 28 | + is not known to the container. Two successive calls to `get` with the same | |
| 29 | + identifier SHOULD return the same value. However, depending on the `implementor` | |
| 30 | + design and/or `user` configuration, different values might be returned, so | |
| 31 | + `user` SHOULD NOT rely on getting the same value on 2 successive calls. | |
| 32 | + While `ContainerInterface` only defines one mandatory parameter in `get()`, implementations | |
| 33 | + MAY accept additional optional parameters. | |
| 34 | + | |
| 35 | +- `has` takes one unique parameter: an entry identifier. It MUST return `true` | |
| 36 | + if an entry identifier is known to the container and `false` if it is not. | |
| 37 | + `has($id)` returning true does not mean that `get($id)` will not throw an exception. | |
| 38 | + It does however mean that `get($id)` will not throw a `NotFoundException`. | |
| 39 | + | |
| 40 | +### 1.2 Exceptions | |
| 41 | + | |
| 42 | +Exceptions directly thrown by the container MUST implement the | |
| 43 | +[`Interop\Container\Exception\ContainerException`](../src/Interop/Container/Exception/ContainerException.php). | |
| 44 | + | |
| 45 | +A call to the `get` method with a non-existing id SHOULD throw a | |
| 46 | +[`Interop\Container\Exception\NotFoundException`](../src/Interop/Container/Exception/NotFoundException.php). | |
| 47 | + | |
| 48 | +### 1.3 Additional features | |
| 49 | + | |
| 50 | +This section describes additional features that MAY be added to a container. Containers are not | |
| 51 | +required to implement these features to respect the ContainerInterface. | |
| 52 | + | |
| 53 | +#### 1.3.1 Delegate lookup feature | |
| 54 | + | |
| 55 | +The goal of the *delegate lookup* feature is to allow several containers to share entries. | |
| 56 | +Containers implementing this feature can perform dependency lookups in other containers. | |
| 57 | + | |
| 58 | +Containers implementing this feature will offer a greater lever of interoperability | |
| 59 | +with other containers. Implementation of this feature is therefore RECOMMENDED. | |
| 60 | + | |
| 61 | +A container implementing this feature: | |
| 62 | + | |
| 63 | +- MUST implement the `ContainerInterface` | |
| 64 | +- MUST provide a way to register a delegate container (using a constructor parameter, or a setter, | |
| 65 | + or any possible way). The delegate container MUST implement the `ContainerInterface`. | |
| 66 | + | |
| 67 | +When a container is configured to use a delegate container for dependencies: | |
| 68 | + | |
| 69 | +- Calls to the `get` method should only return an entry if the entry is part of the container. | |
| 70 | + If the entry is not part of the container, an exception should be thrown | |
| 71 | + (as requested by the `ContainerInterface`). | |
| 72 | +- Calls to the `has` method should only return `true` if the entry is part of the container. | |
| 73 | + If the entry is not part of the container, `false` should be returned. | |
| 74 | +- If the fetched entry has dependencies, **instead** of performing | |
| 75 | + the dependency lookup in the container, the lookup is performed on the *delegate container*. | |
| 76 | + | |
| 77 | +Important! By default, the lookup SHOULD be performed on the delegate container **only**, not on the container itself. | |
| 78 | + | |
| 79 | +It is however allowed for containers to provide exception cases for special entries, and a way to lookup | |
| 80 | +into the same container (or another container) instead of the delegate container. | |
| 81 | + | |
| 82 | +2. Package | |
| 83 | +---------- | |
| 84 | + | |
| 85 | +The interfaces and classes described as well as relevant exception are provided as part of the | |
| 86 | +[container-interop/container-interop](https://packagist.org/packages/container-interop/container-interop) package. | |
| 87 | + | |
| 88 | +3. `Interop\Container\ContainerInterface` | |
| 89 | +----------------------------------------- | |
| 90 | + | |
| 91 | +```php | |
| 92 | +<?php | |
| 93 | +namespace Interop\Container; | |
| 94 | + | |
| 95 | +use Interop\Container\Exception\ContainerException; | |
| 96 | +use Interop\Container\Exception\NotFoundException; | |
| 97 | + | |
| 98 | +/** | |
| 99 | + * Describes the interface of a container that exposes methods to read its entries. | |
| 100 | + */ | |
| 101 | +interface ContainerInterface | |
| 102 | +{ | |
| 103 | + /** | |
| 104 | + * Finds an entry of the container by its identifier and returns it. | |
| 105 | + * | |
| 106 | + * @param string $id Identifier of the entry to look for. | |
| 107 | + * | |
| 108 | + * @throws NotFoundException No entry was found for this identifier. | |
| 109 | + * @throws ContainerException Error while retrieving the entry. | |
| 110 | + * | |
| 111 | + * @return mixed Entry. | |
| 112 | + */ | |
| 113 | + public function get($id); | |
| 114 | + | |
| 115 | + /** | |
| 116 | + * Returns true if the container can return an entry for the given identifier. | |
| 117 | + * Returns false otherwise. | |
| 118 | + * | |
| 119 | + * `has($id)` returning true does not mean that `get($id)` will not throw an exception. | |
| 120 | + * It does however mean that `get($id)` will not throw a `NotFoundException`. | |
| 121 | + * | |
| 122 | + * @param string $id Identifier of the entry to look for. | |
| 123 | + * | |
| 124 | + * @return boolean | |
| 125 | + */ | |
| 126 | + public function has($id); | |
| 127 | +} | |
| 128 | +``` | |
| 129 | + | |
| 130 | +4. `Interop\Container\Exception\ContainerException` | |
| 131 | +--------------------------------------------------- | |
| 132 | + | |
| 133 | +```php | |
| 134 | +<?php | |
| 135 | +namespace Interop\Container\Exception; | |
| 136 | + | |
| 137 | +/** | |
| 138 | + * Base interface representing a generic exception in a container. | |
| 139 | + */ | |
| 140 | +interface ContainerException | |
| 141 | +{ | |
| 142 | +} | |
| 143 | +``` | |
| 144 | + | |
| 145 | +5. `Interop\Container\Exception\NotFoundException` | |
| 146 | +--------------------------------------------------- | |
| 147 | + | |
| 148 | +```php | |
| 149 | +<?php | |
| 150 | +namespace Interop\Container\Exception; | |
| 151 | + | |
| 152 | +/** | |
| 153 | + * No entry was found in the container. | |
| 154 | + */ | |
| 155 | +interface NotFoundException extends ContainerException | |
| 156 | +{ | |
| 157 | +} | |
| 158 | +``` | ... | ... |
vendor/container-interop/container-interop/docs/Delegate-lookup-meta.md
0 → 100644
| 1 | +++ a/vendor/container-interop/container-interop/docs/Delegate-lookup-meta.md | |
| ... | ... | @@ -0,0 +1,259 @@ |
| 1 | +Delegate lookup feature Meta Document | |
| 2 | +===================================== | |
| 3 | + | |
| 4 | +1. Summary | |
| 5 | +---------- | |
| 6 | + | |
| 7 | +This document describes the *delegate lookup feature*. | |
| 8 | +Containers are not required to implement this feature to respect the `ContainerInterface`. | |
| 9 | +However, containers implementing this feature will offer a greater lever of interoperability | |
| 10 | +with other containers, allowing multiple containers to share entries in the same application. | |
| 11 | +Implementation of this feature is therefore recommanded. | |
| 12 | + | |
| 13 | +2. Why Bother? | |
| 14 | +-------------- | |
| 15 | + | |
| 16 | +The [`ContainerInterface`](../src/Interop/Container/ContainerInterface.php) ([meta doc](ContainerInterface.md)) | |
| 17 | +standardizes how frameworks and libraries make use of a container to obtain objects and parameters. | |
| 18 | + | |
| 19 | +By standardizing such a behavior, frameworks and libraries relying on the `ContainerInterface` | |
| 20 | +could work with any compatible container. | |
| 21 | +That would allow end users to choose their own container based on their own preferences. | |
| 22 | + | |
| 23 | +The `ContainerInterface` is also enough if we want to have several containers side-by-side in the same | |
| 24 | +application. For instance, this is what the [CompositeContainer](https://github.com/jeremeamia/acclimate-container/blob/master/src/CompositeContainer.php) | |
| 25 | +class of [Acclimate](https://github.com/jeremeamia/acclimate-container) is designed for: | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | +However, an instance in container 1 cannot reference an instance in container 2. | |
| 30 | + | |
| 31 | +It would be better if an instance of container 1 could reference an instance in container 2, | |
| 32 | +and the opposite should be true. | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | +In the sample above, entry 1 in container 1 is referencing entry 3 in container 2. | |
| 37 | + | |
| 38 | +3. Scope | |
| 39 | +-------- | |
| 40 | + | |
| 41 | +### 3.1 Goals | |
| 42 | + | |
| 43 | +The goal of the *delegate lookup* feature is to allow several containers to share entries. | |
| 44 | + | |
| 45 | +4. Approaches | |
| 46 | +------------- | |
| 47 | + | |
| 48 | +### 4.1 Chosen Approach | |
| 49 | + | |
| 50 | +Containers implementing this feature can perform dependency lookups in other containers. | |
| 51 | + | |
| 52 | +A container implementing this feature: | |
| 53 | + | |
| 54 | +- must implement the `ContainerInterface` | |
| 55 | +- must provide a way to register a *delegate container* (using a constructor parameter, or a setter, or any | |
| 56 | +possible way). The *delegate container* must implement the `ContainerInterface`. | |
| 57 | + | |
| 58 | +When a *delegate container* is configured on a container: | |
| 59 | + | |
| 60 | +- Calls to the `get` method should only return an entry if the entry is part of the container. | |
| 61 | +If the entry is not part of the container, an exception should be thrown (as required in the `ContainerInterface`). | |
| 62 | +- Calls to the `has` method should only return *true* if the entry is part of the container. | |
| 63 | +If the entry is not part of the container, *false* should be returned. | |
| 64 | + - Finally, the important part: if the entry we are fetching has dependencies, | |
| 65 | +**instead** of perfoming the dependency lookup in the container, the lookup is performed on the *delegate container*. | |
| 66 | + | |
| 67 | +Important! By default, the lookup should be performed on the delegate container **only**, not on the container itself. | |
| 68 | + | |
| 69 | +It is however allowed for containers to provide exception cases for special entries, and a way to lookup into | |
| 70 | +the same container (or another container) instead of the delegate container. | |
| 71 | + | |
| 72 | +### 4.2 Typical usage | |
| 73 | + | |
| 74 | +The *delegate container* will usually be a composite container. A composite container is a container that | |
| 75 | +contains several other containers. When performing a lookup on a composite container, the inner containers are | |
| 76 | +queried until one container returns an entry. | |
| 77 | +An inner container implementing the *delegate lookup feature* will return entries it contains, but if these | |
| 78 | +entries have dependencies, the dependencies lookup calls will be performed on the composite container, giving | |
| 79 | +a chance to all containers to answer. | |
| 80 | + | |
| 81 | +Interestingly enough, the order in which containers are added in the composite container matters. Indeed, | |
| 82 | +the first containers to be added in the composite container can "override" the entries of containers with | |
| 83 | +lower priority. | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | +In the example above, "container 2" contains a controller "myController" and the controller is referencing an | |
| 88 | +"entityManager" entry. "Container 1" contains also an entry named "entityManager". | |
| 89 | +Without the *delegate lookup* feature, when requesting the "myController" instance to container 2, it would take | |
| 90 | +in charge the instanciation of both entries. | |
| 91 | + | |
| 92 | +However, using the *delegate lookup* feature, here is what happens when we ask the composite container for the | |
| 93 | +"myController" instance: | |
| 94 | + | |
| 95 | +- The composite container asks container 1 if if contains the "myController" instance. The answer is no. | |
| 96 | +- The composite container asks container 2 if if contains the "myController" instance. The answer is yes. | |
| 97 | +- The composite container performs a `get` call on container 2 for the "myController" instance. | |
| 98 | +- Container 2 sees that "myController" has a dependency on "entityManager". | |
| 99 | +- Container 2 delegates the lookup of "entityManager" to the composite container. | |
| 100 | +- The composite container asks container 1 if if contains the "entityManager" instance. The answer is yes. | |
| 101 | +- The composite container performs a `get` call on container 1 for the "entityManager" instance. | |
| 102 | + | |
| 103 | +In the end, we get a controller instanciated by container 2 that references an entityManager instanciated | |
| 104 | +by container 1. | |
| 105 | + | |
| 106 | +### 4.3 Alternative: the fallback strategy | |
| 107 | + | |
| 108 | +The first proposed approach we tried was to perform all the lookups in the "local" container, | |
| 109 | +and if a lookup fails in the container, to use the delegate container. In this scenario, the | |
| 110 | +delegate container is used in "fallback" mode. | |
| 111 | + | |
| 112 | +This strategy has been described in @moufmouf blog post: http://mouf-php.com/container-interop-whats-next (solution 1). | |
| 113 | +It was also discussed [here](https://github.com/container-interop/container-interop/pull/8#issuecomment-33570697) and | |
| 114 | +[here](https://github.com/container-interop/container-interop/pull/20#issuecomment-56599631). | |
| 115 | + | |
| 116 | +Problems with this strategy: | |
| 117 | + | |
| 118 | +- Heavy problem regarding infinite loops | |
| 119 | +- Unable to overload a container entry with the delegate container entry | |
| 120 | + | |
| 121 | +### 4.4 Alternative: force implementing an interface | |
| 122 | + | |
| 123 | +The first proposed approach was to develop a `ParentAwareContainerInterface` interface. | |
| 124 | +It was proposed here: https://github.com/container-interop/container-interop/pull/8 | |
| 125 | + | |
| 126 | +The interface would have had the behaviour of the delegate lookup feature but would have forced the addition of | |
| 127 | +a `setParentContainter` method: | |
| 128 | + | |
| 129 | +```php | |
| 130 | +interface ParentAwareContainerInterface extends ReadableContainerInterface { | |
| 131 | + /** | |
| 132 | + * Sets the parent container associated to that container. This container will call | |
| 133 | + * the parent container to fetch dependencies. | |
| 134 | + * | |
| 135 | + * @param ContainerInterface $container | |
| 136 | + */ | |
| 137 | + public function setParentContainer(ContainerInterface $container); | |
| 138 | +} | |
| 139 | +``` | |
| 140 | + | |
| 141 | +The interface idea was first questioned by @Ocramius [here](https://github.com/container-interop/container-interop/pull/8#issuecomment-51721777). | |
| 142 | +@Ocramius expressed the idea that an interface should not contain setters, otherwise, it is forcing implementation | |
| 143 | +details on the class implementing the interface. | |
| 144 | +Then @mnapoli made a proposal for a "convention" [here](https://github.com/container-interop/container-interop/pull/8#issuecomment-51841079), | |
| 145 | +this idea was further discussed until all participants in the discussion agreed to remove the interface idea | |
| 146 | +and replace it with a "standard" feature. | |
| 147 | + | |
| 148 | +**Pros:** | |
| 149 | + | |
| 150 | +If we had had an interface, we could have delegated the registration of the delegate/composite container to the | |
| 151 | +the delegate/composite container itself. | |
| 152 | +For instance: | |
| 153 | + | |
| 154 | +```php | |
| 155 | +$containerA = new ContainerA(); | |
| 156 | +$containerB = new ContainerB(); | |
| 157 | + | |
| 158 | +$compositeContainer = new CompositeContainer([$containerA, $containerB]); | |
| 159 | + | |
| 160 | +// The call to 'setParentContainer' is delegated to the CompositeContainer | |
| 161 | +// It is not the responsibility of the user anymore. | |
| 162 | +class CompositeContainer { | |
| 163 | + ... | |
| 164 | + | |
| 165 | + public function __construct($containers) { | |
| 166 | + foreach ($containers as $container) { | |
| 167 | + if ($container instanceof ParentAwareContainerInterface) { | |
| 168 | + $container->setParentContainer($this); | |
| 169 | + } | |
| 170 | + } | |
| 171 | + ... | |
| 172 | + } | |
| 173 | +} | |
| 174 | + | |
| 175 | +``` | |
| 176 | + | |
| 177 | +**Cons:** | |
| 178 | + | |
| 179 | +Cons have been extensively discussed [here](https://github.com/container-interop/container-interop/pull/8#issuecomment-51721777). | |
| 180 | +Basically, forcing a setter into an interface is a bad idea. Setters are similar to constructor arguments, | |
| 181 | +and it's a bad idea to standardize a constructor: how the delegate container is configured into a container is an implementation detail. This outweights the benefits of the interface. | |
| 182 | + | |
| 183 | +### 4.4 Alternative: no exception case for delegate lookups | |
| 184 | + | |
| 185 | +Originally, the proposed wording for delegate lookup calls was: | |
| 186 | + | |
| 187 | +> Important! The lookup MUST be performed on the delegate container **only**, not on the container itself. | |
| 188 | + | |
| 189 | +This was later replaced by: | |
| 190 | + | |
| 191 | +> Important! By default, the lookup SHOULD be performed on the delegate container **only**, not on the container itself. | |
| 192 | +> | |
| 193 | +> It is however allowed for containers to provide exception cases for special entries, and a way to lookup | |
| 194 | +> into the same container (or another container) instead of the delegate container. | |
| 195 | + | |
| 196 | +Exception cases have been allowed to avoid breaking dependencies with some services that must be provided | |
| 197 | +by the container (on @njasm proposal). This was proposed here: https://github.com/container-interop/container-interop/pull/20#issuecomment-56597235 | |
| 198 | + | |
| 199 | +### 4.5 Alternative: having one of the containers act as the composite container | |
| 200 | + | |
| 201 | +In real-life scenarios, we usually have a big framework (Symfony 2, Zend Framework 2, etc...) and we want to | |
| 202 | +add another DI container to this container. Most of the time, the "big" framework will be responsible for | |
| 203 | +creating the controller's instances, using it's own DI container. Until *container-interop* is fully adopted, | |
| 204 | +the "big" framework will not be aware of the existence of a composite container that it should use instead | |
| 205 | +of its own container. | |
| 206 | + | |
| 207 | +For this real-life use cases, @mnapoli and @moufmouf proposed to extend the "big" framework's DI container | |
| 208 | +to make it act as a composite container. | |
| 209 | + | |
| 210 | +This has been discussed [here](https://github.com/container-interop/container-interop/pull/8#issuecomment-40367194) | |
| 211 | +and [here](http://mouf-php.com/container-interop-whats-next#solution4). | |
| 212 | + | |
| 213 | +This was implemented in Symfony 2 using: | |
| 214 | + | |
| 215 | +- [interop.symfony.di](https://github.com/thecodingmachine/interop.symfony.di/tree/v0.1.0) | |
| 216 | +- [framework interop](https://github.com/mnapoli/framework-interop/) | |
| 217 | + | |
| 218 | +This was implemented in Silex using: | |
| 219 | + | |
| 220 | +- [interop.silex.di](https://github.com/thecodingmachine/interop.silex.di) | |
| 221 | + | |
| 222 | +Having a container act as the composite container is not part of the delegate lookup standard because it is | |
| 223 | +simply a temporary design pattern used to make existing frameworks that do not support yet ContainerInterop | |
| 224 | +play nice with other DI containers. | |
| 225 | + | |
| 226 | + | |
| 227 | +5. Implementations | |
| 228 | +------------------ | |
| 229 | + | |
| 230 | +The following projects already implement the delegate lookup feature: | |
| 231 | + | |
| 232 | +- [Mouf](http://mouf-php.com), through the [`setDelegateLookupContainer` method](https://github.com/thecodingmachine/mouf/blob/2.0/src/Mouf/MoufManager.php#L2120) | |
| 233 | +- [PHP-DI](http://php-di.org/), through the [`$wrapperContainer` parameter of the constructor](https://github.com/mnapoli/PHP-DI/blob/master/src/DI/Container.php#L72) | |
| 234 | +- [pimple-interop](https://github.com/moufmouf/pimple-interop), through the [`$container` parameter of the constructor](https://github.com/moufmouf/pimple-interop/blob/master/src/Interop/Container/Pimple/PimpleInterop.php#L62) | |
| 235 | + | |
| 236 | +6. People | |
| 237 | +--------- | |
| 238 | + | |
| 239 | +Are listed here all people that contributed in the discussions, by alphabetical order: | |
| 240 | + | |
| 241 | +- [Alexandru Pătrănescu](https://github.com/drealecs) | |
| 242 | +- [Ben Peachey](https://github.com/potherca) | |
| 243 | +- [David Negrier](https://github.com/moufmouf) | |
| 244 | +- [Jeremy Lindblom](https://github.com/jeremeamia) | |
| 245 | +- [Marco Pivetta](https://github.com/Ocramius) | |
| 246 | +- [Matthieu Napoli](https://github.com/mnapoli) | |
| 247 | +- [Nelson J Morais](https://github.com/njasm) | |
| 248 | +- [Phil Sturgeon](https://github.com/philsturgeon) | |
| 249 | +- [Stephan Hochdörfer](https://github.com/shochdoerfer) | |
| 250 | + | |
| 251 | +7. Relevant Links | |
| 252 | +----------------- | |
| 253 | + | |
| 254 | +_**Note:** Order descending chronologically._ | |
| 255 | + | |
| 256 | +- [Pull request on the delegate lookup feature](https://github.com/container-interop/container-interop/pull/20) | |
| 257 | +- [Pull request on the interface idea](https://github.com/container-interop/container-interop/pull/8) | |
| 258 | +- [Original article exposing the delegate lookup idea along many others](http://mouf-php.com/container-interop-whats-next) | |
| 259 | + | ... | ... |
vendor/container-interop/container-interop/docs/Delegate-lookup.md
0 → 100644
| 1 | +++ a/vendor/container-interop/container-interop/docs/Delegate-lookup.md | |
| ... | ... | @@ -0,0 +1,60 @@ |
| 1 | +Delegate lookup feature | |
| 2 | +======================= | |
| 3 | + | |
| 4 | +This document describes a standard for dependency injection containers. | |
| 5 | + | |
| 6 | +The goal set by the *delegate lookup* feature is to allow several containers to share entries. | |
| 7 | +Containers implementing this feature can perform dependency lookups in other containers. | |
| 8 | + | |
| 9 | +Containers implementing this feature will offer a greater lever of interoperability | |
| 10 | +with other containers. Implementation of this feature is therefore RECOMMENDED. | |
| 11 | + | |
| 12 | +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", | |
| 13 | +"SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be | |
| 14 | +interpreted as described in [RFC 2119][]. | |
| 15 | + | |
| 16 | +The word `implementor` in this document is to be interpreted as someone | |
| 17 | +implementing the delegate lookup feature in a dependency injection-related library or framework. | |
| 18 | +Users of dependency injections containers (DIC) are referred to as `user`. | |
| 19 | + | |
| 20 | +[RFC 2119]: http://tools.ietf.org/html/rfc2119 | |
| 21 | + | |
| 22 | +1. Vocabulary | |
| 23 | +------------- | |
| 24 | + | |
| 25 | +In a dependency injection container, the container is used to fetch entries. | |
| 26 | +Entries can have dependencies on other entries. Usually, these other entries are fetched by the container. | |
| 27 | + | |
| 28 | +The *delegate lookup* feature is the ability for a container to fetch dependencies in | |
| 29 | +another container. In the rest of the document, the word "container" will reference the container | |
| 30 | +implemented by the implementor. The word "delegate container" will reference the container we are | |
| 31 | +fetching the dependencies from. | |
| 32 | + | |
| 33 | +2. Specification | |
| 34 | +---------------- | |
| 35 | + | |
| 36 | +A container implementing the *delegate lookup* feature: | |
| 37 | + | |
| 38 | +- MUST implement the [`ContainerInterface`](ContainerInterface.md) | |
| 39 | +- MUST provide a way to register a delegate container (using a constructor parameter, or a setter, | |
| 40 | + or any possible way). The delegate container MUST implement the [`ContainerInterface`](ContainerInterface.md). | |
| 41 | + | |
| 42 | +When a container is configured to use a delegate container for dependencies: | |
| 43 | + | |
| 44 | +- Calls to the `get` method should only return an entry if the entry is part of the container. | |
| 45 | + If the entry is not part of the container, an exception should be thrown | |
| 46 | + (as requested by the [`ContainerInterface`](ContainerInterface.md)). | |
| 47 | +- Calls to the `has` method should only return `true` if the entry is part of the container. | |
| 48 | + If the entry is not part of the container, `false` should be returned. | |
| 49 | +- If the fetched entry has dependencies, **instead** of performing | |
| 50 | + the dependency lookup in the container, the lookup is performed on the *delegate container*. | |
| 51 | + | |
| 52 | +Important: By default, the dependency lookups SHOULD be performed on the delegate container **only**, not on the container itself. | |
| 53 | + | |
| 54 | +It is however allowed for containers to provide exception cases for special entries, and a way to lookup | |
| 55 | +into the same container (or another container) instead of the delegate container. | |
| 56 | + | |
| 57 | +3. Package / Interface | |
| 58 | +---------------------- | |
| 59 | + | |
| 60 | +This feature is not tied to any code, interface or package. | ... | ... |
vendor/container-interop/container-interop/docs/images/interoperating_containers.png
0 → 100644
25.1 KB
15.9 KB
vendor/container-interop/container-interop/docs/images/side_by_side_containers.png
0 → 100644
15.9 KB
vendor/container-interop/container-interop/src/Interop/Container/ContainerInterface.php
0 → 100644
| 1 | +++ a/vendor/container-interop/container-interop/src/Interop/Container/ContainerInterface.php | |
| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file) | |
| 4 | + */ | |
| 5 | + | |
| 6 | +namespace Interop\Container; | |
| 7 | + | |
| 8 | +use Psr\Container\ContainerInterface as PsrContainerInterface; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * Describes the interface of a container that exposes methods to read its entries. | |
| 12 | + */ | |
| 13 | +interface ContainerInterface extends PsrContainerInterface | |
| 14 | +{ | |
| 15 | +} | ... | ... |
vendor/container-interop/container-interop/src/Interop/Container/Exception/ContainerException.php
0 → 100644
| 1 | +++ a/vendor/container-interop/container-interop/src/Interop/Container/Exception/ContainerException.php | |
| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file) | |
| 4 | + */ | |
| 5 | + | |
| 6 | +namespace Interop\Container\Exception; | |
| 7 | + | |
| 8 | +use Psr\Container\ContainerExceptionInterface as PsrContainerException; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * Base interface representing a generic exception in a container. | |
| 12 | + */ | |
| 13 | +interface ContainerException extends PsrContainerException | |
| 14 | +{ | |
| 15 | +} | ... | ... |
vendor/container-interop/container-interop/src/Interop/Container/Exception/NotFoundException.php
0 → 100644
| 1 | +++ a/vendor/container-interop/container-interop/src/Interop/Container/Exception/NotFoundException.php | |
| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file) | |
| 4 | + */ | |
| 5 | + | |
| 6 | +namespace Interop\Container\Exception; | |
| 7 | + | |
| 8 | +use Psr\Container\NotFoundExceptionInterface as PsrNotFoundException; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * No entry was found in the container. | |
| 12 | + */ | |
| 13 | +interface NotFoundException extends ContainerException, PsrNotFoundException | |
| 14 | +{ | |
| 15 | +} | ... | ... |
| 1 | +++ a/vendor/nikic/fast-route/FastRoute.hhi | |
| ... | ... | @@ -0,0 +1,126 @@ |
| 1 | +<?hh // decl | |
| 2 | + | |
| 3 | +namespace FastRoute { | |
| 4 | + class BadRouteException extends \LogicException { | |
| 5 | + } | |
| 6 | + | |
| 7 | + interface RouteParser { | |
| 8 | + public function parse(string $route): array<array>; | |
| 9 | + } | |
| 10 | + | |
| 11 | + class RouteCollector { | |
| 12 | + public function __construct(RouteParser $routeParser, DataGenerator $dataGenerator); | |
| 13 | + public function addRoute(mixed $httpMethod, string $route, mixed $handler): void; | |
| 14 | + public function getData(): array; | |
| 15 | + } | |
| 16 | + | |
| 17 | + class Route { | |
| 18 | + public function __construct(string $httpMethod, mixed $handler, string $regex, array $variables); | |
| 19 | + public function matches(string $str): bool; | |
| 20 | + } | |
| 21 | + | |
| 22 | + interface DataGenerator { | |
| 23 | + public function addRoute(string $httpMethod, array $routeData, mixed $handler); | |
| 24 | + public function getData(): array; | |
| 25 | + } | |
| 26 | + | |
| 27 | + interface Dispatcher { | |
| 28 | + const int NOT_FOUND = 0; | |
| 29 | + const int FOUND = 1; | |
| 30 | + const int METHOD_NOT_ALLOWED = 2; | |
| 31 | + public function dispatch(string $httpMethod, string $uri): array; | |
| 32 | + } | |
| 33 | + | |
| 34 | + function simpleDispatcher( | |
| 35 | + (function(RouteCollector): void) $routeDefinitionCallback, | |
| 36 | + shape( | |
| 37 | + 'routeParser' => ?classname<RouteParser>, | |
| 38 | + 'dataGenerator' => ?classname<DataGenerator>, | |
| 39 | + 'dispatcher' => ?classname<Dispatcher>, | |
| 40 | + 'routeCollector' => ?classname<RouteCollector>, | |
| 41 | + ) $options = shape()): Dispatcher; | |
| 42 | + | |
| 43 | + function cachedDispatcher( | |
| 44 | + (function(RouteCollector): void) $routeDefinitionCallback, | |
| 45 | + shape( | |
| 46 | + 'routeParser' => ?classname<RouteParser>, | |
| 47 | + 'dataGenerator' => ?classname<DataGenerator>, | |
| 48 | + 'dispatcher' => ?classname<Dispatcher>, | |
| 49 | + 'routeCollector' => ?classname<RouteCollector>, | |
| 50 | + 'cacheDisabled' => ?bool, | |
| 51 | + 'cacheFile' => ?string, | |
| 52 | + ) $options = shape()): Dispatcher; | |
| 53 | +} | |
| 54 | + | |
| 55 | +namespace FastRoute\DataGenerator { | |
| 56 | + abstract class RegexBasedAbstract implements \FastRoute\DataGenerator { | |
| 57 | + protected abstract function getApproxChunkSize(); | |
| 58 | + protected abstract function processChunk($regexToRoutesMap); | |
| 59 | + | |
| 60 | + public function addRoute(string $httpMethod, array $routeData, mixed $handler): void; | |
| 61 | + public function getData(): array; | |
| 62 | + } | |
| 63 | + | |
| 64 | + class CharCountBased extends RegexBasedAbstract { | |
| 65 | + protected function getApproxChunkSize(): int; | |
| 66 | + protected function processChunk(array<string, string> $regexToRoutesMap): array<string, mixed>; | |
| 67 | + } | |
| 68 | + | |
| 69 | + class GroupCountBased extends RegexBasedAbstract { | |
| 70 | + protected function getApproxChunkSize(): int; | |
| 71 | + protected function processChunk(array<string, string> $regexToRoutesMap): array<string, mixed>; | |
| 72 | + } | |
| 73 | + | |
| 74 | + class GroupPosBased extends RegexBasedAbstract { | |
| 75 | + protected function getApproxChunkSize(): int; | |
| 76 | + protected function processChunk(array<string, string> $regexToRoutesMap): array<string, mixed>; | |
| 77 | + } | |
| 78 | + | |
| 79 | + class MarkBased extends RegexBasedAbstract { | |
| 80 | + protected function getApproxChunkSize(): int; | |
| 81 | + protected function processChunk(array<string, string> $regexToRoutesMap): array<string, mixed>; | |
| 82 | + } | |
| 83 | +} | |
| 84 | + | |
| 85 | +namespace FastRoute\Dispatcher { | |
| 86 | + abstract class RegexBasedAbstract implements \FastRoute\Dispatcher { | |
| 87 | + protected abstract function dispatchVariableRoute(array<array> $routeData, string $uri): array; | |
| 88 | + | |
| 89 | + public function dispatch(string $httpMethod, string $uri): array; | |
| 90 | + } | |
| 91 | + | |
| 92 | + class GroupPosBased extends RegexBasedAbstract { | |
| 93 | + public function __construct(array $data); | |
| 94 | + protected function dispatchVariableRoute(array<array> $routeData, string $uri): array; | |
| 95 | + } | |
| 96 | + | |
| 97 | + class GroupCountBased extends RegexBasedAbstract { | |
| 98 | + public function __construct(array $data); | |
| 99 | + protected function dispatchVariableRoute(array<array> $routeData, string $uri): array; | |
| 100 | + } | |
| 101 | + | |
| 102 | + class CharCountBased extends RegexBasedAbstract { | |
| 103 | + public function __construct(array $data); | |
| 104 | + protected function dispatchVariableRoute(array<array> $routeData, string $uri): array; | |
| 105 | + } | |
| 106 | + | |
| 107 | + class MarkBased extends RegexBasedAbstract { | |
| 108 | + public function __construct(array $data); | |
| 109 | + protected function dispatchVariableRoute(array<array> $routeData, string $uri): array; | |
| 110 | + } | |
| 111 | +} | |
| 112 | + | |
| 113 | +namespace FastRoute\RouteParser { | |
| 114 | + class Std implements \FastRoute\RouteParser { | |
| 115 | + const string VARIABLE_REGEX = <<<'REGEX' | |
| 116 | +\{ | |
| 117 | + \s* ([a-zA-Z][a-zA-Z0-9_]*) \s* | |
| 118 | + (?: | |
| 119 | + : \s* ([^{}]*(?:\{(?-1)\}[^{}]*)*) | |
| 120 | + )? | |
| 121 | +\} | |
| 122 | +REGEX; | |
| 123 | + const string DEFAULT_DISPATCH_REGEX = '[^/]+'; | |
| 124 | + public function parse(string $route): array<array>; | |
| 125 | + } | |
| 126 | +} | ... | ... |
| 1 | +++ a/vendor/nikic/fast-route/LICENSE | |
| ... | ... | @@ -0,0 +1,31 @@ |
| 1 | +Copyright (c) 2013 by Nikita Popov. | |
| 2 | + | |
| 3 | +Some rights reserved. | |
| 4 | + | |
| 5 | +Redistribution and use in source and binary forms, with or without | |
| 6 | +modification, are permitted provided that the following conditions are | |
| 7 | +met: | |
| 8 | + | |
| 9 | + * Redistributions of source code must retain the above copyright | |
| 10 | + notice, this list of conditions and the following disclaimer. | |
| 11 | + | |
| 12 | + * Redistributions in binary form must reproduce the above | |
| 13 | + copyright notice, this list of conditions and the following | |
| 14 | + disclaimer in the documentation and/or other materials provided | |
| 15 | + with the distribution. | |
| 16 | + | |
| 17 | + * The names of the contributors may not be used to endorse or | |
| 18 | + promote products derived from this software without specific | |
| 19 | + prior written permission. | |
| 20 | + | |
| 21 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 22 | +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 23 | +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 24 | +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 25 | +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 26 | +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 27 | +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 28 | +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 29 | +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 30 | +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 31 | +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ... | ... |
| 1 | +++ a/vendor/nikic/fast-route/README.md | |
| ... | ... | @@ -0,0 +1,313 @@ |
| 1 | +FastRoute - Fast request router for PHP | |
| 2 | +======================================= | |
| 3 | + | |
| 4 | +This library provides a fast implementation of a regular expression based router. [Blog post explaining how the | |
| 5 | +implementation works and why it is fast.][blog_post] | |
| 6 | + | |
| 7 | +Install | |
| 8 | +------- | |
| 9 | + | |
| 10 | +To install with composer: | |
| 11 | + | |
| 12 | +```sh | |
| 13 | +composer require nikic/fast-route | |
| 14 | +``` | |
| 15 | + | |
| 16 | +Requires PHP 5.4 or newer. | |
| 17 | + | |
| 18 | +Usage | |
| 19 | +----- | |
| 20 | + | |
| 21 | +Here's a basic usage example: | |
| 22 | + | |
| 23 | +```php | |
| 24 | +<?php | |
| 25 | + | |
| 26 | +require '/path/to/vendor/autoload.php'; | |
| 27 | + | |
| 28 | +$dispatcher = FastRoute\simpleDispatcher(function(FastRoute\RouteCollector $r) { | |
| 29 | + $r->addRoute('GET', '/users', 'get_all_users_handler'); | |
| 30 | + // {id} must be a number (\d+) | |
| 31 | + $r->addRoute('GET', '/user/{id:\d+}', 'get_user_handler'); | |
| 32 | + // The /{title} suffix is optional | |
| 33 | + $r->addRoute('GET', '/articles/{id:\d+}[/{title}]', 'get_article_handler'); | |
| 34 | +}); | |
| 35 | + | |
| 36 | +// Fetch method and URI from somewhere | |
| 37 | +$httpMethod = $_SERVER['REQUEST_METHOD']; | |
| 38 | +$uri = $_SERVER['REQUEST_URI']; | |
| 39 | + | |
| 40 | +// Strip query string (?foo=bar) and decode URI | |
| 41 | +if (false !== $pos = strpos($uri, '?')) { | |
| 42 | + $uri = substr($uri, 0, $pos); | |
| 43 | +} | |
| 44 | +$uri = rawurldecode($uri); | |
| 45 | + | |
| 46 | +$routeInfo = $dispatcher->dispatch($httpMethod, $uri); | |
| 47 | +switch ($routeInfo[0]) { | |
| 48 | + case FastRoute\Dispatcher::NOT_FOUND: | |
| 49 | + // ... 404 Not Found | |
| 50 | + break; | |
| 51 | + case FastRoute\Dispatcher::METHOD_NOT_ALLOWED: | |
| 52 | + $allowedMethods = $routeInfo[1]; | |
| 53 | + // ... 405 Method Not Allowed | |
| 54 | + break; | |
| 55 | + case FastRoute\Dispatcher::FOUND: | |
| 56 | + $handler = $routeInfo[1]; | |
| 57 | + $vars = $routeInfo[2]; | |
| 58 | + // ... call $handler with $vars | |
| 59 | + break; | |
| 60 | +} | |
| 61 | +``` | |
| 62 | + | |
| 63 | +### Defining routes | |
| 64 | + | |
| 65 | +The routes are defined by calling the `FastRoute\simpleDispatcher()` function, which accepts | |
| 66 | +a callable taking a `FastRoute\RouteCollector` instance. The routes are added by calling | |
| 67 | +`addRoute()` on the collector instance: | |
| 68 | + | |
| 69 | +```php | |
| 70 | +$r->addRoute($method, $routePattern, $handler); | |
| 71 | +``` | |
| 72 | + | |
| 73 | +The `$method` is an uppercase HTTP method string for which a certain route should match. It | |
| 74 | +is possible to specify multiple valid methods using an array: | |
| 75 | + | |
| 76 | +```php | |
| 77 | +// These two calls | |
| 78 | +$r->addRoute('GET', '/test', 'handler'); | |
| 79 | +$r->addRoute('POST', '/test', 'handler'); | |
| 80 | +// Are equivalent to this one call | |
| 81 | +$r->addRoute(['GET', 'POST'], '/test', 'handler'); | |
| 82 | +``` | |
| 83 | + | |
| 84 | +By default the `$routePattern` uses a syntax where `{foo}` specifies a placeholder with name `foo` | |
| 85 | +and matching the regex `[^/]+`. To adjust the pattern the placeholder matches, you can specify | |
| 86 | +a custom pattern by writing `{bar:[0-9]+}`. Some examples: | |
| 87 | + | |
| 88 | +```php | |
| 89 | +// Matches /user/42, but not /user/xyz | |
| 90 | +$r->addRoute('GET', '/user/{id:\d+}', 'handler'); | |
| 91 | + | |
| 92 | +// Matches /user/foobar, but not /user/foo/bar | |
| 93 | +$r->addRoute('GET', '/user/{name}', 'handler'); | |
| 94 | + | |
| 95 | +// Matches /user/foo/bar as well | |
| 96 | +$r->addRoute('GET', '/user/{name:.+}', 'handler'); | |
| 97 | +``` | |
| 98 | + | |
| 99 | +Custom patterns for route placeholders cannot use capturing groups. For example `{lang:(en|de)}` | |
| 100 | +is not a valid placeholder, because `()` is a capturing group. Instead you can use either | |
| 101 | +`{lang:en|de}` or `{lang:(?:en|de)}`. | |
| 102 | + | |
| 103 | +Furthermore parts of the route enclosed in `[...]` are considered optional, so that `/foo[bar]` | |
| 104 | +will match both `/foo` and `/foobar`. Optional parts are only supported in a trailing position, | |
| 105 | +not in the middle of a route. | |
| 106 | + | |
| 107 | +```php | |
| 108 | +// This route | |
| 109 | +$r->addRoute('GET', '/user/{id:\d+}[/{name}]', 'handler'); | |
| 110 | +// Is equivalent to these two routes | |
| 111 | +$r->addRoute('GET', '/user/{id:\d+}', 'handler'); | |
| 112 | +$r->addRoute('GET', '/user/{id:\d+}/{name}', 'handler'); | |
| 113 | + | |
| 114 | +// Multiple nested optional parts are possible as well | |
| 115 | +$r->addRoute('GET', '/user[/{id:\d+}[/{name}]]', 'handler'); | |
| 116 | + | |
| 117 | +// This route is NOT valid, because optional parts can only occur at the end | |
| 118 | +$r->addRoute('GET', '/user[/{id:\d+}]/{name}', 'handler'); | |
| 119 | +``` | |
| 120 | + | |
| 121 | +The `$handler` parameter does not necessarily have to be a callback, it could also be a controller | |
| 122 | +class name or any other kind of data you wish to associate with the route. FastRoute only tells you | |
| 123 | +which handler corresponds to your URI, how you interpret it is up to you. | |
| 124 | + | |
| 125 | +#### Shorcut methods for common request methods | |
| 126 | + | |
| 127 | +For the `GET`, `POST`, `PUT`, `PATCH`, `DELETE` and `HEAD` request methods shortcut methods are available. For example: | |
| 128 | + | |
| 129 | +```php | |
| 130 | +$r->get('/get-route', 'get_handler'); | |
| 131 | +$r->post('/post-route', 'post_handler'); | |
| 132 | +``` | |
| 133 | + | |
| 134 | +Is equivalent to: | |
| 135 | + | |
| 136 | +```php | |
| 137 | +$r->addRoute('GET', '/get-route', 'get_handler'); | |
| 138 | +$r->addRoute('POST', '/post-route', 'post_handler'); | |
| 139 | +``` | |
| 140 | + | |
| 141 | +#### Route Groups | |
| 142 | + | |
| 143 | +Additionally, you can specify routes inside of a group. All routes defined inside a group will have a common prefix. | |
| 144 | + | |
| 145 | +For example, defining your routes as: | |
| 146 | + | |
| 147 | +```php | |
| 148 | +$r->addGroup('/admin', function (RouteCollector $r) { | |
| 149 | + $r->addRoute('GET', '/do-something', 'handler'); | |
| 150 | + $r->addRoute('GET', '/do-another-thing', 'handler'); | |
| 151 | + $r->addRoute('GET', '/do-something-else', 'handler'); | |
| 152 | +}); | |
| 153 | +``` | |
| 154 | + | |
| 155 | +Will have the same result as: | |
| 156 | + | |
| 157 | + ```php | |
| 158 | +$r->addRoute('GET', '/admin/do-something', 'handler'); | |
| 159 | +$r->addRoute('GET', '/admin/do-another-thing', 'handler'); | |
| 160 | +$r->addRoute('GET', '/admin/do-something-else', 'handler'); | |
| 161 | + ``` | |
| 162 | + | |
| 163 | +Nested groups are also supported, in which case the prefixes of all the nested groups are combined. | |
| 164 | + | |
| 165 | +### Caching | |
| 166 | + | |
| 167 | +The reason `simpleDispatcher` accepts a callback for defining the routes is to allow seamless | |
| 168 | +caching. By using `cachedDispatcher` instead of `simpleDispatcher` you can cache the generated | |
| 169 | +routing data and construct the dispatcher from the cached information: | |
| 170 | + | |
| 171 | +```php | |
| 172 | +<?php | |
| 173 | + | |
| 174 | +$dispatcher = FastRoute\cachedDispatcher(function(FastRoute\RouteCollector $r) { | |
| 175 | + $r->addRoute('GET', '/user/{name}/{id:[0-9]+}', 'handler0'); | |
| 176 | + $r->addRoute('GET', '/user/{id:[0-9]+}', 'handler1'); | |
| 177 | + $r->addRoute('GET', '/user/{name}', 'handler2'); | |
| 178 | +}, [ | |
| 179 | + 'cacheFile' => __DIR__ . '/route.cache', /* required */ | |
| 180 | + 'cacheDisabled' => IS_DEBUG_ENABLED, /* optional, enabled by default */ | |
| 181 | +]); | |
| 182 | +``` | |
| 183 | + | |
| 184 | +The second parameter to the function is an options array, which can be used to specify the cache | |
| 185 | +file location, among other things. | |
| 186 | + | |
| 187 | +### Dispatching a URI | |
| 188 | + | |
| 189 | +A URI is dispatched by calling the `dispatch()` method of the created dispatcher. This method | |
| 190 | +accepts the HTTP method and a URI. Getting those two bits of information (and normalizing them | |
| 191 | +appropriately) is your job - this library is not bound to the PHP web SAPIs. | |
| 192 | + | |
| 193 | +The `dispatch()` method returns an array whose first element contains a status code. It is one | |
| 194 | +of `Dispatcher::NOT_FOUND`, `Dispatcher::METHOD_NOT_ALLOWED` and `Dispatcher::FOUND`. For the | |
| 195 | +method not allowed status the second array element contains a list of HTTP methods allowed for | |
| 196 | +the supplied URI. For example: | |
| 197 | + | |
| 198 | + [FastRoute\Dispatcher::METHOD_NOT_ALLOWED, ['GET', 'POST']] | |
| 199 | + | |
| 200 | +> **NOTE:** The HTTP specification requires that a `405 Method Not Allowed` response include the | |
| 201 | +`Allow:` header to detail available methods for the requested resource. Applications using FastRoute | |
| 202 | +should use the second array element to add this header when relaying a 405 response. | |
| 203 | + | |
| 204 | +For the found status the second array element is the handler that was associated with the route | |
| 205 | +and the third array element is a dictionary of placeholder names to their values. For example: | |
| 206 | + | |
| 207 | + /* Routing against GET /user/nikic/42 */ | |
| 208 | + | |
| 209 | + [FastRoute\Dispatcher::FOUND, 'handler0', ['name' => 'nikic', 'id' => '42']] | |
| 210 | + | |
| 211 | +### Overriding the route parser and dispatcher | |
| 212 | + | |
| 213 | +The routing process makes use of three components: A route parser, a data generator and a | |
| 214 | +dispatcher. The three components adhere to the following interfaces: | |
| 215 | + | |
| 216 | +```php | |
| 217 | +<?php | |
| 218 | + | |
| 219 | +namespace FastRoute; | |
| 220 | + | |
| 221 | +interface RouteParser { | |
| 222 | + public function parse($route); | |
| 223 | +} | |
| 224 | + | |
| 225 | +interface DataGenerator { | |
| 226 | + public function addRoute($httpMethod, $routeData, $handler); | |
| 227 | + public function getData(); | |
| 228 | +} | |
| 229 | + | |
| 230 | +interface Dispatcher { | |
| 231 | + const NOT_FOUND = 0, FOUND = 1, METHOD_NOT_ALLOWED = 2; | |
| 232 | + | |
| 233 | + public function dispatch($httpMethod, $uri); | |
| 234 | +} | |
| 235 | +``` | |
| 236 | + | |
| 237 | +The route parser takes a route pattern string and converts it into an array of route infos, where | |
| 238 | +each route info is again an array of it's parts. The structure is best understood using an example: | |
| 239 | + | |
| 240 | + /* The route /user/{id:\d+}[/{name}] converts to the following array: */ | |
| 241 | + [ | |
| 242 | + [ | |
| 243 | + '/user/', | |
| 244 | + ['id', '\d+'], | |
| 245 | + ], | |
| 246 | + [ | |
| 247 | + '/user/', | |
| 248 | + ['id', '\d+'], | |
| 249 | + '/', | |
| 250 | + ['name', '[^/]+'], | |
| 251 | + ], | |
| 252 | + ] | |
| 253 | + | |
| 254 | +This array can then be passed to the `addRoute()` method of a data generator. After all routes have | |
| 255 | +been added the `getData()` of the generator is invoked, which returns all the routing data required | |
| 256 | +by the dispatcher. The format of this data is not further specified - it is tightly coupled to | |
| 257 | +the corresponding dispatcher. | |
| 258 | + | |
| 259 | +The dispatcher accepts the routing data via a constructor and provides a `dispatch()` method, which | |
| 260 | +you're already familiar with. | |
| 261 | + | |
| 262 | +The route parser can be overwritten individually (to make use of some different pattern syntax), | |
| 263 | +however the data generator and dispatcher should always be changed as a pair, as the output from | |
| 264 | +the former is tightly coupled to the input of the latter. The reason the generator and the | |
| 265 | +dispatcher are separate is that only the latter is needed when using caching (as the output of | |
| 266 | +the former is what is being cached.) | |
| 267 | + | |
| 268 | +When using the `simpleDispatcher` / `cachedDispatcher` functions from above the override happens | |
| 269 | +through the options array: | |
| 270 | + | |
| 271 | +```php | |
| 272 | +<?php | |
| 273 | + | |
| 274 | +$dispatcher = FastRoute\simpleDispatcher(function(FastRoute\RouteCollector $r) { | |
| 275 | + /* ... */ | |
| 276 | +}, [ | |
| 277 | + 'routeParser' => 'FastRoute\\RouteParser\\Std', | |
| 278 | + 'dataGenerator' => 'FastRoute\\DataGenerator\\GroupCountBased', | |
| 279 | + 'dispatcher' => 'FastRoute\\Dispatcher\\GroupCountBased', | |
| 280 | +]); | |
| 281 | +``` | |
| 282 | + | |
| 283 | +The above options array corresponds to the defaults. By replacing `GroupCountBased` by | |
| 284 | +`GroupPosBased` you could switch to a different dispatching strategy. | |
| 285 | + | |
| 286 | +### A Note on HEAD Requests | |
| 287 | + | |
| 288 | +The HTTP spec requires servers to [support both GET and HEAD methods][2616-511]: | |
| 289 | + | |
| 290 | +> The methods GET and HEAD MUST be supported by all general-purpose servers | |
| 291 | + | |
| 292 | +To avoid forcing users to manually register HEAD routes for each resource we fallback to matching an | |
| 293 | +available GET route for a given resource. The PHP web SAPI transparently removes the entity body | |
| 294 | +from HEAD responses so this behavior has no effect on the vast majority of users. | |
| 295 | + | |
| 296 | +However, implementers using FastRoute outside the web SAPI environment (e.g. a custom server) MUST | |
| 297 | +NOT send entity bodies generated in response to HEAD requests. If you are a non-SAPI user this is | |
| 298 | +*your responsibility*; FastRoute has no purview to prevent you from breaking HTTP in such cases. | |
| 299 | + | |
| 300 | +Finally, note that applications MAY always specify their own HEAD method route for a given | |
| 301 | +resource to bypass this behavior entirely. | |
| 302 | + | |
| 303 | +### Credits | |
| 304 | + | |
| 305 | +This library is based on a router that [Levi Morrison][levi] implemented for the Aerys server. | |
| 306 | + | |
| 307 | +A large number of tests, as well as HTTP compliance considerations, were provided by [Daniel Lowrey][rdlowrey]. | |
| 308 | + | |
| 309 | + | |
| 310 | +[2616-511]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.1 "RFC 2616 Section 5.1.1" | |
| 311 | +[blog_post]: http://nikic.github.io/2014/02/18/Fast-request-routing-using-regular-expressions.html | |
| 312 | +[levi]: https://github.com/morrisonlevi | |
| 313 | +[rdlowrey]: https://github.com/rdlowrey | ... | ... |
| 1 | +++ a/vendor/nikic/fast-route/composer.json | |
| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | +{ | |
| 2 | + "name": "nikic/fast-route", | |
| 3 | + "description": "Fast request router for PHP", | |
| 4 | + "keywords": ["routing", "router"], | |
| 5 | + "license": "BSD-3-Clause", | |
| 6 | + "authors": [ | |
| 7 | + { | |
| 8 | + "name": "Nikita Popov", | |
| 9 | + "email": "nikic@php.net" | |
| 10 | + } | |
| 11 | + ], | |
| 12 | + "require": { | |
| 13 | + "php": ">=5.4.0" | |
| 14 | + }, | |
| 15 | + "autoload": { | |
| 16 | + "psr-4": { | |
| 17 | + "FastRoute\\": "src/" | |
| 18 | + }, | |
| 19 | + "files": ["src/functions.php"] | |
| 20 | + } | |
| 21 | +} | ... | ... |
| 1 | +++ a/vendor/nikic/fast-route/phpunit.xml | |
| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | + | |
| 3 | +<phpunit backupGlobals="false" | |
| 4 | + backupStaticAttributes="false" | |
| 5 | + colors="true" | |
| 6 | + convertErrorsToExceptions="true" | |
| 7 | + convertNoticesToExceptions="true" | |
| 8 | + convertWarningsToExceptions="true" | |
| 9 | + processIsolation="false" | |
| 10 | + syntaxCheck="false" | |
| 11 | + bootstrap="test/bootstrap.php" | |
| 12 | + > | |
| 13 | + <testsuites> | |
| 14 | + <testsuite name="FastRoute Tests"> | |
| 15 | + <directory>./test/</directory> | |
| 16 | + </testsuite> | |
| 17 | + </testsuites> | |
| 18 | + | |
| 19 | + <filter> | |
| 20 | + <whitelist> | |
| 21 | + <directory>./src/</directory> | |
| 22 | + </whitelist> | |
| 23 | + </filter> | |
| 24 | +</phpunit> | ... | ... |
| 1 | +++ a/vendor/nikic/fast-route/src/DataGenerator.php | |
| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute; | |
| 4 | + | |
| 5 | +interface DataGenerator { | |
| 6 | + /** | |
| 7 | + * Adds a route to the data generator. The route data uses the | |
| 8 | + * same format that is returned by RouterParser::parser(). | |
| 9 | + * | |
| 10 | + * The handler doesn't necessarily need to be a callable, it | |
| 11 | + * can be arbitrary data that will be returned when the route | |
| 12 | + * matches. | |
| 13 | + * | |
| 14 | + * @param string $httpMethod | |
| 15 | + * @param array $routeData | |
| 16 | + * @param mixed $handler | |
| 17 | + */ | |
| 18 | + public function addRoute($httpMethod, $routeData, $handler); | |
| 19 | + | |
| 20 | + /** | |
| 21 | + * Returns dispatcher data in some unspecified format, which | |
| 22 | + * depends on the used method of dispatch. | |
| 23 | + */ | |
| 24 | + public function getData(); | |
| 25 | +} | ... | ... |
vendor/nikic/fast-route/src/DataGenerator/CharCountBased.php
0 → 100644
| 1 | +++ a/vendor/nikic/fast-route/src/DataGenerator/CharCountBased.php | |
| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute\DataGenerator; | |
| 4 | + | |
| 5 | +class CharCountBased extends RegexBasedAbstract { | |
| 6 | + protected function getApproxChunkSize() { | |
| 7 | + return 30; | |
| 8 | + } | |
| 9 | + | |
| 10 | + protected function processChunk($regexToRoutesMap) { | |
| 11 | + $routeMap = []; | |
| 12 | + $regexes = []; | |
| 13 | + | |
| 14 | + $suffixLen = 0; | |
| 15 | + $suffix = ''; | |
| 16 | + $count = count($regexToRoutesMap); | |
| 17 | + foreach ($regexToRoutesMap as $regex => $route) { | |
| 18 | + $suffixLen++; | |
| 19 | + $suffix .= "\t"; | |
| 20 | + | |
| 21 | + $regexes[] = '(?:' . $regex . '/(\t{' . $suffixLen . '})\t{' . ($count - $suffixLen) . '})'; | |
| 22 | + $routeMap[$suffix] = [$route->handler, $route->variables]; | |
| 23 | + } | |
| 24 | + | |
| 25 | + $regex = '~^(?|' . implode('|', $regexes) . ')$~'; | |
| 26 | + return ['regex' => $regex, 'suffix' => '/' . $suffix, 'routeMap' => $routeMap]; | |
| 27 | + } | |
| 28 | +} | ... | ... |
vendor/nikic/fast-route/src/DataGenerator/GroupCountBased.php
0 → 100644
| 1 | +++ a/vendor/nikic/fast-route/src/DataGenerator/GroupCountBased.php | |
| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute\DataGenerator; | |
| 4 | + | |
| 5 | +class GroupCountBased extends RegexBasedAbstract { | |
| 6 | + protected function getApproxChunkSize() { | |
| 7 | + return 10; | |
| 8 | + } | |
| 9 | + | |
| 10 | + protected function processChunk($regexToRoutesMap) { | |
| 11 | + $routeMap = []; | |
| 12 | + $regexes = []; | |
| 13 | + $numGroups = 0; | |
| 14 | + foreach ($regexToRoutesMap as $regex => $route) { | |
| 15 | + $numVariables = count($route->variables); | |
| 16 | + $numGroups = max($numGroups, $numVariables); | |
| 17 | + | |
| 18 | + $regexes[] = $regex . str_repeat('()', $numGroups - $numVariables); | |
| 19 | + $routeMap[$numGroups + 1] = [$route->handler, $route->variables]; | |
| 20 | + | |
| 21 | + ++$numGroups; | |
| 22 | + } | |
| 23 | + | |
| 24 | + $regex = '~^(?|' . implode('|', $regexes) . ')$~'; | |
| 25 | + return ['regex' => $regex, 'routeMap' => $routeMap]; | |
| 26 | + } | |
| 27 | +} | |
| 28 | + | ... | ... |
vendor/nikic/fast-route/src/DataGenerator/GroupPosBased.php
0 → 100644
| 1 | +++ a/vendor/nikic/fast-route/src/DataGenerator/GroupPosBased.php | |
| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute\DataGenerator; | |
| 4 | + | |
| 5 | +class GroupPosBased extends RegexBasedAbstract { | |
| 6 | + protected function getApproxChunkSize() { | |
| 7 | + return 10; | |
| 8 | + } | |
| 9 | + | |
| 10 | + protected function processChunk($regexToRoutesMap) { | |
| 11 | + $routeMap = []; | |
| 12 | + $regexes = []; | |
| 13 | + $offset = 1; | |
| 14 | + foreach ($regexToRoutesMap as $regex => $route) { | |
| 15 | + $regexes[] = $regex; | |
| 16 | + $routeMap[$offset] = [$route->handler, $route->variables]; | |
| 17 | + | |
| 18 | + $offset += count($route->variables); | |
| 19 | + } | |
| 20 | + | |
| 21 | + $regex = '~^(?:' . implode('|', $regexes) . ')$~'; | |
| 22 | + return ['regex' => $regex, 'routeMap' => $routeMap]; | |
| 23 | + } | |
| 24 | +} | |
| 25 | + | ... | ... |
| 1 | +++ a/vendor/nikic/fast-route/src/DataGenerator/MarkBased.php | |
| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute\DataGenerator; | |
| 4 | + | |
| 5 | +class MarkBased extends RegexBasedAbstract { | |
| 6 | + protected function getApproxChunkSize() { | |
| 7 | + return 30; | |
| 8 | + } | |
| 9 | + | |
| 10 | + protected function processChunk($regexToRoutesMap) { | |
| 11 | + $routeMap = []; | |
| 12 | + $regexes = []; | |
| 13 | + $markName = 'a'; | |
| 14 | + foreach ($regexToRoutesMap as $regex => $route) { | |
| 15 | + $regexes[] = $regex . '(*MARK:' . $markName . ')'; | |
| 16 | + $routeMap[$markName] = [$route->handler, $route->variables]; | |
| 17 | + | |
| 18 | + ++$markName; | |
| 19 | + } | |
| 20 | + | |
| 21 | + $regex = '~^(?|' . implode('|', $regexes) . ')$~'; | |
| 22 | + return ['regex' => $regex, 'routeMap' => $routeMap]; | |
| 23 | + } | |
| 24 | +} | |
| 25 | + | ... | ... |
vendor/nikic/fast-route/src/DataGenerator/RegexBasedAbstract.php
0 → 100644
| 1 | +++ a/vendor/nikic/fast-route/src/DataGenerator/RegexBasedAbstract.php | |
| ... | ... | @@ -0,0 +1,144 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute\DataGenerator; | |
| 4 | + | |
| 5 | +use FastRoute\DataGenerator; | |
| 6 | +use FastRoute\BadRouteException; | |
| 7 | +use FastRoute\Route; | |
| 8 | + | |
| 9 | +abstract class RegexBasedAbstract implements DataGenerator { | |
| 10 | + protected $staticRoutes = []; | |
| 11 | + protected $methodToRegexToRoutesMap = []; | |
| 12 | + | |
| 13 | + protected abstract function getApproxChunkSize(); | |
| 14 | + protected abstract function processChunk($regexToRoutesMap); | |
| 15 | + | |
| 16 | + public function addRoute($httpMethod, $routeData, $handler) { | |
| 17 | + if ($this->isStaticRoute($routeData)) { | |
| 18 | + $this->addStaticRoute($httpMethod, $routeData, $handler); | |
| 19 | + } else { | |
| 20 | + $this->addVariableRoute($httpMethod, $routeData, $handler); | |
| 21 | + } | |
| 22 | + } | |
| 23 | + | |
| 24 | + public function getData() { | |
| 25 | + if (empty($this->methodToRegexToRoutesMap)) { | |
| 26 | + return [$this->staticRoutes, []]; | |
| 27 | + } | |
| 28 | + | |
| 29 | + return [$this->staticRoutes, $this->generateVariableRouteData()]; | |
| 30 | + } | |
| 31 | + | |
| 32 | + private function generateVariableRouteData() { | |
| 33 | + $data = []; | |
| 34 | + foreach ($this->methodToRegexToRoutesMap as $method => $regexToRoutesMap) { | |
| 35 | + $chunkSize = $this->computeChunkSize(count($regexToRoutesMap)); | |
| 36 | + $chunks = array_chunk($regexToRoutesMap, $chunkSize, true); | |
| 37 | + $data[$method] = array_map([$this, 'processChunk'], $chunks); | |
| 38 | + } | |
| 39 | + return $data; | |
| 40 | + } | |
| 41 | + | |
| 42 | + private function computeChunkSize($count) { | |
| 43 | + $numParts = max(1, round($count / $this->getApproxChunkSize())); | |
| 44 | + return ceil($count / $numParts); | |
| 45 | + } | |
| 46 | + | |
| 47 | + private function isStaticRoute($routeData) { | |
| 48 | + return count($routeData) === 1 && is_string($routeData[0]); | |
| 49 | + } | |
| 50 | + | |
| 51 | + private function addStaticRoute($httpMethod, $routeData, $handler) { | |
| 52 | + $routeStr = $routeData[0]; | |
| 53 | + | |
| 54 | + if (isset($this->staticRoutes[$httpMethod][$routeStr])) { | |
| 55 | + throw new BadRouteException(sprintf( | |
| 56 | + 'Cannot register two routes matching "%s" for method "%s"', | |
| 57 | + $routeStr, $httpMethod | |
| 58 | + )); | |
| 59 | + } | |
| 60 | + | |
| 61 | + if (isset($this->methodToRegexToRoutesMap[$httpMethod])) { | |
| 62 | + foreach ($this->methodToRegexToRoutesMap[$httpMethod] as $route) { | |
| 63 | + if ($route->matches($routeStr)) { | |
| 64 | + throw new BadRouteException(sprintf( | |
| 65 | + 'Static route "%s" is shadowed by previously defined variable route "%s" for method "%s"', | |
| 66 | + $routeStr, $route->regex, $httpMethod | |
| 67 | + )); | |
| 68 | + } | |
| 69 | + } | |
| 70 | + } | |
| 71 | + | |
| 72 | + $this->staticRoutes[$httpMethod][$routeStr] = $handler; | |
| 73 | + } | |
| 74 | + | |
| 75 | + private function addVariableRoute($httpMethod, $routeData, $handler) { | |
| 76 | + list($regex, $variables) = $this->buildRegexForRoute($routeData); | |
| 77 | + | |
| 78 | + if (isset($this->methodToRegexToRoutesMap[$httpMethod][$regex])) { | |
| 79 | + throw new BadRouteException(sprintf( | |
| 80 | + 'Cannot register two routes matching "%s" for method "%s"', | |
| 81 | + $regex, $httpMethod | |
| 82 | + )); | |
| 83 | + } | |
| 84 | + | |
| 85 | + $this->methodToRegexToRoutesMap[$httpMethod][$regex] = new Route( | |
| 86 | + $httpMethod, $handler, $regex, $variables | |
| 87 | + ); | |
| 88 | + } | |
| 89 | + | |
| 90 | + private function buildRegexForRoute($routeData) { | |
| 91 | + $regex = ''; | |
| 92 | + $variables = []; | |
| 93 | + foreach ($routeData as $part) { | |
| 94 | + if (is_string($part)) { | |
| 95 | + $regex .= preg_quote($part, '~'); | |
| 96 | + continue; | |
| 97 | + } | |
| 98 | + | |
| 99 | + list($varName, $regexPart) = $part; | |
| 100 | + | |
| 101 | + if (isset($variables[$varName])) { | |
| 102 | + throw new BadRouteException(sprintf( | |
| 103 | + 'Cannot use the same placeholder "%s" twice', $varName | |
| 104 | + )); | |
| 105 | + } | |
| 106 | + | |
| 107 | + if ($this->regexHasCapturingGroups($regexPart)) { | |
| 108 | + throw new BadRouteException(sprintf( | |
| 109 | + 'Regex "%s" for parameter "%s" contains a capturing group', | |
| 110 | + $regexPart, $varName | |
| 111 | + )); | |
| 112 | + } | |
| 113 | + | |
| 114 | + $variables[$varName] = $varName; | |
| 115 | + $regex .= '(' . $regexPart . ')'; | |
| 116 | + } | |
| 117 | + | |
| 118 | + return [$regex, $variables]; | |
| 119 | + } | |
| 120 | + | |
| 121 | + private function regexHasCapturingGroups($regex) { | |
| 122 | + if (false === strpos($regex, '(')) { | |
| 123 | + // Needs to have at least a ( to contain a capturing group | |
| 124 | + return false; | |
| 125 | + } | |
| 126 | + | |
| 127 | + // Semi-accurate detection for capturing groups | |
| 128 | + return preg_match( | |
| 129 | + '~ | |
| 130 | + (?: | |
| 131 | + \(\?\( | |
| 132 | + | \[ [^\]\\\\]* (?: \\\\ . [^\]\\\\]* )* \] | |
| 133 | + | \\\\ . | |
| 134 | + ) (*SKIP)(*FAIL) | | |
| 135 | + \( | |
| 136 | + (?! | |
| 137 | + \? (?! <(?![!=]) | P< | \' ) | |
| 138 | + | \* | |
| 139 | + ) | |
| 140 | + ~x', | |
| 141 | + $regex | |
| 142 | + ); | |
| 143 | + } | |
| 144 | +} | ... | ... |
| 1 | +++ a/vendor/nikic/fast-route/src/Dispatcher.php | |
| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute; | |
| 4 | + | |
| 5 | +interface Dispatcher { | |
| 6 | + const NOT_FOUND = 0; | |
| 7 | + const FOUND = 1; | |
| 8 | + const METHOD_NOT_ALLOWED = 2; | |
| 9 | + | |
| 10 | + /** | |
| 11 | + * Dispatches against the provided HTTP method verb and URI. | |
| 12 | + * | |
| 13 | + * Returns array with one of the following formats: | |
| 14 | + * | |
| 15 | + * [self::NOT_FOUND] | |
| 16 | + * [self::METHOD_NOT_ALLOWED, ['GET', 'OTHER_ALLOWED_METHODS']] | |
| 17 | + * [self::FOUND, $handler, ['varName' => 'value', ...]] | |
| 18 | + * | |
| 19 | + * @param string $httpMethod | |
| 20 | + * @param string $uri | |
| 21 | + * | |
| 22 | + * @return array | |
| 23 | + */ | |
| 24 | + public function dispatch($httpMethod, $uri); | |
| 25 | +} | ... | ... |
vendor/nikic/fast-route/src/Dispatcher/CharCountBased.php
0 → 100644
| 1 | +++ a/vendor/nikic/fast-route/src/Dispatcher/CharCountBased.php | |
| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute\Dispatcher; | |
| 4 | + | |
| 5 | +class CharCountBased extends RegexBasedAbstract { | |
| 6 | + public function __construct($data) { | |
| 7 | + list($this->staticRouteMap, $this->variableRouteData) = $data; | |
| 8 | + } | |
| 9 | + | |
| 10 | + protected function dispatchVariableRoute($routeData, $uri) { | |
| 11 | + foreach ($routeData as $data) { | |
| 12 | + if (!preg_match($data['regex'], $uri . $data['suffix'], $matches)) { | |
| 13 | + continue; | |
| 14 | + } | |
| 15 | + | |
| 16 | + list($handler, $varNames) = $data['routeMap'][end($matches)]; | |
| 17 | + | |
| 18 | + $vars = []; | |
| 19 | + $i = 0; | |
| 20 | + foreach ($varNames as $varName) { | |
| 21 | + $vars[$varName] = $matches[++$i]; | |
| 22 | + } | |
| 23 | + return [self::FOUND, $handler, $vars]; | |
| 24 | + } | |
| 25 | + | |
| 26 | + return [self::NOT_FOUND]; | |
| 27 | + } | |
| 28 | +} | ... | ... |
vendor/nikic/fast-route/src/Dispatcher/GroupCountBased.php
0 → 100644
| 1 | +++ a/vendor/nikic/fast-route/src/Dispatcher/GroupCountBased.php | |
| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute\Dispatcher; | |
| 4 | + | |
| 5 | +class GroupCountBased extends RegexBasedAbstract { | |
| 6 | + public function __construct($data) { | |
| 7 | + list($this->staticRouteMap, $this->variableRouteData) = $data; | |
| 8 | + } | |
| 9 | + | |
| 10 | + protected function dispatchVariableRoute($routeData, $uri) { | |
| 11 | + foreach ($routeData as $data) { | |
| 12 | + if (!preg_match($data['regex'], $uri, $matches)) { | |
| 13 | + continue; | |
| 14 | + } | |
| 15 | + | |
| 16 | + list($handler, $varNames) = $data['routeMap'][count($matches)]; | |
| 17 | + | |
| 18 | + $vars = []; | |
| 19 | + $i = 0; | |
| 20 | + foreach ($varNames as $varName) { | |
| 21 | + $vars[$varName] = $matches[++$i]; | |
| 22 | + } | |
| 23 | + return [self::FOUND, $handler, $vars]; | |
| 24 | + } | |
| 25 | + | |
| 26 | + return [self::NOT_FOUND]; | |
| 27 | + } | |
| 28 | +} | ... | ... |
vendor/nikic/fast-route/src/Dispatcher/GroupPosBased.php
0 → 100644
| 1 | +++ a/vendor/nikic/fast-route/src/Dispatcher/GroupPosBased.php | |
| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute\Dispatcher; | |
| 4 | + | |
| 5 | +class GroupPosBased extends RegexBasedAbstract { | |
| 6 | + public function __construct($data) { | |
| 7 | + list($this->staticRouteMap, $this->variableRouteData) = $data; | |
| 8 | + } | |
| 9 | + | |
| 10 | + protected function dispatchVariableRoute($routeData, $uri) { | |
| 11 | + foreach ($routeData as $data) { | |
| 12 | + if (!preg_match($data['regex'], $uri, $matches)) { | |
| 13 | + continue; | |
| 14 | + } | |
| 15 | + | |
| 16 | + // find first non-empty match | |
| 17 | + for ($i = 1; '' === $matches[$i]; ++$i); | |
| 18 | + | |
| 19 | + list($handler, $varNames) = $data['routeMap'][$i]; | |
| 20 | + | |
| 21 | + $vars = []; | |
| 22 | + foreach ($varNames as $varName) { | |
| 23 | + $vars[$varName] = $matches[$i++]; | |
| 24 | + } | |
| 25 | + return [self::FOUND, $handler, $vars]; | |
| 26 | + } | |
| 27 | + | |
| 28 | + return [self::NOT_FOUND]; | |
| 29 | + } | |
| 30 | +} | ... | ... |
| 1 | +++ a/vendor/nikic/fast-route/src/Dispatcher/MarkBased.php | |
| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute\Dispatcher; | |
| 4 | + | |
| 5 | +class MarkBased extends RegexBasedAbstract { | |
| 6 | + public function __construct($data) { | |
| 7 | + list($this->staticRouteMap, $this->variableRouteData) = $data; | |
| 8 | + } | |
| 9 | + | |
| 10 | + protected function dispatchVariableRoute($routeData, $uri) { | |
| 11 | + foreach ($routeData as $data) { | |
| 12 | + if (!preg_match($data['regex'], $uri, $matches)) { | |
| 13 | + continue; | |
| 14 | + } | |
| 15 | + | |
| 16 | + list($handler, $varNames) = $data['routeMap'][$matches['MARK']]; | |
| 17 | + | |
| 18 | + $vars = []; | |
| 19 | + $i = 0; | |
| 20 | + foreach ($varNames as $varName) { | |
| 21 | + $vars[$varName] = $matches[++$i]; | |
| 22 | + } | |
| 23 | + return [self::FOUND, $handler, $vars]; | |
| 24 | + } | |
| 25 | + | |
| 26 | + return [self::NOT_FOUND]; | |
| 27 | + } | |
| 28 | +} | ... | ... |
vendor/nikic/fast-route/src/Dispatcher/RegexBasedAbstract.php
0 → 100644
| 1 | +++ a/vendor/nikic/fast-route/src/Dispatcher/RegexBasedAbstract.php | |
| ... | ... | @@ -0,0 +1,80 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute\Dispatcher; | |
| 4 | + | |
| 5 | +use FastRoute\Dispatcher; | |
| 6 | + | |
| 7 | +abstract class RegexBasedAbstract implements Dispatcher { | |
| 8 | + protected $staticRouteMap; | |
| 9 | + protected $variableRouteData; | |
| 10 | + | |
| 11 | + protected abstract function dispatchVariableRoute($routeData, $uri); | |
| 12 | + | |
| 13 | + public function dispatch($httpMethod, $uri) { | |
| 14 | + if (isset($this->staticRouteMap[$httpMethod][$uri])) { | |
| 15 | + $handler = $this->staticRouteMap[$httpMethod][$uri]; | |
| 16 | + return [self::FOUND, $handler, []]; | |
| 17 | + } | |
| 18 | + | |
| 19 | + $varRouteData = $this->variableRouteData; | |
| 20 | + if (isset($varRouteData[$httpMethod])) { | |
| 21 | + $result = $this->dispatchVariableRoute($varRouteData[$httpMethod], $uri); | |
| 22 | + if ($result[0] === self::FOUND) { | |
| 23 | + return $result; | |
| 24 | + } | |
| 25 | + } | |
| 26 | + | |
| 27 | + // For HEAD requests, attempt fallback to GET | |
| 28 | + if ($httpMethod === 'HEAD') { | |
| 29 | + if (isset($this->staticRouteMap['GET'][$uri])) { | |
| 30 | + $handler = $this->staticRouteMap['GET'][$uri]; | |
| 31 | + return [self::FOUND, $handler, []]; | |
| 32 | + } | |
| 33 | + if (isset($varRouteData['GET'])) { | |
| 34 | + $result = $this->dispatchVariableRoute($varRouteData['GET'], $uri); | |
| 35 | + if ($result[0] === self::FOUND) { | |
| 36 | + return $result; | |
| 37 | + } | |
| 38 | + } | |
| 39 | + } | |
| 40 | + | |
| 41 | + // If nothing else matches, try fallback routes | |
| 42 | + if (isset($this->staticRouteMap['*'][$uri])) { | |
| 43 | + $handler = $this->staticRouteMap['*'][$uri]; | |
| 44 | + return [self::FOUND, $handler, []]; | |
| 45 | + } | |
| 46 | + if (isset($varRouteData['*'])) { | |
| 47 | + $result = $this->dispatchVariableRoute($varRouteData['*'], $uri); | |
| 48 | + if ($result[0] === self::FOUND) { | |
| 49 | + return $result; | |
| 50 | + } | |
| 51 | + } | |
| 52 | + | |
| 53 | + // Find allowed methods for this URI by matching against all other HTTP methods as well | |
| 54 | + $allowedMethods = []; | |
| 55 | + | |
| 56 | + foreach ($this->staticRouteMap as $method => $uriMap) { | |
| 57 | + if ($method !== $httpMethod && isset($uriMap[$uri])) { | |
| 58 | + $allowedMethods[] = $method; | |
| 59 | + } | |
| 60 | + } | |
| 61 | + | |
| 62 | + foreach ($varRouteData as $method => $routeData) { | |
| 63 | + if ($method === $httpMethod) { | |
| 64 | + continue; | |
| 65 | + } | |
| 66 | + | |
| 67 | + $result = $this->dispatchVariableRoute($routeData, $uri); | |
| 68 | + if ($result[0] === self::FOUND) { | |
| 69 | + $allowedMethods[] = $method; | |
| 70 | + } | |
| 71 | + } | |
| 72 | + | |
| 73 | + // If there are no allowed methods the route simply does not exist | |
| 74 | + if ($allowedMethods) { | |
| 75 | + return [self::METHOD_NOT_ALLOWED, $allowedMethods]; | |
| 76 | + } else { | |
| 77 | + return [self::NOT_FOUND]; | |
| 78 | + } | |
| 79 | + } | |
| 80 | +} | ... | ... |
| 1 | +++ a/vendor/nikic/fast-route/src/Route.php | |
| ... | ... | @@ -0,0 +1,38 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute; | |
| 4 | + | |
| 5 | +class Route { | |
| 6 | + public $httpMethod; | |
| 7 | + public $regex; | |
| 8 | + public $variables; | |
| 9 | + public $handler; | |
| 10 | + | |
| 11 | + /** | |
| 12 | + * Constructs a route (value object). | |
| 13 | + * | |
| 14 | + * @param string $httpMethod | |
| 15 | + * @param mixed $handler | |
| 16 | + * @param string $regex | |
| 17 | + * @param array $variables | |
| 18 | + */ | |
| 19 | + public function __construct($httpMethod, $handler, $regex, $variables) { | |
| 20 | + $this->httpMethod = $httpMethod; | |
| 21 | + $this->handler = $handler; | |
| 22 | + $this->regex = $regex; | |
| 23 | + $this->variables = $variables; | |
| 24 | + } | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * Tests whether this route matches the given string. | |
| 28 | + * | |
| 29 | + * @param string $str | |
| 30 | + * | |
| 31 | + * @return bool | |
| 32 | + */ | |
| 33 | + public function matches($str) { | |
| 34 | + $regex = '~^' . $this->regex . '$~'; | |
| 35 | + return (bool) preg_match($regex, $str); | |
| 36 | + } | |
| 37 | +} | |
| 38 | + | ... | ... |
| 1 | +++ a/vendor/nikic/fast-route/src/RouteCollector.php | |
| ... | ... | @@ -0,0 +1,136 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute; | |
| 4 | + | |
| 5 | +class RouteCollector { | |
| 6 | + protected $routeParser; | |
| 7 | + protected $dataGenerator; | |
| 8 | + protected $currentGroupPrefix; | |
| 9 | + | |
| 10 | + /** | |
| 11 | + * Constructs a route collector. | |
| 12 | + * | |
| 13 | + * @param RouteParser $routeParser | |
| 14 | + * @param DataGenerator $dataGenerator | |
| 15 | + */ | |
| 16 | + public function __construct(RouteParser $routeParser, DataGenerator $dataGenerator) { | |
| 17 | + $this->routeParser = $routeParser; | |
| 18 | + $this->dataGenerator = $dataGenerator; | |
| 19 | + $this->currentGroupPrefix = ''; | |
| 20 | + } | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * Adds a route to the collection. | |
| 24 | + * | |
| 25 | + * The syntax used in the $route string depends on the used route parser. | |
| 26 | + * | |
| 27 | + * @param string|string[] $httpMethod | |
| 28 | + * @param string $route | |
| 29 | + * @param mixed $handler | |
| 30 | + */ | |
| 31 | + public function addRoute($httpMethod, $route, $handler) { | |
| 32 | + $route = $this->currentGroupPrefix . $route; | |
| 33 | + $routeDatas = $this->routeParser->parse($route); | |
| 34 | + foreach ((array) $httpMethod as $method) { | |
| 35 | + foreach ($routeDatas as $routeData) { | |
| 36 | + $this->dataGenerator->addRoute($method, $routeData, $handler); | |
| 37 | + } | |
| 38 | + } | |
| 39 | + } | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * Create a route group with a common prefix. | |
| 43 | + * | |
| 44 | + * All routes created in the passed callback will have the given group prefix prepended. | |
| 45 | + * | |
| 46 | + * @param string $prefix | |
| 47 | + * @param callable $callback | |
| 48 | + */ | |
| 49 | + public function addGroup($prefix, callable $callback) { | |
| 50 | + $previousGroupPrefix = $this->currentGroupPrefix; | |
| 51 | + $this->currentGroupPrefix = $previousGroupPrefix . $prefix; | |
| 52 | + $callback($this); | |
| 53 | + $this->currentGroupPrefix = $previousGroupPrefix; | |
| 54 | + } | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * Adds a GET route to the collection | |
| 58 | + * | |
| 59 | + * This is simply an alias of $this->addRoute('GET', $route, $handler) | |
| 60 | + * | |
| 61 | + * @param string $route | |
| 62 | + * @param mixed $handler | |
| 63 | + */ | |
| 64 | + public function get($route, $handler) { | |
| 65 | + $this->addRoute('GET', $route, $handler); | |
| 66 | + } | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * Adds a POST route to the collection | |
| 70 | + * | |
| 71 | + * This is simply an alias of $this->addRoute('POST', $route, $handler) | |
| 72 | + * | |
| 73 | + * @param string $route | |
| 74 | + * @param mixed $handler | |
| 75 | + */ | |
| 76 | + public function post($route, $handler) { | |
| 77 | + $this->addRoute('POST', $route, $handler); | |
| 78 | + } | |
| 79 | + | |
| 80 | + /** | |
| 81 | + * Adds a PUT route to the collection | |
| 82 | + * | |
| 83 | + * This is simply an alias of $this->addRoute('PUT', $route, $handler) | |
| 84 | + * | |
| 85 | + * @param string $route | |
| 86 | + * @param mixed $handler | |
| 87 | + */ | |
| 88 | + public function put($route, $handler) { | |
| 89 | + $this->addRoute('PUT', $route, $handler); | |
| 90 | + } | |
| 91 | + | |
| 92 | + /** | |
| 93 | + * Adds a DELETE route to the collection | |
| 94 | + * | |
| 95 | + * This is simply an alias of $this->addRoute('DELETE', $route, $handler) | |
| 96 | + * | |
| 97 | + * @param string $route | |
| 98 | + * @param mixed $handler | |
| 99 | + */ | |
| 100 | + public function delete($route, $handler) { | |
| 101 | + $this->addRoute('DELETE', $route, $handler); | |
| 102 | + } | |
| 103 | + | |
| 104 | + /** | |
| 105 | + * Adds a PATCH route to the collection | |
| 106 | + * | |
| 107 | + * This is simply an alias of $this->addRoute('PATCH', $route, $handler) | |
| 108 | + * | |
| 109 | + * @param string $route | |
| 110 | + * @param mixed $handler | |
| 111 | + */ | |
| 112 | + public function patch($route, $handler) { | |
| 113 | + $this->addRoute('PATCH', $route, $handler); | |
| 114 | + } | |
| 115 | + | |
| 116 | + /** | |
| 117 | + * Adds a HEAD route to the collection | |
| 118 | + * | |
| 119 | + * This is simply an alias of $this->addRoute('HEAD', $route, $handler) | |
| 120 | + * | |
| 121 | + * @param string $route | |
| 122 | + * @param mixed $handler | |
| 123 | + */ | |
| 124 | + public function head($route, $handler) { | |
| 125 | + $this->addRoute('HEAD', $route, $handler); | |
| 126 | + } | |
| 127 | + | |
| 128 | + /** | |
| 129 | + * Returns the collected route data, as provided by the data generator. | |
| 130 | + * | |
| 131 | + * @return array | |
| 132 | + */ | |
| 133 | + public function getData() { | |
| 134 | + return $this->dataGenerator->getData(); | |
| 135 | + } | |
| 136 | +} | ... | ... |
| 1 | +++ a/vendor/nikic/fast-route/src/RouteParser.php | |
| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute; | |
| 4 | + | |
| 5 | +interface RouteParser { | |
| 6 | + /** | |
| 7 | + * Parses a route string into multiple route data arrays. | |
| 8 | + * | |
| 9 | + * The expected output is defined using an example: | |
| 10 | + * | |
| 11 | + * For the route string "/fixedRoutePart/{varName}[/moreFixed/{varName2:\d+}]", if {varName} is interpreted as | |
| 12 | + * a placeholder and [...] is interpreted as an optional route part, the expected result is: | |
| 13 | + * | |
| 14 | + * [ | |
| 15 | + * // first route: without optional part | |
| 16 | + * [ | |
| 17 | + * "/fixedRoutePart/", | |
| 18 | + * ["varName", "[^/]+"], | |
| 19 | + * ], | |
| 20 | + * // second route: with optional part | |
| 21 | + * [ | |
| 22 | + * "/fixedRoutePart/", | |
| 23 | + * ["varName", "[^/]+"], | |
| 24 | + * "/moreFixed/", | |
| 25 | + * ["varName2", [0-9]+"], | |
| 26 | + * ], | |
| 27 | + * ] | |
| 28 | + * | |
| 29 | + * Here one route string was converted into two route data arrays. | |
| 30 | + * | |
| 31 | + * @param string $route Route string to parse | |
| 32 | + * | |
| 33 | + * @return mixed[][] Array of route data arrays | |
| 34 | + */ | |
| 35 | + public function parse($route); | |
| 36 | +} | ... | ... |
| 1 | +++ a/vendor/nikic/fast-route/src/RouteParser/Std.php | |
| ... | ... | @@ -0,0 +1,81 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute\RouteParser; | |
| 4 | + | |
| 5 | +use FastRoute\BadRouteException; | |
| 6 | +use FastRoute\RouteParser; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * Parses route strings of the following form: | |
| 10 | + * | |
| 11 | + * "/user/{name}[/{id:[0-9]+}]" | |
| 12 | + */ | |
| 13 | +class Std implements RouteParser { | |
| 14 | + const VARIABLE_REGEX = <<<'REGEX' | |
| 15 | +\{ | |
| 16 | + \s* ([a-zA-Z_][a-zA-Z0-9_-]*) \s* | |
| 17 | + (?: | |
| 18 | + : \s* ([^{}]*(?:\{(?-1)\}[^{}]*)*) | |
| 19 | + )? | |
| 20 | +\} | |
| 21 | +REGEX; | |
| 22 | + const DEFAULT_DISPATCH_REGEX = '[^/]+'; | |
| 23 | + | |
| 24 | + public function parse($route) { | |
| 25 | + $routeWithoutClosingOptionals = rtrim($route, ']'); | |
| 26 | + $numOptionals = strlen($route) - strlen($routeWithoutClosingOptionals); | |
| 27 | + | |
| 28 | + // Split on [ while skipping placeholders | |
| 29 | + $segments = preg_split('~' . self::VARIABLE_REGEX . '(*SKIP)(*F) | \[~x', $routeWithoutClosingOptionals); | |
| 30 | + if ($numOptionals !== count($segments) - 1) { | |
| 31 | + // If there are any ] in the middle of the route, throw a more specific error message | |
| 32 | + if (preg_match('~' . self::VARIABLE_REGEX . '(*SKIP)(*F) | \]~x', $routeWithoutClosingOptionals)) { | |
| 33 | + throw new BadRouteException("Optional segments can only occur at the end of a route"); | |
| 34 | + } | |
| 35 | + throw new BadRouteException("Number of opening '[' and closing ']' does not match"); | |
| 36 | + } | |
| 37 | + | |
| 38 | + $currentRoute = ''; | |
| 39 | + $routeDatas = []; | |
| 40 | + foreach ($segments as $n => $segment) { | |
| 41 | + if ($segment === '' && $n !== 0) { | |
| 42 | + throw new BadRouteException("Empty optional part"); | |
| 43 | + } | |
| 44 | + | |
| 45 | + $currentRoute .= $segment; | |
| 46 | + $routeDatas[] = $this->parsePlaceholders($currentRoute); | |
| 47 | + } | |
| 48 | + return $routeDatas; | |
| 49 | + } | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * Parses a route string that does not contain optional segments. | |
| 53 | + */ | |
| 54 | + private function parsePlaceholders($route) { | |
| 55 | + if (!preg_match_all( | |
| 56 | + '~' . self::VARIABLE_REGEX . '~x', $route, $matches, | |
| 57 | + PREG_OFFSET_CAPTURE | PREG_SET_ORDER | |
| 58 | + )) { | |
| 59 | + return [$route]; | |
| 60 | + } | |
| 61 | + | |
| 62 | + $offset = 0; | |
| 63 | + $routeData = []; | |
| 64 | + foreach ($matches as $set) { | |
| 65 | + if ($set[0][1] > $offset) { | |
| 66 | + $routeData[] = substr($route, $offset, $set[0][1] - $offset); | |
| 67 | + } | |
| 68 | + $routeData[] = [ | |
| 69 | + $set[1][0], | |
| 70 | + isset($set[2]) ? trim($set[2][0]) : self::DEFAULT_DISPATCH_REGEX | |
| 71 | + ]; | |
| 72 | + $offset = $set[0][1] + strlen($set[0][0]); | |
| 73 | + } | |
| 74 | + | |
| 75 | + if ($offset != strlen($route)) { | |
| 76 | + $routeData[] = substr($route, $offset); | |
| 77 | + } | |
| 78 | + | |
| 79 | + return $routeData; | |
| 80 | + } | |
| 81 | +} | ... | ... |
| 1 | +++ a/vendor/nikic/fast-route/src/bootstrap.php | |
| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute; | |
| 4 | + | |
| 5 | +require __DIR__ . '/functions.php'; | |
| 6 | + | |
| 7 | +spl_autoload_register(function($class) { | |
| 8 | + if (strpos($class, 'FastRoute\\') === 0) { | |
| 9 | + $name = substr($class, strlen('FastRoute')); | |
| 10 | + require __DIR__ . strtr($name, '\\', DIRECTORY_SEPARATOR) . '.php'; | |
| 11 | + } | |
| 12 | +}); | ... | ... |
| 1 | +++ a/vendor/nikic/fast-route/src/functions.php | |
| ... | ... | @@ -0,0 +1,72 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute; | |
| 4 | + | |
| 5 | +if (!function_exists('FastRoute\simpleDispatcher')) { | |
| 6 | + /** | |
| 7 | + * @param callable $routeDefinitionCallback | |
| 8 | + * @param array $options | |
| 9 | + * | |
| 10 | + * @return Dispatcher | |
| 11 | + */ | |
| 12 | + function simpleDispatcher(callable $routeDefinitionCallback, array $options = []) { | |
| 13 | + $options += [ | |
| 14 | + 'routeParser' => 'FastRoute\\RouteParser\\Std', | |
| 15 | + 'dataGenerator' => 'FastRoute\\DataGenerator\\GroupCountBased', | |
| 16 | + 'dispatcher' => 'FastRoute\\Dispatcher\\GroupCountBased', | |
| 17 | + 'routeCollector' => 'FastRoute\\RouteCollector', | |
| 18 | + ]; | |
| 19 | + | |
| 20 | + /** @var RouteCollector $routeCollector */ | |
| 21 | + $routeCollector = new $options['routeCollector']( | |
| 22 | + new $options['routeParser'], new $options['dataGenerator'] | |
| 23 | + ); | |
| 24 | + $routeDefinitionCallback($routeCollector); | |
| 25 | + | |
| 26 | + return new $options['dispatcher']($routeCollector->getData()); | |
| 27 | + } | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * @param callable $routeDefinitionCallback | |
| 31 | + * @param array $options | |
| 32 | + * | |
| 33 | + * @return Dispatcher | |
| 34 | + */ | |
| 35 | + function cachedDispatcher(callable $routeDefinitionCallback, array $options = []) { | |
| 36 | + $options += [ | |
| 37 | + 'routeParser' => 'FastRoute\\RouteParser\\Std', | |
| 38 | + 'dataGenerator' => 'FastRoute\\DataGenerator\\GroupCountBased', | |
| 39 | + 'dispatcher' => 'FastRoute\\Dispatcher\\GroupCountBased', | |
| 40 | + 'routeCollector' => 'FastRoute\\RouteCollector', | |
| 41 | + 'cacheDisabled' => false, | |
| 42 | + ]; | |
| 43 | + | |
| 44 | + if (!isset($options['cacheFile'])) { | |
| 45 | + throw new \LogicException('Must specify "cacheFile" option'); | |
| 46 | + } | |
| 47 | + | |
| 48 | + if (!$options['cacheDisabled'] && file_exists($options['cacheFile'])) { | |
| 49 | + $dispatchData = require $options['cacheFile']; | |
| 50 | + if (!is_array($dispatchData)) { | |
| 51 | + throw new \RuntimeException('Invalid cache file "' . $options['cacheFile'] . '"'); | |
| 52 | + } | |
| 53 | + return new $options['dispatcher']($dispatchData); | |
| 54 | + } | |
| 55 | + | |
| 56 | + $routeCollector = new $options['routeCollector']( | |
| 57 | + new $options['routeParser'], new $options['dataGenerator'] | |
| 58 | + ); | |
| 59 | + $routeDefinitionCallback($routeCollector); | |
| 60 | + | |
| 61 | + /** @var RouteCollector $routeCollector */ | |
| 62 | + $dispatchData = $routeCollector->getData(); | |
| 63 | + if (!$options['cacheDisabled']) { | |
| 64 | + file_put_contents( | |
| 65 | + $options['cacheFile'], | |
| 66 | + '<?php return ' . var_export($dispatchData, true) . ';' | |
| 67 | + ); | |
| 68 | + } | |
| 69 | + | |
| 70 | + return new $options['dispatcher']($dispatchData); | |
| 71 | + } | |
| 72 | +} | ... | ... |
vendor/nikic/fast-route/test/Dispatcher/CharCountBasedTest.php
0 → 100644
| 1 | +++ a/vendor/nikic/fast-route/test/Dispatcher/CharCountBasedTest.php | |
| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute\Dispatcher; | |
| 4 | + | |
| 5 | +class CharCountBasedTest extends DispatcherTest { | |
| 6 | + protected function getDispatcherClass() { | |
| 7 | + return 'FastRoute\\Dispatcher\\CharCountBased'; | |
| 8 | + } | |
| 9 | + | |
| 10 | + protected function getDataGeneratorClass() { | |
| 11 | + return 'FastRoute\\DataGenerator\\CharCountBased'; | |
| 12 | + } | |
| 13 | +} | ... | ... |
vendor/nikic/fast-route/test/Dispatcher/DispatcherTest.php
0 → 100644
| 1 | +++ a/vendor/nikic/fast-route/test/Dispatcher/DispatcherTest.php | |
| ... | ... | @@ -0,0 +1,561 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute\Dispatcher; | |
| 4 | + | |
| 5 | +use FastRoute\RouteCollector; | |
| 6 | + | |
| 7 | +abstract class DispatcherTest extends \PHPUnit_Framework_TestCase { | |
| 8 | + | |
| 9 | + /** | |
| 10 | + * Delegate dispatcher selection to child test classes | |
| 11 | + */ | |
| 12 | + abstract protected function getDispatcherClass(); | |
| 13 | + | |
| 14 | + /** | |
| 15 | + * Delegate dataGenerator selection to child test classes | |
| 16 | + */ | |
| 17 | + abstract protected function getDataGeneratorClass(); | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * Set appropriate options for the specific Dispatcher class we're testing | |
| 21 | + */ | |
| 22 | + private function generateDispatcherOptions() { | |
| 23 | + return [ | |
| 24 | + 'dataGenerator' => $this->getDataGeneratorClass(), | |
| 25 | + 'dispatcher' => $this->getDispatcherClass() | |
| 26 | + ]; | |
| 27 | + } | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * @dataProvider provideFoundDispatchCases | |
| 31 | + */ | |
| 32 | + public function testFoundDispatches($method, $uri, $callback, $handler, $argDict) { | |
| 33 | + $dispatcher = \FastRoute\simpleDispatcher($callback, $this->generateDispatcherOptions()); | |
| 34 | + $info = $dispatcher->dispatch($method, $uri); | |
| 35 | + $this->assertSame($dispatcher::FOUND, $info[0]); | |
| 36 | + $this->assertSame($handler, $info[1]); | |
| 37 | + $this->assertSame($argDict, $info[2]); | |
| 38 | + } | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * @dataProvider provideNotFoundDispatchCases | |
| 42 | + */ | |
| 43 | + public function testNotFoundDispatches($method, $uri, $callback) { | |
| 44 | + $dispatcher = \FastRoute\simpleDispatcher($callback, $this->generateDispatcherOptions()); | |
| 45 | + $routeInfo = $dispatcher->dispatch($method, $uri); | |
| 46 | + $this->assertFalse(isset($routeInfo[1]), | |
| 47 | + "NOT_FOUND result must only contain a single element in the returned info array" | |
| 48 | + ); | |
| 49 | + $this->assertSame($dispatcher::NOT_FOUND, $routeInfo[0]); | |
| 50 | + } | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * @dataProvider provideMethodNotAllowedDispatchCases | |
| 54 | + */ | |
| 55 | + public function testMethodNotAllowedDispatches($method, $uri, $callback, $availableMethods) { | |
| 56 | + $dispatcher = \FastRoute\simpleDispatcher($callback, $this->generateDispatcherOptions()); | |
| 57 | + $routeInfo = $dispatcher->dispatch($method, $uri); | |
| 58 | + $this->assertTrue(isset($routeInfo[1]), | |
| 59 | + "METHOD_NOT_ALLOWED result must return an array of allowed methods at index 1" | |
| 60 | + ); | |
| 61 | + | |
| 62 | + list($routedStatus, $methodArray) = $dispatcher->dispatch($method, $uri); | |
| 63 | + $this->assertSame($dispatcher::METHOD_NOT_ALLOWED, $routedStatus); | |
| 64 | + $this->assertSame($availableMethods, $methodArray); | |
| 65 | + } | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * @expectedException \FastRoute\BadRouteException | |
| 69 | + * @expectedExceptionMessage Cannot use the same placeholder "test" twice | |
| 70 | + */ | |
| 71 | + public function testDuplicateVariableNameError() { | |
| 72 | + \FastRoute\simpleDispatcher(function(RouteCollector $r) { | |
| 73 | + $r->addRoute('GET', '/foo/{test}/{test:\d+}', 'handler0'); | |
| 74 | + }, $this->generateDispatcherOptions()); | |
| 75 | + } | |
| 76 | + | |
| 77 | + /** | |
| 78 | + * @expectedException \FastRoute\BadRouteException | |
| 79 | + * @expectedExceptionMessage Cannot register two routes matching "/user/([^/]+)" for method "GET" | |
| 80 | + */ | |
| 81 | + public function testDuplicateVariableRoute() { | |
| 82 | + \FastRoute\simpleDispatcher(function(RouteCollector $r) { | |
| 83 | + $r->addRoute('GET', '/user/{id}', 'handler0'); // oops, forgot \d+ restriction ;) | |
| 84 | + $r->addRoute('GET', '/user/{name}', 'handler1'); | |
| 85 | + }, $this->generateDispatcherOptions()); | |
| 86 | + } | |
| 87 | + | |
| 88 | + /** | |
| 89 | + * @expectedException \FastRoute\BadRouteException | |
| 90 | + * @expectedExceptionMessage Cannot register two routes matching "/user" for method "GET" | |
| 91 | + */ | |
| 92 | + public function testDuplicateStaticRoute() { | |
| 93 | + \FastRoute\simpleDispatcher(function(RouteCollector $r) { | |
| 94 | + $r->addRoute('GET', '/user', 'handler0'); | |
| 95 | + $r->addRoute('GET', '/user', 'handler1'); | |
| 96 | + }, $this->generateDispatcherOptions()); | |
| 97 | + } | |
| 98 | + | |
| 99 | + /** | |
| 100 | + * @expectedException \FastRoute\BadRouteException | |
| 101 | + * @expectedExceptionMessage Static route "/user/nikic" is shadowed by previously defined variable route "/user/([^/]+)" for method "GET" | |
| 102 | + */ | |
| 103 | + public function testShadowedStaticRoute() { | |
| 104 | + \FastRoute\simpleDispatcher(function(RouteCollector $r) { | |
| 105 | + $r->addRoute('GET', '/user/{name}', 'handler0'); | |
| 106 | + $r->addRoute('GET', '/user/nikic', 'handler1'); | |
| 107 | + }, $this->generateDispatcherOptions()); | |
| 108 | + } | |
| 109 | + | |
| 110 | + /** | |
| 111 | + * @expectedException \FastRoute\BadRouteException | |
| 112 | + * @expectedExceptionMessage Regex "(en|de)" for parameter "lang" contains a capturing group | |
| 113 | + */ | |
| 114 | + public function testCapturing() { | |
| 115 | + \FastRoute\simpleDispatcher(function(RouteCollector $r) { | |
| 116 | + $r->addRoute('GET', '/{lang:(en|de)}', 'handler0'); | |
| 117 | + }, $this->generateDispatcherOptions()); | |
| 118 | + } | |
| 119 | + | |
| 120 | + public function provideFoundDispatchCases() { | |
| 121 | + $cases = []; | |
| 122 | + | |
| 123 | + // 0 --------------------------------------------------------------------------------------> | |
| 124 | + | |
| 125 | + $callback = function(RouteCollector $r) { | |
| 126 | + $r->addRoute('GET', '/resource/123/456', 'handler0'); | |
| 127 | + }; | |
| 128 | + | |
| 129 | + $method = 'GET'; | |
| 130 | + $uri = '/resource/123/456'; | |
| 131 | + $handler = 'handler0'; | |
| 132 | + $argDict = []; | |
| 133 | + | |
| 134 | + $cases[] = [$method, $uri, $callback, $handler, $argDict]; | |
| 135 | + | |
| 136 | + // 1 --------------------------------------------------------------------------------------> | |
| 137 | + | |
| 138 | + $callback = function(RouteCollector $r) { | |
| 139 | + $r->addRoute('GET', '/handler0', 'handler0'); | |
| 140 | + $r->addRoute('GET', '/handler1', 'handler1'); | |
| 141 | + $r->addRoute('GET', '/handler2', 'handler2'); | |
| 142 | + }; | |
| 143 | + | |
| 144 | + $method = 'GET'; | |
| 145 | + $uri = '/handler2'; | |
| 146 | + $handler = 'handler2'; | |
| 147 | + $argDict = []; | |
| 148 | + | |
| 149 | + $cases[] = [$method, $uri, $callback, $handler, $argDict]; | |
| 150 | + | |
| 151 | + // 2 --------------------------------------------------------------------------------------> | |
| 152 | + | |
| 153 | + $callback = function(RouteCollector $r) { | |
| 154 | + $r->addRoute('GET', '/user/{name}/{id:[0-9]+}', 'handler0'); | |
| 155 | + $r->addRoute('GET', '/user/{id:[0-9]+}', 'handler1'); | |
| 156 | + $r->addRoute('GET', '/user/{name}', 'handler2'); | |
| 157 | + }; | |
| 158 | + | |
| 159 | + $method = 'GET'; | |
| 160 | + $uri = '/user/rdlowrey'; | |
| 161 | + $handler = 'handler2'; | |
| 162 | + $argDict = ['name' => 'rdlowrey']; | |
| 163 | + | |
| 164 | + $cases[] = [$method, $uri, $callback, $handler, $argDict]; | |
| 165 | + | |
| 166 | + // 3 --------------------------------------------------------------------------------------> | |
| 167 | + | |
| 168 | + // reuse $callback from #2 | |
| 169 | + | |
| 170 | + $method = 'GET'; | |
| 171 | + $uri = '/user/12345'; | |
| 172 | + $handler = 'handler1'; | |
| 173 | + $argDict = ['id' => '12345']; | |
| 174 | + | |
| 175 | + $cases[] = [$method, $uri, $callback, $handler, $argDict]; | |
| 176 | + | |
| 177 | + // 4 --------------------------------------------------------------------------------------> | |
| 178 | + | |
| 179 | + // reuse $callback from #3 | |
| 180 | + | |
| 181 | + $method = 'GET'; | |
| 182 | + $uri = '/user/NaN'; | |
| 183 | + $handler = 'handler2'; | |
| 184 | + $argDict = ['name' => 'NaN']; | |
| 185 | + | |
| 186 | + $cases[] = [$method, $uri, $callback, $handler, $argDict]; | |
| 187 | + | |
| 188 | + // 5 --------------------------------------------------------------------------------------> | |
| 189 | + | |
| 190 | + // reuse $callback from #4 | |
| 191 | + | |
| 192 | + $method = 'GET'; | |
| 193 | + $uri = '/user/rdlowrey/12345'; | |
| 194 | + $handler = 'handler0'; | |
| 195 | + $argDict = ['name' => 'rdlowrey', 'id' => '12345']; | |
| 196 | + | |
| 197 | + $cases[] = [$method, $uri, $callback, $handler, $argDict]; | |
| 198 | + | |
| 199 | + // 6 --------------------------------------------------------------------------------------> | |
| 200 | + | |
| 201 | + $callback = function(RouteCollector $r) { | |
| 202 | + $r->addRoute('GET', '/user/{id:[0-9]+}', 'handler0'); | |
| 203 | + $r->addRoute('GET', '/user/12345/extension', 'handler1'); | |
| 204 | + $r->addRoute('GET', '/user/{id:[0-9]+}.{extension}', 'handler2'); | |
| 205 | + | |
| 206 | + }; | |
| 207 | + | |
| 208 | + $method = 'GET'; | |
| 209 | + $uri = '/user/12345.svg'; | |
| 210 | + $handler = 'handler2'; | |
| 211 | + $argDict = ['id' => '12345', 'extension' => 'svg']; | |
| 212 | + | |
| 213 | + $cases[] = [$method, $uri, $callback, $handler, $argDict]; | |
| 214 | + | |
| 215 | + // 7 ----- Test GET method fallback on HEAD route miss ------------------------------------> | |
| 216 | + | |
| 217 | + $callback = function(RouteCollector $r) { | |
| 218 | + $r->addRoute('GET', '/user/{name}', 'handler0'); | |
| 219 | + $r->addRoute('GET', '/user/{name}/{id:[0-9]+}', 'handler1'); | |
| 220 | + $r->addRoute('GET', '/static0', 'handler2'); | |
| 221 | + $r->addRoute('GET', '/static1', 'handler3'); | |
| 222 | + $r->addRoute('HEAD', '/static1', 'handler4'); | |
| 223 | + }; | |
| 224 | + | |
| 225 | + $method = 'HEAD'; | |
| 226 | + $uri = '/user/rdlowrey'; | |
| 227 | + $handler = 'handler0'; | |
| 228 | + $argDict = ['name' => 'rdlowrey']; | |
| 229 | + | |
| 230 | + $cases[] = [$method, $uri, $callback, $handler, $argDict]; | |
| 231 | + | |
| 232 | + // 8 ----- Test GET method fallback on HEAD route miss ------------------------------------> | |
| 233 | + | |
| 234 | + // reuse $callback from #7 | |
| 235 | + | |
| 236 | + $method = 'HEAD'; | |
| 237 | + $uri = '/user/rdlowrey/1234'; | |
| 238 | + $handler = 'handler1'; | |
| 239 | + $argDict = ['name' => 'rdlowrey', 'id' => '1234']; | |
| 240 | + | |
| 241 | + $cases[] = [$method, $uri, $callback, $handler, $argDict]; | |
| 242 | + | |
| 243 | + // 9 ----- Test GET method fallback on HEAD route miss ------------------------------------> | |
| 244 | + | |
| 245 | + // reuse $callback from #8 | |
| 246 | + | |
| 247 | + $method = 'HEAD'; | |
| 248 | + $uri = '/static0'; | |
| 249 | + $handler = 'handler2'; | |
| 250 | + $argDict = []; | |
| 251 | + | |
| 252 | + $cases[] = [$method, $uri, $callback, $handler, $argDict]; | |
| 253 | + | |
| 254 | + // 10 ---- Test existing HEAD route used if available (no fallback) -----------------------> | |
| 255 | + | |
| 256 | + // reuse $callback from #9 | |
| 257 | + | |
| 258 | + $method = 'HEAD'; | |
| 259 | + $uri = '/static1'; | |
| 260 | + $handler = 'handler4'; | |
| 261 | + $argDict = []; | |
| 262 | + | |
| 263 | + $cases[] = [$method, $uri, $callback, $handler, $argDict]; | |
| 264 | + | |
| 265 | + // 11 ---- More specified routes are not shadowed by less specific of another method ------> | |
| 266 | + | |
| 267 | + $callback = function(RouteCollector $r) { | |
| 268 | + $r->addRoute('GET', '/user/{name}', 'handler0'); | |
| 269 | + $r->addRoute('POST', '/user/{name:[a-z]+}', 'handler1'); | |
| 270 | + }; | |
| 271 | + | |
| 272 | + $method = 'POST'; | |
| 273 | + $uri = '/user/rdlowrey'; | |
| 274 | + $handler = 'handler1'; | |
| 275 | + $argDict = ['name' => 'rdlowrey']; | |
| 276 | + | |
| 277 | + $cases[] = [$method, $uri, $callback, $handler, $argDict]; | |
| 278 | + | |
| 279 | + // 12 ---- Handler of more specific routes is used, if it occurs first --------------------> | |
| 280 | + | |
| 281 | + $callback = function(RouteCollector $r) { | |
| 282 | + $r->addRoute('GET', '/user/{name}', 'handler0'); | |
| 283 | + $r->addRoute('POST', '/user/{name:[a-z]+}', 'handler1'); | |
| 284 | + $r->addRoute('POST', '/user/{name}', 'handler2'); | |
| 285 | + }; | |
| 286 | + | |
| 287 | + $method = 'POST'; | |
| 288 | + $uri = '/user/rdlowrey'; | |
| 289 | + $handler = 'handler1'; | |
| 290 | + $argDict = ['name' => 'rdlowrey']; | |
| 291 | + | |
| 292 | + $cases[] = [$method, $uri, $callback, $handler, $argDict]; | |
| 293 | + | |
| 294 | + // 13 ---- Route with constant suffix -----------------------------------------------------> | |
| 295 | + | |
| 296 | + $callback = function(RouteCollector $r) { | |
| 297 | + $r->addRoute('GET', '/user/{name}', 'handler0'); | |
| 298 | + $r->addRoute('GET', '/user/{name}/edit', 'handler1'); | |
| 299 | + }; | |
| 300 | + | |
| 301 | + $method = 'GET'; | |
| 302 | + $uri = '/user/rdlowrey/edit'; | |
| 303 | + $handler = 'handler1'; | |
| 304 | + $argDict = ['name' => 'rdlowrey']; | |
| 305 | + | |
| 306 | + $cases[] = [$method, $uri, $callback, $handler, $argDict]; | |
| 307 | + | |
| 308 | + // 14 ---- Handle multiple methods with the same handler ----------------------------------> | |
| 309 | + | |
| 310 | + $callback = function(RouteCollector $r) { | |
| 311 | + $r->addRoute(['GET', 'POST'], '/user', 'handlerGetPost'); | |
| 312 | + $r->addRoute(['DELETE'], '/user', 'handlerDelete'); | |
| 313 | + $r->addRoute([], '/user', 'handlerNone'); | |
| 314 | + }; | |
| 315 | + | |
| 316 | + $argDict = []; | |
| 317 | + $cases[] = ['GET', '/user', $callback, 'handlerGetPost', $argDict]; | |
| 318 | + $cases[] = ['POST', '/user', $callback, 'handlerGetPost', $argDict]; | |
| 319 | + $cases[] = ['DELETE', '/user', $callback, 'handlerDelete', $argDict]; | |
| 320 | + | |
| 321 | + // 15 ---- | |
| 322 | + | |
| 323 | + $callback = function(RouteCollector $r) { | |
| 324 | + $r->addRoute('POST', '/user.json', 'handler0'); | |
| 325 | + $r->addRoute('GET', '/{entity}.json', 'handler1'); | |
| 326 | + }; | |
| 327 | + | |
| 328 | + $cases[] = ['GET', '/user.json', $callback, 'handler1', ['entity' => 'user']]; | |
| 329 | + | |
| 330 | + // 16 ---- | |
| 331 | + | |
| 332 | + $callback = function(RouteCollector $r) { | |
| 333 | + $r->addRoute('GET', '', 'handler0'); | |
| 334 | + }; | |
| 335 | + | |
| 336 | + $cases[] = ['GET', '', $callback, 'handler0', []]; | |
| 337 | + | |
| 338 | + // 17 ---- | |
| 339 | + | |
| 340 | + $callback = function(RouteCollector $r) { | |
| 341 | + $r->addRoute('HEAD', '/a/{foo}', 'handler0'); | |
| 342 | + $r->addRoute('GET', '/b/{foo}', 'handler1'); | |
| 343 | + }; | |
| 344 | + | |
| 345 | + $cases[] = ['HEAD', '/b/bar', $callback, 'handler1', ['foo' => 'bar']]; | |
| 346 | + | |
| 347 | + // 18 ---- | |
| 348 | + | |
| 349 | + $callback = function(RouteCollector $r) { | |
| 350 | + $r->addRoute('HEAD', '/a', 'handler0'); | |
| 351 | + $r->addRoute('GET', '/b', 'handler1'); | |
| 352 | + }; | |
| 353 | + | |
| 354 | + $cases[] = ['HEAD', '/b', $callback, 'handler1', []]; | |
| 355 | + | |
| 356 | + // 19 ---- | |
| 357 | + | |
| 358 | + $callback = function(RouteCollector $r) { | |
| 359 | + $r->addRoute('GET', '/foo', 'handler0'); | |
| 360 | + $r->addRoute('HEAD', '/{bar}', 'handler1'); | |
| 361 | + }; | |
| 362 | + | |
| 363 | + $cases[] = ['HEAD', '/foo', $callback, 'handler1', ['bar' => 'foo']]; | |
| 364 | + | |
| 365 | + // 20 ---- | |
| 366 | + | |
| 367 | + $callback = function(RouteCollector $r) { | |
| 368 | + $r->addRoute('*', '/user', 'handler0'); | |
| 369 | + $r->addRoute('*', '/{user}', 'handler1'); | |
| 370 | + $r->addRoute('GET', '/user', 'handler2'); | |
| 371 | + }; | |
| 372 | + | |
| 373 | + $cases[] = ['GET', '/user', $callback, 'handler2', []]; | |
| 374 | + | |
| 375 | + // 21 ---- | |
| 376 | + | |
| 377 | + $callback = function(RouteCollector $r) { | |
| 378 | + $r->addRoute('*', '/user', 'handler0'); | |
| 379 | + $r->addRoute('GET', '/user', 'handler1'); | |
| 380 | + }; | |
| 381 | + | |
| 382 | + $cases[] = ['POST', '/user', $callback, 'handler0', []]; | |
| 383 | + | |
| 384 | + // 22 ---- | |
| 385 | + | |
| 386 | + $cases[] = ['HEAD', '/user', $callback, 'handler1', []]; | |
| 387 | + | |
| 388 | + // 23 ---- | |
| 389 | + | |
| 390 | + $callback = function(RouteCollector $r) { | |
| 391 | + $r->addRoute('GET', '/{bar}', 'handler0'); | |
| 392 | + $r->addRoute('*', '/foo', 'handler1'); | |
| 393 | + }; | |
| 394 | + | |
| 395 | + $cases[] = ['GET', '/foo', $callback, 'handler0', ['bar' => 'foo']]; | |
| 396 | + | |
| 397 | + // x --------------------------------------------------------------------------------------> | |
| 398 | + | |
| 399 | + return $cases; | |
| 400 | + } | |
| 401 | + | |
| 402 | + public function provideNotFoundDispatchCases() { | |
| 403 | + $cases = []; | |
| 404 | + | |
| 405 | + // 0 --------------------------------------------------------------------------------------> | |
| 406 | + | |
| 407 | + $callback = function(RouteCollector $r) { | |
| 408 | + $r->addRoute('GET', '/resource/123/456', 'handler0'); | |
| 409 | + }; | |
| 410 | + | |
| 411 | + $method = 'GET'; | |
| 412 | + $uri = '/not-found'; | |
| 413 | + | |
| 414 | + $cases[] = [$method, $uri, $callback]; | |
| 415 | + | |
| 416 | + // 1 --------------------------------------------------------------------------------------> | |
| 417 | + | |
| 418 | + // reuse callback from #0 | |
| 419 | + $method = 'POST'; | |
| 420 | + $uri = '/not-found'; | |
| 421 | + | |
| 422 | + $cases[] = [$method, $uri, $callback]; | |
| 423 | + | |
| 424 | + // 2 --------------------------------------------------------------------------------------> | |
| 425 | + | |
| 426 | + // reuse callback from #1 | |
| 427 | + $method = 'PUT'; | |
| 428 | + $uri = '/not-found'; | |
| 429 | + | |
| 430 | + $cases[] = [$method, $uri, $callback]; | |
| 431 | + | |
| 432 | + // 3 --------------------------------------------------------------------------------------> | |
| 433 | + | |
| 434 | + $callback = function(RouteCollector $r) { | |
| 435 | + $r->addRoute('GET', '/handler0', 'handler0'); | |
| 436 | + $r->addRoute('GET', '/handler1', 'handler1'); | |
| 437 | + $r->addRoute('GET', '/handler2', 'handler2'); | |
| 438 | + }; | |
| 439 | + | |
| 440 | + $method = 'GET'; | |
| 441 | + $uri = '/not-found'; | |
| 442 | + | |
| 443 | + $cases[] = [$method, $uri, $callback]; | |
| 444 | + | |
| 445 | + // 4 --------------------------------------------------------------------------------------> | |
| 446 | + | |
| 447 | + $callback = function(RouteCollector $r) { | |
| 448 | + $r->addRoute('GET', '/user/{name}/{id:[0-9]+}', 'handler0'); | |
| 449 | + $r->addRoute('GET', '/user/{id:[0-9]+}', 'handler1'); | |
| 450 | + $r->addRoute('GET', '/user/{name}', 'handler2'); | |
| 451 | + }; | |
| 452 | + | |
| 453 | + $method = 'GET'; | |
| 454 | + $uri = '/not-found'; | |
| 455 | + | |
| 456 | + $cases[] = [$method, $uri, $callback]; | |
| 457 | + | |
| 458 | + // 5 --------------------------------------------------------------------------------------> | |
| 459 | + | |
| 460 | + // reuse callback from #4 | |
| 461 | + $method = 'GET'; | |
| 462 | + $uri = '/user/rdlowrey/12345/not-found'; | |
| 463 | + | |
| 464 | + $cases[] = [$method, $uri, $callback]; | |
| 465 | + | |
| 466 | + // 6 --------------------------------------------------------------------------------------> | |
| 467 | + | |
| 468 | + // reuse callback from #5 | |
| 469 | + $method = 'HEAD'; | |
| 470 | + | |
| 471 | + $cases[] = array($method, $uri, $callback); | |
| 472 | + | |
| 473 | + // x --------------------------------------------------------------------------------------> | |
| 474 | + | |
| 475 | + return $cases; | |
| 476 | + } | |
| 477 | + | |
| 478 | + public function provideMethodNotAllowedDispatchCases() { | |
| 479 | + $cases = []; | |
| 480 | + | |
| 481 | + // 0 --------------------------------------------------------------------------------------> | |
| 482 | + | |
| 483 | + $callback = function(RouteCollector $r) { | |
| 484 | + $r->addRoute('GET', '/resource/123/456', 'handler0'); | |
| 485 | + }; | |
| 486 | + | |
| 487 | + $method = 'POST'; | |
| 488 | + $uri = '/resource/123/456'; | |
| 489 | + $allowedMethods = ['GET']; | |
| 490 | + | |
| 491 | + $cases[] = [$method, $uri, $callback, $allowedMethods]; | |
| 492 | + | |
| 493 | + // 1 --------------------------------------------------------------------------------------> | |
| 494 | + | |
| 495 | + $callback = function(RouteCollector $r) { | |
| 496 | + $r->addRoute('GET', '/resource/123/456', 'handler0'); | |
| 497 | + $r->addRoute('POST', '/resource/123/456', 'handler1'); | |
| 498 | + $r->addRoute('PUT', '/resource/123/456', 'handler2'); | |
| 499 | + $r->addRoute('*', '/', 'handler3'); | |
| 500 | + }; | |
| 501 | + | |
| 502 | + $method = 'DELETE'; | |
| 503 | + $uri = '/resource/123/456'; | |
| 504 | + $allowedMethods = ['GET', 'POST', 'PUT']; | |
| 505 | + | |
| 506 | + $cases[] = [$method, $uri, $callback, $allowedMethods]; | |
| 507 | + | |
| 508 | + // 2 --------------------------------------------------------------------------------------> | |
| 509 | + | |
| 510 | + $callback = function(RouteCollector $r) { | |
| 511 | + $r->addRoute('GET', '/user/{name}/{id:[0-9]+}', 'handler0'); | |
| 512 | + $r->addRoute('POST', '/user/{name}/{id:[0-9]+}', 'handler1'); | |
| 513 | + $r->addRoute('PUT', '/user/{name}/{id:[0-9]+}', 'handler2'); | |
| 514 | + $r->addRoute('PATCH', '/user/{name}/{id:[0-9]+}', 'handler3'); | |
| 515 | + }; | |
| 516 | + | |
| 517 | + $method = 'DELETE'; | |
| 518 | + $uri = '/user/rdlowrey/42'; | |
| 519 | + $allowedMethods = ['GET', 'POST', 'PUT', 'PATCH']; | |
| 520 | + | |
| 521 | + $cases[] = [$method, $uri, $callback, $allowedMethods]; | |
| 522 | + | |
| 523 | + // 3 --------------------------------------------------------------------------------------> | |
| 524 | + | |
| 525 | + $callback = function(RouteCollector $r) { | |
| 526 | + $r->addRoute('POST', '/user/{name}', 'handler1'); | |
| 527 | + $r->addRoute('PUT', '/user/{name:[a-z]+}', 'handler2'); | |
| 528 | + $r->addRoute('PATCH', '/user/{name:[a-z]+}', 'handler3'); | |
| 529 | + }; | |
| 530 | + | |
| 531 | + $method = 'GET'; | |
| 532 | + $uri = '/user/rdlowrey'; | |
| 533 | + $allowedMethods = ['POST', 'PUT', 'PATCH']; | |
| 534 | + | |
| 535 | + $cases[] = [$method, $uri, $callback, $allowedMethods]; | |
| 536 | + | |
| 537 | + // 4 --------------------------------------------------------------------------------------> | |
| 538 | + | |
| 539 | + $callback = function(RouteCollector $r) { | |
| 540 | + $r->addRoute(['GET', 'POST'], '/user', 'handlerGetPost'); | |
| 541 | + $r->addRoute(['DELETE'], '/user', 'handlerDelete'); | |
| 542 | + $r->addRoute([], '/user', 'handlerNone'); | |
| 543 | + }; | |
| 544 | + | |
| 545 | + $cases[] = ['PUT', '/user', $callback, ['GET', 'POST', 'DELETE']]; | |
| 546 | + | |
| 547 | + // 5 | |
| 548 | + | |
| 549 | + $callback = function(RouteCollector $r) { | |
| 550 | + $r->addRoute('POST', '/user.json', 'handler0'); | |
| 551 | + $r->addRoute('GET', '/{entity}.json', 'handler1'); | |
| 552 | + }; | |
| 553 | + | |
| 554 | + $cases[] = ['PUT', '/user.json', $callback, ['POST', 'GET']]; | |
| 555 | + | |
| 556 | + // x --------------------------------------------------------------------------------------> | |
| 557 | + | |
| 558 | + return $cases; | |
| 559 | + } | |
| 560 | + | |
| 561 | +} | ... | ... |
vendor/nikic/fast-route/test/Dispatcher/GroupCountBasedTest.php
0 → 100644
| 1 | +++ a/vendor/nikic/fast-route/test/Dispatcher/GroupCountBasedTest.php | |
| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute\Dispatcher; | |
| 4 | + | |
| 5 | +class GroupCountBasedTest extends DispatcherTest { | |
| 6 | + protected function getDispatcherClass() { | |
| 7 | + return 'FastRoute\\Dispatcher\\GroupCountBased'; | |
| 8 | + } | |
| 9 | + | |
| 10 | + protected function getDataGeneratorClass() { | |
| 11 | + return 'FastRoute\\DataGenerator\\GroupCountBased'; | |
| 12 | + } | |
| 13 | +} | ... | ... |
vendor/nikic/fast-route/test/Dispatcher/GroupPosBasedTest.php
0 → 100644
| 1 | +++ a/vendor/nikic/fast-route/test/Dispatcher/GroupPosBasedTest.php | |
| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute\Dispatcher; | |
| 4 | + | |
| 5 | +class GroupPosBasedTest extends DispatcherTest { | |
| 6 | + protected function getDispatcherClass() { | |
| 7 | + return 'FastRoute\\Dispatcher\\GroupPosBased'; | |
| 8 | + } | |
| 9 | + | |
| 10 | + protected function getDataGeneratorClass() { | |
| 11 | + return 'FastRoute\\DataGenerator\\GroupPosBased'; | |
| 12 | + } | |
| 13 | +} | ... | ... |
vendor/nikic/fast-route/test/Dispatcher/MarkBasedTest.php
0 → 100644
| 1 | +++ a/vendor/nikic/fast-route/test/Dispatcher/MarkBasedTest.php | |
| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute\Dispatcher; | |
| 4 | + | |
| 5 | +class MarkBasedTest extends DispatcherTest { | |
| 6 | + public function setUp() { | |
| 7 | + preg_match('/(*MARK:A)a/', 'a', $matches); | |
| 8 | + if (!isset($matches['MARK'])) { | |
| 9 | + $this->markTestSkipped('PHP 5.6 required for MARK support'); | |
| 10 | + } | |
| 11 | + } | |
| 12 | + | |
| 13 | + protected function getDispatcherClass() { | |
| 14 | + return 'FastRoute\\Dispatcher\\MarkBased'; | |
| 15 | + } | |
| 16 | + | |
| 17 | + protected function getDataGeneratorClass() { | |
| 18 | + return 'FastRoute\\DataGenerator\\MarkBased'; | |
| 19 | + } | |
| 20 | +} | ... | ... |
vendor/nikic/fast-route/test/HackTypechecker/HackTypecheckerTest.php
0 → 100644
| 1 | +++ a/vendor/nikic/fast-route/test/HackTypechecker/HackTypecheckerTest.php | |
| ... | ... | @@ -0,0 +1,39 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute; | |
| 4 | + | |
| 5 | +class HackTypecheckerTest extends \PhpUnit_Framework_TestCase { | |
| 6 | + const SERVER_ALREADY_RUNNING_CODE = 77; | |
| 7 | + public function testTypechecks($recurse = true) { | |
| 8 | + if (!defined('HHVM_VERSION')) { | |
| 9 | + $this->markTestSkipped("HHVM only"); | |
| 10 | + } | |
| 11 | + if (!version_compare(HHVM_VERSION, '3.9.0', '>=')) { | |
| 12 | + $this->markTestSkipped('classname<T> requires HHVM 3.9+'); | |
| 13 | + } | |
| 14 | + | |
| 15 | + // The typechecker recurses the whole tree, so it makes sure | |
| 16 | + // that everything in fixtures/ is valid when this runs. | |
| 17 | + | |
| 18 | + $output = array(); | |
| 19 | + $exit_code = null; | |
| 20 | + exec( | |
| 21 | + 'hh_server --check '.escapeshellarg(__DIR__.'/../../').' 2>&1', | |
| 22 | + $output, | |
| 23 | + $exit_code | |
| 24 | + ); | |
| 25 | + if ($exit_code === self::SERVER_ALREADY_RUNNING_CODE) { | |
| 26 | + $this->assertTrue( | |
| 27 | + $recurse, | |
| 28 | + "Typechecker still running after running hh_client stop" | |
| 29 | + ); | |
| 30 | + // Server already running - 3.10 => 3.11 regression: | |
| 31 | + // https://github.com/facebook/hhvm/issues/6646 | |
| 32 | + exec('hh_client stop 2>/dev/null'); | |
| 33 | + $this->testTypechecks(/* recurse = */ false); | |
| 34 | + return; | |
| 35 | + | |
| 36 | + } | |
| 37 | + $this->assertSame(0, $exit_code, implode("\n", $output)); | |
| 38 | + } | |
| 39 | +} | ... | ... |
vendor/nikic/fast-route/test/HackTypechecker/fixtures/all_options.php
0 → 100644
| 1 | +++ a/vendor/nikic/fast-route/test/HackTypechecker/fixtures/all_options.php | |
| ... | ... | @@ -0,0 +1,29 @@ |
| 1 | +<?hh | |
| 2 | + | |
| 3 | +namespace FastRoute\TestFixtures; | |
| 4 | + | |
| 5 | +function all_options_simple(): \FastRoute\Dispatcher { | |
| 6 | + return \FastRoute\simpleDispatcher( | |
| 7 | + $collector ==> {}, | |
| 8 | + shape( | |
| 9 | + 'routeParser' => \FastRoute\RouteParser\Std::class, | |
| 10 | + 'dataGenerator' => \FastRoute\DataGenerator\GroupCountBased::class, | |
| 11 | + 'dispatcher' => \FastRoute\Dispatcher\GroupCountBased::class, | |
| 12 | + 'routeCollector' => \FastRoute\RouteCollector::class, | |
| 13 | + ), | |
| 14 | + ); | |
| 15 | +} | |
| 16 | + | |
| 17 | +function all_options_cached(): \FastRoute\Dispatcher { | |
| 18 | + return \FastRoute\cachedDispatcher( | |
| 19 | + $collector ==> {}, | |
| 20 | + shape( | |
| 21 | + 'routeParser' => \FastRoute\RouteParser\Std::class, | |
| 22 | + 'dataGenerator' => \FastRoute\DataGenerator\GroupCountBased::class, | |
| 23 | + 'dispatcher' => \FastRoute\Dispatcher\GroupCountBased::class, | |
| 24 | + 'routeCollector' => \FastRoute\RouteCollector::class, | |
| 25 | + 'cacheFile' => '/dev/null', | |
| 26 | + 'cacheDisabled' => false, | |
| 27 | + ), | |
| 28 | + ); | |
| 29 | +} | ... | ... |
vendor/nikic/fast-route/test/HackTypechecker/fixtures/empty_options.php
0 → 100644
| 1 | +++ a/vendor/nikic/fast-route/test/HackTypechecker/fixtures/empty_options.php | |
| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | +<?hh | |
| 2 | + | |
| 3 | +namespace FastRoute\TestFixtures; | |
| 4 | + | |
| 5 | +function empty_options_simple(): \FastRoute\Dispatcher { | |
| 6 | + return \FastRoute\simpleDispatcher($collector ==> {}, shape()); | |
| 7 | +} | |
| 8 | + | |
| 9 | +function empty_options_cached(): \FastRoute\Dispatcher { | |
| 10 | + return \FastRoute\cachedDispatcher($collector ==> {}, shape()); | |
| 11 | +} | ... | ... |
vendor/nikic/fast-route/test/HackTypechecker/fixtures/no_options.php
0 → 100644
| 1 | +++ a/vendor/nikic/fast-route/test/HackTypechecker/fixtures/no_options.php | |
| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | +<?hh | |
| 2 | + | |
| 3 | +namespace FastRoute\TestFixtures; | |
| 4 | + | |
| 5 | +function no_options_simple(): \FastRoute\Dispatcher { | |
| 6 | + return \FastRoute\simpleDispatcher($collector ==> {}); | |
| 7 | +} | |
| 8 | + | |
| 9 | +function no_options_cached(): \FastRoute\Dispatcher { | |
| 10 | + return \FastRoute\cachedDispatcher($collector ==> {}); | |
| 11 | +} | ... | ... |
| 1 | +++ a/vendor/nikic/fast-route/test/RouteCollectorTest.php | |
| ... | ... | @@ -0,0 +1,97 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute; | |
| 4 | + | |
| 5 | +class RouteCollectorTest extends \PHPUnit_Framework_TestCase { | |
| 6 | + public function testShortcuts() { | |
| 7 | + $r = new DummyRouteCollector(); | |
| 8 | + | |
| 9 | + $r->delete('/delete', 'delete'); | |
| 10 | + $r->get('/get', 'get'); | |
| 11 | + $r->head('/head', 'head'); | |
| 12 | + $r->patch('/patch', 'patch'); | |
| 13 | + $r->post('/post', 'post'); | |
| 14 | + $r->put('/put', 'put'); | |
| 15 | + | |
| 16 | + $expected = [ | |
| 17 | + ['DELETE', '/delete', 'delete'], | |
| 18 | + ['GET', '/get', 'get'], | |
| 19 | + ['HEAD', '/head', 'head'], | |
| 20 | + ['PATCH', '/patch', 'patch'], | |
| 21 | + ['POST', '/post', 'post'], | |
| 22 | + ['PUT', '/put', 'put'], | |
| 23 | + ]; | |
| 24 | + | |
| 25 | + $this->assertSame($expected, $r->routes); | |
| 26 | + } | |
| 27 | + | |
| 28 | + public function testGroups() { | |
| 29 | + $r = new DummyRouteCollector(); | |
| 30 | + | |
| 31 | + $r->delete('/delete', 'delete'); | |
| 32 | + $r->get('/get', 'get'); | |
| 33 | + $r->head('/head', 'head'); | |
| 34 | + $r->patch('/patch', 'patch'); | |
| 35 | + $r->post('/post', 'post'); | |
| 36 | + $r->put('/put', 'put'); | |
| 37 | + | |
| 38 | + $r->addGroup('/group-one', function (DummyRouteCollector $r) { | |
| 39 | + $r->delete('/delete', 'delete'); | |
| 40 | + $r->get('/get', 'get'); | |
| 41 | + $r->head('/head', 'head'); | |
| 42 | + $r->patch('/patch', 'patch'); | |
| 43 | + $r->post('/post', 'post'); | |
| 44 | + $r->put('/put', 'put'); | |
| 45 | + | |
| 46 | + $r->addGroup('/group-two', function (DummyRouteCollector $r) { | |
| 47 | + $r->delete('/delete', 'delete'); | |
| 48 | + $r->get('/get', 'get'); | |
| 49 | + $r->head('/head', 'head'); | |
| 50 | + $r->patch('/patch', 'patch'); | |
| 51 | + $r->post('/post', 'post'); | |
| 52 | + $r->put('/put', 'put'); | |
| 53 | + }); | |
| 54 | + }); | |
| 55 | + | |
| 56 | + $r->addGroup('/admin', function (DummyRouteCollector $r) { | |
| 57 | + $r->get('-some-info', 'admin-some-info'); | |
| 58 | + }); | |
| 59 | + $r->addGroup('/admin-', function (DummyRouteCollector $r) { | |
| 60 | + $r->get('more-info', 'admin-more-info'); | |
| 61 | + }); | |
| 62 | + | |
| 63 | + $expected = [ | |
| 64 | + ['DELETE', '/delete', 'delete'], | |
| 65 | + ['GET', '/get', 'get'], | |
| 66 | + ['HEAD', '/head', 'head'], | |
| 67 | + ['PATCH', '/patch', 'patch'], | |
| 68 | + ['POST', '/post', 'post'], | |
| 69 | + ['PUT', '/put', 'put'], | |
| 70 | + ['DELETE', '/group-one/delete', 'delete'], | |
| 71 | + ['GET', '/group-one/get', 'get'], | |
| 72 | + ['HEAD', '/group-one/head', 'head'], | |
| 73 | + ['PATCH', '/group-one/patch', 'patch'], | |
| 74 | + ['POST', '/group-one/post', 'post'], | |
| 75 | + ['PUT', '/group-one/put', 'put'], | |
| 76 | + ['DELETE', '/group-one/group-two/delete', 'delete'], | |
| 77 | + ['GET', '/group-one/group-two/get', 'get'], | |
| 78 | + ['HEAD', '/group-one/group-two/head', 'head'], | |
| 79 | + ['PATCH', '/group-one/group-two/patch', 'patch'], | |
| 80 | + ['POST', '/group-one/group-two/post', 'post'], | |
| 81 | + ['PUT', '/group-one/group-two/put', 'put'], | |
| 82 | + ['GET', '/admin-some-info', 'admin-some-info'], | |
| 83 | + ['GET', '/admin-more-info', 'admin-more-info'], | |
| 84 | + ]; | |
| 85 | + | |
| 86 | + $this->assertSame($expected, $r->routes); | |
| 87 | + } | |
| 88 | +} | |
| 89 | + | |
| 90 | +class DummyRouteCollector extends RouteCollector { | |
| 91 | + public $routes = []; | |
| 92 | + public function __construct() {} | |
| 93 | + public function addRoute($method, $route, $handler) { | |
| 94 | + $route = $this->currentGroupPrefix . $route; | |
| 95 | + $this->routes[] = [$method, $route, $handler]; | |
| 96 | + } | |
| 97 | +} | |
| 0 | 98 | \ No newline at end of file | ... | ... |
| 1 | +++ a/vendor/nikic/fast-route/test/RouteParser/StdTest.php | |
| ... | ... | @@ -0,0 +1,147 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FastRoute\RouteParser; | |
| 4 | + | |
| 5 | +class StdTest extends \PhpUnit_Framework_TestCase { | |
| 6 | + /** @dataProvider provideTestParse */ | |
| 7 | + public function testParse($routeString, $expectedRouteDatas) { | |
| 8 | + $parser = new Std(); | |
| 9 | + $routeDatas = $parser->parse($routeString); | |
| 10 | + $this->assertSame($expectedRouteDatas, $routeDatas); | |
| 11 | + } | |
| 12 | + | |
| 13 | + /** @dataProvider provideTestParseError */ | |
| 14 | + public function testParseError($routeString, $expectedExceptionMessage) { | |
| 15 | + $parser = new Std(); | |
| 16 | + $this->setExpectedException('FastRoute\\BadRouteException', $expectedExceptionMessage); | |
| 17 | + $parser->parse($routeString); | |
| 18 | + } | |
| 19 | + | |
| 20 | + public function provideTestParse() { | |
| 21 | + return [ | |
| 22 | + [ | |
| 23 | + '/test', | |
| 24 | + [ | |
| 25 | + ['/test'], | |
| 26 | + ] | |
| 27 | + ], | |
| 28 | + [ | |
| 29 | + '/test/{param}', | |
| 30 | + [ | |
| 31 | + ['/test/', ['param', '[^/]+']], | |
| 32 | + ] | |
| 33 | + ], | |
| 34 | + [ | |
| 35 | + '/te{ param }st', | |
| 36 | + [ | |
| 37 | + ['/te', ['param', '[^/]+'], 'st'] | |
| 38 | + ] | |
| 39 | + ], | |
| 40 | + [ | |
| 41 | + '/test/{param1}/test2/{param2}', | |
| 42 | + [ | |
| 43 | + ['/test/', ['param1', '[^/]+'], '/test2/', ['param2', '[^/]+']] | |
| 44 | + ] | |
| 45 | + ], | |
| 46 | + [ | |
| 47 | + '/test/{param:\d+}', | |
| 48 | + [ | |
| 49 | + ['/test/', ['param', '\d+']] | |
| 50 | + ] | |
| 51 | + ], | |
| 52 | + [ | |
| 53 | + '/test/{ param : \d{1,9} }', | |
| 54 | + [ | |
| 55 | + ['/test/', ['param', '\d{1,9}']] | |
| 56 | + ] | |
| 57 | + ], | |
| 58 | + [ | |
| 59 | + '/test[opt]', | |
| 60 | + [ | |
| 61 | + ['/test'], | |
| 62 | + ['/testopt'], | |
| 63 | + ] | |
| 64 | + ], | |
| 65 | + [ | |
| 66 | + '/test[/{param}]', | |
| 67 | + [ | |
| 68 | + ['/test'], | |
| 69 | + ['/test/', ['param', '[^/]+']], | |
| 70 | + ] | |
| 71 | + ], | |
| 72 | + [ | |
| 73 | + '/{param}[opt]', | |
| 74 | + [ | |
| 75 | + ['/', ['param', '[^/]+']], | |
| 76 | + ['/', ['param', '[^/]+'], 'opt'] | |
| 77 | + ] | |
| 78 | + ], | |
| 79 | + [ | |
| 80 | + '/test[/{name}[/{id:[0-9]+}]]', | |
| 81 | + [ | |
| 82 | + ['/test'], | |
| 83 | + ['/test/', ['name', '[^/]+']], | |
| 84 | + ['/test/', ['name', '[^/]+'], '/', ['id', '[0-9]+']], | |
| 85 | + ] | |
| 86 | + ], | |
| 87 | + [ | |
| 88 | + '', | |
| 89 | + [ | |
| 90 | + [''], | |
| 91 | + ] | |
| 92 | + ], | |
| 93 | + [ | |
| 94 | + '[test]', | |
| 95 | + [ | |
| 96 | + [''], | |
| 97 | + ['test'], | |
| 98 | + ] | |
| 99 | + ], | |
| 100 | + [ | |
| 101 | + '/{foo-bar}', | |
| 102 | + [ | |
| 103 | + ['/', ['foo-bar', '[^/]+']] | |
| 104 | + ] | |
| 105 | + ], | |
| 106 | + [ | |
| 107 | + '/{_foo:.*}', | |
| 108 | + [ | |
| 109 | + ['/', ['_foo', '.*']] | |
| 110 | + ] | |
| 111 | + ], | |
| 112 | + ]; | |
| 113 | + } | |
| 114 | + | |
| 115 | + public function provideTestParseError() { | |
| 116 | + return [ | |
| 117 | + [ | |
| 118 | + '/test[opt', | |
| 119 | + "Number of opening '[' and closing ']' does not match" | |
| 120 | + ], | |
| 121 | + [ | |
| 122 | + '/test[opt[opt2]', | |
| 123 | + "Number of opening '[' and closing ']' does not match" | |
| 124 | + ], | |
| 125 | + [ | |
| 126 | + '/testopt]', | |
| 127 | + "Number of opening '[' and closing ']' does not match" | |
| 128 | + ], | |
| 129 | + [ | |
| 130 | + '/test[]', | |
| 131 | + "Empty optional part" | |
| 132 | + ], | |
| 133 | + [ | |
| 134 | + '/test[[opt]]', | |
| 135 | + "Empty optional part" | |
| 136 | + ], | |
| 137 | + [ | |
| 138 | + '[[test]]', | |
| 139 | + "Empty optional part" | |
| 140 | + ], | |
| 141 | + [ | |
| 142 | + '/test[/opt]/required', | |
| 143 | + "Optional segments can only occur at the end of a route" | |
| 144 | + ], | |
| 145 | + ]; | |
| 146 | + } | |
| 147 | +} | ... | ... |
| 1 | +++ a/vendor/nikic/fast-route/test/bootstrap.php | |
| ... | ... | @@ -0,0 +1,11 @@ |
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once __DIR__ . '/../src/functions.php'; | |
| 4 | + | |
| 5 | +spl_autoload_register(function($class) { | |
| 6 | + if (strpos($class, 'FastRoute\\') === 0) { | |
| 7 | + $dir = strcasecmp(substr($class, -4), 'Test') ? 'src/' : 'test/'; | |
| 8 | + $name = substr($class, strlen('FastRoute')); | |
| 9 | + require __DIR__ . '/../' . $dir . strtr($name, '\\', DIRECTORY_SEPARATOR) . '.php'; | |
| 10 | + } | |
| 11 | +}); | ... | ... |
| 1 | +++ a/vendor/pimple/pimple/.travis.yml | |
| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | +language: php | |
| 2 | + | |
| 3 | +env: | |
| 4 | + matrix: | |
| 5 | + - PIMPLE_EXT=no | |
| 6 | + - PIMPLE_EXT=yes | |
| 7 | + global: | |
| 8 | + - REPORT_EXIT_STATUS=1 | |
| 9 | + | |
| 10 | +php: | |
| 11 | + - 5.3 | |
| 12 | + - 5.4 | |
| 13 | + - 5.5 | |
| 14 | + - 5.6 | |
| 15 | + - hhvm | |
| 16 | + | |
| 17 | +before_script: | |
| 18 | + - composer self-update | |
| 19 | + - COMPOSER_ROOT_VERSION=dev-master composer dump-autoload | |
| 20 | + - if [ "$PIMPLE_EXT" == "yes" ]; then sh -c "cd ext/pimple && phpize && ./configure && make && sudo make install"; fi | |
| 21 | + - if [ "$PIMPLE_EXT" == "yes" ]; then echo "extension=pimple.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`; fi | |
| 22 | + | |
| 23 | +script: | |
| 24 | + - cd ext/pimple | |
| 25 | + - if [ "$PIMPLE_EXT" == "yes" ]; then yes n | make test | tee output ; grep -E 'Tests failed +. +0' output; fi | |
| 26 | + - cd ../.. | |
| 27 | + - phpunit | |
| 28 | + | |
| 29 | +matrix: | |
| 30 | + exclude: | |
| 31 | + - php: hhvm | |
| 32 | + env: PIMPLE_EXT=yes | ... | ... |
| 1 | +++ a/vendor/pimple/pimple/CHANGELOG | |
| ... | ... | @@ -0,0 +1,35 @@ |
| 1 | +* 3.0.2 (2015-09-11) | |
| 2 | + | |
| 3 | + * refactored the C extension | |
| 4 | + * minor non-significant changes | |
| 5 | + | |
| 6 | +* 3.0.1 (2015-07-30) | |
| 7 | + | |
| 8 | + * simplified some code | |
| 9 | + * fixed a segfault in the C extension | |
| 10 | + | |
| 11 | +* 3.0.0 (2014-07-24) | |
| 12 | + | |
| 13 | + * removed the Pimple class alias (use Pimple\Container instead) | |
| 14 | + | |
| 15 | +* 2.1.1 (2014-07-24) | |
| 16 | + | |
| 17 | + * fixed compiler warnings for the C extension | |
| 18 | + * fixed code when dealing with circular references | |
| 19 | + | |
| 20 | +* 2.1.0 (2014-06-24) | |
| 21 | + | |
| 22 | + * moved the Pimple to Pimple\Container (with a BC layer -- Pimple is now a | |
| 23 | + deprecated alias which will be removed in Pimple 3.0) | |
| 24 | + * added Pimple\ServiceProviderInterface (and Pimple::register()) | |
| 25 | + | |
| 26 | +* 2.0.0 (2014-02-10) | |
| 27 | + | |
| 28 | + * changed extend to automatically re-assign the extended service and keep it as shared or factory | |
| 29 | + (to keep BC, extend still returns the extended service) | |
| 30 | + * changed services to be shared by default (use factory() for factory | |
| 31 | + services) | |
| 32 | + | |
| 33 | +* 1.0.0 | |
| 34 | + | |
| 35 | + * initial version | ... | ... |
| 1 | +++ a/vendor/pimple/pimple/LICENSE | |
| ... | ... | @@ -0,0 +1,19 @@ |
| 1 | +Copyright (c) 2009-2015 Fabien Potencier | |
| 2 | + | |
| 3 | +Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 4 | +of this software and associated documentation files (the "Software"), to deal | |
| 5 | +in the Software without restriction, including without limitation the rights | |
| 6 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 7 | +copies of the Software, and to permit persons to whom the Software is furnished | |
| 8 | +to do so, subject to the following conditions: | |
| 9 | + | |
| 10 | +The above copyright notice and this permission notice shall be included in all | |
| 11 | +copies or substantial portions of the Software. | |
| 12 | + | |
| 13 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 14 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 15 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 16 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 17 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 18 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 19 | +THE SOFTWARE. | ... | ... |
| 1 | +++ a/vendor/pimple/pimple/README.rst | |
| ... | ... | @@ -0,0 +1,201 @@ |
| 1 | +Pimple | |
| 2 | +====== | |
| 3 | + | |
| 4 | +.. caution:: | |
| 5 | + | |
| 6 | + This is the documentation for Pimple 3.x. If you are using Pimple 1.x, read | |
| 7 | + the `Pimple 1.x documentation`_. Reading the Pimple 1.x code is also a good | |
| 8 | + way to learn more about how to create a simple Dependency Injection | |
| 9 | + Container (recent versions of Pimple are more focused on performance). | |
| 10 | + | |
| 11 | +Pimple is a small Dependency Injection Container for PHP. | |
| 12 | + | |
| 13 | +Installation | |
| 14 | +------------ | |
| 15 | + | |
| 16 | +Before using Pimple in your project, add it to your ``composer.json`` file: | |
| 17 | + | |
| 18 | +.. code-block:: bash | |
| 19 | + | |
| 20 | + $ ./composer.phar require pimple/pimple ~3.0 | |
| 21 | + | |
| 22 | +Alternatively, Pimple is also available as a PHP C extension: | |
| 23 | + | |
| 24 | +.. code-block:: bash | |
| 25 | + | |
| 26 | + $ git clone https://github.com/silexphp/Pimple | |
| 27 | + $ cd Pimple/ext/pimple | |
| 28 | + $ phpize | |
| 29 | + $ ./configure | |
| 30 | + $ make | |
| 31 | + $ make install | |
| 32 | + | |
| 33 | +Usage | |
| 34 | +----- | |
| 35 | + | |
| 36 | +Creating a container is a matter of creating a ``Container`` instance: | |
| 37 | + | |
| 38 | +.. code-block:: php | |
| 39 | + | |
| 40 | + use Pimple\Container; | |
| 41 | + | |
| 42 | + $container = new Container(); | |
| 43 | + | |
| 44 | +As many other dependency injection containers, Pimple manages two different | |
| 45 | +kind of data: **services** and **parameters**. | |
| 46 | + | |
| 47 | +Defining Services | |
| 48 | +~~~~~~~~~~~~~~~~~ | |
| 49 | + | |
| 50 | +A service is an object that does something as part of a larger system. Examples | |
| 51 | +of services: a database connection, a templating engine, or a mailer. Almost | |
| 52 | +any **global** object can be a service. | |
| 53 | + | |
| 54 | +Services are defined by **anonymous functions** that return an instance of an | |
| 55 | +object: | |
| 56 | + | |
| 57 | +.. code-block:: php | |
| 58 | + | |
| 59 | + // define some services | |
| 60 | + $container['session_storage'] = function ($c) { | |
| 61 | + return new SessionStorage('SESSION_ID'); | |
| 62 | + }; | |
| 63 | + | |
| 64 | + $container['session'] = function ($c) { | |
| 65 | + return new Session($c['session_storage']); | |
| 66 | + }; | |
| 67 | + | |
| 68 | +Notice that the anonymous function has access to the current container | |
| 69 | +instance, allowing references to other services or parameters. | |
| 70 | + | |
| 71 | +As objects are only created when you get them, the order of the definitions | |
| 72 | +does not matter. | |
| 73 | + | |
| 74 | +Using the defined services is also very easy: | |
| 75 | + | |
| 76 | +.. code-block:: php | |
| 77 | + | |
| 78 | + // get the session object | |
| 79 | + $session = $container['session']; | |
| 80 | + | |
| 81 | + // the above call is roughly equivalent to the following code: | |
| 82 | + // $storage = new SessionStorage('SESSION_ID'); | |
| 83 | + // $session = new Session($storage); | |
| 84 | + | |
| 85 | +Defining Factory Services | |
| 86 | +~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| 87 | + | |
| 88 | +By default, each time you get a service, Pimple returns the **same instance** | |
| 89 | +of it. If you want a different instance to be returned for all calls, wrap your | |
| 90 | +anonymous function with the ``factory()`` method | |
| 91 | + | |
| 92 | +.. code-block:: php | |
| 93 | + | |
| 94 | + $container['session'] = $container->factory(function ($c) { | |
| 95 | + return new Session($c['session_storage']); | |
| 96 | + }); | |
| 97 | + | |
| 98 | +Now, each call to ``$container['session']`` returns a new instance of the | |
| 99 | +session. | |
| 100 | + | |
| 101 | +Defining Parameters | |
| 102 | +~~~~~~~~~~~~~~~~~~~ | |
| 103 | + | |
| 104 | +Defining a parameter allows to ease the configuration of your container from | |
| 105 | +the outside and to store global values: | |
| 106 | + | |
| 107 | +.. code-block:: php | |
| 108 | + | |
| 109 | + // define some parameters | |
| 110 | + $container['cookie_name'] = 'SESSION_ID'; | |
| 111 | + $container['session_storage_class'] = 'SessionStorage'; | |
| 112 | + | |
| 113 | +If you change the ``session_storage`` service definition like below: | |
| 114 | + | |
| 115 | +.. code-block:: php | |
| 116 | + | |
| 117 | + $container['session_storage'] = function ($c) { | |
| 118 | + return new $c['session_storage_class']($c['cookie_name']); | |
| 119 | + }; | |
| 120 | + | |
| 121 | +You can now easily change the cookie name by overriding the | |
| 122 | +``session_storage_class`` parameter instead of redefining the service | |
| 123 | +definition. | |
| 124 | + | |
| 125 | +Protecting Parameters | |
| 126 | +~~~~~~~~~~~~~~~~~~~~~ | |
| 127 | + | |
| 128 | +Because Pimple sees anonymous functions as service definitions, you need to | |
| 129 | +wrap anonymous functions with the ``protect()`` method to store them as | |
| 130 | +parameters: | |
| 131 | + | |
| 132 | +.. code-block:: php | |
| 133 | + | |
| 134 | + $container['random_func'] = $container->protect(function () { | |
| 135 | + return rand(); | |
| 136 | + }); | |
| 137 | + | |
| 138 | +Modifying Services after Definition | |
| 139 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| 140 | + | |
| 141 | +In some cases you may want to modify a service definition after it has been | |
| 142 | +defined. You can use the ``extend()`` method to define additional code to be | |
| 143 | +run on your service just after it is created: | |
| 144 | + | |
| 145 | +.. code-block:: php | |
| 146 | + | |
| 147 | + $container['session_storage'] = function ($c) { | |
| 148 | + return new $c['session_storage_class']($c['cookie_name']); | |
| 149 | + }; | |
| 150 | + | |
| 151 | + $container->extend('session_storage', function ($storage, $c) { | |
| 152 | + $storage->...(); | |
| 153 | + | |
| 154 | + return $storage; | |
| 155 | + }); | |
| 156 | + | |
| 157 | +The first argument is the name of the service to extend, the second a function | |
| 158 | +that gets access to the object instance and the container. | |
| 159 | + | |
| 160 | +Extending a Container | |
| 161 | +~~~~~~~~~~~~~~~~~~~~~ | |
| 162 | + | |
| 163 | +If you use the same libraries over and over, you might want to reuse some | |
| 164 | +services from one project to the next one; package your services into a | |
| 165 | +**provider** by implementing ``Pimple\ServiceProviderInterface``: | |
| 166 | + | |
| 167 | +.. code-block:: php | |
| 168 | + | |
| 169 | + use Pimple\Container; | |
| 170 | + | |
| 171 | + class FooProvider implements Pimple\ServiceProviderInterface | |
| 172 | + { | |
| 173 | + public function register(Container $pimple) | |
| 174 | + { | |
| 175 | + // register some services and parameters | |
| 176 | + // on $pimple | |
| 177 | + } | |
| 178 | + } | |
| 179 | + | |
| 180 | +Then, register the provider on a Container: | |
| 181 | + | |
| 182 | +.. code-block:: php | |
| 183 | + | |
| 184 | + $pimple->register(new FooProvider()); | |
| 185 | + | |
| 186 | +Fetching the Service Creation Function | |
| 187 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| 188 | + | |
| 189 | +When you access an object, Pimple automatically calls the anonymous function | |
| 190 | +that you defined, which creates the service object for you. If you want to get | |
| 191 | +raw access to this function, you can use the ``raw()`` method: | |
| 192 | + | |
| 193 | +.. code-block:: php | |
| 194 | + | |
| 195 | + $container['session'] = function ($c) { | |
| 196 | + return new Session($c['session_storage']); | |
| 197 | + }; | |
| 198 | + | |
| 199 | + $sessionFunction = $container->raw('session'); | |
| 200 | + | |
| 201 | +.. _Pimple 1.x documentation: https://github.com/silexphp/Pimple/tree/1.1 | ... | ... |
| 1 | +++ a/vendor/pimple/pimple/composer.json | |
| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | +{ | |
| 2 | + "name": "pimple/pimple", | |
| 3 | + "type": "library", | |
| 4 | + "description": "Pimple, a simple Dependency Injection Container", | |
| 5 | + "keywords": ["dependency injection", "container"], | |
| 6 | + "homepage": "http://pimple.sensiolabs.org", | |
| 7 | + "license": "MIT", | |
| 8 | + "authors": [ | |
| 9 | + { | |
| 10 | + "name": "Fabien Potencier", | |
| 11 | + "email": "fabien@symfony.com" | |
| 12 | + } | |
| 13 | + ], | |
| 14 | + "require": { | |
| 15 | + "php": ">=5.3.0" | |
| 16 | + }, | |
| 17 | + "autoload": { | |
| 18 | + "psr-0": { "Pimple": "src/" } | |
| 19 | + }, | |
| 20 | + "extra": { | |
| 21 | + "branch-alias": { | |
| 22 | + "dev-master": "3.0.x-dev" | |
| 23 | + } | |
| 24 | + } | |
| 25 | +} | ... | ... |
| 1 | +++ a/vendor/pimple/pimple/ext/pimple/.gitignore | |
| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | +*.sw* | |
| 2 | +.deps | |
| 3 | +Makefile | |
| 4 | +Makefile.fragments | |
| 5 | +Makefile.global | |
| 6 | +Makefile.objects | |
| 7 | +acinclude.m4 | |
| 8 | +aclocal.m4 | |
| 9 | +build/ | |
| 10 | +config.cache | |
| 11 | +config.guess | |
| 12 | +config.h | |
| 13 | +config.h.in | |
| 14 | +config.log | |
| 15 | +config.nice | |
| 16 | +config.status | |
| 17 | +config.sub | |
| 18 | +configure | |
| 19 | +configure.in | |
| 20 | +install-sh | |
| 21 | +libtool | |
| 22 | +ltmain.sh | |
| 23 | +missing | |
| 24 | +mkinstalldirs | |
| 25 | +run-tests.php | |
| 26 | +*.loT | |
| 27 | +.libs/ | |
| 28 | +modules/ | |
| 29 | +*.la | |
| 30 | +*.lo | ... | ... |
| 1 | +++ a/vendor/pimple/pimple/ext/pimple/config.m4 | |
| ... | ... | @@ -0,0 +1,63 @@ |
| 1 | +dnl $Id$ | |
| 2 | +dnl config.m4 for extension pimple | |
| 3 | + | |
| 4 | +dnl Comments in this file start with the string 'dnl'. | |
| 5 | +dnl Remove where necessary. This file will not work | |
| 6 | +dnl without editing. | |
| 7 | + | |
| 8 | +dnl If your extension references something external, use with: | |
| 9 | + | |
| 10 | +dnl PHP_ARG_WITH(pimple, for pimple support, | |
| 11 | +dnl Make sure that the comment is aligned: | |
| 12 | +dnl [ --with-pimple Include pimple support]) | |
| 13 | + | |
| 14 | +dnl Otherwise use enable: | |
| 15 | + | |
| 16 | +PHP_ARG_ENABLE(pimple, whether to enable pimple support, | |
| 17 | +dnl Make sure that the comment is aligned: | |
| 18 | +[ --enable-pimple Enable pimple support]) | |
| 19 | + | |
| 20 | +if test "$PHP_PIMPLE" != "no"; then | |
| 21 | + dnl Write more examples of tests here... | |
| 22 | + | |
| 23 | + dnl # --with-pimple -> check with-path | |
| 24 | + dnl SEARCH_PATH="/usr/local /usr" # you might want to change this | |
| 25 | + dnl SEARCH_FOR="/include/pimple.h" # you most likely want to change this | |
| 26 | + dnl if test -r $PHP_PIMPLE/$SEARCH_FOR; then # path given as parameter | |
| 27 | + dnl PIMPLE_DIR=$PHP_PIMPLE | |
| 28 | + dnl else # search default path list | |
| 29 | + dnl AC_MSG_CHECKING([for pimple files in default path]) | |
| 30 | + dnl for i in $SEARCH_PATH ; do | |
| 31 | + dnl if test -r $i/$SEARCH_FOR; then | |
| 32 | + dnl PIMPLE_DIR=$i | |
| 33 | + dnl AC_MSG_RESULT(found in $i) | |
| 34 | + dnl fi | |
| 35 | + dnl done | |
| 36 | + dnl fi | |
| 37 | + dnl | |
| 38 | + dnl if test -z "$PIMPLE_DIR"; then | |
| 39 | + dnl AC_MSG_RESULT([not found]) | |
| 40 | + dnl AC_MSG_ERROR([Please reinstall the pimple distribution]) | |
| 41 | + dnl fi | |
| 42 | + | |
| 43 | + dnl # --with-pimple -> add include path | |
| 44 | + dnl PHP_ADD_INCLUDE($PIMPLE_DIR/include) | |
| 45 | + | |
| 46 | + dnl # --with-pimple -> check for lib and symbol presence | |
| 47 | + dnl LIBNAME=pimple # you may want to change this | |
| 48 | + dnl LIBSYMBOL=pimple # you most likely want to change this | |
| 49 | + | |
| 50 | + dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL, | |
| 51 | + dnl [ | |
| 52 | + dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $PIMPLE_DIR/lib, PIMPLE_SHARED_LIBADD) | |
| 53 | + dnl AC_DEFINE(HAVE_PIMPLELIB,1,[ ]) | |
| 54 | + dnl ],[ | |
| 55 | + dnl AC_MSG_ERROR([wrong pimple lib version or lib not found]) | |
| 56 | + dnl ],[ | |
| 57 | + dnl -L$PIMPLE_DIR/lib -lm | |
| 58 | + dnl ]) | |
| 59 | + dnl | |
| 60 | + dnl PHP_SUBST(PIMPLE_SHARED_LIBADD) | |
| 61 | + | |
| 62 | + PHP_NEW_EXTENSION(pimple, pimple.c, $ext_shared) | |
| 63 | +fi | ... | ... |
| 1 | +++ a/vendor/pimple/pimple/ext/pimple/config.w32 | |
| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | +// $Id$ | |
| 2 | +// vim:ft=javascript | |
| 3 | + | |
| 4 | +// If your extension references something external, use ARG_WITH | |
| 5 | +// ARG_WITH("pimple", "for pimple support", "no"); | |
| 6 | + | |
| 7 | +// Otherwise, use ARG_ENABLE | |
| 8 | +// ARG_ENABLE("pimple", "enable pimple support", "no"); | |
| 9 | + | |
| 10 | +if (PHP_PIMPLE != "no") { | |
| 11 | + EXTENSION("pimple", "pimple.c"); | |
| 12 | +} | |
| 13 | + | ... | ... |
| 1 | +++ a/vendor/pimple/pimple/ext/pimple/php_pimple.h | |
| ... | ... | @@ -0,0 +1,121 @@ |
| 1 | + | |
| 2 | +/* | |
| 3 | + * This file is part of Pimple. | |
| 4 | + * | |
| 5 | + * Copyright (c) 2014 Fabien Potencier | |
| 6 | + * | |
| 7 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 8 | + * of this software and associated documentation files (the "Software"), to deal | |
| 9 | + * in the Software without restriction, including without limitation the rights | |
| 10 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 11 | + * copies of the Software, and to permit persons to whom the Software is furnished | |
| 12 | + * to do so, subject to the following conditions: | |
| 13 | + * | |
| 14 | + * The above copyright notice and this permission notice shall be included in all | |
| 15 | + * copies or substantial portions of the Software. | |
| 16 | + * | |
| 17 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 18 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 19 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 20 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 21 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 22 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 23 | + * THE SOFTWARE. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +#ifndef PHP_PIMPLE_H | |
| 27 | +#define PHP_PIMPLE_H | |
| 28 | + | |
| 29 | +extern zend_module_entry pimple_module_entry; | |
| 30 | +#define phpext_pimple_ptr &pimple_module_entry | |
| 31 | + | |
| 32 | +#ifdef PHP_WIN32 | |
| 33 | +# define PHP_PIMPLE_API __declspec(dllexport) | |
| 34 | +#elif defined(__GNUC__) && __GNUC__ >= 4 | |
| 35 | +# define PHP_PIMPLE_API __attribute__ ((visibility("default"))) | |
| 36 | +#else | |
| 37 | +# define PHP_PIMPLE_API | |
| 38 | +#endif | |
| 39 | + | |
| 40 | +#ifdef ZTS | |
| 41 | +#include "TSRM.h" | |
| 42 | +#endif | |
| 43 | + | |
| 44 | +#define PIMPLE_VERSION "3.0.2" | |
| 45 | +#define PIMPLE_NS "Pimple" | |
| 46 | + | |
| 47 | +#define PIMPLE_DEFAULT_ZVAL_CACHE_NUM 5 | |
| 48 | +#define PIMPLE_DEFAULT_ZVAL_VALUES_NUM 10 | |
| 49 | + | |
| 50 | +zend_module_entry *get_module(void); | |
| 51 | + | |
| 52 | +PHP_MINIT_FUNCTION(pimple); | |
| 53 | +PHP_MINFO_FUNCTION(pimple); | |
| 54 | + | |
| 55 | +PHP_METHOD(Pimple, __construct); | |
| 56 | +PHP_METHOD(Pimple, factory); | |
| 57 | +PHP_METHOD(Pimple, protect); | |
| 58 | +PHP_METHOD(Pimple, raw); | |
| 59 | +PHP_METHOD(Pimple, extend); | |
| 60 | +PHP_METHOD(Pimple, keys); | |
| 61 | +PHP_METHOD(Pimple, register); | |
| 62 | +PHP_METHOD(Pimple, offsetSet); | |
| 63 | +PHP_METHOD(Pimple, offsetUnset); | |
| 64 | +PHP_METHOD(Pimple, offsetGet); | |
| 65 | +PHP_METHOD(Pimple, offsetExists); | |
| 66 | + | |
| 67 | +PHP_METHOD(PimpleClosure, invoker); | |
| 68 | + | |
| 69 | +typedef struct _pimple_bucket_value { | |
| 70 | + zval *value; /* Must be the first element */ | |
| 71 | + zval *raw; | |
| 72 | + zend_object_handle handle_num; | |
| 73 | + enum { | |
| 74 | + PIMPLE_IS_PARAM = 0, | |
| 75 | + PIMPLE_IS_SERVICE = 2 | |
| 76 | + } type; | |
| 77 | + zend_bool initialized; | |
| 78 | + zend_fcall_info_cache fcc; | |
| 79 | +} pimple_bucket_value; | |
| 80 | + | |
| 81 | +typedef struct _pimple_object { | |
| 82 | + zend_object zobj; | |
| 83 | + HashTable values; | |
| 84 | + HashTable factories; | |
| 85 | + HashTable protected; | |
| 86 | +} pimple_object; | |
| 87 | + | |
| 88 | +typedef struct _pimple_closure_object { | |
| 89 | + zend_object zobj; | |
| 90 | + zval *callable; | |
| 91 | + zval *factory; | |
| 92 | +} pimple_closure_object; | |
| 93 | + | |
| 94 | +static const char sensiolabs_logo[] = "<img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHYAAAAUCAMAAABvRTlyAAAAz1BMVEUAAAAAAAAAAAAsThWB5j4AAACD6T8AAACC6D+C6D6C6D+C6D4AAAAAAACC6D4AAAAAAACC6D8AAAAAAAAAAAAAAAAAAAAAAACC6D4AAAAAAAAAAACC6D4AAAAAAAAAAAAAAAAAAAAAAACC6D8AAACC6D4AAAAAAAAAAAAAAAAAAACC6D8AAACC6D6C6D+B6D+C6D+C6D+C6D8AAACC6D6C6D4AAACC6D/K/2KC6D+B6D6C6D6C6D+C6D8sTxUyWRhEeiEAAACC6D+C5z6B6D7drnEVAAAAQXRSTlMAE3oCNSUuDHFHzxaF9UFsu+irX+zlKzYimaJXktyOSFD6BolxqT7QGMMdarMIpuO28r9EolXKgR16OphfXYd4V14GtB4AAAMpSURBVEjHvVSJctowEF1jjME2RziMwUCoMfd9heZqG4n//6buLpJjkmYm03byZmxJa2nf6u2uQcG2bfhqRN4LoTKBzyGDm68M7mAwcOEdjo4zhA/Rf9Go/CVtTgiRhXfIC3EDH8F/eUX1/9KexRo+QgOdtHDsEe/sM7QT32/+K61Z1LFXcXJxN4pTbu1aTQUzuy2PIA0rDo0/0Aa5XFaJvKaVTrubywXvaa1Wq4Vu/Snr3Y7Aojh4VccwykW2N2oQ8wmjyut6+Q1t5ywIG5Npj1sh5E0B7YOzFDjfuRfaOh3O+MbbVNfTWS9COZk3Obd2su5d0a6IU9KLREbw8gEehWSr1r2sPWciXLG38r5NdW0xu9eioU87omjC9yNaMi5GNf6WppVSOqXCFkmCvMB3p9SROLoYQn5pDgQOujA1xjYvqH+plUdkwnmII8VxR/PKYkrfLLomhVlE3b/LhNbNr7hp0H2JaOc4v8dFB58HSsFTSafaqtY1sT3GO8wsy5rhokYPlRJdjPMajyYqTt1EHF/2uqSWQWmAjCUSmQ1MS3g8Btf1XOsy7YIC0CB1b5Xw1Vhba0zbxiCAQLH9TNPmHJXQUtJAN0KcDsoqLxsNvJrJExa7mKIdp2lRE2WexiS4pqWk/0jROlw6K6bV9YOBDGAuqMJ0bnuUKGB0L27bxgRhGEbzihbhxxXaQC88Vkwq8ldCi86RApWUb0Q+4VDosBCc+1s81lUdnBavH4Zp2mm3O44USwOfvSo9oBiwpFg71lMS1VKJLKljS3j9p+fOTvXXlsSNuEv6YPaZda9uRope0VJfKdo7fPiYfSmvFjXQbkhY0d9hCbBWIktRgEDieDhf1N3wbbkmNNgRy8hyl620yGQat/grV3HMpc2HDKTVmOPFz6ylPCKt/nXcAyV260jaAowwIW0YuBzrOgb/KrddZS9OmJaLgpWK4JX2DDuklcLZSDGcn8Vmx9YDNvT6UsjyBApRyFQVX7Vxm9TGxE16nmfRd8/zQoDmggQOTRh5Hv8pMt9Q/L2JmSwkMCE7dA4BuDjHJwfu0Om4QAhOjrN5XkIatglfiN/bUPdCQFjTYgAAAABJRU5ErkJggg==\">"; | |
| 95 | + | |
| 96 | +static int pimple_zval_to_pimpleval(zval *_zval, pimple_bucket_value *_pimple_bucket_value TSRMLS_DC); | |
| 97 | +static int pimple_zval_is_valid_callback(zval *_zval, pimple_bucket_value *_pimple_bucket_value TSRMLS_DC); | |
| 98 | + | |
| 99 | +static void pimple_bucket_dtor(pimple_bucket_value *bucket); | |
| 100 | +static void pimple_free_bucket(pimple_bucket_value *bucket); | |
| 101 | + | |
| 102 | +static zval *pimple_object_read_dimension(zval *object, zval *offset, int type TSRMLS_DC); | |
| 103 | +static void pimple_object_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC); | |
| 104 | +static int pimple_object_has_dimension(zval *object, zval *offset, int check_empty TSRMLS_DC); | |
| 105 | +static void pimple_object_unset_dimension(zval *object, zval *offset TSRMLS_DC); | |
| 106 | +static zend_object_value pimple_object_create(zend_class_entry *ce TSRMLS_DC); | |
| 107 | +static void pimple_free_object_storage(pimple_object *obj TSRMLS_DC); | |
| 108 | + | |
| 109 | +static void pimple_closure_free_object_storage(pimple_closure_object *obj TSRMLS_DC); | |
| 110 | +static zend_object_value pimple_closure_object_create(zend_class_entry *ce TSRMLS_DC); | |
| 111 | +static zend_function *pimple_closure_get_constructor(zval * TSRMLS_DC); | |
| 112 | +static int pimple_closure_get_closure(zval *obj, zend_class_entry **ce_ptr, union _zend_function **fptr_ptr, zval **zobj_ptr TSRMLS_DC); | |
| 113 | + | |
| 114 | +#ifdef ZTS | |
| 115 | +#define PIMPLE_G(v) TSRMG(pimple_globals_id, zend_pimple_globals *, v) | |
| 116 | +#else | |
| 117 | +#define PIMPLE_G(v) (pimple_globals.v) | |
| 118 | +#endif | |
| 119 | + | |
| 120 | +#endif /* PHP_PIMPLE_H */ | |
| 121 | + | ... | ... |
| 1 | +++ a/vendor/pimple/pimple/ext/pimple/pimple.c | |
| ... | ... | @@ -0,0 +1,922 @@ |
| 1 | + | |
| 2 | +/* | |
| 3 | + * This file is part of Pimple. | |
| 4 | + * | |
| 5 | + * Copyright (c) 2014 Fabien Potencier | |
| 6 | + * | |
| 7 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 8 | + * of this software and associated documentation files (the "Software"), to deal | |
| 9 | + * in the Software without restriction, including without limitation the rights | |
| 10 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 11 | + * copies of the Software, and to permit persons to whom the Software is furnished | |
| 12 | + * to do so, subject to the following conditions: | |
| 13 | + * | |
| 14 | + * The above copyright notice and this permission notice shall be included in all | |
| 15 | + * copies or substantial portions of the Software. | |
| 16 | + * | |
| 17 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 18 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 19 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 20 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 21 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 22 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 23 | + * THE SOFTWARE. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +#ifdef HAVE_CONFIG_H | |
| 27 | +#include "config.h" | |
| 28 | +#endif | |
| 29 | + | |
| 30 | +#include "php.h" | |
| 31 | +#include "php_ini.h" | |
| 32 | +#include "ext/standard/info.h" | |
| 33 | +#include "php_pimple.h" | |
| 34 | +#include "pimple_compat.h" | |
| 35 | +#include "zend_interfaces.h" | |
| 36 | +#include "zend.h" | |
| 37 | +#include "Zend/zend_closures.h" | |
| 38 | +#include "ext/spl/spl_exceptions.h" | |
| 39 | +#include "Zend/zend_exceptions.h" | |
| 40 | +#include "main/php_output.h" | |
| 41 | +#include "SAPI.h" | |
| 42 | + | |
| 43 | +static zend_class_entry *pimple_ce; | |
| 44 | +static zend_object_handlers pimple_object_handlers; | |
| 45 | +static zend_class_entry *pimple_closure_ce; | |
| 46 | +static zend_class_entry *pimple_serviceprovider_ce; | |
| 47 | +static zend_object_handlers pimple_closure_object_handlers; | |
| 48 | +static zend_internal_function pimple_closure_invoker_function; | |
| 49 | + | |
| 50 | +#define FETCH_DIM_HANDLERS_VARS pimple_object *pimple_obj = NULL; \ | |
| 51 | + ulong index; \ | |
| 52 | + pimple_obj = (pimple_object *)zend_object_store_get_object(object TSRMLS_CC); \ | |
| 53 | + | |
| 54 | +#define PIMPLE_OBJECT_HANDLE_INHERITANCE_OBJECT_HANDLERS do { \ | |
| 55 | + if (ce != pimple_ce) { \ | |
| 56 | + zend_hash_find(&ce->function_table, ZEND_STRS("offsetget"), (void **)&function); \ | |
| 57 | + if (function->common.scope != ce) { /* if the function is not defined in this actual class */ \ | |
| 58 | + pimple_object_handlers.read_dimension = pimple_object_read_dimension; /* then overwrite the handler to use custom one */ \ | |
| 59 | + } \ | |
| 60 | + zend_hash_find(&ce->function_table, ZEND_STRS("offsetset"), (void **)&function); \ | |
| 61 | + if (function->common.scope != ce) { \ | |
| 62 | + pimple_object_handlers.write_dimension = pimple_object_write_dimension; \ | |
| 63 | + } \ | |
| 64 | + zend_hash_find(&ce->function_table, ZEND_STRS("offsetexists"), (void **)&function); \ | |
| 65 | + if (function->common.scope != ce) { \ | |
| 66 | + pimple_object_handlers.has_dimension = pimple_object_has_dimension; \ | |
| 67 | + } \ | |
| 68 | + zend_hash_find(&ce->function_table, ZEND_STRS("offsetunset"), (void **)&function); \ | |
| 69 | + if (function->common.scope != ce) { \ | |
| 70 | + pimple_object_handlers.unset_dimension = pimple_object_unset_dimension; \ | |
| 71 | + } \ | |
| 72 | + } else { \ | |
| 73 | + pimple_object_handlers.read_dimension = pimple_object_read_dimension; \ | |
| 74 | + pimple_object_handlers.write_dimension = pimple_object_write_dimension; \ | |
| 75 | + pimple_object_handlers.has_dimension = pimple_object_has_dimension; \ | |
| 76 | + pimple_object_handlers.unset_dimension = pimple_object_unset_dimension; \ | |
| 77 | + }\ | |
| 78 | + } while(0); | |
| 79 | + | |
| 80 | +#define PIMPLE_CALL_CB do { \ | |
| 81 | + zend_fcall_info_argn(&fci TSRMLS_CC, 1, &object); \ | |
| 82 | + fci.size = sizeof(fci); \ | |
| 83 | + fci.object_ptr = retval->fcc.object_ptr; \ | |
| 84 | + fci.function_name = retval->value; \ | |
| 85 | + fci.no_separation = 1; \ | |
| 86 | + fci.retval_ptr_ptr = &retval_ptr_ptr; \ | |
| 87 | +\ | |
| 88 | + zend_call_function(&fci, &retval->fcc TSRMLS_CC); \ | |
| 89 | + efree(fci.params); \ | |
| 90 | + if (EG(exception)) { \ | |
| 91 | + return EG(uninitialized_zval_ptr); \ | |
| 92 | + } \ | |
| 93 | + } while(0); | |
| 94 | + | |
| 95 | +ZEND_BEGIN_ARG_INFO_EX(arginfo___construct, 0, 0, 0) | |
| 96 | +ZEND_ARG_ARRAY_INFO(0, value, 0) | |
| 97 | +ZEND_END_ARG_INFO() | |
| 98 | + | |
| 99 | +ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetset, 0, 0, 2) | |
| 100 | +ZEND_ARG_INFO(0, offset) | |
| 101 | +ZEND_ARG_INFO(0, value) | |
| 102 | +ZEND_END_ARG_INFO() | |
| 103 | + | |
| 104 | +ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetget, 0, 0, 1) | |
| 105 | +ZEND_ARG_INFO(0, offset) | |
| 106 | +ZEND_END_ARG_INFO() | |
| 107 | + | |
| 108 | +ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetexists, 0, 0, 1) | |
| 109 | +ZEND_ARG_INFO(0, offset) | |
| 110 | +ZEND_END_ARG_INFO() | |
| 111 | + | |
| 112 | +ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetunset, 0, 0, 1) | |
| 113 | +ZEND_ARG_INFO(0, offset) | |
| 114 | +ZEND_END_ARG_INFO() | |
| 115 | + | |
| 116 | +ZEND_BEGIN_ARG_INFO_EX(arginfo_factory, 0, 0, 1) | |
| 117 | +ZEND_ARG_INFO(0, callable) | |
| 118 | +ZEND_END_ARG_INFO() | |
| 119 | + | |
| 120 | +ZEND_BEGIN_ARG_INFO_EX(arginfo_protect, 0, 0, 1) | |
| 121 | +ZEND_ARG_INFO(0, callable) | |
| 122 | +ZEND_END_ARG_INFO() | |
| 123 | + | |
| 124 | +ZEND_BEGIN_ARG_INFO_EX(arginfo_raw, 0, 0, 1) | |
| 125 | +ZEND_ARG_INFO(0, id) | |
| 126 | +ZEND_END_ARG_INFO() | |
| 127 | + | |
| 128 | +ZEND_BEGIN_ARG_INFO_EX(arginfo_extend, 0, 0, 2) | |
| 129 | +ZEND_ARG_INFO(0, id) | |
| 130 | +ZEND_ARG_INFO(0, callable) | |
| 131 | +ZEND_END_ARG_INFO() | |
| 132 | + | |
| 133 | +ZEND_BEGIN_ARG_INFO_EX(arginfo_keys, 0, 0, 0) | |
| 134 | +ZEND_END_ARG_INFO() | |
| 135 | + | |
| 136 | +ZEND_BEGIN_ARG_INFO_EX(arginfo_register, 0, 0, 1) | |
| 137 | +ZEND_ARG_OBJ_INFO(0, provider, Pimple\\ServiceProviderInterface, 0) | |
| 138 | +ZEND_ARG_ARRAY_INFO(0, values, 1) | |
| 139 | +ZEND_END_ARG_INFO() | |
| 140 | + | |
| 141 | +ZEND_BEGIN_ARG_INFO_EX(arginfo_serviceprovider_register, 0, 0, 1) | |
| 142 | +ZEND_ARG_OBJ_INFO(0, pimple, Pimple\\Container, 0) | |
| 143 | +ZEND_END_ARG_INFO() | |
| 144 | + | |
| 145 | +static const zend_function_entry pimple_ce_functions[] = { | |
| 146 | + PHP_ME(Pimple, __construct, arginfo___construct, ZEND_ACC_PUBLIC) | |
| 147 | + PHP_ME(Pimple, factory, arginfo_factory, ZEND_ACC_PUBLIC) | |
| 148 | + PHP_ME(Pimple, protect, arginfo_protect, ZEND_ACC_PUBLIC) | |
| 149 | + PHP_ME(Pimple, raw, arginfo_raw, ZEND_ACC_PUBLIC) | |
| 150 | + PHP_ME(Pimple, extend, arginfo_extend, ZEND_ACC_PUBLIC) | |
| 151 | + PHP_ME(Pimple, keys, arginfo_keys, ZEND_ACC_PUBLIC) | |
| 152 | + PHP_ME(Pimple, register, arginfo_register, ZEND_ACC_PUBLIC) | |
| 153 | + | |
| 154 | + PHP_ME(Pimple, offsetSet, arginfo_offsetset, ZEND_ACC_PUBLIC) | |
| 155 | + PHP_ME(Pimple, offsetGet, arginfo_offsetget, ZEND_ACC_PUBLIC) | |
| 156 | + PHP_ME(Pimple, offsetExists, arginfo_offsetexists, ZEND_ACC_PUBLIC) | |
| 157 | + PHP_ME(Pimple, offsetUnset, arginfo_offsetunset, ZEND_ACC_PUBLIC) | |
| 158 | + PHP_FE_END | |
| 159 | +}; | |
| 160 | + | |
| 161 | +static const zend_function_entry pimple_serviceprovider_iface_ce_functions[] = { | |
| 162 | + PHP_ABSTRACT_ME(ServiceProviderInterface, register, arginfo_serviceprovider_register) | |
| 163 | + PHP_FE_END | |
| 164 | +}; | |
| 165 | + | |
| 166 | +static void pimple_closure_free_object_storage(pimple_closure_object *obj TSRMLS_DC) | |
| 167 | +{ | |
| 168 | + zend_object_std_dtor(&obj->zobj TSRMLS_CC); | |
| 169 | + if (obj->factory) { | |
| 170 | + zval_ptr_dtor(&obj->factory); | |
| 171 | + } | |
| 172 | + if (obj->callable) { | |
| 173 | + zval_ptr_dtor(&obj->callable); | |
| 174 | + } | |
| 175 | + efree(obj); | |
| 176 | +} | |
| 177 | + | |
| 178 | +static void pimple_free_object_storage(pimple_object *obj TSRMLS_DC) | |
| 179 | +{ | |
| 180 | + zend_hash_destroy(&obj->factories); | |
| 181 | + zend_hash_destroy(&obj->protected); | |
| 182 | + zend_hash_destroy(&obj->values); | |
| 183 | + zend_object_std_dtor(&obj->zobj TSRMLS_CC); | |
| 184 | + efree(obj); | |
| 185 | +} | |
| 186 | + | |
| 187 | +static void pimple_free_bucket(pimple_bucket_value *bucket) | |
| 188 | +{ | |
| 189 | + if (bucket->raw) { | |
| 190 | + zval_ptr_dtor(&bucket->raw); | |
| 191 | + } | |
| 192 | +} | |
| 193 | + | |
| 194 | +static zend_object_value pimple_closure_object_create(zend_class_entry *ce TSRMLS_DC) | |
| 195 | +{ | |
| 196 | + zend_object_value retval; | |
| 197 | + pimple_closure_object *pimple_closure_obj = NULL; | |
| 198 | + | |
| 199 | + pimple_closure_obj = ecalloc(1, sizeof(pimple_closure_object)); | |
| 200 | + ZEND_OBJ_INIT(&pimple_closure_obj->zobj, ce); | |
| 201 | + | |
| 202 | + pimple_closure_object_handlers.get_constructor = pimple_closure_get_constructor; | |
| 203 | + retval.handlers = &pimple_closure_object_handlers; | |
| 204 | + retval.handle = zend_objects_store_put(pimple_closure_obj, (zend_objects_store_dtor_t) zend_objects_destroy_object, (zend_objects_free_object_storage_t) pimple_closure_free_object_storage, NULL TSRMLS_CC); | |
| 205 | + | |
| 206 | + return retval; | |
| 207 | +} | |
| 208 | + | |
| 209 | +static zend_function *pimple_closure_get_constructor(zval *obj TSRMLS_DC) | |
| 210 | +{ | |
| 211 | + zend_error(E_ERROR, "Pimple\\ContainerClosure is an internal class and cannot be instantiated"); | |
| 212 | + | |
| 213 | + return NULL; | |
| 214 | +} | |
| 215 | + | |
| 216 | +static int pimple_closure_get_closure(zval *obj, zend_class_entry **ce_ptr, union _zend_function **fptr_ptr, zval **zobj_ptr TSRMLS_DC) | |
| 217 | +{ | |
| 218 | + *zobj_ptr = obj; | |
| 219 | + *ce_ptr = Z_OBJCE_P(obj); | |
| 220 | + *fptr_ptr = (zend_function *)&pimple_closure_invoker_function; | |
| 221 | + | |
| 222 | + return SUCCESS; | |
| 223 | +} | |
| 224 | + | |
| 225 | +static zend_object_value pimple_object_create(zend_class_entry *ce TSRMLS_DC) | |
| 226 | +{ | |
| 227 | + zend_object_value retval; | |
| 228 | + pimple_object *pimple_obj = NULL; | |
| 229 | + zend_function *function = NULL; | |
| 230 | + | |
| 231 | + pimple_obj = emalloc(sizeof(pimple_object)); | |
| 232 | + ZEND_OBJ_INIT(&pimple_obj->zobj, ce); | |
| 233 | + | |
| 234 | + PIMPLE_OBJECT_HANDLE_INHERITANCE_OBJECT_HANDLERS | |
| 235 | + | |
| 236 | + retval.handlers = &pimple_object_handlers; | |
| 237 | + retval.handle = zend_objects_store_put(pimple_obj, (zend_objects_store_dtor_t) zend_objects_destroy_object, (zend_objects_free_object_storage_t) pimple_free_object_storage, NULL TSRMLS_CC); | |
| 238 | + | |
| 239 | + zend_hash_init(&pimple_obj->factories, PIMPLE_DEFAULT_ZVAL_CACHE_NUM, NULL, (dtor_func_t)pimple_bucket_dtor, 0); | |
| 240 | + zend_hash_init(&pimple_obj->protected, PIMPLE_DEFAULT_ZVAL_CACHE_NUM, NULL, (dtor_func_t)pimple_bucket_dtor, 0); | |
| 241 | + zend_hash_init(&pimple_obj->values, PIMPLE_DEFAULT_ZVAL_VALUES_NUM, NULL, (dtor_func_t)pimple_bucket_dtor, 0); | |
| 242 | + | |
| 243 | + return retval; | |
| 244 | +} | |
| 245 | + | |
| 246 | +static void pimple_object_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC) | |
| 247 | +{ | |
| 248 | + FETCH_DIM_HANDLERS_VARS | |
| 249 | + | |
| 250 | + pimple_bucket_value pimple_value = {0}, *found_value = NULL; | |
| 251 | + ulong hash; | |
| 252 | + | |
| 253 | + pimple_zval_to_pimpleval(value, &pimple_value TSRMLS_CC); | |
| 254 | + | |
| 255 | + if (!offset) {/* $p[] = 'foo' when not overloaded */ | |
| 256 | + zend_hash_next_index_insert(&pimple_obj->values, (void *)&pimple_value, sizeof(pimple_bucket_value), NULL); | |
| 257 | + Z_ADDREF_P(value); | |
| 258 | + return; | |
| 259 | + } | |
| 260 | + | |
| 261 | + switch (Z_TYPE_P(offset)) { | |
| 262 | + case IS_STRING: | |
| 263 | + hash = zend_hash_func(Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1); | |
| 264 | + zend_hash_quick_find(&pimple_obj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hash, (void **)&found_value); | |
| 265 | + if (found_value && found_value->type == PIMPLE_IS_SERVICE && found_value->initialized == 1) { | |
| 266 | + pimple_free_bucket(&pimple_value); | |
| 267 | + zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, "Cannot override frozen service \"%s\".", Z_STRVAL_P(offset)); | |
| 268 | + return; | |
| 269 | + } | |
| 270 | + if (zend_hash_quick_update(&pimple_obj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, hash, (void *)&pimple_value, sizeof(pimple_bucket_value), NULL) == FAILURE) { | |
| 271 | + pimple_free_bucket(&pimple_value); | |
| 272 | + return; | |
| 273 | + } | |
| 274 | + Z_ADDREF_P(value); | |
| 275 | + break; | |
| 276 | + case IS_DOUBLE: | |
| 277 | + case IS_BOOL: | |
| 278 | + case IS_LONG: | |
| 279 | + if (Z_TYPE_P(offset) == IS_DOUBLE) { | |
| 280 | + index = (ulong)Z_DVAL_P(offset); | |
| 281 | + } else { | |
| 282 | + index = Z_LVAL_P(offset); | |
| 283 | + } | |
| 284 | + zend_hash_index_find(&pimple_obj->values, index, (void **)&found_value); | |
| 285 | + if (found_value && found_value->type == PIMPLE_IS_SERVICE && found_value->initialized == 1) { | |
| 286 | + pimple_free_bucket(&pimple_value); | |
| 287 | + zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, "Cannot override frozen service \"%ld\".", index); | |
| 288 | + return; | |
| 289 | + } | |
| 290 | + if (zend_hash_index_update(&pimple_obj->values, index, (void *)&pimple_value, sizeof(pimple_bucket_value), NULL) == FAILURE) { | |
| 291 | + pimple_free_bucket(&pimple_value); | |
| 292 | + return; | |
| 293 | + } | |
| 294 | + Z_ADDREF_P(value); | |
| 295 | + break; | |
| 296 | + case IS_NULL: /* $p[] = 'foo' when overloaded */ | |
| 297 | + zend_hash_next_index_insert(&pimple_obj->values, (void *)&pimple_value, sizeof(pimple_bucket_value), NULL); | |
| 298 | + Z_ADDREF_P(value); | |
| 299 | + break; | |
| 300 | + default: | |
| 301 | + pimple_free_bucket(&pimple_value); | |
| 302 | + zend_error(E_WARNING, "Unsupported offset type"); | |
| 303 | + } | |
| 304 | +} | |
| 305 | + | |
| 306 | +static void pimple_object_unset_dimension(zval *object, zval *offset TSRMLS_DC) | |
| 307 | +{ | |
| 308 | + FETCH_DIM_HANDLERS_VARS | |
| 309 | + | |
| 310 | + switch (Z_TYPE_P(offset)) { | |
| 311 | + case IS_STRING: | |
| 312 | + zend_symtable_del(&pimple_obj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1); | |
| 313 | + zend_symtable_del(&pimple_obj->factories, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1); | |
| 314 | + zend_symtable_del(&pimple_obj->protected, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1); | |
| 315 | + break; | |
| 316 | + case IS_DOUBLE: | |
| 317 | + case IS_BOOL: | |
| 318 | + case IS_LONG: | |
| 319 | + if (Z_TYPE_P(offset) == IS_DOUBLE) { | |
| 320 | + index = (ulong)Z_DVAL_P(offset); | |
| 321 | + } else { | |
| 322 | + index = Z_LVAL_P(offset); | |
| 323 | + } | |
| 324 | + zend_hash_index_del(&pimple_obj->values, index); | |
| 325 | + zend_hash_index_del(&pimple_obj->factories, index); | |
| 326 | + zend_hash_index_del(&pimple_obj->protected, index); | |
| 327 | + break; | |
| 328 | + default: | |
| 329 | + zend_error(E_WARNING, "Unsupported offset type"); | |
| 330 | + } | |
| 331 | +} | |
| 332 | + | |
| 333 | +static int pimple_object_has_dimension(zval *object, zval *offset, int check_empty TSRMLS_DC) | |
| 334 | +{ | |
| 335 | + FETCH_DIM_HANDLERS_VARS | |
| 336 | + | |
| 337 | + pimple_bucket_value *retval = NULL; | |
| 338 | + | |
| 339 | + switch (Z_TYPE_P(offset)) { | |
| 340 | + case IS_STRING: | |
| 341 | + if (zend_symtable_find(&pimple_obj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **)&retval) == SUCCESS) { | |
| 342 | + switch (check_empty) { | |
| 343 | + case 0: /* isset */ | |
| 344 | + return 1; /* Differs from PHP behavior (Z_TYPE_P(retval->value) != IS_NULL;) */ | |
| 345 | + case 1: /* empty */ | |
| 346 | + default: | |
| 347 | + return zend_is_true(retval->value); | |
| 348 | + } | |
| 349 | + } | |
| 350 | + return 0; | |
| 351 | + break; | |
| 352 | + case IS_DOUBLE: | |
| 353 | + case IS_BOOL: | |
| 354 | + case IS_LONG: | |
| 355 | + if (Z_TYPE_P(offset) == IS_DOUBLE) { | |
| 356 | + index = (ulong)Z_DVAL_P(offset); | |
| 357 | + } else { | |
| 358 | + index = Z_LVAL_P(offset); | |
| 359 | + } | |
| 360 | + if (zend_hash_index_find(&pimple_obj->values, index, (void **)&retval) == SUCCESS) { | |
| 361 | + switch (check_empty) { | |
| 362 | + case 0: /* isset */ | |
| 363 | + return 1; /* Differs from PHP behavior (Z_TYPE_P(retval->value) != IS_NULL;)*/ | |
| 364 | + case 1: /* empty */ | |
| 365 | + default: | |
| 366 | + return zend_is_true(retval->value); | |
| 367 | + } | |
| 368 | + } | |
| 369 | + return 0; | |
| 370 | + break; | |
| 371 | + default: | |
| 372 | + zend_error(E_WARNING, "Unsupported offset type"); | |
| 373 | + return 0; | |
| 374 | + } | |
| 375 | +} | |
| 376 | + | |
| 377 | +static zval *pimple_object_read_dimension(zval *object, zval *offset, int type TSRMLS_DC) | |
| 378 | +{ | |
| 379 | + FETCH_DIM_HANDLERS_VARS | |
| 380 | + | |
| 381 | + pimple_bucket_value *retval = NULL; | |
| 382 | + zend_fcall_info fci = {0}; | |
| 383 | + zval *retval_ptr_ptr = NULL; | |
| 384 | + | |
| 385 | + switch (Z_TYPE_P(offset)) { | |
| 386 | + case IS_STRING: | |
| 387 | + if (zend_symtable_find(&pimple_obj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **)&retval) == FAILURE) { | |
| 388 | + zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Identifier \"%s\" is not defined.", Z_STRVAL_P(offset)); | |
| 389 | + return EG(uninitialized_zval_ptr); | |
| 390 | + } | |
| 391 | + break; | |
| 392 | + case IS_DOUBLE: | |
| 393 | + case IS_BOOL: | |
| 394 | + case IS_LONG: | |
| 395 | + if (Z_TYPE_P(offset) == IS_DOUBLE) { | |
| 396 | + index = (ulong)Z_DVAL_P(offset); | |
| 397 | + } else { | |
| 398 | + index = Z_LVAL_P(offset); | |
| 399 | + } | |
| 400 | + if (zend_hash_index_find(&pimple_obj->values, index, (void **)&retval) == FAILURE) { | |
| 401 | + return EG(uninitialized_zval_ptr); | |
| 402 | + } | |
| 403 | + break; | |
| 404 | + case IS_NULL: /* $p[][3] = 'foo' first dim access */ | |
| 405 | + return EG(uninitialized_zval_ptr); | |
| 406 | + break; | |
| 407 | + default: | |
| 408 | + zend_error(E_WARNING, "Unsupported offset type"); | |
| 409 | + return EG(uninitialized_zval_ptr); | |
| 410 | + } | |
| 411 | + | |
| 412 | + if(retval->type == PIMPLE_IS_PARAM) { | |
| 413 | + return retval->value; | |
| 414 | + } | |
| 415 | + | |
| 416 | + if (zend_hash_index_exists(&pimple_obj->protected, retval->handle_num)) { | |
| 417 | + /* Service is protected, return the value every time */ | |
| 418 | + return retval->value; | |
| 419 | + } | |
| 420 | + | |
| 421 | + if (zend_hash_index_exists(&pimple_obj->factories, retval->handle_num)) { | |
| 422 | + /* Service is a factory, call it everytime and never cache its result */ | |
| 423 | + PIMPLE_CALL_CB | |
| 424 | + Z_DELREF_P(retval_ptr_ptr); /* fetch dim addr will increment refcount */ | |
| 425 | + return retval_ptr_ptr; | |
| 426 | + } | |
| 427 | + | |
| 428 | + if (retval->initialized == 1) { | |
| 429 | + /* Service has already been called, return its cached value */ | |
| 430 | + return retval->value; | |
| 431 | + } | |
| 432 | + | |
| 433 | + ALLOC_INIT_ZVAL(retval->raw); | |
| 434 | + MAKE_COPY_ZVAL(&retval->value, retval->raw); | |
| 435 | + | |
| 436 | + PIMPLE_CALL_CB | |
| 437 | + | |
| 438 | + retval->initialized = 1; | |
| 439 | + zval_ptr_dtor(&retval->value); | |
| 440 | + retval->value = retval_ptr_ptr; | |
| 441 | + | |
| 442 | + return retval->value; | |
| 443 | +} | |
| 444 | + | |
| 445 | +static int pimple_zval_is_valid_callback(zval *_zval, pimple_bucket_value *_pimple_bucket_value TSRMLS_DC) | |
| 446 | +{ | |
| 447 | + if (Z_TYPE_P(_zval) != IS_OBJECT) { | |
| 448 | + return FAILURE; | |
| 449 | + } | |
| 450 | + | |
| 451 | + if (_pimple_bucket_value->fcc.called_scope) { | |
| 452 | + return SUCCESS; | |
| 453 | + } | |
| 454 | + | |
| 455 | + if (Z_OBJ_HANDLER_P(_zval, get_closure) && Z_OBJ_HANDLER_P(_zval, get_closure)(_zval, &_pimple_bucket_value->fcc.calling_scope, &_pimple_bucket_value->fcc.function_handler, &_pimple_bucket_value->fcc.object_ptr TSRMLS_CC) == SUCCESS) { | |
| 456 | + _pimple_bucket_value->fcc.called_scope = _pimple_bucket_value->fcc.calling_scope; | |
| 457 | + return SUCCESS; | |
| 458 | + } else { | |
| 459 | + return FAILURE; | |
| 460 | + } | |
| 461 | +} | |
| 462 | + | |
| 463 | +static int pimple_zval_to_pimpleval(zval *_zval, pimple_bucket_value *_pimple_bucket_value TSRMLS_DC) | |
| 464 | +{ | |
| 465 | + _pimple_bucket_value->value = _zval; | |
| 466 | + | |
| 467 | + if (Z_TYPE_P(_zval) != IS_OBJECT) { | |
| 468 | + return PIMPLE_IS_PARAM; | |
| 469 | + } | |
| 470 | + | |
| 471 | + if (pimple_zval_is_valid_callback(_zval, _pimple_bucket_value TSRMLS_CC) == SUCCESS) { | |
| 472 | + _pimple_bucket_value->type = PIMPLE_IS_SERVICE; | |
| 473 | + _pimple_bucket_value->handle_num = Z_OBJ_HANDLE_P(_zval); | |
| 474 | + } | |
| 475 | + | |
| 476 | + return PIMPLE_IS_SERVICE; | |
| 477 | +} | |
| 478 | + | |
| 479 | +static void pimple_bucket_dtor(pimple_bucket_value *bucket) | |
| 480 | +{ | |
| 481 | + zval_ptr_dtor(&bucket->value); | |
| 482 | + pimple_free_bucket(bucket); | |
| 483 | +} | |
| 484 | + | |
| 485 | +PHP_METHOD(Pimple, protect) | |
| 486 | +{ | |
| 487 | + zval *protected = NULL; | |
| 488 | + pimple_object *pobj = NULL; | |
| 489 | + pimple_bucket_value bucket = {0}; | |
| 490 | + | |
| 491 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &protected) == FAILURE) { | |
| 492 | + return; | |
| 493 | + } | |
| 494 | + | |
| 495 | + if (pimple_zval_is_valid_callback(protected, &bucket TSRMLS_CC) == FAILURE) { | |
| 496 | + pimple_free_bucket(&bucket); | |
| 497 | + zend_throw_exception(spl_ce_InvalidArgumentException, "Callable is not a Closure or invokable object.", 0 TSRMLS_CC); | |
| 498 | + return; | |
| 499 | + } | |
| 500 | + | |
| 501 | + pimple_zval_to_pimpleval(protected, &bucket TSRMLS_CC); | |
| 502 | + pobj = (pimple_object *)zend_object_store_get_object(getThis() TSRMLS_CC); | |
| 503 | + | |
| 504 | + if (zend_hash_index_update(&pobj->protected, bucket.handle_num, (void *)&bucket, sizeof(pimple_bucket_value), NULL) == SUCCESS) { | |
| 505 | + Z_ADDREF_P(protected); | |
| 506 | + RETURN_ZVAL(protected, 1 , 0); | |
| 507 | + } else { | |
| 508 | + pimple_free_bucket(&bucket); | |
| 509 | + } | |
| 510 | + RETURN_FALSE; | |
| 511 | +} | |
| 512 | + | |
| 513 | +PHP_METHOD(Pimple, raw) | |
| 514 | +{ | |
| 515 | + zval *offset = NULL; | |
| 516 | + pimple_object *pobj = NULL; | |
| 517 | + pimple_bucket_value *value = NULL; | |
| 518 | + ulong index; | |
| 519 | + | |
| 520 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &offset) == FAILURE) { | |
| 521 | + return; | |
| 522 | + } | |
| 523 | + | |
| 524 | + pobj = zend_object_store_get_object(getThis() TSRMLS_CC); | |
| 525 | + | |
| 526 | + switch (Z_TYPE_P(offset)) { | |
| 527 | + case IS_STRING: | |
| 528 | + if (zend_symtable_find(&pobj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void *)&value) == FAILURE) { | |
| 529 | + zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Identifier \"%s\" is not defined.", Z_STRVAL_P(offset)); | |
| 530 | + RETURN_NULL(); | |
| 531 | + } | |
| 532 | + break; | |
| 533 | + case IS_DOUBLE: | |
| 534 | + case IS_BOOL: | |
| 535 | + case IS_LONG: | |
| 536 | + if (Z_TYPE_P(offset) == IS_DOUBLE) { | |
| 537 | + index = (ulong)Z_DVAL_P(offset); | |
| 538 | + } else { | |
| 539 | + index = Z_LVAL_P(offset); | |
| 540 | + } | |
| 541 | + if (zend_hash_index_find(&pobj->values, index, (void *)&value) == FAILURE) { | |
| 542 | + RETURN_NULL(); | |
| 543 | + } | |
| 544 | + break; | |
| 545 | + case IS_NULL: | |
| 546 | + default: | |
| 547 | + zend_error(E_WARNING, "Unsupported offset type"); | |
| 548 | + } | |
| 549 | + | |
| 550 | + if (value->raw) { | |
| 551 | + RETVAL_ZVAL(value->raw, 1, 0); | |
| 552 | + } else { | |
| 553 | + RETVAL_ZVAL(value->value, 1, 0); | |
| 554 | + } | |
| 555 | +} | |
| 556 | + | |
| 557 | +PHP_METHOD(Pimple, extend) | |
| 558 | +{ | |
| 559 | + zval *offset = NULL, *callable = NULL, *pimple_closure_obj = NULL; | |
| 560 | + pimple_bucket_value bucket = {0}, *value = NULL; | |
| 561 | + pimple_object *pobj = NULL; | |
| 562 | + pimple_closure_object *pcobj = NULL; | |
| 563 | + ulong index; | |
| 564 | + | |
| 565 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &offset, &callable) == FAILURE) { | |
| 566 | + return; | |
| 567 | + } | |
| 568 | + | |
| 569 | + pobj = zend_object_store_get_object(getThis() TSRMLS_CC); | |
| 570 | + | |
| 571 | + switch (Z_TYPE_P(offset)) { | |
| 572 | + case IS_STRING: | |
| 573 | + if (zend_symtable_find(&pobj->values, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void *)&value) == FAILURE) { | |
| 574 | + zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Identifier \"%s\" is not defined.", Z_STRVAL_P(offset)); | |
| 575 | + RETURN_NULL(); | |
| 576 | + } | |
| 577 | + if (value->type != PIMPLE_IS_SERVICE) { | |
| 578 | + zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Identifier \"%s\" does not contain an object definition.", Z_STRVAL_P(offset)); | |
| 579 | + RETURN_NULL(); | |
| 580 | + } | |
| 581 | + break; | |
| 582 | + case IS_DOUBLE: | |
| 583 | + case IS_BOOL: | |
| 584 | + case IS_LONG: | |
| 585 | + if (Z_TYPE_P(offset) == IS_DOUBLE) { | |
| 586 | + index = (ulong)Z_DVAL_P(offset); | |
| 587 | + } else { | |
| 588 | + index = Z_LVAL_P(offset); | |
| 589 | + } | |
| 590 | + if (zend_hash_index_find(&pobj->values, index, (void *)&value) == FAILURE) { | |
| 591 | + zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Identifier \"%ld\" is not defined.", index); | |
| 592 | + RETURN_NULL(); | |
| 593 | + } | |
| 594 | + if (value->type != PIMPLE_IS_SERVICE) { | |
| 595 | + zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Identifier \"%ld\" does not contain an object definition.", index); | |
| 596 | + RETURN_NULL(); | |
| 597 | + } | |
| 598 | + break; | |
| 599 | + case IS_NULL: | |
| 600 | + default: | |
| 601 | + zend_error(E_WARNING, "Unsupported offset type"); | |
| 602 | + } | |
| 603 | + | |
| 604 | + if (pimple_zval_is_valid_callback(callable, &bucket TSRMLS_CC) == FAILURE) { | |
| 605 | + pimple_free_bucket(&bucket); | |
| 606 | + zend_throw_exception(spl_ce_InvalidArgumentException, "Extension service definition is not a Closure or invokable object.", 0 TSRMLS_CC); | |
| 607 | + RETURN_NULL(); | |
| 608 | + } | |
| 609 | + pimple_free_bucket(&bucket); | |
| 610 | + | |
| 611 | + ALLOC_INIT_ZVAL(pimple_closure_obj); | |
| 612 | + object_init_ex(pimple_closure_obj, pimple_closure_ce); | |
| 613 | + | |
| 614 | + pcobj = zend_object_store_get_object(pimple_closure_obj TSRMLS_CC); | |
| 615 | + pcobj->callable = callable; | |
| 616 | + pcobj->factory = value->value; | |
| 617 | + Z_ADDREF_P(callable); | |
| 618 | + Z_ADDREF_P(value->value); | |
| 619 | + | |
| 620 | + if (zend_hash_index_exists(&pobj->factories, value->handle_num)) { | |
| 621 | + pimple_zval_to_pimpleval(pimple_closure_obj, &bucket TSRMLS_CC); | |
| 622 | + zend_hash_index_del(&pobj->factories, value->handle_num); | |
| 623 | + zend_hash_index_update(&pobj->factories, bucket.handle_num, (void *)&bucket, sizeof(pimple_bucket_value), NULL); | |
| 624 | + Z_ADDREF_P(pimple_closure_obj); | |
| 625 | + } | |
| 626 | + | |
| 627 | + pimple_object_write_dimension(getThis(), offset, pimple_closure_obj TSRMLS_CC); | |
| 628 | + | |
| 629 | + RETVAL_ZVAL(pimple_closure_obj, 1, 1); | |
| 630 | +} | |
| 631 | + | |
| 632 | +PHP_METHOD(Pimple, keys) | |
| 633 | +{ | |
| 634 | + HashPosition pos; | |
| 635 | + pimple_object *pobj = NULL; | |
| 636 | + zval **value = NULL; | |
| 637 | + zval *endval = NULL; | |
| 638 | + char *str_index = NULL; | |
| 639 | + int str_len; | |
| 640 | + ulong num_index; | |
| 641 | + | |
| 642 | + if (zend_parse_parameters_none() == FAILURE) { | |
| 643 | + return; | |
| 644 | + } | |
| 645 | + | |
| 646 | + pobj = zend_object_store_get_object(getThis() TSRMLS_CC); | |
| 647 | + array_init_size(return_value, zend_hash_num_elements(&pobj->values)); | |
| 648 | + | |
| 649 | + zend_hash_internal_pointer_reset_ex(&pobj->values, &pos); | |
| 650 | + | |
| 651 | + while(zend_hash_get_current_data_ex(&pobj->values, (void **)&value, &pos) == SUCCESS) { | |
| 652 | + MAKE_STD_ZVAL(endval); | |
| 653 | + switch (zend_hash_get_current_key_ex(&pobj->values, &str_index, (uint *)&str_len, &num_index, 0, &pos)) { | |
| 654 | + case HASH_KEY_IS_STRING: | |
| 655 | + ZVAL_STRINGL(endval, str_index, str_len - 1, 1); | |
| 656 | + zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &endval, sizeof(zval *), NULL); | |
| 657 | + break; | |
| 658 | + case HASH_KEY_IS_LONG: | |
| 659 | + ZVAL_LONG(endval, num_index); | |
| 660 | + zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &endval, sizeof(zval *), NULL); | |
| 661 | + break; | |
| 662 | + } | |
| 663 | + zend_hash_move_forward_ex(&pobj->values, &pos); | |
| 664 | + } | |
| 665 | +} | |
| 666 | + | |
| 667 | +PHP_METHOD(Pimple, factory) | |
| 668 | +{ | |
| 669 | + zval *factory = NULL; | |
| 670 | + pimple_object *pobj = NULL; | |
| 671 | + pimple_bucket_value bucket = {0}; | |
| 672 | + | |
| 673 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &factory) == FAILURE) { | |
| 674 | + return; | |
| 675 | + } | |
| 676 | + | |
| 677 | + if (pimple_zval_is_valid_callback(factory, &bucket TSRMLS_CC) == FAILURE) { | |
| 678 | + pimple_free_bucket(&bucket); | |
| 679 | + zend_throw_exception(spl_ce_InvalidArgumentException, "Service definition is not a Closure or invokable object.", 0 TSRMLS_CC); | |
| 680 | + return; | |
| 681 | + } | |
| 682 | + | |
| 683 | + pimple_zval_to_pimpleval(factory, &bucket TSRMLS_CC); | |
| 684 | + pobj = (pimple_object *)zend_object_store_get_object(getThis() TSRMLS_CC); | |
| 685 | + | |
| 686 | + if (zend_hash_index_update(&pobj->factories, bucket.handle_num, (void *)&bucket, sizeof(pimple_bucket_value), NULL) == SUCCESS) { | |
| 687 | + Z_ADDREF_P(factory); | |
| 688 | + RETURN_ZVAL(factory, 1 , 0); | |
| 689 | + } else { | |
| 690 | + pimple_free_bucket(&bucket); | |
| 691 | + } | |
| 692 | + | |
| 693 | + RETURN_FALSE; | |
| 694 | +} | |
| 695 | + | |
| 696 | +PHP_METHOD(Pimple, offsetSet) | |
| 697 | +{ | |
| 698 | + zval *offset = NULL, *value = NULL; | |
| 699 | + | |
| 700 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &offset, &value) == FAILURE) { | |
| 701 | + return; | |
| 702 | + } | |
| 703 | + | |
| 704 | + pimple_object_write_dimension(getThis(), offset, value TSRMLS_CC); | |
| 705 | +} | |
| 706 | + | |
| 707 | +PHP_METHOD(Pimple, offsetGet) | |
| 708 | +{ | |
| 709 | + zval *offset = NULL, *retval = NULL; | |
| 710 | + | |
| 711 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &offset) == FAILURE) { | |
| 712 | + return; | |
| 713 | + } | |
| 714 | + | |
| 715 | + retval = pimple_object_read_dimension(getThis(), offset, 0 TSRMLS_CC); | |
| 716 | + | |
| 717 | + RETVAL_ZVAL(retval, 1, 0); | |
| 718 | +} | |
| 719 | + | |
| 720 | +PHP_METHOD(Pimple, offsetUnset) | |
| 721 | +{ | |
| 722 | + zval *offset = NULL; | |
| 723 | + | |
| 724 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &offset) == FAILURE) { | |
| 725 | + return; | |
| 726 | + } | |
| 727 | + | |
| 728 | + pimple_object_unset_dimension(getThis(), offset TSRMLS_CC); | |
| 729 | +} | |
| 730 | + | |
| 731 | +PHP_METHOD(Pimple, offsetExists) | |
| 732 | +{ | |
| 733 | + zval *offset = NULL; | |
| 734 | + | |
| 735 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &offset) == FAILURE) { | |
| 736 | + return; | |
| 737 | + } | |
| 738 | + | |
| 739 | + RETVAL_BOOL(pimple_object_has_dimension(getThis(), offset, 1 TSRMLS_CC)); | |
| 740 | +} | |
| 741 | + | |
| 742 | +PHP_METHOD(Pimple, register) | |
| 743 | +{ | |
| 744 | + zval *provider; | |
| 745 | + zval **data; | |
| 746 | + zval *retval = NULL; | |
| 747 | + zval key; | |
| 748 | + | |
| 749 | + HashTable *array = NULL; | |
| 750 | + HashPosition pos; | |
| 751 | + | |
| 752 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|h", &provider, pimple_serviceprovider_ce, &array) == FAILURE) { | |
| 753 | + return; | |
| 754 | + } | |
| 755 | + | |
| 756 | + RETVAL_ZVAL(getThis(), 1, 0); | |
| 757 | + | |
| 758 | + zend_call_method_with_1_params(&provider, Z_OBJCE_P(provider), NULL, "register", &retval, getThis()); | |
| 759 | + | |
| 760 | + if (retval) { | |
| 761 | + zval_ptr_dtor(&retval); | |
| 762 | + } | |
| 763 | + | |
| 764 | + if (!array) { | |
| 765 | + return; | |
| 766 | + } | |
| 767 | + | |
| 768 | + zend_hash_internal_pointer_reset_ex(array, &pos); | |
| 769 | + | |
| 770 | + while(zend_hash_get_current_data_ex(array, (void **)&data, &pos) == SUCCESS) { | |
| 771 | + zend_hash_get_current_key_zval_ex(array, &key, &pos); | |
| 772 | + pimple_object_write_dimension(getThis(), &key, *data TSRMLS_CC); | |
| 773 | + zend_hash_move_forward_ex(array, &pos); | |
| 774 | + } | |
| 775 | +} | |
| 776 | + | |
| 777 | +PHP_METHOD(Pimple, __construct) | |
| 778 | +{ | |
| 779 | + zval *values = NULL, **pData = NULL, offset; | |
| 780 | + HashPosition pos; | |
| 781 | + char *str_index = NULL; | |
| 782 | + zend_uint str_length; | |
| 783 | + ulong num_index; | |
| 784 | + | |
| 785 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a!", &values) == FAILURE || !values) { | |
| 786 | + return; | |
| 787 | + } | |
| 788 | + | |
| 789 | + zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(values), &pos); | |
| 790 | + while (zend_hash_has_more_elements_ex(Z_ARRVAL_P(values), &pos) == SUCCESS) { | |
| 791 | + zend_hash_get_current_data_ex(Z_ARRVAL_P(values), (void **)&pData, &pos); | |
| 792 | + zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &str_index, &str_length, &num_index, 0, &pos); | |
| 793 | + INIT_ZVAL(offset); | |
| 794 | + if (zend_hash_get_current_key_type_ex(Z_ARRVAL_P(values), &pos) == HASH_KEY_IS_LONG) { | |
| 795 | + ZVAL_LONG(&offset, num_index); | |
| 796 | + } else { | |
| 797 | + ZVAL_STRINGL(&offset, str_index, (str_length - 1), 0); | |
| 798 | + } | |
| 799 | + pimple_object_write_dimension(getThis(), &offset, *pData TSRMLS_CC); | |
| 800 | + zend_hash_move_forward_ex(Z_ARRVAL_P(values), &pos); | |
| 801 | + } | |
| 802 | +} | |
| 803 | + | |
| 804 | +/* | |
| 805 | + * This is PHP code snippet handling extend()s calls : | |
| 806 | + | |
| 807 | + $extended = function ($c) use ($callable, $factory) { | |
| 808 | + return $callable($factory($c), $c); | |
| 809 | + }; | |
| 810 | + | |
| 811 | + */ | |
| 812 | +PHP_METHOD(PimpleClosure, invoker) | |
| 813 | +{ | |
| 814 | + pimple_closure_object *pcobj = NULL; | |
| 815 | + zval *arg = NULL, *retval = NULL, *newretval = NULL; | |
| 816 | + zend_fcall_info fci = {0}; | |
| 817 | + zval **args[2]; | |
| 818 | + | |
| 819 | + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) { | |
| 820 | + return; | |
| 821 | + } | |
| 822 | + | |
| 823 | + pcobj = zend_object_store_get_object(getThis() TSRMLS_CC); | |
| 824 | + | |
| 825 | + fci.function_name = pcobj->factory; | |
| 826 | + args[0] = &arg; | |
| 827 | + zend_fcall_info_argp(&fci TSRMLS_CC, 1, args); | |
| 828 | + fci.retval_ptr_ptr = &retval; | |
| 829 | + fci.size = sizeof(fci); | |
| 830 | + | |
| 831 | + if (zend_call_function(&fci, NULL TSRMLS_CC) == FAILURE || EG(exception)) { | |
| 832 | + efree(fci.params); | |
| 833 | + return; /* Should here return default zval */ | |
| 834 | + } | |
| 835 | + | |
| 836 | + efree(fci.params); | |
| 837 | + memset(&fci, 0, sizeof(fci)); | |
| 838 | + fci.size = sizeof(fci); | |
| 839 | + | |
| 840 | + fci.function_name = pcobj->callable; | |
| 841 | + args[0] = &retval; | |
| 842 | + args[1] = &arg; | |
| 843 | + zend_fcall_info_argp(&fci TSRMLS_CC, 2, args); | |
| 844 | + fci.retval_ptr_ptr = &newretval; | |
| 845 | + | |
| 846 | + if (zend_call_function(&fci, NULL TSRMLS_CC) == FAILURE || EG(exception)) { | |
| 847 | + efree(fci.params); | |
| 848 | + zval_ptr_dtor(&retval); | |
| 849 | + return; | |
| 850 | + } | |
| 851 | + | |
| 852 | + efree(fci.params); | |
| 853 | + zval_ptr_dtor(&retval); | |
| 854 | + | |
| 855 | + RETVAL_ZVAL(newretval, 1 ,1); | |
| 856 | +} | |
| 857 | + | |
| 858 | +PHP_MINIT_FUNCTION(pimple) | |
| 859 | +{ | |
| 860 | + zend_class_entry tmp_pimple_ce, tmp_pimple_closure_ce, tmp_pimple_serviceprovider_iface_ce; | |
| 861 | + INIT_NS_CLASS_ENTRY(tmp_pimple_ce, PIMPLE_NS, "Container", pimple_ce_functions); | |
| 862 | + INIT_NS_CLASS_ENTRY(tmp_pimple_closure_ce, PIMPLE_NS, "ContainerClosure", NULL); | |
| 863 | + INIT_NS_CLASS_ENTRY(tmp_pimple_serviceprovider_iface_ce, PIMPLE_NS, "ServiceProviderInterface", pimple_serviceprovider_iface_ce_functions); | |
| 864 | + | |
| 865 | + tmp_pimple_ce.create_object = pimple_object_create; | |
| 866 | + tmp_pimple_closure_ce.create_object = pimple_closure_object_create; | |
| 867 | + | |
| 868 | + pimple_ce = zend_register_internal_class(&tmp_pimple_ce TSRMLS_CC); | |
| 869 | + zend_class_implements(pimple_ce TSRMLS_CC, 1, zend_ce_arrayaccess); | |
| 870 | + | |
| 871 | + pimple_closure_ce = zend_register_internal_class(&tmp_pimple_closure_ce TSRMLS_CC); | |
| 872 | + pimple_closure_ce->ce_flags |= ZEND_ACC_FINAL_CLASS; | |
| 873 | + | |
| 874 | + pimple_serviceprovider_ce = zend_register_internal_interface(&tmp_pimple_serviceprovider_iface_ce TSRMLS_CC); | |
| 875 | + | |
| 876 | + memcpy(&pimple_closure_object_handlers, zend_get_std_object_handlers(), sizeof(*zend_get_std_object_handlers())); | |
| 877 | + pimple_object_handlers = std_object_handlers; | |
| 878 | + pimple_closure_object_handlers.get_closure = pimple_closure_get_closure; | |
| 879 | + | |
| 880 | + pimple_closure_invoker_function.function_name = "Pimple closure internal invoker"; | |
| 881 | + pimple_closure_invoker_function.fn_flags |= ZEND_ACC_CLOSURE; | |
| 882 | + pimple_closure_invoker_function.handler = ZEND_MN(PimpleClosure_invoker); | |
| 883 | + pimple_closure_invoker_function.num_args = 1; | |
| 884 | + pimple_closure_invoker_function.required_num_args = 1; | |
| 885 | + pimple_closure_invoker_function.scope = pimple_closure_ce; | |
| 886 | + pimple_closure_invoker_function.type = ZEND_INTERNAL_FUNCTION; | |
| 887 | + pimple_closure_invoker_function.module = &pimple_module_entry; | |
| 888 | + | |
| 889 | + return SUCCESS; | |
| 890 | +} | |
| 891 | + | |
| 892 | +PHP_MINFO_FUNCTION(pimple) | |
| 893 | +{ | |
| 894 | + php_info_print_table_start(); | |
| 895 | + php_info_print_table_header(2, "SensioLabs Pimple C support", "enabled"); | |
| 896 | + php_info_print_table_row(2, "Pimple supported version", PIMPLE_VERSION); | |
| 897 | + php_info_print_table_end(); | |
| 898 | + | |
| 899 | + php_info_print_box_start(0); | |
| 900 | + php_write((void *)ZEND_STRL("SensioLabs Pimple C support developed by Julien Pauli") TSRMLS_CC); | |
| 901 | + if (!sapi_module.phpinfo_as_text) { | |
| 902 | + php_write((void *)ZEND_STRL(sensiolabs_logo) TSRMLS_CC); | |
| 903 | + } | |
| 904 | + php_info_print_box_end(); | |
| 905 | +} | |
| 906 | + | |
| 907 | +zend_module_entry pimple_module_entry = { | |
| 908 | + STANDARD_MODULE_HEADER, | |
| 909 | + "pimple", | |
| 910 | + NULL, | |
| 911 | + PHP_MINIT(pimple), | |
| 912 | + NULL, | |
| 913 | + NULL, | |
| 914 | + NULL, | |
| 915 | + PHP_MINFO(pimple), | |
| 916 | + PIMPLE_VERSION, | |
| 917 | + STANDARD_MODULE_PROPERTIES | |
| 918 | +}; | |
| 919 | + | |
| 920 | +#ifdef COMPILE_DL_PIMPLE | |
| 921 | +ZEND_GET_MODULE(pimple) | |
| 922 | +#endif | ... | ... |
| 1 | +++ a/vendor/pimple/pimple/ext/pimple/pimple_compat.h | |
| ... | ... | @@ -0,0 +1,81 @@ |
| 1 | + | |
| 2 | +/* | |
| 3 | + * This file is part of Pimple. | |
| 4 | + * | |
| 5 | + * Copyright (c) 2014 Fabien Potencier | |
| 6 | + * | |
| 7 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 8 | + * of this software and associated documentation files (the "Software"), to deal | |
| 9 | + * in the Software without restriction, including without limitation the rights | |
| 10 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 11 | + * copies of the Software, and to permit persons to whom the Software is furnished | |
| 12 | + * to do so, subject to the following conditions: | |
| 13 | + * | |
| 14 | + * The above copyright notice and this permission notice shall be included in all | |
| 15 | + * copies or substantial portions of the Software. | |
| 16 | + * | |
| 17 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 18 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 19 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 20 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 21 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 22 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 23 | + * THE SOFTWARE. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +#ifndef PIMPLE_COMPAT_H_ | |
| 27 | +#define PIMPLE_COMPAT_H_ | |
| 28 | + | |
| 29 | +#include "Zend/zend_extensions.h" /* for ZEND_EXTENSION_API_NO */ | |
| 30 | + | |
| 31 | +#define PHP_5_0_X_API_NO 220040412 | |
| 32 | +#define PHP_5_1_X_API_NO 220051025 | |
| 33 | +#define PHP_5_2_X_API_NO 220060519 | |
| 34 | +#define PHP_5_3_X_API_NO 220090626 | |
| 35 | +#define PHP_5_4_X_API_NO 220100525 | |
| 36 | +#define PHP_5_5_X_API_NO 220121212 | |
| 37 | +#define PHP_5_6_X_API_NO 220131226 | |
| 38 | + | |
| 39 | +#define IS_PHP_56 ZEND_EXTENSION_API_NO == PHP_5_6_X_API_NO | |
| 40 | +#define IS_AT_LEAST_PHP_56 ZEND_EXTENSION_API_NO >= PHP_5_6_X_API_NO | |
| 41 | + | |
| 42 | +#define IS_PHP_55 ZEND_EXTENSION_API_NO == PHP_5_5_X_API_NO | |
| 43 | +#define IS_AT_LEAST_PHP_55 ZEND_EXTENSION_API_NO >= PHP_5_5_X_API_NO | |
| 44 | + | |
| 45 | +#define IS_PHP_54 ZEND_EXTENSION_API_NO == PHP_5_4_X_API_NO | |
| 46 | +#define IS_AT_LEAST_PHP_54 ZEND_EXTENSION_API_NO >= PHP_5_4_X_API_NO | |
| 47 | + | |
| 48 | +#define IS_PHP_53 ZEND_EXTENSION_API_NO == PHP_5_3_X_API_NO | |
| 49 | +#define IS_AT_LEAST_PHP_53 ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO | |
| 50 | + | |
| 51 | +#if IS_PHP_53 | |
| 52 | +#define object_properties_init(obj, ce) do { \ | |
| 53 | + zend_hash_copy(obj->properties, &ce->default_properties, zval_copy_property_ctor(ce), NULL, sizeof(zval *)); \ | |
| 54 | + } while (0); | |
| 55 | +#endif | |
| 56 | + | |
| 57 | +#define ZEND_OBJ_INIT(obj, ce) do { \ | |
| 58 | + zend_object_std_init(obj, ce TSRMLS_CC); \ | |
| 59 | + object_properties_init((obj), (ce)); \ | |
| 60 | + } while(0); | |
| 61 | + | |
| 62 | +#if IS_PHP_53 || IS_PHP_54 | |
| 63 | +static void zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, HashPosition *pos) { | |
| 64 | + Bucket *p; | |
| 65 | + | |
| 66 | + p = pos ? (*pos) : ht->pInternalPointer; | |
| 67 | + | |
| 68 | + if (!p) { | |
| 69 | + Z_TYPE_P(key) = IS_NULL; | |
| 70 | + } else if (p->nKeyLength) { | |
| 71 | + Z_TYPE_P(key) = IS_STRING; | |
| 72 | + Z_STRVAL_P(key) = estrndup(p->arKey, p->nKeyLength - 1); | |
| 73 | + Z_STRLEN_P(key) = p->nKeyLength - 1; | |
| 74 | + } else { | |
| 75 | + Z_TYPE_P(key) = IS_LONG; | |
| 76 | + Z_LVAL_P(key) = p->h; | |
| 77 | + } | |
| 78 | +} | |
| 79 | +#endif | |
| 80 | + | |
| 81 | +#endif /* PIMPLE_COMPAT_H_ */ | ... | ... |
| 1 | +++ a/vendor/pimple/pimple/ext/pimple/tests/001.phpt | |
| ... | ... | @@ -0,0 +1,45 @@ |
| 1 | +--TEST-- | |
| 2 | +Test for read_dim/write_dim handlers | |
| 3 | +--SKIPIF-- | |
| 4 | +<?php if (!extension_loaded("pimple")) print "skip"; ?> | |
| 5 | +--FILE-- | |
| 6 | +<?php | |
| 7 | +$p = new Pimple\Container(); | |
| 8 | +$p[42] = 'foo'; | |
| 9 | +$p['foo'] = 42; | |
| 10 | + | |
| 11 | +echo $p[42]; | |
| 12 | +echo "\n"; | |
| 13 | +echo $p['foo']; | |
| 14 | +echo "\n"; | |
| 15 | +try { | |
| 16 | + var_dump($p['nonexistant']); | |
| 17 | + echo "Exception excpected"; | |
| 18 | +} catch (InvalidArgumentException $e) { } | |
| 19 | + | |
| 20 | +$p[54.2] = 'foo2'; | |
| 21 | +echo $p[54]; | |
| 22 | +echo "\n"; | |
| 23 | +$p[242.99] = 'foo99'; | |
| 24 | +echo $p[242]; | |
| 25 | + | |
| 26 | +echo "\n"; | |
| 27 | + | |
| 28 | +$p[5] = 'bar'; | |
| 29 | +$p[5] = 'baz'; | |
| 30 | +echo $p[5]; | |
| 31 | + | |
| 32 | +echo "\n"; | |
| 33 | + | |
| 34 | +$p['str'] = 'str'; | |
| 35 | +$p['str'] = 'strstr'; | |
| 36 | +echo $p['str']; | |
| 37 | +?> | |
| 38 | + | |
| 39 | +--EXPECTF-- | |
| 40 | +foo | |
| 41 | +42 | |
| 42 | +foo2 | |
| 43 | +foo99 | |
| 44 | +baz | |
| 45 | +strstr | |
| 0 | 46 | \ No newline at end of file | ... | ... |
| 1 | +++ a/vendor/pimple/pimple/ext/pimple/tests/002.phpt | |
| ... | ... | @@ -0,0 +1,15 @@ |
| 1 | +--TEST-- | |
| 2 | +Test for constructor | |
| 3 | +--SKIPIF-- | |
| 4 | +<?php if (!extension_loaded("pimple")) print "skip"; ?> | |
| 5 | +--FILE-- | |
| 6 | +<?php | |
| 7 | +$p = new Pimple\Container(); | |
| 8 | +var_dump($p[42]); | |
| 9 | + | |
| 10 | +$p = new Pimple\Container(array(42=>'foo')); | |
| 11 | +var_dump($p[42]); | |
| 12 | +?> | |
| 13 | +--EXPECT-- | |
| 14 | +NULL | |
| 15 | +string(3) "foo" | ... | ... |