@@ -2,166 +2,166 @@ |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - /** |
|
| 6 | - * You can specify one of several different connections when building an |
|
| 7 | - * Elasticsearch client. |
|
| 8 | - * |
|
| 9 | - * Here you may specify which of the connections below you wish to use |
|
| 10 | - * as your default connection when building an client. Of course you may |
|
| 11 | - * use create several clients at once, each with different configurations. |
|
| 12 | - */ |
|
| 13 | - |
|
| 14 | - 'defaultConnection' => 'default', |
|
| 15 | - |
|
| 16 | - /** |
|
| 17 | - * These are the connection parameters used when building a client. |
|
| 18 | - */ |
|
| 19 | - |
|
| 20 | - 'connections' => [ |
|
| 21 | - |
|
| 22 | - 'default' => [ |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * Hosts |
|
| 26 | - * |
|
| 27 | - * This is an array of hosts that the client will connect to. It can be a |
|
| 28 | - * single host name, or an array if you are running a cluster of Elasticsearch |
|
| 29 | - * instances. |
|
| 30 | - * |
|
| 31 | - * This is the only configuration value that is mandatory. |
|
| 32 | - * |
|
| 33 | - * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_host_configuration |
|
| 34 | - */ |
|
| 35 | - |
|
| 36 | - 'hosts' => [ |
|
| 37 | - 'localhost:9200', |
|
| 38 | - ], |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * SSL |
|
| 42 | - * |
|
| 43 | - * If your Elasticsearch instance uses an out-dated or self-signed SSL |
|
| 44 | - * certificate, you will need to pass in the certificate bundle. This can |
|
| 45 | - * either be the path to the certificate file (for self-signed certs), or a |
|
| 46 | - * package like https://github.com/Kdyby/CurlCaBundle. See the documentation |
|
| 47 | - * below for all the details. |
|
| 48 | - * |
|
| 49 | - * If you are using SSL instances, and the certificates are up-to-date and |
|
| 50 | - * signed by a public certificate authority, then you can leave this null and |
|
| 51 | - * just use "https" in the host path(s) above and you should be fine. |
|
| 52 | - * |
|
| 53 | - * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_security.html#_ssl_encryption_2 |
|
| 54 | - */ |
|
| 55 | - |
|
| 56 | - 'sslVerification' => null, |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Logging |
|
| 60 | - * |
|
| 61 | - * Logging is handled by passing in an instance of Monolog\Logger (which |
|
| 62 | - * coincidentally is what Laravel's default logger is). |
|
| 63 | - * |
|
| 64 | - * If logging is enabled, you either need to set the path and log level |
|
| 65 | - * (some defaults are given for you below), or you can use a custom logger by |
|
| 66 | - * setting 'logObject' to an instance of Psr\Log\LoggerInterface. In fact, |
|
| 67 | - * if you just want to use the default Laravel logger, then set 'logObject' |
|
| 68 | - * to \Log::getMonolog(). |
|
| 69 | - * |
|
| 70 | - * Note: 'logObject' takes precedent over 'logPath'/'logLevel', so set |
|
| 71 | - * 'logObject' null if you just want file-based logging to a custom path. |
|
| 72 | - * |
|
| 73 | - * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#enabling_logger |
|
| 74 | - */ |
|
| 75 | - |
|
| 76 | - 'logging' => false, |
|
| 77 | - |
|
| 78 | - // If you have an existing instance of Monolog you can use it here. |
|
| 79 | - //'logObject' => \Log::getMonolog(), |
|
| 80 | - |
|
| 81 | - 'logPath' => storage_path('logs/elasticsearch.log'), |
|
| 82 | - |
|
| 83 | - 'logLevel' => Monolog\Logger::INFO, |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Retries |
|
| 87 | - * |
|
| 88 | - * By default, the client will retry n times, where n = number of nodes in |
|
| 89 | - * your cluster. If you would like to disable retries, or change the number, |
|
| 90 | - * you can do so here. |
|
| 91 | - * |
|
| 92 | - * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_set_retries |
|
| 93 | - */ |
|
| 94 | - |
|
| 95 | - 'retries' => null, |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * The remainder of the configuration options can almost always be left |
|
| 99 | - * as-is unless you have specific reasons to change them. Refer to the |
|
| 100 | - * appropriate sections in the Elasticsearch documentation for what each option |
|
| 101 | - * does and what values it expects. |
|
| 102 | - */ |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * Sniff On Start |
|
| 106 | - * |
|
| 107 | - * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html |
|
| 108 | - */ |
|
| 109 | - |
|
| 110 | - 'sniffOnStart' => false, |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * HTTP Handler |
|
| 114 | - * |
|
| 115 | - * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_configure_the_http_handler |
|
| 116 | - * @see http://ringphp.readthedocs.org/en/latest/client_handlers.html |
|
| 117 | - */ |
|
| 118 | - |
|
| 119 | - 'httpHandler' => null, |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * Connection Pool |
|
| 123 | - * |
|
| 124 | - * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_setting_the_connection_pool |
|
| 125 | - * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_connection_pool.html |
|
| 126 | - */ |
|
| 127 | - |
|
| 128 | - 'connectionPool' => null, |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * Connection Selector |
|
| 132 | - * |
|
| 133 | - * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_setting_the_connection_selector |
|
| 134 | - * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_selectors.html |
|
| 135 | - */ |
|
| 136 | - |
|
| 137 | - 'connectionSelector' => null, |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * Serializer |
|
| 141 | - * |
|
| 142 | - * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_setting_the_serializer |
|
| 143 | - * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_serializers.html |
|
| 144 | - */ |
|
| 145 | - |
|
| 146 | - 'serializer' => null, |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * Connection Factory |
|
| 150 | - * |
|
| 151 | - * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_setting_a_custom_connectionfactory |
|
| 152 | - */ |
|
| 153 | - |
|
| 154 | - 'connectionFactory' => null, |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * Endpoint |
|
| 158 | - * |
|
| 159 | - * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_set_the_endpoint_closure |
|
| 160 | - */ |
|
| 161 | - |
|
| 162 | - 'endpoint' => null, |
|
| 163 | - |
|
| 164 | - ], |
|
| 165 | - ], |
|
| 5 | + /** |
|
| 6 | + * You can specify one of several different connections when building an |
|
| 7 | + * Elasticsearch client. |
|
| 8 | + * |
|
| 9 | + * Here you may specify which of the connections below you wish to use |
|
| 10 | + * as your default connection when building an client. Of course you may |
|
| 11 | + * use create several clients at once, each with different configurations. |
|
| 12 | + */ |
|
| 13 | + |
|
| 14 | + 'defaultConnection' => 'default', |
|
| 15 | + |
|
| 16 | + /** |
|
| 17 | + * These are the connection parameters used when building a client. |
|
| 18 | + */ |
|
| 19 | + |
|
| 20 | + 'connections' => [ |
|
| 21 | + |
|
| 22 | + 'default' => [ |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * Hosts |
|
| 26 | + * |
|
| 27 | + * This is an array of hosts that the client will connect to. It can be a |
|
| 28 | + * single host name, or an array if you are running a cluster of Elasticsearch |
|
| 29 | + * instances. |
|
| 30 | + * |
|
| 31 | + * This is the only configuration value that is mandatory. |
|
| 32 | + * |
|
| 33 | + * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_host_configuration |
|
| 34 | + */ |
|
| 35 | + |
|
| 36 | + 'hosts' => [ |
|
| 37 | + 'localhost:9200', |
|
| 38 | + ], |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * SSL |
|
| 42 | + * |
|
| 43 | + * If your Elasticsearch instance uses an out-dated or self-signed SSL |
|
| 44 | + * certificate, you will need to pass in the certificate bundle. This can |
|
| 45 | + * either be the path to the certificate file (for self-signed certs), or a |
|
| 46 | + * package like https://github.com/Kdyby/CurlCaBundle. See the documentation |
|
| 47 | + * below for all the details. |
|
| 48 | + * |
|
| 49 | + * If you are using SSL instances, and the certificates are up-to-date and |
|
| 50 | + * signed by a public certificate authority, then you can leave this null and |
|
| 51 | + * just use "https" in the host path(s) above and you should be fine. |
|
| 52 | + * |
|
| 53 | + * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_security.html#_ssl_encryption_2 |
|
| 54 | + */ |
|
| 55 | + |
|
| 56 | + 'sslVerification' => null, |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Logging |
|
| 60 | + * |
|
| 61 | + * Logging is handled by passing in an instance of Monolog\Logger (which |
|
| 62 | + * coincidentally is what Laravel's default logger is). |
|
| 63 | + * |
|
| 64 | + * If logging is enabled, you either need to set the path and log level |
|
| 65 | + * (some defaults are given for you below), or you can use a custom logger by |
|
| 66 | + * setting 'logObject' to an instance of Psr\Log\LoggerInterface. In fact, |
|
| 67 | + * if you just want to use the default Laravel logger, then set 'logObject' |
|
| 68 | + * to \Log::getMonolog(). |
|
| 69 | + * |
|
| 70 | + * Note: 'logObject' takes precedent over 'logPath'/'logLevel', so set |
|
| 71 | + * 'logObject' null if you just want file-based logging to a custom path. |
|
| 72 | + * |
|
| 73 | + * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#enabling_logger |
|
| 74 | + */ |
|
| 75 | + |
|
| 76 | + 'logging' => false, |
|
| 77 | + |
|
| 78 | + // If you have an existing instance of Monolog you can use it here. |
|
| 79 | + //'logObject' => \Log::getMonolog(), |
|
| 80 | + |
|
| 81 | + 'logPath' => storage_path('logs/elasticsearch.log'), |
|
| 82 | + |
|
| 83 | + 'logLevel' => Monolog\Logger::INFO, |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Retries |
|
| 87 | + * |
|
| 88 | + * By default, the client will retry n times, where n = number of nodes in |
|
| 89 | + * your cluster. If you would like to disable retries, or change the number, |
|
| 90 | + * you can do so here. |
|
| 91 | + * |
|
| 92 | + * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_set_retries |
|
| 93 | + */ |
|
| 94 | + |
|
| 95 | + 'retries' => null, |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * The remainder of the configuration options can almost always be left |
|
| 99 | + * as-is unless you have specific reasons to change them. Refer to the |
|
| 100 | + * appropriate sections in the Elasticsearch documentation for what each option |
|
| 101 | + * does and what values it expects. |
|
| 102 | + */ |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * Sniff On Start |
|
| 106 | + * |
|
| 107 | + * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html |
|
| 108 | + */ |
|
| 109 | + |
|
| 110 | + 'sniffOnStart' => false, |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * HTTP Handler |
|
| 114 | + * |
|
| 115 | + * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_configure_the_http_handler |
|
| 116 | + * @see http://ringphp.readthedocs.org/en/latest/client_handlers.html |
|
| 117 | + */ |
|
| 118 | + |
|
| 119 | + 'httpHandler' => null, |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * Connection Pool |
|
| 123 | + * |
|
| 124 | + * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_setting_the_connection_pool |
|
| 125 | + * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_connection_pool.html |
|
| 126 | + */ |
|
| 127 | + |
|
| 128 | + 'connectionPool' => null, |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * Connection Selector |
|
| 132 | + * |
|
| 133 | + * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_setting_the_connection_selector |
|
| 134 | + * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_selectors.html |
|
| 135 | + */ |
|
| 136 | + |
|
| 137 | + 'connectionSelector' => null, |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * Serializer |
|
| 141 | + * |
|
| 142 | + * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_setting_the_serializer |
|
| 143 | + * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_serializers.html |
|
| 144 | + */ |
|
| 145 | + |
|
| 146 | + 'serializer' => null, |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * Connection Factory |
|
| 150 | + * |
|
| 151 | + * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_setting_a_custom_connectionfactory |
|
| 152 | + */ |
|
| 153 | + |
|
| 154 | + 'connectionFactory' => null, |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * Endpoint |
|
| 158 | + * |
|
| 159 | + * @see https://www.elastic.co/guide/en/elasticsearch/client/php-api/2.0/_configuration.html#_set_the_endpoint_closure |
|
| 160 | + */ |
|
| 161 | + |
|
| 162 | + 'endpoint' => null, |
|
| 163 | + |
|
| 164 | + ], |
|
| 165 | + ], |
|
| 166 | 166 | |
| 167 | 167 | ]; |
@@ -9,77 +9,77 @@ |
||
| 9 | 9 | class Factory |
| 10 | 10 | { |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * Map configuration array keys with ES ClientBuilder setters |
|
| 14 | - * |
|
| 15 | - * @var array |
|
| 16 | - */ |
|
| 17 | - protected $configMappings = [ |
|
| 18 | - 'sslVerification' => 'setSSLVerification', |
|
| 19 | - 'sniffOnStart' => 'setSniffOnStart', |
|
| 20 | - 'retries' => 'setRetries', |
|
| 21 | - 'httpHandler' => 'setHandler', |
|
| 22 | - 'connectionPool' => 'setConnectionPool', |
|
| 23 | - 'connectionSelector' => 'setSelector', |
|
| 24 | - 'serializer' => 'setSerializer', |
|
| 25 | - 'connectionFactory' => 'setConnectionFactory', |
|
| 26 | - 'endpoint' => 'setEndpoint', |
|
| 27 | - ]; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Make the Elasticsearch client for the given named configuration, or |
|
| 31 | - * the default client. |
|
| 32 | - * |
|
| 33 | - * @param array $config |
|
| 34 | - * @return \Elasticsearch\Client|mixed |
|
| 35 | - */ |
|
| 36 | - public function make(array $config) |
|
| 37 | - { |
|
| 38 | - |
|
| 39 | - // Build the client |
|
| 40 | - return $this->buildClient($config); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Build and configure an Elasticsearch client. |
|
| 45 | - * |
|
| 46 | - * @param array $config |
|
| 47 | - * @return \Elasticsearch\Client |
|
| 48 | - */ |
|
| 49 | - protected function buildClient(array $config) |
|
| 50 | - { |
|
| 51 | - |
|
| 52 | - $clientBuilder = ClientBuilder::create(); |
|
| 53 | - |
|
| 54 | - // Configure hosts |
|
| 55 | - |
|
| 56 | - $clientBuilder->setHosts($config['hosts']); |
|
| 57 | - |
|
| 58 | - // Configure logging |
|
| 59 | - |
|
| 60 | - if (array_get($config, 'logging')) { |
|
| 61 | - $logObject = array_get($config, 'logObject'); |
|
| 62 | - $logPath = array_get($config, 'logPath'); |
|
| 63 | - $logLevel = array_get($config, 'logLevel'); |
|
| 64 | - if ($logObject && $logObject instanceof LoggerInterface) { |
|
| 65 | - $clientBuilder->setLogger($logObject); |
|
| 66 | - } else if ($logPath && $logLevel) { |
|
| 67 | - $logObject = ClientBuilder::defaultLogger($logPath, $logLevel); |
|
| 68 | - $clientBuilder->setLogger($logObject); |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - // Set additional client configuration |
|
| 73 | - |
|
| 74 | - foreach ($this->configMappings as $key => $method) { |
|
| 75 | - $value = array_get($config, $key); |
|
| 76 | - if ($value !== null) { |
|
| 77 | - call_user_func([$clientBuilder, $method], $value); |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - // Build and return the client |
|
| 82 | - |
|
| 83 | - return $clientBuilder->build(); |
|
| 84 | - } |
|
| 12 | + /** |
|
| 13 | + * Map configuration array keys with ES ClientBuilder setters |
|
| 14 | + * |
|
| 15 | + * @var array |
|
| 16 | + */ |
|
| 17 | + protected $configMappings = [ |
|
| 18 | + 'sslVerification' => 'setSSLVerification', |
|
| 19 | + 'sniffOnStart' => 'setSniffOnStart', |
|
| 20 | + 'retries' => 'setRetries', |
|
| 21 | + 'httpHandler' => 'setHandler', |
|
| 22 | + 'connectionPool' => 'setConnectionPool', |
|
| 23 | + 'connectionSelector' => 'setSelector', |
|
| 24 | + 'serializer' => 'setSerializer', |
|
| 25 | + 'connectionFactory' => 'setConnectionFactory', |
|
| 26 | + 'endpoint' => 'setEndpoint', |
|
| 27 | + ]; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Make the Elasticsearch client for the given named configuration, or |
|
| 31 | + * the default client. |
|
| 32 | + * |
|
| 33 | + * @param array $config |
|
| 34 | + * @return \Elasticsearch\Client|mixed |
|
| 35 | + */ |
|
| 36 | + public function make(array $config) |
|
| 37 | + { |
|
| 38 | + |
|
| 39 | + // Build the client |
|
| 40 | + return $this->buildClient($config); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Build and configure an Elasticsearch client. |
|
| 45 | + * |
|
| 46 | + * @param array $config |
|
| 47 | + * @return \Elasticsearch\Client |
|
| 48 | + */ |
|
| 49 | + protected function buildClient(array $config) |
|
| 50 | + { |
|
| 51 | + |
|
| 52 | + $clientBuilder = ClientBuilder::create(); |
|
| 53 | + |
|
| 54 | + // Configure hosts |
|
| 55 | + |
|
| 56 | + $clientBuilder->setHosts($config['hosts']); |
|
| 57 | + |
|
| 58 | + // Configure logging |
|
| 59 | + |
|
| 60 | + if (array_get($config, 'logging')) { |
|
| 61 | + $logObject = array_get($config, 'logObject'); |
|
| 62 | + $logPath = array_get($config, 'logPath'); |
|
| 63 | + $logLevel = array_get($config, 'logLevel'); |
|
| 64 | + if ($logObject && $logObject instanceof LoggerInterface) { |
|
| 65 | + $clientBuilder->setLogger($logObject); |
|
| 66 | + } else if ($logPath && $logLevel) { |
|
| 67 | + $logObject = ClientBuilder::defaultLogger($logPath, $logLevel); |
|
| 68 | + $clientBuilder->setLogger($logObject); |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + // Set additional client configuration |
|
| 73 | + |
|
| 74 | + foreach ($this->configMappings as $key => $method) { |
|
| 75 | + $value = array_get($config, $key); |
|
| 76 | + if ($value !== null) { |
|
| 77 | + call_user_func([$clientBuilder, $method], $value); |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + // Build and return the client |
|
| 82 | + |
|
| 83 | + return $clientBuilder->build(); |
|
| 84 | + } |
|
| 85 | 85 | } |
@@ -14,45 +14,45 @@ |
||
| 14 | 14 | class ServiceProvider extends BaseServiceProvider |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Indicates if loading of the provider is deferred. |
|
| 19 | - * |
|
| 20 | - * @var bool |
|
| 21 | - */ |
|
| 22 | - protected $defer = false; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * Bootstrap the application events. |
|
| 26 | - * |
|
| 27 | - * @return void |
|
| 28 | - */ |
|
| 29 | - public function boot() |
|
| 30 | - { |
|
| 31 | - $configPath = realpath(__DIR__ . '/../config/elasticsearch.php'); |
|
| 32 | - $this->publishes([ |
|
| 33 | - $configPath => config_path('elasticsearch.php'), |
|
| 34 | - ]); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * Register the service provider. |
|
| 39 | - * |
|
| 40 | - * @return void |
|
| 41 | - */ |
|
| 42 | - public function register() |
|
| 43 | - { |
|
| 44 | - $app = $this->app; |
|
| 45 | - |
|
| 46 | - $app->singleton('elasticsearch.factory', function($app) { |
|
| 47 | - return new Factory(); |
|
| 48 | - }); |
|
| 49 | - |
|
| 50 | - $app->singleton('elasticsearch', function($app) { |
|
| 51 | - return new Manager($app, $app['elasticsearch.factory']); |
|
| 52 | - }); |
|
| 53 | - |
|
| 54 | - $app->singleton(Client::class, function($app) { |
|
| 55 | - return $app['elasticsearch']->connection(); |
|
| 56 | - }); |
|
| 57 | - } |
|
| 17 | + /** |
|
| 18 | + * Indicates if loading of the provider is deferred. |
|
| 19 | + * |
|
| 20 | + * @var bool |
|
| 21 | + */ |
|
| 22 | + protected $defer = false; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * Bootstrap the application events. |
|
| 26 | + * |
|
| 27 | + * @return void |
|
| 28 | + */ |
|
| 29 | + public function boot() |
|
| 30 | + { |
|
| 31 | + $configPath = realpath(__DIR__ . '/../config/elasticsearch.php'); |
|
| 32 | + $this->publishes([ |
|
| 33 | + $configPath => config_path('elasticsearch.php'), |
|
| 34 | + ]); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * Register the service provider. |
|
| 39 | + * |
|
| 40 | + * @return void |
|
| 41 | + */ |
|
| 42 | + public function register() |
|
| 43 | + { |
|
| 44 | + $app = $this->app; |
|
| 45 | + |
|
| 46 | + $app->singleton('elasticsearch.factory', function($app) { |
|
| 47 | + return new Factory(); |
|
| 48 | + }); |
|
| 49 | + |
|
| 50 | + $app->singleton('elasticsearch', function($app) { |
|
| 51 | + return new Manager($app, $app['elasticsearch.factory']); |
|
| 52 | + }); |
|
| 53 | + |
|
| 54 | + $app->singleton(Client::class, function($app) { |
|
| 55 | + return $app['elasticsearch']->connection(); |
|
| 56 | + }); |
|
| 57 | + } |
|
| 58 | 58 | } |
@@ -13,28 +13,28 @@ |
||
| 13 | 13 | class LumenServiceProvider extends BaseServiceProvider |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Indicates if loading of the provider is deferred. |
|
| 18 | - * |
|
| 19 | - * @var bool |
|
| 20 | - */ |
|
| 21 | - protected $defer = false; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * Register the service provider. |
|
| 25 | - * |
|
| 26 | - * @return void |
|
| 27 | - */ |
|
| 28 | - public function register() |
|
| 29 | - { |
|
| 30 | - $app = $this->app; |
|
| 31 | - |
|
| 32 | - $app->singleton('elasticsearch.factory', function($app) { |
|
| 33 | - return new Factory(); |
|
| 34 | - }); |
|
| 35 | - |
|
| 36 | - $app->singleton('elasticsearch', function($app) { |
|
| 37 | - return new LumenManager($app, $app['elasticsearch.factory']); |
|
| 38 | - }); |
|
| 39 | - } |
|
| 16 | + /** |
|
| 17 | + * Indicates if loading of the provider is deferred. |
|
| 18 | + * |
|
| 19 | + * @var bool |
|
| 20 | + */ |
|
| 21 | + protected $defer = false; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * Register the service provider. |
|
| 25 | + * |
|
| 26 | + * @return void |
|
| 27 | + */ |
|
| 28 | + public function register() |
|
| 29 | + { |
|
| 30 | + $app = $this->app; |
|
| 31 | + |
|
| 32 | + $app->singleton('elasticsearch.factory', function($app) { |
|
| 33 | + return new Factory(); |
|
| 34 | + }); |
|
| 35 | + |
|
| 36 | + $app->singleton('elasticsearch', function($app) { |
|
| 37 | + return new LumenManager($app, $app['elasticsearch.factory']); |
|
| 38 | + }); |
|
| 39 | + } |
|
| 40 | 40 | } |