Skip to content

Commit

Permalink
Improvements and bug fixes
Browse files Browse the repository at this point in the history
Recursive placeholders, automatic completion of multiline values with trailing slash, and custom parameters
  • Loading branch information
ergnuor committed Apr 9, 2020
1 parent 179998b commit 6c0d312
Show file tree
Hide file tree
Showing 13 changed files with 511 additions and 143 deletions.
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,17 @@ return [
'sql_query_pre' => [
'SET NAMES utf8',
// ... other pre queries
'sph_counter' => 'INSERT INTO sphCounter (indexingStartedAt, caption) \
VALUES(NOW(), \'main\') \
'sph_counter' => 'INSERT INTO sphCounter (indexingStartedAt, caption)
VALUES(NOW(), \'main\')
ON DUPLICATE KEY UPDATE indexingStartedAt = now()'
],
// ... other block settings
],
'delta' => [
'extends' => 'main',
'sql_query_pre' => [
'sph_counter' => 'INSERT INTO sphCounter (indexingStartedAt, caption) \
VALUES(NOW(), \'delta\') \
'sph_counter' => 'INSERT INTO sphCounter (indexingStartedAt, caption)
VALUES(NOW(), \'delta\')
ON DUPLICATE KEY UPDATE indexingStartedAt = now()'
],
// ... other block settings
Expand Down Expand Up @@ -194,7 +194,7 @@ The example of usage is storing database connection settings in `/path/to/config

Note that in internal representation `indexer`, `searchd` and `common` sections are converted into sections containing self-titled blocks. This allows them to be used in the same way as `source` and `index` sections. So, as in the last example, you can store common settings for `indexer`, `searchd` and `common` sections in separate blocks and inherit from them.
## Placeholders
Each value of Sphinx parameter may contain a placeholder in `::path.to.value:`: format. Placeholder uses dot notation, so it is possible to extract values from multidimensional arrays.
Each value of Sphinx parameter may contain a placeholder in `::path.to.value:`: format. Placeholder uses dot notation, so it is possible to extract values from multidimensional arrays. The replacement values themselves can contain placeholders. So placeholders are dereferenced recursively.

There are two ways of passing values:
- You can pass global values for entire configuration using `setPlaceholderValues()` method.
Expand All @@ -208,8 +208,8 @@ return [
'sql_query_pre' => [
'SET NAMES utf8',
// ... other queries
'INSERT INTO sphCounter (indexingStartedAt, caption) \
VALUES(NOW(), \'::sourceName::\') \
'INSERT INTO sphCounter (indexingStartedAt, caption)
VALUES(NOW(), \'::sourceName::\')
ON DUPLICATE KEY UPDATE indexingStartedAt = now()'
],
'placeholderValues' => [
Expand Down Expand Up @@ -248,6 +248,12 @@ source delta : main {
// ... other block settings
}
```
## Parameter values
Multiline values are automatically padded with a trailing slash. This is useful when formatting queries.

## Custom parameters
Parameter will be ignored if its name starts with an underscore. This allows you to add parameters for internal use, for example, if the configuration is being pre-processed and you want to be able to configure this process.

## Method list
- **```setSrcPath($srcPath)```**
Sets the directory containing source configurations,
Expand Down
Loading

0 comments on commit 6c0d312

Please sign in to comment.