[cookienotice] Fix wrong type-hint in hook function cookienotice_page_content_top #1270

Merged
MrPetovan merged 1 commit from bug/fatal-errors into develop 2022-07-03 06:31:08 +02:00
MrPetovan commented 2022-07-03 06:27:40 +02:00 (Migrated from github.com)
- Address https://github.com/friendica/friendica/issues/11695#issuecomment-1173006420 Probably fixes https://github.com/friendica/friendica/issues/11695
Quix0r commented 2022-07-03 14:48:49 +02:00 (Migrated from github.com)

Mostly the $b name has confused me. Cannot we make a naming-convention here, e.g. if it is HTML code, use $body ($o for historical reasons but that doesn't need change), $data if it is an array? At least not $b everywhere.

Mostly the `$b` name has confused me. Cannot we make a naming-convention here, e.g. if it is HTML code, use `$body` (`$o` for historical reasons but that doesn't need change), `$data` if it is an array? At least not `$b` everywhere.
MrPetovan commented 2022-07-03 14:57:01 +02:00 (Migrated from github.com)

Sure, go ahead.

Sure, go ahead.
Quix0r commented 2022-07-03 15:15:52 +02:00 (Migrated from github.com)

Sure, go ahead.

I will do it more in a controlled fashion. :-)

> Sure, go ahead. I will do it more in a controlled fashion. :-)
nupplaphil commented 2022-07-03 16:37:54 +02:00 (Migrated from github.com)

Somewhere in the future (:D) I do want to rewrite the add-on classes at all .. to make them testable, like for the s3 storage classes .. and to avoid DB loadings and with type safe parameters depending on the hook calls not on the Hook class itself

Somewhere in the future (:D) I do want to rewrite the add-on classes at all .. to make them testable, like for the s3 storage classes .. and to avoid DB loadings and with type safe parameters depending on the hook calls not on the Hook class itself
MrPetovan commented 2022-07-03 17:13:39 +02:00 (Migrated from github.com)

How do you plan on doing the last part?

How do you plan on doing the last part?
nupplaphil commented 2022-07-03 19:45:11 +02:00 (Migrated from github.com)

Using the observer pattern and passing concrete, event specific, interfaces as parameters.

Observer = Addon-Functions
Subject = Hooks

And inside the Addon-constructor, I add the the functions as observers into the subjects. So no need of any DB call and I can customize observer and subjects as I like, because I will introduce a common interface for all addons :)

I must confess it's just inside my brain now, so I'm not sure about the pitfalls .. yet :D

Using the [observer pattern](https://sourcemaking.com/design_patterns/observer/php) and passing concrete, event specific, interfaces as parameters. Observer = Addon-Functions Subject = Hooks And inside the Addon-constructor, I add the the functions as observers into the subjects. So no need of any DB call and I can customize observer and subjects as I like, because I will introduce a common interface for all addons :) I must confess it's just inside my brain now, so I'm not sure about the pitfalls .. yet :D
MrPetovan commented 2022-07-04 01:24:39 +02:00 (Migrated from github.com)

We still need a DB call to figure out all the addons that need to be instantiated, right? And then they can subscribe to any hook they need. I'm looking forward a prototype implementation.

We still need a DB call to figure out all the addons that need to be instantiated, right? And then they can subscribe to any hook they need. I'm looking forward a prototype implementation.
Quix0r commented 2022-07-04 10:10:25 +02:00 (Migrated from github.com)

In my old mailer software I cached these hooks (I called them filters) to speed up the registration a little, so it doesn't have to go through all "hook" registrations but just read the database table and fill the "filter" array. Maybe @nupplaphil you can grab a few ideas: https://git.mxchange.org/?p=mailer.git;a=blob;f=inc/filter-functions.php;h=de21a6fd9c69a8fe4e1d0e050fe5ccc158ced7b0;hb=refs/heads/0.2.1-FINAL

In my old `mailer` software I cached these hooks (I called them filters) to speed up the registration a little, so it doesn't have to go through all "hook" registrations but just read the database table and fill the "filter" array. Maybe @nupplaphil you can grab a few ideas: https://git.mxchange.org/?p=mailer.git;a=blob;f=inc/filter-functions.php;h=de21a6fd9c69a8fe4e1d0e050fe5ccc158ced7b0;hb=refs/heads/0.2.1-FINAL
Sign in to join this conversation.
No description provided.