Version Description
Download this release
Release Info
Developer | aytac |
Plugin | ![]() |
Version | 3.10.0 |
Comparing to | |
See all releases |
Code changes from version 3.9.0 to 3.10.0
- addons/addons.json +7 -0
- addons/composer.json +37 -2
- addons/composer.lock +987 -11
- addons/config/settings-config.php +10 -10
- addons/controller/addons/add-to-any/add-to-any.php +47 -1
- addons/controller/addons/custom-facebook-feed-old/custom-facebook-feed-old.php +347 -0
- addons/controller/addons/custom-facebook-feed/custom-facebook-feed.php +33 -296
- addons/controller/addons/embed-autocorrect/embed-autocorrect.php +12 -11
- addons/controller/addons/enfold/enfold.php +326 -0
- addons/controller/addons/enhanced-ecommerce-for-woocommerce-store/enhanced-ecommerce-for-woocommerce-store.php +1 -1
- addons/controller/addons/gadwp/gadwp.php +19 -10
- addons/controller/addons/google-analytics-plus/google-analytics-plus.php +1 -1
- addons/controller/addons/google-analytics/google-analytics.php +1 -1
- addons/controller/addons/google-site-kit/google-site-kit.php +1 -1
- addons/controller/addons/jetpack/visitor-cookies.php +2 -2
- addons/controller/addons/jetpack/widget/facebook-widget.php +2 -2
- addons/controller/addons/jetpack/widget/goodreads-widget.php +1 -1
- addons/controller/addons/jetpack/widget/google-maps-widget.php +1 -1
- addons/controller/addons/jetpack/widget/googleplus-badge-widget.php +1 -1
- addons/controller/addons/jetpack/widget/internet-defense-league-widget.php +1 -1
- addons/controller/addons/jetpack/widget/twitter-timeline-widget.php +1 -1
- addons/controller/addons/litespeed-cache/litespeed-cache.php +1 -1
- addons/controller/addons/official-facebook-pixel/official-facebook-pixel.php +3 -1
- addons/controller/addons/optinmonster/optinmonster.php +1 -1
- addons/controller/addons/pixel-caffeine/pixel-caffeine.php +1 -1
- addons/controller/addons/simple-share-buttons-adder/simple-share-buttons-adder.php +1 -1
- addons/controller/addons/wp-rocket/wp-rocket.php +1 -1
- addons/controller/addons/wpforms/wpforms.php +2 -2
- addons/controller/plugin-controller.php +5 -5
- addons/cookiebot-addons-init.php +12 -7
- addons/inc/Dependencies/DI/Annotation/Inject.php +95 -0
- addons/inc/Dependencies/DI/Annotation/Injectable.php +74 -0
- addons/inc/Dependencies/DI/Container.php +340 -0
- addons/inc/Dependencies/DI/ContainerBuilder.php +258 -0
- addons/inc/Dependencies/DI/Debug.php +39 -0
- addons/inc/Dependencies/DI/Definition/AbstractFunctionCallDefinition.php +82 -0
- addons/inc/Dependencies/DI/Definition/AliasDefinition.php +66 -0
- addons/inc/Dependencies/DI/Definition/ArrayDefinition.php +66 -0
- addons/inc/Dependencies/DI/Definition/ArrayDefinitionExtension.php +61 -0
- addons/inc/Dependencies/DI/Definition/CacheableDefinition.php +19 -0
- addons/inc/Dependencies/DI/Definition/DecoratorDefinition.php +48 -0
- addons/inc/Dependencies/DI/Definition/Definition.php +32 -0
- addons/inc/Dependencies/DI/Definition/Dumper/AliasDefinitionDumper.php +48 -0
- addons/inc/Dependencies/DI/Definition/Dumper/ArrayDefinitionDumper.php +65 -0
- addons/inc/Dependencies/DI/Definition/Dumper/DecoratorDefinitionDumper.php +37 -0
- addons/inc/Dependencies/DI/Definition/Dumper/DefinitionDumper.php +30 -0
- addons/inc/Dependencies/DI/Definition/Dumper/DefinitionDumperDispatcher.php +68 -0
- addons/inc/Dependencies/DI/Definition/Dumper/EnvironmentVariableDefinitionDumper.php +63 -0
- addons/inc/Dependencies/DI/Definition/Dumper/FactoryDefinitionDumper.php +37 -0
- addons/inc/Dependencies/DI/Definition/Dumper/ObjectDefinitionDumper.php +156 -0
- addons/inc/Dependencies/DI/Definition/Dumper/StringDefinitionDumper.php +37 -0
- addons/inc/Dependencies/DI/Definition/Dumper/ValueDefinitionDumper.php +44 -0
- addons/inc/Dependencies/DI/Definition/EntryReference.php +52 -0
- addons/inc/Dependencies/DI/Definition/EnvironmentVariableDefinition.php +116 -0
- addons/inc/Dependencies/DI/Definition/Exception/AnnotationException.php +19 -0
- addons/inc/Dependencies/DI/Definition/Exception/DefinitionException.php +30 -0
- addons/inc/Dependencies/DI/Definition/FactoryDefinition.php +75 -0
- addons/inc/Dependencies/DI/Definition/HasSubDefinition.php +28 -0
- addons/inc/Dependencies/DI/Definition/Helper/ArrayDefinitionExtensionHelper.php +46 -0
- addons/inc/Dependencies/DI/Definition/Helper/DefinitionHelper.php +24 -0
- addons/inc/Dependencies/DI/Definition/Helper/EnvironmentVariableDefinitionHelper.php +64 -0
- addons/inc/Dependencies/DI/Definition/Helper/FactoryDefinitionHelper.php +72 -0
- addons/inc/Dependencies/DI/Definition/Helper/ObjectDefinitionHelper.php +273 -0
- addons/inc/Dependencies/DI/Definition/Helper/StringDefinitionHelper.php +39 -0
- addons/inc/Dependencies/DI/Definition/Helper/ValueDefinitionHelper.php +42 -0
- addons/inc/Dependencies/DI/Definition/InstanceDefinition.php +76 -0
- addons/inc/Dependencies/DI/Definition/ObjectDefinition.php +294 -0
- addons/inc/Dependencies/DI/Definition/ObjectDefinition/MethodInjection.php +54 -0
- addons/inc/Dependencies/DI/Definition/ObjectDefinition/PropertyInjection.php +56 -0
- addons/inc/Dependencies/DI/Definition/Resolver/AliasResolver.php +77 -0
- addons/inc/Dependencies/DI/Definition/Resolver/ArrayResolver.php +105 -0
- addons/inc/Dependencies/DI/Definition/Resolver/DecoratorResolver.php +107 -0
- addons/inc/Dependencies/DI/Definition/Resolver/DefinitionResolver.php +44 -0
- addons/inc/Dependencies/DI/Definition/Resolver/EnvironmentVariableResolver.php +94 -0
- addons/inc/Dependencies/DI/Definition/Resolver/FactoryResolver.php +85 -0
- addons/inc/Dependencies/DI/Definition/Resolver/InstanceInjector.php +67 -0
- addons/inc/Dependencies/DI/Definition/Resolver/ObjectCreator.php +266 -0
- addons/inc/Dependencies/DI/Definition/Resolver/ParameterResolver.php +138 -0
- addons/inc/Dependencies/DI/Definition/Resolver/ResolverDispatcher.php +141 -0
- addons/inc/Dependencies/DI/Definition/Resolver/StringResolver.php +95 -0
- addons/inc/Dependencies/DI/Definition/Resolver/ValueResolver.php +58 -0
- addons/inc/Dependencies/DI/Definition/Source/AnnotationReader.php +298 -0
- addons/inc/Dependencies/DI/Definition/Source/Autowiring.php +68 -0
- addons/inc/Dependencies/DI/Definition/Source/CachedDefinitionSource.php +104 -0
- addons/inc/Dependencies/DI/Definition/Source/DefinitionArray.php +142 -0
- addons/inc/Dependencies/DI/Definition/Source/DefinitionFile.php +74 -0
- addons/inc/Dependencies/DI/Definition/Source/DefinitionSource.php +31 -0
- addons/inc/Dependencies/DI/Definition/Source/MutableDefinitionSource.php +15 -0
- addons/inc/Dependencies/DI/Definition/Source/SourceChain.php +108 -0
- addons/inc/Dependencies/DI/Definition/StringDefinition.php +66 -0
- addons/inc/Dependencies/DI/Definition/ValueDefinition.php +67 -0
- addons/inc/Dependencies/DI/DependencyException.php +19 -0
- addons/inc/Dependencies/DI/FactoryInterface.php +34 -0
- addons/inc/Dependencies/DI/Invoker/DefinitionParameterResolver.php +45 -0
- addons/inc/Dependencies/DI/InvokerInterface.php +19 -0
- addons/inc/Dependencies/DI/NotFoundException.php +19 -0
- addons/inc/Dependencies/DI/Proxy/ProxyFactory.php +88 -0
- addons/inc/Dependencies/DI/Reflection/CallableReflectionFactory.php +51 -0
- addons/inc/Dependencies/DI/Scope.php +54 -0
- addons/inc/Dependencies/DI/functions.php +181 -0
- addons/inc/Dependencies/Interop/Container/ContainerInterface.php +15 -0
- addons/inc/Dependencies/Interop/Container/Exception/ContainerException.php +15 -0
- addons/inc/Dependencies/Interop/Container/Exception/NotFoundException.php +15 -0
- addons/inc/Dependencies/Invoker/CallableResolver.php +127 -0
- addons/inc/Dependencies/Invoker/Exception/InvocationException.php +12 -0
- addons/inc/Dependencies/Invoker/Exception/NotCallableException.php +35 -0
- addons/inc/Dependencies/Invoker/Exception/NotEnoughParametersException.php +12 -0
- addons/inc/Dependencies/Invoker/Invoker.php +122 -0
- addons/inc/Dependencies/Invoker/InvokerInterface.php +29 -0
- addons/inc/Dependencies/Invoker/ParameterResolver/AssociativeArrayResolver.php +39 -0
- addons/inc/Dependencies/Invoker/ParameterResolver/Container/ParameterNameContainerResolver.php +51 -0
- addons/inc/Dependencies/Invoker/ParameterResolver/Container/TypeHintContainerResolver.php +51 -0
- addons/inc/Dependencies/Invoker/ParameterResolver/DefaultValueResolver.php +40 -0
- addons/inc/Dependencies/Invoker/ParameterResolver/NumericArrayResolver.php +39 -0
- addons/inc/Dependencies/Invoker/ParameterResolver/ParameterResolver.php +33 -0
- addons/inc/Dependencies/Invoker/ParameterResolver/ResolverChain.php +69 -0
- addons/inc/Dependencies/Invoker/ParameterResolver/TypeHintResolver.php +39 -0
- addons/inc/Dependencies/Invoker/Reflection/CallableReflection.php +61 -0
- addons/inc/Dependencies/PhpDocReader/AnnotationException.php +10 -0
- addons/inc/Dependencies/PhpDocReader/PhpDocReader.php +307 -0
- addons/inc/Dependencies/PhpDocReader/PhpParser/TokenParser.php +182 -0
- addons/inc/Dependencies/PhpDocReader/PhpParser/UseStatementParser.php +64 -0
- addons/inc/Dependencies/Psr/Container/ContainerExceptionInterface.php +13 -0
- addons/inc/Dependencies/Psr/Container/ContainerInterface.php +37 -0
- addons/inc/Dependencies/Psr/Container/NotFoundExceptionInterface.php +13 -0
- addons/inc/classes/dependencies/.gitkeep +0 -0
- addons/lib/helper.php +47 -3
- addons/lib/settings-service-interface.php +6 -5
- addons/lib/settings-service.php +12 -8
- addons/lib/theme-settings-service.php +70 -0
- addons/tests/integration/addons/test-custom-facebook-feed-old.php +24 -0
- addons/tests/integration/addons/test-custom-facebook-feed.php +5 -6
- addons/tests/integration/addons/test-google-site-kit.php +1 -1
- addons/tests/integration/addons/test-official-facebook-pixel.php +1 -1
- addons/tests/integration/test-buffer-priorities.php +0 -9
- addons/vendor/autoload.php +7 -0
- addons/vendor/composer/ClassLoader.php +445 -0
- addons/vendor/composer/LICENSE +21 -0
- addons/vendor/composer/autoload_classmap.php +9 -0
- addons/vendor/composer/autoload_files.php +10 -0
- addons/vendor/composer/autoload_namespaces.php +9 -0
- addons/vendor/composer/autoload_psr4.php +10 -0
- addons/vendor/composer/autoload_real.php +73 -0
- addons/vendor/composer/autoload_static.php +35 -0
- addons/vendor/composer/installed.json +1224 -0
- addons/view/admin/settings/available-addon-callback.php +7 -20
- addons/view/admin/settings/jetpack-addon-callback.php +7 -7
- addons/view/admin/settings/setting-page.php +6 -6
- cookiebot.php +1389 -1261
- readme.txt +14 -2
- widgets/cookiebot-declaration-widget.php +4 -4
addons/addons.json
CHANGED
@@ -23,6 +23,9 @@
|
|
23 |
"Hubspot_Tracking_Code": {
|
24 |
"class": "cookiebot_addons\\controller\\addons\\hubspot_tracking_code\\Hubspot_Tracking_Code"
|
25 |
},
|
|
|
|
|
|
|
26 |
"Custom_Facebook_Feed": {
|
27 |
"class": "cookiebot_addons\\controller\\addons\\custom_facebook_feed\\Custom_Facebook_Feed"
|
28 |
},
|
@@ -94,5 +97,9 @@
|
|
94 |
},
|
95 |
"Google_Site_Kit": {
|
96 |
"class": "cookiebot_addons\\controller\\addons\\google_site_kit\\Google_Site_Kit"
|
|
|
|
|
|
|
|
|
97 |
}
|
98 |
}
|
23 |
"Hubspot_Tracking_Code": {
|
24 |
"class": "cookiebot_addons\\controller\\addons\\hubspot_tracking_code\\Hubspot_Tracking_Code"
|
25 |
},
|
26 |
+
"Custom_Facebook_Feed_Old": {
|
27 |
+
"class": "cookiebot_addons\\controller\\addons\\custom_facebook_feed_old\\Custom_Facebook_Feed_Old"
|
28 |
+
},
|
29 |
"Custom_Facebook_Feed": {
|
30 |
"class": "cookiebot_addons\\controller\\addons\\custom_facebook_feed\\Custom_Facebook_Feed"
|
31 |
},
|
97 |
},
|
98 |
"Google_Site_Kit": {
|
99 |
"class": "cookiebot_addons\\controller\\addons\\google_site_kit\\Google_Site_Kit"
|
100 |
+
},
|
101 |
+
"Enfold": {
|
102 |
+
"class": "cookiebot_addons\\controller\\addons\\enfold\\Enfold",
|
103 |
+
"is_theme": true
|
104 |
}
|
105 |
}
|
addons/composer.json
CHANGED
@@ -2,7 +2,42 @@
|
|
2 |
"require": {
|
3 |
"php-di/php-di": "5.0"
|
4 |
},
|
5 |
-
"
|
6 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
}
|
8 |
}
|
2 |
"require": {
|
3 |
"php-di/php-di": "5.0"
|
4 |
},
|
5 |
+
"require-dev": {
|
6 |
+
"coenjacobs/mozart": "^0.6.0-beta-3"
|
7 |
+
},
|
8 |
+
"extra": {
|
9 |
+
"mozart": {
|
10 |
+
"dep_namespace": "Cybot\\Dependencies\\",
|
11 |
+
"dep_directory": "/inc/Dependencies/",
|
12 |
+
"classmap_directory": "/inc/classes/dependencies/",
|
13 |
+
"classmap_prefix": "Cybot_",
|
14 |
+
"packages": [
|
15 |
+
"php-di/php-di"
|
16 |
+
],
|
17 |
+
"delete_vendor_directories": true
|
18 |
+
}
|
19 |
+
},
|
20 |
+
"autoload": {
|
21 |
+
"classmap": [
|
22 |
+
"inc/classes"
|
23 |
+
],
|
24 |
+
"psr-4": {
|
25 |
+
"Cybot\\": "inc/"
|
26 |
+
},
|
27 |
+
"files": [
|
28 |
+
"inc/Dependencies/DI/functions.php"
|
29 |
+
]
|
30 |
+
},
|
31 |
+
"scripts": {
|
32 |
+
"post-install-cmd": [
|
33 |
+
"\"vendor/bin/mozart\" compose",
|
34 |
+
"rm -Rf vendor/symfony vendor/coenjacobs vendor/league",
|
35 |
+
"composer dump-autoload"
|
36 |
+
],
|
37 |
+
"post-update-cmd": [
|
38 |
+
"\"vendor/bin/mozart\" compose",
|
39 |
+
"rm -Rf vendor/symfony vendor/coenjacobs vendor/league",
|
40 |
+
"composer dump-autoload"
|
41 |
+
]
|
42 |
}
|
43 |
}
|
addons/composer.lock
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
5 |
"This file is @generated automatically"
|
6 |
],
|
7 |
-
"content-hash": "
|
8 |
"packages": [
|
9 |
{
|
10 |
"name": "container-interop/container-interop",
|
@@ -35,6 +35,7 @@
|
|
35 |
],
|
36 |
"description": "Promoting the interoperability of container objects (DIC, SL, etc.)",
|
37 |
"homepage": "https://github.com/container-interop/container-interop",
|
|
|
38 |
"time": "2017-02-14T19:40:03+00:00"
|
39 |
},
|
40 |
{
|
@@ -136,23 +137,24 @@
|
|
136 |
},
|
137 |
{
|
138 |
"name": "php-di/phpdoc-reader",
|
139 |
-
"version": "2.
|
140 |
"source": {
|
141 |
"type": "git",
|
142 |
"url": "https://github.com/PHP-DI/PhpDocReader.git",
|
143 |
-
"reference": "
|
144 |
},
|
145 |
"dist": {
|
146 |
"type": "zip",
|
147 |
-
"url": "https://api.github.com/repos/PHP-DI/PhpDocReader/zipball/
|
148 |
-
"reference": "
|
149 |
"shasum": ""
|
150 |
},
|
151 |
"require": {
|
152 |
-
"php": ">=
|
153 |
},
|
154 |
"require-dev": {
|
155 |
-
"
|
|
|
156 |
},
|
157 |
"type": "library",
|
158 |
"autoload": {
|
@@ -169,7 +171,7 @@
|
|
169 |
"phpdoc",
|
170 |
"reflection"
|
171 |
],
|
172 |
-
"time": "
|
173 |
},
|
174 |
{
|
175 |
"name": "psr/container",
|
@@ -221,12 +223,986 @@
|
|
221 |
"time": "2017-02-14T16:28:37+00:00"
|
222 |
}
|
223 |
],
|
224 |
-
"packages-dev": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
"aliases": [],
|
226 |
"minimum-stability": "stable",
|
227 |
-
"stability-flags":
|
|
|
|
|
228 |
"prefer-stable": false,
|
229 |
"prefer-lowest": false,
|
230 |
"platform": [],
|
231 |
-
"platform-dev": []
|
|
|
232 |
}
|
4 |
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
5 |
"This file is @generated automatically"
|
6 |
],
|
7 |
+
"content-hash": "da8cd89411908476f7e244c8b5404934",
|
8 |
"packages": [
|
9 |
{
|
10 |
"name": "container-interop/container-interop",
|
35 |
],
|
36 |
"description": "Promoting the interoperability of container objects (DIC, SL, etc.)",
|
37 |
"homepage": "https://github.com/container-interop/container-interop",
|
38 |
+
"abandoned": "psr/container",
|
39 |
"time": "2017-02-14T19:40:03+00:00"
|
40 |
},
|
41 |
{
|
137 |
},
|
138 |
{
|
139 |
"name": "php-di/phpdoc-reader",
|
140 |
+
"version": "2.2.1",
|
141 |
"source": {
|
142 |
"type": "git",
|
143 |
"url": "https://github.com/PHP-DI/PhpDocReader.git",
|
144 |
+
"reference": "66daff34cbd2627740ffec9469ffbac9f8c8185c"
|
145 |
},
|
146 |
"dist": {
|
147 |
"type": "zip",
|
148 |
+
"url": "https://api.github.com/repos/PHP-DI/PhpDocReader/zipball/66daff34cbd2627740ffec9469ffbac9f8c8185c",
|
149 |
+
"reference": "66daff34cbd2627740ffec9469ffbac9f8c8185c",
|
150 |
"shasum": ""
|
151 |
},
|
152 |
"require": {
|
153 |
+
"php": ">=7.2.0"
|
154 |
},
|
155 |
"require-dev": {
|
156 |
+
"mnapoli/hard-mode": "~0.3.0",
|
157 |
+
"phpunit/phpunit": "^8.5|^9.0"
|
158 |
},
|
159 |
"type": "library",
|
160 |
"autoload": {
|
171 |
"phpdoc",
|
172 |
"reflection"
|
173 |
],
|
174 |
+
"time": "2020-10-12T12:39:22+00:00"
|
175 |
},
|
176 |
{
|
177 |
"name": "psr/container",
|
223 |
"time": "2017-02-14T16:28:37+00:00"
|
224 |
}
|
225 |
],
|
226 |
+
"packages-dev": [
|
227 |
+
{
|
228 |
+
"name": "coenjacobs/mozart",
|
229 |
+
"version": "0.6.0-beta-3",
|
230 |
+
"source": {
|
231 |
+
"type": "git",
|
232 |
+
"url": "https://github.com/coenjacobs/mozart.git",
|
233 |
+
"reference": "965d698d76639587b26c878b22f4373c32f3d9ee"
|
234 |
+
},
|
235 |
+
"dist": {
|
236 |
+
"type": "zip",
|
237 |
+
"url": "https://api.github.com/repos/coenjacobs/mozart/zipball/965d698d76639587b26c878b22f4373c32f3d9ee",
|
238 |
+
"reference": "965d698d76639587b26c878b22f4373c32f3d9ee",
|
239 |
+
"shasum": ""
|
240 |
+
},
|
241 |
+
"require": {
|
242 |
+
"league/flysystem": "^1.0",
|
243 |
+
"php": "^7.2",
|
244 |
+
"symfony/console": "^4|^5",
|
245 |
+
"symfony/finder": "^4|^5"
|
246 |
+
},
|
247 |
+
"require-dev": {
|
248 |
+
"phpunit/phpunit": "^8.5",
|
249 |
+
"squizlabs/php_codesniffer": "^3.5"
|
250 |
+
},
|
251 |
+
"bin": [
|
252 |
+
"bin/mozart"
|
253 |
+
],
|
254 |
+
"type": "library",
|
255 |
+
"autoload": {
|
256 |
+
"psr-4": {
|
257 |
+
"CoenJacobs\\Mozart\\": "src/"
|
258 |
+
}
|
259 |
+
},
|
260 |
+
"notification-url": "https://packagist.org/downloads/",
|
261 |
+
"license": [
|
262 |
+
"MIT"
|
263 |
+
],
|
264 |
+
"authors": [
|
265 |
+
{
|
266 |
+
"name": "Coen Jacobs",
|
267 |
+
"email": "coenjacobs@gmail.com"
|
268 |
+
}
|
269 |
+
],
|
270 |
+
"description": "Composes all dependencies as a package inside a WordPress plugin",
|
271 |
+
"funding": [
|
272 |
+
{
|
273 |
+
"url": "https://github.com/coenjacobs",
|
274 |
+
"type": "github"
|
275 |
+
}
|
276 |
+
],
|
277 |
+
"time": "2020-06-02T06:54:01+00:00"
|
278 |
+
},
|
279 |
+
{
|
280 |
+
"name": "league/flysystem",
|
281 |
+
"version": "1.1.3",
|
282 |
+
"source": {
|
283 |
+
"type": "git",
|
284 |
+
"url": "https://github.com/thephpleague/flysystem.git",
|
285 |
+
"reference": "9be3b16c877d477357c015cec057548cf9b2a14a"
|
286 |
+
},
|
287 |
+
"dist": {
|
288 |
+
"type": "zip",
|
289 |
+
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/9be3b16c877d477357c015cec057548cf9b2a14a",
|
290 |
+
"reference": "9be3b16c877d477357c015cec057548cf9b2a14a",
|
291 |
+
"shasum": ""
|
292 |
+
},
|
293 |
+
"require": {
|
294 |
+
"ext-fileinfo": "*",
|
295 |
+
"league/mime-type-detection": "^1.3",
|
296 |
+
"php": "^7.2.5 || ^8.0"
|
297 |
+
},
|
298 |
+
"conflict": {
|
299 |
+
"league/flysystem-sftp": "<1.0.6"
|
300 |
+
},
|
301 |
+
"require-dev": {
|
302 |
+
"phpspec/prophecy": "^1.11.1",
|
303 |
+
"phpunit/phpunit": "^8.5.8"
|
304 |
+
},
|
305 |
+
"suggest": {
|
306 |
+
"ext-fileinfo": "Required for MimeType",
|
307 |
+
"ext-ftp": "Allows you to use FTP server storage",
|
308 |
+
"ext-openssl": "Allows you to use FTPS server storage",
|
309 |
+
"league/flysystem-aws-s3-v2": "Allows you to use S3 storage with AWS SDK v2",
|
310 |
+
"league/flysystem-aws-s3-v3": "Allows you to use S3 storage with AWS SDK v3",
|
311 |
+
"league/flysystem-azure": "Allows you to use Windows Azure Blob storage",
|
312 |
+
"league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching",
|
313 |
+
"league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem",
|
314 |
+
"league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files",
|
315 |
+
"league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib",
|
316 |
+
"league/flysystem-webdav": "Allows you to use WebDAV storage",
|
317 |
+
"league/flysystem-ziparchive": "Allows you to use ZipArchive adapter",
|
318 |
+
"spatie/flysystem-dropbox": "Allows you to use Dropbox storage",
|
319 |
+
"srmklive/flysystem-dropbox-v2": "Allows you to use Dropbox storage for PHP 5 applications"
|
320 |
+
},
|
321 |
+
"type": "library",
|
322 |
+
"extra": {
|
323 |
+
"branch-alias": {
|
324 |
+
"dev-master": "1.1-dev"
|
325 |
+
}
|
326 |
+
},
|
327 |
+
"autoload": {
|
328 |
+
"psr-4": {
|
329 |
+
"League\\Flysystem\\": "src/"
|
330 |
+
}
|
331 |
+
},
|
332 |
+
"notification-url": "https://packagist.org/downloads/",
|
333 |
+
"license": [
|
334 |
+
"MIT"
|
335 |
+
],
|
336 |
+
"authors": [
|
337 |
+
{
|
338 |
+
"name": "Frank de Jonge",
|
339 |
+
"email": "info@frenky.net"
|
340 |
+
}
|
341 |
+
],
|
342 |
+
"description": "Filesystem abstraction: Many filesystems, one API.",
|
343 |
+
"keywords": [
|
344 |
+
"Cloud Files",
|
345 |
+
"WebDAV",
|
346 |
+
"abstraction",
|
347 |
+
"aws",
|
348 |
+
"cloud",
|
349 |
+
"copy.com",
|
350 |
+
"dropbox",
|
351 |
+
"file systems",
|
352 |
+
"files",
|
353 |
+
"filesystem",
|
354 |
+
"filesystems",
|
355 |
+
"ftp",
|
356 |
+
"rackspace",
|
357 |
+
"remote",
|
358 |
+
"s3",
|
359 |
+
"sftp",
|
360 |
+
"storage"
|
361 |
+
],
|
362 |
+
"funding": [
|
363 |
+
{
|
364 |
+
"url": "https://offset.earth/frankdejonge",
|
365 |
+
"type": "other"
|
366 |
+
}
|
367 |
+
],
|
368 |
+
"time": "2020-08-23T07:39:11+00:00"
|
369 |
+
},
|
370 |
+
{
|
371 |
+
"name": "league/mime-type-detection",
|
372 |
+
"version": "1.5.1",
|
373 |
+
"source": {
|
374 |
+
"type": "git",
|
375 |
+
"url": "https://github.com/thephpleague/mime-type-detection.git",
|
376 |
+
"reference": "353f66d7555d8a90781f6f5e7091932f9a4250aa"
|
377 |
+
},
|
378 |
+
"dist": {
|
379 |
+
"type": "zip",
|
380 |
+
"url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/353f66d7555d8a90781f6f5e7091932f9a4250aa",
|
381 |
+
"reference": "353f66d7555d8a90781f6f5e7091932f9a4250aa",
|
382 |
+
"shasum": ""
|
383 |
+
},
|
384 |
+
"require": {
|
385 |
+
"ext-fileinfo": "*",
|
386 |
+
"php": "^7.2 || ^8.0"
|
387 |
+
},
|
388 |
+
"require-dev": {
|
389 |
+
"phpstan/phpstan": "^0.12.36",
|
390 |
+
"phpunit/phpunit": "^8.5.8"
|
391 |
+
},
|
392 |
+
"type": "library",
|
393 |
+
"autoload": {
|
394 |
+
"psr-4": {
|
395 |
+
"League\\MimeTypeDetection\\": "src"
|
396 |
+
}
|
397 |
+
},
|
398 |
+
"notification-url": "https://packagist.org/downloads/",
|
399 |
+
"license": [
|
400 |
+
"MIT"
|
401 |
+
],
|
402 |
+
"authors": [
|
403 |
+
{
|
404 |
+
"name": "Frank de Jonge",
|
405 |
+
"email": "info@frankdejonge.nl"
|
406 |
+
}
|
407 |
+
],
|
408 |
+
"description": "Mime-type detection for Flysystem",
|
409 |
+
"funding": [
|
410 |
+
{
|
411 |
+
"url": "https://github.com/frankdejonge",
|
412 |
+
"type": "github"
|
413 |
+
},
|
414 |
+
{
|
415 |
+
"url": "https://tidelift.com/funding/github/packagist/league/flysystem",
|
416 |
+
"type": "tidelift"
|
417 |
+
}
|
418 |
+
],
|
419 |
+
"time": "2020-10-18T11:50:25+00:00"
|
420 |
+
},
|
421 |
+
{
|
422 |
+
"name": "symfony/console",
|
423 |
+
"version": "v5.2.1",
|
424 |
+
"source": {
|
425 |
+
"type": "git",
|
426 |
+
"url": "https://github.com/symfony/console.git",
|
427 |
+
"reference": "47c02526c532fb381374dab26df05e7313978976"
|
428 |
+
},
|
429 |
+
"dist": {
|
430 |
+
"type": "zip",
|
431 |
+
"url": "https://api.github.com/repos/symfony/console/zipball/47c02526c532fb381374dab26df05e7313978976",
|
432 |
+
"reference": "47c02526c532fb381374dab26df05e7313978976",
|
433 |
+
"shasum": ""
|
434 |
+
},
|
435 |
+
"require": {
|
436 |
+
"php": ">=7.2.5",
|
437 |
+
"symfony/polyfill-mbstring": "~1.0",
|
438 |
+
"symfony/polyfill-php73": "^1.8",
|
439 |
+
"symfony/polyfill-php80": "^1.15",
|
440 |
+
"symfony/service-contracts": "^1.1|^2",
|
441 |
+
"symfony/string": "^5.1"
|
442 |
+
},
|
443 |
+
"conflict": {
|
444 |
+
"symfony/dependency-injection": "<4.4",
|
445 |
+
"symfony/dotenv": "<5.1",
|
446 |
+
"symfony/event-dispatcher": "<4.4",
|
447 |
+
"symfony/lock": "<4.4",
|
448 |
+
"symfony/process": "<4.4"
|
449 |
+
},
|
450 |
+
"provide": {
|
451 |
+
"psr/log-implementation": "1.0"
|
452 |
+
},
|
453 |
+
"require-dev": {
|
454 |
+
"psr/log": "~1.0",
|
455 |
+
"symfony/config": "^4.4|^5.0",
|
456 |
+
"symfony/dependency-injection": "^4.4|^5.0",
|
457 |
+
"symfony/event-dispatcher": "^4.4|^5.0",
|
458 |
+
"symfony/lock": "^4.4|^5.0",
|
459 |
+
"symfony/process": "^4.4|^5.0",
|
460 |
+
"symfony/var-dumper": "^4.4|^5.0"
|
461 |
+
},
|
462 |
+
"suggest": {
|
463 |
+
"psr/log": "For using the console logger",
|
464 |
+
"symfony/event-dispatcher": "",
|
465 |
+
"symfony/lock": "",
|
466 |
+
"symfony/process": ""
|
467 |
+
},
|
468 |
+
"type": "library",
|
469 |
+
"autoload": {
|
470 |
+
"psr-4": {
|
471 |
+
"Symfony\\Component\\Console\\": ""
|
472 |
+
},
|
473 |
+
"exclude-from-classmap": [
|
474 |
+
"/Tests/"
|
475 |
+
]
|
476 |
+
},
|
477 |
+
"notification-url": "https://packagist.org/downloads/",
|
478 |
+
"license": [
|
479 |
+
"MIT"
|
480 |
+
],
|
481 |
+
"authors": [
|
482 |
+
{
|
483 |
+
"name": "Fabien Potencier",
|
484 |
+
"email": "fabien@symfony.com"
|
485 |
+
},
|
486 |
+
{
|
487 |
+
"name": "Symfony Community",
|
488 |
+
"homepage": "https://symfony.com/contributors"
|
489 |
+
}
|
490 |
+
],
|
491 |
+
"description": "Symfony Console Component",
|
492 |
+
"homepage": "https://symfony.com",
|
493 |
+
"keywords": [
|
494 |
+
"cli",
|
495 |
+
"command line",
|
496 |
+
"console",
|
497 |
+
"terminal"
|
498 |
+
],
|
499 |
+
"funding": [
|
500 |
+
{
|
501 |
+
"url": "https://symfony.com/sponsor",
|
502 |
+
"type": "custom"
|
503 |
+
},
|
504 |
+
{
|
505 |
+
"url": "https://github.com/fabpot",
|
506 |
+
"type": "github"
|
507 |
+
},
|
508 |
+
{
|
509 |
+
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
510 |
+
"type": "tidelift"
|
511 |
+
}
|
512 |
+
],
|
513 |
+
"time": "2020-12-18T08:03:05+00:00"
|
514 |
+
},
|
515 |
+
{
|
516 |
+
"name": "symfony/finder",
|
517 |
+
"version": "v5.2.1",
|
518 |
+
"source": {
|
519 |
+
"type": "git",
|
520 |
+
"url": "https://github.com/symfony/finder.git",
|
521 |
+
"reference": "0b9231a5922fd7287ba5b411893c0ecd2733e5ba"
|
522 |
+
},
|
523 |
+
"dist": {
|
524 |
+
"type": "zip",
|
525 |
+
"url": "https://api.github.com/repos/symfony/finder/zipball/0b9231a5922fd7287ba5b411893c0ecd2733e5ba",
|
526 |
+
"reference": "0b9231a5922fd7287ba5b411893c0ecd2733e5ba",
|
527 |
+
"shasum": ""
|
528 |
+
},
|
529 |
+
"require": {
|
530 |
+
"php": ">=7.2.5"
|
531 |
+
},
|
532 |
+
"type": "library",
|
533 |
+
"autoload": {
|
534 |
+
"psr-4": {
|
535 |
+
"Symfony\\Component\\Finder\\": ""
|
536 |
+
},
|
537 |
+
"exclude-from-classmap": [
|
538 |
+
"/Tests/"
|
539 |
+
]
|
540 |
+
},
|
541 |
+
"notification-url": "https://packagist.org/downloads/",
|
542 |
+
"license": [
|
543 |
+
"MIT"
|
544 |
+
],
|
545 |
+
"authors": [
|
546 |
+
{
|
547 |
+
"name": "Fabien Potencier",
|
548 |
+
"email": "fabien@symfony.com"
|
549 |
+
},
|
550 |
+
{
|
551 |
+
"name": "Symfony Community",
|
552 |
+
"homepage": "https://symfony.com/contributors"
|
553 |
+
}
|
554 |
+
],
|
555 |
+
"description": "Symfony Finder Component",
|
556 |
+
"homepage": "https://symfony.com",
|
557 |
+
"funding": [
|
558 |
+
{
|
559 |
+
"url": "https://symfony.com/sponsor",
|
560 |
+
"type": "custom"
|
561 |
+
},
|
562 |
+
{
|
563 |
+
"url": "https://github.com/fabpot",
|
564 |
+
"type": "github"
|
565 |
+
},
|
566 |
+
{
|
567 |
+
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
568 |
+
"type": "tidelift"
|
569 |
+
}
|
570 |
+
],
|
571 |
+
"time": "2020-12-08T17:02:38+00:00"
|
572 |
+
},
|
573 |
+
{
|
574 |
+
"name": "symfony/polyfill-ctype",
|
575 |
+
"version": "v1.22.0",
|
576 |
+
"source": {
|
577 |
+
"type": "git",
|
578 |
+
"url": "https://github.com/symfony/polyfill-ctype.git",
|
579 |
+
"reference": "c6c942b1ac76c82448322025e084cadc56048b4e"
|
580 |
+
},
|
581 |
+
"dist": {
|
582 |
+
"type": "zip",
|
583 |
+
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/c6c942b1ac76c82448322025e084cadc56048b4e",
|
584 |
+
"reference": "c6c942b1ac76c82448322025e084cadc56048b4e",
|
585 |
+
"shasum": ""
|
586 |
+
},
|
587 |
+
"require": {
|
588 |
+
"php": ">=7.1"
|
589 |
+
},
|
590 |
+
"suggest": {
|
591 |
+
"ext-ctype": "For best performance"
|
592 |
+
},
|
593 |
+
"type": "library",
|
594 |
+
"extra": {
|
595 |
+
"branch-alias": {
|
596 |
+
"dev-main": "1.22-dev"
|
597 |
+
},
|
598 |
+
"thanks": {
|
599 |
+
"name": "symfony/polyfill",
|
600 |
+
"url": "https://github.com/symfony/polyfill"
|
601 |
+
}
|
602 |
+
},
|
603 |
+
"autoload": {
|
604 |
+
"psr-4": {
|
605 |
+
"Symfony\\Polyfill\\Ctype\\": ""
|
606 |
+
},
|
607 |
+
"files": [
|
608 |
+
"bootstrap.php"
|
609 |
+
]
|
610 |
+
},
|
611 |
+
"notification-url": "https://packagist.org/downloads/",
|
612 |
+
"license": [
|
613 |
+
"MIT"
|
614 |
+
],
|
615 |
+
"authors": [
|
616 |
+
{
|
617 |
+
"name": "Gert de Pagter",
|
618 |
+
"email": "BackEndTea@gmail.com"
|
619 |
+
},
|
620 |
+
{
|
621 |
+
"name": "Symfony Community",
|
622 |
+
"homepage": "https://symfony.com/contributors"
|
623 |
+
}
|
624 |
+
],
|
625 |
+
"description": "Symfony polyfill for ctype functions",
|
626 |
+
"homepage": "https://symfony.com",
|
627 |
+
"keywords": [
|
628 |
+
"compatibility",
|
629 |
+
"ctype",
|
630 |
+
"polyfill",
|
631 |
+
"portable"
|
632 |
+
],
|
633 |
+
"funding": [
|
634 |
+
{
|
635 |
+
"url": "https://symfony.com/sponsor",
|
636 |
+
"type": "custom"
|
637 |
+
},
|
638 |
+
{
|
639 |
+
"url": "https://github.com/fabpot",
|
640 |
+
"type": "github"
|
641 |
+
},
|
642 |
+
{
|
643 |
+
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
644 |
+
"type": "tidelift"
|
645 |
+
}
|
646 |
+
],
|
647 |
+
"time": "2021-01-07T16:49:33+00:00"
|
648 |
+
},
|
649 |
+
{
|
650 |
+
"name": "symfony/polyfill-intl-grapheme",
|
651 |
+
"version": "v1.22.0",
|
652 |
+
"source": {
|
653 |
+
"type": "git",
|
654 |
+
"url": "https://github.com/symfony/polyfill-intl-grapheme.git",
|
655 |
+
"reference": "267a9adeb8ecb8071040a740930e077cdfb987af"
|
656 |
+
},
|
657 |
+
"dist": {
|
658 |
+
"type": "zip",
|
659 |
+
"url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/267a9adeb8ecb8071040a740930e077cdfb987af",
|
660 |
+
"reference": "267a9adeb8ecb8071040a740930e077cdfb987af",
|
661 |
+
"shasum": ""
|
662 |
+
},
|
663 |
+
"require": {
|
664 |
+
"php": ">=7.1"
|
665 |
+
},
|
666 |
+
"suggest": {
|
667 |
+
"ext-intl": "For best performance"
|
668 |
+
},
|
669 |
+
"type": "library",
|
670 |
+
"extra": {
|
671 |
+
"branch-alias": {
|
672 |
+
"dev-main": "1.22-dev"
|
673 |
+
},
|
674 |
+
"thanks": {
|
675 |
+
"name": "symfony/polyfill",
|
676 |
+
"url": "https://github.com/symfony/polyfill"
|
677 |
+
}
|
678 |
+
},
|
679 |
+
"autoload": {
|
680 |
+
"psr-4": {
|
681 |
+
"Symfony\\Polyfill\\Intl\\Grapheme\\": ""
|
682 |
+
},
|
683 |
+
"files": [
|
684 |
+
"bootstrap.php"
|
685 |
+
]
|
686 |
+
},
|
687 |
+
"notification-url": "https://packagist.org/downloads/",
|
688 |
+
"license": [
|
689 |
+
"MIT"
|
690 |
+
],
|
691 |
+
"authors": [
|
692 |
+
{
|
693 |
+
"name": "Nicolas Grekas",
|
694 |
+
"email": "p@tchwork.com"
|
695 |
+
},
|
696 |
+
{
|
697 |
+
"name": "Symfony Community",
|
698 |
+
"homepage": "https://symfony.com/contributors"
|
699 |
+
}
|
700 |
+
],
|
701 |
+
"description": "Symfony polyfill for intl's grapheme_* functions",
|
702 |
+
"homepage": "https://symfony.com",
|
703 |
+
"keywords": [
|
704 |
+
"compatibility",
|
705 |
+
"grapheme",
|
706 |
+
"intl",
|
707 |
+
"polyfill",
|
708 |
+
"portable",
|
709 |
+
"shim"
|
710 |
+
],
|
711 |
+
"funding": [
|
712 |
+
{
|
713 |
+
"url": "https://symfony.com/sponsor",
|
714 |
+
"type": "custom"
|
715 |
+
},
|
716 |
+
{
|
717 |
+
"url": "https://github.com/fabpot",
|
718 |
+
"type": "github"
|
719 |
+
},
|
720 |
+
{
|
721 |
+
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
722 |
+
"type": "tidelift"
|
723 |
+
}
|
724 |
+
],
|
725 |
+
"time": "2021-01-07T16:49:33+00:00"
|
726 |
+
},
|
727 |
+
{
|
728 |
+
"name": "symfony/polyfill-intl-normalizer",
|
729 |
+
"version": "v1.22.0",
|
730 |
+
"source": {
|
731 |
+
"type": "git",
|
732 |
+
"url": "https://github.com/symfony/polyfill-intl-normalizer.git",
|
733 |
+
"reference": "6e971c891537eb617a00bb07a43d182a6915faba"
|
734 |
+
},
|
735 |
+
"dist": {
|
736 |
+
"type": "zip",
|
737 |
+
"url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/6e971c891537eb617a00bb07a43d182a6915faba",
|
738 |
+
"reference": "6e971c891537eb617a00bb07a43d182a6915faba",
|
739 |
+
"shasum": ""
|
740 |
+
},
|
741 |
+
"require": {
|
742 |
+
"php": ">=7.1"
|
743 |
+
},
|
744 |
+
"suggest": {
|
745 |
+
"ext-intl": "For best performance"
|
746 |
+
},
|
747 |
+
"type": "library",
|
748 |
+
"extra": {
|
749 |
+
"branch-alias": {
|
750 |
+
"dev-main": "1.22-dev"
|
751 |
+
},
|
752 |
+
"thanks": {
|
753 |
+
"name": "symfony/polyfill",
|
754 |
+
"url": "https://github.com/symfony/polyfill"
|
755 |
+
}
|
756 |
+
},
|
757 |
+
"autoload": {
|
758 |
+
"psr-4": {
|
759 |
+
"Symfony\\Polyfill\\Intl\\Normalizer\\": ""
|
760 |
+
},
|
761 |
+
"files": [
|
762 |
+
"bootstrap.php"
|
763 |
+
],
|
764 |
+
"classmap": [
|
765 |
+
"Resources/stubs"
|
766 |
+
]
|
767 |
+
},
|
768 |
+
"notification-url": "https://packagist.org/downloads/",
|
769 |
+
"license": [
|
770 |
+
"MIT"
|
771 |
+
],
|
772 |
+
"authors": [
|
773 |
+
{
|
774 |
+
"name": "Nicolas Grekas",
|
775 |
+
"email": "p@tchwork.com"
|
776 |
+
},
|
777 |
+
{
|
778 |
+
"name": "Symfony Community",
|
779 |
+
"homepage": "https://symfony.com/contributors"
|
780 |
+
}
|
781 |
+
],
|
782 |
+
"description": "Symfony polyfill for intl's Normalizer class and related functions",
|
783 |
+
"homepage": "https://symfony.com",
|
784 |
+
"keywords": [
|
785 |
+
"compatibility",
|
786 |
+
"intl",
|
787 |
+
"normalizer",
|
788 |
+
"polyfill",
|
789 |
+
"portable",
|
790 |
+
"shim"
|
791 |
+
],
|
792 |
+
"funding": [
|
793 |
+
{
|
794 |
+
"url": "https://symfony.com/sponsor",
|
795 |
+
"type": "custom"
|
796 |
+
},
|
797 |
+
{
|
798 |
+
"url": "https://github.com/fabpot",
|
799 |
+
"type": "github"
|
800 |
+
},
|
801 |
+
{
|
802 |
+
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
803 |
+
"type": "tidelift"
|
804 |
+
}
|
805 |
+
],
|
806 |
+
"time": "2021-01-07T17:09:11+00:00"
|
807 |
+
},
|
808 |
+
{
|
809 |
+
"name": "symfony/polyfill-mbstring",
|
810 |
+
"version": "v1.22.0",
|
811 |
+
"source": {
|
812 |
+
"type": "git",
|
813 |
+
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
814 |
+
"reference": "f377a3dd1fde44d37b9831d68dc8dea3ffd28e13"
|
815 |
+
},
|
816 |
+
"dist": {
|
817 |
+
"type": "zip",
|
818 |
+
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f377a3dd1fde44d37b9831d68dc8dea3ffd28e13",
|
819 |
+
"reference": "f377a3dd1fde44d37b9831d68dc8dea3ffd28e13",
|
820 |
+
"shasum": ""
|
821 |
+
},
|
822 |
+
"require": {
|
823 |
+
"php": ">=7.1"
|
824 |
+
},
|
825 |
+
"suggest": {
|
826 |
+
"ext-mbstring": "For best performance"
|
827 |
+
},
|
828 |
+
"type": "library",
|
829 |
+
"extra": {
|
830 |
+
"branch-alias": {
|
831 |
+
"dev-main": "1.22-dev"
|
832 |
+
},
|
833 |
+
"thanks": {
|
834 |
+
"name": "symfony/polyfill",
|
835 |
+
"url": "https://github.com/symfony/polyfill"
|
836 |
+
}
|
837 |
+
},
|
838 |
+
"autoload": {
|
839 |
+
"psr-4": {
|
840 |
+
"Symfony\\Polyfill\\Mbstring\\": ""
|
841 |
+
},
|
842 |
+
"files": [
|
843 |
+
"bootstrap.php"
|
844 |
+
]
|
845 |
+
},
|
846 |
+
"notification-url": "https://packagist.org/downloads/",
|
847 |
+
"license": [
|
848 |
+
"MIT"
|
849 |
+
],
|
850 |
+
"authors": [
|
851 |
+
{
|
852 |
+
"name": "Nicolas Grekas",
|
853 |
+
"email": "p@tchwork.com"
|
854 |
+
},
|
855 |
+
{
|
856 |
+
"name": "Symfony Community",
|
857 |
+
"homepage": "https://symfony.com/contributors"
|
858 |
+
}
|
859 |
+
],
|
860 |
+
"description": "Symfony polyfill for the Mbstring extension",
|
861 |
+
"homepage": "https://symfony.com",
|
862 |
+
"keywords": [
|
863 |
+
"compatibility",
|
864 |
+
"mbstring",
|
865 |
+
"polyfill",
|
866 |
+
"portable",
|
867 |
+
"shim"
|
868 |
+
],
|
869 |
+
"funding": [
|
870 |
+
{
|
871 |
+
"url": "https://symfony.com/sponsor",
|
872 |
+
"type": "custom"
|
873 |
+
},
|
874 |
+
{
|
875 |
+
"url": "https://github.com/fabpot",
|
876 |
+
"type": "github"
|
877 |
+
},
|
878 |
+
{
|
879 |
+
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
880 |
+
"type": "tidelift"
|
881 |
+
}
|
882 |
+
],
|
883 |
+
"time": "2021-01-07T16:49:33+00:00"
|
884 |
+
},
|
885 |
+
{
|
886 |
+
"name": "symfony/polyfill-php73",
|
887 |
+
"version": "v1.22.0",
|
888 |
+
"source": {
|
889 |
+
"type": "git",
|
890 |
+
"url": "https://github.com/symfony/polyfill-php73.git",
|
891 |
+
"reference": "a678b42e92f86eca04b7fa4c0f6f19d097fb69e2"
|
892 |
+
},
|
893 |
+
"dist": {
|
894 |
+
"type": "zip",
|
895 |
+
"url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/a678b42e92f86eca04b7fa4c0f6f19d097fb69e2",
|
896 |
+
"reference": "a678b42e92f86eca04b7fa4c0f6f19d097fb69e2",
|
897 |
+
"shasum": ""
|
898 |
+
},
|
899 |
+
"require": {
|
900 |
+
"php": ">=7.1"
|
901 |
+
},
|
902 |
+
"type": "library",
|
903 |
+
"extra": {
|
904 |
+
"branch-alias": {
|
905 |
+
"dev-main": "1.22-dev"
|
906 |
+
},
|
907 |
+
"thanks": {
|
908 |
+
"name": "symfony/polyfill",
|
909 |
+
"url": "https://github.com/symfony/polyfill"
|
910 |
+
}
|
911 |
+
},
|
912 |
+
"autoload": {
|
913 |
+
"psr-4": {
|
914 |
+
"Symfony\\Polyfill\\Php73\\": ""
|
915 |
+
},
|
916 |
+
"files": [
|
917 |
+
"bootstrap.php"
|
918 |
+
],
|
919 |
+
"classmap": [
|
920 |
+
"Resources/stubs"
|
921 |
+
]
|
922 |
+
},
|
923 |
+
"notification-url": "https://packagist.org/downloads/",
|
924 |
+
"license": [
|
925 |
+
"MIT"
|
926 |
+
],
|
927 |
+
"authors": [
|
928 |
+
{
|
929 |
+
"name": "Nicolas Grekas",
|
930 |
+
"email": "p@tchwork.com"
|
931 |
+
},
|
932 |
+
{
|
933 |
+
"name": "Symfony Community",
|
934 |
+
"homepage": "https://symfony.com/contributors"
|
935 |
+
}
|
936 |
+
],
|
937 |
+
"description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions",
|
938 |
+
"homepage": "https://symfony.com",
|
939 |
+
"keywords": [
|
940 |
+
"compatibility",
|
941 |
+
"polyfill",
|
942 |
+
"portable",
|
943 |
+
"shim"
|
944 |
+
],
|
945 |
+
"funding": [
|
946 |
+
{
|
947 |
+
"url": "https://symfony.com/sponsor",
|
948 |
+
"type": "custom"
|
949 |
+
},
|
950 |
+
{
|
951 |
+
"url": "https://github.com/fabpot",
|
952 |
+
"type": "github"
|
953 |
+
},
|
954 |
+
{
|
955 |
+
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
956 |
+
"type": "tidelift"
|
957 |
+
}
|
958 |
+
],
|
959 |
+
"time": "2021-01-07T16:49:33+00:00"
|
960 |
+
},
|
961 |
+
{
|
962 |
+
"name": "symfony/polyfill-php80",
|
963 |
+
"version": "v1.22.0",
|
964 |
+
"source": {
|
965 |
+
"type": "git",
|
966 |
+
"url": "https://github.com/symfony/polyfill-php80.git",
|
967 |
+
"reference": "dc3063ba22c2a1fd2f45ed856374d79114998f91"
|
968 |
+
},
|
969 |
+
"dist": {
|
970 |
+
"type": "zip",
|
971 |
+
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/dc3063ba22c2a1fd2f45ed856374d79114998f91",
|
972 |
+
"reference": "dc3063ba22c2a1fd2f45ed856374d79114998f91",
|
973 |
+
"shasum": ""
|
974 |
+
},
|
975 |
+
"require": {
|
976 |
+
"php": ">=7.1"
|
977 |
+
},
|
978 |
+
"type": "library",
|
979 |
+
"extra": {
|
980 |
+
"branch-alias": {
|
981 |
+
"dev-main": "1.22-dev"
|
982 |
+
},
|
983 |
+
"thanks": {
|
984 |
+
"name": "symfony/polyfill",
|
985 |
+
"url": "https://github.com/symfony/polyfill"
|
986 |
+
}
|
987 |
+
},
|
988 |
+
"autoload": {
|
989 |
+
"psr-4": {
|
990 |
+
"Symfony\\Polyfill\\Php80\\": ""
|
991 |
+
},
|
992 |
+
"files": [
|
993 |
+
"bootstrap.php"
|
994 |
+
],
|
995 |
+
"classmap": [
|
996 |
+
"Resources/stubs"
|
997 |
+
]
|
998 |
+
},
|
999 |
+
"notification-url": "https://packagist.org/downloads/",
|
1000 |
+
"license": [
|
1001 |
+
"MIT"
|
1002 |
+
],
|
1003 |
+
"authors": [
|
1004 |
+
{
|
1005 |
+
"name": "Ion Bazan",
|
1006 |
+
"email": "ion.bazan@gmail.com"
|
1007 |
+
},
|
1008 |
+
{
|
1009 |
+
"name": "Nicolas Grekas",
|
1010 |
+
"email": "p@tchwork.com"
|
1011 |
+
},
|
1012 |
+
{
|
1013 |
+
"name": "Symfony Community",
|
1014 |
+
"homepage": "https://symfony.com/contributors"
|
1015 |
+
}
|
1016 |
+
],
|
1017 |
+
"description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
|
1018 |
+
"homepage": "https://symfony.com",
|
1019 |
+
"keywords": [
|
1020 |
+
"compatibility",
|
1021 |
+
"polyfill",
|
1022 |
+
"portable",
|
1023 |
+
"shim"
|
1024 |
+
],
|
1025 |
+
"funding": [
|
1026 |
+
{
|
1027 |
+
"url": "https://symfony.com/sponsor",
|
1028 |
+
"type": "custom"
|
1029 |
+
},
|
1030 |
+
{
|
1031 |
+
"url": "https://github.com/fabpot",
|
1032 |
+
"type": "github"
|
1033 |
+
},
|
1034 |
+
{
|
1035 |
+
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
1036 |
+
"type": "tidelift"
|
1037 |
+
}
|
1038 |
+
],
|
1039 |
+
"time": "2021-01-07T16:49:33+00:00"
|
1040 |
+
},
|
1041 |
+
{
|
1042 |
+
"name": "symfony/service-contracts",
|
1043 |
+
"version": "v2.2.0",
|
1044 |
+
"source": {
|
1045 |
+
"type": "git",
|
1046 |
+
"url": "https://github.com/symfony/service-contracts.git",
|
1047 |
+
"reference": "d15da7ba4957ffb8f1747218be9e1a121fd298a1"
|
1048 |
+
},
|
1049 |
+
"dist": {
|
1050 |
+
"type": "zip",
|
1051 |
+
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/d15da7ba4957ffb8f1747218be9e1a121fd298a1",
|
1052 |
+
"reference": "d15da7ba4957ffb8f1747218be9e1a121fd298a1",
|
1053 |
+
"shasum": ""
|
1054 |
+
},
|
1055 |
+
"require": {
|
1056 |
+
"php": ">=7.2.5",
|
1057 |
+
"psr/container": "^1.0"
|
1058 |
+
},
|
1059 |
+
"suggest": {
|
1060 |
+
"symfony/service-implementation": ""
|
1061 |
+
},
|
1062 |
+
"type": "library",
|
1063 |
+
"extra": {
|
1064 |
+
"branch-alias": {
|
1065 |
+
"dev-master": "2.2-dev"
|
1066 |
+
},
|
1067 |
+
"thanks": {
|
1068 |
+
"name": "symfony/contracts",
|
1069 |
+
"url": "https://github.com/symfony/contracts"
|
1070 |
+
}
|
1071 |
+
},
|
1072 |
+
"autoload": {
|
1073 |
+
"psr-4": {
|
1074 |
+
"Symfony\\Contracts\\Service\\": ""
|
1075 |
+
}
|
1076 |
+
},
|
1077 |
+
"notification-url": "https://packagist.org/downloads/",
|
1078 |
+
"license": [
|
1079 |
+
"MIT"
|
1080 |
+
],
|
1081 |
+
"authors": [
|
1082 |
+
{
|
1083 |
+
"name": "Nicolas Grekas",
|
1084 |
+
"email": "p@tchwork.com"
|
1085 |
+
},
|
1086 |
+
{
|
1087 |
+
"name": "Symfony Community",
|
1088 |
+
"homepage": "https://symfony.com/contributors"
|
1089 |
+
}
|
1090 |
+
],
|
1091 |
+
"description": "Generic abstractions related to writing services",
|
1092 |
+
"homepage": "https://symfony.com",
|
1093 |
+
"keywords": [
|
1094 |
+
"abstractions",
|
1095 |
+
"contracts",
|
1096 |
+
"decoupling",
|
1097 |
+
"interfaces",
|
1098 |
+
"interoperability",
|
1099 |
+
"standards"
|
1100 |
+
],
|
1101 |
+
"funding": [
|
1102 |
+
{
|
1103 |
+
"url": "https://symfony.com/sponsor",
|
1104 |
+
"type": "custom"
|
1105 |
+
},
|
1106 |
+
{
|
1107 |
+
"url": "https://github.com/fabpot",
|
1108 |
+
"type": "github"
|
1109 |
+
},
|
1110 |
+
{
|
1111 |
+
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
1112 |
+
"type": "tidelift"
|
1113 |
+
}
|
1114 |
+
],
|
1115 |
+
"time": "2020-09-07T11:33:47+00:00"
|
1116 |
+
},
|
1117 |
+
{
|
1118 |
+
"name": "symfony/string",
|
1119 |
+
"version": "v5.2.1",
|
1120 |
+
"source": {
|
1121 |
+
"type": "git",
|
1122 |
+
"url": "https://github.com/symfony/string.git",
|
1123 |
+
"reference": "5bd67751d2e3f7d6f770c9154b8fbcb2aa05f7ed"
|
1124 |
+
},
|
1125 |
+
"dist": {
|
1126 |
+
"type": "zip",
|
1127 |
+
"url": "https://api.github.com/repos/symfony/string/zipball/5bd67751d2e3f7d6f770c9154b8fbcb2aa05f7ed",
|
1128 |
+
"reference": "5bd67751d2e3f7d6f770c9154b8fbcb2aa05f7ed",
|
1129 |
+
"shasum": ""
|
1130 |
+
},
|
1131 |
+
"require": {
|
1132 |
+
"php": ">=7.2.5",
|
1133 |
+
"symfony/polyfill-ctype": "~1.8",
|
1134 |
+
"symfony/polyfill-intl-grapheme": "~1.0",
|
1135 |
+
"symfony/polyfill-intl-normalizer": "~1.0",
|
1136 |
+
"symfony/polyfill-mbstring": "~1.0",
|
1137 |
+
"symfony/polyfill-php80": "~1.15"
|
1138 |
+
},
|
1139 |
+
"require-dev": {
|
1140 |
+
"symfony/error-handler": "^4.4|^5.0",
|
1141 |
+
"symfony/http-client": "^4.4|^5.0",
|
1142 |
+
"symfony/translation-contracts": "^1.1|^2",
|
1143 |
+
"symfony/var-exporter": "^4.4|^5.0"
|
1144 |
+
},
|
1145 |
+
"type": "library",
|
1146 |
+
"autoload": {
|
1147 |
+
"psr-4": {
|
1148 |
+
"Symfony\\Component\\String\\": ""
|
1149 |
+
},
|
1150 |
+
"files": [
|
1151 |
+
"Resources/functions.php"
|
1152 |
+
],
|
1153 |
+
"exclude-from-classmap": [
|
1154 |
+
"/Tests/"
|
1155 |
+
]
|
1156 |
+
},
|
1157 |
+
"notification-url": "https://packagist.org/downloads/",
|
1158 |
+
"license": [
|
1159 |
+
"MIT"
|
1160 |
+
],
|
1161 |
+
"authors": [
|
1162 |
+
{
|
1163 |
+
"name": "Nicolas Grekas",
|
1164 |
+
"email": "p@tchwork.com"
|
1165 |
+
},
|
1166 |
+
{
|
1167 |
+
"name": "Symfony Community",
|
1168 |
+
"homepage": "https://symfony.com/contributors"
|
1169 |
+
}
|
1170 |
+
],
|
1171 |
+
"description": "Symfony String component",
|
1172 |
+
"homepage": "https://symfony.com",
|
1173 |
+
"keywords": [
|
1174 |
+
"grapheme",
|
1175 |
+
"i18n",
|
1176 |
+
"string",
|
1177 |
+
"unicode",
|
1178 |
+
"utf-8",
|
1179 |
+
"utf8"
|
1180 |
+
],
|
1181 |
+
"funding": [
|
1182 |
+
{
|
1183 |
+
"url": "https://symfony.com/sponsor",
|
1184 |
+
"type": "custom"
|
1185 |
+
},
|
1186 |
+
{
|
1187 |
+
"url": "https://github.com/fabpot",
|
1188 |
+
"type": "github"
|
1189 |
+
},
|
1190 |
+
{
|
1191 |
+
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
1192 |
+
"type": "tidelift"
|
1193 |
+
}
|
1194 |
+
],
|
1195 |
+
"time": "2020-12-05T07:33:16+00:00"
|
1196 |
+
}
|
1197 |
+
],
|
1198 |
"aliases": [],
|
1199 |
"minimum-stability": "stable",
|
1200 |
+
"stability-flags": {
|
1201 |
+
"coenjacobs/mozart": 10
|
1202 |
+
},
|
1203 |
"prefer-stable": false,
|
1204 |
"prefer-lowest": false,
|
1205 |
"platform": [],
|
1206 |
+
"platform-dev": [],
|
1207 |
+
"plugin-api-version": "1.1.0"
|
1208 |
}
|
addons/config/settings-config.php
CHANGED
@@ -43,12 +43,12 @@ class Settings_Config {
|
|
43 |
* @since 1.3.0
|
44 |
*/
|
45 |
public function add_submenu() {
|
46 |
-
/*add_submenu_page('cookiebot', 'Prior Consent',
|
47 |
$this,
|
48 |
'setting_page'
|
49 |
) );*/
|
50 |
|
51 |
-
add_submenu_page( 'cookiebot',
|
52 |
$this,
|
53 |
'setting_page'
|
54 |
) );
|
@@ -67,7 +67,7 @@ class Settings_Config {
|
|
67 |
|
68 |
wp_enqueue_script( 'cookiebot_tiptip_js', plugins_url( 'js/jquery.tipTip.js', dirname( __FILE__ ) ), array( 'jquery' ), '1.8', true );
|
69 |
wp_enqueue_script( 'cookiebot_addons_custom_js', plugins_url( 'js/settings.js', dirname( __FILE__ ) ), array( 'jquery' ), '1.8', true );
|
70 |
-
wp_localize_script( 'cookiebot_addons_custom_js', 'php', array( 'remove_link' => ' <a href="" class="submitdelete deletion">' .
|
71 |
wp_enqueue_style( 'cookiebot_addons_custom_css', plugins_url( 'style/css/admin_styles.css', dirname( __FILE__ ) ) );
|
72 |
}
|
73 |
|
@@ -223,7 +223,7 @@ class Settings_Config {
|
|
223 |
* @since 1.3.0
|
224 |
*/
|
225 |
public function header_jetpack_addon() {
|
226 |
-
echo '<p>' .
|
227 |
}
|
228 |
|
229 |
/**
|
@@ -245,11 +245,11 @@ class Settings_Config {
|
|
245 |
public function header_available_addons() {
|
246 |
?>
|
247 |
<p>
|
248 |
-
<?php
|
249 |
<br/>
|
250 |
-
<?php
|
251 |
<br/>
|
252 |
-
<?php
|
253 |
</p>
|
254 |
<?php
|
255 |
}
|
@@ -273,7 +273,7 @@ class Settings_Config {
|
|
273 |
* @since 1.3.0
|
274 |
*/
|
275 |
public function header_unavailable_addons() {
|
276 |
-
echo '<p>' .
|
277 |
}
|
278 |
|
279 |
/**
|
@@ -290,9 +290,9 @@ class Settings_Config {
|
|
290 |
<div class="postbox cookiebot-addon">
|
291 |
<i><?php
|
292 |
if ( ! $addon->is_addon_installed() ) {
|
293 |
-
|
294 |
} else if ( ! $addon->is_addon_activated() ) {
|
295 |
-
|
296 |
}
|
297 |
?></i>
|
298 |
</div>
|
43 |
* @since 1.3.0
|
44 |
*/
|
45 |
public function add_submenu() {
|
46 |
+
/*add_submenu_page('cookiebot', 'Prior Consent', esc_html__( 'Prior Consent', 'cookiebot' ), 'manage_options', 'cookiebot_addons', array(
|
47 |
$this,
|
48 |
'setting_page'
|
49 |
) );*/
|
50 |
|
51 |
+
add_submenu_page( 'cookiebot', esc_html__( 'Prior Consent', 'cookiebot' ), esc_html__( 'Prior Consent', 'cookiebot' ), 'manage_options', 'cookiebot-addons', array(
|
52 |
$this,
|
53 |
'setting_page'
|
54 |
) );
|
67 |
|
68 |
wp_enqueue_script( 'cookiebot_tiptip_js', plugins_url( 'js/jquery.tipTip.js', dirname( __FILE__ ) ), array( 'jquery' ), '1.8', true );
|
69 |
wp_enqueue_script( 'cookiebot_addons_custom_js', plugins_url( 'js/settings.js', dirname( __FILE__ ) ), array( 'jquery' ), '1.8', true );
|
70 |
+
wp_localize_script( 'cookiebot_addons_custom_js', 'php', array( 'remove_link' => ' <a href="" class="submitdelete deletion">' . esc_html__( 'Remove language', 'cookiebot-addons' ) . '</a>' ) );
|
71 |
wp_enqueue_style( 'cookiebot_addons_custom_css', plugins_url( 'style/css/admin_styles.css', dirname( __FILE__ ) ) );
|
72 |
}
|
73 |
|
223 |
* @since 1.3.0
|
224 |
*/
|
225 |
public function header_jetpack_addon() {
|
226 |
+
echo '<p>' . esc_html__( 'Jetpack settings.', 'cookiebot' ) . '</p>';
|
227 |
}
|
228 |
|
229 |
/**
|
245 |
public function header_available_addons() {
|
246 |
?>
|
247 |
<p>
|
248 |
+
<?php esc_html_e( 'Below is a list of addons for Cookiebot. Addons help you make installed plugins GDPR compliant.', 'cookiebot' ); ?>
|
249 |
<br/>
|
250 |
+
<?php esc_html_e( 'These addons are available because you have the corresponding plugins installed and activated.', 'cookiebot' ); ?>
|
251 |
<br/>
|
252 |
+
<?php esc_html_e( 'Deactivate an addon if you want to handle GDPR compliance yourself, or through another plugin.', 'cookiebot' ); ?>
|
253 |
</p>
|
254 |
<?php
|
255 |
}
|
273 |
* @since 1.3.0
|
274 |
*/
|
275 |
public function header_unavailable_addons() {
|
276 |
+
echo '<p>' . esc_html__( 'The following addons are unavailable. This is because the corresponding plugin is not installed.', 'cookiebot' ) . '</p>';
|
277 |
}
|
278 |
|
279 |
/**
|
290 |
<div class="postbox cookiebot-addon">
|
291 |
<i><?php
|
292 |
if ( ! $addon->is_addon_installed() ) {
|
293 |
+
esc_html_e( 'The plugin is not installed.', 'cookiebot' );
|
294 |
} else if ( ! $addon->is_addon_activated() ) {
|
295 |
+
esc_html_e( 'The plugin is not activated.', 'cookiebot' );
|
296 |
}
|
297 |
?></i>
|
298 |
</div>
|
addons/controller/addons/add-to-any/add-to-any.php
CHANGED
@@ -2,6 +2,9 @@
|
|
2 |
|
3 |
namespace cookiebot_addons\controller\addons\add_to_any;
|
4 |
|
|
|
|
|
|
|
5 |
use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
|
6 |
use cookiebot_addons\lib\Cookie_Consent_Interface;
|
7 |
use cookiebot_addons\lib\Settings_Service_Interface;
|
@@ -87,6 +90,49 @@ class Add_To_Any implements Cookiebot_Addons_Interface {
|
|
87 |
if ( has_action( 'wp_enqueue_scripts', 'A2A_SHARE_SAVE_enqueue_script' ) ) {
|
88 |
$this->script_loader_tag->add_tag( 'addtoany', $this->get_cookie_types() );
|
89 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
}
|
91 |
|
92 |
/**
|
@@ -248,7 +294,7 @@ class Add_To_Any implements Cookiebot_Addons_Interface {
|
|
248 |
* @since 1.8.0
|
249 |
*/
|
250 |
public function get_extra_information() {
|
251 |
-
return '<p>' .
|
252 |
}
|
253 |
|
254 |
/**
|
2 |
|
3 |
namespace cookiebot_addons\controller\addons\add_to_any;
|
4 |
|
5 |
+
use DOMDocument;
|
6 |
+
use DOMXPath;
|
7 |
+
use DOMElement;
|
8 |
use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
|
9 |
use cookiebot_addons\lib\Cookie_Consent_Interface;
|
10 |
use cookiebot_addons\lib\Settings_Service_Interface;
|
90 |
if ( has_action( 'wp_enqueue_scripts', 'A2A_SHARE_SAVE_enqueue_script' ) ) {
|
91 |
$this->script_loader_tag->add_tag( 'addtoany', $this->get_cookie_types() );
|
92 |
}
|
93 |
+
|
94 |
+
add_filter( 'the_content', array(
|
95 |
+
$this,
|
96 |
+
'cookiebot_addon_add_to_any_content',
|
97 |
+
), 1000 ); //Ensure it is executed as the last filter
|
98 |
+
|
99 |
+
add_filter( 'the_excerpt', array(
|
100 |
+
$this,
|
101 |
+
'cookiebot_addon_add_to_any_content',
|
102 |
+
), 1000 ); //Ensure it is executed as the last filter
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Display a placeholder on elements with "addtoany_share_save_container" class name.
|
107 |
+
*
|
108 |
+
* @param string $content
|
109 |
+
*
|
110 |
+
* @return string
|
111 |
+
*/
|
112 |
+
public function cookiebot_addon_add_to_any_content( $content ) {
|
113 |
+
if ( ! class_exists( 'DOMDocument' ) || ! class_exists( 'DOMXPath' ) || ! class_exists( 'DOMElement' ) ) {
|
114 |
+
return $content;
|
115 |
+
}
|
116 |
+
|
117 |
+
if ( $this->has_placeholder() && $this->is_placeholder_enabled() ) {
|
118 |
+
$dom = new DOMDocument();
|
119 |
+
$dom->loadHTML( $content );
|
120 |
+
$finder = new DOMXPath( $dom );
|
121 |
+
$nodes = $finder->query( "//*[contains(@class, 'addtoany_share_save_container')]" );
|
122 |
+
|
123 |
+
$placeholder = $this->get_placeholder();
|
124 |
+
$placeholder_element = $dom->createDocumentFragment();
|
125 |
+
$placeholder_element->appendXML( '<div class="' . cookiebot_addons_cookieconsent_optout( $this->get_cookie_types() ) . '">' . $placeholder . '</div>' );
|
126 |
+
|
127 |
+
foreach ( $nodes as $node ) {
|
128 |
+
/* @var DOMElement $node */
|
129 |
+
$node->appendChild( $placeholder_element );
|
130 |
+
}
|
131 |
+
|
132 |
+
$content = $dom->saveHTML();
|
133 |
+
}
|
134 |
+
|
135 |
+
return $content;
|
136 |
}
|
137 |
|
138 |
/**
|
294 |
* @since 1.8.0
|
295 |
*/
|
296 |
public function get_extra_information() {
|
297 |
+
return '<p>' . esc_html__( 'Blocks embedded videos from Youtube, Twitter, Vimeo and Facebook.', 'cookiebot-addons' ) . '</p>';
|
298 |
}
|
299 |
|
300 |
/**
|
addons/controller/addons/custom-facebook-feed-old/custom-facebook-feed-old.php
ADDED
@@ -0,0 +1,347 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace cookiebot_addons\controller\addons\custom_facebook_feed_old;
|
4 |
+
|
5 |
+
use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
|
6 |
+
use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
|
7 |
+
use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
|
8 |
+
use cookiebot_addons\lib\Cookie_Consent_Interface;
|
9 |
+
use cookiebot_addons\lib\Settings_Service_Interface;
|
10 |
+
|
11 |
+
class Custom_Facebook_Feed_Old implements Cookiebot_Addons_Interface {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var Settings_Service_Interface
|
15 |
+
*
|
16 |
+
* @since 1.3.0
|
17 |
+
*/
|
18 |
+
protected $settings;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @var Script_Loader_Tag_Interface
|
22 |
+
*
|
23 |
+
* @since 1.3.0
|
24 |
+
*/
|
25 |
+
protected $script_loader_tag;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @var Cookie_Consent_Interface
|
29 |
+
*
|
30 |
+
* @since 1.3.0
|
31 |
+
*/
|
32 |
+
public $cookie_consent;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @var Buffer_Output_Interface
|
36 |
+
*
|
37 |
+
* @since 1.3.0
|
38 |
+
*/
|
39 |
+
protected $buffer_output;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Jetpack constructor.
|
43 |
+
*
|
44 |
+
* @param $settings Settings_Service_Interface
|
45 |
+
* @param $script_loader_tag Script_Loader_Tag_Interface
|
46 |
+
* @param $cookie_consent Cookie_Consent_Interface
|
47 |
+
* @param $buffer_output Buffer_Output_Interface
|
48 |
+
*
|
49 |
+
* @since 1.2.0
|
50 |
+
*/
|
51 |
+
public function __construct( Settings_Service_Interface $settings, Script_Loader_Tag_Interface $script_loader_tag, Cookie_Consent_Interface $cookie_consent, Buffer_Output_Interface $buffer_output ) {
|
52 |
+
$this->settings = $settings;
|
53 |
+
$this->script_loader_tag = $script_loader_tag;
|
54 |
+
$this->cookie_consent = $cookie_consent;
|
55 |
+
$this->buffer_output = $buffer_output;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Loads addon configuration
|
60 |
+
*
|
61 |
+
* @since 1.3.0
|
62 |
+
*/
|
63 |
+
public function load_configuration() {
|
64 |
+
/**
|
65 |
+
* We add the action after wp_loaded and replace the original GA Google
|
66 |
+
* Analytics action with our own adjusted version.
|
67 |
+
*/
|
68 |
+
add_action( 'wp_loaded', array( $this, 'cookiebot_addon_custom_facebook_feed' ), 5 );
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Manipulate the scripts if they are loaded.
|
73 |
+
*
|
74 |
+
* @since 1.1.0
|
75 |
+
*/
|
76 |
+
public function cookiebot_addon_custom_facebook_feed() {
|
77 |
+
|
78 |
+
if ( has_action( 'wp_footer', 'cff_js' ) ) {
|
79 |
+
/**
|
80 |
+
* Consent not given - no cache
|
81 |
+
*/
|
82 |
+
$this->buffer_output->add_tag( 'wp_footer', 10, array( 'cfflinkhashtags' => $this->get_cookie_types() ), false );
|
83 |
+
}
|
84 |
+
|
85 |
+
// External js, so manipulate attributes
|
86 |
+
if ( has_action( 'wp_enqueue_scripts', 'cff_scripts_method' ) ) {
|
87 |
+
/**
|
88 |
+
* Consent not given - no cache
|
89 |
+
*/
|
90 |
+
$this->script_loader_tag->add_tag( 'cffscripts', $this->get_cookie_types(), false );
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Return addon/plugin name
|
96 |
+
*
|
97 |
+
* @return string
|
98 |
+
*
|
99 |
+
* @since 1.3.0
|
100 |
+
*/
|
101 |
+
public function get_addon_name() {
|
102 |
+
return 'Custom Facebook Feed (<= 2.17.1)';
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Option name in the database
|
107 |
+
*
|
108 |
+
* @return string
|
109 |
+
*
|
110 |
+
* @since 1.3.0
|
111 |
+
*/
|
112 |
+
public function get_option_name() {
|
113 |
+
return 'custom_facebook_feed';
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Plugin file name
|
118 |
+
*
|
119 |
+
* @return string
|
120 |
+
*
|
121 |
+
* @since 1.3.0
|
122 |
+
*/
|
123 |
+
public function get_plugin_file() {
|
124 |
+
return 'custom-facebook-feed/custom-facebook-feed.php';
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Returns checked cookie types
|
129 |
+
* @return mixed
|
130 |
+
*
|
131 |
+
* @since 1.3.0
|
132 |
+
*/
|
133 |
+
public function get_cookie_types() {
|
134 |
+
return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Returns default cookie types
|
139 |
+
* @return array
|
140 |
+
*
|
141 |
+
* @since 1.5.0
|
142 |
+
*/
|
143 |
+
public function get_default_cookie_types() {
|
144 |
+
return array( 'marketing' );
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Check if plugin is activated and checked in the backend
|
149 |
+
*
|
150 |
+
* @since 1.3.0
|
151 |
+
*/
|
152 |
+
public function is_addon_enabled() {
|
153 |
+
return $this->settings->is_addon_enabled( $this->get_option_name() );
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Checks if addon is installed
|
158 |
+
*
|
159 |
+
* @since 1.3.0
|
160 |
+
*/
|
161 |
+
public function is_addon_installed() {
|
162 |
+
$installed = $this->settings->is_addon_installed( $this->get_plugin_file() );
|
163 |
+
|
164 |
+
if ( $installed && version_compare( $this->get_addon_version(), '2.17.1', '>' ) ) {
|
165 |
+
$installed = false;
|
166 |
+
}
|
167 |
+
|
168 |
+
return $installed;
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Checks if addon is activated
|
173 |
+
*
|
174 |
+
* @since 1.3.0
|
175 |
+
*/
|
176 |
+
public function is_addon_activated() {
|
177 |
+
return $this->settings->is_addon_activated( $this->get_plugin_file() );
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Retrieves current installed version of the addon
|
182 |
+
*
|
183 |
+
* @return bool
|
184 |
+
*
|
185 |
+
* @since 2.2.1
|
186 |
+
*/
|
187 |
+
public function get_addon_version() {
|
188 |
+
return $this->settings->get_addon_version( $this->get_plugin_file() );
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Default placeholder content
|
193 |
+
*
|
194 |
+
* @return string
|
195 |
+
*
|
196 |
+
* @since 1.8.0
|
197 |
+
*/
|
198 |
+
public function get_default_placeholder() {
|
199 |
+
return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Get placeholder content
|
204 |
+
*
|
205 |
+
* This function will check following features:
|
206 |
+
* - Current language
|
207 |
+
*
|
208 |
+
* @param $src
|
209 |
+
*
|
210 |
+
* @return bool|mixed
|
211 |
+
*
|
212 |
+
* @since 1.8.0
|
213 |
+
*/
|
214 |
+
public function get_placeholder( $src = '' ) {
|
215 |
+
return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Checks if it does have custom placeholder content
|
220 |
+
*
|
221 |
+
* @return mixed
|
222 |
+
*
|
223 |
+
* @since 1.8.0
|
224 |
+
*/
|
225 |
+
public function has_placeholder() {
|
226 |
+
return $this->settings->has_placeholder( $this->get_option_name() );
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* returns all placeholder contents
|
231 |
+
*
|
232 |
+
* @return mixed
|
233 |
+
*
|
234 |
+
* @since 1.8.0
|
235 |
+
*/
|
236 |
+
public function get_placeholders() {
|
237 |
+
return $this->settings->get_placeholders( $this->get_option_name() );
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Return true if the placeholder is enabled
|
242 |
+
*
|
243 |
+
* @return mixed
|
244 |
+
*
|
245 |
+
* @since 1.8.0
|
246 |
+
*/
|
247 |
+
public function is_placeholder_enabled() {
|
248 |
+
return $this->settings->is_placeholder_enabled( $this->get_option_name() );
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Adds extra information under the label
|
253 |
+
*
|
254 |
+
* @return string
|
255 |
+
*
|
256 |
+
* @since 1.8.0
|
257 |
+
*/
|
258 |
+
public function get_extra_information() {
|
259 |
+
return false;
|
260 |
+
}
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
|
264 |
+
*
|
265 |
+
* @return string
|
266 |
+
*
|
267 |
+
* @since 1.8.0
|
268 |
+
*/
|
269 |
+
public function get_svn_url() {
|
270 |
+
return 'http://plugins.svn.wordpress.org/custom-facebook-feed/tags/2.17.1/custom-facebook-feed.php';
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Placeholder helper overlay in the settings page.
|
275 |
+
*
|
276 |
+
* @return string
|
277 |
+
*
|
278 |
+
* @since 1.8.0
|
279 |
+
*/
|
280 |
+
public function get_placeholder_helper() {
|
281 |
+
return '<p>Merge tags you can use in the placeholder text:</p><ul><li>%cookie_types - Lists required cookie types</li><li>[renew_consent]text[/renew_consent] - link to display cookie settings in frontend</li></ul>';
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Returns parent class or false
|
286 |
+
*
|
287 |
+
* @return string|bool
|
288 |
+
*
|
289 |
+
* @since 2.1.3
|
290 |
+
*/
|
291 |
+
public function get_parent_class() {
|
292 |
+
return get_parent_class( $this );
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Action after enabling the addon on the settings page
|
297 |
+
*
|
298 |
+
* @since 2.2.0
|
299 |
+
*/
|
300 |
+
public function post_hook_after_enabling() {
|
301 |
+
//do nothing
|
302 |
+
}
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Cookiebot plugin is deactivated
|
306 |
+
*
|
307 |
+
* @since 2.2.0
|
308 |
+
*/
|
309 |
+
public function plugin_deactivated() {
|
310 |
+
//do nothing
|
311 |
+
}
|
312 |
+
|
313 |
+
/**
|
314 |
+
* @return mixed
|
315 |
+
*
|
316 |
+
* @since 2.4.5
|
317 |
+
*/
|
318 |
+
public function extra_available_addon_option() {
|
319 |
+
//do nothing
|
320 |
+
}
|
321 |
+
|
322 |
+
/**
|
323 |
+
* Returns boolean to enable/disable plugin by default
|
324 |
+
*
|
325 |
+
* @return bool
|
326 |
+
*
|
327 |
+
* @since 3.6.3
|
328 |
+
*/
|
329 |
+
public function enable_by_default() {
|
330 |
+
return false;
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* Sets default settings for this addon
|
335 |
+
*
|
336 |
+
* @return array
|
337 |
+
*
|
338 |
+
* @since 3.6.3
|
339 |
+
*/
|
340 |
+
public function get_default_enable_setting() {
|
341 |
+
return array(
|
342 |
+
'enabled' => 1,
|
343 |
+
'cookie_type' => $this->get_default_cookie_types(),
|
344 |
+
'placeholder' => $this->get_default_placeholder(),
|
345 |
+
);
|
346 |
+
}
|
347 |
+
}
|
addons/controller/addons/custom-facebook-feed/custom-facebook-feed.php
CHANGED
@@ -3,93 +3,13 @@
|
|
3 |
namespace cookiebot_addons\controller\addons\custom_facebook_feed;
|
4 |
|
5 |
use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
|
|
|
6 |
use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
|
7 |
use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
|
8 |
use cookiebot_addons\lib\Cookie_Consent_Interface;
|
9 |
use cookiebot_addons\lib\Settings_Service_Interface;
|
10 |
|
11 |
-
class Custom_Facebook_Feed
|
12 |
-
|
13 |
-
/**
|
14 |
-
* @var Settings_Service_Interface
|
15 |
-
*
|
16 |
-
* @since 1.3.0
|
17 |
-
*/
|
18 |
-
protected $settings;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* @var Script_Loader_Tag_Interface
|
22 |
-
*
|
23 |
-
* @since 1.3.0
|
24 |
-
*/
|
25 |
-
protected $script_loader_tag;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* @var Cookie_Consent_Interface
|
29 |
-
*
|
30 |
-
* @since 1.3.0
|
31 |
-
*/
|
32 |
-
public $cookie_consent;
|
33 |
-
|
34 |
-
/**
|
35 |
-
* @var Buffer_Output_Interface
|
36 |
-
*
|
37 |
-
* @since 1.3.0
|
38 |
-
*/
|
39 |
-
protected $buffer_output;
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Jetpack constructor.
|
43 |
-
*
|
44 |
-
* @param $settings Settings_Service_Interface
|
45 |
-
* @param $script_loader_tag Script_Loader_Tag_Interface
|
46 |
-
* @param $cookie_consent Cookie_Consent_Interface
|
47 |
-
* @param $buffer_output Buffer_Output_Interface
|
48 |
-
*
|
49 |
-
* @since 1.2.0
|
50 |
-
*/
|
51 |
-
public function __construct( Settings_Service_Interface $settings, Script_Loader_Tag_Interface $script_loader_tag, Cookie_Consent_Interface $cookie_consent, Buffer_Output_Interface $buffer_output ) {
|
52 |
-
$this->settings = $settings;
|
53 |
-
$this->script_loader_tag = $script_loader_tag;
|
54 |
-
$this->cookie_consent = $cookie_consent;
|
55 |
-
$this->buffer_output = $buffer_output;
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Loads addon configuration
|
60 |
-
*
|
61 |
-
* @since 1.3.0
|
62 |
-
*/
|
63 |
-
public function load_configuration() {
|
64 |
-
/**
|
65 |
-
* We add the action after wp_loaded and replace the original GA Google
|
66 |
-
* Analytics action with our own adjusted version.
|
67 |
-
*/
|
68 |
-
add_action( 'wp_loaded', array( $this, 'cookiebot_addon_custom_facebook_feed' ), 5 );
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Manipulate the scripts if they are loaded.
|
73 |
-
*
|
74 |
-
* @since 1.1.0
|
75 |
-
*/
|
76 |
-
public function cookiebot_addon_custom_facebook_feed() {
|
77 |
-
|
78 |
-
if ( has_action( 'wp_footer', 'cff_js' ) ) {
|
79 |
-
/**
|
80 |
-
* Consent not given - no cache
|
81 |
-
*/
|
82 |
-
$this->buffer_output->add_tag( 'wp_footer', 10, array( 'cfflinkhashtags' => $this->get_cookie_types() ), false );
|
83 |
-
}
|
84 |
-
|
85 |
-
// External js, so manipulate attributes
|
86 |
-
if ( has_action( 'wp_enqueue_scripts', 'cff_scripts_method' ) ) {
|
87 |
-
/**
|
88 |
-
* Consent not given - no cache
|
89 |
-
*/
|
90 |
-
$this->script_loader_tag->add_tag( 'cffscripts', $this->get_cookie_types(), false );
|
91 |
-
}
|
92 |
-
}
|
93 |
|
94 |
/**
|
95 |
* Return addon/plugin name
|
@@ -102,155 +22,19 @@ class Custom_Facebook_Feed implements Cookiebot_Addons_Interface {
|
|
102 |
return 'Custom Facebook Feed';
|
103 |
}
|
104 |
|
105 |
-
/**
|
106 |
-
* Option name in the database
|
107 |
-
*
|
108 |
-
* @return string
|
109 |
-
*
|
110 |
-
* @since 1.3.0
|
111 |
-
*/
|
112 |
-
public function get_option_name() {
|
113 |
-
return 'custom_facebook_feed';
|
114 |
-
}
|
115 |
-
|
116 |
-
/**
|
117 |
-
* Plugin file name
|
118 |
-
*
|
119 |
-
* @return string
|
120 |
-
*
|
121 |
-
* @since 1.3.0
|
122 |
-
*/
|
123 |
-
public function get_plugin_file() {
|
124 |
-
return 'custom-facebook-feed/custom-facebook-feed.php';
|
125 |
-
}
|
126 |
-
|
127 |
-
/**
|
128 |
-
* Returns checked cookie types
|
129 |
-
* @return mixed
|
130 |
-
*
|
131 |
-
* @since 1.3.0
|
132 |
-
*/
|
133 |
-
public function get_cookie_types() {
|
134 |
-
return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
|
135 |
-
}
|
136 |
-
|
137 |
-
/**
|
138 |
-
* Returns default cookie types
|
139 |
-
* @return array
|
140 |
-
*
|
141 |
-
* @since 1.5.0
|
142 |
-
*/
|
143 |
-
public function get_default_cookie_types() {
|
144 |
-
return array( 'marketing' );
|
145 |
-
}
|
146 |
-
|
147 |
-
/**
|
148 |
-
* Check if plugin is activated and checked in the backend
|
149 |
-
*
|
150 |
-
* @since 1.3.0
|
151 |
-
*/
|
152 |
-
public function is_addon_enabled() {
|
153 |
-
return $this->settings->is_addon_enabled( $this->get_option_name() );
|
154 |
-
}
|
155 |
-
|
156 |
/**
|
157 |
* Checks if addon is installed
|
158 |
*
|
159 |
* @since 1.3.0
|
160 |
*/
|
161 |
public function is_addon_installed() {
|
162 |
-
|
163 |
-
}
|
164 |
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
* @since 1.3.0
|
169 |
-
*/
|
170 |
-
public function is_addon_activated() {
|
171 |
-
return $this->settings->is_addon_activated( $this->get_plugin_file() );
|
172 |
-
}
|
173 |
|
174 |
-
|
175 |
-
* Retrieves current installed version of the addon
|
176 |
-
*
|
177 |
-
* @return bool
|
178 |
-
*
|
179 |
-
* @since 2.2.1
|
180 |
-
*/
|
181 |
-
public function get_addon_version() {
|
182 |
-
return $this->settings->get_addon_version( $this->get_plugin_file() );
|
183 |
-
}
|
184 |
-
|
185 |
-
/**
|
186 |
-
* Default placeholder content
|
187 |
-
*
|
188 |
-
* @return string
|
189 |
-
*
|
190 |
-
* @since 1.8.0
|
191 |
-
*/
|
192 |
-
public function get_default_placeholder() {
|
193 |
-
return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
|
194 |
-
}
|
195 |
-
|
196 |
-
/**
|
197 |
-
* Get placeholder content
|
198 |
-
*
|
199 |
-
* This function will check following features:
|
200 |
-
* - Current language
|
201 |
-
*
|
202 |
-
* @param $src
|
203 |
-
*
|
204 |
-
* @return bool|mixed
|
205 |
-
*
|
206 |
-
* @since 1.8.0
|
207 |
-
*/
|
208 |
-
public function get_placeholder( $src = '' ) {
|
209 |
-
return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
|
210 |
-
}
|
211 |
-
|
212 |
-
/**
|
213 |
-
* Checks if it does have custom placeholder content
|
214 |
-
*
|
215 |
-
* @return mixed
|
216 |
-
*
|
217 |
-
* @since 1.8.0
|
218 |
-
*/
|
219 |
-
public function has_placeholder() {
|
220 |
-
return $this->settings->has_placeholder( $this->get_option_name() );
|
221 |
-
}
|
222 |
-
|
223 |
-
/**
|
224 |
-
* returns all placeholder contents
|
225 |
-
*
|
226 |
-
* @return mixed
|
227 |
-
*
|
228 |
-
* @since 1.8.0
|
229 |
-
*/
|
230 |
-
public function get_placeholders() {
|
231 |
-
return $this->settings->get_placeholders( $this->get_option_name() );
|
232 |
-
}
|
233 |
-
|
234 |
-
/**
|
235 |
-
* Return true if the placeholder is enabled
|
236 |
-
*
|
237 |
-
* @return mixed
|
238 |
-
*
|
239 |
-
* @since 1.8.0
|
240 |
-
*/
|
241 |
-
public function is_placeholder_enabled() {
|
242 |
-
return $this->settings->is_placeholder_enabled( $this->get_option_name() );
|
243 |
-
}
|
244 |
-
|
245 |
-
/**
|
246 |
-
* Adds extra information under the label
|
247 |
-
*
|
248 |
-
* @return string
|
249 |
-
*
|
250 |
-
* @since 1.8.0
|
251 |
-
*/
|
252 |
-
public function get_extra_information() {
|
253 |
-
return false;
|
254 |
}
|
255 |
|
256 |
/**
|
@@ -264,78 +48,31 @@ class Custom_Facebook_Feed implements Cookiebot_Addons_Interface {
|
|
264 |
return 'http://plugins.svn.wordpress.org/custom-facebook-feed/trunk/custom-facebook-feed.php';
|
265 |
}
|
266 |
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
|
278 |
-
/**
|
279 |
-
* Returns parent class or false
|
280 |
-
*
|
281 |
-
* @return string|bool
|
282 |
-
*
|
283 |
-
* @since 2.1.3
|
284 |
-
*/
|
285 |
-
public function get_parent_class() {
|
286 |
-
return get_parent_class( $this );
|
287 |
-
}
|
288 |
-
|
289 |
-
/**
|
290 |
-
* Action after enabling the addon on the settings page
|
291 |
-
*
|
292 |
-
* @since 2.2.0
|
293 |
-
*/
|
294 |
-
public function post_hook_after_enabling() {
|
295 |
-
//do nothing
|
296 |
-
}
|
297 |
-
|
298 |
-
/**
|
299 |
-
* Cookiebot plugin is deactivated
|
300 |
-
*
|
301 |
-
* @since 2.2.0
|
302 |
-
*/
|
303 |
-
public function plugin_deactivated() {
|
304 |
-
//do nothing
|
305 |
-
}
|
306 |
-
|
307 |
-
/**
|
308 |
-
* @return mixed
|
309 |
-
*
|
310 |
-
* @since 2.4.5
|
311 |
-
*/
|
312 |
-
public function extra_available_addon_option() {
|
313 |
-
//do nothing
|
314 |
-
}
|
315 |
-
|
316 |
-
/**
|
317 |
-
* Returns boolean to enable/disable plugin by default
|
318 |
-
*
|
319 |
-
* @return bool
|
320 |
-
*
|
321 |
-
* @since 3.6.3
|
322 |
-
*/
|
323 |
-
public function enable_by_default() {
|
324 |
-
return false;
|
325 |
-
}
|
326 |
-
|
327 |
-
/**
|
328 |
-
* Sets default settings for this addon
|
329 |
-
*
|
330 |
-
* @return array
|
331 |
-
*
|
332 |
-
* @since 3.6.3
|
333 |
-
*/
|
334 |
-
public function get_default_enable_setting() {
|
335 |
-
return array(
|
336 |
-
'enabled' => 1,
|
337 |
-
'cookie_type' => $this->get_default_cookie_types(),
|
338 |
-
'placeholder' => $this->get_default_placeholder(),
|
339 |
-
);
|
340 |
-
}
|
341 |
}
|
3 |
namespace cookiebot_addons\controller\addons\custom_facebook_feed;
|
4 |
|
5 |
use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
|
6 |
+
use cookiebot_addons\controller\addons\custom_facebook_feed_old\Custom_Facebook_Feed_Old;
|
7 |
use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
|
8 |
use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
|
9 |
use cookiebot_addons\lib\Cookie_Consent_Interface;
|
10 |
use cookiebot_addons\lib\Settings_Service_Interface;
|
11 |
|
12 |
+
class Custom_Facebook_Feed extends Custom_Facebook_Feed_Old {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
/**
|
15 |
* Return addon/plugin name
|
22 |
return 'Custom Facebook Feed';
|
23 |
}
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
/**
|
26 |
* Checks if addon is installed
|
27 |
*
|
28 |
* @since 1.3.0
|
29 |
*/
|
30 |
public function is_addon_installed() {
|
31 |
+
$installed = $this->settings->is_addon_installed( $this->get_plugin_file() );
|
|
|
32 |
|
33 |
+
if ( $installed && version_compare( $this->get_addon_version(), '2.17.1', '<=' ) ) {
|
34 |
+
$installed = false;
|
35 |
+
}
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
+
return $installed;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
}
|
39 |
|
40 |
/**
|
48 |
return 'http://plugins.svn.wordpress.org/custom-facebook-feed/trunk/custom-facebook-feed.php';
|
49 |
}
|
50 |
|
51 |
+
/**
|
52 |
+
* Manipulate the scripts if they are loaded.
|
53 |
+
*
|
54 |
+
* @since 1.1.0
|
55 |
+
*/
|
56 |
+
public function cookiebot_addon_custom_facebook_feed() {
|
57 |
+
|
58 |
+
if(class_exists("\CustomFacebookFeed\Custom_Facebook_Feed")) {
|
59 |
+
$instance = \CustomFacebookFeed\Custom_Facebook_Feed::instance();
|
60 |
+
|
61 |
+
if ( has_action( 'wp_footer', array($instance, 'cff_js') ) ) {
|
62 |
+
/**
|
63 |
+
* Consent not given - no cache
|
64 |
+
*/
|
65 |
+
$this->buffer_output->add_tag( 'wp_footer', 10, array( 'cfflinkhashtags' => $this->get_cookie_types() ), false );
|
66 |
+
}
|
67 |
+
|
68 |
+
// External js, so manipulate attributes
|
69 |
+
if ( has_action( 'wp_enqueue_scripts', array($instance, 'enqueue_scripts_assets') ) ) {
|
70 |
+
/**
|
71 |
+
* Consent not given - no cache
|
72 |
+
*/
|
73 |
+
$this->script_loader_tag->add_tag( 'cffscripts', $this->get_cookie_types(), false );
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
}
|
addons/controller/addons/embed-autocorrect/embed-autocorrect.php
CHANGED
@@ -129,7 +129,9 @@ class Embed_Autocorrect implements Cookiebot_Addons_Interface {
|
|
129 |
$this->get_cookie_types() ); ?>) {
|
130 |
jQuery( '.wp-video-shortcode__disabled' ).addClass( 'wp-video-shortcode' ).removeClass( 'wp-video-shortcode__disabled' );
|
131 |
jQuery( '.wp-audio-shortcode__disabled' ).addClass( 'wp-audio-shortcode' ).removeClass( 'wp-audio-shortcode__disabled' );
|
132 |
-
window.wp.mediaelement.initialize
|
|
|
|
|
133 |
}
|
134 |
}, false );
|
135 |
</script><?php
|
@@ -257,7 +259,7 @@ class Embed_Autocorrect implements Cookiebot_Addons_Interface {
|
|
257 |
}
|
258 |
|
259 |
unset( $matches );
|
260 |
-
preg_match_all( '/<script.*(instagram|issuu|imgur|polldaddy|tumblr)+.*<\/script>/mi', $content, $matches );
|
261 |
foreach ( $matches[0] as $x => $match ) {
|
262 |
//Replace - and add cookie consent notice.
|
263 |
$adjusted = str_replace( ' src=',
|
@@ -282,7 +284,6 @@ class Embed_Autocorrect implements Cookiebot_Addons_Interface {
|
|
282 |
}
|
283 |
unset( $matches );
|
284 |
|
285 |
-
|
286 |
return $content;
|
287 |
}
|
288 |
|
@@ -354,7 +355,7 @@ class Embed_Autocorrect implements Cookiebot_Addons_Interface {
|
|
354 |
* @return string
|
355 |
*/
|
356 |
public function generate_placeholder_with_src( $src = '' ) {
|
357 |
-
$cookieContentNotice = '<div class="
|
358 |
$cookieContentNotice .= $this->get_placeholder( $src );
|
359 |
$cookieContentNotice .= '</div>';
|
360 |
|
@@ -521,7 +522,7 @@ class Embed_Autocorrect implements Cookiebot_Addons_Interface {
|
|
521 |
* @since 1.8.0
|
522 |
*/
|
523 |
public function get_extra_information() {
|
524 |
-
return '<p>' .
|
525 |
'cookiebot-addons' ) . '</p>';
|
526 |
}
|
527 |
|
@@ -598,7 +599,7 @@ class Embed_Autocorrect implements Cookiebot_Addons_Interface {
|
|
598 |
*/
|
599 |
private function get_default_regex() {
|
600 |
return apply_filters( 'cookiebot_embed_default_regex',
|
601 |
-
'/<iframe[^>]* src=("|\').*(facebook\.com|youtu\.be|youtube\.com|youtube-nocookie\.com|player\.vimeo\.com).*[^>].*>.*?<\/iframe>/mi' );
|
602 |
}
|
603 |
|
604 |
/**
|
@@ -620,13 +621,13 @@ class Embed_Autocorrect implements Cookiebot_Addons_Interface {
|
|
620 |
public function extra_available_addon_option() {
|
621 |
?>
|
622 |
<div class="show_advanced_options">
|
623 |
-
<button class="button button-secondary"><?php
|
624 |
<span class="help-tip"
|
625 |
-
title="<?php echo
|
626 |
</div>
|
627 |
<div class="advanced_options">
|
628 |
|
629 |
-
<label for="embed_regex"><?php
|
630 |
<textarea
|
631 |
id="embed_regex"
|
632 |
cols="80"
|
@@ -636,14 +637,14 @@ class Embed_Autocorrect implements Cookiebot_Addons_Interface {
|
|
636 |
><?php echo esc_html( $this->get_regex() ); ?></textarea>
|
637 |
|
638 |
<?php if ( $this->is_regex_default() ) : ?>
|
639 |
-
<button id="edit_embed_regex" class="button"><?php
|
640 |
<?php endif; ?>
|
641 |
|
642 |
<button
|
643 |
id="btn_default_embed_regex"
|
644 |
class="button<?php echo ( $this->is_regex_default() ) ? ' hidden' : ''; ?>"
|
645 |
type="button"
|
646 |
-
value="Reset to default regex"><?php
|
647 |
<input
|
648 |
type="hidden"
|
649 |
name="default_embed_regex"
|
129 |
$this->get_cookie_types() ); ?>) {
|
130 |
jQuery( '.wp-video-shortcode__disabled' ).addClass( 'wp-video-shortcode' ).removeClass( 'wp-video-shortcode__disabled' );
|
131 |
jQuery( '.wp-audio-shortcode__disabled' ).addClass( 'wp-audio-shortcode' ).removeClass( 'wp-audio-shortcode__disabled' );
|
132 |
+
if (window.wp && window.wp.mediaelement && window.wp.mediaelement.initialize) {
|
133 |
+
window.wp.mediaelement.initialize();
|
134 |
+
}
|
135 |
}
|
136 |
}, false );
|
137 |
</script><?php
|
259 |
}
|
260 |
|
261 |
unset( $matches );
|
262 |
+
preg_match_all( '/<script.*(instagram|twitter|issuu|imgur|redditmedia\.com|tiktok\.com|polldaddy|tumblr)+.*<\/script>/mi', $content, $matches );
|
263 |
foreach ( $matches[0] as $x => $match ) {
|
264 |
//Replace - and add cookie consent notice.
|
265 |
$adjusted = str_replace( ' src=',
|
284 |
}
|
285 |
unset( $matches );
|
286 |
|
|
|
287 |
return $content;
|
288 |
}
|
289 |
|
355 |
* @return string
|
356 |
*/
|
357 |
public function generate_placeholder_with_src( $src = '' ) {
|
358 |
+
$cookieContentNotice = '<div class="' . cookiebot_addons_cookieconsent_optout( $this->get_cookie_types() ) . '">';
|
359 |
$cookieContentNotice .= $this->get_placeholder( $src );
|
360 |
$cookieContentNotice .= '</div>';
|
361 |
|
522 |
* @since 1.8.0
|
523 |
*/
|
524 |
public function get_extra_information() {
|
525 |
+
return '<p>' . esc_html__( 'Blocks embedded videos from Youtube, Twitter, Vimeo and Facebook.',
|
526 |
'cookiebot-addons' ) . '</p>';
|
527 |
}
|
528 |
|
599 |
*/
|
600 |
private function get_default_regex() {
|
601 |
return apply_filters( 'cookiebot_embed_default_regex',
|
602 |
+
'/<iframe[^>]* src=("|\').*(facebook\.com|youtu\.be|youtube\.com|youtube-nocookie\.com|player\.vimeo\.com|soundcloud\.com|spotify\.com|speakerdeck\.com|slideshare\.net|screencast\.com|reverbnation\.com|mixcloud\.com|cloudup\.com|animoto\.com|video\.wordpress\.com|embed\.ted\.com|embedly\.com|kickstarter\.com).*[^>].*>.*?<\/iframe>/mi' );
|
603 |
}
|
604 |
|
605 |
/**
|
621 |
public function extra_available_addon_option() {
|
622 |
?>
|
623 |
<div class="show_advanced_options">
|
624 |
+
<button class="button button-secondary"><?php esc_html_e( 'Show advanced options', 'cookiebot-addons' ); ?></button>
|
625 |
<span class="help-tip"
|
626 |
+
title="<?php echo esc_html__( 'This is for more advanced users.', 'cookiebot-addons' ); ?>"></span>
|
627 |
</div>
|
628 |
<div class="advanced_options">
|
629 |
|
630 |
+
<label for="embed_regex"><?php esc_html_e( 'Regex:', 'cookiebot-addons' ); ?></label>
|
631 |
<textarea
|
632 |
id="embed_regex"
|
633 |
cols="80"
|
637 |
><?php echo esc_html( $this->get_regex() ); ?></textarea>
|
638 |
|
639 |
<?php if ( $this->is_regex_default() ) : ?>
|
640 |
+
<button id="edit_embed_regex" class="button"><?php esc_html_e( 'Edit regex', 'cookiebot-addons' ); ?></button>
|
641 |
<?php endif; ?>
|
642 |
|
643 |
<button
|
644 |
id="btn_default_embed_regex"
|
645 |
class="button<?php echo ( $this->is_regex_default() ) ? ' hidden' : ''; ?>"
|
646 |
type="button"
|
647 |
+
value="Reset to default regex"><?php esc_html_e( 'Reset to default regex', 'cookiebot-addons' ); ?></button>
|
648 |
<input
|
649 |
type="hidden"
|
650 |
name="default_embed_regex"
|
addons/controller/addons/enfold/enfold.php
ADDED
@@ -0,0 +1,326 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace cookiebot_addons\controller\addons\enfold;
|
4 |
+
|
5 |
+
use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
|
6 |
+
use cookiebot_addons\lib\Cookie_Consent_Interface;
|
7 |
+
use cookiebot_addons\lib\Settings_Service_Interface;
|
8 |
+
use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
|
9 |
+
use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
|
10 |
+
|
11 |
+
class Enfold implements Cookiebot_Addons_Interface {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var Settings_Service_Interface
|
15 |
+
*
|
16 |
+
* @since 1.3.0
|
17 |
+
*/
|
18 |
+
protected $settings;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @var Script_Loader_Tag_Interface
|
22 |
+
*
|
23 |
+
* @since 1.3.0
|
24 |
+
*/
|
25 |
+
protected $script_loader_tag;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @var Cookie_Consent_Interface
|
29 |
+
*
|
30 |
+
* @since 1.3.0
|
31 |
+
*/
|
32 |
+
public $cookie_consent;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @var Buffer_Output_Interface
|
36 |
+
*
|
37 |
+
* @since 1.3.0
|
38 |
+
*/
|
39 |
+
protected $buffer_output;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Jetpack constructor.
|
43 |
+
*
|
44 |
+
* @param $settings Settings_Service_Interface
|
45 |
+
* @param $script_loader_tag Script_Loader_Tag_Interface
|
46 |
+
* @param $cookie_consent Cookie_Consent_Interface
|
47 |
+
* @param $buffer_output Buffer_Output_Interface
|
48 |
+
*
|
49 |
+
* @since 1.3.0
|
50 |
+
*/
|
51 |
+
public function __construct( Settings_Service_Interface $settings, Script_Loader_Tag_Interface $script_loader_tag, Cookie_Consent_Interface $cookie_consent, Buffer_Output_Interface $buffer_output ) {
|
52 |
+
$this->settings = $settings;
|
53 |
+
$this->script_loader_tag = $script_loader_tag;
|
54 |
+
$this->cookie_consent = $cookie_consent;
|
55 |
+
$this->buffer_output = $buffer_output;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Loads addon configuration
|
60 |
+
*
|
61 |
+
* @since 1.3.0
|
62 |
+
*/
|
63 |
+
public function load_configuration() {
|
64 |
+
add_action( 'wp_loaded', array( $this, 'cookiebot_addon_enfold' ), 10 );
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Disable scripts if state not accepted
|
69 |
+
*
|
70 |
+
* @since 1.3.0
|
71 |
+
*/
|
72 |
+
public function cookiebot_addon_enfold() {
|
73 |
+
$this->buffer_output->add_tag( 'wp_footer', 10000, array(
|
74 |
+
'google_analytics_script' => $this->get_cookie_types()
|
75 |
+
) );
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Return addon/plugin name
|
80 |
+
*
|
81 |
+
* @return string
|
82 |
+
*
|
83 |
+
* @since 1.3.0
|
84 |
+
*/
|
85 |
+
public function get_addon_name() {
|
86 |
+
return 'Enfold';
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Default placeholder content
|
91 |
+
*
|
92 |
+
* @return string
|
93 |
+
*
|
94 |
+
* @since 1.8.0
|
95 |
+
*/
|
96 |
+
public function get_default_placeholder() {
|
97 |
+
return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to enable Google Services.';
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Get placeholder content
|
102 |
+
*
|
103 |
+
* This function will check following features:
|
104 |
+
* - Current language
|
105 |
+
*
|
106 |
+
* @param $src
|
107 |
+
*
|
108 |
+
* @return bool|mixed
|
109 |
+
*
|
110 |
+
* @since 1.8.0
|
111 |
+
*/
|
112 |
+
public function get_placeholder( $src = '' ) {
|
113 |
+
return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Option name in the database
|
118 |
+
*
|
119 |
+
* @return string
|
120 |
+
*
|
121 |
+
* @since 1.3.0
|
122 |
+
*/
|
123 |
+
public function get_option_name() {
|
124 |
+
return 'enfold';
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Plugin file name
|
129 |
+
*
|
130 |
+
* @return string
|
131 |
+
*
|
132 |
+
* @since 1.3.0
|
133 |
+
*/
|
134 |
+
public function get_plugin_file() {
|
135 |
+
return '';
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Returns checked cookie types
|
140 |
+
* @return mixed
|
141 |
+
*
|
142 |
+
* @since 1.3.0
|
143 |
+
*/
|
144 |
+
public function get_cookie_types() {
|
145 |
+
return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Returns default cookie types
|
150 |
+
* @return array
|
151 |
+
*
|
152 |
+
* @since 1.5.0
|
153 |
+
*/
|
154 |
+
public function get_default_cookie_types() {
|
155 |
+
return array( 'marketing', 'statistics' );
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Check if plugin is activated and checked in the backend
|
160 |
+
*
|
161 |
+
* @since 1.3.0
|
162 |
+
*/
|
163 |
+
public function is_addon_enabled() {
|
164 |
+
return $this->settings->is_addon_enabled( $this->get_option_name() );
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Checks if addon is installed
|
169 |
+
*
|
170 |
+
* @since 1.3.0
|
171 |
+
*/
|
172 |
+
public function is_addon_installed() {
|
173 |
+
return $this->settings->is_addon_installed( $this->get_option_name() );
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Checks if addon is activated
|
178 |
+
*
|
179 |
+
* @since 1.3.0
|
180 |
+
*/
|
181 |
+
public function is_addon_activated() {
|
182 |
+
return $this->settings->is_addon_activated( $this->get_option_name() );
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Retrieves current installed version of the addon
|
187 |
+
*
|
188 |
+
* @return bool
|
189 |
+
*
|
190 |
+
* @since 2.2.1
|
191 |
+
*/
|
192 |
+
public function get_addon_version() {
|
193 |
+
return $this->settings->get_addon_version( $this->get_option_name() );
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Checks if it does have custom placeholder content
|
198 |
+
*
|
199 |
+
* @return mixed
|
200 |
+
*
|
201 |
+
* @since 1.8.0
|
202 |
+
*/
|
203 |
+
public function has_placeholder() {
|
204 |
+
return $this->settings->has_placeholder( $this->get_option_name() );
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* returns all placeholder contents
|
209 |
+
*
|
210 |
+
* @return mixed
|
211 |
+
*
|
212 |
+
* @since 1.8.0
|
213 |
+
*/
|
214 |
+
public function get_placeholders() {
|
215 |
+
return $this->settings->get_placeholders( $this->get_option_name() );
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Return true if the placeholder is enabled
|
220 |
+
*
|
221 |
+
* @return mixed
|
222 |
+
*
|
223 |
+
* @since 1.8.0
|
224 |
+
*/
|
225 |
+
public function is_placeholder_enabled() {
|
226 |
+
return $this->settings->is_placeholder_enabled( $this->get_option_name() );
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Adds extra information under the label
|
231 |
+
*
|
232 |
+
* @return string
|
233 |
+
*
|
234 |
+
* @since 1.8.0
|
235 |
+
*/
|
236 |
+
public function get_extra_information() {
|
237 |
+
return '<p>' . __( 'Blocks cookies created by Enfold theme\'s Google Services.', 'cookiebot-addons' ) . '</p>';
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
|
242 |
+
*
|
243 |
+
* @return string
|
244 |
+
*
|
245 |
+
* @since 1.8.0
|
246 |
+
*/
|
247 |
+
public function get_svn_url() {
|
248 |
+
return ''; // Premium theme doesn't have this
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Placeholder helper overlay in the settings page.
|
253 |
+
*
|
254 |
+
* @return string
|
255 |
+
*
|
256 |
+
* @since 1.8.0
|
257 |
+
*/
|
258 |
+
public function get_placeholder_helper() {
|
259 |
+
return '<p>Merge tags you can use in the placeholder text:</p><ul><li>%cookie_types - Lists required cookie types</li><li>[renew_consent]text[/renew_consent] - link to display cookie settings in frontend</li></ul>';
|
260 |
+
}
|
261 |
+
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Returns parent class or false
|
265 |
+
*
|
266 |
+
* @return string|bool
|
267 |
+
*
|
268 |
+
* @since 2.1.3
|
269 |
+
*/
|
270 |
+
public function get_parent_class() {
|
271 |
+
return get_parent_class( $this );
|
272 |
+
}
|
273 |
+
|
274 |
+
/**
|
275 |
+
* Action after enabling the addon on the settings page
|
276 |
+
*
|
277 |
+
* @since 2.2.0
|
278 |
+
*/
|
279 |
+
public function post_hook_after_enabling() {
|
280 |
+
//do nothing
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Cookiebot plugin is deactivated
|
285 |
+
*
|
286 |
+
* @since 2.2.0
|
287 |
+
*/
|
288 |
+
public function plugin_deactivated() {
|
289 |
+
//do nothing
|
290 |
+
}
|
291 |
+
|
292 |
+
/**
|
293 |
+
* @return mixed
|
294 |
+
*
|
295 |
+
* @since 2.4.5
|
296 |
+
*/
|
297 |
+
public function extra_available_addon_option() {
|
298 |
+
//do nothing
|
299 |
+
}
|
300 |
+
|
301 |
+
/**
|
302 |
+
* Returns boolean to enable/disable plugin by default
|
303 |
+
*
|
304 |
+
* @return bool
|
305 |
+
*
|
306 |
+
* @since 3.6.3
|
307 |
+
*/
|
308 |
+
public function enable_by_default() {
|
309 |
+
return false;
|
310 |
+
}
|
311 |
+
|
312 |
+
/**
|
313 |
+
* Sets default settings for this addon
|
314 |
+
*
|
315 |
+
* @return array
|
316 |
+
*
|
317 |
+
* @since 3.6.3
|
318 |
+
*/
|
319 |
+
public function get_default_enable_setting() {
|
320 |
+
return array(
|
321 |
+
'enabled' => 1,
|
322 |
+
'cookie_type' => $this->get_default_cookie_types(),
|
323 |
+
'placeholder' => $this->get_default_placeholder(),
|
324 |
+
);
|
325 |
+
}
|
326 |
+
}
|
addons/controller/addons/enhanced-ecommerce-for-woocommerce-store/enhanced-ecommerce-for-woocommerce-store.php
CHANGED
@@ -239,7 +239,7 @@
|
|
239 |
* @since 1.8.0
|
240 |
*/
|
241 |
public function get_extra_information() {
|
242 |
-
return '<p>' .
|
243 |
}
|
244 |
|
245 |
/**
|
239 |
* @since 1.8.0
|
240 |
*/
|
241 |
public function get_extra_information() {
|
242 |
+
return '<p>' . esc_html__( 'Blocks enhanced e-commerce for WooCommerce store', 'cookiebot-addons' ) . '</p>';
|
243 |
}
|
244 |
|
245 |
/**
|
addons/controller/addons/gadwp/gadwp.php
CHANGED
@@ -54,10 +54,10 @@ class Gadwp implements Cookiebot_Addons_Interface {
|
|
54 |
Cookie_Consent_Interface $cookie_consent,
|
55 |
Buffer_Output_Interface $buffer_output
|
56 |
) {
|
57 |
-
$this->settings
|
58 |
$this->script_loader_tag = $script_loader_tag;
|
59 |
-
$this->cookie_consent
|
60 |
-
$this->buffer_output
|
61 |
}
|
62 |
|
63 |
/**
|
@@ -76,7 +76,7 @@ class Gadwp implements Cookiebot_Addons_Interface {
|
|
76 |
/**
|
77 |
* Manipulate the scripts if they are loaded.
|
78 |
*
|
79 |
-
* @version
|
80 |
* @since 1.1.0
|
81 |
*/
|
82 |
public function cookiebot_addon_ga_google_analytics() {
|
@@ -107,17 +107,26 @@ class Gadwp implements Cookiebot_Addons_Interface {
|
|
107 |
'ga-disable-' => $this->get_cookie_types(),
|
108 |
),
|
109 |
false );
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
6,
|
116 |
array(
|
117 |
'GoogleAnalyticsObject' => $this->get_cookie_types(),
|
|
|
118 |
),
|
119 |
false );
|
120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
}
|
122 |
|
123 |
/**
|
@@ -128,7 +137,7 @@ class Gadwp implements Cookiebot_Addons_Interface {
|
|
128 |
* @since 1.3.0
|
129 |
*/
|
130 |
public function get_addon_name() {
|
131 |
-
return 'Google Analytics Dashboard for WP
|
132 |
}
|
133 |
|
134 |
/**
|
54 |
Cookie_Consent_Interface $cookie_consent,
|
55 |
Buffer_Output_Interface $buffer_output
|
56 |
) {
|
57 |
+
$this->settings = $settings;
|
58 |
$this->script_loader_tag = $script_loader_tag;
|
59 |
+
$this->cookie_consent = $cookie_consent;
|
60 |
+
$this->buffer_output = $buffer_output;
|
61 |
}
|
62 |
|
63 |
/**
|
76 |
/**
|
77 |
* Manipulate the scripts if they are loaded.
|
78 |
*
|
79 |
+
* @version 3.9.0
|
80 |
* @since 1.1.0
|
81 |
*/
|
82 |
public function cookiebot_addon_ga_google_analytics() {
|
107 |
'ga-disable-' => $this->get_cookie_types(),
|
108 |
),
|
109 |
false );
|
110 |
+
|
111 |
+
|
112 |
+
/* For new versions of GADWP */
|
113 |
+
$this->script_loader_tag->add_tag( 'exactmetrics-frontend-script', $this->get_cookie_types() );
|
114 |
+
$this->buffer_output->add_tag( 'wp_head',
|
115 |
6,
|
116 |
array(
|
117 |
'GoogleAnalyticsObject' => $this->get_cookie_types(),
|
118 |
+
'googletagmanager' => $this->get_cookie_types()
|
119 |
),
|
120 |
false );
|
121 |
|
122 |
+
|
123 |
+
add_filter('exactmetrics_tracking_analytics_script_attributes', function($atts){
|
124 |
+
$atts['type'] = 'text/plain';
|
125 |
+
$atts['data-cookieconsent'] = cookiebot_addons_output_cookie_types( $this->get_cookie_types() );
|
126 |
+
|
127 |
+
return $atts;
|
128 |
+
});
|
129 |
+
|
130 |
}
|
131 |
|
132 |
/**
|
137 |
* @since 1.3.0
|
138 |
*/
|
139 |
public function get_addon_name() {
|
140 |
+
return 'Google Analytics Dashboard for WP by ExactMetrics';
|
141 |
}
|
142 |
|
143 |
/**
|
addons/controller/addons/google-analytics-plus/google-analytics-plus.php
CHANGED
@@ -235,7 +235,7 @@ class Google_Analytics_Plus implements Cookiebot_Addons_Interface {
|
|
235 |
* @since 1.8.0
|
236 |
*/
|
237 |
public function get_extra_information() {
|
238 |
-
return '<p>' .
|
239 |
}
|
240 |
|
241 |
/**
|
235 |
* @since 1.8.0
|
236 |
*/
|
237 |
public function get_extra_information() {
|
238 |
+
return '<p>' . esc_html__( 'Google Analytics is a simple, easy-to-use tool that helps website owners measure how users interact with website content', 'cookiebot-addons' ) . '</p>';
|
239 |
}
|
240 |
|
241 |
/**
|
addons/controller/addons/google-analytics/google-analytics.php
CHANGED
@@ -240,7 +240,7 @@ class Google_Analytics implements Cookiebot_Addons_Interface {
|
|
240 |
* @since 1.8.0
|
241 |
*/
|
242 |
public function get_extra_information() {
|
243 |
-
return '<p>' .
|
244 |
}
|
245 |
|
246 |
/**
|
240 |
* @since 1.8.0
|
241 |
*/
|
242 |
public function get_extra_information() {
|
243 |
+
return '<p>' . esc_html__( 'Google Analytics is used to track how visitor interact with website content.', 'cookiebot-addons' ) . '</p>';
|
244 |
}
|
245 |
|
246 |
/**
|
addons/controller/addons/google-site-kit/google-site-kit.php
CHANGED
@@ -239,7 +239,7 @@ class Google_Site_Kit implements Cookiebot_Addons_Interface {
|
|
239 |
* @since 1.8.0
|
240 |
*/
|
241 |
public function get_extra_information() {
|
242 |
-
return '<p>' .
|
243 |
}
|
244 |
|
245 |
/**
|
239 |
* @since 1.8.0
|
240 |
*/
|
241 |
public function get_extra_information() {
|
242 |
+
return '<p>' . esc_html__( 'Blocks Google Analytics scripts', 'cookiebot-addons' ) . '</p>';
|
243 |
}
|
244 |
|
245 |
/**
|
addons/controller/addons/jetpack/visitor-cookies.php
CHANGED
@@ -241,7 +241,7 @@ class Visitor_Cookies implements Jetpack_Widget_Interface {
|
|
241 |
* Show message to accept preferences consent to save
|
242 |
*/
|
243 |
if ( $this->is_widget_placeholder_enabled() ) {
|
244 |
-
add_action( '
|
245 |
}
|
246 |
}
|
247 |
|
@@ -251,7 +251,7 @@ class Visitor_Cookies implements Jetpack_Widget_Interface {
|
|
251 |
* @since 1.2.0
|
252 |
*/
|
253 |
public function view_accept_preferences_consent() {
|
254 |
-
echo '<div class="
|
255 |
' . $this->get_default_placeholder() . '
|
256 |
</div>';
|
257 |
}
|
241 |
* Show message to accept preferences consent to save
|
242 |
*/
|
243 |
if ( $this->is_widget_placeholder_enabled() ) {
|
244 |
+
add_action( 'wp_footer', array( $this, 'view_accept_preferences_consent' ) );
|
245 |
}
|
246 |
}
|
247 |
|
251 |
* @since 1.2.0
|
252 |
*/
|
253 |
public function view_accept_preferences_consent() {
|
254 |
+
echo '<div class="' . cookiebot_addons_cookieconsent_optout( $this->get_widget_cookie_types() ) . '">
|
255 |
' . $this->get_default_placeholder() . '
|
256 |
</div>';
|
257 |
}
|
addons/controller/addons/jetpack/widget/facebook-widget.php
CHANGED
@@ -215,7 +215,7 @@ class Facebook_Widget {
|
|
215 |
public function cookie_consent_div( $view, $widget ) {
|
216 |
if ( $widget == 'facebook-likebox' && $view == 'widget_view' ) {
|
217 |
if ( is_array( $this->get_widget_cookie_types() ) && count( $this->get_widget_cookie_types() ) > 0 ) {
|
218 |
-
echo '<div class="
|
219 |
' . $this->get_widget_placeholder() . '
|
220 |
</div>';
|
221 |
}
|
@@ -230,7 +230,7 @@ class Facebook_Widget {
|
|
230 |
* @since 1.8.0
|
231 |
*/
|
232 |
public function get_extra_information() {
|
233 |
-
return '<p>' .
|
234 |
}
|
235 |
|
236 |
/**
|
215 |
public function cookie_consent_div( $view, $widget ) {
|
216 |
if ( $widget == 'facebook-likebox' && $view == 'widget_view' ) {
|
217 |
if ( is_array( $this->get_widget_cookie_types() ) && count( $this->get_widget_cookie_types() ) > 0 ) {
|
218 |
+
echo '<div class="' . cookiebot_addons_cookieconsent_optout( $this->get_widget_cookie_types() ) . '">
|
219 |
' . $this->get_widget_placeholder() . '
|
220 |
</div>';
|
221 |
}
|
230 |
* @since 1.8.0
|
231 |
*/
|
232 |
public function get_extra_information() {
|
233 |
+
return '<p>' . esc_html__( 'Facebook widget.', 'cookiebot-addons' ) . '</p>';
|
234 |
}
|
235 |
|
236 |
/**
|
addons/controller/addons/jetpack/widget/goodreads-widget.php
CHANGED
@@ -271,7 +271,7 @@ class Goodreads_Widget implements Jetpack_Widget_Interface {
|
|
271 |
public function cookie_consent_div( $view, $widget ) {
|
272 |
if ( $widget == 'goodreads' && $view == 'widget_view' ) {
|
273 |
if ( is_array( $this->get_widget_cookie_types() ) && count( $this->get_widget_cookie_types() ) > 0 ) {
|
274 |
-
echo '<div class="
|
275 |
' . $this->get_widget_placeholder() . '
|
276 |
</div>';
|
277 |
}
|
271 |
public function cookie_consent_div( $view, $widget ) {
|
272 |
if ( $widget == 'goodreads' && $view == 'widget_view' ) {
|
273 |
if ( is_array( $this->get_widget_cookie_types() ) && count( $this->get_widget_cookie_types() ) > 0 ) {
|
274 |
+
echo '<div class="' . cookiebot_addons_cookieconsent_optout( $this->get_widget_cookie_types() ) . '">
|
275 |
' . $this->get_widget_placeholder() . '
|
276 |
</div>';
|
277 |
}
|
addons/controller/addons/jetpack/widget/google-maps-widget.php
CHANGED
@@ -268,7 +268,7 @@ class Google_Maps_Widget implements Jetpack_Widget_Interface {
|
|
268 |
public function cookie_consent_div( $view, $widget ) {
|
269 |
if ( $widget == 'contact_info' && $view == 'widget_view' ) {
|
270 |
if ( is_array( $this->get_widget_cookie_types() ) && count( $this->get_widget_cookie_types() ) > 0 ) {
|
271 |
-
echo '<div class="
|
272 |
' . $this->get_widget_placeholder() . '
|
273 |
</div>';
|
274 |
}
|
268 |
public function cookie_consent_div( $view, $widget ) {
|
269 |
if ( $widget == 'contact_info' && $view == 'widget_view' ) {
|
270 |
if ( is_array( $this->get_widget_cookie_types() ) && count( $this->get_widget_cookie_types() ) > 0 ) {
|
271 |
+
echo '<div class="' . cookiebot_addons_cookieconsent_optout( $this->get_widget_cookie_types() ) . '">
|
272 |
' . $this->get_widget_placeholder() . '
|
273 |
</div>';
|
274 |
}
|
addons/controller/addons/jetpack/widget/googleplus-badge-widget.php
CHANGED
@@ -208,7 +208,7 @@ class Googleplus_Badge_Widget {
|
|
208 |
public function display_div_message_to_go_to_consent_settings( $view, $widget ) {
|
209 |
if ( $widget == 'googleplus-badge' && $view == 'widget_view' ) {
|
210 |
if ( is_array( $this->cookie_types ) && count( $this->cookie_types ) > 0 ) {
|
211 |
-
echo '<div class="
|
212 |
}
|
213 |
|
214 |
}
|
208 |
public function display_div_message_to_go_to_consent_settings( $view, $widget ) {
|
209 |
if ( $widget == 'googleplus-badge' && $view == 'widget_view' ) {
|
210 |
if ( is_array( $this->cookie_types ) && count( $this->cookie_types ) > 0 ) {
|
211 |
+
echo '<div class="' . cookiebot_addons_cookieconsent_optout( $this->cookie_types ) . '">' . $this->get_widget_placeholder() . '</div>';
|
212 |
}
|
213 |
|
214 |
}
|
addons/controller/addons/jetpack/widget/internet-defense-league-widget.php
CHANGED
@@ -203,7 +203,7 @@ class Internet_Defense_league_Widget implements Jetpack_Widget_Interface {
|
|
203 |
public function cookie_consent_div( $view, $widget ) {
|
204 |
if ( $widget == 'internet_defense_league' && $view == 'widget_view' ) {
|
205 |
if ( is_array( $this->get_widget_cookie_types() ) && count( $this->get_widget_cookie_types() ) > 0 ) {
|
206 |
-
echo '<div class="
|
207 |
' . $this->get_widget_placeholder() . '
|
208 |
</div>';
|
209 |
}
|
203 |
public function cookie_consent_div( $view, $widget ) {
|
204 |
if ( $widget == 'internet_defense_league' && $view == 'widget_view' ) {
|
205 |
if ( is_array( $this->get_widget_cookie_types() ) && count( $this->get_widget_cookie_types() ) > 0 ) {
|
206 |
+
echo '<div class="' . cookiebot_addons_cookieconsent_optout( $this->get_widget_cookie_types() ) . '">
|
207 |
' . $this->get_widget_placeholder() . '
|
208 |
</div>';
|
209 |
}
|
addons/controller/addons/jetpack/widget/twitter-timeline-widget.php
CHANGED
@@ -204,7 +204,7 @@ class Twitter_Timeline_Widget {
|
|
204 |
public function display_div_message_to_go_to_consent_settings( $view, $widget ) {
|
205 |
if ( $widget == 'twitter_timeline' && $view == 'widget_view' ) {
|
206 |
if ( is_array( $this->get_widget_cookie_types() ) && count( $this->get_widget_cookie_types() ) > 0 ) {
|
207 |
-
echo '<div class="
|
208 |
}
|
209 |
}
|
210 |
}
|
204 |
public function display_div_message_to_go_to_consent_settings( $view, $widget ) {
|
205 |
if ( $widget == 'twitter_timeline' && $view == 'widget_view' ) {
|
206 |
if ( is_array( $this->get_widget_cookie_types() ) && count( $this->get_widget_cookie_types() ) > 0 ) {
|
207 |
+
echo '<div class="' . cookiebot_addons_cookieconsent_optout( $this->get_widget_cookie_types() ) . '">' . $this->get_widget_placeholder() . '</div>';
|
208 |
}
|
209 |
}
|
210 |
}
|
addons/controller/addons/litespeed-cache/litespeed-cache.php
CHANGED
@@ -250,7 +250,7 @@ class Litespeed_Cache implements Cookiebot_Addons_Interface {
|
|
250 |
* @since 1.8.0
|
251 |
*/
|
252 |
public function get_extra_information() {
|
253 |
-
return '<p>' .
|
254 |
'cookiebot-addons' ) . '</p>';;
|
255 |
}
|
256 |
|
250 |
* @since 1.8.0
|
251 |
*/
|
252 |
public function get_extra_information() {
|
253 |
+
return '<p>' . esc_html__( 'Excludes cookiebot javascript files when the Litespeed Cache deter option is enabled.',
|
254 |
'cookiebot-addons' ) . '</p>';;
|
255 |
}
|
256 |
|
addons/controller/addons/official-facebook-pixel/official-facebook-pixel.php
CHANGED
@@ -126,6 +126,8 @@ class Official_Facebook_Pixel implements Cookiebot_Addons_Interface {
|
|
126 |
'FacebookPixelPlugin\Integration\FacebookWordpressContactForm7', 'trackServerEvent' );
|
127 |
cookiebot_addons_remove_class_action( 'wpcf7_ajax_json_echo',
|
128 |
'FacebookPixelPlugin\Integration\FacebookWordpressContactForm7', 'injectLeadEvent', 20 );
|
|
|
|
|
129 |
|
130 |
// Formidable Form integration
|
131 |
cookiebot_addons_remove_class_action( 'frm_after_create_entry',
|
@@ -339,7 +341,7 @@ class Official_Facebook_Pixel implements Cookiebot_Addons_Interface {
|
|
339 |
* @since 1.8.0
|
340 |
*/
|
341 |
public function get_extra_information() {
|
342 |
-
return '<p>' .
|
343 |
}
|
344 |
|
345 |
/**
|
126 |
'FacebookPixelPlugin\Integration\FacebookWordpressContactForm7', 'trackServerEvent' );
|
127 |
cookiebot_addons_remove_class_action( 'wpcf7_ajax_json_echo',
|
128 |
'FacebookPixelPlugin\Integration\FacebookWordpressContactForm7', 'injectLeadEvent', 20 );
|
129 |
+
cookiebot_addons_remove_class_action( 'wpcf7_feedback_response',
|
130 |
+
'FacebookPixelPlugin\Integration\FacebookWordpressContactForm7', 'injectLeadEvent', 20 );
|
131 |
|
132 |
// Formidable Form integration
|
133 |
cookiebot_addons_remove_class_action( 'frm_after_create_entry',
|
341 |
* @since 1.8.0
|
342 |
*/
|
343 |
public function get_extra_information() {
|
344 |
+
return '<p>' . esc_html__( 'Blocks Official Facebook Pixel scripts', 'cookiebot-addons' ) . '</p>';
|
345 |
}
|
346 |
|
347 |
/**
|
addons/controller/addons/optinmonster/optinmonster.php
CHANGED
@@ -232,7 +232,7 @@ class Optinmonster implements Cookiebot_Addons_Interface {
|
|
232 |
* @since 1.8.0
|
233 |
*/
|
234 |
public function get_extra_information() {
|
235 |
-
return '<p>' .
|
236 |
}
|
237 |
|
238 |
/**
|
232 |
* @since 1.8.0
|
233 |
*/
|
234 |
public function get_extra_information() {
|
235 |
+
return '<p>' . esc_html__( 'OptinMonster API plugin to connect your WordPress site to your OptinMonster account.', 'cookiebot-addons' ) . '</p>';
|
236 |
}
|
237 |
|
238 |
/**
|
addons/controller/addons/pixel-caffeine/pixel-caffeine.php
CHANGED
@@ -70,7 +70,7 @@ class Pixel_Caffeine implements Cookiebot_Addons_Interface {
|
|
70 |
* @since 1.4.0
|
71 |
*/
|
72 |
public function cookiebot_addon_pixel_caffeine() {
|
73 |
-
$this->script_loader_tag->add_tag( 'aepc-pixel-events',
|
74 |
|
75 |
$this->buffer_output->add_tag( 'wp_head', 99, array(
|
76 |
'aepc_pixel' => $this->get_cookie_types(),
|
70 |
* @since 1.4.0
|
71 |
*/
|
72 |
public function cookiebot_addon_pixel_caffeine() {
|
73 |
+
$this->script_loader_tag->add_tag( 'aepc-pixel-events', $this->get_cookie_types() );
|
74 |
|
75 |
$this->buffer_output->add_tag( 'wp_head', 99, array(
|
76 |
'aepc_pixel' => $this->get_cookie_types(),
|
addons/controller/addons/simple-share-buttons-adder/simple-share-buttons-adder.php
CHANGED
@@ -232,7 +232,7 @@ class Simple_Share_Buttons_Adder implements Cookiebot_Addons_Interface {
|
|
232 |
* @since 1.8.0
|
233 |
*/
|
234 |
public function get_extra_information() {
|
235 |
-
return '<p>' .
|
236 |
}
|
237 |
|
238 |
/**
|
232 |
* @since 1.8.0
|
233 |
*/
|
234 |
public function get_extra_information() {
|
235 |
+
return '<p>' . esc_html__( 'Blocks Simple Share Buttons Adder.', 'cookiebot-addons' ) . '</p>';
|
236 |
}
|
237 |
|
238 |
/**
|
addons/controller/addons/wp-rocket/wp-rocket.php
CHANGED
@@ -250,7 +250,7 @@ class Wp_Rocket implements Cookiebot_Addons_Interface {
|
|
250 |
* @since 1.8.0
|
251 |
*/
|
252 |
public function get_extra_information() {
|
253 |
-
return '<p>' .
|
254 |
'cookiebot-addons' ) . '</p>';;
|
255 |
}
|
256 |
|
250 |
* @since 1.8.0
|
251 |
*/
|
252 |
public function get_extra_information() {
|
253 |
+
return '<p>' . esc_html__( 'Excludes cookiebot javascript files when the WP-Rocket deter option is enabled.',
|
254 |
'cookiebot-addons' ) . '</p>';;
|
255 |
}
|
256 |
|
addons/controller/addons/wpforms/wpforms.php
CHANGED
@@ -267,9 +267,9 @@ class Wpforms implements Cookiebot_Addons_Interface {
|
|
267 |
*/
|
268 |
public function get_extra_information() {
|
269 |
return '<p>' .
|
270 |
-
|
271 |
'<br />' .
|
272 |
-
|
273 |
'</p>';
|
274 |
}
|
275 |
|
267 |
*/
|
268 |
public function get_extra_information() {
|
269 |
return '<p>' .
|
270 |
+
esc_html__( 'If the user gives correct consent, IP and Unique User ID will be saved on form submissions, otherwise not.', 'cookiebot-addons' ) .
|
271 |
'<br />' .
|
272 |
+
esc_html__( 'Increases opt-in rate compared to WPForms "GDPR mode".', 'cookiebot-addons' ) .
|
273 |
'</p>';
|
274 |
}
|
275 |
|
addons/controller/plugin-controller.php
CHANGED
@@ -5,6 +5,7 @@ namespace cookiebot_addons\controller;
|
|
5 |
use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
|
6 |
use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
|
7 |
use cookiebot_addons\lib\Settings_Service_Interface;
|
|
|
8 |
|
9 |
class Plugin_Controller {
|
10 |
|
@@ -26,7 +27,6 @@ class Plugin_Controller {
|
|
26 |
*/
|
27 |
public function __construct( Settings_Service_Interface $settings_service ) {
|
28 |
$this->settings_service = $settings_service;
|
29 |
-
|
30 |
$this->load_init_files();
|
31 |
}
|
32 |
|
@@ -46,8 +46,8 @@ class Plugin_Controller {
|
|
46 |
/**
|
47 |
* Load addon configuration if the plugin is activated
|
48 |
*
|
49 |
-
* @throws
|
50 |
-
* @throws
|
51 |
*
|
52 |
* @version 1.3.0
|
53 |
* @since 1.2.0
|
@@ -95,8 +95,8 @@ class Plugin_Controller {
|
|
95 |
add_action('admin_notices', function() {
|
96 |
echo '<div class="notice notice-warning">
|
97 |
<p>
|
98 |
-
<strong>'.
|
99 |
-
'.
|
100 |
</p>
|
101 |
</div>';
|
102 |
});
|
5 |
use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
|
6 |
use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
|
7 |
use cookiebot_addons\lib\Settings_Service_Interface;
|
8 |
+
use Cybot\Dependencies\DI;
|
9 |
|
10 |
class Plugin_Controller {
|
11 |
|
27 |
*/
|
28 |
public function __construct( Settings_Service_Interface $settings_service ) {
|
29 |
$this->settings_service = $settings_service;
|
|
|
30 |
$this->load_init_files();
|
31 |
}
|
32 |
|
46 |
/**
|
47 |
* Load addon configuration if the plugin is activated
|
48 |
*
|
49 |
+
* @throws DI\DependencyException
|
50 |
+
* @throws DI\NotFoundException
|
51 |
*
|
52 |
* @version 1.3.0
|
53 |
* @since 1.2.0
|
95 |
add_action('admin_notices', function() {
|
96 |
echo '<div class="notice notice-warning">
|
97 |
<p>
|
98 |
+
<strong>'.esc_html__('You enabled Cookiebot auto blocking mode but still using addons').'</strong><br>
|
99 |
+
'.esc_html__('In some occasions this may cause client side errors. If you notice any errors please try to disable Cookiebot addons or contact Cookiebot support.').'
|
100 |
</p>
|
101 |
</div>';
|
102 |
});
|
addons/cookiebot-addons-init.php
CHANGED
@@ -5,8 +5,8 @@ namespace cookiebot_addons;
|
|
5 |
use cookiebot_addons\config\Settings_Config;
|
6 |
use cookiebot_addons\controller\Plugin_Controller;
|
7 |
use cookiebot_addons\lib\Settings_Service_Interface;
|
8 |
-
use DI\ContainerBuilder;
|
9 |
-
use DI;
|
10 |
|
11 |
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
exit;
|
@@ -40,14 +40,14 @@ include_once COOKIEBOT_ADDONS_DIR . 'lib/helper.php';
|
|
40 |
*
|
41 |
* "php-di/php-di": "5.0"
|
42 |
*/
|
43 |
-
include_once COOKIEBOT_ADDONS_DIR . '
|
44 |
|
45 |
class Cookiebot_Addons {
|
46 |
|
47 |
/**
|
48 |
* IoC Container - is used for dependency injections
|
49 |
*
|
50 |
-
* @var
|
51 |
*
|
52 |
* @since 1.3.0
|
53 |
*/
|
@@ -83,7 +83,7 @@ class Cookiebot_Addons {
|
|
83 |
if ( is_null( self::$_instance ) ) {
|
84 |
try {
|
85 |
self::$_instance = new self();
|
86 |
-
} catch (
|
87 |
echo 'Dependencies are not loaded.';
|
88 |
} catch ( DI\NotFoundException $e ) {
|
89 |
echo 'Dependencies are not found.';
|
@@ -183,6 +183,9 @@ class Cookiebot_Addons {
|
|
183 |
|
184 |
$this->container->set( 'Settings_Service_Interface', DI\object( 'cookiebot_addons\lib\Settings_Service' )
|
185 |
->constructor( $this->container ) );
|
|
|
|
|
|
|
186 |
}
|
187 |
|
188 |
/**
|
@@ -201,9 +204,11 @@ class Cookiebot_Addons {
|
|
201 |
/**
|
202 |
* Load addon class to the container
|
203 |
*/
|
204 |
-
$this->container->set( $plugin->class,
|
205 |
->constructor(
|
206 |
-
$
|
|
|
|
|
207 |
$this->container->get( 'Script_Loader_Tag_Interface' ),
|
208 |
$this->container->get( 'Cookie_Consent_Interface' ),
|
209 |
$this->container->get( 'Buffer_Output_Interface' ) )
|
5 |
use cookiebot_addons\config\Settings_Config;
|
6 |
use cookiebot_addons\controller\Plugin_Controller;
|
7 |
use cookiebot_addons\lib\Settings_Service_Interface;
|
8 |
+
use Cybot\Dependencies\DI\ContainerBuilder;
|
9 |
+
use Cybot\Dependencies\DI;
|
10 |
|
11 |
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
exit;
|
40 |
*
|
41 |
* "php-di/php-di": "5.0"
|
42 |
*/
|
43 |
+
include_once COOKIEBOT_ADDONS_DIR . 'vendor/autoload.php';
|
44 |
|
45 |
class Cookiebot_Addons {
|
46 |
|
47 |
/**
|
48 |
* IoC Container - is used for dependency injections
|
49 |
*
|
50 |
+
* @var DI\Container
|
51 |
*
|
52 |
* @since 1.3.0
|
53 |
*/
|
83 |
if ( is_null( self::$_instance ) ) {
|
84 |
try {
|
85 |
self::$_instance = new self();
|
86 |
+
} catch ( DI\DependencyException $e ) {
|
87 |
echo 'Dependencies are not loaded.';
|
88 |
} catch ( DI\NotFoundException $e ) {
|
89 |
echo 'Dependencies are not found.';
|
183 |
|
184 |
$this->container->set( 'Settings_Service_Interface', DI\object( 'cookiebot_addons\lib\Settings_Service' )
|
185 |
->constructor( $this->container ) );
|
186 |
+
|
187 |
+
$this->container->set( 'Theme_Settings_Service_Interface', DI\object( 'cookiebot_addons\lib\Theme_Settings_Service' )
|
188 |
+
->constructor( $this->container ) );
|
189 |
}
|
190 |
|
191 |
/**
|
204 |
/**
|
205 |
* Load addon class to the container
|
206 |
*/
|
207 |
+
$this->container->set( $plugin->class, DI\object( $plugin->class )
|
208 |
->constructor(
|
209 |
+
isset( $plugin->is_theme ) && $plugin->is_theme
|
210 |
+
? $this->container->get( 'Theme_Settings_Service_Interface' )
|
211 |
+
: $this->container->get( 'Settings_Service_Interface' ),
|
212 |
$this->container->get( 'Script_Loader_Tag_Interface' ),
|
213 |
$this->container->get( 'Cookie_Consent_Interface' ),
|
214 |
$this->container->get( 'Buffer_Output_Interface' ) )
|
addons/inc/Dependencies/DI/Annotation/Inject.php
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Annotation;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\Exception\AnnotationException;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* "Inject" annotation
|
16 |
+
*
|
17 |
+
* Marks a property or method as an injection point
|
18 |
+
*
|
19 |
+
* @Annotation
|
20 |
+
* @Target({"METHOD","PROPERTY"})
|
21 |
+
*
|
22 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
23 |
+
*/
|
24 |
+
final class Inject
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Entry name
|
28 |
+
* @var string
|
29 |
+
*/
|
30 |
+
private $name;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Parameters, indexed by the parameter number (index) or name
|
34 |
+
*
|
35 |
+
* Used if the annotation is set on a method
|
36 |
+
* @var array
|
37 |
+
*/
|
38 |
+
private $parameters = [];
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @param array $values
|
42 |
+
*/
|
43 |
+
public function __construct(array $values)
|
44 |
+
{
|
45 |
+
// Process the parameters as a list AND as a parameter array (we don't know on what the annotation is)
|
46 |
+
|
47 |
+
// @Inject(name="foo")
|
48 |
+
if (isset($values['name']) && is_string($values['name'])) {
|
49 |
+
$this->name = $values['name'];
|
50 |
+
return;
|
51 |
+
}
|
52 |
+
|
53 |
+
// @Inject
|
54 |
+
if (! isset($values['value'])) {
|
55 |
+
return;
|
56 |
+
}
|
57 |
+
|
58 |
+
$values = $values['value'];
|
59 |
+
|
60 |
+
// @Inject("foo")
|
61 |
+
if (is_string($values)) {
|
62 |
+
$this->name = $values;
|
63 |
+
}
|
64 |
+
|
65 |
+
// @Inject({...}) on a method
|
66 |
+
if (is_array($values)) {
|
67 |
+
foreach ($values as $key => $value) {
|
68 |
+
if (! is_string($value)) {
|
69 |
+
throw new AnnotationException(sprintf(
|
70 |
+
'@Inject({"param" = "value"}) expects "value" to be a string, %s given.',
|
71 |
+
json_encode($value)
|
72 |
+
));
|
73 |
+
}
|
74 |
+
|
75 |
+
$this->parameters[$key] = $value;
|
76 |
+
}
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* @return string Name of the entry to inject
|
82 |
+
*/
|
83 |
+
public function getName()
|
84 |
+
{
|
85 |
+
return $this->name;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* @return array Parameters, indexed by the parameter number (index) or name
|
90 |
+
*/
|
91 |
+
public function getParameters()
|
92 |
+
{
|
93 |
+
return $this->parameters;
|
94 |
+
}
|
95 |
+
}
|
addons/inc/Dependencies/DI/Annotation/Injectable.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Annotation;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Scope;
|
13 |
+
use UnexpectedValueException;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* "Injectable" annotation
|
17 |
+
*
|
18 |
+
* Marks a class as injectable
|
19 |
+
*
|
20 |
+
* @Annotation
|
21 |
+
* @Target("CLASS")
|
22 |
+
*
|
23 |
+
* @author Domenic Muskulus <domenic@muskulus.eu>
|
24 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
25 |
+
*/
|
26 |
+
final class Injectable
|
27 |
+
{
|
28 |
+
/**
|
29 |
+
* The scope of an class: prototype, singleton
|
30 |
+
* @var string|null
|
31 |
+
*/
|
32 |
+
private $scope;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Should the object be lazy-loaded
|
36 |
+
* @var boolean|null
|
37 |
+
*/
|
38 |
+
private $lazy;
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @param array $values
|
42 |
+
*/
|
43 |
+
public function __construct(array $values)
|
44 |
+
{
|
45 |
+
if (isset($values['scope'])) {
|
46 |
+
if ($values['scope'] === 'prototype') {
|
47 |
+
$this->scope = Scope::PROTOTYPE;
|
48 |
+
} elseif ($values['scope'] === 'singleton') {
|
49 |
+
$this->scope = Scope::SINGLETON;
|
50 |
+
} else {
|
51 |
+
throw new UnexpectedValueException(sprintf("Value '%s' is not a valid scope", $values['scope']));
|
52 |
+
}
|
53 |
+
}
|
54 |
+
if (isset($values['lazy'])) {
|
55 |
+
$this->lazy = (boolean) $values['lazy'];
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @return string|null
|
61 |
+
*/
|
62 |
+
public function getScope()
|
63 |
+
{
|
64 |
+
return $this->scope;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @return boolean|null
|
69 |
+
*/
|
70 |
+
public function isLazy()
|
71 |
+
{
|
72 |
+
return $this->lazy;
|
73 |
+
}
|
74 |
+
}
|
addons/inc/Dependencies/DI/Container.php
ADDED
@@ -0,0 +1,340 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\ObjectDefinition;
|
13 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
14 |
+
use Cybot\Dependencies\DI\Definition\FactoryDefinition;
|
15 |
+
use Cybot\Dependencies\DI\Definition\InstanceDefinition;
|
16 |
+
use Cybot\Dependencies\DI\Definition\Resolver\ResolverDispatcher;
|
17 |
+
use Cybot\Dependencies\DI\Definition\Source\CachedDefinitionSource;
|
18 |
+
use Cybot\Dependencies\DI\Definition\Source\DefinitionSource;
|
19 |
+
use Cybot\Dependencies\DI\Definition\Source\MutableDefinitionSource;
|
20 |
+
use Cybot\Dependencies\DI\Definition\Helper\DefinitionHelper;
|
21 |
+
use Cybot\Dependencies\DI\Definition\Resolver\DefinitionResolver;
|
22 |
+
use Cybot\Dependencies\DI\Cybot\Dependencies\Invoker\DefinitionParameterResolver;
|
23 |
+
use Cybot\Dependencies\DI\Proxy\ProxyFactory;
|
24 |
+
use Exception;
|
25 |
+
use Cybot\Dependencies\Interop\Container\ContainerInterface;
|
26 |
+
use InvalidArgumentException;
|
27 |
+
use Cybot\Dependencies\Invoker\Invoker;
|
28 |
+
use Cybot\Dependencies\Invoker\ParameterResolver\AssociativeArrayResolver;
|
29 |
+
use Cybot\Dependencies\Invoker\ParameterResolver\Container\TypeHintContainerResolver;
|
30 |
+
use Cybot\Dependencies\Invoker\ParameterResolver\NumericArrayResolver;
|
31 |
+
use Cybot\Dependencies\Invoker\ParameterResolver\ResolverChain;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Dependency Injection Container.
|
35 |
+
*
|
36 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
37 |
+
*/
|
38 |
+
class Container implements ContainerInterface, FactoryInterface, \Cybot\Dependencies\DI\InvokerInterface
|
39 |
+
{
|
40 |
+
/**
|
41 |
+
* Map of entries with Singleton scope that are already resolved.
|
42 |
+
* @var array
|
43 |
+
*/
|
44 |
+
private $singletonEntries = [];
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @var DefinitionSource
|
48 |
+
*/
|
49 |
+
private $definitionSource;
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @var DefinitionResolver
|
53 |
+
*/
|
54 |
+
private $definitionResolver;
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Array of entries being resolved. Used to avoid circular dependencies and infinite loops.
|
58 |
+
* @var array
|
59 |
+
*/
|
60 |
+
private $entriesBeingResolved = [];
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @var \Cybot\Dependencies\Invoker\InvokerInterface|null
|
64 |
+
*/
|
65 |
+
private $invoker;
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Container that wraps this container. If none, points to $this.
|
69 |
+
*
|
70 |
+
* @var ContainerInterface
|
71 |
+
*/
|
72 |
+
private $wrapperContainer;
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Use the ContainerBuilder to ease constructing the Container.
|
76 |
+
*
|
77 |
+
* @see ContainerBuilder
|
78 |
+
*
|
79 |
+
* @param DefinitionSource $definitionSource
|
80 |
+
* @param ProxyFactory $proxyFactory
|
81 |
+
* @param ContainerInterface $wrapperContainer If the container is wrapped by another container.
|
82 |
+
*/
|
83 |
+
public function __construct(
|
84 |
+
DefinitionSource $definitionSource,
|
85 |
+
ProxyFactory $proxyFactory,
|
86 |
+
ContainerInterface $wrapperContainer = null
|
87 |
+
) {
|
88 |
+
$this->wrapperContainer = $wrapperContainer ?: $this;
|
89 |
+
|
90 |
+
$this->definitionSource = $definitionSource;
|
91 |
+
$this->definitionResolver = new ResolverDispatcher($this->wrapperContainer, $proxyFactory);
|
92 |
+
|
93 |
+
// Auto-register the container
|
94 |
+
$this->singletonEntries['Cybot\Dependencies\DI\Container'] = $this;
|
95 |
+
$this->singletonEntries['Cybot\Dependencies\DI\ContainerInterface'] = $this;
|
96 |
+
$this->singletonEntries['Cybot\Dependencies\DI\FactoryInterface'] = $this;
|
97 |
+
$this->singletonEntries['Cybot\Dependencies\DI\InvokerInterface'] = $this;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Returns an entry of the container by its name.
|
102 |
+
*
|
103 |
+
* @param string $name Entry name or a class name.
|
104 |
+
*
|
105 |
+
* @throws InvalidArgumentException The name parameter must be of type string.
|
106 |
+
* @throws DependencyException Error while resolving the entry.
|
107 |
+
* @throws NotFoundException No entry found for the given name.
|
108 |
+
* @return mixed
|
109 |
+
*/
|
110 |
+
public function get($name)
|
111 |
+
{
|
112 |
+
if (! is_string($name)) {
|
113 |
+
throw new InvalidArgumentException(sprintf(
|
114 |
+
'The name parameter must be of type string, %s given',
|
115 |
+
is_object($name) ? get_class($name) : gettype($name)
|
116 |
+
));
|
117 |
+
}
|
118 |
+
|
119 |
+
// Try to find the entry in the singleton map
|
120 |
+
if (array_key_exists($name, $this->singletonEntries)) {
|
121 |
+
return $this->singletonEntries[$name];
|
122 |
+
}
|
123 |
+
|
124 |
+
$definition = $this->definitionSource->getDefinition($name);
|
125 |
+
if (! $definition) {
|
126 |
+
throw new NotFoundException("No entry or class found for '$name'");
|
127 |
+
}
|
128 |
+
|
129 |
+
$value = $this->resolveDefinition($definition);
|
130 |
+
|
131 |
+
// If the entry is singleton, we store it to always return it without recomputing it
|
132 |
+
if ($definition->getScope() === Scope::SINGLETON) {
|
133 |
+
$this->singletonEntries[$name] = $value;
|
134 |
+
}
|
135 |
+
|
136 |
+
return $value;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Build an entry of the container by its name.
|
141 |
+
*
|
142 |
+
* This method behave like get() except it forces the scope to "prototype",
|
143 |
+
* which means the definition of the entry will be re-evaluated each time.
|
144 |
+
* For example, if the entry is a class, then a new instance will be created each time.
|
145 |
+
*
|
146 |
+
* This method makes the container behave like a factory.
|
147 |
+
*
|
148 |
+
* @param string $name Entry name or a class name.
|
149 |
+
* @param array $parameters Optional parameters to use to build the entry. Use this to force specific parameters
|
150 |
+
* to specific values. Parameters not defined in this array will be resolved using
|
151 |
+
* the container.
|
152 |
+
*
|
153 |
+
* @throws InvalidArgumentException The name parameter must be of type string.
|
154 |
+
* @throws DependencyException Error while resolving the entry.
|
155 |
+
* @throws NotFoundException No entry found for the given name.
|
156 |
+
* @return mixed
|
157 |
+
*/
|
158 |
+
public function make($name, array $parameters = [])
|
159 |
+
{
|
160 |
+
if (! is_string($name)) {
|
161 |
+
throw new InvalidArgumentException(sprintf(
|
162 |
+
'The name parameter must be of type string, %s given',
|
163 |
+
is_object($name) ? get_class($name) : gettype($name)
|
164 |
+
));
|
165 |
+
}
|
166 |
+
|
167 |
+
$definition = $this->definitionSource->getDefinition($name);
|
168 |
+
if (! $definition) {
|
169 |
+
// Try to find the entry in the singleton map
|
170 |
+
if (array_key_exists($name, $this->singletonEntries)) {
|
171 |
+
return $this->singletonEntries[$name];
|
172 |
+
}
|
173 |
+
|
174 |
+
throw new NotFoundException("No entry or class found for '$name'");
|
175 |
+
}
|
176 |
+
|
177 |
+
return $this->resolveDefinition($definition, $parameters);
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Test if the container can provide something for the given name.
|
182 |
+
*
|
183 |
+
* @param string $name Entry name or a class name.
|
184 |
+
*
|
185 |
+
* @throws InvalidArgumentException The name parameter must be of type string.
|
186 |
+
* @return bool
|
187 |
+
*/
|
188 |
+
public function has($name)
|
189 |
+
{
|
190 |
+
if (! is_string($name)) {
|
191 |
+
throw new InvalidArgumentException(sprintf(
|
192 |
+
'The name parameter must be of type string, %s given',
|
193 |
+
is_object($name) ? get_class($name) : gettype($name)
|
194 |
+
));
|
195 |
+
}
|
196 |
+
|
197 |
+
if (array_key_exists($name, $this->singletonEntries)) {
|
198 |
+
return true;
|
199 |
+
}
|
200 |
+
|
201 |
+
$definition = $this->definitionSource->getDefinition($name);
|
202 |
+
if ($definition === null) {
|
203 |
+
return false;
|
204 |
+
}
|
205 |
+
|
206 |
+
return $this->definitionResolver->isResolvable($definition);
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Inject all dependencies on an existing instance
|
211 |
+
*
|
212 |
+
* @param object $instance Object to perform injection upon
|
213 |
+
* @throws InvalidArgumentException
|
214 |
+
* @throws DependencyException Error while injecting dependencies
|
215 |
+
* @return object $instance Returns the same instance
|
216 |
+
*/
|
217 |
+
public function injectOn($instance)
|
218 |
+
{
|
219 |
+
$objectDefinition = $this->definitionSource->getDefinition(get_class($instance));
|
220 |
+
if (! $objectDefinition instanceof ObjectDefinition) {
|
221 |
+
return $instance;
|
222 |
+
}
|
223 |
+
|
224 |
+
$definition = new InstanceDefinition($instance, $objectDefinition);
|
225 |
+
|
226 |
+
$this->definitionResolver->resolve($definition);
|
227 |
+
|
228 |
+
return $instance;
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Call the given function using the given parameters.
|
233 |
+
*
|
234 |
+
* Missing parameters will be resolved from the container.
|
235 |
+
*
|
236 |
+
* @param callable $callable Function to call.
|
237 |
+
* @param array $parameters Parameters to use. Can be indexed by the parameter names
|
238 |
+
* or not indexed (same order as the parameters).
|
239 |
+
* The array can also contain DI definitions, e.g. Cybot\Dependencies\DI\get().
|
240 |
+
*
|
241 |
+
* @return mixed Result of the function.
|
242 |
+
*/
|
243 |
+
public function call($callable, array $parameters = [])
|
244 |
+
{
|
245 |
+
return $this->getInvoker()->call($callable, $parameters);
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* Define an object or a value in the container.
|
250 |
+
*
|
251 |
+
* @param string $name Entry name
|
252 |
+
* @param mixed|DefinitionHelper $value Value, use definition helpers to define objects
|
253 |
+
*/
|
254 |
+
public function set($name, $value)
|
255 |
+
{
|
256 |
+
if ($value instanceof DefinitionHelper) {
|
257 |
+
$value = $value->getDefinition($name);
|
258 |
+
} elseif ($value instanceof \Closure) {
|
259 |
+
$value = new FactoryDefinition($name, $value);
|
260 |
+
}
|
261 |
+
|
262 |
+
if ($value instanceof Definition) {
|
263 |
+
$this->setDefinition($name, $value);
|
264 |
+
} else {
|
265 |
+
$this->singletonEntries[$name] = $value;
|
266 |
+
}
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Resolves a definition.
|
271 |
+
*
|
272 |
+
* Checks for circular dependencies while resolving the definition.
|
273 |
+
*
|
274 |
+
* @param Definition $definition
|
275 |
+
* @param array $parameters
|
276 |
+
*
|
277 |
+
* @throws DependencyException Error while resolving the entry.
|
278 |
+
* @return mixed
|
279 |
+
*/
|
280 |
+
private function resolveDefinition(Definition $definition, array $parameters = [])
|
281 |
+
{
|
282 |
+
$entryName = $definition->getName();
|
283 |
+
|
284 |
+
// Check if we are already getting this entry -> circular dependency
|
285 |
+
if (isset($this->entriesBeingResolved[$entryName])) {
|
286 |
+
throw new DependencyException("Circular dependency detected while trying to resolve entry '$entryName'");
|
287 |
+
}
|
288 |
+
$this->entriesBeingResolved[$entryName] = true;
|
289 |
+
|
290 |
+
// Resolve the definition
|
291 |
+
try {
|
292 |
+
$value = $this->definitionResolver->resolve($definition, $parameters);
|
293 |
+
} catch (Exception $exception) {
|
294 |
+
unset($this->entriesBeingResolved[$entryName]);
|
295 |
+
throw $exception;
|
296 |
+
}
|
297 |
+
|
298 |
+
unset($this->entriesBeingResolved[$entryName]);
|
299 |
+
|
300 |
+
return $value;
|
301 |
+
}
|
302 |
+
|
303 |
+
private function setDefinition($name, Definition $definition)
|
304 |
+
{
|
305 |
+
if ($this->definitionSource instanceof CachedDefinitionSource) {
|
306 |
+
throw new \LogicException('You cannot set a definition at runtime on a container that has a cache configured. Doing so would risk caching the definition for the next execution, where it might be different. You can either put your definitions in a file, remove the cache or ->set() a raw value directly (PHP object, string, int, ...) instead of a PHP-DI definition.');
|
307 |
+
}
|
308 |
+
|
309 |
+
if (! $this->definitionSource instanceof MutableDefinitionSource) {
|
310 |
+
// This can happen if you instantiate the container yourself
|
311 |
+
throw new \LogicException('The container has not been initialized correctly');
|
312 |
+
}
|
313 |
+
|
314 |
+
// Clear existing entry if it exists
|
315 |
+
if (array_key_exists($name, $this->singletonEntries)) {
|
316 |
+
unset($this->singletonEntries[$name]);
|
317 |
+
}
|
318 |
+
|
319 |
+
$this->definitionSource->addDefinition($definition);
|
320 |
+
}
|
321 |
+
|
322 |
+
/**
|
323 |
+
* @return \Cybot\Dependencies\Invoker\InvokerInterface
|
324 |
+
*/
|
325 |
+
private function getInvoker()
|
326 |
+
{
|
327 |
+
if (! $this->invoker) {
|
328 |
+
$parameterResolver = new ResolverChain([
|
329 |
+
new NumericArrayResolver,
|
330 |
+
new AssociativeArrayResolver,
|
331 |
+
new DefinitionParameterResolver($this->definitionResolver),
|
332 |
+
new TypeHintContainerResolver($this->wrapperContainer),
|
333 |
+
]);
|
334 |
+
|
335 |
+
$this->invoker = new Invoker($parameterResolver, $this);
|
336 |
+
}
|
337 |
+
|
338 |
+
return $this->invoker;
|
339 |
+
}
|
340 |
+
}
|
addons/inc/Dependencies/DI/ContainerBuilder.php
ADDED
@@ -0,0 +1,258 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\Source\AnnotationReader;
|
13 |
+
use Cybot\Dependencies\DI\Definition\Source\DefinitionArray;
|
14 |
+
use Cybot\Dependencies\DI\Definition\Source\CachedDefinitionSource;
|
15 |
+
use Cybot\Dependencies\DI\Definition\Source\DefinitionSource;
|
16 |
+
use Cybot\Dependencies\DI\Definition\Source\DefinitionFile;
|
17 |
+
use Cybot\Dependencies\DI\Definition\Source\Autowiring;
|
18 |
+
use Cybot\Dependencies\DI\Definition\Source\SourceChain;
|
19 |
+
use Cybot\Dependencies\DI\Proxy\ProxyFactory;
|
20 |
+
use Doctrine\Common\Cache\Cache;
|
21 |
+
use Cybot\Dependencies\Interop\Container\ContainerInterface;
|
22 |
+
use InvalidArgumentException;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Helper to create and configure a Container.
|
26 |
+
*
|
27 |
+
* With the default options, the container created is appropriate for the development environment.
|
28 |
+
*
|
29 |
+
* Example:
|
30 |
+
*
|
31 |
+
* $builder = new ContainerBuilder();
|
32 |
+
* $container = $builder->build();
|
33 |
+
*
|
34 |
+
* @since 3.2
|
35 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
36 |
+
*/
|
37 |
+
class ContainerBuilder
|
38 |
+
{
|
39 |
+
/**
|
40 |
+
* Name of the container class, used to create the container.
|
41 |
+
* @var string
|
42 |
+
*/
|
43 |
+
private $containerClass;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @var boolean
|
47 |
+
*/
|
48 |
+
private $useAutowiring = true;
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @var boolean
|
52 |
+
*/
|
53 |
+
private $useAnnotations = false;
|
54 |
+
|
55 |
+
/**
|
56 |
+
* @var boolean
|
57 |
+
*/
|
58 |
+
private $ignorePhpDocErrors = false;
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @var Cache
|
62 |
+
*/
|
63 |
+
private $cache;
|
64 |
+
|
65 |
+
/**
|
66 |
+
* If true, write the proxies to disk to improve performances.
|
67 |
+
* @var boolean
|
68 |
+
*/
|
69 |
+
private $writeProxiesToFile = false;
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Directory where to write the proxies (if $writeProxiesToFile is enabled).
|
73 |
+
* @var string
|
74 |
+
*/
|
75 |
+
private $proxyDirectory;
|
76 |
+
|
77 |
+
/**
|
78 |
+
* If PHP-DI is wrapped in another container, this references the wrapper.
|
79 |
+
* @var ContainerInterface
|
80 |
+
*/
|
81 |
+
private $wrapperContainer;
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @var DefinitionSource[]
|
85 |
+
*/
|
86 |
+
private $definitionSources = [];
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Build a container configured for the dev environment.
|
90 |
+
*
|
91 |
+
* @return Container
|
92 |
+
*/
|
93 |
+
public static function buildDevContainer()
|
94 |
+
{
|
95 |
+
$builder = new self();
|
96 |
+
return $builder->build();
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* @param string $containerClass Name of the container class, used to create the container.
|
101 |
+
*/
|
102 |
+
public function __construct($containerClass = 'Cybot\Dependencies\DI\Container')
|
103 |
+
{
|
104 |
+
$this->containerClass = $containerClass;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Build and return a container.
|
109 |
+
*
|
110 |
+
* @return Container
|
111 |
+
*/
|
112 |
+
public function build()
|
113 |
+
{
|
114 |
+
$sources = array_reverse($this->definitionSources);
|
115 |
+
if ($this->useAnnotations) {
|
116 |
+
$sources[] = new AnnotationReader($this->ignorePhpDocErrors);
|
117 |
+
} elseif ($this->useAutowiring) {
|
118 |
+
$sources[] = new Autowiring();
|
119 |
+
}
|
120 |
+
|
121 |
+
$chain = new SourceChain($sources);
|
122 |
+
|
123 |
+
if ($this->cache) {
|
124 |
+
$source = new CachedDefinitionSource($chain, $this->cache);
|
125 |
+
$chain->setRootDefinitionSource($source);
|
126 |
+
} else {
|
127 |
+
$source = $chain;
|
128 |
+
// Mutable definition source
|
129 |
+
$source->setMutableDefinitionSource(new DefinitionArray());
|
130 |
+
}
|
131 |
+
|
132 |
+
$proxyFactory = new ProxyFactory($this->writeProxiesToFile, $this->proxyDirectory);
|
133 |
+
|
134 |
+
$containerClass = $this->containerClass;
|
135 |
+
|
136 |
+
return new $containerClass($source, $proxyFactory, $this->wrapperContainer);
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Enable or disable the use of autowiring to guess injections.
|
141 |
+
*
|
142 |
+
* Enabled by default.
|
143 |
+
*
|
144 |
+
* @param boolean $bool
|
145 |
+
* @return ContainerBuilder
|
146 |
+
*/
|
147 |
+
public function useAutowiring($bool)
|
148 |
+
{
|
149 |
+
$this->useAutowiring = $bool;
|
150 |
+
return $this;
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Enable or disable the use of annotations to guess injections.
|
155 |
+
*
|
156 |
+
* Disabled by default.
|
157 |
+
*
|
158 |
+
* @param boolean $bool
|
159 |
+
* @return ContainerBuilder
|
160 |
+
*/
|
161 |
+
public function useAnnotations($bool)
|
162 |
+
{
|
163 |
+
$this->useAnnotations = $bool;
|
164 |
+
return $this;
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Enable or disable ignoring phpdoc errors (non-existent classes in `@param` or `@var`)
|
169 |
+
*
|
170 |
+
* @param boolean $bool
|
171 |
+
* @return ContainerBuilder
|
172 |
+
*/
|
173 |
+
public function ignorePhpDocErrors($bool)
|
174 |
+
{
|
175 |
+
$this->ignorePhpDocErrors = $bool;
|
176 |
+
return $this;
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Enables the use of a cache for the definitions.
|
181 |
+
*
|
182 |
+
* @param Cache $cache Cache backend to use
|
183 |
+
* @return ContainerBuilder
|
184 |
+
*/
|
185 |
+
public function setDefinitionCache(Cache $cache)
|
186 |
+
{
|
187 |
+
$this->cache = $cache;
|
188 |
+
return $this;
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Configure the proxy generation
|
193 |
+
*
|
194 |
+
* For dev environment, use writeProxiesToFile(false) (default configuration)
|
195 |
+
* For production environment, use writeProxiesToFile(true, 'tmp/proxies')
|
196 |
+
*
|
197 |
+
* @param boolean $writeToFile If true, write the proxies to disk to improve performances
|
198 |
+
* @param string|null $proxyDirectory Directory where to write the proxies
|
199 |
+
* @return ContainerBuilder
|
200 |
+
*
|
201 |
+
* @throws InvalidArgumentException when writeToFile is set to true and the proxy directory is null
|
202 |
+
*/
|
203 |
+
public function writeProxiesToFile($writeToFile, $proxyDirectory = null)
|
204 |
+
{
|
205 |
+
$this->writeProxiesToFile = $writeToFile;
|
206 |
+
|
207 |
+
if ($writeToFile && $proxyDirectory === null) {
|
208 |
+
throw new InvalidArgumentException(
|
209 |
+
"The proxy directory must be specified if you want to write proxies on disk"
|
210 |
+
);
|
211 |
+
}
|
212 |
+
$this->proxyDirectory = $proxyDirectory;
|
213 |
+
|
214 |
+
return $this;
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* If PHP-DI's container is wrapped by another container, we can
|
219 |
+
* set this so that PHP-DI will use the wrapper rather than itself for building objects.
|
220 |
+
*
|
221 |
+
* @param ContainerInterface $otherContainer
|
222 |
+
* @return $this
|
223 |
+
*/
|
224 |
+
public function wrapContainer(ContainerInterface $otherContainer)
|
225 |
+
{
|
226 |
+
$this->wrapperContainer = $otherContainer;
|
227 |
+
|
228 |
+
return $this;
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Add definitions to the container.
|
233 |
+
*
|
234 |
+
* @param string|array|DefinitionSource $definitions Can be an array of definitions, the
|
235 |
+
* name of a file containing definitions
|
236 |
+
* or a DefinitionSource object.
|
237 |
+
* @return $this
|
238 |
+
*/
|
239 |
+
public function addDefinitions($definitions)
|
240 |
+
{
|
241 |
+
if (is_string($definitions)) {
|
242 |
+
// File
|
243 |
+
$definitions = new DefinitionFile($definitions);
|
244 |
+
} elseif (is_array($definitions)) {
|
245 |
+
$definitions = new DefinitionArray($definitions);
|
246 |
+
} elseif (! $definitions instanceof DefinitionSource) {
|
247 |
+
throw new InvalidArgumentException(sprintf(
|
248 |
+
'%s parameter must be a string, an array or a DefinitionSource object, %s given',
|
249 |
+
'ContainerBuilder::addDefinitions()',
|
250 |
+
is_object($definitions) ? get_class($definitions) : gettype($definitions)
|
251 |
+
));
|
252 |
+
}
|
253 |
+
|
254 |
+
$this->definitionSources[] = $definitions;
|
255 |
+
|
256 |
+
return $this;
|
257 |
+
}
|
258 |
+
}
|
addons/inc/Dependencies/DI/Debug.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
13 |
+
use Cybot\Dependencies\DI\Definition\Dumper\DefinitionDumperDispatcher;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Debug utilities.
|
17 |
+
*
|
18 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
19 |
+
*/
|
20 |
+
class Debug
|
21 |
+
{
|
22 |
+
/**
|
23 |
+
* Dump the definition to a string.
|
24 |
+
*
|
25 |
+
* @param Definition $definition
|
26 |
+
*
|
27 |
+
* @return string
|
28 |
+
*/
|
29 |
+
public static function dumpDefinition(Definition $definition)
|
30 |
+
{
|
31 |
+
static $dumper;
|
32 |
+
|
33 |
+
if (! $dumper) {
|
34 |
+
$dumper = new DefinitionDumperDispatcher();
|
35 |
+
}
|
36 |
+
|
37 |
+
return $dumper->dump($definition);
|
38 |
+
}
|
39 |
+
}
|
addons/inc/Dependencies/DI/Definition/AbstractFunctionCallDefinition.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Scope;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Describe a function call.
|
16 |
+
*
|
17 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
18 |
+
*/
|
19 |
+
abstract class AbstractFunctionCallDefinition implements Definition
|
20 |
+
{
|
21 |
+
/**
|
22 |
+
* @var array
|
23 |
+
*/
|
24 |
+
protected $parameters = [];
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @return array
|
28 |
+
*/
|
29 |
+
public function getParameters()
|
30 |
+
{
|
31 |
+
return $this->parameters;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @param int $index Position of the parameter (starting at 0)
|
36 |
+
* @return mixed|null Value to inject, or null if no injection defined.
|
37 |
+
*/
|
38 |
+
public function hasParameter($index)
|
39 |
+
{
|
40 |
+
return array_key_exists($index, $this->parameters);
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @param int $index Position of the parameter (starting at 0)
|
45 |
+
* @throws \InvalidArgumentException
|
46 |
+
* @return mixed Value to inject
|
47 |
+
*/
|
48 |
+
public function getParameter($index)
|
49 |
+
{
|
50 |
+
if (! array_key_exists($index, $this->parameters)) {
|
51 |
+
throw new \InvalidArgumentException('There is no parameter value for index ' . $index);
|
52 |
+
}
|
53 |
+
|
54 |
+
return $this->parameters[$index];
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Replace the parameters of the definition by a new array of parameters.
|
59 |
+
*
|
60 |
+
* @param array $parameters
|
61 |
+
*/
|
62 |
+
public function replaceParameters(array $parameters)
|
63 |
+
{
|
64 |
+
$this->parameters = $parameters;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* {@inheritdoc}
|
69 |
+
*/
|
70 |
+
public function getName()
|
71 |
+
{
|
72 |
+
return null;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* {@inheritdoc}
|
77 |
+
*/
|
78 |
+
public function getScope()
|
79 |
+
{
|
80 |
+
return Scope::PROTOTYPE;
|
81 |
+
}
|
82 |
+
}
|
addons/inc/Dependencies/DI/Definition/AliasDefinition.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Scope;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Defines an alias from an entry to another.
|
16 |
+
*
|
17 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
18 |
+
*/
|
19 |
+
class AliasDefinition implements CacheableDefinition
|
20 |
+
{
|
21 |
+
/**
|
22 |
+
* Entry name
|
23 |
+
* @var string
|
24 |
+
*/
|
25 |
+
private $name;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Name of the target entry
|
29 |
+
* @var string
|
30 |
+
*/
|
31 |
+
private $targetEntryName;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @param string $name Entry name
|
35 |
+
* @param string $targetEntryName Name of the target entry
|
36 |
+
*/
|
37 |
+
public function __construct($name, $targetEntryName)
|
38 |
+
{
|
39 |
+
$this->name = $name;
|
40 |
+
$this->targetEntryName = $targetEntryName;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @return string Entry name
|
45 |
+
*/
|
46 |
+
public function getName()
|
47 |
+
{
|
48 |
+
return $this->name;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* {@inheritdoc}
|
53 |
+
*/
|
54 |
+
public function getScope()
|
55 |
+
{
|
56 |
+
return Scope::PROTOTYPE;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @return string
|
61 |
+
*/
|
62 |
+
public function getTargetEntryName()
|
63 |
+
{
|
64 |
+
return $this->targetEntryName;
|
65 |
+
}
|
66 |
+
}
|
addons/inc/Dependencies/DI/Definition/ArrayDefinition.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Scope;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Definition of an array containing values or references.
|
16 |
+
*
|
17 |
+
* @since 5.0
|
18 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
19 |
+
*/
|
20 |
+
class ArrayDefinition implements Definition
|
21 |
+
{
|
22 |
+
/**
|
23 |
+
* Entry name
|
24 |
+
* @var string
|
25 |
+
*/
|
26 |
+
private $name;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @var array
|
30 |
+
*/
|
31 |
+
private $values;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @param string $name Entry name
|
35 |
+
* @param array $values
|
36 |
+
*/
|
37 |
+
public function __construct($name, array $values)
|
38 |
+
{
|
39 |
+
$this->name = $name;
|
40 |
+
$this->values = $values;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @return string Entry name
|
45 |
+
*/
|
46 |
+
public function getName()
|
47 |
+
{
|
48 |
+
return $this->name;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* {@inheritdoc}
|
53 |
+
*/
|
54 |
+
public function getScope()
|
55 |
+
{
|
56 |
+
return Scope::SINGLETON;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @return array
|
61 |
+
*/
|
62 |
+
public function getValues()
|
63 |
+
{
|
64 |
+
return $this->values;
|
65 |
+
}
|
66 |
+
}
|
addons/inc/Dependencies/DI/Definition/ArrayDefinitionExtension.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\Exception\DefinitionException;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Extends an array definition by adding new elements into it.
|
16 |
+
*
|
17 |
+
* @since 5.0
|
18 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
19 |
+
*/
|
20 |
+
class ArrayDefinitionExtension extends ArrayDefinition implements HasSubDefinition
|
21 |
+
{
|
22 |
+
/**
|
23 |
+
* @var ArrayDefinition
|
24 |
+
*/
|
25 |
+
private $subDefinition;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* {@inheritdoc}
|
29 |
+
*/
|
30 |
+
public function getValues()
|
31 |
+
{
|
32 |
+
if (! $this->subDefinition) {
|
33 |
+
return parent::getValues();
|
34 |
+
}
|
35 |
+
|
36 |
+
return array_merge($this->subDefinition->getValues(), parent::getValues());
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @return string
|
41 |
+
*/
|
42 |
+
public function getSubDefinitionName()
|
43 |
+
{
|
44 |
+
return $this->getName();
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* {@inheritdoc}
|
49 |
+
*/
|
50 |
+
public function setSubDefinition(Definition $definition)
|
51 |
+
{
|
52 |
+
if (! $definition instanceof ArrayDefinition) {
|
53 |
+
throw new DefinitionException(sprintf(
|
54 |
+
'Definition %s tries to add array entries but the previous definition is not an array',
|
55 |
+
$this->getName()
|
56 |
+
));
|
57 |
+
}
|
58 |
+
|
59 |
+
$this->subDefinition = $definition;
|
60 |
+
}
|
61 |
+
}
|
addons/inc/Dependencies/DI/Definition/CacheableDefinition.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Cacheable definition
|
14 |
+
*
|
15 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
16 |
+
*/
|
17 |
+
interface CacheableDefinition extends Definition
|
18 |
+
{
|
19 |
+
}
|
addons/inc/Dependencies/DI/Definition/DecoratorDefinition.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Factory that decorates a sub-definition.
|
14 |
+
*
|
15 |
+
* @since 5.0
|
16 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
17 |
+
*/
|
18 |
+
class DecoratorDefinition extends FactoryDefinition implements Definition, HasSubDefinition
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* @var Definition
|
22 |
+
*/
|
23 |
+
private $decorated;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @return string
|
27 |
+
*/
|
28 |
+
public function getSubDefinitionName()
|
29 |
+
{
|
30 |
+
return $this->getName();
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @param Definition $definition
|
35 |
+
*/
|
36 |
+
public function setSubDefinition(Definition $definition)
|
37 |
+
{
|
38 |
+
$this->decorated = $definition;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @return Definition
|
43 |
+
*/
|
44 |
+
public function getDecoratedDefinition()
|
45 |
+
{
|
46 |
+
return $this->decorated;
|
47 |
+
}
|
48 |
+
}
|
addons/inc/Dependencies/DI/Definition/Definition.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Definition
|
14 |
+
*
|
15 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
16 |
+
*/
|
17 |
+
interface Definition
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Returns the name of the entry in the container
|
21 |
+
*
|
22 |
+
* @return string
|
23 |
+
*/
|
24 |
+
public function getName();
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Returns the scope of the entry
|
28 |
+
*
|
29 |
+
* @return string
|
30 |
+
*/
|
31 |
+
public function getScope();
|
32 |
+
}
|
addons/inc/Dependencies/DI/Definition/Dumper/AliasDefinitionDumper.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Dumper;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\AliasDefinition;
|
13 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Dumps alias definitions.
|
17 |
+
*
|
18 |
+
* @since 4.1
|
19 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
20 |
+
*/
|
21 |
+
class AliasDefinitionDumper implements DefinitionDumper
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* {@inheritdoc}
|
25 |
+
*/
|
26 |
+
public function dump(Definition $definition)
|
27 |
+
{
|
28 |
+
if (! $definition instanceof AliasDefinition) {
|
29 |
+
throw new \InvalidArgumentException(sprintf(
|
30 |
+
'This definition dumper is only compatible with AliasDefinition objects, %s given',
|
31 |
+
get_class($definition)
|
32 |
+
));
|
33 |
+
}
|
34 |
+
|
35 |
+
if ($definition->getName()) {
|
36 |
+
return sprintf(
|
37 |
+
"get(%s => %s)",
|
38 |
+
$definition->getName(),
|
39 |
+
$definition->getTargetEntryName()
|
40 |
+
);
|
41 |
+
}
|
42 |
+
|
43 |
+
return sprintf(
|
44 |
+
"get(%s)",
|
45 |
+
$definition->getTargetEntryName()
|
46 |
+
);
|
47 |
+
}
|
48 |
+
}
|
addons/inc/Dependencies/DI/Definition/Dumper/ArrayDefinitionDumper.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Dumper;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Debug;
|
13 |
+
use Cybot\Dependencies\DI\Definition\ArrayDefinition;
|
14 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
15 |
+
use Cybot\Dependencies\DI\Definition\Helper\DefinitionHelper;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Dumps array definitions.
|
19 |
+
*
|
20 |
+
* @since 5.0
|
21 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
22 |
+
*/
|
23 |
+
class ArrayDefinitionDumper implements DefinitionDumper
|
24 |
+
{
|
25 |
+
/**
|
26 |
+
* {@inheritdoc}
|
27 |
+
*/
|
28 |
+
public function dump(Definition $definition)
|
29 |
+
{
|
30 |
+
if (! $definition instanceof ArrayDefinition) {
|
31 |
+
throw new \InvalidArgumentException(sprintf(
|
32 |
+
'This definition dumper is only compatible with ArrayDefinition objects, %s given',
|
33 |
+
get_class($definition)
|
34 |
+
));
|
35 |
+
}
|
36 |
+
|
37 |
+
$str = '[' . PHP_EOL;
|
38 |
+
|
39 |
+
foreach ($definition->getValues() as $key => $value) {
|
40 |
+
if (is_string($key)) {
|
41 |
+
$key = "'" . $key . "'";
|
42 |
+
}
|
43 |
+
|
44 |
+
$str .= ' ' . $key . ' => ';
|
45 |
+
|
46 |
+
if ($value instanceof DefinitionHelper) {
|
47 |
+
$nestedDefinition = Debug::dumpDefinition($value->getDefinition(''));
|
48 |
+
$str .= $this->indent($nestedDefinition);
|
49 |
+
} else {
|
50 |
+
$str .= var_export($value, true);
|
51 |
+
}
|
52 |
+
|
53 |
+
$str .= ',' . PHP_EOL;
|
54 |
+
}
|
55 |
+
|
56 |
+
$str .= ']';
|
57 |
+
|
58 |
+
return $str;
|
59 |
+
}
|
60 |
+
|
61 |
+
private function indent($str)
|
62 |
+
{
|
63 |
+
return str_replace("\n", "\n ", $str);
|
64 |
+
}
|
65 |
+
}
|
addons/inc/Dependencies/DI/Definition/Dumper/DecoratorDefinitionDumper.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Dumper;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\DecoratorDefinition;
|
13 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Dumps decorator definitions.
|
17 |
+
*
|
18 |
+
* @since 5.0
|
19 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
20 |
+
*/
|
21 |
+
class DecoratorDefinitionDumper implements DefinitionDumper
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* {@inheritdoc}
|
25 |
+
*/
|
26 |
+
public function dump(Definition $definition)
|
27 |
+
{
|
28 |
+
if (! $definition instanceof DecoratorDefinition) {
|
29 |
+
throw new \InvalidArgumentException(sprintf(
|
30 |
+
'This definition dumper is only compatible with DecoratorDefinition objects, %s given',
|
31 |
+
get_class($definition)
|
32 |
+
));
|
33 |
+
}
|
34 |
+
|
35 |
+
return 'Decorate(' . $definition->getSubDefinitionName() . ')';
|
36 |
+
}
|
37 |
+
}
|
addons/inc/Dependencies/DI/Definition/Dumper/DefinitionDumper.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Dumper;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Dumps definitions to help debugging.
|
16 |
+
*
|
17 |
+
* @since 4.1
|
18 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
19 |
+
*/
|
20 |
+
interface DefinitionDumper
|
21 |
+
{
|
22 |
+
/**
|
23 |
+
* Returns the given definition as string representation.
|
24 |
+
*
|
25 |
+
* @param Definition $definition
|
26 |
+
*
|
27 |
+
* @return string
|
28 |
+
*/
|
29 |
+
public function dump(Definition $definition);
|
30 |
+
}
|
addons/inc/Dependencies/DI/Definition/Dumper/DefinitionDumperDispatcher.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Dumper;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Dispatch a definition to the appropriate dumper.
|
16 |
+
*
|
17 |
+
* @since 4.1
|
18 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
19 |
+
*/
|
20 |
+
class DefinitionDumperDispatcher implements DefinitionDumper
|
21 |
+
{
|
22 |
+
/**
|
23 |
+
* Definition dumpers, indexed by the class of the definition they can dump.
|
24 |
+
*
|
25 |
+
* @var DefinitionDumper[]|null
|
26 |
+
*/
|
27 |
+
private $dumpers = [];
|
28 |
+
|
29 |
+
public function __construct($dumpers = null)
|
30 |
+
{
|
31 |
+
$this->dumpers = $dumpers;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* {@inheritdoc}
|
36 |
+
*/
|
37 |
+
public function dump(Definition $definition)
|
38 |
+
{
|
39 |
+
$this->initialize();
|
40 |
+
|
41 |
+
$class = get_class($definition);
|
42 |
+
|
43 |
+
if (! array_key_exists($class, $this->dumpers)) {
|
44 |
+
throw new \RuntimeException(sprintf(
|
45 |
+
'There is no DefinitionDumper capable of dumping this definition of type %s',
|
46 |
+
$class
|
47 |
+
));
|
48 |
+
}
|
49 |
+
|
50 |
+
$dumper = $this->dumpers[$class];
|
51 |
+
|
52 |
+
return $dumper->dump($definition);
|
53 |
+
}
|
54 |
+
|
55 |
+
private function initialize()
|
56 |
+
{
|
57 |
+
if ($this->dumpers === null) {
|
58 |
+
$this->dumpers = [
|
59 |
+
'Cybot\Dependencies\DI\Definition\ValueDefinition' => new ValueDefinitionDumper(),
|
60 |
+
'Cybot\Dependencies\DI\Definition\FactoryDefinition' => new FactoryDefinitionDumper(),
|
61 |
+
'Cybot\Dependencies\DI\Definition\DecoratorDefinition' => new DecoratorDefinitionDumper(),
|
62 |
+
'Cybot\Dependencies\DI\Definition\AliasDefinition' => new AliasDefinitionDumper(),
|
63 |
+
'Cybot\Dependencies\DI\Definition\ObjectDefinition' => new ObjectDefinitionDumper(),
|
64 |
+
'Cybot\Dependencies\DI\Definition\EnvironmentVariableDefinition' => new EnvironmentVariableDefinitionDumper(),
|
65 |
+
];
|
66 |
+
}
|
67 |
+
}
|
68 |
+
}
|
addons/inc/Dependencies/DI/Definition/Dumper/EnvironmentVariableDefinitionDumper.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Dumper;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Debug;
|
13 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
14 |
+
use Cybot\Dependencies\DI\Definition\EntryReference;
|
15 |
+
use Cybot\Dependencies\DI\Definition\EnvironmentVariableDefinition;
|
16 |
+
use Cybot\Dependencies\DI\Definition\Helper\DefinitionHelper;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Dumps environment variable definitions.
|
20 |
+
*
|
21 |
+
* @author James Harris <james.harris@icecave.com.au>
|
22 |
+
*/
|
23 |
+
class EnvironmentVariableDefinitionDumper implements DefinitionDumper
|
24 |
+
{
|
25 |
+
/**
|
26 |
+
* {@inheritdoc}
|
27 |
+
*/
|
28 |
+
public function dump(Definition $definition)
|
29 |
+
{
|
30 |
+
if (! $definition instanceof EnvironmentVariableDefinition) {
|
31 |
+
throw new \InvalidArgumentException(sprintf(
|
32 |
+
'This definition dumper is only compatible with EnvironmentVariableDefinition objects, %s given',
|
33 |
+
get_class($definition)
|
34 |
+
));
|
35 |
+
}
|
36 |
+
|
37 |
+
$str = " variable = " . $definition->getVariableName();
|
38 |
+
$str .= "\n optional = " . ($definition->isOptional() ? 'yes' : 'no');
|
39 |
+
|
40 |
+
if ($definition->isOptional()) {
|
41 |
+
$defaultValue = $definition->getDefaultValue();
|
42 |
+
|
43 |
+
if ($defaultValue instanceof DefinitionHelper) {
|
44 |
+
$nestedDefinition = Debug::dumpDefinition($defaultValue->getDefinition(''));
|
45 |
+
$defaultValueStr = $this->indent($nestedDefinition);
|
46 |
+
} else {
|
47 |
+
$defaultValueStr = var_export($defaultValue, true);
|
48 |
+
}
|
49 |
+
|
50 |
+
$str .= "\n default = " . $defaultValueStr;
|
51 |
+
}
|
52 |
+
|
53 |
+
return sprintf(
|
54 |
+
"Environment variable (\n%s\n)",
|
55 |
+
$str
|
56 |
+
);
|
57 |
+
}
|
58 |
+
|
59 |
+
private function indent($str)
|
60 |
+
{
|
61 |
+
return str_replace("\n", "\n ", $str);
|
62 |
+
}
|
63 |
+
}
|
addons/inc/Dependencies/DI/Definition/Dumper/FactoryDefinitionDumper.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Dumper;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
13 |
+
use Cybot\Dependencies\DI\Definition\FactoryDefinition;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Dumps factory definitions.
|
17 |
+
*
|
18 |
+
* @since 4.1
|
19 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
20 |
+
*/
|
21 |
+
class FactoryDefinitionDumper implements DefinitionDumper
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* {@inheritdoc}
|
25 |
+
*/
|
26 |
+
public function dump(Definition $definition)
|
27 |
+
{
|
28 |
+
if (! $definition instanceof FactoryDefinition) {
|
29 |
+
throw new \InvalidArgumentException(sprintf(
|
30 |
+
'This definition dumper is only compatible with FactoryDefinition objects, %s given',
|
31 |
+
get_class($definition)
|
32 |
+
));
|
33 |
+
}
|
34 |
+
|
35 |
+
return 'Factory';
|
36 |
+
}
|
37 |
+
}
|
addons/inc/Dependencies/DI/Definition/Dumper/ObjectDefinitionDumper.php
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Dumper;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\ObjectDefinition;
|
13 |
+
use Cybot\Dependencies\DI\Definition\ObjectDefinition\MethodInjection;
|
14 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
15 |
+
use Cybot\Dependencies\DI\Definition\EntryReference;
|
16 |
+
use ReflectionException;
|
17 |
+
use ReflectionMethod;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Dumps object definitions.
|
21 |
+
*
|
22 |
+
* @since 4.1
|
23 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
24 |
+
*/
|
25 |
+
class ObjectDefinitionDumper implements DefinitionDumper
|
26 |
+
{
|
27 |
+
/**
|
28 |
+
* {@inheritdoc}
|
29 |
+
*/
|
30 |
+
public function dump(Definition $definition)
|
31 |
+
{
|
32 |
+
if (! $definition instanceof ObjectDefinition) {
|
33 |
+
throw new \InvalidArgumentException(sprintf(
|
34 |
+
'This definition dumper is only compatible with ObjectDefinition objects, %s given',
|
35 |
+
get_class($definition)
|
36 |
+
));
|
37 |
+
}
|
38 |
+
|
39 |
+
$className = $definition->getClassName();
|
40 |
+
$classExist = class_exists($className) || interface_exists($className);
|
41 |
+
|
42 |
+
// Class
|
43 |
+
if (! $classExist) {
|
44 |
+
$warning = '#UNKNOWN# ';
|
45 |
+
} else {
|
46 |
+
$class = new \ReflectionClass($className);
|
47 |
+
$warning = $class->isInstantiable() ? '' : '#NOT INSTANTIABLE# ';
|
48 |
+
}
|
49 |
+
$str = sprintf(' class = %s%s', $warning, $className);
|
50 |
+
|
51 |
+
// Scope
|
52 |
+
$str .= "\n scope = " . $definition->getScope();
|
53 |
+
|
54 |
+
// Lazy
|
55 |
+
$str .= "\n lazy = " . var_export($definition->isLazy(), true);
|
56 |
+
|
57 |
+
if ($classExist) {
|
58 |
+
// Constructor
|
59 |
+
$str .= $this->dumpConstructor($className, $definition);
|
60 |
+
|
61 |
+
// Properties
|
62 |
+
$str .= $this->dumpProperties($definition);
|
63 |
+
|
64 |
+
// Methods
|
65 |
+
$str .= $this->dumpMethods($className, $definition);
|
66 |
+
}
|
67 |
+
|
68 |
+
return sprintf("Object (\n%s\n)", $str);
|
69 |
+
}
|
70 |
+
|
71 |
+
private function dumpConstructor($className, ObjectDefinition $definition)
|
72 |
+
{
|
73 |
+
$str = '';
|
74 |
+
|
75 |
+
$constructorInjection = $definition->getConstructorInjection();
|
76 |
+
|
77 |
+
if ($constructorInjection !== null) {
|
78 |
+
$parameters = $this->dumpMethodParameters($className, $constructorInjection);
|
79 |
+
|
80 |
+
$str .= sprintf("\n __construct(\n %s\n )", $parameters);
|
81 |
+
}
|
82 |
+
|
83 |
+
return $str;
|
84 |
+
}
|
85 |
+
|
86 |
+
private function dumpProperties(ObjectDefinition $definition)
|
87 |
+
{
|
88 |
+
$str = '';
|
89 |
+
|
90 |
+
foreach ($definition->getPropertyInjections() as $propertyInjection) {
|
91 |
+
$value = $propertyInjection->getValue();
|
92 |
+
if ($value instanceof EntryReference) {
|
93 |
+
$valueStr = sprintf('get(%s)', $value->getName());
|
94 |
+
} else {
|
95 |
+
$valueStr = var_export($value, true);
|
96 |
+
}
|
97 |
+
|
98 |
+
$str .= sprintf("\n $%s = %s", $propertyInjection->getPropertyName(), $valueStr);
|
99 |
+
}
|
100 |
+
|
101 |
+
return $str;
|
102 |
+
}
|
103 |
+
|
104 |
+
private function dumpMethods($className, ObjectDefinition $definition)
|
105 |
+
{
|
106 |
+
$str = '';
|
107 |
+
|
108 |
+
foreach ($definition->getMethodInjections() as $methodInjection) {
|
109 |
+
$parameters = $this->dumpMethodParameters($className, $methodInjection);
|
110 |
+
|
111 |
+
$str .= sprintf("\n %s(\n %s\n )", $methodInjection->getMethodName(), $parameters);
|
112 |
+
}
|
113 |
+
|
114 |
+
return $str;
|
115 |
+
}
|
116 |
+
|
117 |
+
private function dumpMethodParameters($className, MethodInjection $methodInjection)
|
118 |
+
{
|
119 |
+
$methodReflection = new \ReflectionMethod($className, $methodInjection->getMethodName());
|
120 |
+
|
121 |
+
$args = [];
|
122 |
+
|
123 |
+
foreach ($methodReflection->getParameters() as $index => $parameter) {
|
124 |
+
if ($methodInjection->hasParameter($index)) {
|
125 |
+
$value = $methodInjection->getParameter($index);
|
126 |
+
|
127 |
+
if ($value instanceof EntryReference) {
|
128 |
+
$args[] = sprintf('$%s = get(%s)', $parameter->getName(), $value->getName());
|
129 |
+
} else {
|
130 |
+
$args[] = sprintf('$%s = %s', $parameter->getName(), var_export($value, true));
|
131 |
+
}
|
132 |
+
continue;
|
133 |
+
}
|
134 |
+
|
135 |
+
// If the parameter is optional and wasn't specified, we take its default value
|
136 |
+
if ($parameter->isOptional()) {
|
137 |
+
try {
|
138 |
+
$value = $parameter->getDefaultValue();
|
139 |
+
|
140 |
+
$args[] = sprintf(
|
141 |
+
'$%s = (default value) %s',
|
142 |
+
$parameter->getName(),
|
143 |
+
var_export($value, true)
|
144 |
+
);
|
145 |
+
continue;
|
146 |
+
} catch (ReflectionException $e) {
|
147 |
+
// The default value can't be read through Reflection because it is a PHP internal class
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
$args[] = sprintf('$%s = #UNDEFINED#', $parameter->getName());
|
152 |
+
}
|
153 |
+
|
154 |
+
return implode(PHP_EOL . ' ', $args);
|
155 |
+
}
|
156 |
+
}
|
addons/inc/Dependencies/DI/Definition/Dumper/StringDefinitionDumper.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Dumper;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
13 |
+
use Cybot\Dependencies\DI\Definition\StringDefinition;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Dumps string definitions.
|
17 |
+
*
|
18 |
+
* @since 5.0
|
19 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
20 |
+
*/
|
21 |
+
class StringDefinitionDumper implements DefinitionDumper
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* {@inheritdoc}
|
25 |
+
*/
|
26 |
+
public function dump(Definition $definition)
|
27 |
+
{
|
28 |
+
if (! $definition instanceof StringDefinition) {
|
29 |
+
throw new \InvalidArgumentException(sprintf(
|
30 |
+
'This definition dumper is only compatible with StringDefinition objects, %s given',
|
31 |
+
get_class($definition)
|
32 |
+
));
|
33 |
+
}
|
34 |
+
|
35 |
+
return $definition->getExpression();
|
36 |
+
}
|
37 |
+
}
|
addons/inc/Dependencies/DI/Definition/Dumper/ValueDefinitionDumper.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Dumper;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
13 |
+
use Cybot\Dependencies\DI\Definition\ValueDefinition;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Dumps value definitions.
|
17 |
+
*
|
18 |
+
* @since 4.1
|
19 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
20 |
+
*/
|
21 |
+
class ValueDefinitionDumper implements DefinitionDumper
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* {@inheritdoc}
|
25 |
+
*/
|
26 |
+
public function dump(Definition $definition)
|
27 |
+
{
|
28 |
+
if (! $definition instanceof ValueDefinition) {
|
29 |
+
throw new \InvalidArgumentException(sprintf(
|
30 |
+
'This definition dumper is only compatible with ValueDefinition objects, %s given',
|
31 |
+
get_class($definition)
|
32 |
+
));
|
33 |
+
}
|
34 |
+
|
35 |
+
ob_start();
|
36 |
+
|
37 |
+
var_dump($definition->getValue());
|
38 |
+
|
39 |
+
return sprintf(
|
40 |
+
"Value (\n %s\n)",
|
41 |
+
trim(ob_get_clean())
|
42 |
+
);
|
43 |
+
}
|
44 |
+
}
|
addons/inc/Dependencies/DI/Definition/EntryReference.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\Helper\DefinitionHelper;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Represents a reference to a container entry.
|
16 |
+
*
|
17 |
+
* TODO should EntryReference and AliasDefinition be merged into a ReferenceDefinition?
|
18 |
+
*
|
19 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
20 |
+
*/
|
21 |
+
class EntryReference implements DefinitionHelper
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* Entry name
|
25 |
+
* @var string
|
26 |
+
*/
|
27 |
+
private $name;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @param string $entryName Entry name
|
31 |
+
*/
|
32 |
+
public function __construct($entryName)
|
33 |
+
{
|
34 |
+
$this->name = $entryName;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @return string Entry name
|
39 |
+
*/
|
40 |
+
public function getName()
|
41 |
+
{
|
42 |
+
return $this->name;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* {@inheritdoc}
|
47 |
+
*/
|
48 |
+
public function getDefinition($entryName)
|
49 |
+
{
|
50 |
+
return new AliasDefinition($entryName, $this->name);
|
51 |
+
}
|
52 |
+
}
|
addons/inc/Dependencies/DI/Definition/EnvironmentVariableDefinition.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Scope;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Defines a reference to an environment variable, with fallback to a default
|
16 |
+
* value if the environment variable is not defined.
|
17 |
+
*
|
18 |
+
* @author James Harris <james.harris@icecave.com.au>
|
19 |
+
*/
|
20 |
+
class EnvironmentVariableDefinition implements CacheableDefinition
|
21 |
+
{
|
22 |
+
/**
|
23 |
+
* Entry name
|
24 |
+
* @var string
|
25 |
+
*/
|
26 |
+
private $name;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* The name of the environment variable
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
private $variableName;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Whether or not the environment variable definition is optional
|
36 |
+
*
|
37 |
+
* If true and the environment variable given by $variableName has not been
|
38 |
+
* defined, $defaultValue is used.
|
39 |
+
*
|
40 |
+
* @var boolean
|
41 |
+
*/
|
42 |
+
private $isOptional;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* The default value to use if the environment variable is optional and not provided
|
46 |
+
* @var mixed
|
47 |
+
*/
|
48 |
+
private $defaultValue;
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @var string|null
|
52 |
+
*/
|
53 |
+
private $scope;
|
54 |
+
|
55 |
+
/**
|
56 |
+
* @param string $name Entry name
|
57 |
+
* @param string $variableName The name of the environment variable
|
58 |
+
* @param boolean $isOptional Whether or not the environment variable definition is optional
|
59 |
+
* @param mixed $defaultValue The default value to use if the environment variable is optional and not provided
|
60 |
+
*/
|
61 |
+
public function __construct($name, $variableName, $isOptional = false, $defaultValue = null)
|
62 |
+
{
|
63 |
+
$this->name = $name;
|
64 |
+
$this->variableName = $variableName;
|
65 |
+
$this->isOptional = $isOptional;
|
66 |
+
$this->defaultValue = $defaultValue;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @return string Entry name
|
71 |
+
*/
|
72 |
+
public function getName()
|
73 |
+
{
|
74 |
+
return $this->name;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @return string The name of the environment variable
|
79 |
+
*/
|
80 |
+
public function getVariableName()
|
81 |
+
{
|
82 |
+
return $this->variableName;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* @return boolean Whether or not the environment variable definition is optional
|
87 |
+
*/
|
88 |
+
public function isOptional()
|
89 |
+
{
|
90 |
+
return $this->isOptional;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* @return mixed The default value to use if the environment variable is optional and not provided
|
95 |
+
*/
|
96 |
+
public function getDefaultValue()
|
97 |
+
{
|
98 |
+
return $this->defaultValue;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* @param string $scope
|
103 |
+
*/
|
104 |
+
public function setScope($scope)
|
105 |
+
{
|
106 |
+
$this->scope = $scope;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* {@inheritdoc}
|
111 |
+
*/
|
112 |
+
public function getScope()
|
113 |
+
{
|
114 |
+
return $this->scope ?: Scope::SINGLETON;
|
115 |
+
}
|
116 |
+
}
|
addons/inc/Dependencies/DI/Definition/Exception/AnnotationException.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Exception;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Exception in the definitions using annotations
|
14 |
+
*
|
15 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
16 |
+
*/
|
17 |
+
class AnnotationException extends DefinitionException
|
18 |
+
{
|
19 |
+
}
|
addons/inc/Dependencies/DI/Definition/Exception/DefinitionException.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Exception;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Debug;
|
13 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Invalid DI definitions
|
17 |
+
*
|
18 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
19 |
+
*/
|
20 |
+
class DefinitionException extends \Exception
|
21 |
+
{
|
22 |
+
public static function create(Definition $definition, $message)
|
23 |
+
{
|
24 |
+
return new self(sprintf(
|
25 |
+
"%s\nFull definition:\n%s",
|
26 |
+
$message,
|
27 |
+
Debug::dumpDefinition($definition)
|
28 |
+
));
|
29 |
+
}
|
30 |
+
}
|
addons/inc/Dependencies/DI/Definition/FactoryDefinition.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Scope;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Definition of a value or class with a factory.
|
16 |
+
*
|
17 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
18 |
+
*/
|
19 |
+
class FactoryDefinition implements Definition
|
20 |
+
{
|
21 |
+
/**
|
22 |
+
* Entry name.
|
23 |
+
* @var string
|
24 |
+
*/
|
25 |
+
private $name;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @var string
|
29 |
+
*/
|
30 |
+
private $scope;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Callable that returns the value.
|
34 |
+
* @var callable
|
35 |
+
*/
|
36 |
+
private $factory;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @param string $name Entry name
|
40 |
+
* @param callable $factory Callable that returns the value associated to the entry name.
|
41 |
+
* @param string|null $scope
|
42 |
+
*/
|
43 |
+
public function __construct($name, $factory, $scope = null)
|
44 |
+
{
|
45 |
+
$this->name = $name;
|
46 |
+
$this->factory = $factory;
|
47 |
+
$this->scope = $scope;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @return string Entry name.
|
52 |
+
*/
|
53 |
+
public function getName()
|
54 |
+
{
|
55 |
+
return $this->name;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Default scope is singleton: the callable is called once and the result is shared.
|
60 |
+
*
|
61 |
+
* {@inheritdoc}
|
62 |
+
*/
|
63 |
+
public function getScope()
|
64 |
+
{
|
65 |
+
return $this->scope ?: Scope::SINGLETON;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* @return callable Callable that returns the value associated to the entry name.
|
70 |
+
*/
|
71 |
+
public function getCallable()
|
72 |
+
{
|
73 |
+
return $this->factory;
|
74 |
+
}
|
75 |
+
}
|
addons/inc/Dependencies/DI/Definition/HasSubDefinition.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* A definition that has a sub-definition.
|
14 |
+
*
|
15 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
16 |
+
*/
|
17 |
+
interface HasSubDefinition extends Definition
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* @return string
|
21 |
+
*/
|
22 |
+
public function getSubDefinitionName();
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @param Definition $definition
|
26 |
+
*/
|
27 |
+
public function setSubDefinition(Definition $definition);
|
28 |
+
}
|
addons/inc/Dependencies/DI/Definition/Helper/ArrayDefinitionExtensionHelper.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Helper;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\ArrayDefinitionExtension;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Helps extending the definition of an array.
|
16 |
+
*
|
17 |
+
* For example you can add new entries to the array.
|
18 |
+
*
|
19 |
+
* @since 5.0
|
20 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
21 |
+
*/
|
22 |
+
class ArrayDefinitionExtensionHelper implements DefinitionHelper
|
23 |
+
{
|
24 |
+
/**
|
25 |
+
* @var array
|
26 |
+
*/
|
27 |
+
private $values = [];
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @param array $values Values to add to the array.
|
31 |
+
*/
|
32 |
+
public function __construct(array $values)
|
33 |
+
{
|
34 |
+
$this->values = $values;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @param string $entryName Container entry name
|
39 |
+
*
|
40 |
+
* @return ArrayDefinitionExtension
|
41 |
+
*/
|
42 |
+
public function getDefinition($entryName)
|
43 |
+
{
|
44 |
+
return new ArrayDefinitionExtension($entryName, $this->values);
|
45 |
+
}
|
46 |
+
}
|
addons/inc/Dependencies/DI/Definition/Helper/DefinitionHelper.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Helper;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Helps defining container entries.
|
14 |
+
*
|
15 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
16 |
+
*/
|
17 |
+
interface DefinitionHelper
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* @param string $entryName Container entry name
|
21 |
+
* @return \Cybot\Dependencies\DI\Definition\Definition
|
22 |
+
*/
|
23 |
+
public function getDefinition($entryName);
|
24 |
+
}
|
addons/inc/Dependencies/DI/Definition/Helper/EnvironmentVariableDefinitionHelper.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Helper;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\EnvironmentVariableDefinition;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Helps defining how to create an instance of an environment variable definition.
|
16 |
+
*
|
17 |
+
* @author James Harris <james.harris@icecave.com.au>
|
18 |
+
*/
|
19 |
+
class EnvironmentVariableDefinitionHelper implements DefinitionHelper
|
20 |
+
{
|
21 |
+
/**
|
22 |
+
* The name of the environment variable
|
23 |
+
* @var string
|
24 |
+
*/
|
25 |
+
private $variableName;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Whether or not the environment variable definition is optional
|
29 |
+
*
|
30 |
+
* If true and the environment variable given by $variableName has not been
|
31 |
+
* defined, $defaultValue is used.
|
32 |
+
*
|
33 |
+
* @var boolean
|
34 |
+
*/
|
35 |
+
private $isOptional;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* The default value to use if the environment variable is optional and not provided
|
39 |
+
* @var mixed
|
40 |
+
*/
|
41 |
+
private $defaultValue;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @param string $variableName The name of the environment variable
|
45 |
+
* @param boolean $isOptional Whether or not the environment variable definition is optional
|
46 |
+
* @param mixed $defaultValue The default value to use if the environment variable is optional and not provided
|
47 |
+
*/
|
48 |
+
public function __construct($variableName, $isOptional, $defaultValue = null)
|
49 |
+
{
|
50 |
+
$this->variableName = $variableName;
|
51 |
+
$this->isOptional = $isOptional;
|
52 |
+
$this->defaultValue = $defaultValue;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* @param string $entryName Container entry name
|
57 |
+
*
|
58 |
+
* @return EnvironmentVariableDefinition
|
59 |
+
*/
|
60 |
+
public function getDefinition($entryName)
|
61 |
+
{
|
62 |
+
return new EnvironmentVariableDefinition($entryName, $this->variableName, $this->isOptional, $this->defaultValue);
|
63 |
+
}
|
64 |
+
}
|
addons/inc/Dependencies/DI/Definition/Helper/FactoryDefinitionHelper.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Helper;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\DecoratorDefinition;
|
13 |
+
use Cybot\Dependencies\DI\Definition\FactoryDefinition;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Helps defining how to create an instance of a class using a factory (callable).
|
17 |
+
*
|
18 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
19 |
+
*/
|
20 |
+
class FactoryDefinitionHelper implements DefinitionHelper
|
21 |
+
{
|
22 |
+
/**
|
23 |
+
* @var callable
|
24 |
+
*/
|
25 |
+
private $factory;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @var string|null
|
29 |
+
*/
|
30 |
+
private $scope;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @var bool
|
34 |
+
*/
|
35 |
+
private $decorate;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @param callable $factory
|
39 |
+
* @param bool $decorate Is the factory decorating a previous definition?
|
40 |
+
*/
|
41 |
+
public function __construct($factory, $decorate = false)
|
42 |
+
{
|
43 |
+
$this->factory = $factory;
|
44 |
+
$this->decorate = $decorate;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Defines the scope of the entry.
|
49 |
+
*
|
50 |
+
* @param string $scope
|
51 |
+
*
|
52 |
+
* @return FactoryDefinitionHelper
|
53 |
+
*/
|
54 |
+
public function scope($scope)
|
55 |
+
{
|
56 |
+
$this->scope = $scope;
|
57 |
+
return $this;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @param string $entryName Container entry name
|
62 |
+
* @return FactoryDefinition
|
63 |
+
*/
|
64 |
+
public function getDefinition($entryName)
|
65 |
+
{
|
66 |
+
if ($this->decorate) {
|
67 |
+
return new DecoratorDefinition($entryName, $this->factory, $this->scope);
|
68 |
+
}
|
69 |
+
|
70 |
+
return new FactoryDefinition($entryName, $this->factory, $this->scope);
|
71 |
+
}
|
72 |
+
}
|
addons/inc/Dependencies/DI/Definition/Helper/ObjectDefinitionHelper.php
ADDED
@@ -0,0 +1,273 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Helper;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\ObjectDefinition;
|
13 |
+
use Cybot\Dependencies\DI\Definition\ObjectDefinition\MethodInjection;
|
14 |
+
use Cybot\Dependencies\DI\Definition\ObjectDefinition\PropertyInjection;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Helps defining how to create an instance of a class.
|
18 |
+
*
|
19 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
20 |
+
*/
|
21 |
+
class ObjectDefinitionHelper implements DefinitionHelper
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* @var string|null
|
25 |
+
*/
|
26 |
+
private $className;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @var boolean|null
|
30 |
+
*/
|
31 |
+
private $lazy;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @var string|null
|
35 |
+
*/
|
36 |
+
private $scope;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Array of constructor parameters.
|
40 |
+
* @var array
|
41 |
+
*/
|
42 |
+
private $constructor = [];
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Array of properties and their value.
|
46 |
+
* @var array
|
47 |
+
*/
|
48 |
+
private $properties = [];
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Array of methods and their parameters.
|
52 |
+
* @var array
|
53 |
+
*/
|
54 |
+
private $methods = [];
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Helper for defining an object.
|
58 |
+
*
|
59 |
+
* @param string|null $className Class name of the object.
|
60 |
+
* If null, the name of the entry (in the container) will be used as class name.
|
61 |
+
*/
|
62 |
+
public function __construct($className = null)
|
63 |
+
{
|
64 |
+
$this->className = $className;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Define the entry as lazy.
|
69 |
+
*
|
70 |
+
* A lazy entry is created only when it is used, a proxy is injected instead.
|
71 |
+
*
|
72 |
+
* @return ObjectDefinitionHelper
|
73 |
+
*/
|
74 |
+
public function lazy()
|
75 |
+
{
|
76 |
+
$this->lazy = true;
|
77 |
+
return $this;
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Defines the scope of the entry.
|
82 |
+
*
|
83 |
+
* @param string $scope
|
84 |
+
*
|
85 |
+
* @return ObjectDefinitionHelper
|
86 |
+
*/
|
87 |
+
public function scope($scope)
|
88 |
+
{
|
89 |
+
$this->scope = $scope;
|
90 |
+
return $this;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Defines the arguments to use to call the constructor.
|
95 |
+
*
|
96 |
+
* This method takes a variable number of arguments, example:
|
97 |
+
* ->constructor($param1, $param2, $param3)
|
98 |
+
*
|
99 |
+
* @param mixed ... Parameters to use for calling the constructor of the class.
|
100 |
+
*
|
101 |
+
* @return ObjectDefinitionHelper
|
102 |
+
*/
|
103 |
+
public function constructor()
|
104 |
+
{
|
105 |
+
$this->constructor = func_get_args();
|
106 |
+
return $this;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Defines a value for a specific argument of the constructor.
|
111 |
+
*
|
112 |
+
* This method is usually used together with annotations or autowiring, when a parameter
|
113 |
+
* is not (or cannot be) type-hinted. Using this method instead of constructor() allows to
|
114 |
+
* avoid defining all the parameters (letting them being resolved using annotations or autowiring)
|
115 |
+
* and only define one.
|
116 |
+
*
|
117 |
+
* @param string $parameter Parameter for which the value will be given.
|
118 |
+
* @param mixed $value Value to give to this parameter.
|
119 |
+
*
|
120 |
+
* @return ObjectDefinitionHelper
|
121 |
+
*/
|
122 |
+
public function constructorParameter($parameter, $value)
|
123 |
+
{
|
124 |
+
$this->constructor[$parameter] = $value;
|
125 |
+
return $this;
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Defines a value to inject in a property of the object.
|
130 |
+
*
|
131 |
+
* @param string $property Entry in which to inject the value.
|
132 |
+
* @param mixed $value Value to inject in the property.
|
133 |
+
*
|
134 |
+
* @return ObjectDefinitionHelper
|
135 |
+
*/
|
136 |
+
public function property($property, $value)
|
137 |
+
{
|
138 |
+
$this->properties[$property] = $value;
|
139 |
+
return $this;
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Defines a method to call and the arguments to use.
|
144 |
+
*
|
145 |
+
* This method takes a variable number of arguments after the method name, example:
|
146 |
+
*
|
147 |
+
* ->method('myMethod', $param1, $param2)
|
148 |
+
*
|
149 |
+
* Can be used multiple times to declare multiple calls.
|
150 |
+
*
|
151 |
+
* @param string $method Name of the method to call.
|
152 |
+
* @param mixed ... Parameters to use for calling the method.
|
153 |
+
*
|
154 |
+
* @return ObjectDefinitionHelper
|
155 |
+
*/
|
156 |
+
public function method($method)
|
157 |
+
{
|
158 |
+
$args = func_get_args();
|
159 |
+
array_shift($args);
|
160 |
+
|
161 |
+
if (! isset($this->methods[$method])) {
|
162 |
+
$this->methods[$method] = [];
|
163 |
+
}
|
164 |
+
|
165 |
+
$this->methods[$method][] = $args;
|
166 |
+
|
167 |
+
return $this;
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Defines a method to call and a value for a specific argument.
|
172 |
+
*
|
173 |
+
* This method is usually used together with annotations or autowiring, when a parameter
|
174 |
+
* is not (or cannot be) type-hinted. Using this method instead of method() allows to
|
175 |
+
* avoid defining all the parameters (letting them being resolved using annotations or
|
176 |
+
* autowiring) and only define one.
|
177 |
+
*
|
178 |
+
* If multiple calls to the method have been configured already (e.g. in a previous definition)
|
179 |
+
* then this method only overrides the parameter for the *first* call.
|
180 |
+
*
|
181 |
+
* @param string $method Name of the method to call.
|
182 |
+
* @param string $parameter Name or index of the parameter for which the value will be given.
|
183 |
+
* @param mixed $value Value to give to this parameter.
|
184 |
+
*
|
185 |
+
* @return ObjectDefinitionHelper
|
186 |
+
*/
|
187 |
+
public function methodParameter($method, $parameter, $value)
|
188 |
+
{
|
189 |
+
// Special case for the constructor
|
190 |
+
if ($method === '__construct') {
|
191 |
+
$this->constructor[$parameter] = $value;
|
192 |
+
return $this;
|
193 |
+
}
|
194 |
+
|
195 |
+
if (! isset($this->methods[$method])) {
|
196 |
+
$this->methods[$method] = [0 => []];
|
197 |
+
}
|
198 |
+
|
199 |
+
$this->methods[$method][0][$parameter] = $value;
|
200 |
+
|
201 |
+
return $this;
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* {@inheritdoc}
|
206 |
+
*/
|
207 |
+
public function getDefinition($entryName)
|
208 |
+
{
|
209 |
+
$definition = new ObjectDefinition($entryName, $this->className);
|
210 |
+
|
211 |
+
if ($this->lazy !== null) {
|
212 |
+
$definition->setLazy($this->lazy);
|
213 |
+
}
|
214 |
+
if ($this->scope !== null) {
|
215 |
+
$definition->setScope($this->scope);
|
216 |
+
}
|
217 |
+
|
218 |
+
if (! empty($this->constructor)) {
|
219 |
+
$parameters = $this->fixParameters($definition, '__construct', $this->constructor);
|
220 |
+
$constructorInjection = MethodInjection::constructor($parameters);
|
221 |
+
$definition->setConstructorInjection($constructorInjection);
|
222 |
+
}
|
223 |
+
|
224 |
+
if (! empty($this->properties)) {
|
225 |
+
foreach ($this->properties as $property => $value) {
|
226 |
+
$definition->addPropertyInjection(
|
227 |
+
new PropertyInjection($property, $value)
|
228 |
+
);
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
if (! empty($this->methods)) {
|
233 |
+
foreach ($this->methods as $method => $calls) {
|
234 |
+
foreach ($calls as $parameters) {
|
235 |
+
$parameters = $this->fixParameters($definition, $method, $parameters);
|
236 |
+
$methodInjection = new MethodInjection($method, $parameters);
|
237 |
+
$definition->addMethodInjection($methodInjection);
|
238 |
+
}
|
239 |
+
}
|
240 |
+
}
|
241 |
+
|
242 |
+
return $definition;
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Fixes parameters indexed by the parameter name -> reindex by position.
|
247 |
+
*
|
248 |
+
* This is necessary so that merging definitions between sources is possible.
|
249 |
+
*
|
250 |
+
* @param ObjectDefinition $definition
|
251 |
+
* @param string $method
|
252 |
+
* @param array $parameters
|
253 |
+
* @return array
|
254 |
+
*/
|
255 |
+
private function fixParameters(ObjectDefinition $definition, $method, $parameters)
|
256 |
+
{
|
257 |
+
$fixedParameters = [];
|
258 |
+
|
259 |
+
foreach ($parameters as $index => $parameter) {
|
260 |
+
// Parameter indexed by the parameter name, we reindex it with its position
|
261 |
+
if (is_string($index)) {
|
262 |
+
$callable = [$definition->getClassName(), $method];
|
263 |
+
$reflectionParameter = new \ReflectionParameter($callable, $index);
|
264 |
+
|
265 |
+
$index = $reflectionParameter->getPosition();
|
266 |
+
}
|
267 |
+
|
268 |
+
$fixedParameters[$index] = $parameter;
|
269 |
+
}
|
270 |
+
|
271 |
+
return $fixedParameters;
|
272 |
+
}
|
273 |
+
}
|
addons/inc/Dependencies/DI/Definition/Helper/StringDefinitionHelper.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Helper;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\StringDefinition;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @since 5.0
|
16 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
17 |
+
*/
|
18 |
+
class StringDefinitionHelper implements DefinitionHelper
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
+
private $expression;
|
24 |
+
|
25 |
+
public function __construct($expression)
|
26 |
+
{
|
27 |
+
$this->expression = $expression;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @param string $entryName Container entry name
|
32 |
+
*
|
33 |
+
* @return StringDefinition
|
34 |
+
*/
|
35 |
+
public function getDefinition($entryName)
|
36 |
+
{
|
37 |
+
return new StringDefinition($entryName, $this->expression);
|
38 |
+
}
|
39 |
+
}
|
addons/inc/Dependencies/DI/Definition/Helper/ValueDefinitionHelper.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Helper;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\ValueDefinition;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Helps defining a value.
|
16 |
+
*
|
17 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
18 |
+
*/
|
19 |
+
class ValueDefinitionHelper implements DefinitionHelper
|
20 |
+
{
|
21 |
+
/**
|
22 |
+
* @var mixed
|
23 |
+
*/
|
24 |
+
private $value;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @param mixed $value
|
28 |
+
*/
|
29 |
+
public function __construct($value)
|
30 |
+
{
|
31 |
+
$this->value = $value;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @param string $entryName Container entry name
|
36 |
+
* @return ValueDefinition
|
37 |
+
*/
|
38 |
+
public function getDefinition($entryName)
|
39 |
+
{
|
40 |
+
return new ValueDefinition($entryName, $this->value);
|
41 |
+
}
|
42 |
+
}
|
addons/inc/Dependencies/DI/Definition/InstanceDefinition.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Scope;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Defines injections on an existing class instance.
|
16 |
+
*
|
17 |
+
* @since 5.0
|
18 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
19 |
+
*/
|
20 |
+
class InstanceDefinition implements Definition
|
21 |
+
{
|
22 |
+
/**
|
23 |
+
* Instance on which to inject dependencies.
|
24 |
+
*
|
25 |
+
* @var object
|
26 |
+
*/
|
27 |
+
private $instance;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @var ObjectDefinition
|
31 |
+
*/
|
32 |
+
private $objectDefinition;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @param object $instance
|
36 |
+
* @param ObjectDefinition $objectDefinition
|
37 |
+
*/
|
38 |
+
public function __construct($instance, ObjectDefinition $objectDefinition)
|
39 |
+
{
|
40 |
+
$this->instance = $instance;
|
41 |
+
$this->objectDefinition = $objectDefinition;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* {@inheritdoc}
|
46 |
+
*/
|
47 |
+
public function getName()
|
48 |
+
{
|
49 |
+
// Name are superfluous for instance definitions
|
50 |
+
return '';
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* {@inheritdoc}
|
55 |
+
*/
|
56 |
+
public function getScope()
|
57 |
+
{
|
58 |
+
return Scope::PROTOTYPE;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @return object
|
63 |
+
*/
|
64 |
+
public function getInstance()
|
65 |
+
{
|
66 |
+
return $this->instance;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @return ObjectDefinition
|
71 |
+
*/
|
72 |
+
public function getObjectDefinition()
|
73 |
+
{
|
74 |
+
return $this->objectDefinition;
|
75 |
+
}
|
76 |
+
}
|
addons/inc/Dependencies/DI/Definition/ObjectDefinition.php
ADDED
@@ -0,0 +1,294 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\ObjectDefinition\MethodInjection;
|
13 |
+
use Cybot\Dependencies\DI\Definition\ObjectDefinition\PropertyInjection;
|
14 |
+
use Cybot\Dependencies\DI\Definition\Exception\DefinitionException;
|
15 |
+
use Cybot\Dependencies\DI\Scope;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Defines how an object can be instantiated.
|
19 |
+
*
|
20 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
21 |
+
*/
|
22 |
+
class ObjectDefinition implements Definition, CacheableDefinition, HasSubDefinition
|
23 |
+
{
|
24 |
+
/**
|
25 |
+
* Entry name (most of the time, same as $classname)
|
26 |
+
* @var string
|
27 |
+
*/
|
28 |
+
private $name;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Class name (if null, then the class name is $name)
|
32 |
+
* @var string|null
|
33 |
+
*/
|
34 |
+
private $className;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Constructor parameter injection
|
38 |
+
* @var MethodInjection|null
|
39 |
+
*/
|
40 |
+
private $constructorInjection;
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Property injections
|
44 |
+
* @var PropertyInjection[]
|
45 |
+
*/
|
46 |
+
private $propertyInjections = [];
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Method calls
|
50 |
+
* @var MethodInjection[][]
|
51 |
+
*/
|
52 |
+
private $methodInjections = [];
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @var string|null
|
56 |
+
*/
|
57 |
+
private $scope;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @var boolean|null
|
61 |
+
*/
|
62 |
+
private $lazy;
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @param string $name Class name
|
66 |
+
* @param string $className
|
67 |
+
*/
|
68 |
+
public function __construct($name, $className = null)
|
69 |
+
{
|
70 |
+
$this->name = (string) $name;
|
71 |
+
$this->className = $className;
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @return string Entry name
|
76 |
+
*/
|
77 |
+
public function getName()
|
78 |
+
{
|
79 |
+
return $this->name;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @param string $className
|
84 |
+
*/
|
85 |
+
public function setClassName($className)
|
86 |
+
{
|
87 |
+
$this->className = $className;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* @return string Class name
|
92 |
+
*/
|
93 |
+
public function getClassName()
|
94 |
+
{
|
95 |
+
if ($this->className !== null) {
|
96 |
+
return $this->className;
|
97 |
+
}
|
98 |
+
return $this->name;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* @return MethodInjection|null
|
103 |
+
*/
|
104 |
+
public function getConstructorInjection()
|
105 |
+
{
|
106 |
+
return $this->constructorInjection;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* @param MethodInjection $constructorInjection
|
111 |
+
*/
|
112 |
+
public function setConstructorInjection(MethodInjection $constructorInjection)
|
113 |
+
{
|
114 |
+
$this->constructorInjection = $constructorInjection;
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* @return PropertyInjection[] Property injections
|
119 |
+
*/
|
120 |
+
public function getPropertyInjections()
|
121 |
+
{
|
122 |
+
return $this->propertyInjections;
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* @param string $propertyName
|
127 |
+
* @return PropertyInjection
|
128 |
+
*/
|
129 |
+
public function getPropertyInjection($propertyName)
|
130 |
+
{
|
131 |
+
return isset($this->propertyInjections[$propertyName]) ? $this->propertyInjections[$propertyName] : null;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* @param PropertyInjection $propertyInjection
|
136 |
+
*/
|
137 |
+
public function addPropertyInjection(PropertyInjection $propertyInjection)
|
138 |
+
{
|
139 |
+
$this->propertyInjections[$propertyInjection->getPropertyName()] = $propertyInjection;
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* @return MethodInjection[] Method injections
|
144 |
+
*/
|
145 |
+
public function getMethodInjections()
|
146 |
+
{
|
147 |
+
// Return array leafs
|
148 |
+
$injections = [];
|
149 |
+
array_walk_recursive($this->methodInjections, function ($injection) use (&$injections) {
|
150 |
+
$injections[] = $injection;
|
151 |
+
});;
|
152 |
+
return $injections;
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* @param MethodInjection $methodInjection
|
157 |
+
*/
|
158 |
+
public function addMethodInjection(MethodInjection $methodInjection)
|
159 |
+
{
|
160 |
+
$method = $methodInjection->getMethodName();
|
161 |
+
if (! isset($this->methodInjections[$method])) {
|
162 |
+
$this->methodInjections[$method] = [];
|
163 |
+
}
|
164 |
+
$this->methodInjections[$method][] = $methodInjection;
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* @param string $scope
|
169 |
+
*/
|
170 |
+
public function setScope($scope)
|
171 |
+
{
|
172 |
+
$this->scope = $scope;
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* {@inheritdoc}
|
177 |
+
*/
|
178 |
+
public function getScope()
|
179 |
+
{
|
180 |
+
return $this->scope ?: Scope::SINGLETON;
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* @param boolean|null $lazy
|
185 |
+
*/
|
186 |
+
public function setLazy($lazy)
|
187 |
+
{
|
188 |
+
$this->lazy = $lazy;
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* @return bool
|
193 |
+
*/
|
194 |
+
public function isLazy()
|
195 |
+
{
|
196 |
+
if ($this->lazy !== null) {
|
197 |
+
return $this->lazy;
|
198 |
+
} else {
|
199 |
+
// Default value
|
200 |
+
return false;
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* {@inheritdoc}
|
206 |
+
*/
|
207 |
+
public function getSubDefinitionName()
|
208 |
+
{
|
209 |
+
return $this->getClassName();
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* {@inheritdoc}
|
214 |
+
*/
|
215 |
+
public function setSubDefinition(Definition $definition)
|
216 |
+
{
|
217 |
+
if (! $definition instanceof ObjectDefinition) {
|
218 |
+
throw new DefinitionException(sprintf(
|
219 |
+
"Container entry '%s' extends entry '%s' which is not an object",
|
220 |
+
$this->getName(),
|
221 |
+
$definition->getName()
|
222 |
+
));
|
223 |
+
}
|
224 |
+
|
225 |
+
// The current prevails
|
226 |
+
if ($this->className === null) {
|
227 |
+
$this->className = $definition->className;
|
228 |
+
}
|
229 |
+
if ($this->scope === null) {
|
230 |
+
$this->scope = $definition->scope;
|
231 |
+
}
|
232 |
+
if ($this->lazy === null) {
|
233 |
+
$this->lazy = $definition->lazy;
|
234 |
+
}
|
235 |
+
|
236 |
+
// Merge constructor injection
|
237 |
+
$this->mergeConstructorInjection($definition);
|
238 |
+
|
239 |
+
// Merge property injections
|
240 |
+
$this->mergePropertyInjections($definition);
|
241 |
+
|
242 |
+
// Merge method injections
|
243 |
+
$this->mergeMethodInjections($definition);
|
244 |
+
}
|
245 |
+
|
246 |
+
private function mergeConstructorInjection(ObjectDefinition $definition)
|
247 |
+
{
|
248 |
+
if ($definition->getConstructorInjection() !== null) {
|
249 |
+
if ($this->constructorInjection !== null) {
|
250 |
+
// Merge
|
251 |
+
$this->constructorInjection->merge($definition->getConstructorInjection());
|
252 |
+
} else {
|
253 |
+
// Set
|
254 |
+
$this->constructorInjection = $definition->getConstructorInjection();
|
255 |
+
}
|
256 |
+
}
|
257 |
+
}
|
258 |
+
|
259 |
+
private function mergePropertyInjections(ObjectDefinition $definition)
|
260 |
+
{
|
261 |
+
foreach ($definition->getPropertyInjections() as $propertyName => $propertyInjection) {
|
262 |
+
if (! array_key_exists($propertyName, $this->propertyInjections)) {
|
263 |
+
// Add
|
264 |
+
$this->propertyInjections[$propertyName] = $propertyInjection;
|
265 |
+
}
|
266 |
+
}
|
267 |
+
}
|
268 |
+
|
269 |
+
private function mergeMethodInjections(ObjectDefinition $definition)
|
270 |
+
{
|
271 |
+
foreach ($definition->methodInjections as $methodName => $calls) {
|
272 |
+
if (array_key_exists($methodName, $this->methodInjections)) {
|
273 |
+
$this->mergeMethodCalls($calls, $methodName);
|
274 |
+
} else {
|
275 |
+
// Add
|
276 |
+
$this->methodInjections[$methodName] = $calls;
|
277 |
+
}
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
private function mergeMethodCalls(array $calls, $methodName)
|
282 |
+
{
|
283 |
+
foreach ($calls as $index => $methodInjection) {
|
284 |
+
// Merge
|
285 |
+
if (array_key_exists($index, $this->methodInjections[$methodName])) {
|
286 |
+
// Merge
|
287 |
+
$this->methodInjections[$methodName][$index]->merge($methodInjection);
|
288 |
+
} else {
|
289 |
+
// Add
|
290 |
+
$this->methodInjections[$methodName][$index] = $methodInjection;
|
291 |
+
}
|
292 |
+
}
|
293 |
+
}
|
294 |
+
}
|
addons/inc/Dependencies/DI/Definition/ObjectDefinition/MethodInjection.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\ObjectDefinition;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\AbstractFunctionCallDefinition;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Describe an injection in an object method.
|
16 |
+
*
|
17 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
18 |
+
*/
|
19 |
+
class MethodInjection extends AbstractFunctionCallDefinition
|
20 |
+
{
|
21 |
+
/**
|
22 |
+
* @var string
|
23 |
+
*/
|
24 |
+
private $methodName;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @param string $methodName
|
28 |
+
* @param array $parameters
|
29 |
+
*/
|
30 |
+
public function __construct($methodName, array $parameters = [])
|
31 |
+
{
|
32 |
+
$this->methodName = (string) $methodName;
|
33 |
+
$this->parameters = $parameters;
|
34 |
+
}
|
35 |
+
|
36 |
+
public static function constructor(array $parameters = [])
|
37 |
+
{
|
38 |
+
return new self('__construct', $parameters);
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @return string Method name
|
43 |
+
*/
|
44 |
+
public function getMethodName()
|
45 |
+
{
|
46 |
+
return $this->methodName;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function merge(MethodInjection $definition)
|
50 |
+
{
|
51 |
+
// In case of conflicts, the current definition prevails.
|
52 |
+
$this->parameters = $this->parameters + $definition->parameters;
|
53 |
+
}
|
54 |
+
}
|
addons/inc/Dependencies/DI/Definition/ObjectDefinition/PropertyInjection.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://php-di.org/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\ObjectDefinition;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Describe an injection in a class property.
|
14 |
+
*
|
15 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
16 |
+
*/
|
17 |
+
class PropertyInjection
|
18 |
+
{
|
19 |
+
/**
|
20 |
+
* Property name
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
+
private $propertyName;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Value that should be injected in the property
|
27 |
+
* @var mixed
|
28 |
+
*/
|
29 |
+
private $value;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @param string $propertyName Property name
|
33 |
+
* @param mixed $value Value that should be injected in the property
|
34 |
+
*/
|
35 |
+
public function __construct($propertyName, $value)
|
36 |
+
{
|
37 |
+
$this->propertyName = (string) $propertyName;
|
38 |
+
$this->value = $value;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @return string Property name
|
43 |
+
*/
|
44 |
+
public function getPropertyName()
|
45 |
+
{
|
46 |
+
return $this->propertyName;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* @return string Value that should be injected in the property
|
51 |
+
*/
|
52 |
+
public function getValue()
|
53 |
+
{
|
54 |
+
return $this->value;
|
55 |
+
}
|
56 |
+
}
|
addons/inc/Dependencies/DI/Definition/Resolver/AliasResolver.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://mnapoli.github.com/PHP-DI/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Resolver;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\AliasDefinition;
|
13 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
14 |
+
use Cybot\Dependencies\Interop\Container\ContainerInterface;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Resolves an alias definition to a value.
|
18 |
+
*
|
19 |
+
* @since 4.0
|
20 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
21 |
+
*/
|
22 |
+
class AliasResolver implements DefinitionResolver
|
23 |
+
{
|
24 |
+
/**
|
25 |
+
* @var ContainerInterface
|
26 |
+
*/
|
27 |
+
private $container;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* The resolver needs a container.
|
31 |
+
* This container will be used to get the entry to which the alias points to.
|
32 |
+
*
|
33 |
+
* @param ContainerInterface $container
|
34 |
+
*/
|
35 |
+
public function __construct(ContainerInterface $container)
|
36 |
+
{
|
37 |
+
$this->container = $container;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Resolve an alias definition to a value.
|
42 |
+
*
|
43 |
+
* This will return the entry the alias points to.
|
44 |
+
*
|
45 |
+
* @param AliasDefinition $definition
|
46 |
+
*
|
47 |
+
* {@inheritdoc}
|
48 |
+
*/
|
49 |
+
public function resolve(Definition $definition, array $parameters = [])
|
50 |
+
{
|
51 |
+
$this->assertIsAliasDefinition($definition);
|
52 |
+
|
53 |
+
return $this->container->get($definition->getTargetEntryName());
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* @param AliasDefinition $definition
|
58 |
+
*
|
59 |
+
* {@inheritdoc}
|
60 |
+
*/
|
61 |
+
public function isResolvable(Definition $definition, array $parameters = [])
|
62 |
+
{
|
63 |
+
$this->assertIsAliasDefinition($definition);
|
64 |
+
|
65 |
+
return $this->container->has($definition->getTargetEntryName());
|
66 |
+
}
|
67 |
+
|
68 |
+
private function assertIsAliasDefinition(Definition $definition)
|
69 |
+
{
|
70 |
+
if (!$definition instanceof AliasDefinition) {
|
71 |
+
throw new \InvalidArgumentException(sprintf(
|
72 |
+
'This definition resolver is only compatible with AliasDefinition objects, %s given',
|
73 |
+
get_class($definition)
|
74 |
+
));
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
addons/inc/Dependencies/DI/Definition/Resolver/ArrayResolver.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://mnapoli.github.com/PHP-DI/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Resolver;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\ArrayDefinition;
|
13 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
14 |
+
use Cybot\Dependencies\DI\Definition\Helper\DefinitionHelper;
|
15 |
+
use Cybot\Dependencies\DI\DependencyException;
|
16 |
+
use Exception;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Resolves an array definition to a value.
|
20 |
+
*
|
21 |
+
* @since 5.0
|
22 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
23 |
+
*/
|
24 |
+
class ArrayResolver implements DefinitionResolver
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* @var DefinitionResolver
|
28 |
+
*/
|
29 |
+
private $definitionResolver;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @param DefinitionResolver $definitionResolver Used to resolve nested definitions.
|
33 |
+
*/
|
34 |
+
public function __construct(DefinitionResolver $definitionResolver)
|
35 |
+
{
|
36 |
+
$this->definitionResolver = $definitionResolver;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Resolve an array definition to a value.
|
41 |
+
*
|
42 |
+
* An array definition can contain simple values or references to other entries.
|
43 |
+
*
|
44 |
+
* @param ArrayDefinition $definition
|
45 |
+
*
|
46 |
+
* {@inheritdoc}
|
47 |
+
*/
|
48 |
+
public function resolve(Definition $definition, array $parameters = [])
|
49 |
+
{
|
50 |
+
$this->assertIsArrayDefinition($definition);
|
51 |
+
|
52 |
+
$values = $definition->getValues();
|
53 |
+
|
54 |
+
$values = $this->resolveNestedDefinitions($definition, $values);
|
55 |
+
|
56 |
+
return $values;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* {@inheritdoc}
|
61 |
+
*/
|
62 |
+
public function isResolvable(Definition $definition, array $parameters = [])
|
63 |
+
{
|
64 |
+
$this->assertIsArrayDefinition($definition);
|
65 |
+
|
66 |
+
return true;
|
67 |
+
}
|
68 |
+
|
69 |
+
private function assertIsArrayDefinition(Definition $definition)
|
70 |
+
{
|
71 |
+
if (!$definition instanceof ArrayDefinition) {
|
72 |
+
throw new \InvalidArgumentException(sprintf(
|
73 |
+
'This definition resolver is only compatible with ArrayDefinition objects, %s given',
|
74 |
+
get_class($definition)
|
75 |
+
));
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
private function resolveNestedDefinitions(ArrayDefinition $definition, array $values)
|
80 |
+
{
|
81 |
+
foreach ($values as $key => $value) {
|
82 |
+
if ($value instanceof DefinitionHelper) {
|
83 |
+
$values[$key] = $this->resolveDefinition($value, $definition, $key);
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
return $values;
|
88 |
+
}
|
89 |
+
|
90 |
+
private function resolveDefinition(DefinitionHelper $value, ArrayDefinition $definition, $key)
|
91 |
+
{
|
92 |
+
try {
|
93 |
+
return $this->definitionResolver->resolve($value->getDefinition(''));
|
94 |
+
} catch (DependencyException $e) {
|
95 |
+
throw $e;
|
96 |
+
} catch (Exception $e) {
|
97 |
+
throw new DependencyException(sprintf(
|
98 |
+
"Error while resolving %s[%s]. %s",
|
99 |
+
$definition->getName(),
|
100 |
+
$key,
|
101 |
+
$e->getMessage()
|
102 |
+
), 0, $e);
|
103 |
+
}
|
104 |
+
}
|
105 |
+
}
|
addons/inc/Dependencies/DI/Definition/Resolver/DecoratorResolver.php
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://mnapoli.github.com/PHP-DI/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Resolver;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\DecoratorDefinition;
|
13 |
+
use Cybot\Dependencies\DI\Definition\Exception\DefinitionException;
|
14 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
15 |
+
use Cybot\Dependencies\Interop\Container\ContainerInterface;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Resolves a decorator definition to a value.
|
19 |
+
*
|
20 |
+
* @since 5.0
|
21 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
22 |
+
*/
|
23 |
+
class DecoratorResolver implements DefinitionResolver
|
24 |
+
{
|
25 |
+
/**
|
26 |
+
* @var ContainerInterface
|
27 |
+
*/
|
28 |
+
private $container;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @var DefinitionResolver
|
32 |
+
*/
|
33 |
+
private $definitionResolver;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* The resolver needs a container. This container will be passed to the factory as a parameter
|
37 |
+
* so that the factory can access other entries of the container.
|
38 |
+
*
|
39 |
+
* @param ContainerInterface $container
|
40 |
+
* @param DefinitionResolver $definitionResolver Used to resolve nested definitions.
|
41 |
+
*/
|
42 |
+
public function __construct(ContainerInterface $container, DefinitionResolver $definitionResolver)
|
43 |
+
{
|
44 |
+
$this->container = $container;
|
45 |
+
$this->definitionResolver = $definitionResolver;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Resolve a decorator definition to a value.
|
50 |
+
*
|
51 |
+
* This will call the callable of the definition and pass it the decorated entry.
|
52 |
+
*
|
53 |
+
* @param DecoratorDefinition $definition
|
54 |
+
*
|
55 |
+
* {@inheritdoc}
|
56 |
+
*/
|
57 |
+
public function resolve(Definition $definition, array $parameters = [])
|
58 |
+
{
|
59 |
+
$this->assertIsDecoratorDefinition($definition);
|
60 |
+
|
61 |
+
$callable = $definition->getCallable();
|
62 |
+
|
63 |
+
if (! is_callable($callable)) {
|
64 |
+
throw new DefinitionException(sprintf(
|
65 |
+
'The decorator "%s" is not callable',
|
66 |
+
$definition->getName()
|
67 |
+
));
|
68 |
+
}
|
69 |
+
|
70 |
+
$decoratedDefinition = $definition->getDecoratedDefinition();
|
71 |
+
|
72 |
+
if (! $decoratedDefinition instanceof Definition) {
|
73 |
+
if (! $definition->getSubDefinitionName()) {
|
74 |
+
throw new DefinitionException('Decorators cannot be nested in another definition');
|
75 |
+
}
|
76 |
+
|
77 |
+
throw new DefinitionException(sprintf(
|
78 |
+
'Entry "%s" decorates nothing: no previous definition with the same name was found',
|
79 |
+
$definition->getName()
|
80 |
+
));
|
81 |
+
}
|
82 |
+
|
83 |
+
$decorated = $this->definitionResolver->resolve($decoratedDefinition);
|
84 |
+
|
85 |
+
return call_user_func($callable, $decorated, $this->container);
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* {@inheritdoc}
|
90 |
+
*/
|
91 |
+
public function isResolvable(Definition $definition, array $parameters = [])
|
92 |
+
{
|
93 |
+
$this->assertIsDecoratorDefinition($definition);
|
94 |
+
|
95 |
+
return true;
|
96 |
+
}
|
97 |
+
|
98 |
+
private function assertIsDecoratorDefinition(Definition $definition)
|
99 |
+
{
|
100 |
+
if (!$definition instanceof DecoratorDefinition) {
|
101 |
+
throw new \InvalidArgumentException(sprintf(
|
102 |
+
'This definition resolver is only compatible with DecoratorDefinition objects, %s given',
|
103 |
+
get_class($definition)
|
104 |
+
));
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
addons/inc/Dependencies/DI/Definition/Resolver/DefinitionResolver.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://mnapoli.github.com/PHP-DI/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Resolver;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
13 |
+
use Cybot\Dependencies\DI\Definition\Exception\DefinitionException;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Resolves a definition to a value.
|
17 |
+
*
|
18 |
+
* @since 4.0
|
19 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
20 |
+
*/
|
21 |
+
interface DefinitionResolver
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* Resolve a definition to a value.
|
25 |
+
*
|
26 |
+
* @param Definition $definition Object that defines how the value should be obtained.
|
27 |
+
* @param array $parameters Optional parameters to use to build the entry.
|
28 |
+
*
|
29 |
+
* @throws DefinitionException If the definition cannot be resolved.
|
30 |
+
*
|
31 |
+
* @return mixed Value obtained from the definition.
|
32 |
+
*/
|
33 |
+
public function resolve(Definition $definition, array $parameters = []);
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Check if a definition can be resolved.
|
37 |
+
*
|
38 |
+
* @param Definition $definition Object that defines how the value should be obtained.
|
39 |
+
* @param array $parameters Optional parameters to use to build the entry.
|
40 |
+
*
|
41 |
+
* @return bool
|
42 |
+
*/
|
43 |
+
public function isResolvable(Definition $definition, array $parameters = []);
|
44 |
+
}
|
addons/inc/Dependencies/DI/Definition/Resolver/EnvironmentVariableResolver.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://mnapoli.github.com/PHP-DI/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Resolver;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
13 |
+
use Cybot\Dependencies\DI\Definition\EnvironmentVariableDefinition;
|
14 |
+
use Cybot\Dependencies\DI\Definition\Exception\DefinitionException;
|
15 |
+
use Cybot\Dependencies\DI\Definition\Helper\DefinitionHelper;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Resolves a environment variable definition to a value.
|
19 |
+
*
|
20 |
+
* @author James Harris <james.harris@icecave.com.au>
|
21 |
+
*/
|
22 |
+
class EnvironmentVariableResolver implements DefinitionResolver
|
23 |
+
{
|
24 |
+
/**
|
25 |
+
* @var DefinitionResolver
|
26 |
+
*/
|
27 |
+
private $definitionResolver;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @var callable
|
31 |
+
*/
|
32 |
+
private $variableReader;
|
33 |
+
|
34 |
+
public function __construct(DefinitionResolver $definitionResolver, $variableReader = 'getenv')
|
35 |
+
{
|
36 |
+
$this->definitionResolver = $definitionResolver;
|
37 |
+
$this->variableReader = $variableReader;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Resolve an environment variable definition to a value.
|
42 |
+
*
|
43 |
+
* @param EnvironmentVariableDefinition $definition
|
44 |
+
*
|
45 |
+
* {@inheritdoc}
|
46 |
+
*/
|
47 |
+
public function resolve(Definition $definition, array $parameters = [])
|
48 |
+
{
|
49 |
+
$this->assertIsEnvironmentVariableDefinition($definition);
|
50 |
+
|
51 |
+
$value = call_user_func($this->variableReader, $definition->getVariableName());
|
52 |
+
|
53 |
+
if (false !== $value) {
|
54 |
+
return $value;
|
55 |
+
} elseif (!$definition->isOptional()) {
|
56 |
+
throw new DefinitionException(sprintf(
|
57 |
+
"The environment variable '%s' has not been defined",
|
58 |
+
$definition->getVariableName()
|
59 |
+
));
|
60 |
+
}
|
61 |
+
|
62 |
+
$value = $definition->getDefaultValue();
|
63 |
+
|
64 |
+
// Nested definition
|
65 |
+
if ($value instanceof DefinitionHelper) {
|
66 |
+
return $this->definitionResolver->resolve($value->getDefinition(''));
|
67 |
+
}
|
68 |
+
|
69 |
+
return $value;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @param EnvironmentVariableDefinition $definition
|
74 |
+
*
|
75 |
+
* {@inheritdoc}
|
76 |
+
*/
|
77 |
+
public function isResolvable(Definition $definition, array $parameters = [])
|
78 |
+
{
|
79 |
+
$this->assertIsEnvironmentVariableDefinition($definition);
|
80 |
+
|
81 |
+
return $definition->isOptional()
|
82 |
+
|| false !== call_user_func($this->variableReader, $definition->getVariableName());
|
83 |
+
}
|
84 |
+
|
85 |
+
private function assertIsEnvironmentVariableDefinition(Definition $definition)
|
86 |
+
{
|
87 |
+
if (!$definition instanceof EnvironmentVariableDefinition) {
|
88 |
+
throw new \InvalidArgumentException(sprintf(
|
89 |
+
'This definition resolver is only compatible with EnvironmentVariableDefinition objects, %s given',
|
90 |
+
get_class($definition)
|
91 |
+
));
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
addons/inc/Dependencies/DI/Definition/Resolver/FactoryResolver.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://mnapoli.github.com/PHP-DI/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Resolver;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\Exception\DefinitionException;
|
13 |
+
use Cybot\Dependencies\DI\Definition\FactoryDefinition;
|
14 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
15 |
+
use Cybot\Dependencies\Interop\Container\ContainerInterface;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Resolves a factory definition to a value.
|
19 |
+
*
|
20 |
+
* @since 4.0
|
21 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
22 |
+
*/
|
23 |
+
class FactoryResolver implements DefinitionResolver
|
24 |
+
{
|
25 |
+
/**
|
26 |
+
* @var ContainerInterface
|
27 |
+
*/
|
28 |
+
private $container;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* The resolver needs a container. This container will be passed to the factory as a parameter
|
32 |
+
* so that the factory can access other entries of the container.
|
33 |
+
*
|
34 |
+
* @param ContainerInterface $container
|
35 |
+
*/
|
36 |
+
public function __construct(ContainerInterface $container)
|
37 |
+
{
|
38 |
+
$this->container = $container;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Resolve a factory definition to a value.
|
43 |
+
*
|
44 |
+
* This will call the callable of the definition.
|
45 |
+
*
|
46 |
+
* @param FactoryDefinition $definition
|
47 |
+
*
|
48 |
+
* {@inheritdoc}
|
49 |
+
*/
|
50 |
+
public function resolve(Definition $definition, array $parameters = [])
|
51 |
+
{
|
52 |
+
$this->assertIsFactoryDefinition($definition);
|
53 |
+
|
54 |
+
$callable = $definition->getCallable();
|
55 |
+
|
56 |
+
if (! is_callable($callable)) {
|
57 |
+
throw new DefinitionException(sprintf(
|
58 |
+
'The factory definition "%s" is not callable',
|
59 |
+
$definition->getName()
|
60 |
+
));
|
61 |
+
}
|
62 |
+
|
63 |
+
return call_user_func($callable, $this->container);
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* {@inheritdoc}
|
68 |
+
*/
|
69 |
+
public function isResolvable(Definition $definition, array $parameters = [])
|
70 |
+
{
|
71 |
+
$this->assertIsFactoryDefinition($definition);
|
72 |
+
|
73 |
+
return true;
|
74 |
+
}
|
75 |
+
|
76 |
+
private function assertIsFactoryDefinition(Definition $definition)
|
77 |
+
{
|
78 |
+
if (!$definition instanceof FactoryDefinition) {
|
79 |
+
throw new \InvalidArgumentException(sprintf(
|
80 |
+
'This definition resolver is only compatible with FactoryDefinition objects, %s given',
|
81 |
+
get_class($definition)
|
82 |
+
));
|
83 |
+
}
|
84 |
+
}
|
85 |
+
}
|
addons/inc/Dependencies/DI/Definition/Resolver/InstanceInjector.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://mnapoli.github.com/PHP-DI/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Resolver;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
13 |
+
use Cybot\Dependencies\DI\Definition\InstanceDefinition;
|
14 |
+
use Cybot\Dependencies\DI\DependencyException;
|
15 |
+
use Cybot\Dependencies\Interop\Container\Exception\NotFoundException;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Injects dependencies on an existing instance.
|
19 |
+
*
|
20 |
+
* @since 5.0
|
21 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
22 |
+
*/
|
23 |
+
class InstanceInjector extends ObjectCreator
|
24 |
+
{
|
25 |
+
/**
|
26 |
+
* Injects dependencies on an existing instance.
|
27 |
+
*
|
28 |
+
* @param InstanceDefinition $definition
|
29 |
+
*
|
30 |
+
* {@inheritdoc}
|
31 |
+
*/
|
32 |
+
public function resolve(Definition $definition, array $parameters = [])
|
33 |
+
{
|
34 |
+
$this->assertIsInstanceDefinition($definition);
|
35 |
+
|
36 |
+
try {
|
37 |
+
$this->injectMethodsAndProperties($definition->getInstance(), $definition->getObjectDefinition());
|
38 |
+
} catch (NotFoundException $e) {
|
39 |
+
$message = sprintf(
|
40 |
+
"Error while injecting dependencies into %s: %s",
|
41 |
+
get_class($definition->getInstance()),
|
42 |
+
$e->getMessage()
|
43 |
+
);
|
44 |
+
throw new DependencyException($message, 0, $e);
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* {@inheritdoc}
|
50 |
+
*/
|
51 |
+
public function isResolvable(Definition $definition, array $parameters = [])
|
52 |
+
{
|
53 |
+
$this->assertIsInstanceDefinition($definition);
|
54 |
+
|
55 |
+
return true;
|
56 |
+
}
|
57 |
+
|
58 |
+
private function assertIsInstanceDefinition(Definition $definition)
|
59 |
+
{
|
60 |
+
if (!$definition instanceof InstanceDefinition) {
|
61 |
+
throw new \InvalidArgumentException(sprintf(
|
62 |
+
'This definition resolver is only compatible with InstanceDefinition objects, %s given',
|
63 |
+
get_class($definition)
|
64 |
+
));
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
addons/inc/Dependencies/DI/Definition/Resolver/ObjectCreator.php
ADDED
@@ -0,0 +1,266 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://mnapoli.github.com/PHP-DI/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Resolver;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\ObjectDefinition;
|
13 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
14 |
+
use Cybot\Dependencies\DI\Definition\Exception\DefinitionException;
|
15 |
+
use Cybot\Dependencies\DI\Definition\ObjectDefinition\PropertyInjection;
|
16 |
+
use Cybot\Dependencies\DI\Definition\Helper\DefinitionHelper;
|
17 |
+
use Cybot\Dependencies\DI\DependencyException;
|
18 |
+
use Cybot\Dependencies\DI\Proxy\ProxyFactory;
|
19 |
+
use Exception;
|
20 |
+
use Cybot\Dependencies\Interop\Container\Exception\NotFoundException;
|
21 |
+
use ProxyManager\Proxy\LazyLoadingInterface;
|
22 |
+
use ReflectionClass;
|
23 |
+
use ReflectionProperty;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Create objects based on an object definition.
|
27 |
+
*
|
28 |
+
* @since 4.0
|
29 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
30 |
+
*/
|
31 |
+
class ObjectCreator implements DefinitionResolver
|
32 |
+
{
|
33 |
+
/**
|
34 |
+
* @var ProxyFactory
|
35 |
+
*/
|
36 |
+
private $proxyFactory;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @var ParameterResolver
|
40 |
+
*/
|
41 |
+
private $parameterResolver;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @var DefinitionResolver
|
45 |
+
*/
|
46 |
+
private $definitionResolver;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @param DefinitionResolver $definitionResolver Used to resolve nested definitions.
|
50 |
+
* @param ProxyFactory $proxyFactory Used to create proxies for lazy injections.
|
51 |
+
*/
|
52 |
+
public function __construct(
|
53 |
+
DefinitionResolver $definitionResolver,
|
54 |
+
ProxyFactory $proxyFactory
|
55 |
+
) {
|
56 |
+
$this->definitionResolver = $definitionResolver;
|
57 |
+
$this->proxyFactory = $proxyFactory;
|
58 |
+
$this->parameterResolver = new ParameterResolver($definitionResolver);
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Resolve a class definition to a value.
|
63 |
+
*
|
64 |
+
* This will create a new instance of the class using the injections points defined.
|
65 |
+
*
|
66 |
+
* @param ObjectDefinition $definition
|
67 |
+
*
|
68 |
+
* {@inheritdoc}
|
69 |
+
*/
|
70 |
+
public function resolve(Definition $definition, array $parameters = [])
|
71 |
+
{
|
72 |
+
$this->assertIsObjectDefinition($definition);
|
73 |
+
|
74 |
+
// Lazy?
|
75 |
+
if ($definition->isLazy()) {
|
76 |
+
return $this->createProxy($definition, $parameters);
|
77 |
+
}
|
78 |
+
|
79 |
+
return $this->createInstance($definition, $parameters);
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* The definition is not resolvable if the class is not instantiable (interface or abstract)
|
84 |
+
* or if the class doesn't exist.
|
85 |
+
*
|
86 |
+
* @param ObjectDefinition $definition
|
87 |
+
*
|
88 |
+
* {@inheritdoc}
|
89 |
+
*/
|
90 |
+
public function isResolvable(Definition $definition, array $parameters = [])
|
91 |
+
{
|
92 |
+
$this->assertIsObjectDefinition($definition);
|
93 |
+
|
94 |
+
if (! class_exists($definition->getClassName())) {
|
95 |
+
return false;
|
96 |
+
}
|
97 |
+
|
98 |
+
$classReflection = new ReflectionClass($definition->getClassName());
|
99 |
+
|
100 |
+
return $classReflection->isInstantiable();
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Returns a proxy instance
|
105 |
+
*
|
106 |
+
* @param ObjectDefinition $definition
|
107 |
+
* @param array $parameters
|
108 |
+
*
|
109 |
+
* @return LazyLoadingInterface Proxy instance
|
110 |
+
*/
|
111 |
+
private function createProxy(ObjectDefinition $definition, array $parameters)
|
112 |
+
{
|
113 |
+
/** @noinspection PhpUnusedParameterInspection */
|
114 |
+
$proxy = $this->proxyFactory->createProxy(
|
115 |
+
$definition->getClassName(),
|
116 |
+
function (& $wrappedObject, $proxy, $method, $params, & $initializer) use ($definition, $parameters) {
|
117 |
+
$wrappedObject = $this->createInstance($definition, $parameters);
|
118 |
+
$initializer = null; // turning off further lazy initialization
|
119 |
+
return true;
|
120 |
+
}
|
121 |
+
);
|
122 |
+
|
123 |
+
return $proxy;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Creates an instance of the class and injects dependencies..
|
128 |
+
*
|
129 |
+
* @param ObjectDefinition $definition
|
130 |
+
* @param array $parameters Optional parameters to use to create the instance.
|
131 |
+
*
|
132 |
+
* @throws DefinitionException
|
133 |
+
* @throws DependencyException
|
134 |
+
* @return object
|
135 |
+
*/
|
136 |
+
private function createInstance(ObjectDefinition $definition, array $parameters)
|
137 |
+
{
|
138 |
+
$this->assertClassExists($definition);
|
139 |
+
|
140 |
+
$classReflection = new ReflectionClass($definition->getClassName());
|
141 |
+
|
142 |
+
$this->assertClassIsInstantiable($definition, $classReflection);
|
143 |
+
|
144 |
+
$constructorInjection = $definition->getConstructorInjection();
|
145 |
+
|
146 |
+
try {
|
147 |
+
$args = $this->parameterResolver->resolveParameters(
|
148 |
+
$constructorInjection,
|
149 |
+
$classReflection->getConstructor(),
|
150 |
+
$parameters
|
151 |
+
);
|
152 |
+
|
153 |
+
if (count($args) > 0) {
|
154 |
+
$object = $classReflection->newInstanceArgs($args);
|
155 |
+
} else {
|
156 |
+
$object = $classReflection->newInstance();
|
157 |
+
}
|
158 |
+
|
159 |
+
$this->injectMethodsAndProperties($object, $definition);
|
160 |
+
} catch (NotFoundException $e) {
|
161 |
+
throw new DependencyException(sprintf(
|
162 |
+
"Error while injecting dependencies into %s: %s",
|
163 |
+
$classReflection->getName(),
|
164 |
+
$e->getMessage()
|
165 |
+
), 0, $e);
|
166 |
+
} catch (DefinitionException $e) {
|
167 |
+
throw DefinitionException::create($definition, sprintf(
|
168 |
+
"Entry %s cannot be resolved: %s",
|
169 |
+
$definition->getName(),
|
170 |
+
$e->getMessage()
|
171 |
+
));
|
172 |
+
}
|
173 |
+
|
174 |
+
return $object;
|
175 |
+
}
|
176 |
+
|
177 |
+
protected function injectMethodsAndProperties($object, ObjectDefinition $objectDefinition)
|
178 |
+
{
|
179 |
+
// Property injections
|
180 |
+
foreach ($objectDefinition->getPropertyInjections() as $propertyInjection) {
|
181 |
+
$this->injectProperty($object, $propertyInjection);
|
182 |
+
}
|
183 |
+
|
184 |
+
// Method injections
|
185 |
+
foreach ($objectDefinition->getMethodInjections() as $methodInjection) {
|
186 |
+
$methodReflection = new \ReflectionMethod($object, $methodInjection->getMethodName());
|
187 |
+
$args = $this->parameterResolver->resolveParameters($methodInjection, $methodReflection);
|
188 |
+
|
189 |
+
$methodReflection->invokeArgs($object, $args);
|
190 |
+
}
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Inject dependencies into properties.
|
195 |
+
*
|
196 |
+
* @param object $object Object to inject dependencies into
|
197 |
+
* @param PropertyInjection $propertyInjection Property injection definition
|
198 |
+
*
|
199 |
+
* @throws DependencyException
|
200 |
+
* @throws DefinitionException
|
201 |
+
*/
|
202 |
+
private function injectProperty($object, PropertyInjection $propertyInjection)
|
203 |
+
{
|
204 |
+
$propertyName = $propertyInjection->getPropertyName();
|
205 |
+
$property = new ReflectionProperty(get_class($object), $propertyName);
|
206 |
+
|
207 |
+
$value = $propertyInjection->getValue();
|
208 |
+
|
209 |
+
if ($value instanceof DefinitionHelper) {
|
210 |
+
/** @var Definition $nestedDefinition */
|
211 |
+
$nestedDefinition = $value->getDefinition('');
|
212 |
+
|
213 |
+
try {
|
214 |
+
$value = $this->definitionResolver->resolve($nestedDefinition);
|
215 |
+
} catch (DependencyException $e) {
|
216 |
+
throw $e;
|
217 |
+
} catch (Exception $e) {
|
218 |
+
throw new DependencyException(sprintf(
|
219 |
+
"Error while injecting in %s::%s. %s",
|
220 |
+
get_class($object),
|
221 |
+
$propertyName,
|
222 |
+
$e->getMessage()
|
223 |
+
), 0, $e);
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
if (! $property->isPublic()) {
|
228 |
+
$property->setAccessible(true);
|
229 |
+
}
|
230 |
+
$property->setValue($object, $value);
|
231 |
+
}
|
232 |
+
|
233 |
+
private function assertIsObjectDefinition(Definition $definition)
|
234 |
+
{
|
235 |
+
if (!$definition instanceof ObjectDefinition) {
|
236 |
+
throw new \InvalidArgumentException(sprintf(
|
237 |
+
'This definition resolver is only compatible with ObjectDefinition objects, %s given',
|
238 |
+
get_class($definition)
|
239 |
+
));
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
private function assertClassExists(ObjectDefinition $definition)
|
244 |
+
{
|
245 |
+
if (!class_exists($definition->getClassName()) && !interface_exists($definition->getClassName())) {
|
246 |
+
throw DefinitionException::create($definition,
|
247 |
+
sprintf(
|
248 |
+
"Entry %s cannot be resolved: class %s doesn't exist",
|
249 |
+
$definition->getName(),
|
250 |
+
$definition->getClassName()
|
251 |
+
));
|
252 |
+
}
|
253 |
+
}
|
254 |
+
|
255 |
+
private function assertClassIsInstantiable(ObjectDefinition $definition, ReflectionClass $classReflection)
|
256 |
+
{
|
257 |
+
if (!$classReflection->isInstantiable()) {
|
258 |
+
throw DefinitionException::create($definition,
|
259 |
+
sprintf(
|
260 |
+
"Entry %s cannot be resolved: class %s is not instantiable",
|
261 |
+
$definition->getName(),
|
262 |
+
$definition->getClassName()
|
263 |
+
));
|
264 |
+
}
|
265 |
+
}
|
266 |
+
}
|
addons/inc/Dependencies/DI/Definition/Resolver/ParameterResolver.php
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://mnapoli.github.com/PHP-DI/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Resolver;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\AbstractFunctionCallDefinition;
|
13 |
+
use Cybot\Dependencies\DI\Definition\ObjectDefinition;
|
14 |
+
use Cybot\Dependencies\DI\Definition\Exception\DefinitionException;
|
15 |
+
use Cybot\Dependencies\DI\Definition\Helper\DefinitionHelper;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Resolves parameters for a function call.
|
19 |
+
*
|
20 |
+
* @since 4.2
|
21 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
22 |
+
*/
|
23 |
+
class ParameterResolver
|
24 |
+
{
|
25 |
+
/**
|
26 |
+
* @var DefinitionResolver
|
27 |
+
*/
|
28 |
+
private $definitionResolver;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @param DefinitionResolver $definitionResolver Will be used to resolve nested definitions.
|
32 |
+
*/
|
33 |
+
public function __construct(DefinitionResolver $definitionResolver)
|
34 |
+
{
|
35 |
+
$this->definitionResolver = $definitionResolver;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @param AbstractFunctionCallDefinition $definition
|
40 |
+
* @param \ReflectionFunctionAbstract $functionReflection
|
41 |
+
* @param array $parameters
|
42 |
+
*
|
43 |
+
* @throws DefinitionException A parameter has no value defined or guessable.
|
44 |
+
* @return array Parameters to use to call the function.
|
45 |
+
*/
|
46 |
+
public function resolveParameters(
|
47 |
+
AbstractFunctionCallDefinition $definition = null,
|
48 |
+
\ReflectionFunctionAbstract $functionReflection = null,
|
49 |
+
array $parameters = []
|
50 |
+
) {
|
51 |
+
$args = [];
|
52 |
+
|
53 |
+
if (! $functionReflection) {
|
54 |
+
return $args;
|
55 |
+
}
|
56 |
+
|
57 |
+
foreach ($functionReflection->getParameters() as $index => $parameter) {
|
58 |
+
if (array_key_exists($parameter->getName(), $parameters)) {
|
59 |
+
// Look in the $parameters array
|
60 |
+
$value = $parameters[$parameter->getName()];
|
61 |
+
} elseif ($definition && $definition->hasParameter($index)) {
|
62 |
+
// Look in the definition
|
63 |
+
$value = $definition->getParameter($index);
|
64 |
+
} else {
|
65 |
+
// If the parameter is optional and wasn't specified, we take its default value
|
66 |
+
if ($parameter->isOptional()) {
|
67 |
+
$args[] = $this->getParameterDefaultValue($parameter, $functionReflection);
|
68 |
+
continue;
|
69 |
+
}
|
70 |
+
|
71 |
+
throw new DefinitionException(sprintf(
|
72 |
+
"The parameter '%s' of %s has no value defined or guessable",
|
73 |
+
$parameter->getName(),
|
74 |
+
$this->getFunctionName($functionReflection)
|
75 |
+
));
|
76 |
+
}
|
77 |
+
|
78 |
+
if ($value instanceof DefinitionHelper) {
|
79 |
+
$nestedDefinition = $value->getDefinition('');
|
80 |
+
|
81 |
+
// If the container cannot produce the entry, we can use the default parameter value
|
82 |
+
if (!$this->definitionResolver->isResolvable($nestedDefinition) && $parameter->isOptional()) {
|
83 |
+
$value = $this->getParameterDefaultValue($parameter, $functionReflection);
|
84 |
+
} else {
|
85 |
+
$value = $this->definitionResolver->resolve($nestedDefinition);
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
$args[] = $value;
|
90 |
+
}
|
91 |
+
|
92 |
+
return $args;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Returns the default value of a function parameter.
|
97 |
+
*
|
98 |
+
* @param \ReflectionParameter $parameter
|
99 |
+
* @param \ReflectionFunctionAbstract $function
|
100 |
+
*
|
101 |
+
* @throws DefinitionException Can't get default values from PHP internal classes and functions
|
102 |
+
* @return mixed
|
103 |
+
*/
|
104 |
+
private function getParameterDefaultValue(
|
105 |
+
\ReflectionParameter $parameter,
|
106 |
+
\ReflectionFunctionAbstract $function
|
107 |
+
) {
|
108 |
+
try {
|
109 |
+
return $parameter->getDefaultValue();
|
110 |
+
} catch (\ReflectionException $e) {
|
111 |
+
throw new DefinitionException(sprintf(
|
112 |
+
"The parameter '%s' of %s has no type defined or guessable. It has a default value, "
|
113 |
+
. "but the default value can't be read through Reflection because it is a PHP internal class.",
|
114 |
+
$parameter->getName(),
|
115 |
+
$this->getFunctionName($function)
|
116 |
+
));
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
private function getFunctionName(\ReflectionFunctionAbstract $reflectionFunction)
|
121 |
+
{
|
122 |
+
if ($reflectionFunction instanceof \ReflectionMethod) {
|
123 |
+
return sprintf(
|
124 |
+
'%s::%s',
|
125 |
+
$reflectionFunction->getDeclaringClass()->getName(),
|
126 |
+
$reflectionFunction->getName()
|
127 |
+
);
|
128 |
+
} elseif ($reflectionFunction->isClosure()) {
|
129 |
+
return sprintf(
|
130 |
+
'closure defined in %s at line %d',
|
131 |
+
$reflectionFunction->getFileName(),
|
132 |
+
$reflectionFunction->getStartLine()
|
133 |
+
);
|
134 |
+
}
|
135 |
+
|
136 |
+
return $reflectionFunction->getName();
|
137 |
+
}
|
138 |
+
}
|
addons/inc/Dependencies/DI/Definition/Resolver/ResolverDispatcher.php
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Cybot\Dependencies\DI\Definition\Resolver;
|
4 |
+
|
5 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
6 |
+
use Cybot\Dependencies\DI\Definition\Exception\DefinitionException;
|
7 |
+
use Cybot\Dependencies\DI\Proxy\ProxyFactory;
|
8 |
+
use Cybot\Dependencies\Interop\Container\ContainerInterface;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Dispatches to more specific resolvers.
|
12 |
+
*
|
13 |
+
* Dynamic dispatch pattern.
|
14 |
+
*
|
15 |
+
* @since 5.0
|
16 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
17 |
+
*/
|
18 |
+
class ResolverDispatcher implements DefinitionResolver
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* @var ContainerInterface
|
22 |
+
*/
|
23 |
+
private $container;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @var ProxyFactory
|
27 |
+
*/
|
28 |
+
private $proxyFactory;
|
29 |
+
|
30 |
+
private $valueResolver;
|
31 |
+
private $arrayResolver;
|
32 |
+
private $factoryResolver;
|
33 |
+
private $decoratorResolver;
|
34 |
+
private $aliasResolver;
|
35 |
+
private $objectResolver;
|
36 |
+
private $instanceResolver;
|
37 |
+
private $envVariableResolver;
|
38 |
+
private $stringResolver;
|
39 |
+
|
40 |
+
public function __construct(ContainerInterface $container, ProxyFactory $proxyFactory)
|
41 |
+
{
|
42 |
+
$this->container = $container;
|
43 |
+
$this->proxyFactory = $proxyFactory;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Resolve a definition to a value.
|
48 |
+
*
|
49 |
+
* @param Definition $definition Object that defines how the value should be obtained.
|
50 |
+
* @param array $parameters Optional parameters to use to build the entry.
|
51 |
+
*
|
52 |
+
* @throws DefinitionException If the definition cannot be resolved.
|
53 |
+
*
|
54 |
+
* @return mixed Value obtained from the definition.
|
55 |
+
*/
|
56 |
+
public function resolve(Definition $definition, array $parameters = [])
|
57 |
+
{
|
58 |
+
$definitionResolver = $this->getDefinitionResolver($definition);
|
59 |
+
|
60 |
+
return $definitionResolver->resolve($definition, $parameters);
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Check if a definition can be resolved.
|
65 |
+
*
|
66 |
+
* @param Definition $definition Object that defines how the value should be obtained.
|
67 |
+
* @param array $parameters Optional parameters to use to build the entry.
|
68 |
+
*
|
69 |
+
* @return bool
|
70 |
+
*/
|
71 |
+
public function isResolvable(Definition $definition, array $parameters = [])
|
72 |
+
{
|
73 |
+
$definitionResolver = $this->getDefinitionResolver($definition);
|
74 |
+
|
75 |
+
return $definitionResolver->isResolvable($definition, $parameters);
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Returns a resolver capable of handling the given definition.
|
80 |
+
*
|
81 |
+
* @param Definition $definition
|
82 |
+
*
|
83 |
+
* @throws \RuntimeException No definition resolver was found for this type of definition.
|
84 |
+
* @return DefinitionResolver
|
85 |
+
*/
|
86 |
+
private function getDefinitionResolver(Definition $definition)
|
87 |
+
{
|
88 |
+
$definitionType = get_class($definition);
|
89 |
+
|
90 |
+
switch ($definitionType) {
|
91 |
+
case 'Cybot\Dependencies\DI\Definition\ValueDefinition':
|
92 |
+
if (! $this->valueResolver) {
|
93 |
+
$this->valueResolver = new ValueResolver();
|
94 |
+
}
|
95 |
+
return $this->valueResolver;
|
96 |
+
case 'Cybot\Dependencies\DI\Definition\ArrayDefinition':
|
97 |
+
case 'Cybot\Dependencies\DI\Definition\ArrayDefinitionExtension':
|
98 |
+
if (! $this->arrayResolver) {
|
99 |
+
$this->arrayResolver = new ArrayResolver($this);
|
100 |
+
}
|
101 |
+
return $this->arrayResolver;
|
102 |
+
case 'Cybot\Dependencies\DI\Definition\FactoryDefinition':
|
103 |
+
if (! $this->factoryResolver) {
|
104 |
+
$this->factoryResolver = new FactoryResolver($this->container);
|
105 |
+
}
|
106 |
+
return $this->factoryResolver;
|
107 |
+
case 'Cybot\Dependencies\DI\Definition\DecoratorDefinition':
|
108 |
+
if (! $this->decoratorResolver) {
|
109 |
+
$this->decoratorResolver = new DecoratorResolver($this->container, $this);
|
110 |
+
}
|
111 |
+
return $this->decoratorResolver;
|
112 |
+
case 'Cybot\Dependencies\DI\Definition\AliasDefinition':
|
113 |
+
if (! $this->aliasResolver) {
|
114 |
+
$this->aliasResolver = new AliasResolver($this->container);
|
115 |
+
}
|
116 |
+
return $this->aliasResolver;
|
117 |
+
case 'Cybot\Dependencies\DI\Definition\ObjectDefinition':
|
118 |
+
if (! $this->objectResolver) {
|
119 |
+
$this->objectResolver = new ObjectCreator($this, $this->proxyFactory);
|
120 |
+
}
|
121 |
+
return $this->objectResolver;
|
122 |
+
case 'Cybot\Dependencies\DI\Definition\InstanceDefinition':
|
123 |
+
if (! $this->instanceResolver) {
|
124 |
+
$this->instanceResolver = new InstanceInjector($this, $this->proxyFactory);
|
125 |
+
}
|
126 |
+
return $this->instanceResolver;
|
127 |
+
case 'Cybot\Dependencies\DI\Definition\EnvironmentVariableDefinition':
|
128 |
+
if (! $this->envVariableResolver) {
|
129 |
+
$this->envVariableResolver = new EnvironmentVariableResolver($this);
|
130 |
+
}
|
131 |
+
return $this->envVariableResolver;
|
132 |
+
case 'Cybot\Dependencies\DI\Definition\StringDefinition':
|
133 |
+
if (! $this->stringResolver) {
|
134 |
+
$this->stringResolver = new StringResolver($this->container);
|
135 |
+
}
|
136 |
+
return $this->stringResolver;
|
137 |
+
default:
|
138 |
+
throw new \RuntimeException("No definition resolver was configured for definition of type $definitionType");
|
139 |
+
}
|
140 |
+
}
|
141 |
+
}
|
addons/inc/Dependencies/DI/Definition/Resolver/StringResolver.php
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://mnapoli.github.com/PHP-DI/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Resolver;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
13 |
+
use Cybot\Dependencies\DI\Definition\StringDefinition;
|
14 |
+
use Cybot\Dependencies\DI\DependencyException;
|
15 |
+
use Cybot\Dependencies\DI\NotFoundException;
|
16 |
+
use Cybot\Dependencies\Interop\Container\ContainerInterface;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Resolves a string expression.
|
20 |
+
*
|
21 |
+
* @since 5.0
|
22 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
23 |
+
*/
|
24 |
+
class StringResolver implements DefinitionResolver
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* @var ContainerInterface
|
28 |
+
*/
|
29 |
+
private $container;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* The resolver needs a container.
|
33 |
+
* This container will be used to get the entry to which the alias points to.
|
34 |
+
*
|
35 |
+
* @param ContainerInterface $container
|
36 |
+
*/
|
37 |
+
public function __construct(ContainerInterface $container)
|
38 |
+
{
|
39 |
+
$this->container = $container;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Resolve a value definition to a value.
|
44 |
+
*
|
45 |
+
* A value definition is simple, so this will just return the value of the ValueDefinition.
|
46 |
+
*
|
47 |
+
* @param StringDefinition $definition
|
48 |
+
*
|
49 |
+
* {@inheritdoc}
|
50 |
+
*/
|
51 |
+
public function resolve(Definition $definition, array $parameters = [])
|
52 |
+
{
|
53 |
+
$this->assertIsStringDefinition($definition);
|
54 |
+
|
55 |
+
$expression = $definition->getExpression();
|
56 |
+
|
57 |
+
$result = preg_replace_callback('#\{([^\{\}]+)\}#', function (array $matches) use ($definition) {
|
58 |
+
try {
|
59 |
+
return $this->container->get($matches[1]);
|
60 |
+
} catch (NotFoundException $e) {
|
61 |
+
throw new DependencyException(sprintf(
|
62 |
+
"Error while parsing string expression for entry '%s': %s",
|
63 |
+
$definition->getName(),
|
64 |
+
$e->getMessage()
|
65 |
+
), 0, $e);
|
66 |
+
}
|
67 |
+
}, $expression);
|
68 |
+
|
69 |
+
if ($result === null) {
|
70 |
+
throw new \RuntimeException(sprintf('An unknown error occurred while parsing the string definition: \'%s\'', $expression));
|
71 |
+
}
|
72 |
+
|
73 |
+
return $result;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* {@inheritdoc}
|
78 |
+
*/
|
79 |
+
public function isResolvable(Definition $definition, array $parameters = [])
|
80 |
+
{
|
81 |
+
$this->assertIsStringDefinition($definition);
|
82 |
+
|
83 |
+
return true;
|
84 |
+
}
|
85 |
+
|
86 |
+
private function assertIsStringDefinition(Definition $definition)
|
87 |
+
{
|
88 |
+
if (!$definition instanceof StringDefinition) {
|
89 |
+
throw new \InvalidArgumentException(sprintf(
|
90 |
+
'This definition resolver is only compatible with StringDefinition objects, %s given',
|
91 |
+
get_class($definition)
|
92 |
+
));
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
addons/inc/Dependencies/DI/Definition/Resolver/ValueResolver.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* PHP-DI
|
4 |
+
*
|
5 |
+
* @link http://mnapoli.github.com/PHP-DI/
|
6 |
+
* @copyright Matthieu Napoli (http://mnapoli.fr/)
|
7 |
+
* @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
|
8 |
+
*/
|
9 |
+
|
10 |
+
namespace Cybot\Dependencies\DI\Definition\Resolver;
|
11 |
+
|
12 |
+
use Cybot\Dependencies\DI\Definition\Definition;
|
13 |
+
use Cybot\Dependencies\DI\Definition\ValueDefinition;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Resolves a value definition to a value.
|
17 |
+
*
|
18 |
+
* @since 4.0
|
19 |
+
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
20 |
+
*/
|
21 |
+
class ValueResolver implements DefinitionResolver
|
22 |
+
{
|
23 |
+
/**
|
24 |
+
* Resolve a value definition to a value.
|
25 |
+
*
|
26 |
+
* A value definition is simple, so this will just return the value of the ValueDefinition.
|
27 |
+
*
|
28 |
+
* @param ValueDefinition $definition
|
29 |
+
*
|
30 |
+
* {@inheritdoc}
|
31 |
+
*/
|
32 |
+
public function resolve(Definition $definition, array $parameters = [])
|
33 |
+
{
|
34 |
+
$this->assertIsValueDefinition($definition);
|
35 |
+
|
36 |
+
return $definition->getValue();
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* {@inheritdoc}
|
41 |
+
*/
|
42 |
+
public function isResolvable(Definition $definition, array $parameters = [])
|
43 |
+
{
|
44 |
+
$this->assertIsValueDefinition($definition);
|
45 |
+
|
46 |
+
return true;
|
47 |
+
}
|
48 |
+
|
49 |
+
private function assertIsValueDefinition(Definition $definition)
|
50 |
+
{
|
51 |
+
if (!$definition instanceof ValueDefinition) {
|
52 |
+
throw new \InvalidArgumentException(sprintf(
|
53 |
+
'This definition resolver is only compatible with ValueDefinition objects, %s given',
|
54 |
+
get_class($definition)
|
55 |
+
));
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
addons/inc/Dependencies/DI/Definition/Source/AnnotationReader.php
ADDED
@@ -0,0 +1,298 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|