Skip to content

Conversation

@ArtificialOwl
Copy link
Member

@ArtificialOwl ArtificialOwl commented Jun 20, 2025

adding events when working on config keys

  • add onSet() which is executed when a new value is set for this config key. Can be used to modify the new value before being stored into database, or to cancel the process if the new value is considered invalid (by returning false):
(new ConfigLexiconEntry('email', ValueType::STRING, '', 'email'))->onSet(
				function (string &$value): void {
					$value = strtolower($value);
				}
			),
(new ConfigLexiconEntry('email', ValueType::STRING, '', 'email'))->onSet(
				function (string &$value): bool {
					return ((int)$value > 100);
				}
			),
  • add initialize() which is executed when reading a config key that has no known value. Can be used to fill the value at first read, unless the closure returns false
not in this PR anymore ``` (new ConfigLexiconEntry('email', ValueType::STRING, '', 'email'))->initialize( function (string &$value): void { $value = $this->secureRandom->generate(5, 'abcdefghijklmnopqrstuvwxyz0123456789'); } ), ```

initialize() has been removed, will be prep in a separated PR and forgotten until it needs to be added in the future!

@ArtificialOwl ArtificialOwl force-pushed the feat/noid/lexicon-events branch 2 times, most recently from 02593d5 to 106ba14 Compare June 20, 2025 16:17
@ArtificialOwl ArtificialOwl force-pushed the feat/noid/lexicon-migrate-keys branch from 1b42dad to d860cfd Compare June 24, 2025 13:10
Base automatically changed from feat/noid/lexicon-migrate-keys to master June 24, 2025 13:54
@ArtificialOwl ArtificialOwl force-pushed the feat/noid/lexicon-events branch 3 times, most recently from 2630b8f to 24c55f4 Compare June 25, 2025 16:09
@ArtificialOwl ArtificialOwl added the 3. to review Waiting for reviews label Jun 25, 2025
@ArtificialOwl ArtificialOwl added this to the Nextcloud 32 milestone Jun 25, 2025
@ArtificialOwl ArtificialOwl force-pushed the feat/noid/lexicon-events branch 2 times, most recently from 240bc41 to ba11c71 Compare June 25, 2025 17:49
@ArtificialOwl ArtificialOwl marked this pull request as ready for review June 26, 2025 00:12
@ArtificialOwl ArtificialOwl requested a review from a team as a code owner June 26, 2025 00:12
@ArtificialOwl ArtificialOwl requested review from come-nc, leftybournes and yemkareems and removed request for a team June 26, 2025 00:12
@come-nc
Copy link
Contributor

come-nc commented Jun 26, 2025

I’m a bit reluctant because this looks like a 4th event system 😒

But it’s not really events I suppose, it’s more validators and setters… unsure.

@ArtificialOwl
Copy link
Member Author

I’m a bit reluctant because this looks like a 4th event system 😒

But it’s not really events I suppose, it’s more validators and setters… unsure.

still better than having a particular condition within the general/official setter

@ArtificialOwl ArtificialOwl force-pushed the feat/noid/lexicon-events branch from ba11c71 to fb1085d Compare June 30, 2025 10:57
@ArtificialOwl
Copy link
Member Author

  • removed initialized()

@skjnldsv skjnldsv modified the milestones: Nextcloud 32, Nextcloud 33 Sep 28, 2025
@susnux susnux deleted the feat/noid/lexicon-events branch November 1, 2025 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants