@@ -16,7 +16,7 @@ |
||
| 16 | 16 | |
| 17 | 17 | public function __construct($auth_config = null) |
| 18 | 18 | { |
| 19 | - $auth_config = $auth_config ?: [ |
|
| 19 | + $auth_config = $auth_config ?: [ |
|
| 20 | 20 | "auth.api_path" => "^/?", |
| 21 | 21 | "auth.force_guest" => true, |
| 22 | 22 | "auth.cookie_expiration" => false, |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | $app["orm.em"]->getConnection()->getConfiguration()->setSQLLogger($app["orm.profiler"]); |
| 27 | 27 | |
| 28 | 28 | $app->after( |
| 29 | - function (Request $request, Response $response) use ($app) { |
|
| 29 | + function(Request $request, Response $response) use ($app) { |
|
| 30 | 30 | $response->headers->set("X-ORM-Profiler-Route", $request->getPathInfo()); |
| 31 | 31 | $response->headers->set("X-ORM-Profiler-Count", count($app["orm.profiler"]->queries)); |
| 32 | 32 | $response->headers->set("X-ORM-Profiler-Queries", json_encode($app["orm.profiler"]->queries)); |
@@ -21,17 +21,17 @@ |
||
| 21 | 21 | private function coerce_to_bool(String $value, String $name) |
| 22 | 22 | { |
| 23 | 23 | switch (strtolower($value)) { |
| 24 | - case "yes": |
|
| 25 | - case "1": |
|
| 26 | - case "true": |
|
| 27 | - return true; |
|
| 28 | - case "no": |
|
| 29 | - case "0": |
|
| 30 | - case "false": |
|
| 31 | - return false; |
|
| 32 | - default: |
|
| 33 | - throw new \Exception("Cannot coerce value '{$value}' into a boolean for {$name}"); |
|
| 34 | - return false; |
|
| 24 | + case "yes": |
|
| 25 | + case "1": |
|
| 26 | + case "true": |
|
| 27 | + return true; |
|
| 28 | + case "no": |
|
| 29 | + case "0": |
|
| 30 | + case "false": |
|
| 31 | + return false; |
|
| 32 | + default: |
|
| 33 | + throw new \Exception("Cannot coerce value '{$value}' into a boolean for {$name}"); |
|
| 34 | + return false; |
|
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | { |
| 16 | 16 | $rmq_config = $rmq_config ?: []; |
| 17 | 17 | $this->rmq_config['exchanges'] = isset($rmq_config['exchanges']) ? $rmq_config['exchanges'] : []; |
| 18 | - $this->rmq_config['queues'] = isset($rmq_config['queues']) ? $rmq_config['queues'] : []; |
|
| 18 | + $this->rmq_config['queues'] = isset($rmq_config['queues']) ? $rmq_config['queues'] : []; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | private function coerce_to_bool(String $value, String $name) |
@@ -93,24 +93,24 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | $configuration->addCustomStringFunction('REPLACE', 'DoctrineExtensions\Query\Mysql\Replace'); |
| 95 | 95 | |
| 96 | - $configuration->addCustomStringFunction('MD5', 'DoctrineExtensions\Query\Mysql\Md5'); |
|
| 96 | + $configuration->addCustomStringFunction('MD5', 'DoctrineExtensions\Query\Mysql\Md5'); |
|
| 97 | 97 | $configuration->addCustomStringFunction('SHA1', 'DoctrineExtensions\Query\Mysql\Sha1'); |
| 98 | 98 | $configuration->addCustomStringFunction('SHA2', 'DoctrineExtensions\Query\Mysql\Sha2'); |
| 99 | 99 | |
| 100 | - $configuration->addCustomNumericFunction('RAND', 'DoctrineExtensions\Query\Mysql\Rand'); |
|
| 100 | + $configuration->addCustomNumericFunction('RAND', 'DoctrineExtensions\Query\Mysql\Rand'); |
|
| 101 | 101 | $configuration->addCustomNumericFunction('ROUND', 'DoctrineExtensions\Query\Mysql\Round'); |
| 102 | 102 | |
| 103 | - $configuration->addCustomDatetimeFunction('DATE', 'DoctrineExtensions\Query\Mysql\Date'); |
|
| 104 | - $configuration->addCustomDatetimeFunction('DATEDIFF', 'DoctrineExtensions\Query\Mysql\DateDiff'); |
|
| 105 | - $configuration->addCustomDatetimeFunction('DATEADD', 'DoctrineExtensions\Query\Mysql\DateAdd'); |
|
| 103 | + $configuration->addCustomDatetimeFunction('DATE', 'DoctrineExtensions\Query\Mysql\Date'); |
|
| 104 | + $configuration->addCustomDatetimeFunction('DATEDIFF', 'DoctrineExtensions\Query\Mysql\DateDiff'); |
|
| 105 | + $configuration->addCustomDatetimeFunction('DATEADD', 'DoctrineExtensions\Query\Mysql\DateAdd'); |
|
| 106 | 106 | $configuration->addCustomDatetimeFunction('DATEFORMAT', 'DoctrineExtensions\Query\Mysql\DateFormat'); |
| 107 | - $configuration->addCustomDatetimeFunction('HOUR', 'DoctrineExtensions\Query\Mysql\Hour'); |
|
| 108 | - $configuration->addCustomDatetimeFunction('DAY', 'DoctrineExtensions\Query\Mysql\Day'); |
|
| 109 | - $configuration->addCustomDatetimeFunction('WEEK', 'DoctrineExtensions\Query\Mysql\Week'); |
|
| 110 | - $configuration->addCustomDatetimeFunction('MONTH', 'DoctrineExtensions\Query\Mysql\Month'); |
|
| 111 | - $configuration->addCustomDatetimeFunction('YEAR', 'DoctrineExtensions\Query\Mysql\Year'); |
|
| 107 | + $configuration->addCustomDatetimeFunction('HOUR', 'DoctrineExtensions\Query\Mysql\Hour'); |
|
| 108 | + $configuration->addCustomDatetimeFunction('DAY', 'DoctrineExtensions\Query\Mysql\Day'); |
|
| 109 | + $configuration->addCustomDatetimeFunction('WEEK', 'DoctrineExtensions\Query\Mysql\Week'); |
|
| 110 | + $configuration->addCustomDatetimeFunction('MONTH', 'DoctrineExtensions\Query\Mysql\Month'); |
|
| 111 | + $configuration->addCustomDatetimeFunction('YEAR', 'DoctrineExtensions\Query\Mysql\Year'); |
|
| 112 | 112 | |
| 113 | - $configuration->addCustomDatetimeFunction('FIELD', 'DoctrineExtensions\Query\Mysql\Field'); |
|
| 113 | + $configuration->addCustomDatetimeFunction('FIELD', 'DoctrineExtensions\Query\Mysql\Field'); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | // Connect Repositories to the app |
| 133 | 133 | $app[$repositories_access] = $app->protect( |
| 134 | - function ($repository_name) use ($app, $db_config) { |
|
| 135 | - $class_name = "\\{$db_config['mappings'][0]['namespace']}\\". $repository_name; |
|
| 134 | + function($repository_name) use ($app, $db_config) { |
|
| 135 | + $class_name = "\\{$db_config['mappings'][0]['namespace']}\\".$repository_name; |
|
| 136 | 136 | if (class_exists($class_name)) { |
| 137 | 137 | return $app['orm.em']->getRepository($class_name); |
| 138 | 138 | } |
@@ -159,9 +159,9 @@ discard block |
||
| 159 | 159 | foreach ($app["orm.ems.options"] as $db_name => $db_config) { |
| 160 | 160 | $fct_name = $db_name === 'default' ? 'findOneOr404Factory' : "findOneOr404Factory_{$db_name}"; |
| 161 | 161 | $app[$fct_name] = $app->protect( |
| 162 | - function ($entity_name, $field_name = "") use ($app, $db_config) { |
|
| 163 | - return function ($field_value) use ($app, $db_config, $entity_name, $field_name) { |
|
| 164 | - $class_name = "\\{$db_config['mappings'][0]['namespace']}\\". $entity_name; |
|
| 162 | + function($entity_name, $field_name = "") use ($app, $db_config) { |
|
| 163 | + return function($field_value) use ($app, $db_config, $entity_name, $field_name) { |
|
| 164 | + $class_name = "\\{$db_config['mappings'][0]['namespace']}\\".$entity_name; |
|
| 165 | 165 | |
| 166 | 166 | if (!class_exists($class_name)) { |
| 167 | 167 | throw new NotFoundHttpException(sprintf('%s does not exist', $class_name)); |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | foreach ($dbs_options as $db_name) { |
| 24 | 24 | $database_env = getenv(strtoupper("{$db_name}_DATABASE_URL")); |
| 25 | 25 | if (false === $database_env) { |
| 26 | - throw new \Exception(strtoupper($db_name) . "_DATABASE_URL doesn't exist"); |
|
| 26 | + throw new \Exception(strtoupper($db_name)."_DATABASE_URL doesn't exist"); |
|
| 27 | 27 | |
| 28 | 28 | } |
| 29 | 29 | $this->dbs_options[$db_name] = [ |
@@ -29,10 +29,10 @@ discard block |
||
| 29 | 29 | $elasicsearch_host = getenv(strtoupper("{$db_name}_ELASTICSEARCH_HOST")); |
| 30 | 30 | $elasicsearch_type = getenv(strtoupper("{$db_name}_ELASTICSEARCH_TYPE")); |
| 31 | 31 | if (false === $elasicsearch_host) { |
| 32 | - throw new \Exception(strtoupper($db_name) . "_ELASTICSEARCH_HOST doesn't exist"); |
|
| 32 | + throw new \Exception(strtoupper($db_name)."_ELASTICSEARCH_HOST doesn't exist"); |
|
| 33 | 33 | } |
| 34 | 34 | if (false === $elasicsearch_type) { |
| 35 | - throw new \Exception(strtoupper($db_name) . "_ELASTICSEARCH_TYPE doesn't exist"); |
|
| 35 | + throw new \Exception(strtoupper($db_name)."_ELASTICSEARCH_TYPE doesn't exist"); |
|
| 36 | 36 | |
| 37 | 37 | } |
| 38 | 38 | $this->es_options[$db_name] = [ |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $parsed_url = parse_url($es_option['host']); |
| 63 | 63 | $index = ltrim($parsed_url['path'], '/'); |
| 64 | 64 | |
| 65 | - $app["elasticsearch.server"] = str_replace($parsed_url['path'], '', $es_option['host']) . "/"; |
|
| 65 | + $app["elasticsearch.server"] = str_replace($parsed_url['path'], '', $es_option['host'])."/"; |
|
| 66 | 66 | $app["elasticsearch.index"] = $index; |
| 67 | 67 | $app["elasticsearch.type"] = $es_option['type']; |
| 68 | 68 | break; |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | } catch (\Exception $exception) { |
| 97 | 97 | echo "Index {$app["elasticsearch.index"]} doesn't exist... \n"; |
| 98 | 98 | } |
| 99 | - $app["elasticsearch"]->put("/{$app["elasticsearch.index"]}-{$app["version"]}", [], file_get_contents($app["application_path"] . "/app/Utils/elasticsearch-settings.json"))->send(); |
|
| 100 | - $app["elasticsearch"]->put("/{$app["elasticsearch.index"]}-{$app["version"]}/{$app["elasticsearch.type"]}/_mapping", [], file_get_contents($app["application_path"] . "/app/Utils/elasticsearch-mapping.json"))->send(); |
|
| 99 | + $app["elasticsearch"]->put("/{$app["elasticsearch.index"]}-{$app["version"]}", [], file_get_contents($app["application_path"]."/app/Utils/elasticsearch-settings.json"))->send(); |
|
| 100 | + $app["elasticsearch"]->put("/{$app["elasticsearch.index"]}-{$app["version"]}/{$app["elasticsearch.type"]}/_mapping", [], file_get_contents($app["application_path"]."/app/Utils/elasticsearch-mapping.json"))->send(); |
|
| 101 | 101 | |
| 102 | 102 | // Rajout de l'alias |
| 103 | 103 | $aliases = json_encode( |
@@ -105,13 +105,13 @@ discard block |
||
| 105 | 105 | "actions" => [ |
| 106 | 106 | [ |
| 107 | 107 | "remove" => [ |
| 108 | - "index" => $app["elasticsearch.index"] . "-{$app["version"]}", |
|
| 108 | + "index" => $app["elasticsearch.index"]."-{$app["version"]}", |
|
| 109 | 109 | "alias" => $app["elasticsearch.index"] |
| 110 | 110 | ], |
| 111 | 111 | ], |
| 112 | 112 | [ |
| 113 | 113 | "add" => [ |
| 114 | - "index" => $app["elasticsearch.index"] . "-{$app["version"]}", |
|
| 114 | + "index" => $app["elasticsearch.index"]."-{$app["version"]}", |
|
| 115 | 115 | "alias" => $app["elasticsearch.index"] |
| 116 | 116 | ] |
| 117 | 117 | ] |
@@ -143,14 +143,14 @@ discard block |
||
| 143 | 143 | case false === isset($this->app): |
| 144 | 144 | case false === isset($this->app["elasticsearch.server"]): |
| 145 | 145 | case false === isset($this->app["elasticsearch.index"]): |
| 146 | - throw new \Exception(__METHOD__ . "::{$action}: Missing parameter"); |
|
| 146 | + throw new \Exception(__METHOD__."::{$action}: Missing parameter"); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $action = ("lock" === $action) ? "true" : "false"; |
| 150 | 150 | |
| 151 | - $server = $this->app["elasticsearch.server"] . $this->app["elasticsearch.index"]; |
|
| 151 | + $server = $this->app["elasticsearch.server"].$this->app["elasticsearch.index"]; |
|
| 152 | 152 | exec( |
| 153 | - "curl -XPUT '" . $server . "/_settings' -d ' |
|
| 153 | + "curl -XPUT '".$server."/_settings' -d ' |
|
| 154 | 154 | { |
| 155 | 155 | \"index\" : { |
| 156 | 156 | \"blocks.read_only\" : {$action} |