mpratt / Embera

A Oembed consumer library, that gives you information about urls. It helps you replace urls to youtube or vimeo for example, with their html embed code. It has advanced features like offline support, responsive embeds and caching support.
MIT License
335 stars 59 forks source link

fix: use current `__NAMESPACE__` instead of hardcoded string #92

Closed matzeeable closed 2 years ago

matzeeable commented 2 years ago
Q A
Bug fix? yes
New feature? no
BC breaks? no
Need Doc update no

Describe your change

Use the __NAMESPACE__ identifier to get the full qualified name for a class instead of a string.

What problem is this fixing?

I want to bundle this package within my WordPress plugin together with PHP-Scoper, unfortunately it does not scope a hardcoded namespace string.

PHP-Scoper is a tool which essentially moves any body of code, including all dependencies such as vendor directories, to a new and distinct namespace.

WIthout this changes, I get the following error:

PHP Fatal error:  Uncaught Error: Class 'Embera\\Provider\\TwentyThreeHq' not found in X/vendor/mpratt/embera/src/Embera/ProviderCollection/ProviderCollectionAdapter.php:89
mpratt commented 2 years ago

Thanks @matzeeable I merged your PR but made a minor change. I changed the method from static to a regular protected method, since its more in line with the style of the library.

Thanks for the PR and suggestion! Please let me know what cool wordpress plugin you made with help of Embera!

matzeeable commented 2 years ago

Hey @mpratt !

Thanks for the merge. When do you plan to release the changes? :-)

Please let me know what cool wordpress plugin you made with help of Embera!

We are creating a new feature in WordPress Real Cookie Banner to create a GDPR compliance preview of e.g. YouTube videos. When the user clicks on the preview, it will be loaded instead.

mpratt commented 2 years ago

@matzeeable Oh! Forgot to tag! New version should be available with the changes. Es tut mir Leid, dass ich es vergessen habe! Ich hoffe alles funktioniert jetzt! Cool Projekt! Danke für den PR!