Cookiebot | GDPR Compliant Cookie Consent and Notice - Version 4.1.0

Version Description

Download this release

Release Info

Developer aytac
Plugin Icon 128x128 Cookiebot | GDPR Compliant Cookie Consent and Notice
Version 4.1.0
Comparing to
See all releases

Code changes from version 4.0.3 to 4.1.0

Files changed (295) hide show
  1. addons/.travis.yml +0 -22
  2. addons/addons.json +0 -111
  3. addons/bin/install-wp-tests.sh +0 -126
  4. addons/composer.json +0 -43
  5. addons/composer.lock +0 -1208
  6. addons/config/script-config.php +0 -78
  7. addons/config/settings-config.php +0 -331
  8. addons/controller/addons/add-to-any/add-to-any.php +0 -381
  9. addons/controller/addons/addthis/addthis.php +0 -337
  10. addons/controller/addons/caos-host-analyticsjs-local-save-ga-local/caos-host-analyticsjs-local-save-ga-local.php +0 -37
  11. addons/controller/addons/caos-host-analyticsjs-local/caos-host-analyticsjs-local.php +0 -379
  12. addons/controller/addons/cookiebot-addons-interface.php +0 -217
  13. addons/controller/addons/custom-facebook-feed-old/custom-facebook-feed-old.php +0 -347
  14. addons/controller/addons/custom-facebook-feed-pro/custom-facebook-feed-pro.php +0 -342
  15. addons/controller/addons/custom-facebook-feed/custom-facebook-feed.php +0 -78
  16. addons/controller/addons/embed-autocorrect/embed-autocorrect.php +0 -798
  17. addons/controller/addons/enfold/enfold.php +0 -326
  18. addons/controller/addons/enhanced-ecommerce-for-woocommerce-store/enhanced-ecommerce-for-woocommerce-store.php +0 -331
  19. addons/controller/addons/facebook-for-woocommerce/facebook-for-woocommerce.php +0 -386
  20. addons/controller/addons/ga-google-analytics/ga-google-analytics.php +0 -348
  21. addons/controller/addons/gadwp/gadwp.php +0 -382
  22. addons/controller/addons/google-analyticator/google-analyticator.php +0 -364
  23. addons/controller/addons/google-analytics-plus/google-analytics-plus.php +0 -327
  24. addons/controller/addons/google-analytics/google-analytics.php +0 -332
  25. addons/controller/addons/google-site-kit/google-site-kit.php +0 -331
  26. addons/controller/addons/hubspot-leadin/hubspot-leadin.php +0 -336
  27. addons/controller/addons/hubspot-tracking-code/hubspot-tracking-code.php +0 -343
  28. addons/controller/addons/instagram-feed/instagram-feed.php +0 -326
  29. addons/controller/addons/jetpack/jetpack.php +0 -433
  30. addons/controller/addons/jetpack/visitor-cookies.php +0 -287
  31. addons/controller/addons/jetpack/widget/facebook-widget.php +0 -250
  32. addons/controller/addons/jetpack/widget/goodreads-widget.php +0 -309
  33. addons/controller/addons/jetpack/widget/google-maps-widget.php +0 -307
  34. addons/controller/addons/jetpack/widget/googleplus-badge-widget.php +0 -243
  35. addons/controller/addons/jetpack/widget/internet-defense-league-widget.php +0 -243
  36. addons/controller/addons/jetpack/widget/jetpack-widget-interface.php +0 -22
  37. addons/controller/addons/jetpack/widget/twitter-timeline-widget.php +0 -242
  38. addons/controller/addons/litespeed-cache/litespeed-cache.php +0 -343
  39. addons/controller/addons/matomo/matomo.php +0 -348
  40. addons/controller/addons/ninja-forms/ninja-forms.php +0 -345
  41. addons/controller/addons/official-facebook-pixel/official-facebook-pixel.php +0 -433
  42. addons/controller/addons/optinmonster/optinmonster.php +0 -324
  43. addons/controller/addons/pixel-caffeine/pixel-caffeine.php +0 -332
  44. addons/controller/addons/simple-share-buttons-adder/simple-share-buttons-adder.php +0 -324
  45. addons/controller/addons/wd-google-analytics/wd-google-analytics.php +0 -326
  46. addons/controller/addons/woocommerce-google-analytics-pro/woocommerce-google-analytics-pro.php +0 -339
  47. addons/controller/addons/wp-analytify/wp-analytify.php +0 -326
  48. addons/controller/addons/wp-google-analytics-events/wp-google-analytics-events.php +0 -333
  49. addons/controller/addons/wp-mautic/wp-mautic.php +0 -334
  50. addons/controller/addons/wp-piwik/wp-piwik.php +0 -354
  51. addons/controller/addons/wp-rocket/wp-rocket.php +0 -343
  52. addons/controller/addons/wpforms/cookie-after-consent.js +0 -51
  53. addons/controller/addons/wpforms/wpforms.php +0 -395
  54. addons/controller/plugin-controller.php +0 -129
  55. addons/cookiebot-addons-init.php +0 -230
  56. addons/inc/Dependencies/DI/Annotation/Inject.php +0 -95
  57. addons/inc/Dependencies/DI/Annotation/Injectable.php +0 -74
  58. addons/inc/Dependencies/DI/Container.php +0 -340
  59. addons/inc/Dependencies/DI/ContainerBuilder.php +0 -258
  60. addons/inc/Dependencies/DI/Debug.php +0 -39
  61. addons/inc/Dependencies/DI/Definition/AbstractFunctionCallDefinition.php +0 -82
  62. addons/inc/Dependencies/DI/Definition/AliasDefinition.php +0 -66
  63. addons/inc/Dependencies/DI/Definition/ArrayDefinition.php +0 -66
  64. addons/inc/Dependencies/DI/Definition/ArrayDefinitionExtension.php +0 -61
  65. addons/inc/Dependencies/DI/Definition/CacheableDefinition.php +0 -19
  66. addons/inc/Dependencies/DI/Definition/DecoratorDefinition.php +0 -48
  67. addons/inc/Dependencies/DI/Definition/Definition.php +0 -32
  68. addons/inc/Dependencies/DI/Definition/Dumper/AliasDefinitionDumper.php +0 -48
  69. addons/inc/Dependencies/DI/Definition/Dumper/ArrayDefinitionDumper.php +0 -65
  70. addons/inc/Dependencies/DI/Definition/Dumper/DecoratorDefinitionDumper.php +0 -37
  71. addons/inc/Dependencies/DI/Definition/Dumper/DefinitionDumper.php +0 -30
  72. addons/inc/Dependencies/DI/Definition/Dumper/DefinitionDumperDispatcher.php +0 -68
  73. addons/inc/Dependencies/DI/Definition/Dumper/EnvironmentVariableDefinitionDumper.php +0 -63
  74. addons/inc/Dependencies/DI/Definition/Dumper/FactoryDefinitionDumper.php +0 -37
  75. addons/inc/Dependencies/DI/Definition/Dumper/ObjectDefinitionDumper.php +0 -156
  76. addons/inc/Dependencies/DI/Definition/Dumper/StringDefinitionDumper.php +0 -37
  77. addons/inc/Dependencies/DI/Definition/Dumper/ValueDefinitionDumper.php +0 -44
  78. addons/inc/Dependencies/DI/Definition/EntryReference.php +0 -52
  79. addons/inc/Dependencies/DI/Definition/EnvironmentVariableDefinition.php +0 -116
  80. addons/inc/Dependencies/DI/Definition/Exception/AnnotationException.php +0 -19
  81. addons/inc/Dependencies/DI/Definition/Exception/DefinitionException.php +0 -30
  82. addons/inc/Dependencies/DI/Definition/FactoryDefinition.php +0 -75
  83. addons/inc/Dependencies/DI/Definition/HasSubDefinition.php +0 -28
  84. addons/inc/Dependencies/DI/Definition/Helper/ArrayDefinitionExtensionHelper.php +0 -46
  85. addons/inc/Dependencies/DI/Definition/Helper/DefinitionHelper.php +0 -24
  86. addons/inc/Dependencies/DI/Definition/Helper/EnvironmentVariableDefinitionHelper.php +0 -64
  87. addons/inc/Dependencies/DI/Definition/Helper/FactoryDefinitionHelper.php +0 -72
  88. addons/inc/Dependencies/DI/Definition/Helper/ObjectDefinitionHelper.php +0 -273
  89. addons/inc/Dependencies/DI/Definition/Helper/StringDefinitionHelper.php +0 -39
  90. addons/inc/Dependencies/DI/Definition/Helper/ValueDefinitionHelper.php +0 -42
  91. addons/inc/Dependencies/DI/Definition/InstanceDefinition.php +0 -76
  92. addons/inc/Dependencies/DI/Definition/ObjectDefinition.php +0 -294
  93. addons/inc/Dependencies/DI/Definition/ObjectDefinition/MethodInjection.php +0 -54
  94. addons/inc/Dependencies/DI/Definition/ObjectDefinition/PropertyInjection.php +0 -56
  95. addons/inc/Dependencies/DI/Definition/Resolver/AliasResolver.php +0 -77
  96. addons/inc/Dependencies/DI/Definition/Resolver/ArrayResolver.php +0 -105
  97. addons/inc/Dependencies/DI/Definition/Resolver/DecoratorResolver.php +0 -107
  98. addons/inc/Dependencies/DI/Definition/Resolver/DefinitionResolver.php +0 -44
  99. addons/inc/Dependencies/DI/Definition/Resolver/EnvironmentVariableResolver.php +0 -94
  100. addons/inc/Dependencies/DI/Definition/Resolver/FactoryResolver.php +0 -85
  101. addons/inc/Dependencies/DI/Definition/Resolver/InstanceInjector.php +0 -67
  102. addons/inc/Dependencies/DI/Definition/Resolver/ObjectCreator.php +0 -266
  103. addons/inc/Dependencies/DI/Definition/Resolver/ParameterResolver.php +0 -138
  104. addons/inc/Dependencies/DI/Definition/Resolver/ResolverDispatcher.php +0 -141
  105. addons/inc/Dependencies/DI/Definition/Resolver/StringResolver.php +0 -95
  106. addons/inc/Dependencies/DI/Definition/Resolver/ValueResolver.php +0 -58
  107. addons/inc/Dependencies/DI/Definition/Source/AnnotationReader.php +0 -298
  108. addons/inc/Dependencies/DI/Definition/Source/Autowiring.php +0 -68
  109. addons/inc/Dependencies/DI/Definition/Source/CachedDefinitionSource.php +0 -104
  110. addons/inc/Dependencies/DI/Definition/Source/DefinitionArray.php +0 -142
  111. addons/inc/Dependencies/DI/Definition/Source/DefinitionFile.php +0 -74
  112. addons/inc/Dependencies/DI/Definition/Source/DefinitionSource.php +0 -31
  113. addons/inc/Dependencies/DI/Definition/Source/MutableDefinitionSource.php +0 -15
  114. addons/inc/Dependencies/DI/Definition/Source/SourceChain.php +0 -108
  115. addons/inc/Dependencies/DI/Definition/StringDefinition.php +0 -66
  116. addons/inc/Dependencies/DI/Definition/ValueDefinition.php +0 -67
  117. addons/inc/Dependencies/DI/DependencyException.php +0 -19
  118. addons/inc/Dependencies/DI/FactoryInterface.php +0 -34
  119. addons/inc/Dependencies/DI/Invoker/DefinitionParameterResolver.php +0 -45
  120. addons/inc/Dependencies/DI/InvokerInterface.php +0 -19
  121. addons/inc/Dependencies/DI/NotFoundException.php +0 -19
  122. addons/inc/Dependencies/DI/Proxy/ProxyFactory.php +0 -88
  123. addons/inc/Dependencies/DI/Reflection/CallableReflectionFactory.php +0 -51
  124. addons/inc/Dependencies/DI/Scope.php +0 -54
  125. addons/inc/Dependencies/DI/functions.php +0 -181
  126. addons/inc/Dependencies/Interop/Container/ContainerInterface.php +0 -15
  127. addons/inc/Dependencies/Interop/Container/Exception/ContainerException.php +0 -15
  128. addons/inc/Dependencies/Interop/Container/Exception/NotFoundException.php +0 -15
  129. addons/inc/Dependencies/Invoker/CallableResolver.php +0 -127
  130. addons/inc/Dependencies/Invoker/Exception/InvocationException.php +0 -12
  131. addons/inc/Dependencies/Invoker/Exception/NotCallableException.php +0 -35
  132. addons/inc/Dependencies/Invoker/Exception/NotEnoughParametersException.php +0 -12
  133. addons/inc/Dependencies/Invoker/Invoker.php +0 -122
  134. addons/inc/Dependencies/Invoker/InvokerInterface.php +0 -29
  135. addons/inc/Dependencies/Invoker/ParameterResolver/AssociativeArrayResolver.php +0 -39
  136. addons/inc/Dependencies/Invoker/ParameterResolver/Container/ParameterNameContainerResolver.php +0 -51
  137. addons/inc/Dependencies/Invoker/ParameterResolver/Container/TypeHintContainerResolver.php +0 -51
  138. addons/inc/Dependencies/Invoker/ParameterResolver/DefaultValueResolver.php +0 -40
  139. addons/inc/Dependencies/Invoker/ParameterResolver/NumericArrayResolver.php +0 -39
  140. addons/inc/Dependencies/Invoker/ParameterResolver/ParameterResolver.php +0 -33
  141. addons/inc/Dependencies/Invoker/ParameterResolver/ResolverChain.php +0 -69
  142. addons/inc/Dependencies/Invoker/ParameterResolver/TypeHintResolver.php +0 -39
  143. addons/inc/Dependencies/Invoker/Reflection/CallableReflection.php +0 -61
  144. addons/inc/Dependencies/PhpDocReader/AnnotationException.php +0 -10
  145. addons/inc/Dependencies/PhpDocReader/PhpDocReader.php +0 -307
  146. addons/inc/Dependencies/PhpDocReader/PhpParser/TokenParser.php +0 -182
  147. addons/inc/Dependencies/PhpDocReader/PhpParser/UseStatementParser.php +0 -64
  148. addons/inc/Dependencies/Psr/Container/ContainerExceptionInterface.php +0 -13
  149. addons/inc/Dependencies/Psr/Container/ContainerInterface.php +0 -37
  150. addons/inc/Dependencies/Psr/Container/NotFoundExceptionInterface.php +0 -13
  151. addons/inc/classes/dependencies/.gitkeep +0 -0
  152. addons/js/jquery.tipTip.js +0 -193
  153. addons/js/settings.js +0 -203
  154. addons/lib/autoloader.php +0 -54
  155. addons/lib/buffer/buffer-output-interface.php +0 -32
  156. addons/lib/buffer/buffer-output-tag-interface.php +0 -43
  157. addons/lib/buffer/buffer-output-tag.php +0 -147
  158. addons/lib/buffer/buffer-output.php +0 -65
  159. addons/lib/cookie-consent-interface.php +0 -53
  160. addons/lib/cookie-consent.php +0 -166
  161. addons/lib/dependency-container.php +0 -53
  162. addons/lib/helper.php +0 -474
  163. addons/lib/ioc/autoload.php +0 -7
  164. addons/lib/ioc/composer/ClassLoader.php +0 -445
  165. addons/lib/ioc/composer/LICENSE +0 -21
  166. addons/lib/ioc/composer/autoload_classmap.php +0 -9
  167. addons/lib/ioc/composer/autoload_files.php +0 -10
  168. addons/lib/ioc/composer/autoload_namespaces.php +0 -9
  169. addons/lib/ioc/composer/autoload_psr4.php +0 -14
  170. addons/lib/ioc/composer/autoload_real.php +0 -70
  171. addons/lib/ioc/composer/autoload_static.php +0 -61
  172. addons/lib/ioc/composer/installed.json +0 -226
  173. addons/lib/ioc/container-interop/container-interop/.gitignore +0 -3
  174. addons/lib/ioc/container-interop/container-interop/LICENSE +0 -20
  175. addons/lib/ioc/container-interop/container-interop/README.md +0 -148
  176. addons/lib/ioc/container-interop/container-interop/composer.json +0 -15
  177. addons/lib/ioc/container-interop/container-interop/docs/ContainerInterface-meta.md +0 -114
  178. addons/lib/ioc/container-interop/container-interop/docs/ContainerInterface.md +0 -158
  179. addons/lib/ioc/container-interop/container-interop/docs/Delegate-lookup-meta.md +0 -259
  180. addons/lib/ioc/container-interop/container-interop/docs/Delegate-lookup.md +0 -60
  181. addons/lib/ioc/container-interop/container-interop/docs/images/interoperating_containers.png +0 -0
  182. addons/lib/ioc/container-interop/container-interop/docs/images/priority.png +0 -0
  183. addons/lib/ioc/container-interop/container-interop/docs/images/side_by_side_containers.png +0 -0
  184. addons/lib/ioc/container-interop/container-interop/src/Interop/Container/ContainerInterface.php +0 -15
  185. addons/lib/ioc/container-interop/container-interop/src/Interop/Container/Exception/ContainerException.php +0 -15
  186. addons/lib/ioc/container-interop/container-interop/src/Interop/Container/Exception/NotFoundException.php +0 -15
  187. addons/lib/ioc/php-di/invoker/CONTRIBUTING.md +0 -15
  188. addons/lib/ioc/php-di/invoker/LICENSE +0 -21
  189. addons/lib/ioc/php-di/invoker/README.md +0 -234
  190. addons/lib/ioc/php-di/invoker/composer.json +0 -25
  191. addons/lib/ioc/php-di/invoker/doc/parameter-resolvers.md +0 -109
  192. addons/lib/ioc/php-di/invoker/src/CallableResolver.php +0 -127
  193. addons/lib/ioc/php-di/invoker/src/Exception/InvocationException.php +0 -12
  194. addons/lib/ioc/php-di/invoker/src/Exception/NotCallableException.php +0 -35
  195. addons/lib/ioc/php-di/invoker/src/Exception/NotEnoughParametersException.php +0 -12
  196. addons/lib/ioc/php-di/invoker/src/Invoker.php +0 -122
  197. addons/lib/ioc/php-di/invoker/src/InvokerInterface.php +0 -29
  198. addons/lib/ioc/php-di/invoker/src/ParameterResolver/AssociativeArrayResolver.php +0 -39
  199. addons/lib/ioc/php-di/invoker/src/ParameterResolver/Container/ParameterNameContainerResolver.php +0 -51
  200. addons/lib/ioc/php-di/invoker/src/ParameterResolver/Container/TypeHintContainerResolver.php +0 -51
  201. addons/lib/ioc/php-di/invoker/src/ParameterResolver/DefaultValueResolver.php +0 -40
  202. addons/lib/ioc/php-di/invoker/src/ParameterResolver/NumericArrayResolver.php +0 -39
  203. addons/lib/ioc/php-di/invoker/src/ParameterResolver/ParameterResolver.php +0 -33
  204. addons/lib/ioc/php-di/invoker/src/ParameterResolver/ResolverChain.php +0 -69
  205. addons/lib/ioc/php-di/invoker/src/ParameterResolver/TypeHintResolver.php +0 -39
  206. addons/lib/ioc/php-di/invoker/src/Reflection/CallableReflection.php +0 -61
  207. addons/lib/ioc/php-di/php-di/.coveralls.yml +0 -2
  208. addons/lib/ioc/php-di/php-di/.gitattributes +0 -8
  209. addons/lib/ioc/php-di/php-di/.gitignore +0 -9
  210. addons/lib/ioc/php-di/php-di/.travis.yml +0 -26
  211. addons/lib/ioc/php-di/php-di/404.md +0 -3
  212. addons/lib/ioc/php-di/php-di/CONTRIBUTING.md +0 -52
  213. addons/lib/ioc/php-di/php-di/LICENSE +0 -18
  214. addons/lib/ioc/php-di/php-di/README.md +0 -23
  215. addons/lib/ioc/php-di/php-di/change-log.md +0 -280
  216. addons/lib/ioc/php-di/php-di/composer.json +0 -40
  217. addons/lib/ioc/php-di/php-di/couscous.yml +0 -107
  218. addons/lib/ioc/php-di/php-di/phpunit.xml.dist +0 -30
  219. addons/lib/ioc/php-di/php-di/src/DI/Annotation/Inject.php +0 -95
  220. addons/lib/ioc/php-di/php-di/src/DI/Annotation/Injectable.php +0 -74
  221. addons/lib/ioc/php-di/php-di/src/DI/Container.php +0 -340
  222. addons/lib/ioc/php-di/php-di/src/DI/ContainerBuilder.php +0 -258
  223. addons/lib/ioc/php-di/php-di/src/DI/Debug.php +0 -39
  224. addons/lib/ioc/php-di/php-di/src/DI/Definition/AbstractFunctionCallDefinition.php +0 -82
  225. addons/lib/ioc/php-di/php-di/src/DI/Definition/AliasDefinition.php +0 -66
  226. addons/lib/ioc/php-di/php-di/src/DI/Definition/ArrayDefinition.php +0 -66
  227. addons/lib/ioc/php-di/php-di/src/DI/Definition/ArrayDefinitionExtension.php +0 -61
  228. addons/lib/ioc/php-di/php-di/src/DI/Definition/CacheableDefinition.php +0 -19
  229. addons/lib/ioc/php-di/php-di/src/DI/Definition/DecoratorDefinition.php +0 -48
  230. addons/lib/ioc/php-di/php-di/src/DI/Definition/Definition.php +0 -32
  231. addons/lib/ioc/php-di/php-di/src/DI/Definition/Dumper/AliasDefinitionDumper.php +0 -48
  232. addons/lib/ioc/php-di/php-di/src/DI/Definition/Dumper/ArrayDefinitionDumper.php +0 -65
  233. addons/lib/ioc/php-di/php-di/src/DI/Definition/Dumper/DecoratorDefinitionDumper.php +0 -37
  234. addons/lib/ioc/php-di/php-di/src/DI/Definition/Dumper/DefinitionDumper.php +0 -30
  235. addons/lib/ioc/php-di/php-di/src/DI/Definition/Dumper/DefinitionDumperDispatcher.php +0 -68
  236. addons/lib/ioc/php-di/php-di/src/DI/Definition/Dumper/EnvironmentVariableDefinitionDumper.php +0 -63
  237. addons/lib/ioc/php-di/php-di/src/DI/Definition/Dumper/FactoryDefinitionDumper.php +0 -37
  238. addons/lib/ioc/php-di/php-di/src/DI/Definition/Dumper/ObjectDefinitionDumper.php +0 -156
  239. addons/lib/ioc/php-di/php-di/src/DI/Definition/Dumper/StringDefinitionDumper.php +0 -37
  240. addons/lib/ioc/php-di/php-di/src/DI/Definition/Dumper/ValueDefinitionDumper.php +0 -44
  241. addons/lib/ioc/php-di/php-di/src/DI/Definition/EntryReference.php +0 -52
  242. addons/lib/ioc/php-di/php-di/src/DI/Definition/EnvironmentVariableDefinition.php +0 -116
  243. addons/lib/ioc/php-di/php-di/src/DI/Definition/Exception/AnnotationException.php +0 -19
  244. addons/lib/ioc/php-di/php-di/src/DI/Definition/Exception/DefinitionException.php +0 -30
  245. addons/lib/ioc/php-di/php-di/src/DI/Definition/FactoryDefinition.php +0 -75
  246. addons/lib/ioc/php-di/php-di/src/DI/Definition/HasSubDefinition.php +0 -28
  247. addons/lib/ioc/php-di/php-di/src/DI/Definition/Helper/ArrayDefinitionExtensionHelper.php +0 -46
  248. addons/lib/ioc/php-di/php-di/src/DI/Definition/Helper/DefinitionHelper.php +0 -24
  249. addons/lib/ioc/php-di/php-di/src/DI/Definition/Helper/EnvironmentVariableDefinitionHelper.php +0 -64
  250. addons/lib/ioc/php-di/php-di/src/DI/Definition/Helper/FactoryDefinitionHelper.php +0 -72
  251. addons/lib/ioc/php-di/php-di/src/DI/Definition/Helper/ObjectDefinitionHelper.php +0 -273
  252. addons/lib/ioc/php-di/php-di/src/DI/Definition/Helper/StringDefinitionHelper.php +0 -39
  253. addons/lib/ioc/php-di/php-di/src/DI/Definition/Helper/ValueDefinitionHelper.php +0 -42
  254. addons/lib/ioc/php-di/php-di/src/DI/Definition/InstanceDefinition.php +0 -76
  255. addons/lib/ioc/php-di/php-di/src/DI/Definition/ObjectDefinition.php +0 -294
  256. addons/lib/ioc/php-di/php-di/src/DI/Definition/ObjectDefinition/MethodInjection.php +0 -54
  257. addons/lib/ioc/php-di/php-di/src/DI/Definition/ObjectDefinition/PropertyInjection.php +0 -56
  258. addons/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/AliasResolver.php +0 -77
  259. addons/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/ArrayResolver.php +0 -105
  260. addons/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/DecoratorResolver.php +0 -107
  261. addons/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/DefinitionResolver.php +0 -44
  262. addons/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/EnvironmentVariableResolver.php +0 -94
  263. addons/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/FactoryResolver.php +0 -85
  264. addons/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/InstanceInjector.php +0 -67
  265. addons/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/ObjectCreator.php +0 -266
  266. addons/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/ParameterResolver.php +0 -138
  267. addons/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/ResolverDispatcher.php +0 -141
  268. addons/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/StringResolver.php +0 -95
  269. addons/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/ValueResolver.php +0 -58
  270. addons/lib/ioc/php-di/php-di/src/DI/Definition/Source/AnnotationReader.php +0 -298
  271. addons/lib/ioc/php-di/php-di/src/DI/Definition/Source/Autowiring.php +0 -68
  272. addons/lib/ioc/php-di/php-di/src/DI/Definition/Source/CachedDefinitionSource.php +0 -104
  273. addons/lib/ioc/php-di/php-di/src/DI/Definition/Source/DefinitionArray.php +0 -142
  274. addons/lib/ioc/php-di/php-di/src/DI/Definition/Source/DefinitionFile.php +0 -74
  275. addons/lib/ioc/php-di/php-di/src/DI/Definition/Source/DefinitionSource.php +0 -31
  276. addons/lib/ioc/php-di/php-di/src/DI/Definition/Source/MutableDefinitionSource.php +0 -15
  277. addons/lib/ioc/php-di/php-di/src/DI/Definition/Source/SourceChain.php +0 -108
  278. addons/lib/ioc/php-di/php-di/src/DI/Definition/StringDefinition.php +0 -66
  279. addons/lib/ioc/php-di/php-di/src/DI/Definition/ValueDefinition.php +0 -67
  280. addons/lib/ioc/php-di/php-di/src/DI/DependencyException.php +0 -19
  281. addons/lib/ioc/php-di/php-di/src/DI/FactoryInterface.php +0 -34
  282. addons/lib/ioc/php-di/php-di/src/DI/Invoker/DefinitionParameterResolver.php +0 -45
  283. addons/lib/ioc/php-di/php-di/src/DI/InvokerInterface.php +0 -19
  284. addons/lib/ioc/php-di/php-di/src/DI/NotFoundException.php +0 -19
  285. addons/lib/ioc/php-di/php-di/src/DI/Proxy/ProxyFactory.php +0 -88
  286. addons/lib/ioc/php-di/php-di/src/DI/Reflection/CallableReflectionFactory.php +0 -51
  287. addons/lib/ioc/php-di/php-di/src/DI/Scope.php +0 -54
  288. addons/lib/ioc/php-di/php-di/src/DI/functions.php +0 -181
  289. addons/lib/ioc/php-di/phpdoc-reader/.gitattributes +0 -7
  290. addons/lib/ioc/php-di/phpdoc-reader/.gitignore +0 -5
  291. addons/lib/ioc/php-di/phpdoc-reader/LICENSE +0 -16
  292. addons/lib/ioc/php-di/phpdoc-reader/README.md +0 -58
  293. addons/lib/ioc/php-di/phpdoc-reader/composer.json +0 -23
  294. addons/lib/ioc/php-di/phpdoc-reader/src/PhpDocReader/AnnotationException.php +0 -10
  295. addons/lib/ioc/php-di/phpdoc-reader/src/PhpDocReader/PhpDocReader.php +0 -249
addons/.travis.yml DELETED
@@ -1,22 +0,0 @@
1
- # see http://about.travis-ci.org/docs/user/languages/php/ for more hints
2
- language: php
3
-
4
- # list any PHP version you want to test against
5
- php:
6
- # aliased to a recent 5.4.x version
7
- - '5.4'
8
- - '5.6'
9
- - '7.1'
10
-
11
- env:
12
- - WP_PROJECT_TYPE=plugin WP_VERSION=latest WP_MULTISITE=0 WP_TEST_URL=http://localhost:12000 WP_TEST_USER=test WP_TEST_USER_PASS=test
13
-
14
- before_script:
15
- # Install composer packages before trying to activate themes or plugins
16
- # - composer install
17
-
18
- - git clone https://github.com/Seravo/wordpress-test-template wp-tests
19
- - bash wp-tests/bin/install-wp-tests.sh test root '' localhost $WP_VERSION
20
-
21
- script:
22
- - phpunit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/addons.json DELETED
@@ -1,111 +0,0 @@
1
- {
2
- "Add_To_Any": {
3
- "class": "cookiebot_addons\\controller\\addons\\add_to_any\\Add_To_Any"
4
- },
5
- "Ga_Google_Analytics": {
6
- "class": "cookiebot_addons\\controller\\addons\\ga_google_analytics\\Ga_Google_Analytics"
7
- },
8
- "Google_Analytics": {
9
- "class": "cookiebot_addons\\controller\\addons\\google_analytics\\Google_Analytics"
10
- },
11
- "Ga_Analyticator": {
12
- "class": "cookiebot_addons\\controller\\addons\\google_analyticator\\Google_Analyticator"
13
- },
14
- "Wd_Google_Analytics": {
15
- "class": "cookiebot_addons\\controller\\addons\\wd_google_analytics\\Wd_Google_Analytics"
16
- },
17
- "Jetpack": {
18
- "class": "cookiebot_addons\\controller\\addons\\jetpack\\Jetpack"
19
- },
20
- "Hubspot_Leadin": {
21
- "class": "cookiebot_addons\\controller\\addons\\hubspot_leadin\\Hubspot_Leadin"
22
- },
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
- },
32
- "Custom_Facebook_Feed_Pro": {
33
- "class": "cookiebot_addons\\controller\\addons\\custom_facebook_feed_pro\\Custom_Facebook_Feed_Pro"
34
- },
35
- "Embed_Autocorrect": {
36
- "class": "cookiebot_addons\\controller\\addons\\embed_autocorrect\\Embed_Autocorrect"
37
- },
38
- "Instagram_Feed": {
39
- "class": "cookiebot_addons\\controller\\addons\\instagram_feed\\Instagram_Feed"
40
- },
41
- "WP_Piwik": {
42
- "class": "cookiebot_addons\\controller\\addons\\wp_piwik\\Wp_Piwik"
43
- },
44
- "Facebook_For_Woocommerce": {
45
- "class": "cookiebot_addons\\controller\\addons\\facebook_for_woocommerce\\Facebook_For_Woocommerce"
46
- },
47
- "Pixel_Caffeine": {
48
- "class": "cookiebot_addons\\controller\\addons\\pixel_caffeine\\Pixel_Caffeine"
49
- },
50
- "Wp_Analytify": {
51
- "class": "cookiebot_addons\\controller\\addons\\wp_analytify\\Wp_Analytify"
52
- },
53
- "Google_Analytics_Plus": {
54
- "class": "cookiebot_addons\\controller\\addons\\google_analytics_plus\\Google_Analytics_Plus"
55
- },
56
- "CAOS_Host_Analyticsjs_Local_Save_Ga_Local": {
57
- "class": "cookiebot_addons\\controller\\addons\\caos_host_analyticsjs_local_save_ga_local\\CAOS_Host_Analyticsjs_Local_Save_Ga_Local"
58
- },
59
- "CAOS_Host_Analyticsjs_Local": {
60
- "class": "cookiebot_addons\\controller\\addons\\caos_host_analyticsjs_local\\CAOS_Host_Analyticsjs_Local"
61
- },
62
- "Matomo": {
63
- "class": "cookiebot_addons\\controller\\addons\\matomo\\matomo"
64
- },
65
- "Ninja_Forms": {
66
- "class": "cookiebot_addons\\controller\\addons\\ninja_forms\\Ninja_Forms"
67
- },
68
- "Optinmonster": {
69
- "class": "cookiebot_addons\\controller\\addons\\optinmonster\\Optinmonster"
70
- },
71
- "Wpforms": {
72
- "class": "cookiebot_addons\\controller\\addons\\wpforms\\Wpforms"
73
- },
74
- "Gadwp": {
75
- "class": "cookiebot_addons\\controller\\addons\\gadwp\\Gadwp"
76
- },
77
- "Addthis": {
78
- "class": "cookiebot_addons\\controller\\addons\\addthis\\Addthis"
79
- },
80
- "Wp_Mautic": {
81
- "class": "cookiebot_addons\\controller\\addons\\wp_mautic\\Wp_Mautic"
82
- },
83
- "Wp_Rocket": {
84
- "class": "cookiebot_addons\\controller\\addons\\wp_rocket\\Wp_Rocket"
85
- },
86
- "Litespeed_Cache": {
87
- "class": "cookiebot_addons\\controller\\addons\\litespeed_cache\\Litespeed_Cache"
88
- },
89
- "Enhanced_Ecommerce_For_WooCommerce_Store": {
90
- "class": "cookiebot_addons\\controller\\addons\\enhanced_ecommerce_for_woocommerce_store\\Enhanced_Ecommerce_For_WooCommerce_Store"
91
- },
92
- "Simple_Share_Buttons_Adder": {
93
- "class": "cookiebot_addons\\controller\\addons\\simple_share_buttons_adder\\Simple_Share_Buttons_Adder"
94
- },
95
- "Official_Facebook_Pixel": {
96
- "class": "cookiebot_addons\\controller\\addons\\official_facebook_pixel\\Official_Facebook_Pixel"
97
- },
98
- "Woocommerce_Google_Analytics_Pro": {
99
- "class": "cookiebot_addons\\controller\\addons\\woocommerce_google_analytics_pro\\Woocommerce_Google_Analytics_Pro"
100
- },
101
- "Google_Site_Kit": {
102
- "class": "cookiebot_addons\\controller\\addons\\google_site_kit\\Google_Site_Kit"
103
- },
104
- "Enfold": {
105
- "class": "cookiebot_addons\\controller\\addons\\enfold\\Enfold",
106
- "is_theme": true
107
- },
108
- "Wp_Google_Analytics_Events": {
109
- "class": "cookiebot_addons\\controller\\addons\\wp_google_analytics_events\\Wp_Google_Analytics_Events"
110
- }
111
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/bin/install-wp-tests.sh DELETED
@@ -1,126 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- if [ $# -lt 3 ]; then
4
- echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version] [skip-database-creation]"
5
- exit 1
6
- fi
7
-
8
- DB_NAME=$1
9
- DB_USER=$2
10
- DB_PASS=$3
11
- DB_HOST=${4-localhost}
12
- WP_VERSION=${5-latest}
13
- SKIP_DB_CREATE=${6-false}
14
-
15
- WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
16
- WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}
17
-
18
- download() {
19
- if [ `which curl` ]; then
20
- curl -s "$1" > "$2";
21
- elif [ `which wget` ]; then
22
- wget -nv -O "$2" "$1"
23
- fi
24
- }
25
-
26
- if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then
27
- WP_TESTS_TAG="tags/$WP_VERSION"
28
- elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
29
- WP_TESTS_TAG="trunk"
30
- else
31
- # http serves a single offer, whereas https serves multiple. we only want one
32
- download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
33
- grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
34
- LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
35
- if [[ -z "$LATEST_VERSION" ]]; then
36
- echo "Latest WordPress version could not be found"
37
- exit 1
38
- fi
39
- WP_TESTS_TAG="tags/$LATEST_VERSION"
40
- fi
41
-
42
- set -ex
43
-
44
- install_wp() {
45
-
46
- if [ -d $WP_CORE_DIR ]; then
47
- return;
48
- fi
49
-
50
- mkdir -p $WP_CORE_DIR
51
-
52
- if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
53
- mkdir -p /tmp/wordpress-nightly
54
- download https://wordpress.org/nightly-builds/wordpress-latest.zip /tmp/wordpress-nightly/wordpress-nightly.zip
55
- unzip -q /tmp/wordpress-nightly/wordpress-nightly.zip -d /tmp/wordpress-nightly/
56
- mv /tmp/wordpress-nightly/wordpress/* $WP_CORE_DIR
57
- else
58
- if [ $WP_VERSION == 'latest' ]; then
59
- local ARCHIVE_NAME='latest'
60
- else
61
- local ARCHIVE_NAME="wordpress-$WP_VERSION"
62
- fi
63
- download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz
64
- tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
65
- fi
66
-
67
- download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
68
- }
69
-
70
- install_test_suite() {
71
- # portable in-place argument for both GNU sed and Mac OSX sed
72
- if [[ $(uname -s) == 'Darwin' ]]; then
73
- local ioption='-i .bak'
74
- else
75
- local ioption='-i'
76
- fi
77
-
78
- # set up testing suite if it doesn't yet exist
79
- if [ ! -d $WP_TESTS_DIR ]; then
80
- # set up testing suite
81
- mkdir -p $WP_TESTS_DIR
82
- svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
83
- fi
84
-
85
- if [ ! -f wp-tests-config.php ]; then
86
- download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
87
- # remove all forward slashes in the end
88
- WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::")
89
- sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
90
- sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
91
- sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
92
- sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
93
- sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
94
- fi
95
-
96
- }
97
-
98
- install_db() {
99
-
100
- if [ ${SKIP_DB_CREATE} = "true" ]; then
101
- return 0
102
- fi
103
-
104
- # parse DB_HOST for port or socket references
105
- local PARTS=(${DB_HOST//\:/ })
106
- local DB_HOSTNAME=${PARTS[0]};
107
- local DB_SOCK_OR_PORT=${PARTS[1]};
108
- local EXTRA=""
109
-
110
- if ! [ -z $DB_HOSTNAME ] ; then
111
- if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
112
- EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
113
- elif ! [ -z $DB_SOCK_OR_PORT ] ; then
114
- EXTRA=" --socket=$DB_SOCK_OR_PORT"
115
- elif ! [ -z $DB_HOSTNAME ] ; then
116
- EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
117
- fi
118
- fi
119
-
120
- # create database
121
- mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
122
- }
123
-
124
- install_wp
125
- install_test_suite
126
- install_db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/composer.json DELETED
@@ -1,43 +0,0 @@
1
- {
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 DELETED
@@ -1,1208 +0,0 @@
1
- {
2
- "_readme": [
3
- "This file locks the dependencies of your project to a known state",
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",
11
- "version": "1.2.0",
12
- "source": {
13
- "type": "git",
14
- "url": "https://github.com/container-interop/container-interop.git",
15
- "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8"
16
- },
17
- "dist": {
18
- "type": "zip",
19
- "url": "https://api.github.com/repos/container-interop/container-interop/zipball/79cbf1341c22ec75643d841642dd5d6acd83bdb8",
20
- "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8",
21
- "shasum": ""
22
- },
23
- "require": {
24
- "psr/container": "^1.0"
25
- },
26
- "type": "library",
27
- "autoload": {
28
- "psr-4": {
29
- "Interop\\Container\\": "src/Interop/Container/"
30
- }
31
- },
32
- "notification-url": "https://packagist.org/downloads/",
33
- "license": [
34
- "MIT"
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
- {
42
- "name": "php-di/invoker",
43
- "version": "1.3.3",
44
- "source": {
45
- "type": "git",
46
- "url": "https://github.com/PHP-DI/Invoker.git",
47
- "reference": "1f4ca63b9abc66109e53b255e465d0ddb5c2e3f7"
48
- },
49
- "dist": {
50
- "type": "zip",
51
- "url": "https://api.github.com/repos/PHP-DI/Invoker/zipball/1f4ca63b9abc66109e53b255e465d0ddb5c2e3f7",
52
- "reference": "1f4ca63b9abc66109e53b255e465d0ddb5c2e3f7",
53
- "shasum": ""
54
- },
55
- "require": {
56
- "container-interop/container-interop": "~1.1"
57
- },
58
- "require-dev": {
59
- "athletic/athletic": "~0.1.8",
60
- "phpunit/phpunit": "~4.5"
61
- },
62
- "type": "library",
63
- "autoload": {
64
- "psr-4": {
65
- "Invoker\\": "src/"
66
- }
67
- },
68
- "notification-url": "https://packagist.org/downloads/",
69
- "license": [
70
- "MIT"
71
- ],
72
- "description": "Generic and extensible callable invoker",
73
- "homepage": "https://github.com/PHP-DI/Invoker",
74
- "keywords": [
75
- "callable",
76
- "dependency",
77
- "dependency-injection",
78
- "injection",
79
- "invoke",
80
- "invoker"
81
- ],
82
- "time": "2016-07-14T13:09:58+00:00"
83
- },
84
- {
85
- "name": "php-di/php-di",
86
- "version": "5.0.0",
87
- "source": {
88
- "type": "git",
89
- "url": "https://github.com/PHP-DI/PHP-DI.git",
90
- "reference": "c3bbc0d334b888ec8baa75f95b4900ee17b18fa7"
91
- },
92
- "dist": {
93
- "type": "zip",
94
- "url": "https://api.github.com/repos/PHP-DI/PHP-DI/zipball/c3bbc0d334b888ec8baa75f95b4900ee17b18fa7",
95
- "reference": "c3bbc0d334b888ec8baa75f95b4900ee17b18fa7",
96
- "shasum": ""
97
- },
98
- "require": {
99
- "container-interop/container-interop": "~1.0",
100
- "php": ">=5.4.0",
101
- "php-di/invoker": "~1.0",
102
- "php-di/phpdoc-reader": "~2.0"
103
- },
104
- "require-dev": {
105
- "doctrine/annotations": "~1.2",
106
- "doctrine/cache": "~1.0",
107
- "mnapoli/phpunit-easymock": "~0.1.4",
108
- "ocramius/proxy-manager": "~1.0",
109
- "phpunit/phpunit": "~4.5"
110
- },
111
- "suggest": {
112
- "doctrine/annotations": "Install it if you want to use annotations (version ~1.2)",
113
- "doctrine/cache": "Install it if you want to use the cache (version ~1.0)",
114
- "ocramius/proxy-manager": "Install it if you want to use lazy injection (version ~1.0)"
115
- },
116
- "type": "library",
117
- "autoload": {
118
- "psr-4": {
119
- "DI\\": "src/DI/"
120
- },
121
- "files": [
122
- "src/DI/functions.php"
123
- ]
124
- },
125
- "notification-url": "https://packagist.org/downloads/",
126
- "license": [
127
- "MIT"
128
- ],
129
- "description": "The dependency injection container for humans",
130
- "homepage": "http://php-di.org/",
131
- "keywords": [
132
- "container",
133
- "dependency injection",
134
- "di"
135
- ],
136
- "time": "2015-06-10T06:16:52+00:00"
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": {
161
- "psr-4": {
162
- "PhpDocReader\\": "src/PhpDocReader"
163
- }
164
- },
165
- "notification-url": "https://packagist.org/downloads/",
166
- "license": [
167
- "MIT"
168
- ],
169
- "description": "PhpDocReader parses @var and @param values in PHP docblocks (supports namespaced class names with the same resolution rules as PHP)",
170
- "keywords": [
171
- "phpdoc",
172
- "reflection"
173
- ],
174
- "time": "2020-10-12T12:39:22+00:00"
175
- },
176
- {
177
- "name": "psr/container",
178
- "version": "1.0.0",
179
- "source": {
180
- "type": "git",
181
- "url": "https://github.com/php-fig/container.git",
182
- "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f"
183
- },
184
- "dist": {
185
- "type": "zip",
186
- "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
187
- "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
188
- "shasum": ""
189
- },
190
- "require": {
191
- "php": ">=5.3.0"
192
- },
193
- "type": "library",
194
- "extra": {
195
- "branch-alias": {
196
- "dev-master": "1.0.x-dev"
197
- }
198
- },
199
- "autoload": {
200
- "psr-4": {
201
- "Psr\\Container\\": "src/"
202
- }
203
- },
204
- "notification-url": "https://packagist.org/downloads/",
205
- "license": [
206
- "MIT"
207
- ],
208
- "authors": [
209
- {
210
- "name": "PHP-FIG",
211
- "homepage": "http://www.php-fig.org/"
212
- }
213
- ],
214
- "description": "Common Container Interface (PHP FIG PSR-11)",
215
- "homepage": "https://github.com/php-fig/container",
216
- "keywords": [
217
- "PSR-11",
218
- "container",
219
- "container-interface",
220
- "container-interop",
221
- "psr"
222
- ],
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/script-config.php DELETED
@@ -1,78 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\config;
4
-
5
- class Script_Config {
6
-
7
- /**
8
- * Script_Config constructor.
9
- *
10
- * @since 1.9.0
11
- */
12
- public function __construct() {
13
- add_action( 'init', array( $this, 'scripts' ) );
14
- }
15
-
16
- /**
17
- * Run Fix scripts
18
- *
19
- * @since 1.9.0
20
- */
21
- public function scripts() {
22
- $this->fix_cookietypes_placeholder();
23
- }
24
-
25
- /**
26
- * Fix %s mergetag into %cookie_types
27
- * Run it once and only in the cookiebot addon version 1.9.0
28
- *
29
- * @since 1.9.0
30
- */
31
- private function fix_cookietypes_placeholder() {
32
- /**
33
- * Only for the version 1.9.0
34
- */
35
- if ( COOKIEBOT_ADDONS_VERSION == '1.9.0' ) {
36
-
37
- /**
38
- * Only run it once
39
- */
40
- if ( ! get_option( 'fix_cookietypes_placeholder' ) ) {
41
-
42
- $options = array( 'cookiebot_jetpack_addon', 'cookiebot_available_addons' );
43
-
44
- foreach ( $options as $option_key ) {
45
- /**
46
- * Cookiebot jetpack addon
47
- */
48
- $option = get_option( $option_key );
49
-
50
- if ( $option ) {
51
-
52
- foreach ( $option as $addon_key => $addon ) {
53
-
54
- if ( isset( $addon['placeholder'] ) ) {
55
-
56
- foreach ( $addon['placeholder']['languages'] as $addon_option_key => $addon_option ) {
57
- /**
58
- * Replace %s[ with %cookie_types[
59
- */
60
- $text = str_replace( '%s[', '%cookie_types[', $addon_option );
61
-
62
- $option[ $addon_key ]['placeholder']['languages'][ $addon_option_key ] = $text;
63
- }
64
- }
65
- }
66
- }
67
-
68
- /**
69
- * Update the uption value
70
- */
71
- update_option( $option_key, $option );
72
- }
73
-
74
- add_option( 'fix_cookietypes_placeholder' );
75
- }
76
- }
77
- }
78
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/config/settings-config.php DELETED
@@ -1,331 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\config;
4
-
5
- use cookiebot_addons\lib\Settings_Service_Interface;
6
-
7
- class Settings_Config {
8
-
9
- /**
10
- * @var Settings_Service_Interface
11
- */
12
- protected $settings_service;
13
-
14
- /**
15
- * Settings_Config constructor.
16
- *
17
- * @param Settings_Service_Interface $settings_service
18
- *
19
- * @since 1.3.0
20
- */
21
- public function __construct( Settings_Service_Interface $settings_service ) {
22
- $this->settings_service = $settings_service;
23
- }
24
-
25
- /**
26
- * Load data for settings page
27
- *
28
- * @since 1.3.0
29
- */
30
- public function load() {
31
- add_action( 'admin_menu', array( $this, 'add_submenu' ) );
32
- add_action( 'admin_init', array( $this, 'register_settings' ) );
33
- add_action( 'admin_enqueue_scripts', array( $this, 'add_wp_admin_style_script' ) );
34
- add_action( 'update_option_cookiebot_available_addons', array(
35
- $this,
36
- 'post_hook_available_addons_update_option'
37
- ), 10, 3 );
38
- }
39
-
40
- /**
41
- * Registers submenu in options menu.
42
- *
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
- ) );
55
-
56
- }
57
-
58
- /**
59
- * Load css styling to the settings page
60
- *
61
- * @since 1.3.0
62
- */
63
- public function add_wp_admin_style_script( $hook ) {
64
- if ( $hook != 'cookiebot_page_cookiebot-addons' ) {
65
- return;
66
- }
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
-
74
- /**
75
- * Registers addons for settings page.
76
- *
77
- * @since 1.3.0
78
- */
79
- public function register_settings() {
80
- global $pagenow;
81
-
82
- if ( ( isset( $_GET['page'] ) && $_GET['page'] == 'cookiebot-addons' ) || $pagenow == 'options.php' ) {
83
- if ( isset( $_GET['tab'] ) && 'unavailable_addons' === $_GET['tab'] ) {
84
- $this->register_unavailable_addons();
85
- } elseif ( ( isset( $_GET['tab'] ) && 'jetpack' === $_GET['tab'] ) ) {
86
- $this->register_jetpack_addon();
87
- } else {
88
- $this->register_available_addons();
89
- }
90
-
91
- if ( $pagenow == 'options.php' ) {
92
- $this->register_jetpack_addon();
93
- }
94
- }
95
- }
96
-
97
- /**
98
- * Register available addons
99
- *
100
- * @since 1.3.0
101
- */
102
- private function register_available_addons() {
103
- add_settings_section( "available_addons", "Available plugins", array(
104
- $this,
105
- "header_available_addons"
106
- ), "cookiebot-addons" );
107
-
108
- foreach ( $this->settings_service->get_addons() as $addon ) {
109
- if ( $addon->is_addon_installed() && $addon->is_addon_activated() ) {
110
- add_settings_field(
111
- $addon->get_option_name(),
112
- $addon->get_addon_name() . $this->get_extra_information( $addon ),
113
- array(
114
- $this,
115
- "available_addon_callback"
116
- ),
117
- "cookiebot-addons",
118
- "available_addons",
119
- array(
120
- 'addon' => $addon
121
- )
122
- );
123
-
124
- register_setting( 'cookiebot_available_addons', "cookiebot_available_addons", array(
125
- $this,
126
- 'sanitize_cookiebot'
127
- ) );
128
- }
129
- }
130
- }
131
-
132
- /**
133
- * Register jetpack addon - new tab for jetpack specific settings
134
- *
135
- * @since 1.3.0
136
- */
137
- private function register_jetpack_addon() {
138
- add_settings_section( "jetpack_addon", "Jetpack", array(
139
- $this,
140
- "header_jetpack_addon"
141
- ), "cookiebot-addons" );
142
-
143
- foreach ( $this->settings_service->get_addons() as $addon ) {
144
- if ( 'Jetpack' === ( new \ReflectionClass( $addon ) )->getShortName() ) {
145
- if ( $addon->is_addon_installed() && $addon->is_addon_activated() ) {
146
-
147
- foreach ( $addon->get_widgets() as $widget ) {
148
- add_settings_field(
149
- $widget->get_widget_option_name(),
150
- $widget->get_label() . $this->get_extra_information( $widget ),
151
- array(
152
- $this,
153
- "jetpack_addon_callback"
154
- ),
155
- "cookiebot-addons",
156
- "jetpack_addon",
157
- array(
158
- 'widget' => $widget,
159
- 'addon' => $addon
160
- )
161
- );
162
-
163
- register_setting( 'cookiebot_jetpack_addon', 'cookiebot_jetpack_addon' );
164
- }
165
- }
166
- }
167
- }
168
- }
169
-
170
- /**
171
- * Registers unavailabe addons
172
- *
173
- * @since 1.3.0
174
- * @version 2.1.3
175
- */
176
- private function register_unavailable_addons() {
177
- add_settings_section( "unavailable_addons", "Unavailable plugins", array(
178
- $this,
179
- "header_unavailable_addons"
180
- ), "cookiebot-addons" );
181
-
182
- $addons = $this->settings_service->get_addons();
183
-
184
- foreach ( $addons as $addon ) {
185
- if ( ( ! $addon->is_addon_installed() || ! $addon->is_addon_activated() )
186
- && $this->settings_service->is_latest_plugin_version( $addon )
187
- && ! $this->settings_service->is_previous_version_active(
188
- $addons,
189
- get_class( $addon )
190
- )
191
- ) {
192
- // not installed plugins
193
- add_settings_field(
194
- $addon->get_addon_name(),
195
- $addon->get_addon_name() . $this->get_extra_information( $addon ),
196
- array(
197
- $this,
198
- "unavailable_addon_callback"
199
- ),
200
- "cookiebot-addons",
201
- "unavailable_addons",
202
- array( 'addon' => $addon )
203
- );
204
- register_setting( $addon->get_option_name(), "cookiebot_unavailable_addons" );
205
- }
206
- }
207
- }
208
-
209
- /**
210
- * Adds extra information under the label.
211
- *
212
- * @param $addon
213
- *
214
- * @return string
215
- */
216
- private function get_extra_information( $addon ) {
217
- return ( $addon->get_extra_information() !== false ) ? '<div class="extra_information">' . $addon->get_extra_information() . '</div>' : '';
218
- }
219
-
220
- /**
221
- * Jetpack tab - header
222
- *
223
- * @since 1.3.0
224
- */
225
- public function header_jetpack_addon() {
226
- echo '<p>' . esc_html__( 'Jetpack settings.', 'cookiebot' ) . '</p>';
227
- }
228
-
229
- /**
230
- * Jetpack tab - widget callback
231
- *
232
- * @param $args array Information about the widget addon and the option
233
- *
234
- * @since 1.3.0
235
- */
236
- public function jetpack_addon_callback( $args ) {
237
- include COOKIEBOT_ADDONS_DIR . 'view/admin/settings/jetpack-addon-callback.php';
238
- }
239
-
240
- /**
241
- * Returns header for installed plugins
242
- *
243
- * @since 1.3.0
244
- */
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
- }
256
-
257
- /**
258
- * Available addon callback:
259
- * - checkbox to enable
260
- * - select field for cookie type
261
- *
262
- * @param $args
263
- *
264
- * @since 1.3.0
265
- */
266
- public function available_addon_callback( $args ) {
267
- include COOKIEBOT_ADDONS_DIR . 'view/admin/settings/available-addon-callback.php';
268
- }
269
-
270
- /**
271
- * Returns header for unavailable plugins
272
- *
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
- /**
280
- * Unavailable addon callback
281
- *
282
- * @param $args
283
- *
284
- * @since 1.3.0
285
- */
286
- public function unavailable_addon_callback( $args ) {
287
- $addon = $args['addon'];
288
-
289
- ?>
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>
299
- <?php
300
- }
301
-
302
- /**
303
- * Build up settings page
304
- *
305
- * @param string $active_tab
306
- *
307
- * @since 1.3.0
308
- */
309
- public function setting_page( $active_tab = '' ) {
310
- include COOKIEBOT_ADDONS_DIR . 'view/admin/settings/setting-page.php';
311
- }
312
-
313
- /**
314
- * Post action hook after enabling the addon on the settings page.
315
- *
316
- * @param $old_value
317
- * @param $value
318
- * @param $option_name
319
- *
320
- * @since 2.2.0
321
- */
322
- public function post_hook_available_addons_update_option( $old_value, $value, $option_name ) {
323
- if ( is_array( $value ) ) {
324
- foreach ( $value as $addon_option_name => $addon_settings ) {
325
- if ( isset( $addon_settings['enabled'] ) ) {
326
- $this->settings_service->post_hook_after_enabling_addon_on_settings_page( $addon_option_name );
327
- }
328
- }
329
- }
330
- }
331
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/add-to-any/add-to-any.php DELETED
@@ -1,381 +0,0 @@
1
- <?php
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;
8
- use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
9
- use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
10
-
11
- class Add_To_Any 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(
52
- Settings_Service_Interface $settings,
53
- Script_Loader_Tag_Interface $script_loader_tag,
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
- /**
64
- * Loads addon configuration
65
- *
66
- * @since 1.3.0
67
- */
68
- public function load_configuration() {
69
- add_action( 'wp_loaded', array( $this, 'cookiebot_addon_add_to_any' ), 5 );
70
- }
71
-
72
- /**
73
- * Disable scripts if state not accepted
74
- *
75
- * @since 1.3.0
76
- */
77
- public function cookiebot_addon_add_to_any() {
78
-
79
- $this->buffer_output->add_tag( 'wp_head', 10, array(
80
- 'a2a_config' => $this->get_cookie_types(),
81
- ), false );
82
-
83
- $this->buffer_output->add_tag( 'wp_footer', 10, array(
84
- 'a2a_config' => $this->get_cookie_types(),
85
- ), false );
86
-
87
- $this->buffer_output->add_tag( 'pre_get_posts', 10, array(
88
- 'GoogleAnalyticsObject' => $this->get_cookie_types(),
89
- ), false );
90
-
91
- // External js, so manipulate attributes
92
- if ( has_action( 'wp_enqueue_scripts', 'A2A_SHARE_SAVE_enqueue_script' ) ) {
93
- // add-to-any plugin version < 1.8.2
94
- $this->script_loader_tag->add_tag( 'addtoany', $this->get_cookie_types() );
95
-
96
- // add-to-any-plugin version >= 1.8.2
97
- $this->script_loader_tag->add_tag( 'addtoany-core', $this->get_cookie_types() );
98
- $this->script_loader_tag->add_tag( 'addtoany-jquery', $this->get_cookie_types() );
99
- }
100
-
101
- add_filter( 'the_content', array(
102
- $this,
103
- 'cookiebot_addon_add_to_any_content',
104
- ), 1000 ); //Ensure it is executed as the last filter
105
-
106
- add_filter( 'the_excerpt', array(
107
- $this,
108
- 'cookiebot_addon_add_to_any_content',
109
- ), 1000 ); //Ensure it is executed as the last filter
110
- }
111
-
112
- /**
113
- * Display a placeholder on elements with "addtoany_share_save_container" class name.
114
- *
115
- * @param string $content
116
- *
117
- * @return string
118
- */
119
- public function cookiebot_addon_add_to_any_content( $content ) {
120
- if ( $this->has_placeholder() && $this->is_placeholder_enabled() ) {
121
- $pattern = '/(<div[^>]*class="[^"]*addtoany_share_save_container[^"]*"[^>]*>)/';
122
- $placeholder_text = $this->get_placeholder();
123
- $placeholder_class = cookiebot_addons_cookieconsent_optout( $this->get_cookie_types() );
124
- $placeholder = '<div class="' . $placeholder_class . '">' . $placeholder_text . '</div>';
125
- $content = preg_replace( $pattern, '$1' . $placeholder, $content );
126
- }
127
-
128
- return $content;
129
- }
130
-
131
- /**
132
- * Return addon/plugin name
133
- *
134
- * @return string
135
- *
136
- * @since 1.3.0
137
- */
138
- public function get_addon_name() {
139
- return 'addToAny Share Buttons';
140
- }
141
-
142
- /**
143
- * Default placeholder content
144
- *
145
- * @return string
146
- *
147
- * @since 1.8.0
148
- */
149
- public function get_default_placeholder() {
150
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to enable Social Share buttons.';
151
- }
152
-
153
- /**
154
- * Get placeholder content
155
- *
156
- * This function will check following features:
157
- * - Current language
158
- *
159
- * @param $src
160
- *
161
- * @return bool|mixed
162
- *
163
- * @since 1.8.0
164
- */
165
- public function get_placeholder( $src = '' ) {
166
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(),
167
- cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
168
- }
169
-
170
- /**
171
- * Option name in the database
172
- *
173
- * @return string
174
- *
175
- * @since 1.3.0
176
- */
177
- public function get_option_name() {
178
- return 'add_to_any';
179
- }
180
-
181
- /**
182
- * Plugin file name
183
- *
184
- * @return string
185
- *
186
- * @since 1.3.0
187
- */
188
- public function get_plugin_file() {
189
- return 'add-to-any/add-to-any.php';
190
- }
191
-
192
- /**
193
- * Returns checked cookie types
194
- * @return mixed
195
- *
196
- * @since 1.3.0
197
- */
198
- public function get_cookie_types() {
199
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
200
- }
201
-
202
- /**
203
- * Returns default cookie types
204
- * @return array
205
- *
206
- * @since 1.5.0
207
- */
208
- public function get_default_cookie_types() {
209
- return array( 'marketing', 'statistics' );
210
- }
211
-
212
- /**
213
- * Check if plugin is activated and checked in the backend
214
- *
215
- * @since 1.3.0
216
- */
217
- public function is_addon_enabled() {
218
- return $this->settings->is_addon_enabled( $this->get_option_name() );
219
- }
220
-
221
- /**
222
- * Checks if addon is installed
223
- *
224
- * @since 1.3.0
225
- */
226
- public function is_addon_installed() {
227
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
228
- }
229
-
230
- /**
231
- * Checks if addon is activated
232
- *
233
- * @since 1.3.0
234
- */
235
- public function is_addon_activated() {
236
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
237
- }
238
-
239
- /**
240
- * Retrieves current installed version of the addon
241
- *
242
- * @return bool
243
- *
244
- * @since 2.2.1
245
- */
246
- public function get_addon_version() {
247
- return $this->settings->get_addon_version( $this->get_plugin_file() );
248
- }
249
-
250
- /**
251
- * Checks if it does have custom placeholder content
252
- *
253
- * @return mixed
254
- *
255
- * @since 1.8.0
256
- */
257
- public function has_placeholder() {
258
- return $this->settings->has_placeholder( $this->get_option_name() );
259
- }
260
-
261
- /**
262
- * returns all placeholder contents
263
- *
264
- * @return mixed
265
- *
266
- * @since 1.8.0
267
- */
268
- public function get_placeholders() {
269
- return $this->settings->get_placeholders( $this->get_option_name() );
270
- }
271
-
272
- /**
273
- * Return true if the placeholder is enabled
274
- *
275
- * @return mixed
276
- *
277
- * @since 1.8.0
278
- */
279
- public function is_placeholder_enabled() {
280
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
281
- }
282
-
283
- /**
284
- * Adds extra information under the label
285
- *
286
- * @return string
287
- *
288
- * @since 1.8.0
289
- */
290
- public function get_extra_information() {
291
- return '<p>' . esc_html__( 'Blocks embedded videos from Youtube, Twitter, Vimeo and Facebook.',
292
- 'cookiebot-addons' ) . '</p>';
293
- }
294
-
295
- /**
296
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
297
- *
298
- * @return string
299
- *
300
- * @since 1.8.0
301
- */
302
- public function get_svn_url() {
303
- return 'http://plugins.svn.wordpress.org/add-to-any/trunk/add-to-any.php';
304
- }
305
-
306
- /**
307
- * Placeholder helper overlay in the settings page.
308
- *
309
- * @return string
310
- *
311
- * @since 1.8.0
312
- */
313
- public function get_placeholder_helper() {
314
- 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>';
315
- }
316
-
317
-
318
- /**
319
- * Returns parent class or false
320
- *
321
- * @return string|bool
322
- *
323
- * @since 2.1.3
324
- */
325
- public function get_parent_class() {
326
- return get_parent_class( $this );
327
- }
328
-
329
- /**
330
- * Action after enabling the addon on the settings page
331
- *
332
- * @since 2.2.0
333
- */
334
- public function post_hook_after_enabling() {
335
- //do nothing
336
- }
337
-
338
- /**
339
- * Cookiebot plugin is deactivated
340
- *
341
- * @since 2.2.0
342
- */
343
- public function plugin_deactivated() {
344
- //do nothing
345
- }
346
-
347
- /**
348
- * @return mixed
349
- *
350
- * @since 2.4.5
351
- */
352
- public function extra_available_addon_option() {
353
- //do nothing
354
- }
355
-
356
- /**
357
- * Returns boolean to enable/disable plugin by default
358
- *
359
- * @return bool
360
- *
361
- * @since 3.6.3
362
- */
363
- public function enable_by_default() {
364
- return false;
365
- }
366
-
367
- /**
368
- * Sets default settings for this addon
369
- *
370
- * @return array
371
- *
372
- * @since 3.6.3
373
- */
374
- public function get_default_enable_setting() {
375
- return array(
376
- 'enabled' => 1,
377
- 'cookie_type' => $this->get_default_cookie_types(),
378
- 'placeholder' => $this->get_default_placeholder(),
379
- );
380
- }
381
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/addthis/addthis.php DELETED
@@ -1,337 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\addthis;
4
-
5
- use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
6
- use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
7
- use cookiebot_addons\lib\Cookie_Consent_Interface;
8
- use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
9
- use cookiebot_addons\lib\Settings_Service_Interface;
10
-
11
- class Addthis 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
- /**
65
- * We add the action after wp_loaded and replace the original
66
- * Addthis script action with our own adjusted version.
67
- */
68
- add_action( 'wp_loaded', array( $this, 'cookiebot_addon_addthis' ), 10 );
69
- }
70
-
71
- /**
72
- * Manipulate the scripts if they are loaded.
73
- *
74
- * @since 1.3.0
75
- */
76
- public function cookiebot_addon_addthis() {
77
-
78
- // block the script untill the consent is given
79
- $this->script_loader_tag->add_tag( 'addthis_widget', $this->get_cookie_types() );
80
-
81
- $this->buffer_output->add_tag( 'wp_footer', 19, array(
82
- 'addthis_product' => $this->get_cookie_types(),
83
- ), false );
84
- $this->buffer_output->add_tag( 'wp_head', 19, array(
85
- 'addthis_product ' => $this->get_cookie_types(),
86
- ), false );
87
- }
88
-
89
- /**
90
- * Return addon/plugin name
91
- *
92
- * @return string
93
- *
94
- * @since 1.3.0
95
- */
96
- public function get_addon_name() {
97
- return 'WordPress Share Buttons Plugin – AddThis';
98
- }
99
-
100
- /**
101
- * Option name in the database
102
- *
103
- * @return string
104
- *
105
- * @since 1.3.0
106
- */
107
- public function get_option_name() {
108
- return 'addthis';
109
- }
110
-
111
- /**
112
- * Plugin file name
113
- *
114
- * @return string
115
- *
116
- * @since 1.3.0
117
- */
118
- public function get_plugin_file() {
119
- return 'addthis/addthis_social_widget.php';
120
- }
121
-
122
- /**
123
- * Returns checked cookie types
124
- * @return mixed
125
- *
126
- * @since 1.3.0
127
- */
128
- public function get_cookie_types() {
129
- return $this->settings->get_cookie_types( $this->get_option_name() );
130
- }
131
-
132
- /**
133
- * Returns default cookie types
134
- * @return array
135
- *
136
- * @since 1.5.0
137
- */
138
- public function get_default_cookie_types() {
139
- return array( 'marketing', 'statistics' );
140
- }
141
-
142
-
143
- /**
144
- * Check if plugin is activated and checked in the backend
145
- *
146
- * @since 1.3.0
147
- */
148
- public function is_addon_enabled() {
149
- return $this->settings->is_addon_enabled( $this->get_option_name() );
150
- }
151
-
152
- /**
153
- * Checks if addon is installed
154
- *
155
- * @since 1.3.0
156
- */
157
- public function is_addon_installed() {
158
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
159
- }
160
-
161
- /**
162
- * Checks if addon is activated
163
- *
164
- * @since 1.3.0
165
- */
166
- public function is_addon_activated() {
167
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
168
- }
169
-
170
- /**
171
- * Retrieves current installed version of the addon
172
- *
173
- * @return bool
174
- *
175
- * @since 2.2.1
176
- */
177
- public function get_addon_version() {
178
- return $this->settings->get_addon_version( $this->get_plugin_file() );
179
- }
180
-
181
- /**
182
- * Default placeholder content
183
- *
184
- * @return string
185
- *
186
- * @since 1.8.0
187
- */
188
- public function get_default_placeholder() {
189
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to view this element.';
190
- }
191
-
192
- /**
193
- * Get placeholder content
194
- *
195
- * This function will check following features:
196
- * - Current language
197
- *
198
- * @param $src
199
- *
200
- * @return bool|mixed
201
- *
202
- * @since 1.8.0
203
- */
204
- public function get_placeholder( $src = '' ) {
205
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
206
- }
207
-
208
- /**
209
- * Checks if it does have custom placeholder content
210
- *
211
- * @return mixed
212
- *
213
- * @since 1.8.0
214
- */
215
- public function has_placeholder() {
216
- return $this->settings->has_placeholder( $this->get_option_name() );
217
- }
218
-
219
- /**
220
- * returns all placeholder contents
221
- *
222
- * @return mixed
223
- *
224
- * @since 1.8.0
225
- */
226
- public function get_placeholders() {
227
- return $this->settings->get_placeholders( $this->get_option_name() );
228
- }
229
-
230
- /**
231
- * Return true if the placeholder is enabled
232
- *
233
- * @return mixed
234
- *
235
- * @since 1.8.0
236
- */
237
- public function is_placeholder_enabled() {
238
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
239
- }
240
-
241
- /**
242
- * Adds extra information under the label
243
- *
244
- * @return string
245
- *
246
- * @since 1.8.0
247
- */
248
- public function get_extra_information() {
249
- return false;
250
- }
251
-
252
- /**
253
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
254
- *
255
- * @return boolean
256
- *
257
- * @since 1.8.0
258
- */
259
- public function get_svn_url() {
260
- return 'https://plugins.svn.wordpress.org/addthis/trunk/addthis_social_widget.php';
261
- }
262
-
263
- /**
264
- * Placeholder helper overlay in the settings page.
265
- *
266
- * @return string
267
- *
268
- * @since 1.8.0
269
- */
270
- public function get_placeholder_helper() {
271
- 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>';
272
- }
273
-
274
- /**
275
- * Returns parent class or false
276
- *
277
- * @return string|bool
278
- *
279
- * @since 2.1.3
280
- */
281
- public function get_parent_class() {
282
- return get_parent_class( $this );
283
- }
284
-
285
- /**
286
- * Action after enabling the addon on the settings page
287
- *
288
- * @since 2.2.0
289
- */
290
- public function post_hook_after_enabling() {
291
- //do nothing
292
- }
293
-
294
- /**
295
- * Cookiebot plugin is deactivated
296
- *
297
- * @since 2.2.0
298
- */
299
- public function plugin_deactivated() {
300
- //do nothing
301
- }
302
-
303
- /**
304
- * @return mixed
305
- *
306
- * @since 2.4.5
307
- */
308
- public function extra_available_addon_option() {
309
- //do nothing
310
- }
311
-
312
- /**
313
- * Returns boolean to enable/disable plugin by default
314
- *
315
- * @return bool
316
- *
317
- * @since 3.6.3
318
- */
319
- public function enable_by_default() {
320
- return false;
321
- }
322
-
323
- /**
324
- * Sets default settings for this addon
325
- *
326
- * @return array
327
- *
328
- * @since 3.6.3
329
- */
330
- public function get_default_enable_setting() {
331
- return array(
332
- 'enabled' => 1,
333
- 'cookie_type' => $this->get_default_cookie_types(),
334
- 'placeholder' => $this->get_default_placeholder(),
335
- );
336
- }
337
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/caos-host-analyticsjs-local-save-ga-local/caos-host-analyticsjs-local-save-ga-local.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\caos_host_analyticsjs_local_save_ga_local;
4
-
5
- use cookiebot_addons\controller\addons\caos_host_analyticsjs_local\CAOS_Host_Analyticsjs_Local;
6
-
7
- /**
8
- * This is the older version of the plugin: CAOS_Host_Analyticsjs_Local
9
- * Supports till the version: 2.0.0
10
- *
11
- * Class CAOS_Host_Analyticsjs_Local_Save_Ga_Local
12
- * @package cookiebot_addons\controller\addons\caos_host_analyticsjs_local_save_ga_local
13
- */
14
- class CAOS_Host_Analyticsjs_Local_Save_Ga_Local extends CAOS_Host_Analyticsjs_Local {
15
-
16
- /**
17
- * plugin file name
18
- *
19
- * @return string
20
- *
21
- * @since 2.1.3
22
- */
23
- public function get_plugin_file() {
24
- return 'host-analyticsjs-local/save-ga-local.php';
25
- }
26
-
27
- /**
28
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
29
- *
30
- * @return string
31
- *
32
- * @since 2.1.3
33
- */
34
- public function get_svn_url() {
35
- return 'http://plugins.svn.wordpress.org/host-analyticsjs-local/trunk/save-ga-local.php';
36
- }
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/caos-host-analyticsjs-local/caos-host-analyticsjs-local.php DELETED
@@ -1,379 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\caos_host_analyticsjs_local;
4
-
5
- use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
6
- use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
7
- use cookiebot_addons\lib\Cookie_Consent_Interface;
8
- use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
9
- use cookiebot_addons\lib\Settings_Service_Interface;
10
-
11
- class CAOS_Host_Analyticsjs_Local 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
- * Complete Analytics Optimization Suite (CAOS) (Host Analyticsjs Local) 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(
52
- Settings_Service_Interface $settings,
53
- Script_Loader_Tag_Interface $script_loader_tag,
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
- /**
64
- * Loads addon configuration
65
- *
66
- * @since 1.3.0
67
- */
68
- public function load_configuration() {
69
- add_action( 'wp_loaded', array( $this, 'cookiebot_addon_host_analyticsjs_local' ), 5 );
70
- }
71
-
72
- /**
73
- * Check for Host Analyticsjs Local action hooks
74
- *
75
- * @since 1.3.0
76
- */
77
- public function cookiebot_addon_host_analyticsjs_local() {
78
-
79
- /* Priority need to be more than 0 so we are able to hook in before output begins */
80
- $scriptPriority = $this->cookiebot_addon_host_analyticsjs_local_priority();
81
- if ( $scriptPriority <= 0 ) {
82
- //Force priority to 2
83
- $scriptPriority = 2;
84
- update_option( 'sgal_enqueue_order', $scriptPriority );
85
- }
86
-
87
- /**
88
- * ga scripts are loaded in wp_footer priority is defined in option variable
89
- */
90
- if ( has_action( 'wp_footer', 'caos_analytics_render_tracking_code' ) ||
91
- has_action( 'wp_footer', 'caos_render_tracking_code' ) ||
92
- has_action( 'wp_footer', 'add_ga_header_script' ) ||
93
- ( defined( 'CAOS_OPT_SCRIPT_POSITION' ) && CAOS_OPT_SCRIPT_POSITION == 'footer' ) ) {
94
- /**
95
- * Consent not given - no cache
96
- */
97
- $this->buffer_output->add_tag( 'wp_footer', $scriptPriority, array(
98
- 'GoogleAnalyticsObject' => $this->get_cookie_types(),
99
- ), false );
100
- }
101
-
102
- /**
103
- * ga scripts are loaded in wp_head priority is defined in option variable
104
- */
105
- if ( has_action( 'wp_head', 'caos_analytics_render_tracking_code' ) ||
106
- has_action( 'wp_head', 'caos_render_tracking_code' ) ||
107
- has_action( 'wp_head', 'add_ga_header_script' ) ||
108
- ( defined( 'CAOS_OPT_SCRIPT_POSITION' ) && CAOS_OPT_SCRIPT_POSITION != 'footer' ) ) {
109
- /**
110
- * Consent not given - no cache
111
- */
112
- $this->buffer_output->add_tag( 'wp_head', $scriptPriority, array(
113
- 'GoogleAnalyticsObject' => $this->get_cookie_types(),
114
- ), false );
115
- }
116
- }
117
-
118
- /**
119
- * Get priority of script
120
- *
121
- * @return integer
122
- *
123
- * @since 1.3.0
124
- */
125
- public function cookiebot_addon_host_analyticsjs_local_priority() {
126
- return ( esc_attr( get_option( 'sgal_enqueue_order' ) ) ) ? esc_attr( get_option( 'sgal_enqueue_order' ) ) : 0;
127
- }
128
-
129
- /**
130
- * Return addon/plugin name
131
- *
132
- * @return string
133
- *
134
- * @since 1.3.0
135
- */
136
- public function get_addon_name() {
137
- return 'Complete Analytics Optimization Suite (CAOS)';
138
- }
139
-
140
- /**
141
- * Option name in the database
142
- *
143
- * @return string
144
- *
145
- * @since 1.3.0
146
- */
147
- public function get_option_name() {
148
- return 'caos_host_analyticsjs_local';
149
- }
150
-
151
- /**
152
- * plugin file name
153
- *
154
- * @return string
155
- *
156
- * @since 1.3.0
157
- * @version 2.1.3
158
- */
159
- public function get_plugin_file() {
160
- return 'host-analyticsjs-local/host-analyticsjs-local.php';
161
- }
162
-
163
- /**
164
- * Returns checked cookie types
165
- * @return array
166
- *
167
- * @since 1.3.0
168
- */
169
- public function get_cookie_types() {
170
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
171
- }
172
-
173
- /**
174
- * Returns default cookie types
175
- * @return array
176
- *
177
- * @since 1.5.0
178
- */
179
- public function get_default_cookie_types() {
180
- return array( 'statistics' );
181
- }
182
-
183
- /**
184
- * Check if plugin is activated and checked in the backend
185
- *
186
- * @since 1.3.0
187
- */
188
- public function is_addon_enabled() {
189
- return $this->settings->is_addon_enabled( $this->get_option_name() );
190
- }
191
-
192
- /**
193
- * Checks if addon is installed
194
- *
195
- * @since 1.3.0
196
- */
197
- public function is_addon_installed() {
198
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
199
- }
200
-
201
- /**
202
- * Checks if addon is activated
203
- *
204
- * @since 1.3.0
205
- */
206
- public function is_addon_activated() {
207
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
208
- }
209
-
210
- /**
211
- * Retrieves current installed version of the addon
212
- *
213
- * @return bool
214
- *
215
- * @since 2.2.1
216
- */
217
- public function get_addon_version() {
218
- return $this->settings->get_addon_version( $this->get_plugin_file() );
219
- }
220
-
221
- /**
222
- * Default placeholder content
223
- *
224
- * @return string
225
- *
226
- * @since 1.8.0
227
- */
228
- public function get_default_placeholder() {
229
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to enable tracking.';
230
- }
231
-
232
- /**
233
- * Get placeholder content
234
- *
235
- * This function will check following features:
236
- * - Current language
237
- *
238
- * @param $src
239
- *
240
- * @return bool|mixed
241
- *
242
- * @since 1.8.0
243
- */
244
- public function get_placeholder( $src = '' ) {
245
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(),
246
- cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
247
- }
248
-
249
- /**
250
- * Checks if it does have custom placeholder content
251
- *
252
- * @return mixed
253
- *
254
- * @since 1.8.0
255
- */
256
- public function has_placeholder() {
257
- return $this->settings->has_placeholder( $this->get_option_name() );
258
- }
259
-
260
- /**
261
- * returns all placeholder contents
262
- *
263
- * @return mixed
264
- *
265
- * @since 1.8.0
266
- */
267
- public function get_placeholders() {
268
- return $this->settings->get_placeholders( $this->get_option_name() );
269
- }
270
-
271
- /**
272
- * Return true if the placeholder is enabled
273
- *
274
- * @return mixed
275
- *
276
- * @since 1.8.0
277
- */
278
- public function is_placeholder_enabled() {
279
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
280
- }
281
-
282
- /**
283
- * Adds extra information under the label
284
- *
285
- * @return string
286
- *
287
- * @since 1.8.0
288
- */
289
- public function get_extra_information() {
290
- return false;
291
- }
292
-
293
- /**
294
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
295
- *
296
- * @return string
297
- *
298
- * @since 1.8.0
299
- * @version 2.1.3
300
- */
301
- public function get_svn_url() {
302
- return 'http://plugins.svn.wordpress.org/host-analyticsjs-local/trunk/host-analyticsjs-local.php';
303
- }
304
-
305
- /**
306
- * Placeholder helper overlay in the settings page.
307
- *
308
- * @return string
309
- *
310
- * @since 1.8.0
311
- */
312
- public function get_placeholder_helper() {
313
- 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>';
314
- }
315
-
316
- /**
317
- * Returns parent class or false
318
- *
319
- * @return string|bool
320
- *
321
- * @since 2.1.3
322
- */
323
- public function get_parent_class() {
324
- return get_parent_class( $this );
325
- }
326
-
327
- /**
328
- * Action after enabling the addon on the settings page
329
- *
330
- * @since 2.2.0
331
- */
332
- public function post_hook_after_enabling() {
333
- //do nothing
334
- }
335
-
336
- /**
337
- * Cookiebot plugin is deactivated
338
- *
339
- * @since 2.2.0
340
- */
341
- public function plugin_deactivated() {
342
- //do nothing
343
- }
344
-
345
- /**
346
- * @return mixed
347
- *
348
- * @since 2.4.5
349
- */
350
- public function extra_available_addon_option() {
351
- //do nothing
352
- }
353
-
354
- /**
355
- * Returns boolean to enable/disable plugin by default
356
- *
357
- * @return bool
358
- *
359
- * @since 3.6.3
360
- */
361
- public function enable_by_default() {
362
- return false;
363
- }
364
-
365
- /**
366
- * Sets default settings for this addon
367
- *
368
- * @return array
369
- *
370
- * @since 3.6.3
371
- */
372
- public function get_default_enable_setting() {
373
- return array(
374
- 'enabled' => 1,
375
- 'cookie_type' => $this->get_default_cookie_types(),
376
- 'placeholder' => $this->get_default_placeholder(),
377
- );
378
- }
379
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/cookiebot-addons-interface.php DELETED
@@ -1,217 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons;
4
-
5
- use cookiebot_addons\lib\buffer\Buffer_Output_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
-
10
- Interface Cookiebot_Addons_Interface {
11
-
12
- /**
13
- * Cookiebot_Addons_Interface constructor.
14
- *
15
- * @param Settings_Service_Interface $settings
16
- * @param Script_Loader_Tag_Interface $script_loader_tag
17
- * @param Cookie_Consent_Interface $cookie_consent
18
- * @param Buffer_Output_Interface $buffer_output
19
- */
20
- public function __construct( Settings_Service_Interface $settings, Script_Loader_Tag_Interface $script_loader_tag, Cookie_Consent_Interface $cookie_consent, Buffer_Output_Interface $buffer_output );
21
-
22
- /**
23
- * Loads addon configuration
24
- *
25
- * @since 1.3.0
26
- */
27
- public function load_configuration();
28
-
29
- /**
30
- * Return addon/plugin name
31
- *
32
- * @return string
33
- *
34
- * @since 1.3.0
35
- */
36
- public function get_addon_name();
37
-
38
- /**
39
- * Default placeholder content
40
- *
41
- * @return string
42
- *
43
- * @since 1.8.0
44
- */
45
- public function get_default_placeholder();
46
-
47
- /**
48
- * Get placeholder content
49
- *
50
- * This function will check following features:
51
- * - Current language
52
- *
53
- * @param $src string
54
- *
55
- * @return bool|mixed
56
- *
57
- * @since 1.8.0
58
- */
59
- public function get_placeholder( $src = '' );
60
-
61
- /**
62
- * Option name in the database
63
- *
64
- * @return string
65
- *
66
- * @since 1.3.0
67
- */
68
- public function get_option_name();
69
-
70
- /**
71
- * Plugin file name
72
- *
73
- * @return string
74
- *
75
- * @since 1.3.0
76
- */
77
- public function get_plugin_file();
78
-
79
- /**
80
- * Returns checked cookie types
81
- * @return mixed
82
- *
83
- * @since 1.3.0
84
- */
85
- public function get_cookie_types();
86
-
87
- /**
88
- * Returns default cookie types
89
- * @return mixed
90
- *
91
- * @since 1.3.0
92
- */
93
- public function get_default_cookie_types();
94
-
95
- /**
96
- * Check if plugin is activated and checked in the backend
97
- *
98
- * @since 1.3.0
99
- */
100
- public function is_addon_enabled();
101
-
102
- /**
103
- * Checks if addon is installed
104
- *
105
- * @since 1.3.0
106
- */
107
- public function is_addon_installed();
108
-
109
- /**
110
- * Checks if addon is activated
111
- *
112
- * @since 1.3.0
113
- */
114
- public function is_addon_activated();
115
-
116
- /**
117
- * Retrieves current installed version of the addon
118
- *
119
- * @return bool
120
- *
121
- * @since 2.2.1
122
- */
123
- public function get_addon_version();
124
-
125
- /**
126
- * Checks if it does have custom placeholder content
127
- *
128
- * @return mixed
129
- *
130
- * @since 1.8.0
131
- */
132
- public function has_placeholder();
133
-
134
- /**
135
- * returns all placeholder contents
136
- *
137
- * @return mixed
138
- *
139
- * @since 1.8.0
140
- */
141
- public function get_placeholders();
142
-
143
- /**
144
- * Return true if the placeholder is enabled
145
- *
146
- * @return mixed
147
- *
148
- * @since 1.8.0
149
- */
150
- public function is_placeholder_enabled();
151
-
152
- /**
153
- * Adds extra information under the label
154
- *
155
- * @return string
156
- *
157
- * @since 1.8.0
158
- */
159
- public function get_extra_information();
160
-
161
- /**
162
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
163
- *
164
- * @return boolean
165
- *
166
- * @since 1.8.0
167
- */
168
- public function get_svn_url();
169
-
170
- /**
171
- * Placeholder helper overlay in the settings page.
172
- *
173
- * @return string
174
- *
175
- * @since 1.8.0
176
- */
177
- public function get_placeholder_helper();
178
-
179
- /**
180
- * Action after enabling the addon on the settings page
181
- *
182
- * @since 2.2.0
183
- */
184
- public function post_hook_after_enabling();
185
-
186
- /**
187
- * Cookiebot plugin is deactivated
188
- *
189
- * @since 2.2.0
190
- */
191
- public function plugin_deactivated();
192
-
193
- /**
194
- * @return mixed
195
- *
196
- * @since 2.4.5
197
- */
198
- public function extra_available_addon_option();
199
-
200
- /**
201
- * Returns boolean to enable/disable plugin by default
202
- *
203
- * @return bool
204
- *
205
- * @since 3.6.3
206
- */
207
- public function enable_by_default();
208
-
209
- /**
210
- * Sets default settings for this addon
211
- *
212
- * @return array
213
- *
214
- * @since 3.6.3
215
- */
216
- public function get_default_enable_setting();
217
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/custom-facebook-feed-old/custom-facebook-feed-old.php DELETED
@@ -1,347 +0,0 @@
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-pro/custom-facebook-feed-pro.php DELETED
@@ -1,342 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\custom_facebook_feed_pro;
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_Pro implements Cookiebot_Addons_Interface {
12
-
13
- /**
14
- * @var Settings_Service_Interface
15
- *
16
- * @since 2.1.4
17
- */
18
- protected $settings;
19
-
20
- /**
21
- * @var Script_Loader_Tag_Interface
22
- *
23
- * @since 2.1.4
24
- */
25
- protected $script_loader_tag;
26
-
27
- /**
28
- * @var Cookie_Consent_Interface
29
- *
30
- * @since 2.1.4
31
- */
32
- public $cookie_consent;
33
-
34
- /**
35
- * @var Buffer_Output_Interface
36
- *
37
- * @since 2.1.4
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 2.1.4
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 2.1.4
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 2.1.4
75
- */
76
- public function cookiebot_addon_custom_facebook_feed() {
77
-
78
- //Remove cff_js action and replace it with our own
79
- if ( has_action( 'wp_footer', 'cff_js' ) ) {
80
- /**
81
- * Consent not given - no cache
82
- */
83
- $this->buffer_output->add_tag( 'wp_footer', 10, array( 'cfflinkhashtags' => $this->get_cookie_types() ), false );
84
- }
85
-
86
- // External js, so manipulate attributes
87
- if ( has_action( 'wp_enqueue_scripts', 'cff_scripts_method' ) ) {
88
- /**
89
- * Consent not given - no cache
90
- */
91
- $this->script_loader_tag->add_tag( 'cffscripts', $this->get_cookie_types(), false );
92
- }
93
- }
94
-
95
- /**
96
- * Return addon/plugin name
97
- *
98
- * @return string
99
- *
100
- * @since 2.1.4
101
- */
102
- public function get_addon_name() {
103
- return 'Custom Facebook Feed Pro';
104
- }
105
-
106
- /**
107
- * Option name in the database
108
- *
109
- * @return string
110
- *
111
- * @since 2.1.4
112
- */
113
- public function get_option_name() {
114
- return 'custom_facebook_feed_pro';
115
- }
116
-
117
- /**
118
- * Plugin file name
119
- *
120
- * @return string
121
- *
122
- * @since 2.1.4
123
- */
124
- public function get_plugin_file() {
125
- return 'custom-facebook-feed-pro/custom-facebook-feed.php';
126
- }
127
-
128
- /**
129
- * Returns checked cookie types
130
- * @return mixed
131
- *
132
- * @since 2.1.4
133
- */
134
- public function get_cookie_types() {
135
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
136
- }
137
-
138
- /**
139
- * Returns default cookie types
140
- * @return array
141
- *
142
- * @since 1.5.0
143
- */
144
- public function get_default_cookie_types() {
145
- return array( 'marketing' );
146
- }
147
-
148
- /**
149
- * Check if plugin is activated and checked in the backend
150
- *
151
- * @since 2.1.4
152
- */
153
- public function is_addon_enabled() {
154
- return $this->settings->is_addon_enabled( $this->get_option_name() );
155
- }
156
-
157
- /**
158
- * Checks if addon is installed
159
- *
160
- * @since 2.1.4
161
- */
162
- public function is_addon_installed() {
163
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
164
- }
165
-
166
- /**
167
- * Checks if addon is activated
168
- *
169
- * @since 2.1.4
170
- */
171
- public function is_addon_activated() {
172
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
173
- }
174
-
175
- /**
176
- * Retrieves current installed version of the addon
177
- *
178
- * @return bool
179
- *
180
- * @since 2.2.1
181
- */
182
- public function get_addon_version() {
183
- return $this->settings->get_addon_version( $this->get_plugin_file() );
184
- }
185
-
186
- /**
187
- * Default placeholder content
188
- *
189
- * @return string
190
- *
191
- * @since 2.1.4
192
- */
193
- public function get_default_placeholder() {
194
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
195
- }
196
-
197
- /**
198
- * Get placeholder content
199
- *
200
- * This function will check following features:
201
- * - Current language
202
- *
203
- * @param $src
204
- *
205
- * @return bool|mixed
206
- *
207
- * @since 2.1.4
208
- */
209
- public function get_placeholder( $src = '' ) {
210
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
211
- }
212
-
213
- /**
214
- * Checks if it does have custom placeholder content
215
- *
216
- * @return mixed
217
- *
218
- * @since 2.1.4
219
- */
220
- public function has_placeholder() {
221
- return $this->settings->has_placeholder( $this->get_option_name() );
222
- }
223
-
224
- /**
225
- * returns all placeholder contents
226
- *
227
- * @return mixed
228
- *
229
- * @since 2.1.4
230
- */
231
- public function get_placeholders() {
232
- return $this->settings->get_placeholders( $this->get_option_name() );
233
- }
234
-
235
- /**
236
- * Return true if the placeholder is enabled
237
- *
238
- * @return mixed
239
- *
240
- * @since 2.1.4
241
- */
242
- public function is_placeholder_enabled() {
243
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
244
- }
245
-
246
- /**
247
- * Adds extra information under the label
248
- *
249
- * @return string
250
- *
251
- * @since 2.1.4
252
- */
253
- public function get_extra_information() {
254
- return false;
255
- }
256
-
257
- /**
258
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
259
- *
260
- * @return string
261
- *
262
- * @since 2.1.4
263
- */
264
- public function get_svn_url() {
265
- return false;
266
- }
267
-
268
- /**
269
- * Placeholder helper overlay in the settings page.
270
- *
271
- * @return string
272
- *
273
- * @since 2.1.4
274
- */
275
- public function get_placeholder_helper() {
276
- 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>';
277
- }
278
-
279
- /**
280
- * Returns parent class or false
281
- *
282
- * @return string|bool
283
- *
284
- * @since 2.1.4
285
- */
286
- public function get_parent_class() {
287
- return get_parent_class( $this );
288
- }
289
-
290
- /**
291
- * Action after enabling the addon on the settings page
292
- *
293
- * @since 2.2.0
294
- */
295
- public function post_hook_after_enabling() {
296
- //do nothing
297
- }
298
-
299
- /**
300
- * Cookiebot plugin is deactivated
301
- *
302
- * @since 2.2.0
303
- */
304
- public function plugin_deactivated() {
305
- //do nothing
306
- }
307
-
308
- /**
309
- * @return mixed
310
- *
311
- * @since 2.4.5
312
- */
313
- public function extra_available_addon_option() {
314
- //do nothing
315
- }
316
-
317
- /**
318
- * Returns boolean to enable/disable plugin by default
319
- *
320
- * @return bool
321
- *
322
- * @since 3.6.3
323
- */
324
- public function enable_by_default() {
325
- return false;
326
- }
327
-
328
- /**
329
- * Sets default settings for this addon
330
- *
331
- * @return array
332
- *
333
- * @since 3.6.3
334
- */
335
- public function get_default_enable_setting() {
336
- return array(
337
- 'enabled' => 1,
338
- 'cookie_type' => $this->get_default_cookie_types(),
339
- 'placeholder' => $this->get_default_placeholder(),
340
- );
341
- }
342
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/custom-facebook-feed/custom-facebook-feed.php DELETED
@@ -1,78 +0,0 @@
1
- <?php
2
-
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
16
- *
17
- * @return string
18
- *
19
- * @since 1.3.0
20
- */
21
- public function get_addon_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
- /**
41
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
42
- *
43
- * @return string
44
- *
45
- * @since 1.8.0
46
- */
47
- public function get_svn_url() {
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 DELETED
@@ -1,798 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\embed_autocorrect;
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 Embed_Autocorrect 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(
52
- Settings_Service_Interface $settings,
53
- Script_Loader_Tag_Interface $script_loader_tag,
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
- /**
64
- * Loads addon configuration
65
- *
66
- * @since 1.3.0
67
- */
68
- public function load_configuration() {
69
- /**
70
- * We add the action after wp_loaded and replace the original GA Google
71
- * Analytics action with our own adjusted version.
72
- */
73
- add_action( 'wp_loaded', array( $this, 'cookiebot_addon_embed_autocorrect' ) );
74
- }
75
-
76
- /**
77
- * Check for embed autocorrect action hooks
78
- *
79
- * @since 1.3.0
80
- */
81
- public function cookiebot_addon_embed_autocorrect() {
82
-
83
- //add filters to handle autocorrection in content
84
- add_filter(
85
- 'the_content',
86
- array(
87
- $this,
88
- 'cookiebot_addon_embed_autocorrect_content',
89
- ),
90
- 1000
91
- ); //Ensure it is executed as the last filter
92
-
93
- //add filters to handle autocorrection in widget text
94
- add_filter(
95
- 'widget_text',
96
- array(
97
- $this,
98
- 'cookiebot_addon_embed_autocorrect_content',
99
- ),
100
- 1000
101
- ); //Ensure it is executed as the last filter
102
-
103
- //add fitler to handle video shortcodes
104
- add_filter(
105
- 'wp_video_shortcode',
106
- array(
107
- $this,
108
- 'cookiebot_addon_embed_autocorrect_handle_video',
109
- ),
110
- 1000
111
- );
112
-
113
- //add fitler to handle audio shortcodes
114
- add_filter(
115
- 'wp_audio_shortcode',
116
- array(
117
- $this,
118
- 'cookiebot_addon_embed_autocorrect_handle_audio',
119
- ),
120
- 1000
121
- );
122
-
123
- add_action(
124
- 'wp_head',
125
- array(
126
- $this,
127
- 'cookiebot_addon_embed_autocorrect_javascript',
128
- )
129
- );
130
- }
131
-
132
- /**
133
- * Add javascript to handle videos as loaded
134
- *
135
- * @since 1.1.0
136
- */
137
- public function cookiebot_addon_embed_autocorrect_javascript() {
138
- $library = apply_filters( 'wp_video_shortcode_library', 'mediaelement' );
139
- if ( $library === 'mediaelement' ) {
140
- ?>
141
- <style type="text/css">video.wp-video-shortcode__disabled, audio.wp-audio-shortcode__disabled {
142
- display: none;
143
- }</style>
144
- <script>
145
- window.addEventListener( 'CookiebotOnTagsExecuted', function ( e ) {
146
- <?php $cookie_types = implode( ',', $this->get_cookie_types() ); ?>
147
- const cookieTypes = '<?php echo esc_js( $cookie_types ); ?>'
148
- if ( cookieTypes.split(',').every( (cookie_type) => Cookiebot.consent[cookie_type] ) ) {
149
- jQuery( '.wp-video-shortcode__disabled' ).addClass( 'wp-video-shortcode' ).removeClass( 'wp-video-shortcode__disabled' );
150
- jQuery( '.wp-audio-shortcode__disabled' ).addClass( 'wp-audio-shortcode' ).removeClass( 'wp-audio-shortcode__disabled' );
151
- if ( window.wp && window.wp.mediaelement && window.wp.mediaelement.initialize ) {
152
- window.wp.mediaelement.initialize();
153
- }
154
- }
155
- }, false );
156
- </script>
157
- <?php
158
- }
159
- }
160
-
161
-
162
- /**
163
- * Autocorrection of Vimeo and Youtube tags to make them GDPR compatible
164
- *
165
- * @since 1.1.0
166
- */
167
- public function cookiebot_addon_embed_autocorrect_content( $content ) {
168
- //Make sure Cookiebot is active and the user has enabled autocorrection
169
-
170
- preg_match_all( '|<div[^>]*id=\"fb-root\">.*?</blockquote>|si', $content, $matches );
171
- foreach ( $matches[0] as $match ) {
172
- //Find src.
173
- preg_match( '|<a href=\"([^\"]*)\">([^<]*)</a></p></blockquote>|', $match, $matchSrc );
174
- $src = $matchSrc[1];
175
-
176
- //Replace - and add cookie consent notice.
177
- $adjusted = str_replace(
178
- '<script>',
179
- '<script type="text/plain" data-cookieconsent="' . cookiebot_addons_output_cookie_types( $this->get_cookie_types() ) . '">',
180
- $match
181
- );
182
-
183
- /**
184
- * Generate placeholder
185
- */
186
- $placeholder = $this->generate_placeholder_with_src(
187
- apply_filters(
188
- 'cookiebot_addons_embed_source',
189
- $src
190
- )
191
- );
192
-
193
- /**
194
- * Modify placeholder by Filter
195
- *
196
- * @param $placeholder string Current placeholder text
197
- * @param $src string Source attribute from the embedded video
198
- * @param $this array Array of required cookie types
199
- */
200
- $placeholder = apply_filters(
201
- 'cookiebot_addons_embed_placeholder',
202
- $placeholder,
203
- $src,
204
- $this->get_cookie_types()
205
- );
206
-
207
- $adjusted .= $placeholder;
208
- $content = str_replace( $match, $adjusted, $content );
209
-
210
- }
211
- unset( $matches );
212
-
213
- preg_match_all( '|<blockquote[^>]*class=\"twitter-tweet\"[^>]*>.*?</script>|si', $content, $matches );
214
- foreach ( $matches[0] as $match ) {
215
- //Find src.
216
- preg_match( '|<a href=\"([^\"]*)\">([^<]*)</a></blockquote>|', $match, $matchSrc );
217
-
218
- if ( empty( $matchSrc ) ) {
219
- continue;
220
- }
221
-
222
- $src = $matchSrc[1];
223
-
224
- //Replace - and add cookie consent notice.
225
- $adjusted = str_replace(
226
- '<script ',
227
- '<script type="text/plain" data-cookieconsent="' . cookiebot_addons_output_cookie_types( $this->get_cookie_types() ) . '" ',
228
- $match
229
- );
230
-
231
- /**
232
- * Generate placeholder
233
- */
234
- $placeholder = $this->generate_placeholder_with_src(
235
- apply_filters(
236
- 'cookiebot_addons_embed_source',
237
- $src
238
- )
239
- );
240
-
241
- /**
242
- * Modify placeholder by Filter
243
- *
244
- * @param $placeholder string Current placeholder text
245
- * @param $src string Source attribute from the embedded video
246
- * @param $this array Array of required cookie types
247
- */
248
- $placeholder = apply_filters(
249
- 'cookiebot_addons_embed_placeholder',
250
- $placeholder,
251
- $src,
252
- $this->get_cookie_types()
253
- );
254
-
255
- $adjusted .= $placeholder;
256
- $content = str_replace( $match, $adjusted, $content );
257
-
258
- }
259
- unset( $matches );
260
-
261
- //Match all speakerdeck, slideshare, screencast, reverbnation, mixcloud, kickstarter,
262
- // dailymoition, collegehumor, cloudup, animoto, videopress, youtube, vimeo and facebook iframes.
263
- preg_match_all(
264
- $this->get_regex(),
265
- $content,
266
- $matches
267
- );
268
-
269
- foreach ( $matches[0] as $x => $match ) {
270
- /** Get the source attribute value */
271
- $start = strpos( $match, ' src=' ) + 6;
272
- $end = strpos( $match, $matches[1][ $x ], $start );
273
- $src = substr( $match, $start, $end - $start );
274
-
275
- /** Skip the matched iframe if the data-cookieconsent attribute exists */
276
- if ( strpos( $match, 'data-cookieconsent' ) !== false ) {
277
- continue;
278
- }
279
-
280
- /** Replace - and add cookie consent notice. */
281
- $adjusted = str_replace(
282
- ' src=',
283
- ' data-cookieconsent="' . cookiebot_addons_output_cookie_types( $this->get_cookie_types() ) . '" data-src=',
284
- $match
285
- );
286
-
287
- /** Generate placeholder */
288
- $placeholder = $this->generate_placeholder_with_src(
289
- apply_filters(
290
- 'cookiebot_addons_embed_source',
291
- $src
292
- )
293
- );
294
-
295
- /**
296
- * Modify placeholder by Filter
297
- *
298
- * @param $placeholder string Current placeholder text
299
- * @param $src string Source attribute from the embedded video
300
- * @param $this array Array of required cookie types
301
- */
302
- $placeholder = apply_filters(
303
- 'cookiebot_addons_embed_placeholder',
304
- $placeholder,
305
- $src,
306
- $this->get_cookie_types()
307
- );
308
-
309
- $adjusted .= $placeholder;
310
- $content = str_replace( $match, $adjusted, $content );
311
- }
312
-
313
- unset( $matches );
314
- preg_match_all(
315
- '/<script.*(instagram|twitter|issuu|imgur|redditmedia\.com|tiktok\.com|polldaddy|tumblr)+.*<\/script>/mi',
316
- $content,
317
- $matches
318
- );
319
- foreach ( $matches[0] as $x => $match ) {
320
- //Replace - and add cookie consent notice.
321
- $adjusted = str_replace(
322
- ' src=',
323
- ' data-cookieconsent="' . cookiebot_addons_output_cookie_types( $this->get_cookie_types() ) . '" data-src=',
324
- $match
325
- );
326
- /**
327
- * Generate placeholder
328
- */
329
- $placeholder = $this->generate_placeholder_with_src(
330
- apply_filters(
331
- 'cookiebot_addons_embed_source',
332
- $src
333
- )
334
- );
335
- /**
336
- * Modify placeholder by Filter
337
- *
338
- * @param $placeholder string Current placeholder text
339
- * @param $src string Source attribute from the embedded video
340
- * @param $this array Array of required cookie types
341
- */
342
- $placeholder = apply_filters(
343
- 'cookiebot_addons_embed_placeholder',
344
- $placeholder,
345
- $src,
346
- $this->get_cookie_types()
347
- );
348
- $adjusted .= $placeholder;
349
- $content = str_replace( $match, $adjusted, $content );
350
- }
351
- unset( $matches );
352
-
353
- return $content;
354
- }
355
-
356
- /**
357
- * Implementation of filter wp_video_shortcode - fixing code for cookiebot.
358
- */
359
- public function cookiebot_addon_embed_autocorrect_handle_video(
360
- $output,
361
- $atts = array(),
362
- $video = '',
363
- $post_id = null,
364
- $library = ''
365
- ) {
366
- /* Find src in markup */
367
- preg_match( '| src=\"([^\"]*)\"|', $output, $match );
368
- $src = $match[1];
369
-
370
- // allow same domain embeds without cookieconsent
371
- $src_domain = cookiebot_addons_get_domain_from_url( $src );
372
- if ( cookiebot_addons_get_home_url_domain() === $src_domain ) {
373
- return $output;
374
- }
375
-
376
- /**
377
- * Generate placeholder
378
- */
379
- $placeholder = $this->generate_placeholder_with_src( apply_filters( 'cookiebot_addons_embed_source', $src ) );
380
- $placeholder = apply_filters(
381
- 'cookiebot_addons_embed_placeholder',
382
- $placeholder,
383
- $src,
384
- $this->get_cookie_types()
385
- );
386
-
387
- $output = str_replace( 'wp-video-shortcode', 'wp-video-shortcode__disabled', $output );
388
- $output = str_replace(
389
- ' src=',
390
- ' data-cookieconsent="' . cookiebot_addons_output_cookie_types( $this->get_cookie_types() ) . '" data-src=',
391
- $output
392
- );
393
- $output .= $placeholder;
394
-
395
- return $output;
396
- }
397
-
398
- /**
399
- * Implementation of filter wp_audio_shortcode - fixing code for cookiebot.
400
- */
401
- public function cookiebot_addon_embed_autocorrect_handle_audio(
402
- $output,
403
- $atts = array(),
404
- $video = '',
405
- $post_id = null,
406
- $library = ''
407
- ) {
408
- /* Find src in markup */
409
- preg_match( '| src=\"([^\"]*)\"|', $output, $match );
410
- $src = $match[1];
411
-
412
- /**
413
- * Generate placeholder
414
- */
415
- $placeholder = $this->generate_placeholder_with_src( apply_filters( 'cookiebot_addons_embed_source', $src ) );
416
- $placeholder = apply_filters(
417
- 'cookiebot_addons_embed_placeholder',
418
- $placeholder,
419
- $src,
420
- $this->get_cookie_types()
421
- );
422
-
423
- $output = str_replace( 'wp-audio-shortcode', 'wp-audio-shortcode__disabled', $output );
424
- $output = str_replace(
425
- ' src=',
426
- ' data-cookieconsent="' . cookiebot_addons_output_cookie_types( $this->get_cookie_types() ) . '" data-src=',
427
- $output
428
- );
429
- $output .= $placeholder;
430
-
431
- return $output;
432
- }
433
-
434
- /**
435
- * Generates placeholder for given source
436
- *
437
- * @param $src
438
- *
439
- * @return string
440
- */
441
- public function generate_placeholder_with_src( $src = '' ) {
442
- $cookieContentNotice = '<div class="' . cookiebot_addons_cookieconsent_optout( $this->get_cookie_types() ) . '">';
443
- $cookieContentNotice .= $this->get_placeholder( $src );
444
- $cookieContentNotice .= '</div>';
445
-
446
- return $cookieContentNotice;
447
- }
448
-
449
- /**
450
- * Return addon/plugin name
451
- *
452
- * @return string
453
- *
454
- * @since 1.3.0
455
- */
456
- public function get_addon_name() {
457
- return 'Embed autocorrect';
458
- }
459
-
460
- /**
461
- * Option name in the database
462
- *
463
- * @return string
464
- *
465
- * @since 1.3.0
466
- */
467
- public function get_option_name() {
468
- return 'embed_autocorrect';
469
- }
470
-
471
- /**
472
- * Plugin file path
473
- *
474
- * @return string
475
- *
476
- * @since 1.3.0
477
- */
478
- public function get_plugin_file() {
479
- return false;
480
- }
481
-
482
- /**
483
- * Returns checked cookie types
484
- * @return mixed
485
- *
486
- * @since 1.3.0
487
- */
488
- public function get_cookie_types() {
489
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
490
- }
491
-
492
- /**
493
- * Returns default cookie types
494
- * @return array
495
- *
496
- * @since 1.5.0
497
- */
498
- public function get_default_cookie_types() {
499
- return array( 'marketing', 'statistics' );
500
- }
501
-
502
- /**
503
- * Check if plugin is activated and checked in the backend
504
- *
505
- * @since 1.3.0
506
- */
507
- public function is_addon_enabled() {
508
- return $this->settings->is_addon_enabled( $this->get_option_name() );
509
- }
510
-
511
- /**
512
- * Checks if addon is installed
513
- *
514
- * @since 1.3.0
515
- */
516
- public function is_addon_installed() {
517
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
518
- }
519
-
520
- /**
521
- * Checks if addon is activated
522
- *
523
- * @since 1.3.0
524
- */
525
- public function is_addon_activated() {
526
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
527
- }
528
-
529
- /**
530
- * Retrieves current installed version of the addon
531
- *
532
- * @return bool
533
- *
534
- * @since 2.2.1
535
- */
536
- public function get_addon_version() {
537
- return false;
538
- }
539
-
540
- /**
541
- * Default placeholder content
542
- *
543
- * @return string
544
- *
545
- * @since 1.8.0
546
- */
547
- public function get_default_placeholder() {
548
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
549
- }
550
-
551
- /**
552
- * Get placeholder content
553
- *
554
- * This function will check following features:
555
- * - Current language
556
- *
557
- * @param $src
558
- *
559
- * @return bool|mixed
560
- *
561
- * @since 1.8.0
562
- */
563
- public function get_placeholder( $src = '' ) {
564
- return $this->settings->get_placeholder(
565
- $this->get_option_name(),
566
- $this->get_default_placeholder(),
567
- cookiebot_addons_output_cookie_types( $this->get_cookie_types() ),
568
- $src
569
- );
570
- }
571
-
572
- /**
573
- * Checks if it does have custom placeholder content
574
- *
575
- * @return mixed
576
- *
577
- * @since 1.8.0
578
- */
579
- public function has_placeholder() {
580
- return $this->settings->has_placeholder( $this->get_option_name() );
581
- }
582
-
583
- /**
584
- * returns all placeholder contents
585
- *
586
- * @return mixed
587
- *
588
- * @since 1.8.0
589
- */
590
- public function get_placeholders() {
591
- return $this->settings->get_placeholders( $this->get_option_name() );
592
- }
593
-
594
- /**
595
- * Return true if the placeholder is enabled
596
- *
597
- * @return mixed
598
- *
599
- * @since 1.8.0
600
- */
601
- public function is_placeholder_enabled() {
602
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
603
- }
604
-
605
- /**
606
- * Adds extra information under the label
607
- *
608
- * @return string
609
- *
610
- * @since 1.8.0
611
- */
612
- public function get_extra_information() {
613
- return '<p>' . esc_html__(
614
- 'Blocks embedded videos from Youtube, Twitter, Vimeo and Facebook.',
615
- 'cookiebot-addons'
616
- ) . '</p>';
617
- }
618
-
619
- /**
620
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
621
- *
622
- * @return boolean
623
- *
624
- * @since 1.8.0
625
- */
626
- public function get_svn_url() {
627
- return false;
628
- }
629
-
630
- /**
631
- * Placeholder helper overlay in the settings page.
632
- *
633
- * @return string
634
- *
635
- * @since 1.8.0
636
- */
637
- public function get_placeholder_helper() {
638
- return '<p>Merge tags you can use in the placeholder text:</p><ul><li>%src - video source</li><li>%cookie_types - Lists required cookie types</li><li>[renew_consent]text[/renew_consent] - link to display cookie settings in the frontend</li></ul>';
639
- }
640
-
641
- /**
642
- * Returns parent class or false
643
- *
644
- * @return string|bool
645
- *
646
- * @since 2.1.3
647
- */
648
- public function get_parent_class() {
649
- return get_parent_class( $this );
650
- }
651
-
652
- /**
653
- * Action after enabling the addon on the settings page
654
- *
655
- * @since 2.2.0
656
- */
657
- public function post_hook_after_enabling() {
658
- //do nothing
659
- }
660
-
661
- /**
662
- * Cookiebot plugin is deactivated
663
- *
664
- * @since 2.2.0
665
- */
666
- public function plugin_deactivated() {
667
- //do nothing
668
- }
669
-
670
- /**
671
- * Returns regex from the database
672
- * If it does not exist then it will return the default regex
673
- *
674
- * @return string
675
- *
676
- * @since 2.4.6
677
- */
678
- private function get_regex() {
679
- return apply_filters(
680
- 'cookiebot_embed_regex',
681
- $this->settings->get_addon_regex( $this->get_option_name(), $this->get_default_regex() )
682
- );
683
- }
684
-
685
- /**
686
- * Returns the default regex
687
- *
688
- * @return string
689
- *
690
- * @since 2.4.6
691
- */
692
- private function get_default_regex() {
693
- return apply_filters(
694
- 'cookiebot_embed_default_regex',
695
- '/<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'
696
- );
697
- }
698
-
699
- /**
700
- * Returns true if the default and the normal regex functions match
701
- *
702
- * @return bool
703
- *
704
- * @since 2.4.6
705
- */
706
- private function is_regex_default() {
707
- return $this->get_regex() === $this->get_default_regex();
708
- }
709
-
710
- /**
711
- * @return mixed
712
- *
713
- * @since 2.4.6
714
- */
715
- public function extra_available_addon_option() {
716
- ?>
717
- <div class="show_advanced_options">
718
- <button class="button button-secondary">
719
- <?php
720
- esc_html_e(
721
- 'Show advanced options',
722
- 'cookiebot-addons'
723
- );
724
- ?>
725
- </button>
726
- <span class="help-tip"
727
- title="<?php echo esc_html__( 'This is for more advanced users.', 'cookiebot-addons' ); ?>"></span>
728
- </div>
729
- <div class="advanced_options">
730
-
731
- <label for="embed_regex"><?php esc_html_e( 'Regex:', 'cookiebot-addons' ); ?></label>
732
- <textarea
733
- id="embed_regex"
734
- cols="80"
735
- rows="5"
736
- name="cookiebot_available_addons[<?php echo esc_attr( $this->get_option_name() ); ?>][regex]"
737
- disabled
738
- ><?php echo esc_html( $this->get_regex() ); ?></textarea>
739
-
740
- <?php if ( $this->is_regex_default() ) : ?>
741
- <button id="edit_embed_regex" class="button">
742
- <?php
743
- esc_html_e(
744
- 'Edit regex',
745
- 'cookiebot-addons'
746
- );
747
- ?>
748
- </button>
749
- <?php endif; ?>
750
-
751
- <button
752
- id="btn_default_embed_regex"
753
- class="button<?php echo ( $this->is_regex_default() ) ? ' hidden' : ''; ?>"
754
- type="button"
755
- value="Reset to default regex">
756
- <?php
757
- esc_html_e(
758
- 'Reset to default regex',
759
- 'cookiebot-addons'
760
- );
761
- ?>
762
- </button>
763
- <input
764
- type="hidden"
765
- name="default_embed_regex"
766
- id="default_embed_regex"
767
- value="<?php echo esc_html( $this->get_default_regex() ); ?>"/>
768
- </div>
769
- <?php
770
- }
771
-
772
- /**
773
- * Returns boolean to enable/disable plugin by default
774
- *
775
- * @return bool
776
- *
777
- * @since 3.6.3
778
- */
779
- public function enable_by_default() {
780
- return false;
781
- }
782
-
783
- /**
784
- * Sets default settings for this addon
785
- *
786
- * @return array
787
- *
788
- * @since 3.6.3
789
- */
790
- public function get_default_enable_setting() {
791
- return array(
792
- 'enabled' => 1,
793
- 'cookie_type' => $this->get_default_cookie_types(),
794
- 'placeholder' => $this->get_default_placeholder(),
795
- 'regex' => $this->get_default_regex(),
796
- );
797
- }
798
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/enfold/enfold.php DELETED
@@ -1,326 +0,0 @@
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 DELETED
@@ -1,331 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\enhanced_ecommerce_for_woocommerce_store;
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 Enhanced_Ecommerce_For_WooCommerce_Store 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_enhanced_ecommerce_for_woocommerce_store' ), 5 );
65
- }
66
-
67
- /**
68
- * Disable scripts if state not accepted
69
- *
70
- * @since 1.3.0
71
- */
72
- public function cookiebot_addon_enhanced_ecommerce_for_woocommerce_store() {
73
- $this->buffer_output->add_tag( 'wp_footer', 25, array(
74
- 'gtag' => $this->get_cookie_types()
75
- ), false );
76
-
77
- $this->buffer_output->add_tag( 'wp_head', 10, array(
78
- 'gtag' => $this->get_cookie_types(),
79
- 'gaProperty' => $this->get_cookie_types(),
80
- ), false );
81
- }
82
-
83
- /**
84
- * Return addon/plugin name
85
- *
86
- * @return string
87
- *
88
- * @since 1.3.0
89
- */
90
- public function get_addon_name() {
91
- return 'Enhanced Ecommerce Google Analytics Plugin for WooCommerce';
92
- }
93
-
94
- /**
95
- * Default placeholder content
96
- *
97
- * @return string
98
- *
99
- * @since 1.8.0
100
- */
101
- public function get_default_placeholder() {
102
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to enable Social Share buttons.';
103
- }
104
-
105
- /**
106
- * Get placeholder content
107
- *
108
- * This function will check following features:
109
- * - Current language
110
- *
111
- * @param $src
112
- *
113
- * @return bool|mixed
114
- *
115
- * @since 1.8.0
116
- */
117
- public function get_placeholder( $src = '' ) {
118
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
119
- }
120
-
121
- /**
122
- * Option name in the database
123
- *
124
- * @return string
125
- *
126
- * @since 1.3.0
127
- */
128
- public function get_option_name() {
129
- return 'enhanced_ecommerce_for_woocommerce_store';
130
- }
131
-
132
- /**
133
- * Plugin file name
134
- *
135
- * @return string
136
- *
137
- * @since 1.3.0
138
- */
139
- public function get_plugin_file() {
140
- return 'enhanced-e-commerce-for-woocommerce-store/enhanced-ecommerce-google-analytics.php';
141
- }
142
-
143
- /**
144
- * Returns checked cookie types
145
- * @return mixed
146
- *
147
- * @since 1.3.0
148
- */
149
- public function get_cookie_types() {
150
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
151
- }
152
-
153
- /**
154
- * Returns default cookie types
155
- * @return array
156
- *
157
- * @since 1.5.0
158
- */
159
- public function get_default_cookie_types() {
160
- return array('statistics');
161
- }
162
-
163
- /**
164
- * Check if plugin is activated and checked in the backend
165
- *
166
- * @since 1.3.0
167
- */
168
- public function is_addon_enabled() {
169
- return $this->settings->is_addon_enabled( $this->get_option_name() );
170
- }
171
-
172
- /**
173
- * Checks if addon is installed
174
- *
175
- * @since 1.3.0
176
- */
177
- public function is_addon_installed() {
178
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
179
- }
180
-
181
- /**
182
- * Checks if addon is activated
183
- *
184
- * @since 1.3.0
185
- */
186
- public function is_addon_activated() {
187
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
188
- }
189
-
190
- /**
191
- * Retrieves current installed version of the addon
192
- *
193
- * @return bool
194
- *
195
- * @since 2.2.1
196
- */
197
- public function get_addon_version() {
198
- return $this->settings->get_addon_version( $this->get_plugin_file() );
199
- }
200
-
201
- /**
202
- * Checks if it does have custom placeholder content
203
- *
204
- * @return mixed
205
- *
206
- * @since 1.8.0
207
- */
208
- public function has_placeholder() {
209
- return $this->settings->has_placeholder( $this->get_option_name() );
210
- }
211
-
212
- /**
213
- * returns all placeholder contents
214
- *
215
- * @return mixed
216
- *
217
- * @since 1.8.0
218
- */
219
- public function get_placeholders() {
220
- return $this->settings->get_placeholders( $this->get_option_name() );
221
- }
222
-
223
- /**
224
- * Return true if the placeholder is enabled
225
- *
226
- * @return mixed
227
- *
228
- * @since 1.8.0
229
- */
230
- public function is_placeholder_enabled() {
231
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
232
- }
233
-
234
- /**
235
- * Adds extra information under the label
236
- *
237
- * @return string
238
- *
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
- /**
246
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
247
- *
248
- * @return string
249
- *
250
- * @since 1.8.0
251
- */
252
- public function get_svn_url() {
253
- return 'https://plugins.svn.wordpress.org/enhanced-e-commerce-for-woocommerce-store/trunk/enhanced-ecommerce-google-analytics.php';
254
- }
255
-
256
- /**
257
- * Placeholder helper overlay in the settings page.
258
- *
259
- * @return string
260
- *
261
- * @since 1.8.0
262
- */
263
- public function get_placeholder_helper() {
264
- 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>';
265
- }
266
-
267
-
268
- /**
269
- * Returns parent class or false
270
- *
271
- * @return string|bool
272
- *
273
- * @since 2.1.3
274
- */
275
- public function get_parent_class() {
276
- return get_parent_class( $this );
277
- }
278
-
279
- /**
280
- * Action after enabling the addon on the settings page
281
- *
282
- * @since 2.2.0
283
- */
284
- public function post_hook_after_enabling() {
285
- //do nothing
286
- }
287
-
288
- /**
289
- * Cookiebot plugin is deactivated
290
- *
291
- * @since 2.2.0
292
- */
293
- public function plugin_deactivated() {
294
- //do nothing
295
- }
296
-
297
- /**
298
- * @return mixed
299
- *
300
- * @since 2.4.5
301
- */
302
- public function extra_available_addon_option() {
303
- //do nothing
304
- }
305
-
306
- /**
307
- * Returns boolean to enable/disable plugin by default
308
- *
309
- * @return bool
310
- *
311
- * @since 3.6.3
312
- */
313
- public function enable_by_default() {
314
- return false;
315
- }
316
-
317
- /**
318
- * Sets default settings for this addon
319
- *
320
- * @return array
321
- *
322
- * @since 3.6.3
323
- */
324
- public function get_default_enable_setting() {
325
- return array(
326
- 'enabled' => 1,
327
- 'cookie_type' => $this->get_default_cookie_types(),
328
- 'placeholder' => $this->get_default_placeholder(),
329
- );
330
- }
331
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/facebook-for-woocommerce/facebook-for-woocommerce.php DELETED
@@ -1,386 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\facebook_for_woocommerce;
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 Facebook_For_Woocommerce implements Cookiebot_Addons_Interface {
12
- /**
13
- * @var Settings_Service_Interface
14
- *
15
- * @since 1.3.0
16
- */
17
- protected $settings;
18
-
19
- /**
20
- * @var Script_Loader_Tag_Interface
21
- *
22
- * @since 1.3.0
23
- */
24
- protected $script_loader_tag;
25
-
26
- /**
27
- * @var Cookie_Consent_Interface
28
- *
29
- * @since 1.3.0
30
- */
31
- public $cookie_consent;
32
-
33
- /**
34
- * @var Buffer_Output_Interface
35
- *
36
- * @since 1.3.0
37
- */
38
- protected $buffer_output;
39
-
40
- /**
41
- * Jetpack constructor.
42
- *
43
- * @param $settings Settings_Service_Interface
44
- * @param $script_loader_tag Script_Loader_Tag_Interface
45
- * @param $cookie_consent Cookie_Consent_Interface
46
- * @param $buffer_output Buffer_Output_Interface
47
- *
48
- * @since 1.2.0
49
- */
50
- public function __construct( Settings_Service_Interface $settings, Script_Loader_Tag_Interface $script_loader_tag, Cookie_Consent_Interface $cookie_consent, Buffer_Output_Interface $buffer_output ) {
51
- $this->settings = $settings;
52
- $this->script_loader_tag = $script_loader_tag;
53
- $this->cookie_consent = $cookie_consent;
54
- $this->buffer_output = $buffer_output;
55
- }
56
-
57
- /**
58
- * Loads addon configuration
59
- *
60
- * @since 1.3.0
61
- */
62
- public function load_configuration() {
63
- /**
64
- * We add the action after wp_loaded and replace the original GA Google
65
- * Analytics action with our own adjusted version.
66
- */
67
- add_action( 'wp_loaded', array( $this, 'cookiebot_addon_facebook_for_woocommerce_tracking_code' ), 5 );
68
- }
69
-
70
- /**
71
- * Manipulate the scripts if they are loaded.
72
- *
73
- * @since 1.3.0
74
- */
75
- public function cookiebot_addon_facebook_for_woocommerce_tracking_code() {
76
-
77
- add_filter( 'wc_facebook_pixel_script_attributes', array( $this, 'cookiebot_addon_facebook_for_woocommerce_script_attributes' ) );
78
-
79
- /* Keep for old version */
80
- $this->buffer_output->add_tag( 'woocommerce_after_single_product', 2, array(
81
- 'fbq(\'ViewContent\'' => $this->get_cookie_types()
82
- ), false );
83
-
84
- $this->buffer_output->add_tag( 'woocommerce_after_shop_loop', 10, array(
85
- 'fbq(\'ViewCategory\'' => $this->get_cookie_types()
86
- ), false );
87
-
88
- $this->buffer_output->add_tag( 'pre_get_posts', 10, array(
89
- 'fbq(\'Search\'' => $this->get_cookie_types()
90
- ), false );
91
-
92
- $this->buffer_output->add_tag( 'woocommerce_after_cart', 10, array(
93
- 'fbq(\'AddToCart\'' => $this->get_cookie_types()
94
- ), false );
95
-
96
- $this->buffer_output->add_tag( 'woocommerce_add_to_cart', 2, array(
97
- 'fbq(\'AddToCart\'' => $this->get_cookie_types()
98
- ), false );
99
-
100
- $this->buffer_output->add_tag( 'wc_ajax_fb_inject_add_to_cart_event', 2, array(
101
- 'fbq(\'AddToCart\'' => $this->get_cookie_types()
102
- ), false );
103
-
104
- $this->buffer_output->add_tag( 'woocommerce_after_checkout_form', 10, array(
105
- 'fbq(\'InitiateCheckout\'' => $this->get_cookie_types()
106
- ), false );
107
-
108
- $this->buffer_output->add_tag( 'woocommerce_thankyou', 2, array(
109
- 'fbq(\'Purchase\'' => $this->get_cookie_types()
110
- ), false );
111
-
112
- $this->buffer_output->add_tag( 'woocommerce_payment_complete', 2, array(
113
- 'fbq(\'Purchase\'' => $this->get_cookie_types()
114
- ), false );
115
-
116
- $this->buffer_output->add_tag( 'wp_head', 10, array(
117
- 'fbq(\'track\',' => $this->get_cookie_types()
118
- ), false );
119
-
120
- /**
121
- * inject base pixel
122
- */
123
- //We always need to remove this untill consent is given - because we can force no execution before consent it given
124
- cookiebot_addons_remove_class_action( 'wp_footer', 'WC_Facebookcommerce_EventsTracker', 'inject_base_pixel_noscript' );
125
-
126
- }
127
-
128
- /**
129
- * Return attributes for script tags
130
- */
131
- function cookiebot_addon_facebook_for_woocommerce_script_attributes() {
132
- $attr = array();
133
- $attr['type'] = 'text/plain';
134
- $attr['data-cookieconsent'] = implode(',',$this->get_cookie_types());
135
- return $attr;
136
- }
137
-
138
- /**
139
- * Return addon/plugin name
140
- *
141
- * @return string
142
- *
143
- * @since 1.3.0
144
- */
145
- public function get_addon_name() {
146
- return 'Facebook For WooCommerce';
147
- }
148
-
149
- /**
150
- * Default placeholder content
151
- *
152
- * @return string
153
- *
154
- * @since 1.8.0
155
- */
156
- public function get_default_placeholder() {
157
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to enable facebook shopping feature.';
158
- }
159
-
160
- /**
161
- * Get placeholder content
162
- *
163
- * This function will check following features:
164
- * - Current language
165
- *
166
- * @param $src
167
- *
168
- * @return bool|mixed
169
- *
170
- * @since 1.8.0
171
- */
172
- public function get_placeholder( $src = '' ) {
173
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
174
- }
175
-
176
- /**
177
- * Option name in the database
178
- *
179
- * @return string
180
- *
181
- * @since 1.3.0
182
- */
183
- public function get_option_name() {
184
- return 'facebook_for_woocommerce';
185
- }
186
-
187
- /**
188
- * Plugin file name
189
- *
190
- * @return string
191
- *
192
- * @since 1.3.0
193
- */
194
- public function get_plugin_file() {
195
- return 'facebook-for-woocommerce/facebook-for-woocommerce.php';
196
- }
197
-
198
- /**
199
- * Returns checked cookie types
200
- * @return mixed
201
- *
202
- * @since 1.3.0
203
- */
204
- public function get_cookie_types() {
205
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
206
- }
207
-
208
- /**
209
- * Returns default cookie types
210
- * @return array
211
- *
212
- * @since 1.5.0
213
- */
214
- public function get_default_cookie_types() {
215
- return array( 'marketing' );
216
- }
217
-
218
- /**
219
- * Check if plugin is activated and checked in the backend
220
- *
221
- * @since 1.3.0
222
- */
223
- public function is_addon_enabled() {
224
- return $this->settings->is_addon_enabled( $this->get_option_name() );
225
- }
226
-
227
- /**
228
- * Checks if addon is installed
229
- *
230
- * @since 1.3.0
231
- */
232
- public function is_addon_installed() {
233
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
234
- }
235
-
236
- /**
237
- * Checks if addon is activated
238
- *
239
- * @since 1.3.0
240
- */
241
- public function is_addon_activated() {
242
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
243
- }
244
-
245
- /**
246
- * Retrieves current installed version of the addon
247
- *
248
- * @return bool
249
- *
250
- * @since 2.2.1
251
- */
252
- public function get_addon_version() {
253
- return $this->settings->get_addon_version( $this->get_plugin_file() );
254
- }
255
-
256
- /**
257
- * Checks if it does have custom placeholder content
258
- *
259
- * @return mixed
260
- *
261
- * @since 1.8.0
262
- */
263
- public function has_placeholder() {
264
- return $this->settings->has_placeholder( $this->get_option_name() );
265
- }
266
-
267
- /**
268
- * returns all placeholder contents
269
- *
270
- * @return mixed
271
- *
272
- * @since 1.8.0
273
- */
274
- public function get_placeholders() {
275
- return $this->settings->get_placeholders( $this->get_option_name() );
276
- }
277
-
278
- /**
279
- * Return true if the placeholder is enabled
280
- *
281
- * @return mixed
282
- *
283
- * @since 1.8.0
284
- */
285
- public function is_placeholder_enabled() {
286
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
287
- }
288
-
289
- /**
290
- * Adds extra information under the label
291
- *
292
- * @return string
293
- *
294
- * @since 1.8.0
295
- */
296
- public function get_extra_information() {
297
-
298
- }
299
-
300
- /**
301
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
302
- *
303
- * @return string
304
- *
305
- * @since 1.8.0
306
- */
307
- public function get_svn_url() {
308
- return 'https://raw.githubusercontent.com/facebookincubator/facebook-for-woocommerce/master/facebook-commerce.php';
309
- }
310
-
311
- /**
312
- * Placeholder helper overlay in the settings page.
313
- *
314
- * @return string
315
- *
316
- * @since 1.8.0
317
- */
318
- public function get_placeholder_helper() {
319
- 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>';
320
- }
321
-
322
-
323
- /**
324
- * Returns parent class or false
325
- *
326
- * @return string|bool
327
- *
328
- * @since 2.1.3
329
- */
330
- public function get_parent_class() {
331
- return get_parent_class( $this );
332
- }
333
-
334
- /**
335
- * Action after enabling the addon on the settings page
336
- *
337
- * @since 2.2.0
338
- */
339
- public function post_hook_after_enabling() {
340
- //do nothing
341
- }
342
-
343
- /**
344
- * Cookiebot plugin is deactivated
345
- *
346
- * @since 2.2.0
347
- */
348
- public function plugin_deactivated() {
349
- //do nothing
350
- }
351
-
352
- /**
353
- * @return mixed
354
- *
355
- * @since 2.4.5
356
- */
357
- public function extra_available_addon_option() {
358
- //do nothing
359
- }
360
-
361
- /**
362
- * Returns boolean to enable/disable plugin by default
363
- *
364
- * @return bool
365
- *
366
- * @since 3.6.3
367
- */
368
- public function enable_by_default() {
369
- return false;
370
- }
371
-
372
- /**
373
- * Sets default settings for this addon
374
- *
375
- * @return array
376
- *
377
- * @since 3.6.3
378
- */
379
- public function get_default_enable_setting() {
380
- return array(
381
- 'enabled' => 1,
382
- 'cookie_type' => $this->get_default_cookie_types(),
383
- 'placeholder' => $this->get_default_placeholder(),
384
- );
385
- }
386
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/ga-google-analytics/ga-google-analytics.php DELETED
@@ -1,348 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\ga_google_analytics;
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 Ga_Google_Analytics 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_ga_google_analytics' ), 5 );
69
- }
70
-
71
- /**
72
- * Manipulate the scripts if they are loaded.
73
- *
74
- * @version 1.3.0
75
- * @since 1.1.0
76
- */
77
- public function cookiebot_addon_ga_google_analytics() {
78
-
79
- //Remove GA Google action and replace it with our own
80
- if ( has_action( 'wp_head', 'ga_google_analytics_tracking_code' ) ) {
81
- $this->buffer_output->add_tag( 'wp_head', 10, array(
82
- 'gtag(' => $this->get_cookie_types(),
83
- 'google-analytics' => $this->get_cookie_types(),
84
- '_gaq' => $this->get_cookie_types(),
85
- 'www.googletagmanager.com/gtag/js?id=' => $this->get_cookie_types()
86
- ), false );
87
-
88
- } elseif ( has_action( 'wp_footer', 'ga_google_analytics_tracking_code' ) ) {
89
- /**
90
- * Consent not given - no cache
91
- */
92
- $this->buffer_output->add_tag( 'wp_footer', 10, array(
93
- 'gtag(' => $this->get_cookie_types(),
94
- 'google-analytics' => $this->get_cookie_types(),
95
- '_gaq' => $this->get_cookie_types(),
96
- 'www.googletagmanager.com/gtag/js?id=' => $this->get_cookie_types()
97
- ), false );
98
- }
99
- }
100
-
101
- /**
102
- * Return addon/plugin name
103
- *
104
- * @return string
105
- *
106
- * @since 1.3.0
107
- */
108
- public function get_addon_name() {
109
- return 'GA Google Analytics';
110
- }
111
-
112
- /**
113
- * Option name in the database
114
- *
115
- * @return string
116
- *
117
- * @since 1.3.0
118
- */
119
- public function get_option_name() {
120
- return 'ga_google_analytics';
121
- }
122
-
123
- /**
124
- * Plugin file name
125
- *
126
- * @return string
127
- *
128
- * @since 1.3.0
129
- */
130
- public function get_plugin_file() {
131
- return 'ga-google-analytics/ga-google-analytics.php';
132
- }
133
-
134
- /**
135
- * Returns checked cookie types
136
- * @return mixed
137
- *
138
- * @since 1.3.0
139
- */
140
- public function get_cookie_types() {
141
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
142
- }
143
-
144
- /**
145
- * Returns default cookie types
146
- * @return array
147
- *
148
- * @since 1.5.0
149
- */
150
- public function get_default_cookie_types() {
151
- return array( 'statistics' );
152
- }
153
-
154
- /**
155
- * Check if plugin is activated and checked in the backend
156
- *
157
- * @since 1.3.0
158
- */
159
- public function is_addon_enabled() {
160
- return $this->settings->is_addon_enabled( $this->get_option_name() );
161
- }
162
-
163
- /**
164
- * Checks if addon is installed
165
- *
166
- * @since 1.3.0
167
- */
168
- public function is_addon_installed() {
169
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
170
- }
171
-
172
- /**
173
- * Checks if addon is activated
174
- *
175
- * @since 1.3.0
176
- */
177
- public function is_addon_activated() {
178
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
179
- }
180
-
181
- /**
182
- * Retrieves current installed version of the addon
183
- *
184
- * @return bool
185
- *
186
- * @since 2.2.1
187
- */
188
- public function get_addon_version() {
189
- return $this->settings->get_addon_version( $this->get_plugin_file() );
190
- }
191
-
192
- /**
193
- * Default placeholder content
194
- *
195
- * @return string
196
- *
197
- * @since 1.8.0
198
- */
199
- public function get_default_placeholder() {
200
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
201
- }
202
-
203
- /**
204
- * Get placeholder content
205
- *
206
- * This function will check following features:
207
- * - Current language
208
- *
209
- * @param $src
210
- *
211
- * @return bool|mixed
212
- *
213
- * @since 1.8.0
214
- */
215
- public function get_placeholder( $src = '' ) {
216
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
217
- }
218
-
219
- /**
220
- * Checks if it does have custom placeholder content
221
- *
222
- * @return mixed
223
- *
224
- * @since 1.8.0
225
- */
226
- public function has_placeholder() {
227
- return $this->settings->has_placeholder( $this->get_option_name() );
228
- }
229
-
230
- /**
231
- * returns all placeholder contents
232
- *
233
- * @return mixed
234
- *
235
- * @since 1.8.0
236
- */
237
- public function get_placeholders() {
238
- return $this->settings->get_placeholders( $this->get_option_name() );
239
- }
240
-
241
- /**
242
- * Return true if the placeholder is enabled
243
- *
244
- * @return mixed
245
- *
246
- * @since 1.8.0
247
- */
248
- public function is_placeholder_enabled() {
249
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
250
- }
251
-
252
- /**
253
- * Adds extra information under the label
254
- *
255
- * @return string
256
- *
257
- * @since 1.8.0
258
- */
259
- public function get_extra_information() {
260
- return false;
261
- }
262
-
263
- /**
264
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
265
- *
266
- * @return boolean
267
- *
268
- * @since 1.8.0
269
- */
270
- public function get_svn_url() {
271
- return 'http://plugins.svn.wordpress.org/ga-google-analytics/trunk/ga-google-analytics.php';
272
- }
273
-
274
- /**
275
- * Placeholder helper overlay in the settings page.
276
- *
277
- * @return string
278
- *
279
- * @since 1.8.0
280
- */
281
- public function get_placeholder_helper() {
282
- 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>';
283
- }
284
-
285
- /**
286
- * Returns parent class or false
287
- *
288
- * @return string|bool
289
- *
290
- * @since 2.1.3
291
- */
292
- public function get_parent_class() {
293
- return get_parent_class( $this );
294
- }
295
-
296
- /**
297
- * Action after enabling the addon on the settings page
298
- *
299
- * @since 2.2.0
300
- */
301
- public function post_hook_after_enabling() {
302
- //do nothing
303
- }
304
-
305
- /**
306
- * Cookiebot plugin is deactivated
307
- *
308
- * @since 2.2.0
309
- */
310
- public function plugin_deactivated() {
311
- //do nothing
312
- }
313
-
314
- /**
315
- * @return mixed
316
- *
317
- * @since 2.4.5
318
- */
319
- public function extra_available_addon_option() {
320
- //do nothing
321
- }
322
-
323
- /**
324
- * Returns boolean to enable/disable plugin by default
325
- *
326
- * @return bool
327
- *
328
- * @since 3.6.3
329
- */
330
- public function enable_by_default() {
331
- return false;
332
- }
333
-
334
- /**
335
- * Sets default settings for this addon
336
- *
337
- * @return array
338
- *
339
- * @since 3.6.3
340
- */
341
- public function get_default_enable_setting() {
342
- return array(
343
- 'enabled' => 1,
344
- 'cookie_type' => $this->get_default_cookie_types(),
345
- 'placeholder' => $this->get_default_placeholder(),
346
- );
347
- }
348
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/gadwp/gadwp.php DELETED
@@ -1,382 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\gadwp;
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 Gadwp 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(
52
- Settings_Service_Interface $settings,
53
- Script_Loader_Tag_Interface $script_loader_tag,
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
- /**
64
- * Loads addon configuration
65
- *
66
- * @since 1.3.0
67
- */
68
- public function load_configuration() {
69
- /**
70
- * We add the action after wp_loaded and replace the original GA Google
71
- * Analytics action with our own adjusted version.
72
- */
73
- add_action( 'wp_loaded', array( $this, 'cookiebot_addon_ga_google_analytics' ), 5 );
74
- }
75
-
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() {
83
- $this->script_loader_tag->add_tag( 'gadwp-nprogress', $this->get_cookie_types() );
84
- $this->script_loader_tag->add_tag( 'gadwp-frontend-item-reports', $this->get_cookie_types() );
85
-
86
- $this->script_loader_tag->add_tag( 'gadwp-tracking-analytics-events', $this->get_cookie_types() );
87
- $this->script_loader_tag->add_tag( 'gadwp-pagescrolldepth-tracking', $this->get_cookie_types() );
88
-
89
- $this->script_loader_tag->add_tag( 'gadwp-front-widget', $this->get_cookie_types() );
90
- $this->script_loader_tag->add_tag( 'googlecharts', $this->get_cookie_types() );
91
-
92
- $this->buffer_output->add_tag( 'wp_head',
93
- 99,
94
- array(
95
- 'google-analytics.com' => $this->get_cookie_types(),
96
- 'googletagmanager.com' => $this->get_cookie_types(),
97
- 'ga-disable-' => $this->get_cookie_types(),
98
- ),
99
- false );
100
-
101
-
102
- $this->buffer_output->add_tag( 'wp_footer',
103
- 99,
104
- array(
105
- 'google-analytics.com' => $this->get_cookie_types(),
106
- 'googletagmanager.com' => $this->get_cookie_types(),
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
- /**
133
- * Return addon/plugin name
134
- *
135
- * @return string
136
- *
137
- * @since 1.3.0
138
- */
139
- public function get_addon_name() {
140
- return 'Google Analytics Dashboard for WP by ExactMetrics';
141
- }
142
-
143
- /**
144
- * Option name in the database
145
- *
146
- * @return string
147
- *
148
- * @since 1.3.0
149
- */
150
- public function get_option_name() {
151
- return 'gadwp';
152
- }
153
-
154
- /**
155
- * Plugin file name
156
- *
157
- * @return string
158
- *
159
- * @since 1.3.0
160
- */
161
- public function get_plugin_file() {
162
- return 'google-analytics-dashboard-for-wp/gadwp.php';
163
- }
164
-
165
- /**
166
- * Returns checked cookie types
167
- * @return mixed
168
- *
169
- * @since 1.3.0
170
- */
171
- public function get_cookie_types() {
172
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
173
- }
174
-
175
- /**
176
- * Returns default cookie types
177
- * @return array
178
- *
179
- * @since 1.5.0
180
- */
181
- public function get_default_cookie_types() {
182
- return array( 'statistics' );
183
- }
184
-
185
- /**
186
- * Check if plugin is activated and checked in the backend
187
- *
188
- * @since 1.3.0
189
- */
190
- public function is_addon_enabled() {
191
- return $this->settings->is_addon_enabled( $this->get_option_name() );
192
- }
193
-
194
- /**
195
- * Checks if addon is installed
196
- *
197
- * @since 1.3.0
198
- */
199
- public function is_addon_installed() {
200
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
201
- }
202
-
203
- /**
204
- * Checks if addon is activated
205
- *
206
- * @since 1.3.0
207
- */
208
- public function is_addon_activated() {
209
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
210
- }
211
-
212
- /**
213
- * Retrieves current installed version of the addon
214
- *
215
- * @return bool
216
- *
217
- * @since 2.2.1
218
- */
219
- public function get_addon_version() {
220
- return $this->settings->get_addon_version( $this->get_plugin_file() );
221
- }
222
-
223
- /**
224
- * Default placeholder content
225
- *
226
- * @return string
227
- *
228
- * @since 1.8.0
229
- */
230
- public function get_default_placeholder() {
231
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to enable tracking.';
232
- }
233
-
234
- /**
235
- * Get placeholder content
236
- *
237
- * This function will check following features:
238
- * - Current language
239
- *
240
- * @param $src
241
- *
242
- * @return bool|mixed
243
- *
244
- * @since 1.8.0
245
- */
246
- public function get_placeholder( $src = '' ) {
247
- return $this->settings->get_placeholder( $this->get_option_name(),
248
- $this->get_default_placeholder(),
249
- cookiebot_addons_output_cookie_types( $this->get_cookie_types() ),
250
- $src );
251
- }
252
-
253
- /**
254
- * Checks if it does have custom placeholder content
255
- *
256
- * @return mixed
257
- *
258
- * @since 1.8.0
259
- */
260
- public function has_placeholder() {
261
- return $this->settings->has_placeholder( $this->get_option_name() );
262
- }
263
-
264
- /**
265
- * returns all placeholder contents
266
- *
267
- * @return mixed
268
- *
269
- * @since 1.8.0
270
- */
271
- public function get_placeholders() {
272
- return $this->settings->get_placeholders( $this->get_option_name() );
273
- }
274
-
275
- /**
276
- * Return true if the placeholder is enabled
277
- *
278
- * @return mixed
279
- *
280
- * @since 1.8.0
281
- */
282
- public function is_placeholder_enabled() {
283
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
284
- }
285
-
286
- /**
287
- * Adds extra information under the label
288
- *
289
- * @return string
290
- *
291
- * @since 1.8.0
292
- */
293
- public function get_extra_information() {
294
- return false;
295
- }
296
-
297
- /**
298
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
299
- *
300
- * @return boolean
301
- *
302
- * @since 1.8.0
303
- */
304
- public function get_svn_url() {
305
- return 'http://plugins.svn.wordpress.org/google-analytics-dashboard-for-wp/trunk/gadwp.php';
306
- }
307
-
308
- /**
309
- * Placeholder helper overlay in the settings page.
310
- *
311
- * @return string
312
- *
313
- * @since 1.8.0
314
- */
315
- public function get_placeholder_helper() {
316
- 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>';
317
- }
318
-
319
- /**
320
- * Returns parent class or false
321
- *
322
- * @return string|bool
323
- *
324
- * @since 2.1.3
325
- */
326
- public function get_parent_class() {
327
- return get_parent_class( $this );
328
- }
329
-
330
- /**
331
- * Action after enabling the addon on the settings page
332
- *
333
- * @since 2.2.0
334
- */
335
- public function post_hook_after_enabling() {
336
- //do nothing
337
- }
338
-
339
- /**
340
- * Cookiebot plugin is deactivated
341
- *
342
- * @since 2.2.0
343
- */
344
- public function plugin_deactivated() {
345
- //do nothing
346
- }
347
-
348
- /**
349
- * @return mixed
350
- *
351
- * @since 2.4.5
352
- */
353
- public function extra_available_addon_option() {
354
- //do nothing
355
- }
356
-
357
- /**
358
- * Returns boolean to enable/disable plugin by default
359
- *
360
- * @return bool
361
- *
362
- * @since 3.6.3
363
- */
364
- public function enable_by_default() {
365
- return false;
366
- }
367
-
368
- /**
369
- * Sets default settings for this addon
370
- *
371
- * @return array
372
- *
373
- * @since 3.6.3
374
- */
375
- public function get_default_enable_setting() {
376
- return array(
377
- 'enabled' => 1,
378
- 'cookie_type' => $this->get_default_cookie_types(),
379
- 'placeholder' => $this->get_default_placeholder(),
380
- );
381
- }
382
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/google-analyticator/google-analyticator.php DELETED
@@ -1,364 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\google_analyticator;
4
-
5
- use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
6
- use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
7
- use cookiebot_addons\lib\Cookie_Consent_Interface;
8
- use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
9
- use cookiebot_addons\lib\Settings_Service_Interface;
10
-
11
- class Google_Analyticator 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_google_analyticator' ), 5 );
65
- }
66
-
67
- /**
68
- * Check for google analyticator action hooks
69
- *
70
- * @since 1.3.0
71
- */
72
- public function cookiebot_addon_google_analyticator() {
73
- /**
74
- * ga scripts are loaded in wp_head priority set to 99
75
- */
76
- if ( has_action( 'wp_head', 'add_google_analytics' ) ) {
77
- /**
78
- * Consent not given - no cache
79
- */
80
- $this->buffer_output->add_tag( 'wp_head', 99, array(
81
- 'gtag' => $this->get_cookie_types(),
82
- 'google-analytics' => $this->get_cookie_types(),
83
- '_gaq' => $this->get_cookie_types(),
84
- 'www.googletagmanager.com/gtag/js?id=' => $this->get_cookie_types()
85
- ), false );
86
- }
87
-
88
- /**
89
- * ga scripts are loaded in login_head priority set to 99
90
- */
91
- if ( has_action( 'login_head', 'add_google_analytics' ) ) {
92
- /**
93
- * Consent not given - no cache
94
- */
95
- $this->buffer_output->add_tag( 'login_head', 99, array(
96
- 'gtag' => $this->get_cookie_types(),
97
- 'google-analytics' => $this->get_cookie_types(),
98
- '_gaq' => $this->get_cookie_types(),
99
- 'www.googletagmanager.com/gtag/js?id=' => $this->get_cookie_types()
100
- ) );
101
- }
102
-
103
- /**
104
- * External js, so manipulate attributes
105
- */
106
- if ( has_action( 'wp_print_scripts', 'ga_external_tracking_js' ) ) {
107
- /**
108
- * Catch external js file and add cookiebot attributes to it
109
- *
110
- * @since 1.1.0
111
- */
112
- $this->script_loader_tag->add_tag( 'ga-external-tracking', $this->get_cookie_types() );
113
- }
114
- }
115
-
116
- /**
117
- * Return addon/plugin name
118
- *
119
- * @return string
120
- *
121
- * @since 1.3.0
122
- */
123
- public function get_addon_name() {
124
- return 'Google Analyticator';
125
- }
126
-
127
- /**
128
- * Option name in the database
129
- *
130
- * @return string
131
- *
132
- * @since 1.3.0
133
- */
134
- public function get_option_name() {
135
- return 'google_analyticator';
136
- }
137
-
138
- /**
139
- * plugin file name
140
- *
141
- * @return string
142
- *
143
- * @since 1.3.0
144
- */
145
- public function get_plugin_file() {
146
- return 'google-analyticator/google-analyticator.php';
147
- }
148
-
149
- /**
150
- * Returns checked cookie types
151
- * @return array
152
- *
153
- * @since 1.3.0
154
- */
155
- public function get_cookie_types() {
156
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
157
- }
158
-
159
- /**
160
- * Returns default cookie types
161
- * @return array
162
- *
163
- * @since 1.5.0
164
- */
165
- public function get_default_cookie_types() {
166
- return array( 'statistics' );
167
- }
168
-
169
- /**
170
- * Check if plugin is activated and checked in the backend
171
- *
172
- * @since 1.3.0
173
- */
174
- public function is_addon_enabled() {
175
- return $this->settings->is_addon_enabled( $this->get_option_name() );
176
- }
177
-
178
- /**
179
- * Checks if addon is installed
180
- *
181
- * @since 1.3.0
182
- */
183
- public function is_addon_installed() {
184
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
185
- }
186
-
187
- /**
188
- * Checks if addon is activated
189
- *
190
- * @since 1.3.0
191
- */
192
- public function is_addon_activated() {
193
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
194
- }
195
-
196
- /**
197
- * Retrieves current installed version of the addon
198
- *
199
- * @return bool
200
- *
201
- * @since 2.2.1
202
- */
203
- public function get_addon_version() {
204
- return $this->settings->get_addon_version( $this->get_plugin_file() );
205
- }
206
-
207
- /**
208
- * Default placeholder content
209
- *
210
- * @return string
211
- *
212
- * @since 1.8.0
213
- */
214
- public function get_default_placeholder() {
215
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
216
- }
217
-
218
- /**
219
- * Get placeholder content
220
- *
221
- * This function will check following features:
222
- * - Current language
223
- *
224
- * @param $src
225
- *
226
- * @return bool|mixed
227
- *
228
- * @since 1.8.0
229
- */
230
- public function get_placeholder( $src = '' ) {
231
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
232
- }
233
-
234
- /**
235
- * Checks if it does have custom placeholder content
236
- *
237
- * @return mixed
238
- *
239
- * @since 1.8.0
240
- */
241
- public function has_placeholder() {
242
- return $this->settings->has_placeholder( $this->get_option_name() );
243
- }
244
-
245
- /**
246
- * returns all placeholder contents
247
- *
248
- * @return mixed
249
- *
250
- * @since 1.8.0
251
- */
252
- public function get_placeholders() {
253
- return $this->settings->get_placeholders( $this->get_option_name() );
254
- }
255
-
256
- /**
257
- * Return true if the placeholder is enabled
258
- *
259
- * @return mixed
260
- *
261
- * @since 1.8.0
262
- */
263
- public function is_placeholder_enabled() {
264
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
265
- }
266
-
267
- /**
268
- * Adds extra information under the label
269
- *
270
- * @return string
271
- *
272
- * @since 1.8.0
273
- */
274
- public function get_extra_information() {
275
-
276
- }
277
-
278
- /**
279
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
280
- *
281
- * @return boolean
282
- *
283
- * @since 1.8.0
284
- */
285
- public function get_svn_url() {
286
- return 'http://plugins.svn.wordpress.org/google-analyticator/trunk/google-analyticator.php';
287
- }
288
-
289
- /**
290
- * Placeholder helper overlay in the settings page.
291
- *
292
- * @return string
293
- *
294
- * @since 1.8.0
295
- */
296
- public function get_placeholder_helper() {
297
- 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>';
298
- }
299
-
300
-
301
- /**
302
- * Returns parent class or false
303
- *
304
- * @return string|bool
305
- *
306
- * @since 2.1.3
307
- */
308
- public function get_parent_class() {
309
- return get_parent_class( $this );
310
- }
311
-
312
- /**
313
- * Action after enabling the addon on the settings page
314
- *
315
- * @since 2.2.0
316
- */
317
- public function post_hook_after_enabling() {
318
- //do nothing
319
- }
320
-
321
- /**
322
- * Cookiebot plugin is deactivated
323
- *
324
- * @since 2.2.0
325
- */
326
- public function plugin_deactivated() {
327
- //do nothing
328
- }
329
-
330
- /**
331
- * @return mixed
332
- *
333
- * @since 2.4.5
334
- */
335
- public function extra_available_addon_option() {
336
- //do nothing
337
- }
338
-
339
- /**
340
- * Returns boolean to enable/disable plugin by default
341
- *
342
- * @return bool
343
- *
344
- * @since 3.6.3
345
- */
346
- public function enable_by_default() {
347
- return false;
348
- }
349
-
350
- /**
351
- * Sets default settings for this addon
352
- *
353
- * @return array
354
- *
355
- * @since 3.6.3
356
- */
357
- public function get_default_enable_setting() {
358
- return array(
359
- 'enabled' => 1,
360
- 'cookie_type' => $this->get_default_cookie_types(),
361
- 'placeholder' => $this->get_default_placeholder(),
362
- );
363
- }
364
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/google-analytics-plus/google-analytics-plus.php DELETED
@@ -1,327 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\google_analytics_plus;
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 Google_Analytics_Plus implements Cookiebot_Addons_Interface {
12
-
13
- /**
14
- * @var Settings_Service_Interface
15
- *
16
- * @since 1.5.0
17
- */
18
- protected $settings;
19
-
20
- /**
21
- * @var Script_Loader_Tag_Interface
22
- *
23
- * @since 1.5.0
24
- */
25
- protected $script_loader_tag;
26
-
27
- /**
28
- * @var Cookie_Consent_Interface
29
- *
30
- * @since 1.5.0
31
- */
32
- public $cookie_consent;
33
-
34
- /**
35
- * @var Buffer_Output_Interface
36
- *
37
- * @since 1.5.0
38
- */
39
- protected $buffer_output;
40
-
41
- /**
42
- * 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.5.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.5.0
62
- */
63
- public function load_configuration() {
64
- add_action( 'wp_loaded', array( $this, 'cookiebot_addon_google_analytics_async' ), 5 );
65
- }
66
-
67
- /**
68
- * Disable scripts if state not accepted
69
- *
70
- * @since 1.5.0
71
- */
72
- public function cookiebot_addon_google_analytics_async() {
73
- // Disable Analytify if cookie consent not allowed
74
- $this->buffer_output->add_tag( 'wp_head', 10, array(
75
- 'GoogleAnalyticsObject' => $this->get_cookie_types(),
76
- ), false );
77
- }
78
-
79
- /**
80
- * Return addon/plugin name
81
- *
82
- * @return string
83
- *
84
- * @since 1.5.0
85
- */
86
- public function get_addon_name() {
87
- return 'Google Analytics +';
88
- }
89
-
90
- /**
91
- * Option name in the database
92
- *
93
- * @return string
94
- *
95
- * @since 1.5.0
96
- */
97
- public function get_option_name() {
98
- return 'google_analytics_plus';
99
- }
100
-
101
- /**
102
- * Plugin file name
103
- *
104
- * @return string
105
- *
106
- * @since 1.5.0
107
- */
108
- public function get_plugin_file() {
109
- return 'google-analytics-async/google-analytics-async.php';
110
- }
111
-
112
- /**
113
- * Returns checked cookie types
114
- * @return mixed
115
- *
116
- * @since 1.5.0
117
- */
118
- public function get_cookie_types() {
119
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
120
- }
121
-
122
- /**
123
- * Returns default cookie types
124
- * @return array
125
- *
126
- * @since 1.5.0
127
- */
128
- public function get_default_cookie_types() {
129
- return array( 'statistics' );
130
- }
131
-
132
- /**
133
- * Check if plugin is activated and checked in the backend
134
- *
135
- * @since 1.5.0
136
- */
137
- public function is_addon_enabled() {
138
- return $this->settings->is_addon_enabled( $this->get_option_name() );
139
- }
140
-
141
- /**
142
- * Checks if addon is installed
143
- *
144
- * @since 1.5.0
145
- */
146
- public function is_addon_installed() {
147
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
148
- }
149
-
150
- /**
151
- * Checks if addon is activated
152
- *
153
- * @since 1.5.0
154
- */
155
- public function is_addon_activated() {
156
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
157
- }
158
-
159
- /**
160
- * Retrieves current installed version of the addon
161
- *
162
- * @return bool
163
- *
164
- * @since 2.2.1
165
- */
166
- public function get_addon_version() {
167
- return $this->settings->get_addon_version( $this->get_plugin_file() );
168
- }
169
-
170
- /**
171
- * Default placeholder content
172
- *
173
- * @return string
174
- *
175
- * @since 1.8.0
176
- */
177
- public function get_default_placeholder() {
178
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
179
- }
180
-
181
- /**
182
- * Get placeholder content
183
- *
184
- * This function will check following features:
185
- * - Current language
186
- *
187
- * @param $src
188
- *
189
- * @return bool|mixed
190
- *
191
- * @since 1.8.0
192
- */
193
- public function get_placeholder( $src = '' ) {
194
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
195
- }
196
-
197
- /**
198
- * Checks if it does have custom placeholder content
199
- *
200
- * @return mixed
201
- *
202
- * @since 1.8.0
203
- */
204
- public function has_placeholder() {
205
- return $this->settings->has_placeholder( $this->get_option_name() );
206
- }
207
-
208
- /**
209
- * returns all placeholder contents
210
- *
211
- * @return mixed
212
- *
213
- * @since 1.8.0
214
- */
215
- public function get_placeholders() {
216
- return $this->settings->get_placeholders( $this->get_option_name() );
217
- }
218
-
219
- /**
220
- * Return true if the placeholder is enabled
221
- *
222
- * @return mixed
223
- *
224
- * @since 1.8.0
225
- */
226
- public function is_placeholder_enabled() {
227
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
228
- }
229
-
230
- /**
231
- * Adds extra information under the label
232
- *
233
- * @return string
234
- *
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
- /**
242
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
243
- *
244
- * @return boolean
245
- *
246
- * @since 1.8.0
247
- */
248
- public function get_svn_url() {
249
- return false;
250
- }
251
-
252
- /**
253
- * Placeholder helper overlay in the settings page.
254
- *
255
- * @return string
256
- *
257
- * @since 1.8.0
258
- */
259
- public function get_placeholder_helper() {
260
- 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>';
261
- }
262
-
263
-
264
- /**
265
- * Returns parent class or false
266
- *
267
- * @return string|bool
268
- *
269
- * @since 2.1.3
270
- */
271
- public function get_parent_class() {
272
- return get_parent_class( $this );
273
- }
274
-
275
- /**
276
- * Action after enabling the addon on the settings page
277
- *
278
- * @since 2.2.0
279
- */
280
- public function post_hook_after_enabling() {
281
- //do nothing
282
- }
283
-
284
- /**
285
- * Cookiebot plugin is deactivated
286
- *
287
- * @since 2.2.0
288
- */
289
- public function plugin_deactivated() {
290
- //do nothing
291
- }
292
-
293
- /**
294
- * @return mixed
295
- *
296
- * @since 2.4.5
297
- */
298
- public function extra_available_addon_option() {
299
- //do nothing
300
- }
301
-
302
- /**
303
- * Returns boolean to enable/disable plugin by default
304
- *
305
- * @return bool
306
- *
307
- * @since 3.6.3
308
- */
309
- public function enable_by_default() {
310
- return false;
311
- }
312
-
313
- /**
314
- * Sets default settings for this addon
315
- *
316
- * @return array
317
- *
318
- * @since 3.6.3
319
- */
320
- public function get_default_enable_setting() {
321
- return array(
322
- 'enabled' => 1,
323
- 'cookie_type' => $this->get_default_cookie_types(),
324
- 'placeholder' => $this->get_default_placeholder(),
325
- );
326
- }
327
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/google-analytics/google-analytics.php DELETED
@@ -1,332 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\google_analytics;
4
-
5
- use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
6
- use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
7
- use cookiebot_addons\lib\Cookie_Consent_Interface;
8
- use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
9
- use cookiebot_addons\lib\Settings_Service_Interface;
10
-
11
- class Google_Analytics 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_google_analyticator' ), 5 );
65
- }
66
-
67
- /**
68
- * Check for google analyticator action hooks
69
- *
70
- * @since 1.3.0
71
- */
72
- public function cookiebot_addon_google_analyticator() {
73
-
74
- $this->buffer_output->add_tag( 'wp_footer', 10, array(
75
- 'googleanalytics_get_script' => $this->get_cookie_types(),
76
- ), false );
77
-
78
- if(has_action( 'wp_enqueue_scripts', 'Ga_Frontend::platform_sharethis' )) {
79
- $this->script_loader_tag->add_tag( GA_NAME . '-platform-sharethis', $this->get_cookie_types() );
80
- }
81
-
82
- }
83
-
84
- /**
85
- * Return addon/plugin name
86
- *
87
- * @return string
88
- *
89
- * @since 1.3.0
90
- */
91
- public function get_addon_name() {
92
- return 'Google Analytics';
93
- }
94
-
95
- /**
96
- * Option name in the database
97
- *
98
- * @return string
99
- *
100
- * @since 1.3.0
101
- */
102
- public function get_option_name() {
103
- return 'google_analytics';
104
- }
105
-
106
- /**
107
- * plugin file name
108
- *
109
- * @return string
110
- *
111
- * @since 1.3.0
112
- */
113
- public function get_plugin_file() {
114
- return 'googleanalytics/googleanalytics.php';
115
- }
116
-
117
- /**
118
- * Returns checked cookie types
119
- * @return array
120
- *
121
- * @since 1.3.0
122
- */
123
- public function get_cookie_types() {
124
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
125
- }
126
-
127
- /**
128
- * Returns default cookie types
129
- * @return array
130
- *
131
- * @since 1.5.0
132
- */
133
- public function get_default_cookie_types() {
134
- return array( 'statistics' );
135
- }
136
-
137
- /**
138
- * Check if plugin is activated and checked in the backend
139
- *
140
- * @since 1.3.0
141
- */
142
- public function is_addon_enabled() {
143
- return $this->settings->is_addon_enabled( $this->get_option_name() );
144
- }
145
-
146
- /**
147
- * Checks if addon is installed
148
- *
149
- * @since 1.3.0
150
- */
151
- public function is_addon_installed() {
152
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
153
- }
154
-
155
- /**
156
- * Checks if addon is activated
157
- *
158
- * @since 1.3.0
159
- */
160
- public function is_addon_activated() {
161
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
162
- }
163
-
164
- /**
165
- * Retrieves current installed version of the addon
166
- *
167
- * @return bool
168
- *
169
- * @since 2.2.1
170
- */
171
- public function get_addon_version() {
172
- return $this->settings->get_addon_version( $this->get_plugin_file() );
173
- }
174
-
175
- /**
176
- * Default placeholder content
177
- *
178
- * @return string
179
- *
180
- * @since 1.8.0
181
- */
182
- public function get_default_placeholder() {
183
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to track for google analytics.';
184
- }
185
-
186
- /**
187
- * Get placeholder content
188
- *
189
- * This function will check following features:
190
- * - Current language
191
- *
192
- * @param $src
193
- *
194
- * @return bool|mixed
195
- *
196
- * @since 1.8.0
197
- */
198
- public function get_placeholder( $src = '' ) {
199
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
200
- }
201
-
202
- /**
203
- * Checks if it does have custom placeholder content
204
- *
205
- * @return mixed
206
- *
207
- * @since 1.8.0
208
- */
209
- public function has_placeholder() {
210
- return $this->settings->has_placeholder( $this->get_option_name() );
211
- }
212
-
213
- /**
214
- * returns all placeholder contents
215
- *
216
- * @return mixed
217
- *
218
- * @since 1.8.0
219
- */
220
- public function get_placeholders() {
221
- return $this->settings->get_placeholders( $this->get_option_name() );
222
- }
223
-
224
- /**
225
- * Return true if the placeholder is enabled
226
- *
227
- * @return mixed
228
- *
229
- * @since 1.8.0
230
- */
231
- public function is_placeholder_enabled() {
232
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
233
- }
234
-
235
- /**
236
- * Adds extra information under the label
237
- *
238
- * @return string
239
- *
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
- /**
247
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
248
- *
249
- * @return boolean
250
- *
251
- * @since 1.8.0
252
- */
253
- public function get_svn_url() {
254
- return 'http://plugins.svn.wordpress.org/googleanalytics/trunk/googleanalytics.php';
255
- }
256
-
257
- /**
258
- * Placeholder helper overlay in the settings page.
259
- *
260
- * @return string
261
- *
262
- * @since 1.8.0
263
- */
264
- public function get_placeholder_helper() {
265
- 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>';
266
- }
267
-
268
-
269
- /**
270
- * Returns parent class or false
271
- *
272
- * @return string|bool
273
- *
274
- * @since 2.1.3
275
- */
276
- public function get_parent_class() {
277
- return get_parent_class( $this );
278
- }
279
-
280
- /**
281
- * Action after enabling the addon on the settings page
282
- *
283
- * @since 2.2.0
284
- */
285
- public function post_hook_after_enabling() {
286
- //do nothing
287
- }
288
-
289
- /**
290
- * Cookiebot plugin is deactivated
291
- *
292
- * @since 2.2.0
293
- */
294
- public function plugin_deactivated() {
295
- //do nothing
296
- }
297
-
298
- /**
299
- * @return mixed
300
- *
301
- * @since 2.4.5
302
- */
303
- public function extra_available_addon_option() {
304
- //do nothing
305
- }
306
-
307
- /**
308
- * Returns boolean to enable/disable plugin by default
309
- *
310
- * @return bool
311
- *
312
- * @since 3.6.3
313
- */
314
- public function enable_by_default() {
315
- return false;
316
- }
317
-
318
- /**
319
- * Sets default settings for this addon
320
- *
321
- * @return array
322
- *
323
- * @since 3.6.3
324
- */
325
- public function get_default_enable_setting() {
326
- return array(
327
- 'enabled' => 1,
328
- 'cookie_type' => $this->get_default_cookie_types(),
329
- 'placeholder' => $this->get_default_placeholder(),
330
- );
331
- }
332
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/google-site-kit/google-site-kit.php DELETED
@@ -1,331 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\google_site_kit;
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 Google_Site_Kit 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(
52
- Settings_Service_Interface $settings,
53
- Script_Loader_Tag_Interface $script_loader_tag,
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
- /**
64
- * Loads addon configuration
65
- *
66
- * @since 1.3.0
67
- */
68
- public function load_configuration() {
69
- add_action( 'wp_loaded', array( $this, 'cookiebot_addon_google_site_kit' ), 5 );
70
- }
71
-
72
- /**
73
- * Disable scripts if state not accepted
74
- *
75
- * @since 1.3.0
76
- */
77
- public function cookiebot_addon_google_site_kit() {
78
- // Google Tag Manager
79
- $this->script_loader_tag->add_tag( 'google_gtagjs', $this->get_cookie_types() );
80
- }
81
-
82
- /**
83
- * Return addon/plugin name
84
- *
85
- * @return string
86
- *
87
- * @since 1.3.0
88
- */
89
- public function get_addon_name() {
90
- return 'Google Site Kit';
91
- }
92
-
93
- /**
94
- * Default placeholder content
95
- *
96
- * @return string
97
- *
98
- * @since 1.8.0
99
- */
100
- public function get_default_placeholder() {
101
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to enable Google Analytics.';
102
- }
103
-
104
- /**
105
- * Get placeholder content
106
- *
107
- * This function will check following features:
108
- * - Current language
109
- *
110
- * @param $src
111
- *
112
- * @return bool|mixed
113
- *
114
- * @since 1.8.0
115
- */
116
- public function get_placeholder( $src = '' ) {
117
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(),
118
- cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
119
- }
120
-
121
- /**
122
- * Option name in the database
123
- *
124
- * @return string
125
- *
126
- * @since 1.3.0
127
- */
128
- public function get_option_name() {
129
- return 'google_site_kit';
130
- }
131
-
132
- /**
133
- * Plugin file name
134
- *
135
- * @return string
136
- *
137
- * @since 1.3.0
138
- */
139
- public function get_plugin_file() {
140
- return 'google-site-kit/google-site-kit.php';
141
- }
142
-
143
- /**
144
- * Returns checked cookie types
145
- * @return mixed
146
- *
147
- * @since 1.3.0
148
- */
149
- public function get_cookie_types() {
150
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
151
- }
152
-
153
- /**
154
- * Returns default cookie types
155
- * @return array
156
- *
157
- * @since 1.5.0
158
- */
159
- public function get_default_cookie_types() {
160
- return array( 'marketing', 'statistics' );
161
- }
162
-
163
- /**
164
- * Check if plugin is activated and checked in the backend
165
- *
166
- * @since 1.3.0
167
- */
168
- public function is_addon_enabled() {
169
- return $this->settings->is_addon_enabled( $this->get_option_name() );
170
- }
171
-
172
- /**
173
- * Checks if addon is installed
174
- *
175
- * @since 1.3.0
176
- */
177
- public function is_addon_installed() {
178
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
179
- }
180
-
181
- /**
182
- * Checks if addon is activated
183
- *
184
- * @since 1.3.0
185
- */
186
- public function is_addon_activated() {
187
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
188
- }
189
-
190
- /**
191
- * Retrieves current installed version of the addon
192
- *
193
- * @return bool
194
- *
195
- * @since 2.2.1
196
- */
197
- public function get_addon_version() {
198
- return $this->settings->get_addon_version( $this->get_plugin_file() );
199
- }
200
-
201
- /**
202
- * Checks if it does have custom placeholder content
203
- *
204
- * @return mixed
205
- *
206
- * @since 1.8.0
207
- */
208
- public function has_placeholder() {
209
- return $this->settings->has_placeholder( $this->get_option_name() );
210
- }
211
-
212
- /**
213
- * returns all placeholder contents
214
- *
215
- * @return mixed
216
- *
217
- * @since 1.8.0
218
- */
219
- public function get_placeholders() {
220
- return $this->settings->get_placeholders( $this->get_option_name() );
221
- }
222
-
223
- /**
224
- * Return true if the placeholder is enabled
225
- *
226
- * @return mixed
227
- *
228
- * @since 1.8.0
229
- */
230
- public function is_placeholder_enabled() {
231
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
232
- }
233
-
234
- /**
235
- * Adds extra information under the label
236
- *
237
- * @return string
238
- *
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
- /**
246
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
247
- *
248
- * @return string
249
- *
250
- * @since 1.8.0
251
- */
252
- public function get_svn_url() {
253
- return 'http://plugins.svn.wordpress.org/google-site-kit/trunk/google-site-kit.php';
254
- }
255
-
256
- /**
257
- * Placeholder helper overlay in the settings page.
258
- *
259
- * @return string
260
- *
261
- * @since 1.8.0
262
- */
263
- public function get_placeholder_helper() {
264
- 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>';
265
- }
266
-
267
-
268
- /**
269
- * Returns parent class or false
270
- *
271
- * @return string|bool
272
- *
273
- * @since 2.1.3
274
- */
275
- public function get_parent_class() {
276
- return get_parent_class( $this );
277
- }
278
-
279
- /**
280
- * Action after enabling the addon on the settings page
281
- *
282
- * @since 2.2.0
283
- */
284
- public function post_hook_after_enabling() {
285
- //do nothing
286
- }
287
-
288
- /**
289
- * Cookiebot plugin is deactivated
290
- *
291
- * @since 2.2.0
292
- */
293
- public function plugin_deactivated() {
294
- //do nothing
295
- }
296
-
297
- /**
298
- * @return mixed
299
- *
300
- * @since 2.4.5
301
- */
302
- public function extra_available_addon_option() {
303
- //do nothing
304
- }
305
-
306
- /**
307
- * Returns boolean to enable/disable plugin by default
308
- *
309
- * @return bool
310
- *
311
- * @since 3.6.3
312
- */
313
- public function enable_by_default() {
314
- return false;
315
- }
316
-
317
- /**
318
- * Sets default settings for this addon
319
- *
320
- * @return array
321
- *
322
- * @since 3.6.3
323
- */
324
- public function get_default_enable_setting() {
325
- return array(
326
- 'enabled' => 1,
327
- 'cookie_type' => $this->get_default_cookie_types(),
328
- 'placeholder' => $this->get_default_placeholder(),
329
- );
330
- }
331
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/hubspot-leadin/hubspot-leadin.php DELETED
@@ -1,336 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\hubspot_leadin;
4
-
5
- use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
6
- use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
7
- use cookiebot_addons\lib\Cookie_Consent_Interface;
8
- use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
9
- use cookiebot_addons\lib\Settings_Service_Interface;
10
-
11
- class Hubspot_Leadin 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
- /**
65
- * We add the action after wp_loaded and replace the original
66
- * HubSpot Tracking Code action with our own adjusted version.
67
- */
68
- add_action( 'wp_loaded', array( $this, 'cookiebot_addon_hubspot_tracking_code' ), 10 );
69
- }
70
-
71
- /**
72
- * Manipulate the scripts if they are loaded.
73
- *
74
- * @since 1.3.0
75
- */
76
- public function cookiebot_addon_hubspot_tracking_code() {
77
-
78
- // block the script untill the consent is given
79
-
80
- if(version_compare(LEADIN_PLUGIN_VERSION,'7.10.0','>=')) {
81
- $this->script_loader_tag->add_tag( 'leadin-script-loader-js', $this->get_cookie_types() );
82
- }
83
- else {
84
- $this->script_loader_tag->add_tag( 'leadin-scriptloader-js', $this->get_cookie_types() );
85
- }
86
- }
87
-
88
- /**
89
- * Return addon/plugin name
90
- *
91
- * @return string
92
- *
93
- * @since 1.3.0
94
- */
95
- public function get_addon_name() {
96
- return 'HubSpot - Free Marketing Plugin for WordPress';
97
- }
98
-
99
- /**
100
- * Option name in the database
101
- *
102
- * @return string
103
- *
104
- * @since 1.3.0
105
- */
106
- public function get_option_name() {
107
- return 'hubspot_leadin';
108
- }
109
-
110
- /**
111
- * Plugin file name
112
- *
113
- * @return string
114
- *
115
- * @since 1.3.0
116
- */
117
- public function get_plugin_file() {
118
- return 'leadin/leadin.php';
119
- }
120
-
121
- /**
122
- * Returns checked cookie types
123
- * @return mixed
124
- *
125
- * @since 1.3.0
126
- */
127
- public function get_cookie_types() {
128
- return $this->settings->get_cookie_types( $this->get_option_name() );
129
- }
130
-
131
- /**
132
- * Returns default cookie types
133
- * @return array
134
- *
135
- * @since 1.5.0
136
- */
137
- public function get_default_cookie_types() {
138
- return array( 'marketing', 'statistics' );
139
- }
140
-
141
-
142
- /**
143
- * Check if plugin is activated and checked in the backend
144
- *
145
- * @since 1.3.0
146
- */
147
- public function is_addon_enabled() {
148
- return $this->settings->is_addon_enabled( $this->get_option_name() );
149
- }
150
-
151
- /**
152
- * Checks if addon is installed
153
- *
154
- * @since 1.3.0
155
- */
156
- public function is_addon_installed() {
157
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
158
- }
159
-
160
- /**
161
- * Checks if addon is activated
162
- *
163
- * @since 1.3.0
164
- */
165
- public function is_addon_activated() {
166
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
167
- }
168
-
169
- /**
170
- * Retrieves current installed version of the addon
171
- *
172
- * @return bool
173
- *
174
- * @since 2.2.1
175
- */
176
- public function get_addon_version() {
177
- return $this->settings->get_addon_version( $this->get_plugin_file() );
178
- }
179
-
180
- /**
181
- * Default placeholder content
182
- *
183
- * @return string
184
- *
185
- * @since 1.8.0
186
- */
187
- public function get_default_placeholder() {
188
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
189
- }
190
-
191
- /**
192
- * Get placeholder content
193
- *
194
- * This function will check following features:
195
- * - Current language
196
- *
197
- * @param $src
198
- *
199
- * @return bool|mixed
200
- *
201
- * @since 1.8.0
202
- */
203
- public function get_placeholder( $src = '' ) {
204
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
205
- }
206
-
207
- /**
208
- * Checks if it does have custom placeholder content
209
- *
210
- * @return mixed
211
- *
212
- * @since 1.8.0
213
- */
214
- public function has_placeholder() {
215
- return $this->settings->has_placeholder( $this->get_option_name() );
216
- }
217
-
218
- /**
219
- * returns all placeholder contents
220
- *
221
- * @return mixed
222
- *
223
- * @since 1.8.0
224
- */
225
- public function get_placeholders() {
226
- return $this->settings->get_placeholders( $this->get_option_name() );
227
- }
228
-
229
- /**
230
- * Return true if the placeholder is enabled
231
- *
232
- * @return mixed
233
- *
234
- * @since 1.8.0
235
- */
236
- public function is_placeholder_enabled() {
237
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
238
- }
239
-
240
- /**
241
- * Adds extra information under the label
242
- *
243
- * @return string
244
- *
245
- * @since 1.8.0
246
- */
247
- public function get_extra_information() {
248
- return false;
249
- }
250
-
251
- /**
252
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
253
- *
254
- * @return boolean
255
- *
256
- * @since 1.8.0
257
- */
258
- public function get_svn_url() {
259
- return 'http://plugins.svn.wordpress.org/leadin/trunk/leadin.php';
260
- }
261
-
262
- /**
263
- * Placeholder helper overlay in the settings page.
264
- *
265
- * @return string
266
- *
267
- * @since 1.8.0
268
- */
269
- public function get_placeholder_helper() {
270
- 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>';
271
- }
272
-
273
- /**
274
- * Returns parent class or false
275
- *
276
- * @return string|bool
277
- *
278
- * @since 2.1.3
279
- */
280
- public function get_parent_class() {
281
- return get_parent_class( $this );
282
- }
283
-
284
- /**
285
- * Action after enabling the addon on the settings page
286
- *
287
- * @since 2.2.0
288
- */
289
- public function post_hook_after_enabling() {
290
- //do nothing
291
- }
292
-
293
- /**
294
- * Cookiebot plugin is deactivated
295
- *
296
- * @since 2.2.0
297
- */
298
- public function plugin_deactivated() {
299
- //do nothing
300
- }
301
-
302
- /**
303
- * @return mixed
304
- *
305
- * @since 2.4.5
306
- */
307
- public function extra_available_addon_option() {
308
- //do nothing
309
- }
310
-
311
- /**
312
- * Returns boolean to enable/disable plugin by default
313
- *
314
- * @return bool
315
- *
316
- * @since 3.6.3
317
- */
318
- public function enable_by_default() {
319
- return false;
320
- }
321
-
322
- /**
323
- * Sets default settings for this addon
324
- *
325
- * @return array
326
- *
327
- * @since 3.6.3
328
- */
329
- public function get_default_enable_setting() {
330
- return array(
331
- 'enabled' => 1,
332
- 'cookie_type' => $this->get_default_cookie_types(),
333
- 'placeholder' => $this->get_default_placeholder(),
334
- );
335
- }
336
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/hubspot-tracking-code/hubspot-tracking-code.php DELETED
@@ -1,343 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\hubspot_tracking_code;
4
-
5
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
6
-
7
- use cookiebot_addons\controller\addons\Cookiebot_Addons_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\buffer\Buffer_Output_Interface;
11
- use cookiebot_addons\lib\Settings_Service_Interface;
12
-
13
- class Hubspot_Tracking_Code implements Cookiebot_Addons_Interface {
14
-
15
- /**
16
- * @var Settings_Service_Interface
17
- *
18
- * @since 1.3.0
19
- */
20
- protected $settings;
21
-
22
- /**
23
- * @var Script_Loader_Tag_Interface
24
- *
25
- * @since 1.3.0
26
- */
27
- protected $script_loader_tag;
28
-
29
- /**
30
- * @var Cookie_Consent_Interface
31
- *
32
- * @since 1.3.0
33
- */
34
- public $cookie_consent;
35
-
36
- /**
37
- * @var Buffer_Output_Interface
38
- *
39
- * @since 1.3.0
40
- */
41
- protected $buffer_output;
42
-
43
- /**
44
- * Jetpack constructor.
45
- *
46
- * @param $settings Settings_Service_Interface
47
- * @param $script_loader_tag Script_Loader_Tag_Interface
48
- * @param $cookie_consent Cookie_Consent_Interface
49
- * @param $buffer_output Buffer_Output_Interface
50
- *
51
- * @since 1.3.0
52
- */
53
- public function __construct( Settings_Service_Interface $settings, Script_Loader_Tag_Interface $script_loader_tag, Cookie_Consent_Interface $cookie_consent, Buffer_Output_Interface $buffer_output ) {
54
- $this->settings = $settings;
55
- $this->script_loader_tag = $script_loader_tag;
56
- $this->cookie_consent = $cookie_consent;
57
- $this->buffer_output = $buffer_output;
58
- }
59
-
60
- /**
61
- * Loads addon configuration
62
- *
63
- * @since 1.3.0
64
- */
65
- public function load_configuration() {
66
- /**
67
- * We add the action after wp_loaded and replace the original
68
- * HubSpot Tracking Code action with our own adjusted version.
69
- */
70
- add_action( 'wp_loaded', array( $this, 'cookiebot_addon_hubspot_tracking_code' ), 10 );
71
- }
72
-
73
- /**
74
- * Manipulate the scripts if they are loaded.
75
- *
76
- * @since 1.3.0
77
- */
78
- public function cookiebot_addon_hubspot_tracking_code() {
79
- // Check if HubSpot Tracking Code is loaded
80
- $options = get_option( 'hs_settings' );
81
- if ( ! isset( $options['hs_portal'] ) || $options['hs_portal'] == '' ) {
82
- return;
83
- }
84
-
85
- // Replace original HubSpot Tracking Code with own one and delete cookie if
86
- // it was perviously set.
87
-
88
- $this->buffer_output->add_tag( 'wp_footer', 10, array( 'hs-script-loader' => $this->get_cookie_types() ), false );
89
-
90
- if ( ! $this->cookie_consent->are_cookie_states_accepted( $this->get_cookie_types() ) && isset( $_COOKIE['hubspotutk'] ) ) {
91
- unset( $_COOKIE['hubspotutk'] );
92
- }
93
-
94
- }
95
-
96
- /**
97
- * Return addon/plugin name
98
- *
99
- * @return string
100
- *
101
- * @since 1.3.0
102
- */
103
- public function get_addon_name() {
104
- return 'Hubspot Tracking Code';
105
- }
106
-
107
- /**
108
- * Option name in the database
109
- *
110
- * @return string
111
- *
112
- * @since 1.3.0
113
- */
114
- public function get_option_name() {
115
- return 'hubspot_tracking_code';
116
- }
117
-
118
- /**
119
- * Plugin file name
120
- *
121
- * @return string
122
- *
123
- * @since 1.3.0
124
- */
125
- public function get_plugin_file() {
126
- return 'hubspot-tracking-code/hubspot-tracking-code.php';
127
- }
128
-
129
- /**
130
- * Returns checked cookie types
131
- * @return mixed
132
- *
133
- * @since 1.3.0
134
- */
135
- public function get_cookie_types() {
136
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
137
- }
138
-
139
- /**
140
- * Returns default cookie types
141
- * @return array
142
- *
143
- * @since 1.5.0
144
- */
145
- public function get_default_cookie_types() {
146
- return array( 'marketing', 'statistics' );
147
- }
148
-
149
- /**
150
- * Check if plugin is activated and checked in the backend
151
- *
152
- * @since 1.3.0
153
- */
154
- public function is_addon_enabled() {
155
- return $this->settings->is_addon_enabled( $this->get_option_name() );
156
- }
157
-
158
- /**
159
- * Checks if addon is installed
160
- *
161
- * @since 1.3.0
162
- */
163
- public function is_addon_installed() {
164
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
165
- }
166
-
167
- /**
168
- * Checks if addon is activated
169
- *
170
- * @since 1.3.0
171
- */
172
- public function is_addon_activated() {
173
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
174
- }
175
-
176
- /**
177
- * Retrieves current installed version of the addon
178
- *
179
- * @return bool
180
- *
181
- * @since 2.2.1
182
- */
183
- public function get_addon_version() {
184
- return $this->settings->get_addon_version( $this->get_plugin_file() );
185
- }
186
-
187
- /**
188
- * Default placeholder content
189
- *
190
- * @return string
191
- *
192
- * @since 1.8.0
193
- */
194
- public function get_default_placeholder() {
195
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
196
- }
197
-
198
- /**
199
- * Get placeholder content
200
- *
201
- * This function will check following features:
202
- * - Current language
203
- *
204
- * @param $src
205
- *
206
- * @return bool|mixed
207
- *
208
- * @since 1.8.0
209
- */
210
- public function get_placeholder( $src = '' ) {
211
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
212
- }
213
-
214
- /**
215
- * Checks if it does have custom placeholder content
216
- *
217
- * @return mixed
218
- *
219
- * @since 1.8.0
220
- */
221
- public function has_placeholder() {
222
- return $this->settings->has_placeholder( $this->get_option_name() );
223
- }
224
-
225
- /**
226
- * returns all placeholder contents
227
- *
228
- * @return mixed
229
- *
230
- * @since 1.8.0
231
- */
232
- public function get_placeholders() {
233
- return $this->settings->get_placeholders( $this->get_option_name() );
234
- }
235
-
236
- /**
237
- * Return true if the placeholder is enabled
238
- *
239
- * @return mixed
240
- *
241
- * @since 1.8.0
242
- */
243
- public function is_placeholder_enabled() {
244
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
245
- }
246
-
247
- /**
248
- * Adds extra information under the label
249
- *
250
- * @return string
251
- *
252
- * @since 1.8.0
253
- */
254
- public function get_extra_information() {
255
- return false;
256
- }
257
-
258
- /**
259
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
260
- *
261
- * @return boolean
262
- *
263
- * @since 1.8.0
264
- */
265
- public function get_svn_url() {
266
- return 'http://plugins.svn.wordpress.org/hubspot-tracking-code/trunk/hubspot-tracking-code.php';
267
- }
268
-
269
- /**
270
- * Placeholder helper overlay in the settings page.
271
- *
272
- * @return string
273
- *
274
- * @since 1.8.0
275
- */
276
- public function get_placeholder_helper() {
277
- 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>';
278
- }
279
-
280
- /**
281
- * Returns parent class or false
282
- *
283
- * @return string|bool
284
- *
285
- * @since 2.1.3
286
- */
287
- public function get_parent_class() {
288
- return get_parent_class( $this );
289
- }
290
-
291
- /**
292
- * Action after enabling the addon on the settings page
293
- *
294
- * @since 2.2.0
295
- */
296
- public function post_hook_after_enabling() {
297
- //do nothing
298
- }
299
-
300
- /**
301
- * Cookiebot plugin is deactivated
302
- *
303
- * @since 2.2.0
304
- */
305
- public function plugin_deactivated() {
306
- //do nothing
307
- }
308
-
309
- /**
310
- * @return mixed
311
- *
312
- * @since 2.4.5
313
- */
314
- public function extra_available_addon_option() {
315
- //do nothing
316
- }
317
-
318
- /**
319
- * Returns boolean to enable/disable plugin by default
320
- *
321
- * @return bool
322
- *
323
- * @since 3.6.3
324
- */
325
- public function enable_by_default() {
326
- return false;
327
- }
328
-
329
- /**
330
- * Sets default settings for this addon
331
- *
332
- * @return array
333
- *
334
- * @since 3.6.3
335
- */
336
- public function get_default_enable_setting() {
337
- return array(
338
- 'enabled' => 1,
339
- 'cookie_type' => $this->get_default_cookie_types(),
340
- 'placeholder' => $this->get_default_placeholder(),
341
- );
342
- }
343
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/instagram-feed/instagram-feed.php DELETED
@@ -1,326 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\instagram_feed;
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 Instagram_Feed 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_sb_instagram' ), 5 );
65
- }
66
-
67
- /**
68
- * Disable scripts if state not accepted
69
- *
70
- * @since 1.3.0
71
- */
72
- public function cookiebot_addon_sb_instagram() {
73
- // External js, so manipulate attributes
74
- if ( has_action( 'wp_enqueue_scripts', 'sb_instagram_scripts_enqueue' ) ) {
75
- $this->script_loader_tag->add_tag( 'sb_instagram_scripts', $this->get_cookie_types() );
76
- }
77
- }
78
-
79
- /**
80
- * Return addon/plugin name
81
- *
82
- * @return string
83
- *
84
- * @since 1.3.0
85
- */
86
- public function get_addon_name() {
87
- return 'Instagram feed';
88
- }
89
-
90
- /**
91
- * Option name in the database
92
- *
93
- * @return string
94
- *
95
- * @since 1.3.0
96
- */
97
- public function get_option_name() {
98
- return 'instagram feed';
99
- }
100
-
101
- /**
102
- * Plugin file name
103
- *
104
- * @return string
105
- *
106
- * @since 1.3.0
107
- */
108
- public function get_plugin_file() {
109
- return 'instagram-feed/instagram-feed.php';
110
- }
111
-
112
- /**
113
- * Returns checked cookie types
114
- * @return mixed
115
- *
116
- * @since 1.3.0
117
- */
118
- public function get_cookie_types() {
119
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
120
- }
121
-
122
- /**
123
- * Returns default cookie types
124
- * @return array
125
- *
126
- * @since 1.5.0
127
- */
128
- public function get_default_cookie_types() {
129
- return array( 'marketing' );
130
- }
131
-
132
- /**
133
- * Check if plugin is activated and checked in the backend
134
- *
135
- * @since 1.3.0
136
- */
137
- public function is_addon_enabled() {
138
- return $this->settings->is_addon_enabled( $this->get_option_name() );
139
- }
140
-
141
- /**
142
- * Checks if addon is installed
143
- *
144
- * @since 1.3.0
145
- */
146
- public function is_addon_installed() {
147
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
148
- }
149
-
150
- /**
151
- * Checks if addon is activated
152
- *
153
- * @since 1.3.0
154
- */
155
- public function is_addon_activated() {
156
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
157
- }
158
-
159
- /**
160
- * Retrieves current installed version of the addon
161
- *
162
- * @return bool
163
- *
164
- * @since 2.2.1
165
- */
166
- public function get_addon_version() {
167
- return $this->settings->get_addon_version( $this->get_plugin_file() );
168
- }
169
-
170
- /**
171
- * Default placeholder content
172
- *
173
- * @return string
174
- *
175
- * @since 1.8.0
176
- */
177
- public function get_default_placeholder() {
178
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
179
- }
180
-
181
- /**
182
- * Get placeholder content
183
- *
184
- * This function will check following features:
185
- * - Current language
186
- *
187
- * @param $src
188
- *
189
- * @return bool|mixed
190
- *
191
- * @since 1.8.0
192
- */
193
- public function get_placeholder( $src = '' ) {
194
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
195
- }
196
-
197
- /**
198
- * Checks if it does have custom placeholder content
199
- *
200
- * @return mixed
201
- *
202
- * @since 1.8.0
203
- */
204
- public function has_placeholder() {
205
- return $this->settings->has_placeholder( $this->get_option_name() );
206
- }
207
-
208
- /**
209
- * returns all placeholder contents
210
- *
211
- * @return mixed
212
- *
213
- * @since 1.8.0
214
- */
215
- public function get_placeholders() {
216
- return $this->settings->get_placeholders( $this->get_option_name() );
217
- }
218
-
219
- /**
220
- * Return true if the placeholder is enabled
221
- *
222
- * @return mixed
223
- *
224
- * @since 1.8.0
225
- */
226
- public function is_placeholder_enabled() {
227
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
228
- }
229
-
230
- /**
231
- * Adds extra information under the label
232
- *
233
- * @return string
234
- *
235
- * @since 1.8.0
236
- */
237
- public function get_extra_information() {
238
- return false;
239
- }
240
-
241
- /**
242
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
243
- *
244
- * @return boolean
245
- *
246
- * @since 1.8.0
247
- */
248
- public function get_svn_url() {
249
- return 'http://plugins.svn.wordpress.org/instagram-feed/trunk/instagram-feed.php';
250
- }
251
-
252
- /**
253
- * Placeholder helper overlay in the settings page.
254
- *
255
- * @return string
256
- *
257
- * @since 1.8.0
258
- */
259
- public function get_placeholder_helper() {
260
- 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>';
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/jetpack/jetpack.php DELETED
@@ -1,433 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\jetpack;
4
-
5
- use cookiebot_addons\controller\addons\jetpack\widget\Google_Maps_Widget;
6
- use cookiebot_addons\controller\addons\jetpack\widget\Facebook_Widget;
7
- use cookiebot_addons\controller\addons\jetpack\widget\Googleplus_Badge_Widget;
8
- use cookiebot_addons\controller\addons\jetpack\widget\Goodreads_Widget;
9
- use cookiebot_addons\controller\addons\jetpack\widget\Internet_Defense_league_Widget;
10
- use cookiebot_addons\controller\addons\jetpack\widget\Twitter_Timeline_Widget;
11
- use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
12
- use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
13
- use cookiebot_addons\lib\Cookie_Consent_Interface;
14
- use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
15
- use cookiebot_addons\lib\Settings_Service_Interface;
16
-
17
- /**
18
- * This class is used to support jetpack in cookiebot
19
- *
20
- * Class Jetpack
21
- * @package cookiebot_addons\controller\addons\jetpack
22
- *
23
- * @since 1.3.0
24
- */
25
- class Jetpack implements Cookiebot_Addons_Interface {
26
-
27
- /**
28
- * @var Settings_Service_Interface
29
- *
30
- * @since 1.3.0
31
- */
32
- protected $settings;
33
-
34
- /**
35
- * @var Script_Loader_Tag_Interface
36
- *
37
- * @since 1.3.0
38
- */
39
- protected $script_loader_tag;
40
-
41
- /**
42
- * @var Cookie_Consent_Interface
43
- *
44
- * @since 1.3.0
45
- */
46
- public $cookie_consent;
47
-
48
- /**
49
- * @var Buffer_Output_Interface
50
- *
51
- * @since 1.3.0
52
- */
53
- protected $buffer_output;
54
-
55
- protected $widgets = array();
56
-
57
- /**
58
- * Jetpack constructor.
59
- *
60
- * @param $settings Settings_Service_Interface
61
- * @param $script_loader_tag Script_Loader_Tag_Interface
62
- * @param $cookie_consent Cookie_Consent_Interface
63
- * @param $buffer_output Buffer_Output_Interface
64
- *
65
- * @since 1.2.0
66
- */
67
- public function __construct( Settings_Service_Interface $settings, Script_Loader_Tag_Interface $script_loader_tag, Cookie_Consent_Interface $cookie_consent, Buffer_Output_Interface $buffer_output ) {
68
- $this->settings = $settings;
69
- $this->script_loader_tag = $script_loader_tag;
70
- $this->cookie_consent = $cookie_consent;
71
- $this->buffer_output = $buffer_output;
72
-
73
- // set widgets
74
- if($this->is_addon_enabled()) {
75
- $this->set_widgets();
76
- }
77
- }
78
-
79
- /**
80
- * Loads addon configuration
81
- *
82
- * @since 1.3.0
83
- */
84
- public function load_configuration() {
85
- // load widgets
86
- $this->load_widgets();
87
- }
88
-
89
- /**
90
- * Sets every widget into this class
91
- *
92
- * @since 1.8.0
93
- */
94
- public function set_widgets() {
95
- /**
96
- * Load configuration for google maps widget
97
- *
98
- * @since 1.2.0
99
- */
100
- $this->widgets[] = new Google_Maps_Widget( $this->settings, $this->script_loader_tag, $this->cookie_consent, $this->buffer_output, $this->get_widget_option() );
101
-
102
- /**
103
- * Load configuration for internet defense league widget
104
- *
105
- * @since 1.2.0
106
- */
107
- $this->widgets[] = new Internet_Defense_league_Widget( $this->settings, $this->script_loader_tag, $this->cookie_consent, $this->buffer_output, $this->get_widget_option() );
108
-
109
- /**
110
- * Load configuration for visitor cookies
111
- *
112
- * @since 1.2.0
113
- */
114
- $this->widgets[] = new Visitor_Cookies( $this->settings, $this->script_loader_tag, $this->cookie_consent, $this->buffer_output, $this->get_widget_option() );
115
-
116
- /**
117
- * Load configuration for twitter timeline widget
118
- *
119
- * @since 1.2.0
120
- */
121
- $this->widgets[] = new Twitter_Timeline_Widget( $this->settings, $this->script_loader_tag, $this->cookie_consent, $this->buffer_output, $this->get_widget_option() );
122
-
123
- /**
124
- * Load configuration for goodreads widget
125
- *
126
- * @since 1.2.0
127
- */
128
- $this->widgets[] = new Goodreads_Widget( $this->settings, $this->script_loader_tag, $this->cookie_consent, $this->buffer_output, $this->get_widget_option() );
129
-
130
- /**
131
- * Load configuration for facebook widget
132
- *
133
- * @since 1.2.0
134
- */
135
- $this->widgets[] = new Facebook_Widget( $this->settings, $this->script_loader_tag, $this->cookie_consent, $this->buffer_output, $this->get_widget_option() );
136
-
137
- /**
138
- * If jetpack version is lower than 7 than add googleplus badge widget
139
- *
140
- * @since 2.2.1
141
- */
142
- if( version_compare($this->get_addon_version(), '7', '<' ) ) {
143
- /**
144
- * Load configuration for googleplus badge widget
145
- *
146
- * @since 1.2.0
147
- */
148
- $this->widgets[] = new Googleplus_Badge_Widget( $this->settings, $this->script_loader_tag, $this->cookie_consent, $this->buffer_output, $this->get_widget_option() );
149
- }
150
- }
151
-
152
- /**
153
- * Load widgets configuration
154
- *
155
- * @since 1.8.0
156
- */
157
- public function load_widgets() {
158
- foreach( $this->get_widgets() as $widget ) {
159
- $widget->load_configuration();
160
- }
161
- }
162
-
163
- /**
164
- * Return addon/plugin name
165
- *
166
- * @return string
167
- *
168
- * @since 1.3.0
169
- */
170
- public function get_addon_name() {
171
- return 'Jetpack';
172
- }
173
-
174
- /**
175
- * Option name in the database
176
- *
177
- * @return string
178
- *
179
- * @since 1.3.0
180
- */
181
- public function get_option_name() {
182
- return 'jetpack';
183
- }
184
-
185
- /**
186
- * Returns widget option key for in the database
187
- *
188
- * @return string
189
- *
190
- * @since 1.3.0
191
- */
192
- public function get_widget_option() {
193
- return 'cookiebot_jetpack_addon';
194
- }
195
-
196
- /**
197
- * Plugin file name
198
- *
199
- * @return string
200
- *
201
- * @since 1.3.0
202
- */
203
- public function get_plugin_file() {
204
- return 'jetpack/jetpack.php';
205
- }
206
-
207
- /**
208
- * Returns checked cookie types
209
- * @return mixed
210
- *
211
- * @since 1.3.0
212
- */
213
- public function get_cookie_types() {
214
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
215
- }
216
-
217
- /**
218
- * Returns default cookie types
219
- * @return array
220
- *
221
- * @since 1.5.0
222
- */
223
- public function get_default_cookie_types() {
224
- return array( 'statistics' );
225
- }
226
-
227
- /**
228
- * Check if plugin is activated and checked in the backend
229
- *
230
- * @since 1.3.0
231
- */
232
- public function is_addon_enabled() {
233
- return $this->settings->is_addon_enabled( $this->get_option_name() );
234
- }
235
-
236
- /**
237
- * Checks if addon is installed
238
- *
239
- * @since 1.3.0
240
- */
241
- public function is_addon_installed() {
242
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
243
- }
244
-
245
- /**
246
- * Checks if addon is activated
247
- *
248
- * @since 1.3.0
249
- */
250
- public function is_addon_activated() {
251
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
252
- }
253
-
254
- /**
255
- * Retrieves current installed version of the addon
256
- *
257
- * @return bool
258
- *
259
- * @since 2.2.1
260
- */
261
- public function get_addon_version() {
262
- return $this->settings->get_addon_version( $this->get_plugin_file() );
263
- }
264
-
265
- /**
266
- * Returns all supported widgets
267
- *
268
- * @return array
269
- *
270
- * @since 1.3.0
271
- */
272
- public function get_widgets() {
273
- return $this->widgets;
274
- }
275
-
276
- /**
277
- * Default placeholder content
278
- *
279
- * @return string
280
- *
281
- * @since 1.8.0
282
- */
283
- public function get_default_placeholder() {
284
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
285
- }
286
-
287
- /**
288
- * Get placeholder content
289
- *
290
- * This function will check following features:
291
- * - Current language
292
- *
293
- * @param $src
294
- *
295
- * @return bool|mixed
296
- *
297
- * @since 1.8.0
298
- */
299
- public function get_placeholder( $src = '' ) {
300
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
301
- }
302
-
303
- /**
304
- * Checks if it does have custom placeholder content
305
- *
306
- * @return mixed
307
- *
308
- * @since 1.8.0
309
- */
310
- public function has_placeholder() {
311
- return $this->settings->has_placeholder( $this->get_option_name() );
312
- }
313
-
314
- /**
315
- * returns all placeholder contents
316
- *
317
- * @return mixed
318
- *
319
- * @since 1.8.0
320
- */
321
- public function get_placeholders() {
322
- return $this->settings->get_placeholders( $this->get_option_name() );
323
- }
324
-
325
- /**
326
- * Return true if the placeholder is enabled
327
- *
328
- * @return mixed
329
- *
330
- * @since 1.8.0
331
- */
332
- public function is_placeholder_enabled() {
333
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
334
- }
335
-
336
- /**
337
- * Adds extra information under the label
338
- *
339
- * @return string
340
- *
341
- * @since 1.8.0
342
- */
343
- public function get_extra_information() {
344
- return false;
345
- }
346
-
347
- /**
348
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
349
- *
350
- * @return boolean
351
- *
352
- * @since 1.8.0
353
- */
354
- public function get_svn_url() {
355
- return 'http://plugins.svn.wordpress.org/jetpack/trunk/jetpack.php';
356
- }
357
-
358
- /**
359
- * Placeholder helper overlay in the settings page.
360
- *
361
- * @return string
362
- *
363
- * @since 1.8.0
364
- */
365
- public function get_placeholder_helper() {
366
- 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>';
367
- }
368
-
369
-
370
- /**
371
- * Returns parent class or false
372
- *
373
- * @return string|bool
374
- *
375
- * @since 2.1.3
376
- */
377
- public function get_parent_class() {
378
- return get_parent_class( $this );
379
- }
380
-
381
- /**
382
- * Action after enabling the addon on the settings page
383
- *
384
- * @since 2.2.0
385
- */
386
- public function post_hook_after_enabling() {
387
- //do nothing
388
- }
389
-
390
- /**
391
- * Cookiebot plugin is deactivated
392
- *
393
- * @since 2.2.0
394
- */
395
- public function plugin_deactivated() {
396
- //do nothing
397
- }
398
-
399
- /**
400
- * @return mixed
401
- *
402
- * @since 2.4.5
403
- */
404
- public function extra_available_addon_option() {
405
- //do nothing
406
- }
407
-
408
- /**
409
- * Returns boolean to enable/disable plugin by default
410
- *
411
- * @return bool
412
- *
413
- * @since 3.6.3
414
- */
415
- public function enable_by_default() {
416
- return false;
417
- }
418
-
419
- /**
420
- * Sets default settings for this addon
421
- *
422
- * @return array
423
- *
424
- * @since 3.6.3
425
- */
426
- public function get_default_enable_setting() {
427
- return array(
428
- 'enabled' => 1,
429
- 'cookie_type' => $this->get_default_cookie_types(),
430
- 'placeholder' => $this->get_default_placeholder(),
431
- );
432
- }
433
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/jetpack/visitor-cookies.php DELETED
@@ -1,287 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\jetpack;
4
-
5
- use cookiebot_addons\controller\addons\jetpack\widget\Jetpack_Widget_Interface;
6
- use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
7
- use cookiebot_addons\lib\Cookie_Consent_Interface;
8
- use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
9
- use cookiebot_addons\lib\Settings_Service_Interface;
10
-
11
- class Visitor_Cookies implements Jetpack_Widget_Interface {
12
-
13
- /**
14
- * @var array list of supported cookie types
15
- *
16
- * @since 1.3.0
17
- */
18
- protected $cookie_types;
19
-
20
- /**
21
- * @var Settings_Service_Interface
22
- *
23
- * @since 1.3.0
24
- */
25
- protected $settings;
26
-
27
- /**
28
- * @var Script_Loader_Tag_Interface
29
- *
30
- * @since 1.3.0
31
- */
32
- protected $script_loader_tag;
33
-
34
- /**
35
- * @var Cookie_Consent_Interface
36
- *
37
- * @since 1.3.0
38
- */
39
- protected $cookie_consent;
40
-
41
- /**
42
- * @var Buffer_Output_Interface
43
- *
44
- * @since 1.3.0
45
- */
46
- protected $buffer_output;
47
-
48
- /**
49
- * Option name for jetpack addon
50
- *
51
- * @var string
52
- */
53
- public $widget_option;
54
-
55
- /**
56
- * Visitor_Cookies constructor.
57
- *
58
- * @param Settings_Service_Interface $settings
59
- * @param Script_Loader_Tag_Interface $script_loader_tag
60
- * @param Cookie_Consent_Interface $cookie_consent
61
- * @param Buffer_Output_Interface $buffer_output
62
- * @param $widget_option
63
- *
64
- * @version 1.8.0
65
- * @since 1.2.0
66
- */
67
- public function __construct( Settings_Service_Interface $settings, Script_Loader_Tag_Interface $script_loader_tag, Cookie_Consent_Interface $cookie_consent, Buffer_Output_Interface $buffer_output, $widget_option ) {
68
- $this->settings = $settings;
69
- $this->script_loader_tag = $script_loader_tag;
70
- $this->cookie_consent = $cookie_consent;
71
- $this->buffer_output = $buffer_output;
72
- $this->widget_option = $widget_option;
73
- }
74
-
75
- public function load_configuration() {
76
- /**
77
- * When consent is not given
78
- * Then disable comment cookies
79
- */
80
- if ( ! $this->cookie_consent->is_cookie_state_accepted( $this->get_widget_cookie_types() ) ) {
81
- $this->disable_comment_cookies();
82
- $this->do_not_save_mobile_or_web_view();
83
- $this->disable_eu_cookie_law();
84
- $this->disable_comment_subscriptions();
85
- }
86
- }
87
-
88
- public function get_label() {
89
- return 'Visitor cookies';
90
- }
91
-
92
- /**
93
- * Returns widget option name
94
- *
95
- * @return string
96
- *
97
- * @since 1.8.0
98
- */
99
- public function get_widget_option_name() {
100
- return 'visitor_cookies';
101
- }
102
-
103
- /**
104
- * Returns cookie types for a widget
105
- *
106
- * @return mixed
107
- *
108
- * @since 1.8.0
109
- */
110
- public function get_widget_cookie_types() {
111
- return $this->settings->get_widget_cookie_types( $this->widget_option, $this->get_widget_option_name() );
112
- }
113
-
114
- /**
115
- * Checks if a widget is enabled
116
- *
117
- * @return mixed
118
- *
119
- * @since 1.8.0
120
- */
121
- public function is_widget_enabled() {
122
- return $this->settings->is_widget_enabled( $this->widget_option, $this->get_widget_option_name() );
123
- }
124
-
125
- /**
126
- * @return string
127
- */
128
- public function get_default_placeholder() {
129
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to allow tracking.';
130
- }
131
-
132
- /**
133
- * Checks if widget has existing placeholders
134
- *
135
- * @return mixed
136
- *
137
- * @since 1.8.0
138
- */
139
- public function widget_has_placeholder() {
140
- return $this->settings->widget_has_placeholder( $this->widget_option, $this->get_widget_option_name() );
141
- }
142
-
143
- /**
144
- * Returns all widget placeholders
145
- *
146
- * @return mixed
147
- *
148
- * @since 1.8.0
149
- */
150
- public function get_widget_placeholders() {
151
- return $this->settings->get_widget_placeholders( $this->widget_option, $this->get_widget_option_name() );
152
- }
153
-
154
- /**
155
- * Checks if a widget placeholder is enabled
156
- *
157
- * @return boolean true If widget placeholder is checked
158
- * false If widget placeholder is not checked
159
- *
160
- * @since 1.8.0
161
- */
162
- public function is_widget_placeholder_enabled() {
163
- return $this->settings->is_widget_placeholder_enabled( $this->widget_option, $this->get_widget_option_name() );
164
- }
165
-
166
- /**
167
- * returns widget placeholder
168
- *
169
- * @return mixed
170
- *
171
- * @since 1.8.0
172
- */
173
- public function get_widget_placeholder() {
174
- return $this->settings->get_widget_placeholder( $this->widget_option, $this->get_widget_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_widget_cookie_types() ) );
175
- }
176
-
177
- /**
178
- * Set comment subscribe cookie time to zero so it expires.
179
- *
180
- * @since 1.2.0
181
- */
182
- protected function disable_comment_subscriptions() {
183
- add_filter(
184
- 'comment_cookie_lifetime',
185
- function ( $time ) {
186
- return 0;
187
- }
188
- );
189
- }
190
-
191
- /**
192
- * Disable eu cookie law script
193
- *
194
- * @since 1.2.0
195
- */
196
- protected function disable_eu_cookie_law() {
197
- $this->script_loader_tag->add_tag( 'eu-cookie-law-script', array( 'preferences' ) );
198
- }
199
-
200
- /**
201
- * Disable cookie comments
202
- *
203
- * Cookies:
204
- * - comment_author_{HASH}
205
- * - comment_author_email_{HASH}
206
- * - comment_author_url_{HASH}
207
- * @since 1.2.0
208
- */
209
- protected function disable_comment_cookies() {
210
- /**
211
- * Remove action comment cookies in jetpack
212
- *
213
- * we have to remove this action, because it does manually add the cookie.
214
- */
215
- cookiebot_addons_remove_class_action( 'comment_post', 'Highlander_Comments_Base', 'set_comment_cookies' );
216
-
217
- /**
218
- * Remove action comment cookies in WordPress core
219
- *
220
- * we have to remove this action, because it does manually add the cookie.
221
- */
222
- if ( has_action( 'set_comment_cookies', 'wp_set_comment_cookies' ) ) {
223
- remove_action( 'set_comment_cookies', 'wp_set_comment_cookies' );
224
- }
225
- }
226
-
227
- /**
228
- * Doesn't save the visitor wish in cookie
229
- *
230
- * Cookie:
231
- * - akm_mobile
232
- *
233
- * @since 1.2.0
234
- */
235
- protected function do_not_save_mobile_or_web_view() {
236
- /**
237
- * we have to remove this action, because it does manually add the cookie.
238
- */
239
- if ( has_action( 'init', 'jetpack_mobile_request_handler' ) ) {
240
- remove_action( 'init', 'jetpack_mobile_request_handler' );
241
- }
242
-
243
- /**
244
- * Show message to accept preferences consent to save
245
- */
246
- if ( $this->is_widget_placeholder_enabled() ) {
247
- add_action( 'wp_footer', array( $this, 'view_accept_preferences_consent' ) );
248
- }
249
- }
250
-
251
- /**
252
- * Display message to enable
253
- *
254
- * @since 1.2.0
255
- */
256
- public function view_accept_preferences_consent() {
257
- $class_name = cookiebot_addons_cookieconsent_optout( $this->get_widget_cookie_types() );
258
- ?>
259
- <div class="<?php echo esc_attr( $class_name ); ?>">
260
- <?php echo $this->get_widget_placeholder(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
261
- </div>
262
- <?php
263
- }
264
-
265
- /**
266
- * Adds extra information under the label
267
- *
268
- * @return string
269
- *
270
- * @since 1.8.0
271
- */
272
- public function get_extra_information() {
273
- return false;
274
- }
275
-
276
- /**
277
- * Placeholder helper overlay in the settings page.
278
- *
279
- * @return string
280
- *
281
- * @since 1.8.0
282
- */
283
- public function get_placeholder_helper() {
284
- 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>';
285
- }
286
-
287
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/jetpack/widget/facebook-widget.php DELETED
@@ -1,250 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\jetpack\widget;
4
-
5
- use cookiebot_addons\lib\Settings_Service_Interface;
6
- use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
7
- use cookiebot_addons\lib\Cookie_Consent_Interface;
8
- use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
9
-
10
- /**
11
- * This class is used to add cookiebot consent to facebook widget
12
- *
13
- * @since 1.2.0
14
- */
15
- class Facebook_Widget {
16
-
17
- /**
18
- * @var array list of supported cookie types
19
- *
20
- * @since 1.3.0
21
- */
22
- protected $cookie_types;
23
-
24
- /**
25
- * @var Settings_Service_Interface
26
- *
27
- * @since 1.3.0
28
- */
29
- protected $settings;
30
-
31
- /**
32
- * @var Script_Loader_Tag_Interface
33
- *
34
- * @since 1.3.0
35
- */
36
- protected $script_loader_tag;
37
-
38
- /**
39
- * @var Cookie_Consent_Interface
40
- *
41
- * @since 1.3.0
42
- */
43
- protected $cookie_consent;
44
-
45
- /**
46
- * @var Buffer_Output_Interface
47
- *
48
- * @since 1.3.0
49
- */
50
- protected $buffer_output;
51
-
52
- /**
53
- * Option name for jetpack addon
54
- *
55
- * @var string
56
- */
57
- public $widget_option;
58
-
59
- /**
60
- * Facebook_Widget constructor.
61
- *
62
- * @param Settings_Service_Interface $settings
63
- * @param Script_Loader_Tag_Interface $script_loader_tag
64
- * @param Cookie_Consent_Interface $cookie_consent
65
- * @param Buffer_Output_Interface $buffer_output
66
- * @param string $widget_option
67
- *
68
- * @version 1.8.0
69
- * @since 1.2.0
70
- */
71
- public function __construct( Settings_Service_Interface $settings, Script_Loader_Tag_Interface $script_loader_tag, Cookie_Consent_Interface $cookie_consent, Buffer_Output_Interface $buffer_output, $widget_option ) {
72
- $this->settings = $settings;
73
- $this->script_loader_tag = $script_loader_tag;
74
- $this->cookie_consent = $cookie_consent;
75
- $this->buffer_output = $buffer_output;
76
- $this->widget_option = $widget_option;
77
- }
78
-
79
- public function load_configuration() {
80
- /**
81
- * The widget is active
82
- */
83
- if ( is_active_widget( false, false, 'facebook-likebox', true ) ) {
84
- /**
85
- * The widget is enabled in Prior consent
86
- */
87
- if ( $this->is_widget_enabled() ) {
88
- /**
89
- * The visitor didn't check the required cookie types
90
- */
91
- if ( ! $this->cookie_consent->are_cookie_states_accepted( $this->get_widget_cookie_types() ) ) {
92
- /**
93
- * Manipulate script attribute
94
- */
95
- $this->add_consent_attribute_to_facebook_embed_javascript();
96
-
97
- /**
98
- * Display placeholder if allowed in the backend settings
99
- */
100
- if ( $this->is_widget_placeholder_enabled() ) {
101
- add_action( 'jetpack_stats_extra', array( $this, 'cookie_consent_div' ), 10, 2 );
102
- }
103
- }
104
- }
105
- }
106
- }
107
-
108
- public function get_label() {
109
- return 'Facebook';
110
- }
111
-
112
- /**
113
- * Returns widget option name
114
- *
115
- * @return string
116
- *
117
- * @since 1.8.0
118
- */
119
- public function get_widget_option_name() {
120
- return 'facebook';
121
- }
122
-
123
- /**
124
- * Returns cookie types for a widget
125
- *
126
- * @return mixed
127
- *
128
- * @since 1.8.0
129
- */
130
- public function get_widget_cookie_types() {
131
- return $this->settings->get_widget_cookie_types( $this->widget_option, $this->get_widget_option_name() );
132
- }
133
-
134
- /**
135
- * Checks if a widget is enabled
136
- *
137
- * @return mixed
138
- *
139
- * @since 1.8.0
140
- */
141
- public function is_widget_enabled() {
142
- return $this->settings->is_widget_enabled( $this->widget_option, $this->get_widget_option_name() );
143
- }
144
-
145
- /**
146
- * @return string
147
- */
148
- public function get_default_placeholder() {
149
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to see facebook widget.';
150
- }
151
-
152
- /**
153
- * Checks if a widget placeholder is enabled
154
- *
155
- * @return boolean true If widget placeholder is checked
156
- * false If widget placeholder is not checked
157
- *
158
- * @since 1.8.0
159
- */
160
- public function is_widget_placeholder_enabled() {
161
- return $this->settings->is_widget_placeholder_enabled( $this->widget_option, $this->get_widget_option_name() );
162
- }
163
-
164
- /**
165
- * Checks if widget has existing placeholders
166
- *
167
- * @return mixed
168
- *
169
- * @since 1.8.0
170
- */
171
- public function widget_has_placeholder() {
172
- return $this->settings->widget_has_placeholder( $this->widget_option, $this->get_widget_option_name() );
173
- }
174
-
175
- /**
176
- * Returns all widget placeholders
177
- *
178
- * @return mixed
179
- *
180
- * @since 1.8.0
181
- */
182
- public function get_widget_placeholders() {
183
- return $this->settings->get_widget_placeholders( $this->widget_option, $this->get_widget_option_name() );
184
- }
185
-
186
- /**
187
- * returns widget placeholder
188
- *
189
- * @return mixed
190
- *
191
- * @since 1.8.0
192
- */
193
- public function get_widget_placeholder() {
194
- return $this->settings->get_widget_placeholder( $this->widget_option, $this->get_widget_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_widget_cookie_types() ) );
195
- }
196
-
197
-
198
- /**
199
- * Tag external Facebook javascript file with cookiebot consent.
200
- *
201
- * @since 1.2.0
202
- */
203
- protected function add_consent_attribute_to_facebook_embed_javascript() {
204
- $this->script_loader_tag->add_tag( 'jetpack-facebook-embed', $this->get_widget_cookie_types() );
205
- }
206
-
207
- /**
208
- * Show consent message when the consent is not given.
209
- *
210
- * @param $view string
211
- * @param $widget string
212
- *
213
- * @since 1.6.0
214
- */
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
- $class_name = cookiebot_addons_cookieconsent_optout( $this->get_widget_cookie_types() );
219
- ?>
220
- <div class="<?php echo esc_attr( $class_name ); ?>">
221
- <?php echo $this->get_widget_placeholder(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
222
- </div>
223
- <?php
224
- }
225
- }
226
- }
227
-
228
- /**
229
- * Adds extra information under the label
230
- *
231
- * @return string
232
- *
233
- * @since 1.8.0
234
- */
235
- public function get_extra_information() {
236
- return '<p>' . esc_html__( 'Facebook widget.', 'cookiebot-addons' ) . '</p>';
237
- }
238
-
239
- /**
240
- * Placeholder helper overlay in the settings page.
241
- *
242
- * @return string
243
- *
244
- * @since 1.8.0
245
- */
246
- public function get_placeholder_helper() {
247
- 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>';
248
- }
249
-
250
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/jetpack/widget/goodreads-widget.php DELETED
@@ -1,309 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\jetpack\widget;
4
-
5
- use cookiebot_addons\lib\Settings_Service_Interface;
6
- use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
7
- use cookiebot_addons\lib\Cookie_Consent_Interface;
8
- use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
9
-
10
- class Goodreads_Widget implements Jetpack_Widget_Interface {
11
-
12
- protected $widget_id;
13
-
14
- protected $transient_name;
15
-
16
- protected $keywords;
17
-
18
- /**
19
- * @var array list of supported cookie types
20
- *
21
- * @since 1.3.0
22
- */
23
- protected $cookie_types;
24
-
25
- /**
26
- * @var Settings_Service_Interface
27
- *
28
- * @since 1.3.0
29
- */
30
- protected $settings;
31
-
32
- /**
33
- * @var Script_Loader_Tag_Interface
34
- *
35
- * @since 1.3.0
36
- */
37
- protected $script_loader_tag;
38
-
39
- /**
40
- * @var Cookie_Consent_Interface
41
- *
42
- * @since 1.3.0
43
- */
44
- protected $cookie_consent;
45
-
46
- /**
47
- * @var Buffer_Output_Interface
48
- *
49
- * @since 1.3.0
50
- */
51
- protected $buffer_output;
52
-
53
- /**
54
- * Option name for jetpack addon
55
- *
56
- * @var string
57
- */
58
- public $widget_option;
59
-
60
- /**
61
- * Goodreads_Widget constructor.
62
- *
63
- * @param Settings_Service_Interface $settings
64
- * @param Script_Loader_Tag_Interface $script_loader_tag
65
- * @param Cookie_Consent_Interface $cookie_consent
66
- * @param Buffer_Output_Interface $buffer_output
67
- * @param $widget_option
68
- *
69
- * @version 1.8.0
70
- * @since 1.3.0
71
- */
72
- public function __construct( Settings_Service_Interface $settings, Script_Loader_Tag_Interface $script_loader_tag, Cookie_Consent_Interface $cookie_consent, Buffer_Output_Interface $buffer_output, $widget_option ) {
73
- $this->settings = $settings;
74
- $this->script_loader_tag = $script_loader_tag;
75
- $this->cookie_consent = $cookie_consent;
76
- $this->buffer_output = $buffer_output;
77
- $this->widget_option = $widget_option;
78
- }
79
-
80
- public function load_configuration() {
81
- /**
82
- * The widget is active
83
- */
84
- if ( is_active_widget( false, false, 'wpcom-goodreads', true ) ) {
85
- /**
86
- * The widget is enabled in Prior consent
87
- */
88
- if ( $this->is_widget_enabled() ) {
89
- /**
90
- * The visitor didn't check the required cookie types
91
- */
92
- if ( ! $this->cookie_consent->are_cookie_states_accepted( $this->get_widget_cookie_types() ) ) {
93
-
94
- if ( $this->is_widget_placeholder_enabled() ) {
95
- add_action( 'jetpack_stats_extra', array( $this, 'cookie_consent_div' ), 10, 2 );
96
- }
97
-
98
- $this->transient_name = 'wpcom-goodreads';
99
-
100
- $this->keywords = array( 'www.goodreads.com' => $this->get_widget_cookie_types() );
101
- $this->block_javascript_file();
102
- $this->output_manipulated();
103
- }
104
- }
105
- }
106
- }
107
-
108
- public function get_label() {
109
- return 'Goodreads';
110
- }
111
-
112
- /**
113
- * Returns widget option name
114
- *
115
- * @return string
116
- *
117
- * @since 1.8.0
118
- */
119
- public function get_widget_option_name() {
120
- return 'goodreads';
121
- }
122
-
123
- /**
124
- * Returns cookie types for a widget
125
- *
126
- * @return mixed
127
- *
128
- * @since 1.8.0
129
- */
130
- public function get_widget_cookie_types() {
131
- return $this->settings->get_widget_cookie_types( $this->widget_option, $this->get_widget_option_name() );
132
- }
133
-
134
- /**
135
- * Checks if a widget is enabled
136
- *
137
- * @return mixed
138
- *
139
- * @since 1.8.0
140
- */
141
- public function is_widget_enabled() {
142
- return $this->settings->is_widget_enabled( $this->widget_option, $this->get_widget_option_name() );
143
- }
144
-
145
- /**
146
- * Checks if widget has existing placeholders
147
- *
148
- * @return mixed
149
- *
150
- * @since 1.8.0
151
- */
152
- public function widget_has_placeholder() {
153
- return $this->settings->widget_has_placeholder( $this->widget_option, $this->get_widget_option_name() );
154
- }
155
-
156
- /**
157
- * @return string
158
- */
159
- public function get_default_placeholder() {
160
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch goodreads.';
161
- }
162
-
163
- /**
164
- * Returns all widget placeholders
165
- *
166
- * @return mixed
167
- *
168
- * @since 1.8.0
169
- */
170
- public function get_widget_placeholders() {
171
- return $this->settings->get_widget_placeholders( $this->widget_option, $this->get_widget_option_name() );
172
- }
173
-
174
- /**
175
- * Checks if a widget placeholder is enabled
176
- *
177
- * @return boolean true If widget placeholder is checked
178
- * false If widget placeholder is not checked
179
- *
180
- * @since 1.8.0
181
- */
182
- public function is_widget_placeholder_enabled() {
183
- return $this->settings->is_widget_placeholder_enabled( $this->widget_option, $this->get_widget_option_name() );
184
- }
185
-
186
- /**
187
- * returns widget placeholder
188
- *
189
- * @return mixed
190
- *
191
- * @since 1.8.0
192
- */
193
- public function get_widget_placeholder() {
194
- return $this->settings->get_widget_placeholder( $this->widget_option, $this->get_widget_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_widget_cookie_types() ) );
195
- }
196
-
197
- /**
198
- * Add message to go to consent settings when marketing consent is not accepted
199
- *
200
- * @since 1.2.0
201
- */
202
- protected function block_javascript_file() {
203
- add_action( 'dynamic_sidebar', array( $this, 'display_div_message_to_go_to_consent_settings' ), 10, 1 );
204
- }
205
-
206
- /**
207
- * Show a messsage to go to consent settings
208
- *
209
- * @param $widget string
210
- *
211
- * @since 1.2.0
212
- */
213
- public function display_div_message_to_go_to_consent_settings( $widget ) {
214
- $callback = $widget['callback'][0];
215
-
216
- if ( $callback->id_base === 'wpcom-goodreads' ) {
217
- ob_start( array( $this, 'manipulate_script' ) );
218
- }
219
- }
220
-
221
- /**
222
- * Return widget output after dynamic sidebar is fully processed
223
- *
224
- * @since 1.2.0
225
- */
226
- public function output_manipulated() {
227
- add_action(
228
- 'dynamic_sidebar_after',
229
- function ( $index ) {
230
- ob_end_flush();
231
- }
232
- );
233
- }
234
-
235
- /**
236
- * Custom manipulation of the script
237
- *
238
- * @param $buffer
239
- *
240
- * @return mixed|null|string|string[]
241
- *
242
- * @since 1.2.0
243
- */
244
- public function manipulate_script( $buffer ) {
245
- /**
246
- * Get wp head scripts from the cache
247
- */
248
- $updated_scripts = get_transient( $this->transient_name );
249
-
250
- /**
251
- * If cache is not set then build it
252
- */
253
- if ( $updated_scripts === false ) {
254
-
255
- $updated_scripts = cookiebot_addons_manipulate_script( $buffer, $this->keywords );
256
-
257
- /**
258
- * Set cache for 15 minutes
259
- */
260
- set_transient( $this->transient_name, $updated_scripts, 60 * 15 );
261
- }
262
-
263
- return $updated_scripts;
264
- }
265
-
266
- /**
267
- * Show consent message when the consent is not given.
268
- *
269
- * @param $view string
270
- * @param $widget string
271
- *
272
- * @since 1.6.0
273
- */
274
- public function cookie_consent_div( $view, $widget ) {
275
- if ( $widget === 'goodreads' && $view === 'widget_view' ) {
276
- if ( is_array( $this->get_widget_cookie_types() ) && count( $this->get_widget_cookie_types() ) > 0 ) {
277
- $class_name = cookiebot_addons_cookieconsent_optout( $this->get_widget_cookie_types() );
278
- ?>
279
- <div class="<?php echo esc_attr( $class_name ); ?>">
280
- <?php echo $this->get_widget_placeholder(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
281
- </div>
282
- <?php
283
- }
284
- }
285
- }
286
-
287
- /**
288
- * Adds extra information under the label
289
- *
290
- * @return string
291
- *
292
- * @since 1.8.0
293
- */
294
- public function get_extra_information() {
295
- return false;
296
- }
297
-
298
- /**
299
- * Placeholder helper overlay in the settings page.
300
- *
301
- * @return string
302
- *
303
- * @since 1.8.0
304
- */
305
- public function get_placeholder_helper() {
306
- 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>';
307
- }
308
-
309
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/jetpack/widget/google-maps-widget.php DELETED
@@ -1,307 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\jetpack\widget;
4
-
5
- use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
6
- use cookiebot_addons\lib\Cookie_Consent_Interface;
7
- use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
8
- use cookiebot_addons\lib\Settings_Service_Interface;
9
-
10
- class Google_Maps_Widget implements Jetpack_Widget_Interface {
11
-
12
- /**
13
- * @var array list of supported cookie types
14
- *
15
- * @since 1.3.0
16
- */
17
- protected $cookie_types;
18
-
19
- /**
20
- * @var Settings_Service_Interface
21
- *
22
- * @since 1.3.0
23
- */
24
- protected $settings;
25
-
26
- /**
27
- * @var Script_Loader_Tag_Interface
28
- *
29
- * @since 1.3.0
30
- */
31
- protected $script_loader_tag;
32
-
33
- /**
34
- * @var Cookie_Consent_Interface
35
- *
36
- * @since 1.3.0
37
- */
38
- protected $cookie_consent;
39
-
40
- /**
41
- * @var Buffer_Output_Interface
42
- *
43
- * @since 1.3.0
44
- */
45
- protected $buffer_output;
46
-
47
- /**
48
- * Option name for jetpack addon
49
- *
50
- * @var string
51
- */
52
- public $widget_option;
53
-
54
- /**
55
- * This class is used to support facebook page widget in jetpack
56
- *
57
- * Google_Maps_Widget constructor.
58
- *
59
- * @param Settings_Service_Interface $settings
60
- * @param Script_Loader_Tag_Interface $script_loader_tag
61
- * @param Cookie_Consent_Interface $cookie_consent
62
- * @param Buffer_Output_Interface $buffer_output
63
- * @param string $widget_option
64
- *
65
- * @version 1.8.0
66
- * @since 1.2.0
67
- */
68
- public function __construct( Settings_Service_Interface $settings, Script_Loader_Tag_Interface $script_loader_tag, Cookie_Consent_Interface $cookie_consent, Buffer_Output_Interface $buffer_output, $widget_option ) {
69
- $this->settings = $settings;
70
- $this->script_loader_tag = $script_loader_tag;
71
- $this->cookie_consent = $cookie_consent;
72
- $this->buffer_output = $buffer_output;
73
- $this->widget_option = $widget_option;
74
- }
75
-
76
- public function load_configuration() {
77
- /**
78
- * The widget is active
79
- */
80
- if ( is_active_widget( false, false, 'widget_contact_info', true ) ) {
81
- /**
82
- * The widget is enabled in Prior consent
83
- */
84
- if ( $this->is_widget_enabled() ) {
85
- /**
86
- * Cookie types are not selected
87
- */
88
- if ( ! $this->cookie_consent->are_cookie_states_accepted( $this->get_widget_cookie_types() ) ) {
89
- $this->cookie_types = $this->get_widget_cookie_types();
90
-
91
- /**
92
- * Replace attributes of the google maps widget iframe
93
- */
94
- add_action( 'jetpack_contact_info_widget_start', array( $this, 'start_buffer' ) );
95
- add_action( 'jetpack_contact_info_widget_end', array( $this, 'stop_buffer' ) );
96
-
97
- if ( $this->is_widget_placeholder_enabled() ) {
98
- add_action( 'jetpack_stats_extra', array( $this, 'cookie_consent_div' ), 10, 2 );
99
- }
100
- }
101
- }
102
- }
103
- }
104
-
105
- public function get_label() {
106
- return 'Google Maps';
107
- }
108
-
109
- /**
110
- * Returns widget option name
111
- *
112
- * @return string
113
- *
114
- * @since 1.8.0
115
- */
116
- public function get_widget_option_name() {
117
- return 'google_maps';
118
- }
119
-
120
- /**
121
- * Returns cookie types for a widget
122
- *
123
- * @return mixed
124
- *
125
- * @since 1.8.0
126
- */
127
- public function get_widget_cookie_types() {
128
- return $this->settings->get_widget_cookie_types( $this->widget_option, $this->get_widget_option_name() );
129
- }
130
-
131
- /**
132
- * Checks if a widget is enabled
133
- *
134
- * @return mixed
135
- *
136
- * @since 1.8.0
137
- */
138
- public function is_widget_enabled() {
139
- return $this->settings->is_widget_enabled( $this->widget_option, $this->get_widget_option_name() );
140
- }
141
-
142
- /**
143
- * @return string
144
- */
145
- public function get_default_placeholder() {
146
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to enable google maps.';
147
- }
148
-
149
- /**
150
- * Checks if a widget placeholder is enabled
151
- *
152
- * @return boolean true If widget placeholder is checked
153
- * false If widget placeholder is not checked
154
- *
155
- * @since 1.8.0
156
- */
157
- public function is_widget_placeholder_enabled() {
158
- return $this->settings->is_widget_placeholder_enabled( $this->widget_option, $this->get_widget_option_name() );
159
- }
160
-
161
- /**
162
- * Checks if widget has existing placeholders
163
- *
164
- * @return mixed
165
- *
166
- * @since 1.8.0
167
- */
168
- public function widget_has_placeholder() {
169
- return $this->settings->widget_has_placeholder( $this->widget_option, $this->get_widget_option_name() );
170
- }
171
-
172
- /**
173
- * Returns all widget placeholders
174
- *
175
- * @return mixed
176
- *
177
- * @since 1.8.0
178
- */
179
- public function get_widget_placeholders() {
180
- return $this->settings->get_widget_placeholders( $this->widget_option, $this->get_widget_option_name() );
181
- }
182
-
183
- /**
184
- * returns widget placeholder
185
- *
186
- * @return mixed
187
- *
188
- * @since 1.8.0
189
- */
190
- public function get_widget_placeholder() {
191
- return $this->settings->get_widget_placeholder( $this->widget_option, $this->get_widget_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_widget_cookie_types() ) );
192
- }
193
-
194
- /**
195
- * Start catching the output
196
- *
197
- * @since 1.2.0
198
- */
199
- public function start_buffer() {
200
- ob_start( array( $this, 'manipulate_iframe' ) );
201
- }
202
-
203
- /**
204
- * Clear the buffer
205
- *
206
- * @since 1.2.0
207
- */
208
- public function stop_buffer() {
209
- ob_end_flush();
210
- }
211
-
212
- /**
213
- * Return manipulated output with cookieconsent attribute
214
- *
215
- * @param $buffer
216
- *
217
- * @return mixed|null|string|string[]
218
- *
219
- * @since 1.2.0
220
- */
221
- public function manipulate_iframe( $buffer ) {
222
- /**
223
- * Get wp head scripts from the cache
224
- */
225
- $updated_scripts = get_transient( 'jetpack_google_maps_widget' );
226
-
227
- /**
228
- * If cache is not set then build it
229
- */
230
- if ( $updated_scripts === false ) {
231
- /**
232
- * Pattern to get all iframes
233
- */
234
- $pattern = '/\<iframe(.*?)?\>(.|\s)*?\<\/iframe\>/i';
235
-
236
- /**
237
- * Get all scripts and add cookieconsent if it does match with the criterion
238
- */
239
- $updated_scripts = preg_replace_callback(
240
- $pattern,
241
- function ( $matches ) {
242
-
243
- $data = ( isset( $matches[0] ) ) ? $matches[0] : '';
244
-
245
- $data = str_replace( 'src=', 'data-cookieconsent="' . cookiebot_addons_output_cookie_types( $this->cookie_types ) . '" data-src=', $data );
246
-
247
- /**
248
- * Return updated iframe tag
249
- */
250
- return $data;
251
- },
252
- $buffer
253
- );
254
-
255
- /**
256
- * Set cache for 15 minutes
257
- */
258
- set_transient( 'jetpack_google_maps_widget', $updated_scripts, 60 * 15 );
259
- }
260
-
261
- return $updated_scripts;
262
- }
263
-
264
- /**
265
- * Show consent message when the consent is not given.
266
- *
267
- * @param $view string
268
- * @param $widget string
269
- *
270
- * @since 1.6.0
271
- */
272
- public function cookie_consent_div( $view, $widget ) {
273
- if ( $widget === 'contact_info' && $view === 'widget_view' ) {
274
- if ( is_array( $this->get_widget_cookie_types() ) && count( $this->get_widget_cookie_types() ) > 0 ) {
275
- $class_name = cookiebot_addons_cookieconsent_optout( $this->get_widget_cookie_types() );
276
- ?>
277
- <div class="<?php esc_attr( $class_name ); ?>">
278
- <?php echo $this->get_widget_placeholder(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
279
- </div>
280
- <?php
281
- }
282
- }
283
- }
284
-
285
- /**
286
- * Adds extra information under the label
287
- *
288
- * @return string
289
- *
290
- * @since 1.8.0
291
- */
292
- public function get_extra_information() {
293
- return false;
294
- }
295
-
296
- /**
297
- * Placeholder helper overlay in the settings page.
298
- *
299
- * @return string
300
- *
301
- * @since 1.8.0
302
- */
303
- public function get_placeholder_helper() {
304
- 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>';
305
- }
306
-
307
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/jetpack/widget/googleplus-badge-widget.php DELETED
@@ -1,243 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\jetpack\widget;
4
-
5
- use cookiebot_addons\lib\Settings_Service_Interface;
6
- use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
7
- use cookiebot_addons\lib\Cookie_Consent_Interface;
8
- use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
9
-
10
- class Googleplus_Badge_Widget {
11
-
12
- /**
13
- * @var array list of supported cookie types
14
- *
15
- * @since 1.3.0
16
- */
17
- protected $cookie_types;
18
-
19
- /**
20
- * @var Settings_Service_Interface
21
- *
22
- * @since 1.3.0
23
- */
24
- protected $settings;
25
-
26
- /**
27
- * @var Script_Loader_Tag_Interface
28
- *
29
- * @since 1.3.0
30
- */
31
- protected $script_loader_tag;
32
-
33
- /**
34
- * @var Cookie_Consent_Interface
35
- *
36
- * @since 1.3.0
37
- */
38
- protected $cookie_consent;
39
-
40
- /**
41
- * @var Buffer_Output_Interface
42
- *
43
- * @since 1.3.0
44
- */
45
- protected $buffer_output;
46
-
47
- /**
48
- * Option name for jetpack addon
49
- *
50
- * @var string
51
- */
52
- public $widget_option;
53
-
54
- /**
55
- * Googleplus_Badge_Widget constructor.
56
- *
57
- * @param Settings_Service_Interface $settings
58
- * @param Script_Loader_Tag_Interface $script_loader_tag
59
- * @param Cookie_Consent_Interface $cookie_consent
60
- * @param Buffer_Output_Interface $buffer_output
61
- * @param $widget_option
62
- *
63
- * @version 1.8.0
64
- * @since 1.2.0
65
- */
66
- public function __construct( Settings_Service_Interface $settings, Script_Loader_Tag_Interface $script_loader_tag, Cookie_Consent_Interface $cookie_consent, Buffer_Output_Interface $buffer_output, $widget_option ) {
67
- $this->settings = $settings;
68
- $this->script_loader_tag = $script_loader_tag;
69
- $this->cookie_consent = $cookie_consent;
70
- $this->buffer_output = $buffer_output;
71
- $this->widget_option = $widget_option;
72
- }
73
-
74
- /**
75
- * Load configuration
76
- */
77
- public function load_configuration() {
78
- /**
79
- * The widget is active
80
- */
81
- if ( is_active_widget( false, false, 'googleplus-badge', true ) ) {
82
- /**
83
- * The widget is enabled in Prior consent
84
- */
85
- if ( $this->is_widget_enabled() ) {
86
- /**
87
- * The visitor didn't check the required cookie types
88
- */
89
- if ( ! $this->cookie_consent->are_cookie_states_accepted( $this->get_widget_cookie_types() ) ) {
90
- $this->cookie_types = $this->get_widget_cookie_types();
91
-
92
- $this->disable_javascript_file();
93
-
94
- if ( $this->is_widget_placeholder_enabled() ) {
95
- add_action( 'jetpack_stats_extra', array( $this, 'display_div_message_to_go_to_consent_settings' ), 10, 2 );
96
- }
97
- }
98
- }
99
- }
100
- }
101
-
102
- public function get_label() {
103
- return 'Google Plus Badge';
104
- }
105
-
106
- /**
107
- * Returns widget option name
108
- *
109
- * @return string
110
- *
111
- * @since 1.8.0
112
- */
113
- public function get_widget_option_name() {
114
- return 'googleplus_badge';
115
- }
116
-
117
- /**
118
- * Returns cookie types for a widget
119
- *
120
- * @return mixed
121
- *
122
- * @since 1.8.0
123
- */
124
- public function get_widget_cookie_types() {
125
- return $this->settings->get_widget_cookie_types( $this->widget_option, $this->get_widget_option_name() );
126
- }
127
-
128
- /**
129
- * Checks if a widget is enabled
130
- *
131
- * @return mixed
132
- *
133
- * @since 1.8.0
134
- */
135
- public function is_widget_enabled() {
136
- return $this->settings->is_widget_enabled( $this->widget_option, $this->get_widget_option_name() );
137
- }
138
-
139
- /**
140
- * @return string
141
- */
142
- public function get_default_placeholder() {
143
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to enable google plus badge.';
144
- }
145
-
146
- /**
147
- * Checks if a widget placeholder is enabled
148
- *
149
- * @return boolean true If widget placeholder is checked
150
- * false If widget placeholder is not checked
151
- *
152
- * @since 1.8.0
153
- */
154
- public function is_widget_placeholder_enabled() {
155
- return $this->settings->is_widget_placeholder_enabled( $this->widget_option, $this->get_widget_option_name() );
156
- }
157
-
158
- /**
159
- * Checks if widget has existing placeholders
160
- *
161
- * @return mixed
162
- *
163
- * @since 1.8.0
164
- */
165
- public function widget_has_placeholder() {
166
- return $this->settings->widget_has_placeholder( $this->widget_option, $this->get_widget_option_name() );
167
- }
168
-
169
- /**
170
- * Returns all widget placeholders
171
- *
172
- * @return mixed
173
- *
174
- * @since 1.8.0
175
- */
176
- public function get_widget_placeholders() {
177
- return $this->settings->get_widget_placeholders( $this->widget_option, $this->get_widget_option_name() );
178
- }
179
-
180
- /**
181
- * returns widget placeholder
182
- *
183
- * @return mixed
184
- *
185
- * @since 1.8.0
186
- */
187
- public function get_widget_placeholder() {
188
- return $this->settings->get_widget_placeholder( $this->widget_option, $this->get_widget_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_widget_cookie_types() ) );
189
- }
190
-
191
- /**
192
- * Disable javascript file if marketing consent is not given
193
- *
194
- * @since 1.2.0
195
- */
196
- protected function disable_javascript_file() {
197
- $this->script_loader_tag->add_tag( 'googleplus-widget', $this->cookie_types );
198
- }
199
-
200
- /**
201
- * Show a messsage to go to consent settings
202
- *
203
- * @param $view string
204
- * @param $widget string
205
- *
206
- * @since 1.2.0
207
- */
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
- $class_name = cookiebot_addons_cookieconsent_optout( $this->cookie_types );
212
- ?>
213
- <div class="<?php echo esc_attr( $class_name ); ?>">
214
- <?php echo $this->get_widget_placeholder(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
215
- </div>
216
- <?php
217
- }
218
- }
219
- }
220
-
221
- /**
222
- * Adds extra information under the label
223
- *
224
- * @return string
225
- *
226
- * @since 1.8.0
227
- */
228
- public function get_extra_information() {
229
- return false;
230
- }
231
-
232
- /**
233
- * Placeholder helper overlay in the settings page.
234
- *
235
- * @return string
236
- *
237
- * @since 1.8.0
238
- */
239
- public function get_placeholder_helper() {
240
- 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>';
241
- }
242
-
243
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/jetpack/widget/internet-defense-league-widget.php DELETED
@@ -1,243 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\jetpack\widget;
4
-
5
- use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
6
- use cookiebot_addons\lib\Cookie_Consent_Interface;
7
- use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
8
- use cookiebot_addons\lib\Settings_Service_Interface;
9
-
10
- class Internet_Defense_league_Widget implements Jetpack_Widget_Interface {
11
-
12
- /**
13
- * @var array list of supported cookie types
14
- *
15
- * @since 1.3.0
16
- */
17
- protected $cookie_types;
18
-
19
- /**
20
- * @var Settings_Service_Interface
21
- *
22
- * @since 1.3.0
23
- */
24
- protected $settings;
25
-
26
- /**
27
- * @var Script_Loader_Tag_Interface
28
- *
29
- * @since 1.3.0
30
- */
31
- protected $script_loader_tag;
32
-
33
- /**
34
- * @var Cookie_Consent_Interface
35
- *
36
- * @since 1.3.0
37
- */
38
- protected $cookie_consent;
39
-
40
- /**
41
- * @var Buffer_Output_Interface
42
- *
43
- * @since 1.3.0
44
- */
45
- protected $buffer_output;
46
-
47
- /**
48
- * Option name for jetpack addon
49
- *
50
- * @var string
51
- */
52
- public $widget_option;
53
-
54
- /**
55
- * Internet_Defense_league_Widget constructor.
56
- *
57
- * @param Settings_Service_Interface $settings
58
- * @param Script_Loader_Tag_Interface $script_loader_tag
59
- * @param Cookie_Consent_Interface $cookie_consent
60
- * @param Buffer_Output_Interface $buffer_output
61
- * @param $widget_option
62
- *
63
- * @since 1.2.0
64
- */
65
- public function __construct( Settings_Service_Interface $settings, Script_Loader_Tag_Interface $script_loader_tag, Cookie_Consent_Interface $cookie_consent, Buffer_Output_Interface $buffer_output, $widget_option ) {
66
- $this->settings = $settings;
67
- $this->script_loader_tag = $script_loader_tag;
68
- $this->cookie_consent = $cookie_consent;
69
- $this->buffer_output = $buffer_output;
70
- $this->widget_option = $widget_option;
71
- }
72
-
73
- public function load_configuration() {
74
- /**
75
- * The widget is active
76
- */
77
- if ( is_active_widget( false, false, 'internet_defense_league_widget', true ) ) {
78
- /**
79
- * The widget is enabled in Prior consent
80
- */
81
- if ( $this->is_widget_enabled() ) {
82
- /**
83
- * The visitor didn't check the required cookie types
84
- */
85
- if ( ! $this->cookie_consent->are_cookie_states_accepted( $this->get_widget_cookie_types() ) ) {
86
- /**
87
- * Remove wp_footer script when the cookieconsent for marketing is not given
88
- *
89
- * @since 1.2.0
90
- */
91
- $this->buffer_output->add_tag(
92
- 'wp_footer',
93
- 10,
94
- array(
95
- 'window._idl' => $this->get_widget_cookie_types(),
96
- ),
97
- false
98
- );
99
-
100
- /**
101
- * Display placeholder if allowed in the backend settings
102
- */
103
- if ( $this->is_widget_placeholder_enabled() ) {
104
- add_action( 'jetpack_stats_extra', array( $this, 'cookie_consent_div' ), 10, 2 );
105
- }
106
- }
107
- }
108
- }
109
- }
110
-
111
- public function get_label() {
112
- return 'Internet defense league';
113
- }
114
-
115
- /**
116
- * Returns widget option name
117
- *
118
- * @return string
119
- *
120
- * @since 1.8.0
121
- */
122
- public function get_widget_option_name() {
123
- return 'internet_defense_league';
124
- }
125
-
126
- /**
127
- * Returns cookie types for a widget
128
- *
129
- * @return mixed
130
- *
131
- * @since 1.8.0
132
- */
133
- public function get_widget_cookie_types() {
134
- return $this->settings->get_widget_cookie_types( $this->widget_option, $this->get_widget_option_name() );
135
- }
136
-
137
- /**
138
- * Checks if a widget is enabled
139
- *
140
- * @return mixed
141
- *
142
- * @since 1.8.0
143
- */
144
- public function is_widget_enabled() {
145
- return $this->settings->is_widget_enabled( $this->widget_option, $this->get_widget_option_name() );
146
- }
147
-
148
- /**
149
- * @return string
150
- */
151
- public function get_default_placeholder() {
152
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to enable internet defense league.';
153
- }
154
-
155
- /**
156
- * Checks if a widget placeholder is enabled
157
- *
158
- * @return boolean true If widget placeholder is checked
159
- * false If widget placeholder is not checked
160
- *
161
- * @since 1.8.0
162
- */
163
- public function is_widget_placeholder_enabled() {
164
- return $this->settings->is_widget_placeholder_enabled( $this->widget_option, $this->get_widget_option_name() );
165
- }
166
-
167
- /**
168
- * Checks if widget has existing placeholders
169
- *
170
- * @return mixed
171
- *
172
- * @since 1.8.0
173
- */
174
- public function widget_has_placeholder() {
175
- return $this->settings->widget_has_placeholder( $this->widget_option, $this->get_widget_option_name() );
176
- }
177
-
178
- /**
179
- * Returns all widget placeholders
180
- *
181
- * @return mixed
182
- *
183
- * @since 1.8.0
184
- */
185
- public function get_widget_placeholders() {
186
- return $this->settings->get_widget_placeholders( $this->widget_option, $this->get_widget_option_name() );
187
- }
188
-
189
- /**
190
- * returns widget placeholder
191
- *
192
- * @return mixed
193
- *
194
- * @since 1.8.0
195
- */
196
- public function get_widget_placeholder() {
197
- return $this->settings->get_widget_placeholder( $this->widget_option, $this->get_widget_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_widget_cookie_types() ) );
198
- }
199
-
200
- /**
201
- * Show consent message when the consent is not given.
202
- *
203
- * @param $view string
204
- * @param $widget string
205
- *
206
- * @since 1.6.0
207
- */
208
- public function cookie_consent_div( $view, $widget ) {
209
- if ( $widget === 'internet_defense_league' && $view === 'widget_view' ) {
210
- if ( is_array( $this->get_widget_cookie_types() ) && count( $this->get_widget_cookie_types() ) > 0 ) {
211
- $class_name = cookiebot_addons_cookieconsent_optout( $this->get_widget_cookie_types() );
212
- ?>
213
- <div class="<?php echo esc_attr( $class_name ); ?>">
214
- <?php echo $this->get_widget_placeholder(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
215
- </div>
216
- <?php
217
- }
218
- }
219
- }
220
-
221
- /**
222
- * Adds extra information under the label
223
- *
224
- * @return string
225
- *
226
- * @since 1.8.0
227
- */
228
- public function get_extra_information() {
229
- return false;
230
- }
231
-
232
- /**
233
- * Placeholder helper overlay in the settings page.
234
- *
235
- * @return string
236
- *
237
- * @since 1.8.0
238
- */
239
- public function get_placeholder_helper() {
240
- 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>';
241
- }
242
-
243
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/jetpack/widget/jetpack-widget-interface.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\jetpack\widget;
4
-
5
- Interface Jetpack_Widget_Interface {
6
-
7
- public function get_label();
8
-
9
- public function get_widget_option_name();
10
-
11
- public function get_widget_cookie_types();
12
-
13
- public function is_widget_enabled();
14
-
15
- public function is_widget_placeholder_enabled();
16
-
17
- public function widget_has_placeholder();
18
-
19
- public function get_widget_placeholder();
20
-
21
- public function get_widget_placeholders();
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/jetpack/widget/twitter-timeline-widget.php DELETED
@@ -1,242 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\jetpack\widget;
4
-
5
- use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
6
- use cookiebot_addons\lib\Settings_Service_Interface;
7
- use cookiebot_addons\lib\Cookie_Consent_Interface;
8
- use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
9
-
10
- class Twitter_Timeline_Widget {
11
-
12
- /**
13
- * @var array list of supported cookie types
14
- *
15
- * @since 1.3.0
16
- */
17
- protected $cookie_types;
18
-
19
- /**
20
- * @var Settings_Service_Interface
21
- *
22
- * @since 1.3.0
23
- */
24
- protected $settings;
25
-
26
- /**
27
- * @var Script_Loader_Tag_Interface
28
- *
29
- * @since 1.3.0
30
- */
31
- protected $script_loader_tag;
32
-
33
- /**
34
- * @var Cookie_Consent_Interface
35
- *
36
- * @since 1.3.0
37
- */
38
- protected $cookie_consent;
39
-
40
- /**
41
- * @var Buffer_Output_Interface
42
- *
43
- * @since 1.3.0
44
- */
45
- protected $buffer_output;
46
-
47
- /**
48
- * Option name for jetpack addon
49
- *
50
- * @var string
51
- */
52
- public $widget_option;
53
-
54
- /**
55
- * Twitter_Timeline_Widget constructor.
56
- *
57
- * @param Settings_Service_Interface $settings
58
- * @param Script_Loader_Tag_Interface $script_loader_tag
59
- * @param Cookie_Consent_Interface $cookie_consent
60
- * @param Buffer_Output_Interface $buffer_output
61
- * @param $widget_option
62
- *
63
- * @since 1.8.0
64
- */
65
- public function __construct( Settings_Service_Interface $settings, Script_Loader_Tag_Interface $script_loader_tag, Cookie_Consent_Interface $cookie_consent, Buffer_Output_Interface $buffer_output, $widget_option ) {
66
- $this->settings = $settings;
67
- $this->script_loader_tag = $script_loader_tag;
68
- $this->cookie_consent = $cookie_consent;
69
- $this->buffer_output = $buffer_output;
70
- $this->widget_option = $widget_option;
71
- }
72
-
73
- public function load_configuration() {
74
- /**
75
- * The widget is active
76
- */
77
- if ( is_active_widget( false, false, 'twitter_timeline', true ) ) {
78
- /**
79
- * The widget is enabled in Prior consent
80
- */
81
- if ( $this->is_widget_enabled() ) {
82
- /**
83
- * The visitor didn't check the required cookie types
84
- */
85
- if ( ! $this->cookie_consent->are_cookie_states_accepted( $this->get_widget_cookie_types() ) ) {
86
- $this->cookie_types = $this->get_widget_cookie_types();
87
-
88
- $this->disable_javascript_file();
89
-
90
- if ( $this->is_widget_placeholder_enabled() ) {
91
- add_action( 'jetpack_stats_extra', array( $this, 'display_div_message_to_go_to_consent_settings' ), 10, 2 );
92
- }
93
- }
94
- }
95
- }
96
- }
97
-
98
- /**
99
- * @return string
100
- */
101
- public function get_label() {
102
- return 'Twitter timeline';
103
- }
104
-
105
- /**
106
- * Returns widget option name
107
- *
108
- * @return string
109
- *
110
- * @since 1.8.0
111
- */
112
- public function get_widget_option_name() {
113
- return 'twitter_timeline';
114
- }
115
-
116
- /**
117
- * Returns cookie types for a widget
118
- *
119
- * @return mixed
120
- *
121
- * @since 1.8.0
122
- */
123
- public function get_widget_cookie_types() {
124
- return $this->settings->get_widget_cookie_types( $this->widget_option, $this->get_widget_option_name() );
125
- }
126
-
127
- /**
128
- * Checks if a widget is enabled
129
- *
130
- * @return mixed
131
- *
132
- * @since 1.8.0
133
- */
134
- public function is_widget_enabled() {
135
- return $this->settings->is_widget_enabled( $this->widget_option, $this->get_widget_option_name() );
136
- }
137
-
138
- /**
139
- * @return string
140
- */
141
- public function get_default_placeholder() {
142
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this twitterline.';
143
- }
144
-
145
- /**
146
- * Checks if a widget placeholder is enabled
147
- *
148
- * @return boolean true If widget placeholder is checked
149
- * false If widget placeholder is not checked
150
- *
151
- * @since 1.8.0
152
- */
153
- public function is_widget_placeholder_enabled() {
154
- return $this->settings->is_widget_placeholder_enabled( $this->widget_option, $this->get_widget_option_name() );
155
- }
156
-
157
- /**
158
- * Checks if widget has existing placeholders
159
- *
160
- * @return mixed
161
- *
162
- * @since 1.8.0
163
- */
164
- public function widget_has_placeholder() {
165
- return $this->settings->widget_has_placeholder( $this->widget_option, $this->get_widget_option_name() );
166
- }
167
-
168
- /**
169
- * Returns all widget placeholders
170
- *
171
- * @return mixed
172
- *
173
- * @since 1.8.0
174
- */
175
- public function get_widget_placeholders() {
176
- return $this->settings->get_widget_placeholders( $this->widget_option, $this->get_widget_option_name() );
177
- }
178
-
179
- /**
180
- * returns widget placeholder
181
- *
182
- * @return mixed
183
- *
184
- * @since 1.8.0
185
- */
186
- public function get_widget_placeholder() {
187
- return $this->settings->get_widget_placeholder( $this->widget_option, $this->get_widget_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_widget_cookie_types() ) );
188
- }
189
-
190
- /**
191
- * Disable javascript file if marketing consent is not given
192
- *
193
- * @since 1.2.0
194
- */
195
- protected function disable_javascript_file() {
196
- $this->script_loader_tag->add_tag( 'jetpack-twitter-timeline', $this->cookie_types );
197
- }
198
-
199
- /**
200
- * Show a messsage to go to consent settings
201
- *
202
- * @param $view string
203
- * @param $widget string
204
- *
205
- * @since 1.2.0
206
- */
207
- public function display_div_message_to_go_to_consent_settings( $view, $widget ) {
208
- if ( $widget === 'twitter_timeline' && $view === 'widget_view' ) {
209
- if ( is_array( $this->get_widget_cookie_types() ) && count( $this->get_widget_cookie_types() ) > 0 ) {
210
- $class_name = cookiebot_addons_cookieconsent_optout( $this->get_widget_cookie_types() )
211
- ?>
212
- <div class="<?php echo esc_attr( $class_name ); ?>">
213
- <?php echo $this->get_widget_placeholder(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
214
- </div>
215
- <?php
216
- }
217
- }
218
- }
219
-
220
- /**
221
- * Adds extra information under the label
222
- *
223
- * @return string
224
- *
225
- * @since 1.8.0
226
- */
227
- public function get_extra_information() {
228
- return false;
229
- }
230
-
231
- /**
232
- * Placeholder helper overlay in the settings page.
233
- *
234
- * @return string
235
- *
236
- * @since 1.8.0
237
- */
238
- public function get_placeholder_helper() {
239
- 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>';
240
- }
241
-
242
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/litespeed-cache/litespeed-cache.php DELETED
@@ -1,343 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\litespeed_cache;
4
-
5
- use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
6
- use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
7
- use cookiebot_addons\lib\Cookie_Consent_Interface;
8
- use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
9
- use cookiebot_addons\lib\Settings_Service_Interface;
10
-
11
- class Litespeed_Cache 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(
52
- Settings_Service_Interface $settings,
53
- Script_Loader_Tag_Interface $script_loader_tag,
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
- /**
64
- * Loads addon configuration
65
- *
66
- * @since 1.3.0
67
- */
68
- public function load_configuration() {
69
- /**
70
- * Exclude Cookiebot files from defer setting
71
- */
72
- add_filter( 'litespeed_optimize_js_excludes', array( $this, 'exclude_files' ) );
73
- }
74
-
75
- /**
76
- * Exclude scripts from Litespeed cache’s defer JS option.
77
- *
78
- * @param array $excluded_files Array of script URLs to be excluded
79
- *
80
- * @return array Extended array script URLs to be excluded
81
- *
82
- * @author Caspar Hübinger
83
- * @since 3.6.2
84
- */
85
- public function exclude_files( $excluded_files = array() ) {
86
- $excluded_files[] = 'consent.cookiebot.com';
87
-
88
- return $excluded_files;
89
- }
90
-
91
- /**
92
- * Check if plugin is activated and checked in the backend
93
- *
94
- * @since 1.3.0
95
- */
96
- public function is_addon_enabled() {
97
- return $this->settings->is_addon_enabled( $this->get_option_name() );
98
- }
99
-
100
- /**
101
- * Option name in the database
102
- *
103
- * @return string
104
- *
105
- * @since 1.3.0
106
- */
107
- public function get_option_name() {
108
- return 'litespeed_cache';
109
- }
110
-
111
- /**
112
- * Returns checked cookie types
113
- * @return mixed
114
- *
115
- * @since 1.3.0
116
- */
117
- public function get_cookie_types() {
118
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
119
- }
120
-
121
- /**
122
- * Returns default cookie types
123
- * @return array
124
- *
125
- * @since 1.3.0
126
- */
127
- public function get_default_cookie_types() {
128
- return array( 'statistics' );
129
- }
130
-
131
- /**
132
- * Return addon/plugin name
133
- *
134
- * @return string
135
- *
136
- * @since 1.3.0
137
- */
138
- public function get_addon_name() {
139
- return 'Litespeed Cache';
140
- }
141
-
142
- /**
143
- * Checks if addon is installed
144
- *
145
- * @since 1.3.0
146
- */
147
- public function is_addon_installed() {
148
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
149
- }
150
-
151
- /**
152
- * Plugin file name
153
- *
154
- * @return string
155
- *
156
- * @since 1.3.0
157
- */
158
- public function get_plugin_file() {
159
- return 'litespeed-cache/litespeed-cache.php';
160
- }
161
-
162
- /**
163
- * Checks if addon is activated
164
- *
165
- * @since 1.3.0
166
- */
167
- public function is_addon_activated() {
168
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
169
- }
170
-
171
- /**
172
- * Retrieves current installed version of the addon
173
- *
174
- * @return bool
175
- *
176
- * @since 2.2.1
177
- */
178
- public function get_addon_version() {
179
- return $this->settings->get_addon_version( $this->get_plugin_file() );
180
- }
181
-
182
- /**
183
- * Default placeholder content
184
- *
185
- * @return string
186
- *
187
- * @since 1.8.0
188
- */
189
- public function get_default_placeholder() {
190
- return '';
191
- }
192
-
193
- /**
194
- * Get placeholder content
195
- *
196
- * This function will check following features:
197
- * - Current language
198
- *
199
- * @param $src
200
- *
201
- * @return bool|mixed
202
- *
203
- * @since 1.8.0
204
- */
205
- public function get_placeholder( $src = '' ) {
206
- return $this->settings->get_placeholder( $this->get_option_name(),
207
- $this->get_default_placeholder(),
208
- cookiebot_addons_output_cookie_types( $this->get_cookie_types() ),
209
- $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 '<p>' . esc_html__( 'Excludes cookiebot javascript files when the Litespeed Cache deter option is enabled.',
254
- 'cookiebot-addons' ) . '</p>';;
255
- }
256
-
257
- /**
258
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
259
- *
260
- * @return boolean
261
- *
262
- * @since 1.8.0
263
- */
264
- public function get_svn_url() {
265
- return 'http://plugins.svn.wordpress.org/litespeed-cache/trunk/litespeed-cache.php';
266
- }
267
-
268
- /**
269
- * Placeholder helper overlay in the settings page.
270
- *
271
- * @return string
272
- *
273
- * @since 1.8.0
274
- */
275
- public function get_placeholder_helper() {
276
- 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>';
277
- }
278
-
279
-
280
- /**
281
- * Returns parent class or false
282
- *
283
- * @return string|bool
284
- *
285
- * @since 2.1.3
286
- */
287
- public function get_parent_class() {
288
- return get_parent_class( $this );
289
- }
290
-
291
- /**
292
- * Action after enabling the addon on the settings page
293
- *
294
- * @since 2.2.0
295
- */
296
- public function post_hook_after_enabling() {
297
- //do nothing
298
- }
299
-
300
- /**
301
- * Cookiebot plugin is deactivated
302
- *
303
- * @since 2.2.0
304
- */
305
- public function plugin_deactivated() {
306
- //do nothing
307
- }
308
-
309
- /**
310
- * @return mixed
311
- *
312
- * @since 2.4.5
313
- */
314
- public function extra_available_addon_option() {
315
- //do nothing
316
- }
317
-
318
- /**
319
- * Returns boolean to enable/disable plugin by default
320
- *
321
- * @return bool
322
- *
323
- * @since 3.6.3
324
- */
325
- public function enable_by_default() {
326
- return true;
327
- }
328
-
329
- /**
330
- * Sets default settings for this addon
331
- *
332
- * @return array
333
- *
334
- * @since 3.6.3
335
- */
336
- public function get_default_enable_setting() {
337
- return array(
338
- 'enabled' => 1,
339
- 'cookie_type' => $this->get_default_cookie_types(),
340
- 'placeholder' => $this->get_default_placeholder(),
341
- );
342
- }
343
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/matomo/matomo.php DELETED
@@ -1,348 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\matomo;
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
- /**
12
- * Class Matomo
13
- * @package cookiebot_addons\controller\addons\wp_mautic
14
- */
15
- class Matomo implements Cookiebot_Addons_Interface {
16
-
17
- /**
18
- * @var Settings_Service_Interface
19
- *
20
- * @since 1.5.0
21
- */
22
- protected $settings;
23
-
24
- /**
25
- * @var Script_Loader_Tag_Interface
26
- *
27
- * @since 1.5.0
28
- */
29
- protected $script_loader_tag;
30
-
31
- /**
32
- * @var Cookie_Consent_Interface
33
- *
34
- * @since 1.5.0
35
- */
36
- public $cookie_consent;
37
-
38
- /**
39
- * @var Buffer_Output_Interface
40
- *
41
- * @since 1.5.0
42
- */
43
- protected $buffer_output;
44
-
45
- /**
46
- * constructor.
47
- *
48
- * @param $settings Settings_Service_Interface
49
- * @param $script_loader_tag Script_Loader_Tag_Interface
50
- * @param $cookie_consent Cookie_Consent_Interface
51
- * @param $buffer_output Buffer_Output_Interface
52
- *
53
- * @since 1.5.0
54
- */
55
- public function __construct( Settings_Service_Interface $settings, Script_Loader_Tag_Interface $script_loader_tag, Cookie_Consent_Interface $cookie_consent, Buffer_Output_Interface $buffer_output ) {
56
- $this->settings = $settings;
57
- $this->script_loader_tag = $script_loader_tag;
58
- $this->cookie_consent = $cookie_consent;
59
- $this->buffer_output = $buffer_output;
60
- }
61
-
62
- /**
63
- * Loads addon configuration
64
- *
65
- * @since 1.5.0
66
- */
67
- public function load_configuration() {
68
- add_action( 'wp_loaded', array( $this, 'cookiebot_addon_matomo' ), 5 );
69
- }
70
-
71
- /**
72
- * Disable scripts if state not accepted
73
- *
74
- * @since 1.5.0
75
- */
76
- public function cookiebot_addon_matomo() {
77
- $possible_tags = array(
78
- 'admin_footer',
79
- 'admin_head',
80
- 'wp_footer',
81
- 'wp_head',
82
- );
83
- foreach ( $possible_tags as $possible_tag ) {
84
- $this->buffer_output->add_tag(
85
- $possible_tag,
86
- 10,
87
- array(
88
- 'matomo' => $this->get_cookie_types(),
89
- ),
90
- false
91
- );
92
- }
93
- }
94
-
95
- /**
96
- * Return addon/plugin name
97
- *
98
- * @return string
99
- *
100
- * @since 1.5.0
101
- */
102
- public function get_addon_name() {
103
- return 'Matomo Analytics';
104
- }
105
-
106
- /**
107
- * Option name in the database
108
- *
109
- * @return string
110
- *
111
- * @since 1.5.0
112
- */
113
- public function get_option_name() {
114
- return 'matomo';
115
- }
116
-
117
- /**
118
- * Plugin file name
119
- *
120
- * @return string
121
- *
122
- * @since 1.5.0
123
- */
124
- public function get_plugin_file() {
125
- return 'matomo/matomo.php';
126
- }
127
-
128
- /**
129
- * Returns checked cookie types
130
- * @return mixed
131
- *
132
- * @since 1.5.0
133
- */
134
- public function get_cookie_types() {
135
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
136
- }
137
-
138
- /**
139
- * Returns default cookie types
140
- * @return array
141
- *
142
- * @since 1.5.0
143
- */
144
- public function get_default_cookie_types() {
145
- return array( 'statistics' );
146
- }
147
-
148
- /**
149
- * Check if plugin is activated and checked in the backend
150
- *
151
- * @since 1.5.0
152
- */
153
- public function is_addon_enabled() {
154
- return $this->settings->is_addon_enabled( $this->get_option_name() );
155
- }
156
-
157
- /**
158
- * Checks if addon is installed
159
- *
160
- * @since 1.5.0
161
- */
162
- public function is_addon_installed() {
163
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
164
- }
165
-
166
- /**
167
- * Checks if addon is activated
168
- *
169
- * @since 1.5.0
170
- */
171
- public function is_addon_activated() {
172
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
173
- }
174
-
175
- /**
176
- * Retrieves current installed version of the addon
177
- *
178
- * @return bool
179
- *
180
- * @since 2.2.1
181
- */
182
- public function get_addon_version() {
183
- return $this->settings->get_addon_version( $this->get_plugin_file() );
184
- }
185
-
186
- /**
187
- * Default placeholder content
188
- *
189
- * @return string
190
- *
191
- * @since 1.8.0
192
- */
193
- public function get_default_placeholder() {
194
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
195
- }
196
-
197
- /**
198
- * Get placeholder content
199
- *
200
- * This function will check following features:
201
- * - Current language
202
- *
203
- * @param $src
204
- *
205
- * @return bool|mixed
206
- *
207
- * @since 1.8.0
208
- */
209
- public function get_placeholder( $src = '' ) {
210
- return $this->settings->get_placeholder(
211
- $this->get_option_name(),
212
- $this->get_default_placeholder(),
213
- cookiebot_addons_output_cookie_types( $this->get_cookie_types() ),
214
- $src
215
- );
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 boolean
266
- *
267
- * @since 1.8.0
268
- */
269
- public function get_svn_url() {
270
- return 'https://plugins.svn.wordpress.org/matomo/trunk/matomo.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
- /**
286
- * Returns parent class or false
287
- *
288
- * @return string|bool
289
- *
290
- * @since 2.1.3
291
- */
292
- public function get_parent_class() {
293
- return get_parent_class( $this );
294
- }
295
-
296
- /**
297
- * Action after enabling the addon on the settings page
298
- *
299
- * @since 2.2.0
300
- */
301
- public function post_hook_after_enabling() {
302
- //do nothing
303
- }
304
-
305
- /**
306
- * Cookiebot plugin is deactivated
307
- *
308
- * @since 2.2.0
309
- */
310
- public function plugin_deactivated() {
311
- //do nothing
312
- }
313
-
314
- /**
315
- * @return mixed
316
- *
317
- * @since 2.4.5
318
- */
319
- public function extra_available_addon_option() {
320
- //do nothing
321
- }
322
-
323
- /**
324
- * Returns boolean to enable/disable plugin by default
325
- *
326
- * @return bool
327
- *
328
- * @since 3.6.3
329
- */
330
- public function enable_by_default() {
331
- return false;
332
- }
333
-
334
- /**
335
- * Sets default settings for this addon
336
- *
337
- * @return array
338
- *
339
- * @since 3.6.3
340
- */
341
- public function get_default_enable_setting() {
342
- return array(
343
- 'enabled' => 1,
344
- 'cookie_type' => $this->get_default_cookie_types(),
345
- 'placeholder' => $this->get_default_placeholder(),
346
- );
347
- }
348
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/ninja-forms/ninja-forms.php DELETED
@@ -1,345 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\ninja_forms;
4
-
5
- use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
6
- use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
7
- use cookiebot_addons\lib\Cookie_Consent_Interface;
8
- use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
9
- use cookiebot_addons\lib\Settings_Service_Interface;
10
-
11
- class Ninja_Forms 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
- /**
65
- * We add the action after wp_loaded and replace the original
66
- * HubSpot Tracking Code action with our own adjusted version.
67
- */
68
- add_action( 'wp_loaded', array( $this, 'cookiebot_addon_ninja_forms' ), 10 );
69
- }
70
-
71
- /**
72
- * Manipulate the scripts if they are loaded.
73
- *
74
- * @since 1.3.0
75
- */
76
- public function cookiebot_addon_ninja_forms() {
77
- /**
78
- * block google captcha script
79
- */
80
- $this->script_loader_tag->add_tag( 'nf-google-recaptcha', $this->get_cookie_types() );
81
-
82
- /**
83
- * Display placeholder message
84
- */
85
- if ( $this->is_placeholder_enabled() ) {
86
- add_filter( 'ninja_forms_display_fields', function ( $fields ) {
87
- foreach ( $fields as $key => $field ) {
88
- if ( $field['type'] == 'recaptcha' ) {
89
- $fields[ $key ]['afterField'] = $this->get_placeholder();
90
- }
91
- }
92
- return $fields;
93
- }, 10, 1 );
94
- }
95
- }
96
-
97
- /**
98
- * Return addon/plugin name
99
- *
100
- * @return string
101
- *
102
- * @since 1.3.0
103
- */
104
- public function get_addon_name() {
105
- return 'Ninja forms';
106
- }
107
-
108
- /**
109
- * Option name in the database
110
- *
111
- * @return string
112
- *
113
- * @since 1.3.0
114
- */
115
- public function get_option_name() {
116
- return 'ninja_forms';
117
- }
118
-
119
- /**
120
- * Plugin file name
121
- *
122
- * @return string
123
- *
124
- * @since 1.3.0
125
- */
126
- public function get_plugin_file() {
127
- return 'ninja-forms/ninja-forms.php';
128
- }
129
-
130
- /**
131
- * Returns checked cookie types
132
- * @return mixed
133
- *
134
- * @since 1.3.0
135
- */
136
- public function get_cookie_types() {
137
- return $this->settings->get_cookie_types( $this->get_option_name() );
138
- }
139
-
140
- /**
141
- * Returns default cookie types
142
- * @return array
143
- *
144
- * @since 1.5.0
145
- */
146
- public function get_default_cookie_types() {
147
- return array( 'marketing', 'statistics' );
148
- }
149
-
150
-
151
- /**
152
- * Check if plugin is activated and checked in the backend
153
- *
154
- * @since 1.3.0
155
- */
156
- public function is_addon_enabled() {
157
- return $this->settings->is_addon_enabled( $this->get_option_name() );
158
- }
159
-
160
- /**
161
- * Checks if addon is installed
162
- *
163
- * @since 1.3.0
164
- */
165
- public function is_addon_installed() {
166
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
167
- }
168
-
169
- /**
170
- * Checks if addon is activated
171
- *
172
- * @since 1.3.0
173
- */
174
- public function is_addon_activated() {
175
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
176
- }
177
-
178
- /**
179
- * Retrieves current installed version of the addon
180
- *
181
- * @return bool
182
- *
183
- * @since 2.2.1
184
- */
185
- public function get_addon_version() {
186
- return $this->settings->get_addon_version( $this->get_plugin_file() );
187
- }
188
-
189
- /**
190
- * Default placeholder content
191
- *
192
- * @return string
193
- *
194
- * @since 1.8.0
195
- */
196
- public function get_default_placeholder() {
197
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to enable captcha.';
198
- }
199
-
200
- /**
201
- * Get placeholder content
202
- *
203
- * This function will check following features:
204
- * - Current language
205
- *
206
- * @param $src
207
- *
208
- * @return bool|mixed
209
- *
210
- * @since 1.8.0
211
- */
212
- public function get_placeholder( $src = '' ) {
213
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
214
- }
215
-
216
- /**
217
- * Checks if it does have custom placeholder content
218
- *
219
- * @return mixed
220
- *
221
- * @since 1.8.0
222
- */
223
- public function has_placeholder() {
224
- return $this->settings->has_placeholder( $this->get_option_name() );
225
- }
226
-
227
- /**
228
- * returns all placeholder contents
229
- *
230
- * @return mixed
231
- *
232
- * @since 1.8.0
233
- */
234
- public function get_placeholders() {
235
- return $this->settings->get_placeholders( $this->get_option_name() );
236
- }
237
-
238
- /**
239
- * Return true if the placeholder is enabled
240
- *
241
- * @return mixed
242
- *
243
- * @since 1.8.0
244
- */
245
- public function is_placeholder_enabled() {
246
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
247
- }
248
-
249
- /**
250
- * Adds extra information under the label
251
- *
252
- * @return string
253
- *
254
- * @since 1.8.0
255
- */
256
- public function get_extra_information() {
257
- return false;
258
- }
259
-
260
- /**
261
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
262
- *
263
- * @return boolean
264
- *
265
- * @since 1.8.0
266
- */
267
- public function get_svn_url() {
268
- return 'http://plugins.svn.wordpress.org/ninja-forms/trunk/ninja-forms.php';
269
- }
270
-
271
- /**
272
- * Placeholder helper overlay in the settings page.
273
- *
274
- * @return string
275
- *
276
- * @since 1.8.0
277
- */
278
- public function get_placeholder_helper() {
279
- 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>';
280
- }
281
-
282
- /**
283
- * Returns parent class or false
284
- *
285
- * @return string|bool
286
- *
287
- * @since 2.1.3
288
- */
289
- public function get_parent_class() {
290
- return get_parent_class( $this );
291
- }
292
-
293
- /**
294
- * Action after enabling the addon on the settings page
295
- *
296
- * @since 2.2.0
297
- */
298
- public function post_hook_after_enabling() {
299
- //do nothing
300
- }
301
-
302
- /**
303
- * Cookiebot plugin is deactivated
304
- *
305
- * @since 2.2.0
306
- */
307
- public function plugin_deactivated() {
308
- //do nothing
309
- }
310
-
311
- /**
312
- * @return mixed
313
- *
314
- * @since 2.4.5
315
- */
316
- public function extra_available_addon_option() {
317
- //do nothing
318
- }
319
-
320
- /**
321
- * Returns boolean to enable/disable plugin by default
322
- *
323
- * @return bool
324
- *
325
- * @since 3.6.3
326
- */
327
- public function enable_by_default() {
328
- return false;
329
- }
330
-
331
- /**
332
- * Sets default settings for this addon
333
- *
334
- * @return array
335
- *
336
- * @since 3.6.3
337
- */
338
- public function get_default_enable_setting() {
339
- return array(
340
- 'enabled' => 1,
341
- 'cookie_type' => $this->get_default_cookie_types(),
342
- 'placeholder' => $this->get_default_placeholder(),
343
- );
344
- }
345
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/official-facebook-pixel/official-facebook-pixel.php DELETED
@@ -1,433 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\official_facebook_pixel;
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
- use FacebookPixelPlugin\Core\FacebookPluginConfig;
11
-
12
- class Official_Facebook_Pixel implements Cookiebot_Addons_Interface {
13
-
14
- /**
15
- * @var Settings_Service_Interface
16
- *
17
- * @since 1.3.0
18
- */
19
- protected $settings;
20
-
21
- /**
22
- * @var Script_Loader_Tag_Interface
23
- *
24
- * @since 1.3.0
25
- */
26
- protected $script_loader_tag;
27
-
28
- /**
29
- * @var Cookie_Consent_Interface
30
- *
31
- * @since 1.3.0
32
- */
33
- public $cookie_consent;
34
-
35
- /**
36
- * @var Buffer_Output_Interface
37
- *
38
- * @since 1.3.0
39
- */
40
- protected $buffer_output;
41
-
42
- /**
43
- * Jetpack constructor.
44
- *
45
- * @param $settings Settings_Service_Interface
46
- * @param $script_loader_tag Script_Loader_Tag_Interface
47
- * @param $cookie_consent Cookie_Consent_Interface
48
- * @param $buffer_output Buffer_Output_Interface
49
- *
50
- * @since 1.3.0
51
- */
52
- public function __construct(
53
- Settings_Service_Interface $settings,
54
- Script_Loader_Tag_Interface $script_loader_tag,
55
- Cookie_Consent_Interface $cookie_consent,
56
- Buffer_Output_Interface $buffer_output
57
- ) {
58
- $this->settings = $settings;
59
- $this->script_loader_tag = $script_loader_tag;
60
- $this->cookie_consent = $cookie_consent;
61
- $this->buffer_output = $buffer_output;
62
- }
63
-
64
- /**
65
- * Loads addon configuration
66
- *
67
- * @since 1.3.0
68
- */
69
- public function load_configuration() {
70
- add_action( 'wp_loaded', array( $this, 'cookiebot_addon_official_facebook_pixel' ), 5 );
71
- }
72
-
73
- /**
74
- * Disable scripts if state not accepted
75
- *
76
- * @since 1.3.0
77
- */
78
- public function cookiebot_addon_official_facebook_pixel() {
79
- // Pageview
80
- $this->buffer_output->add_tag( 'wp_head', 10, array(
81
- 'connect.facebook.net' => $this->get_cookie_types(),
82
- 'fbq' => $this->get_cookie_types(),
83
- ) );
84
-
85
- // Caldera forms integration
86
- $this->buffer_output->add_tag( 'caldera_forms_ajax_return', 10, array(
87
- 'fbq' => $this->get_cookie_types(),
88
- ), false );
89
-
90
- // Gravity forms integration
91
- $this->buffer_output->add_tag( 'gform_confirmation', 10, array(
92
- 'fbq' => $this->get_cookie_types(),
93
- ), false );
94
-
95
- // Ninja forms integration
96
- $this->buffer_output->add_tag( 'ninja_forms_submission_actions', 10, array(
97
- 'fbq' => $this->get_cookie_types(),
98
- ), false );
99
-
100
- // WP Ecommerce integration
101
- $this->buffer_output->add_tag( 'wpsc_add_to_cart_json_response', 11, array(
102
- 'fbq' => $this->get_cookie_types(),
103
- ), false );
104
-
105
- $this->buffer_output->add_tag( 'wpsc_transaction_results_shutdown', 11, array(
106
- 'fbq' => $this->get_cookie_types(),
107
- ), false );
108
-
109
- // WP Forms integration
110
- $this->buffer_output->add_tag( 'wp_footer', 20, array(
111
- 'fbq' => $this->get_cookie_types(),
112
- ), false );
113
-
114
- // Catching most events created with \FacebookPixelPlugin\Integration\FacebookWordpressIntegrationBase::addPixelFireForHook
115
- $this->buffer_output->add_tag( 'wp_footer', 11, array(
116
- 'fbq' => $this->get_cookie_types(),
117
- ), false );
118
-
119
- // Server side pixel events
120
- // Caldera form integration
121
- cookiebot_addons_remove_class_action( 'caldera_forms_ajax_return',
122
- 'FacebookPixelPlugin\Integration\FacebookWordpressCalderaForm', 'injectLeadEvent' );
123
-
124
- // Contact Form 7 integration
125
- cookiebot_addons_remove_class_action( 'wpcf7_submit',
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',
134
- 'FacebookPixelPlugin\Integration\FacebookWordpressFormidableForm', 'trackServerEvent', 20 );
135
- cookiebot_addons_remove_class_action( 'wp_footer',
136
- 'FacebookPixelPlugin\Integration\FacebookWordpressFormidableForm', 'injectLeadEvent', 20 );
137
-
138
- // Easy digital downloads integration
139
- cookiebot_addons_remove_class_action( 'edd_payment_receipt_after',
140
- 'FacebookPixelPlugin\Integration\FacebookWordpressEasyDigitalDownloads', 'trackPurchaseEvent' );
141
- cookiebot_addons_remove_class_action( 'edd_after_download_content',
142
- 'FacebookPixelPlugin\Integration\FacebookWordpressEasyDigitalDownloads', 'injectAddToCartEvent', 11 );
143
- cookiebot_addons_remove_class_action( 'edd_after_checkout_cart',
144
- 'FacebookPixelPlugin\Integration\FacebookWordpressEasyDigitalDownloads', 'injectInitiateCheckoutEvent',
145
- 11 );
146
- cookiebot_addons_remove_class_action( 'edd_after_download_content',
147
- 'FacebookPixelPlugin\Integration\FacebookWordpressEasyDigitalDownloads', 'injectViewContentEvent', 11 );
148
-
149
- // Gravity forms integration
150
- cookiebot_addons_remove_class_action( 'gform_confirmation',
151
- 'FacebookPixelPlugin\Integration\FacebookWordpressGravityForms', 'injectLeadEvent' );
152
-
153
- // Mailchimp for WP integration
154
- cookiebot_addons_remove_class_action( 'mc4wp_form_subscribed',
155
- 'FacebookPixelPlugin\Integration\FacebookWordpressMailchimpForWp', 'injectLeadEvent', 11 );
156
-
157
- // Ninja forms integration
158
- cookiebot_addons_remove_class_action( 'ninja_forms_submission_actions',
159
- 'FacebookPixelPlugin\Integration\FacebookWordpressNinjaForms', 'injectLeadEvent' );
160
-
161
- // WooCommerce integration
162
- cookiebot_addons_remove_class_action( 'woocommerce_after_checkout_form',
163
- 'FacebookPixelPlugin\Integration\FacebookWordpressWooCommerce', 'trackInitiateCheckout', 40 );
164
- cookiebot_addons_remove_class_action( 'woocommerce_add_to_cart',
165
- 'FacebookPixelPlugin\Integration\FacebookWordpressWooCommerce', 'trackAddToCartEvent', 40 );
166
- cookiebot_addons_remove_class_action( 'woocommerce_thankyou',
167
- 'FacebookPixelPlugin\Integration\FacebookWordpressWooCommerce', 'trackPurchaseEvent', 40 );
168
- cookiebot_addons_remove_class_action( 'woocommerce_payment_complete',
169
- 'FacebookPixelPlugin\Integration\FacebookWordpressWooCommerce', 'trackPurchaseEvent', 40 );
170
-
171
- // WP Ecommerce integration
172
- cookiebot_addons_remove_class_action( 'wpsc_add_to_cart_json_response',
173
- 'FacebookPixelPlugin\Integration\FacebookWordpressWPECommerce', 'injectAddToCartEvent', 11 );
174
- cookiebot_addons_remove_class_action( 'wpsc_before_shopping_cart_page',
175
- 'FacebookPixelPlugin\Integration\FacebookWordpressWPECommerce', 'injectInitiateCheckoutEvent', 11 );
176
- cookiebot_addons_remove_class_action( 'wpsc_transaction_results_shutdown',
177
- 'FacebookPixelPlugin\Integration\FacebookWordpressWPECommerce', 'injectPurchaseEvent', 11 );
178
-
179
- // WP Forms integration
180
- cookiebot_addons_remove_class_action( 'wpforms_process_before',
181
- 'FacebookPixelPlugin\Integration\FacebookWordpressWPForms', 'trackEvent', 20 );
182
- }
183
-
184
- /**
185
- * Return addon/plugin name
186
- *
187
- * @return string
188
- *
189
- * @since 1.3.0
190
- */
191
- public function get_addon_name() {
192
- return 'Official Facebook Pixel';
193
- }
194
-
195
- /**
196
- * Default placeholder content
197
- *
198
- * @return string
199
- *
200
- * @since 1.8.0
201
- */
202
- public function get_default_placeholder() {
203
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to enable Social Share buttons.';
204
- }
205
-
206
- /**
207
- * Get placeholder content
208
- *
209
- * This function will check following features:
210
- * - Current language
211
- *
212
- * @param $src
213
- *
214
- * @return bool|mixed
215
- *
216
- * @since 1.8.0
217
- */
218
- public function get_placeholder( $src = '' ) {
219
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(),
220
- cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
221
- }
222
-
223
- /**
224
- * Option name in the database
225
- *
226
- * @return string
227
- *
228
- * @since 1.3.0
229
- */
230
- public function get_option_name() {
231
- return 'official_facebook_pixel';
232
- }
233
-
234
- /**
235
- * Plugin file name
236
- *
237
- * @return string
238
- *
239
- * @since 1.3.0
240
- */
241
- public function get_plugin_file() {
242
- return 'official-facebook-pixel/facebook-for-wordpress.php';
243
- }
244
-
245
- /**
246
- * Returns checked cookie types
247
- * @return mixed
248
- *
249
- * @since 1.3.0
250
- */
251
- public function get_cookie_types() {
252
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
253
- }
254
-
255
- /**
256
- * Returns default cookie types
257
- * @return array
258
- *
259
- * @since 1.5.0
260
- */
261
- public function get_default_cookie_types() {
262
- return array( 'marketing' );
263
- }
264
-
265
- /**
266
- * Check if plugin is activated and checked in the backend
267
- *
268
- * @since 1.3.0
269
- */
270
- public function is_addon_enabled() {
271
- return $this->settings->is_addon_enabled( $this->get_option_name() );
272
- }
273
-
274
- /**
275
- * Checks if addon is installed
276
- *
277
- * @since 1.3.0
278
- */
279
- public function is_addon_installed() {
280
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
281
- }
282
-
283
- /**
284
- * Checks if addon is activated
285
- *
286
- * @since 1.3.0
287
- */
288
- public function is_addon_activated() {
289
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
290
- }
291
-
292
- /**
293
- * Retrieves current installed version of the addon
294
- *
295
- * @return bool
296
- *
297
- * @since 2.2.1
298
- */
299
- public function get_addon_version() {
300
- return $this->settings->get_addon_version( $this->get_plugin_file() );
301
- }
302
-
303
- /**
304
- * Checks if it does have custom placeholder content
305
- *
306
- * @return mixed
307
- *
308
- * @since 1.8.0
309
- */
310
- public function has_placeholder() {
311
- return $this->settings->has_placeholder( $this->get_option_name() );
312
- }
313
-
314
- /**
315
- * returns all placeholder contents
316
- *
317
- * @return mixed
318
- *
319
- * @since 1.8.0
320
- */
321
- public function get_placeholders() {
322
- return $this->settings->get_placeholders( $this->get_option_name() );
323
- }
324
-
325
- /**
326
- * Return true if the placeholder is enabled
327
- *
328
- * @return mixed
329
- *
330
- * @since 1.8.0
331
- */
332
- public function is_placeholder_enabled() {
333
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
334
- }
335
-
336
- /**
337
- * Adds extra information under the label
338
- *
339
- * @return string
340
- *
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
- /**
348
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
349
- *
350
- * @return string
351
- *
352
- * @since 1.8.0
353
- */
354
- public function get_svn_url() {
355
- return 'https://plugins.svn.wordpress.org/official-facebook-pixel/trunk/facebook-for-wordpress.php';
356
- }
357
-
358
- /**
359
- * Placeholder helper overlay in the settings page.
360
- *
361
- * @return string
362
- *
363
- * @since 1.8.0
364
- */
365
- public function get_placeholder_helper() {
366
- 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>';
367
- }
368
-
369
-
370
- /**
371
- * Returns parent class or false
372
- *
373
- * @return string|bool
374
- *
375
- * @since 2.1.3
376
- */
377
- public function get_parent_class() {
378
- return get_parent_class( $this );
379
- }
380
-
381
- /**
382
- * Action after enabling the addon on the settings page
383
- *
384
- * @since 2.2.0
385
- */
386
- public function post_hook_after_enabling() {
387
- //do nothing
388
- }
389
-
390
- /**
391
- * Cookiebot plugin is deactivated
392
- *
393
- * @since 2.2.0
394
- */
395
- public function plugin_deactivated() {
396
- //do nothing
397
- }
398
-
399
- /**
400
- * @return mixed
401
- *
402
- * @since 2.4.5
403
- */
404
- public function extra_available_addon_option() {
405
- //do nothing
406
- }
407
-
408
- /**
409
- * Returns boolean to enable/disable plugin by default
410
- *
411
- * @return bool
412
- *
413
- * @since 3.6.3
414
- */
415
- public function enable_by_default() {
416
- return false;
417
- }
418
-
419
- /**
420
- * Sets default settings for this addon
421
- *
422
- * @return array
423
- *
424
- * @since 3.6.3
425
- */
426
- public function get_default_enable_setting() {
427
- return array(
428
- 'enabled' => 1,
429
- 'cookie_type' => $this->get_default_cookie_types(),
430
- 'placeholder' => $this->get_default_placeholder(),
431
- );
432
- }
433
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/optinmonster/optinmonster.php DELETED
@@ -1,324 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\optinmonster;
4
-
5
- use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
6
- use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
7
- use cookiebot_addons\lib\Cookie_Consent_Interface;
8
- use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
9
- use cookiebot_addons\lib\Settings_Service_Interface;
10
-
11
- class Optinmonster 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_optinmonster' ), 10 );
65
- }
66
-
67
- /**
68
- * Check for optinmonster action hooks
69
- *
70
- * @since 1.3.0
71
- */
72
- public function cookiebot_addon_optinmonster() {
73
- $this->script_loader_tag->add_tag( 'optinmonster-api-script', $this->get_cookie_types() );
74
- }
75
-
76
- /**
77
- * Return addon/plugin name
78
- *
79
- * @return string
80
- *
81
- * @since 1.3.0
82
- */
83
- public function get_addon_name() {
84
- return 'Optinmonster';
85
- }
86
-
87
- /**
88
- * Option name in the database
89
- *
90
- * @return string
91
- *
92
- * @since 1.3.0
93
- */
94
- public function get_option_name() {
95
- return 'optinmonster';
96
- }
97
-
98
- /**
99
- * plugin file name
100
- *
101
- * @return string
102
- *
103
- * @since 1.3.0
104
- */
105
- public function get_plugin_file() {
106
- return 'optinmonster/optin-monster-wp-api.php';
107
- }
108
-
109
- /**
110
- * Returns checked cookie types
111
- * @return array
112
- *
113
- * @since 1.3.0
114
- */
115
- public function get_cookie_types() {
116
- return $this->settings->get_cookie_types( $this->get_option_name() );
117
- }
118
-
119
- /**
120
- * Returns default cookie types
121
- * @return array
122
- *
123
- * @since 1.5.0
124
- */
125
- public function get_default_cookie_types() {
126
- return array( 'marketing', 'statistics' );
127
- }
128
-
129
- /**
130
- * Check if plugin is activated and checked in the backend
131
- *
132
- * @since 1.3.0
133
- */
134
- public function is_addon_enabled() {
135
- return $this->settings->is_addon_enabled( $this->get_option_name() );
136
- }
137
-
138
- /**
139
- * Checks if addon is installed
140
- *
141
- * @since 1.3.0
142
- */
143
- public function is_addon_installed() {
144
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
145
- }
146
-
147
- /**
148
- * Checks if addon is activated
149
- *
150
- * @since 1.3.0
151
- */
152
- public function is_addon_activated() {
153
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
154
- }
155
-
156
- /**
157
- * Retrieves current installed version of the addon
158
- *
159
- * @return bool
160
- *
161
- * @since 2.2.1
162
- */
163
- public function get_addon_version() {
164
- return $this->settings->get_addon_version( $this->get_plugin_file() );
165
- }
166
-
167
- /**
168
- * Default placeholder content
169
- *
170
- * @return string
171
- *
172
- * @since 1.8.0
173
- */
174
- public function get_default_placeholder() {
175
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to track for optinmonster.';
176
- }
177
-
178
- /**
179
- * Get placeholder content
180
- *
181
- * This function will check following features:
182
- * - Current language
183
- *
184
- * @param $src
185
- *
186
- * @return bool|mixed
187
- *
188
- * @since 1.8.0
189
- */
190
- public function get_placeholder( $src = '' ) {
191
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
192
- }
193
-
194
- /**
195
- * Checks if it does have custom placeholder content
196
- *
197
- * @return mixed
198
- *
199
- * @since 1.8.0
200
- */
201
- public function has_placeholder() {
202
- return $this->settings->has_placeholder( $this->get_option_name() );
203
- }
204
-
205
- /**
206
- * returns all placeholder contents
207
- *
208
- * @return mixed
209
- *
210
- * @since 1.8.0
211
- */
212
- public function get_placeholders() {
213
- return $this->settings->get_placeholders( $this->get_option_name() );
214
- }
215
-
216
- /**
217
- * Return true if the placeholder is enabled
218
- *
219
- * @return mixed
220
- *
221
- * @since 1.8.0
222
- */
223
- public function is_placeholder_enabled() {
224
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
225
- }
226
-
227
- /**
228
- * Adds extra information under the label
229
- *
230
- * @return string
231
- *
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
- /**
239
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
240
- *
241
- * @return boolean
242
- *
243
- * @since 1.8.0
244
- */
245
- public function get_svn_url() {
246
- return 'https://plugins.svn.wordpress.org/optinmonster/trunk/optin-monster-wp-api.php';
247
- }
248
-
249
- /**
250
- * Placeholder helper overlay in the settings page.
251
- *
252
- * @return string
253
- *
254
- * @since 1.8.0
255
- */
256
- public function get_placeholder_helper() {
257
- 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>';
258
- }
259
-
260
-
261
- /**
262
- * Returns parent class or false
263
- *
264
- * @return string|bool
265
- *
266
- * @since 2.1.3
267
- */
268
- public function get_parent_class() {
269
- return get_parent_class( $this );
270
- }
271
-
272
- /**
273
- * Action after enabling the addon on the settings page
274
- *
275
- * @since 2.2.0
276
- */
277
- public function post_hook_after_enabling() {
278
- //do nothing
279
- }
280
-
281
- /**
282
- * Cookiebot plugin is deactivated
283
- *
284
- * @since 2.2.0
285
- */
286
- public function plugin_deactivated() {
287
- //do nothing
288
- }
289
-
290
- /**
291
- * @return mixed
292
- *
293
- * @since 2.4.5
294
- */
295
- public function extra_available_addon_option() {
296
- //do nothing
297
- }
298
-
299
- /**
300
- * Returns boolean to enable/disable plugin by default
301
- *
302
- * @return bool
303
- *
304
- * @since 3.6.3
305
- */
306
- public function enable_by_default() {
307
- return false;
308
- }
309
-
310
- /**
311
- * Sets default settings for this addon
312
- *
313
- * @return array
314
- *
315
- * @since 3.6.3
316
- */
317
- public function get_default_enable_setting() {
318
- return array(
319
- 'enabled' => 1,
320
- 'cookie_type' => $this->get_default_cookie_types(),
321
- 'placeholder' => $this->get_default_placeholder(),
322
- );
323
- }
324
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/pixel-caffeine/pixel-caffeine.php DELETED
@@ -1,332 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\pixel_caffeine;
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 Pixel_Caffeine implements Cookiebot_Addons_Interface {
12
-
13
- /**
14
- * @var Settings_Service_Interface
15
- *
16
- * @since 1.4.0
17
- */
18
- protected $settings;
19
-
20
- /**
21
- * @var Script_Loader_Tag_Interface
22
- *
23
- * @since 1.4.0
24
- */
25
- protected $script_loader_tag;
26
-
27
- /**
28
- * @var Cookie_Consent_Interface
29
- *
30
- * @since 1.4.0
31
- */
32
- public $cookie_consent;
33
-
34
- /**
35
- * @var Buffer_Output_Interface
36
- *
37
- * @since 1.4.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.4.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.4.0
62
- */
63
- public function load_configuration() {
64
- add_action( 'wp_loaded', array( $this, 'cookiebot_addon_pixel_caffeine' ), 5 );
65
- }
66
-
67
- /**
68
- * Disable scripts if state not accepted
69
- *
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(),
77
- ), false );
78
-
79
- $this->buffer_output->add_tag( 'wp_footer', 1, array(
80
- 'aepc_pixel' => $this->get_cookie_types(),
81
- ), false );
82
-
83
- }
84
-
85
- /**
86
- * Return addon/plugin name
87
- *
88
- * @return string
89
- *
90
- * @since 1.4.0
91
- */
92
- public function get_addon_name() {
93
- return 'Pixel Caffeine';
94
- }
95
-
96
- /**
97
- * Option name in the database
98
- *
99
- * @return string
100
- *
101
- * @since 1.4.0
102
- */
103
- public function get_option_name() {
104
- return 'pixel_caffeine';
105
- }
106
-
107
- /**
108
- * Plugin file name
109
- *
110
- * @return string
111
- *
112
- * @since 1.4.0
113
- */
114
- public function get_plugin_file() {
115
- return 'pixel-caffeine/pixel-caffeine.php';
116
- }
117
-
118
- /**
119
- * Returns checked cookie types
120
- * @return mixed
121
- *
122
- * @since 1.4.0
123
- */
124
- public function get_cookie_types() {
125
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
126
- }
127
-
128
- /**
129
- * Returns default cookie types
130
- * @return array
131
- *
132
- * @since 1.5.0
133
- */
134
- public function get_default_cookie_types() {
135
- return array( 'marketing' );
136
- }
137
-
138
- /**
139
- * Check if plugin is activated and checked in the backend
140
- *
141
- * @since 1.4.0
142
- */
143
- public function is_addon_enabled() {
144
- return $this->settings->is_addon_enabled( $this->get_option_name() );
145
- }
146
-
147
- /**
148
- * Checks if addon is installed
149
- *
150
- * @since 1.4.0
151
- */
152
- public function is_addon_installed() {
153
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
154
- }
155
-
156
- /**
157
- * Checks if addon is activated
158
- *
159
- * @since 1.4.0
160
- */
161
- public function is_addon_activated() {
162
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
163
- }
164
-
165
- /**
166
- * Retrieves current installed version of the addon
167
- *
168
- * @return bool
169
- *
170
- * @since 2.2.1
171
- */
172
- public function get_addon_version() {
173
- return $this->settings->get_addon_version( $this->get_plugin_file() );
174
- }
175
-
176
- /**
177
- * Default placeholder content
178
- *
179
- * @return string
180
- *
181
- * @since 1.8.0
182
- */
183
- public function get_default_placeholder() {
184
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
185
- }
186
-
187
- /**
188
- * Get placeholder content
189
- *
190
- * This function will check following features:
191
- * - Current language
192
- *
193
- * @param $src
194
- *
195
- * @return bool|mixed
196
- *
197
- * @since 1.8.0
198
- */
199
- public function get_placeholder( $src = '' ) {
200
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
201
- }
202
-
203
- /**
204
- * Checks if it does have custom placeholder content
205
- *
206
- * @return mixed
207
- *
208
- * @since 1.8.0
209
- */
210
- public function has_placeholder() {
211
- return $this->settings->has_placeholder( $this->get_option_name() );
212
- }
213
-
214
- /**
215
- * returns all placeholder contents
216
- *
217
- * @return mixed
218
- *
219
- * @since 1.8.0
220
- */
221
- public function get_placeholders() {
222
- return $this->settings->get_placeholders( $this->get_option_name() );
223
- }
224
-
225
- /**
226
- * Return true if the placeholder is enabled
227
- *
228
- * @return mixed
229
- *
230
- * @since 1.8.0
231
- */
232
- public function is_placeholder_enabled() {
233
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
234
- }
235
-
236
- /**
237
- * Adds extra information under the label
238
- *
239
- * @return string
240
- *
241
- * @since 1.8.0
242
- */
243
- public function get_extra_information() {
244
- return false;
245
- }
246
-
247
- /**
248
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
249
- *
250
- * @return boolean
251
- *
252
- * @since 1.8.0
253
- */
254
- public function get_svn_url() {
255
- return 'http://plugins.svn.wordpress.org/pixel-caffeine/trunk/pixel-caffeine.php';
256
- }
257
-
258
- /**
259
- * Placeholder helper overlay in the settings page.
260
- *
261
- * @return string
262
- *
263
- * @since 1.8.0
264
- */
265
- public function get_placeholder_helper() {
266
- 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>';
267
- }
268
-
269
- /**
270
- * Returns parent class or false
271
- *
272
- * @return string|bool
273
- *
274
- * @since 2.1.3
275
- */
276
- public function get_parent_class() {
277
- return get_parent_class( $this );
278
- }
279
-
280
- /**
281
- * Action after enabling the addon on the settings page
282
- *
283
- * @since 2.2.0
284
- */
285
- public function post_hook_after_enabling() {
286
- //do nothing
287
- }
288
-
289
- /**
290
- * Cookiebot plugin is deactivated
291
- *
292
- * @since 2.2.0
293
- */
294
- public function plugin_deactivated() {
295
- //do nothing
296
- }
297
-
298
- /**
299
- * @return mixed
300
- *
301
- * @since 2.4.5
302
- */
303
- public function extra_available_addon_option() {
304
- //do nothing
305
- }
306
-
307
- /**
308
- * Returns boolean to enable/disable plugin by default
309
- *
310
- * @return bool
311
- *
312
- * @since 3.6.3
313
- */
314
- public function enable_by_default() {
315
- return false;
316
- }
317
-
318
- /**
319
- * Sets default settings for this addon
320
- *
321
- * @return array
322
- *
323
- * @since 3.6.3
324
- */
325
- public function get_default_enable_setting() {
326
- return array(
327
- 'enabled' => 1,
328
- 'cookie_type' => $this->get_default_cookie_types(),
329
- 'placeholder' => $this->get_default_placeholder(),
330
- );
331
- }
332
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/simple-share-buttons-adder/simple-share-buttons-adder.php DELETED
@@ -1,324 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\simple_share_buttons_adder;
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 Simple_Share_Buttons_Adder 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_simple_share_buttons_adder' ), 5 );
65
- }
66
-
67
- /**
68
- * Disable scripts if state not accepted
69
- *
70
- * @since 1.3.0
71
- */
72
- public function cookiebot_addon_simple_share_buttons_adder() {
73
- $this->script_loader_tag->add_tag('ssba-sharethis', $this->get_cookie_types());
74
- }
75
-
76
- /**
77
- * Return addon/plugin name
78
- *
79
- * @return string
80
- *
81
- * @since 1.3.0
82
- */
83
- public function get_addon_name() {
84
- return 'Simple Share Buttons Adder';
85
- }
86
-
87
- /**
88
- * Default placeholder content
89
- *
90
- * @return string
91
- *
92
- * @since 1.8.0
93
- */
94
- public function get_default_placeholder() {
95
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to enable Social Share buttons.';
96
- }
97
-
98
- /**
99
- * Get placeholder content
100
- *
101
- * This function will check following features:
102
- * - Current language
103
- *
104
- * @param $src
105
- *
106
- * @return bool|mixed
107
- *
108
- * @since 1.8.0
109
- */
110
- public function get_placeholder( $src = '' ) {
111
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
112
- }
113
-
114
- /**
115
- * Option name in the database
116
- *
117
- * @return string
118
- *
119
- * @since 1.3.0
120
- */
121
- public function get_option_name() {
122
- return 'simple_share_buttons_adder';
123
- }
124
-
125
- /**
126
- * Plugin file name
127
- *
128
- * @return string
129
- *
130
- * @since 1.3.0
131
- */
132
- public function get_plugin_file() {
133
- return 'simple-share-buttons-adder/simple-share-buttons-adder.php';
134
- }
135
-
136
- /**
137
- * Returns checked cookie types
138
- * @return mixed
139
- *
140
- * @since 1.3.0
141
- */
142
- public function get_cookie_types() {
143
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
144
- }
145
-
146
- /**
147
- * Returns default cookie types
148
- * @return array
149
- *
150
- * @since 1.5.0
151
- */
152
- public function get_default_cookie_types() {
153
- return array('marketing');
154
- }
155
-
156
- /**
157
- * Check if plugin is activated and checked in the backend
158
- *
159
- * @since 1.3.0
160
- */
161
- public function is_addon_enabled() {
162
- return $this->settings->is_addon_enabled( $this->get_option_name() );
163
- }
164
-
165
- /**
166
- * Checks if addon is installed
167
- *
168
- * @since 1.3.0
169
- */
170
- public function is_addon_installed() {
171
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
172
- }
173
-
174
- /**
175
- * Checks if addon is activated
176
- *
177
- * @since 1.3.0
178
- */
179
- public function is_addon_activated() {
180
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
181
- }
182
-
183
- /**
184
- * Retrieves current installed version of the addon
185
- *
186
- * @return bool
187
- *
188
- * @since 2.2.1
189
- */
190
- public function get_addon_version() {
191
- return $this->settings->get_addon_version( $this->get_plugin_file() );
192
- }
193
-
194
- /**
195
- * Checks if it does have custom placeholder content
196
- *
197
- * @return mixed
198
- *
199
- * @since 1.8.0
200
- */
201
- public function has_placeholder() {
202
- return $this->settings->has_placeholder( $this->get_option_name() );
203
- }
204
-
205
- /**
206
- * returns all placeholder contents
207
- *
208
- * @return mixed
209
- *
210
- * @since 1.8.0
211
- */
212
- public function get_placeholders() {
213
- return $this->settings->get_placeholders( $this->get_option_name() );
214
- }
215
-
216
- /**
217
- * Return true if the placeholder is enabled
218
- *
219
- * @return mixed
220
- *
221
- * @since 1.8.0
222
- */
223
- public function is_placeholder_enabled() {
224
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
225
- }
226
-
227
- /**
228
- * Adds extra information under the label
229
- *
230
- * @return string
231
- *
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
- /**
239
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
240
- *
241
- * @return string
242
- *
243
- * @since 1.8.0
244
- */
245
- public function get_svn_url() {
246
- return 'http://plugins.svn.wordpress.org/simple-share-buttons-adder/trunk/simple-share-buttons-adder.php';
247
- }
248
-
249
- /**
250
- * Placeholder helper overlay in the settings page.
251
- *
252
- * @return string
253
- *
254
- * @since 1.8.0
255
- */
256
- public function get_placeholder_helper() {
257
- 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>';
258
- }
259
-
260
-
261
- /**
262
- * Returns parent class or false
263
- *
264
- * @return string|bool
265
- *
266
- * @since 2.1.3
267
- */
268
- public function get_parent_class() {
269
- return get_parent_class( $this );
270
- }
271
-
272
- /**
273
- * Action after enabling the addon on the settings page
274
- *
275
- * @since 2.2.0
276
- */
277
- public function post_hook_after_enabling() {
278
- //do nothing
279
- }
280
-
281
- /**
282
- * Cookiebot plugin is deactivated
283
- *
284
- * @since 2.2.0
285
- */
286
- public function plugin_deactivated() {
287
- //do nothing
288
- }
289
-
290
- /**
291
- * @return mixed
292
- *
293
- * @since 2.4.5
294
- */
295
- public function extra_available_addon_option() {
296
- //do nothing
297
- }
298
-
299
- /**
300
- * Returns boolean to enable/disable plugin by default
301
- *
302
- * @return bool
303
- *
304
- * @since 3.6.3
305
- */
306
- public function enable_by_default() {
307
- return false;
308
- }
309
-
310
- /**
311
- * Sets default settings for this addon
312
- *
313
- * @return array
314
- *
315
- * @since 3.6.3
316
- */
317
- public function get_default_enable_setting() {
318
- return array(
319
- 'enabled' => 1,
320
- 'cookie_type' => $this->get_default_cookie_types(),
321
- 'placeholder' => $this->get_default_placeholder(),
322
- );
323
- }
324
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/wd-google-analytics/wd-google-analytics.php DELETED
@@ -1,326 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\wd_google_analytics;
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 Wd_Google_Analytics 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, 'disable_cookies' ), 5 );
65
- }
66
-
67
- /**
68
- * Disable scripts if state not accepted
69
- *
70
- * @since 1.3.0
71
- */
72
- public function disable_cookies() {
73
- $this->buffer_output->add_tag( 'wp_head', 99, array(
74
- 'GoogleAnalyticsObject' => $this->get_cookie_types(),
75
- ), false );
76
-
77
- }
78
-
79
- /**
80
- * Return addon/plugin name
81
- *
82
- * @return string
83
- *
84
- * @since 1.3.0
85
- */
86
- public function get_addon_name() {
87
- return 'WD google analytics';
88
- }
89
-
90
- /**
91
- * Option name in the database
92
- *
93
- * @return string
94
- *
95
- * @since 1.3.0
96
- */
97
- public function get_option_name() {
98
- return 'wd_google_analytics';
99
- }
100
-
101
- /**
102
- * Plugin file name
103
- *
104
- * @return string
105
- *
106
- * @since 1.3.0
107
- */
108
- public function get_plugin_file() {
109
- return 'wd-google-analytics/google-analytics-wd.php';
110
- }
111
-
112
- /**
113
- * Returns checked cookie types
114
- * @return mixed
115
- *
116
- * @since 1.3.0
117
- */
118
- public function get_cookie_types() {
119
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
120
- }
121
-
122
- /**
123
- * Returns default cookie types
124
- * @return array
125
- *
126
- * @since 1.5.0
127
- */
128
- public function get_default_cookie_types() {
129
- return array( 'statistics' );
130
- }
131
-
132
- /**
133
- * Check if plugin is activated and checked in the backend
134
- *
135
- * @since 1.3.0
136
- */
137
- public function is_addon_enabled() {
138
- return $this->settings->is_addon_enabled( $this->get_option_name() );
139
- }
140
-
141
- /**
142
- * Checks if addon is installed
143
- *
144
- * @since 1.3.0
145
- */
146
- public function is_addon_installed() {
147
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
148
- }
149
-
150
- /**
151
- * Checks if addon is activated
152
- *
153
- * @since 1.3.0
154
- */
155
- public function is_addon_activated() {
156
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
157
- }
158
-
159
- /**
160
- * Retrieves current installed version of the addon
161
- *
162
- * @return bool
163
- *
164
- * @since 2.2.1
165
- */
166
- public function get_addon_version() {
167
- return $this->settings->get_addon_version( $this->get_plugin_file() );
168
- }
169
-
170
- /**
171
- * Default placeholder content
172
- *
173
- * @return string
174
- *
175
- * @since 1.8.0
176
- */
177
- public function get_default_placeholder() {
178
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
179
- }
180
-
181
- /**
182
- * Get placeholder content
183
- *
184
- * This function will check following features:
185
- * - Current language
186
- *
187
- * @param $src
188
- *
189
- * @return bool|mixed
190
- *
191
- * @since 1.8.0
192
- */
193
- public function get_placeholder( $src = '' ) {
194
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
195
- }
196
-
197
- /**
198
- * Checks if it does have custom placeholder content
199
- *
200
- * @return mixed
201
- *
202
- * @since 1.8.0
203
- */
204
- public function has_placeholder() {
205
- return $this->settings->has_placeholder( $this->get_option_name() );
206
- }
207
-
208
- /**
209
- * returns all placeholder contents
210
- *
211
- * @return mixed
212
- *
213
- * @since 1.8.0
214
- */
215
- public function get_placeholders() {
216
- return $this->settings->get_placeholders( $this->get_option_name() );
217
- }
218
-
219
- /**
220
- * Return true if the placeholder is enabled
221
- *
222
- * @return mixed
223
- *
224
- * @since 1.8.0
225
- */
226
- public function is_placeholder_enabled() {
227
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
228
- }
229
-
230
- /**
231
- * Adds extra information under the label
232
- *
233
- * @return string
234
- *
235
- * @since 1.8.0
236
- */
237
- public function get_extra_information() {
238
- return false;
239
- }
240
-
241
- /**
242
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
243
- *
244
- * @return boolean
245
- *
246
- * @since 1.8.0
247
- */
248
- public function get_svn_url() {
249
- return 'http://plugins.svn.wordpress.org/wd-google-analytics/trunk/google-analytics-wd.php';
250
- }
251
-
252
- /**
253
- * Placeholder helper overlay in the settings page.
254
- *
255
- * @return string
256
- *
257
- * @since 1.8.0
258
- */
259
- public function get_placeholder_helper() {
260
- 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>';
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/woocommerce-google-analytics-pro/woocommerce-google-analytics-pro.php DELETED
@@ -1,339 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\woocommerce_google_analytics_pro;
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 Woocommerce_Google_Analytics_Pro implements Cookiebot_Addons_Interface {
12
- /**
13
- * @var Settings_Service_Interface
14
- *
15
- * @since 1.3.0
16
- */
17
- protected $settings;
18
-
19
- /**
20
- * @var Script_Loader_Tag_Interface
21
- *
22
- * @since 1.3.0
23
- */
24
- protected $script_loader_tag;
25
-
26
- /**
27
- * @var Cookie_Consent_Interface
28
- *
29
- * @since 1.3.0
30
- */
31
- public $cookie_consent;
32
-
33
- /**
34
- * @var Buffer_Output_Interface
35
- *
36
- * @since 1.3.0
37
- */
38
- protected $buffer_output;
39
-
40
- /**
41
- * Jetpack constructor.
42
- *
43
- * @param $settings Settings_Service_Interface
44
- * @param $script_loader_tag Script_Loader_Tag_Interface
45
- * @param $cookie_consent Cookie_Consent_Interface
46
- * @param $buffer_output Buffer_Output_Interface
47
- *
48
- * @since 1.2.0
49
- */
50
- public function __construct( Settings_Service_Interface $settings, Script_Loader_Tag_Interface $script_loader_tag, Cookie_Consent_Interface $cookie_consent, Buffer_Output_Interface $buffer_output ) {
51
- $this->settings = $settings;
52
- $this->script_loader_tag = $script_loader_tag;
53
- $this->cookie_consent = $cookie_consent;
54
- $this->buffer_output = $buffer_output;
55
- }
56
-
57
- /**
58
- * Loads addon configuration
59
- *
60
- * @since 1.3.0
61
- */
62
- public function load_configuration() {
63
- /**
64
- * We add the action after wp_loaded and replace the original GA Google
65
- * Analytics action with our own adjusted version.
66
- */
67
- add_action( 'wp_loaded', array( $this, 'cookiebot_addon_woocommerce_google_analytics_pro_tracking_code' ), 5 );
68
- }
69
-
70
- /**
71
- * Manipulate the scripts if they are loaded.
72
- *
73
- * @since 1.3.0
74
- */
75
- public function cookiebot_addon_woocommerce_google_analytics_pro_tracking_code() {
76
-
77
- add_filter( 'wc_google_analytics_pro_script_attributes', array( $this, 'cookiebot_addon_woocommerce_google_analytics_pro_script_attributes' ) );
78
-
79
- }
80
-
81
- /**
82
- * Return attributes for script tags
83
- */
84
- function cookiebot_addon_woocommerce_google_analytics_pro_script_attributes() {
85
- $attr = array();
86
- $attr['type'] = 'text/plain';
87
- $attr['data-cookieconsent'] = implode(',',$this->get_cookie_types());
88
- return $attr;
89
- }
90
-
91
- /**
92
- * Return addon/plugin name
93
- *
94
- * @return string
95
- *
96
- * @since 1.3.0
97
- */
98
- public function get_addon_name() {
99
- return 'WooCommerce Google Analytics Pro';
100
- }
101
-
102
- /**
103
- * Default placeholder content
104
- *
105
- * @return string
106
- *
107
- * @since 1.8.0
108
- */
109
- public function get_default_placeholder() {
110
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to enable facebook shopping feature.';
111
- }
112
-
113
- /**
114
- * Get placeholder content
115
- *
116
- * This function will check following features:
117
- * - Current language
118
- *
119
- * @param $src
120
- *
121
- * @return bool|mixed
122
- *
123
- * @since 1.8.0
124
- */
125
- public function get_placeholder( $src = '' ) {
126
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
127
- }
128
-
129
- /**
130
- * Option name in the database
131
- *
132
- * @return string
133
- *
134
- * @since 1.3.0
135
- */
136
- public function get_option_name() {
137
- return 'woocommerce_google_analytics_pro';
138
- }
139
-
140
- /**
141
- * Plugin file name
142
- *
143
- * @return string
144
- *
145
- * @since 1.3.0
146
- */
147
- public function get_plugin_file() {
148
- return 'woocommerce-google-analytics-pro/woocommerce-google-analytics-pro.php';
149
- }
150
-
151
- /**
152
- * Returns checked cookie types
153
- * @return mixed
154
- *
155
- * @since 1.3.0
156
- */
157
- public function get_cookie_types() {
158
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
159
- }
160
-
161
- /**
162
- * Returns default cookie types
163
- * @return array
164
- *
165
- * @since 1.5.0
166
- */
167
- public function get_default_cookie_types() {
168
- return array( 'statistics' );
169
- }
170
-
171
- /**
172
- * Check if plugin is activated and checked in the backend
173
- *
174
- * @since 1.3.0
175
- */
176
- public function is_addon_enabled() {
177
- return $this->settings->is_addon_enabled( $this->get_option_name() );
178
- }
179
-
180
- /**
181
- * Checks if addon is installed
182
- *
183
- * @since 1.3.0
184
- */
185
- public function is_addon_installed() {
186
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
187
- }
188
-
189
- /**
190
- * Checks if addon is activated
191
- *
192
- * @since 1.3.0
193
- */
194
- public function is_addon_activated() {
195
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
196
- }
197
-
198
- /**
199
- * Retrieves current installed version of the addon
200
- *
201
- * @return bool
202
- *
203
- * @since 2.2.1
204
- */
205
- public function get_addon_version() {
206
- return $this->settings->get_addon_version( $this->get_plugin_file() );
207
- }
208
-
209
- /**
210
- * Checks if it does have custom placeholder content
211
- *
212
- * @return mixed
213
- *
214
- * @since 1.8.0
215
- */
216
- public function has_placeholder() {
217
- return $this->settings->has_placeholder( $this->get_option_name() );
218
- }
219
-
220
- /**
221
- * returns all placeholder contents
222
- *
223
- * @return mixed
224
- *
225
- * @since 1.8.0
226
- */
227
- public function get_placeholders() {
228
- return $this->settings->get_placeholders( $this->get_option_name() );
229
- }
230
-
231
- /**
232
- * Return true if the placeholder is enabled
233
- *
234
- * @return mixed
235
- *
236
- * @since 1.8.0
237
- */
238
- public function is_placeholder_enabled() {
239
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
240
- }
241
-
242
- /**
243
- * Adds extra information under the label
244
- *
245
- * @return string
246
- *
247
- * @since 1.8.0
248
- */
249
- public function get_extra_information() {
250
-
251
- }
252
-
253
- /**
254
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
255
- *
256
- * @return string
257
- *
258
- * @since 1.8.0
259
- */
260
- public function get_svn_url() {
261
- return false; //Commercial plugin - not available
262
- }
263
-
264
- /**
265
- * Placeholder helper overlay in the settings page.
266
- *
267
- * @return string
268
- *
269
- * @since 1.8.0
270
- */
271
- public function get_placeholder_helper() {
272
- 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>';
273
- }
274
-
275
-
276
- /**
277
- * Returns parent class or false
278
- *
279
- * @return string|bool
280
- *
281
- * @since 2.1.3
282
- */
283
- public function get_parent_class() {
284
- return get_parent_class( $this );
285
- }
286
-
287
- /**
288
- * Action after enabling the addon on the settings page
289
- *
290
- * @since 2.2.0
291
- */
292
- public function post_hook_after_enabling() {
293
- //do nothing
294
- }
295
-
296
- /**
297
- * Cookiebot plugin is deactivated
298
- *
299
- * @since 2.2.0
300
- */
301
- public function plugin_deactivated() {
302
- //do nothing
303
- }
304
-
305
- /**
306
- * @return mixed
307
- *
308
- * @since 2.4.5
309
- */
310
- public function extra_available_addon_option() {
311
- //do nothing
312
- }
313
-
314
- /**
315
- * Returns boolean to enable/disable plugin by default
316
- *
317
- * @return bool
318
- *
319
- * @since 3.6.3
320
- */
321
- public function enable_by_default() {
322
- return false;
323
- }
324
-
325
- /**
326
- * Sets default settings for this addon
327
- *
328
- * @return array
329
- *
330
- * @since 3.6.3
331
- */
332
- public function get_default_enable_setting() {
333
- return array(
334
- 'enabled' => 1,
335
- 'cookie_type' => $this->get_default_cookie_types(),
336
- 'placeholder' => $this->get_default_placeholder(),
337
- );
338
- }
339
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/wp-analytify/wp-analytify.php DELETED
@@ -1,326 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\wp_analytify;
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 Wp_Analytify implements Cookiebot_Addons_Interface {
12
-
13
- /**
14
- * @var Settings_Service_Interface
15
- *
16
- * @since 1.5.0
17
- */
18
- protected $settings;
19
-
20
- /**
21
- * @var Script_Loader_Tag_Interface
22
- *
23
- * @since 1.5.0
24
- */
25
- protected $script_loader_tag;
26
-
27
- /**
28
- * @var Cookie_Consent_Interface
29
- *
30
- * @since 1.5.0
31
- */
32
- public $cookie_consent;
33
-
34
- /**
35
- * @var Buffer_Output_Interface
36
- *
37
- * @since 1.5.0
38
- */
39
- protected $buffer_output;
40
-
41
- /**
42
- * 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.5.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.5.0
62
- */
63
- public function load_configuration() {
64
- add_action( 'wp_loaded', array( $this, 'cookiebot_addon_analytify' ), 5 );
65
- }
66
-
67
- /**
68
- * Disable scripts if state not accepted
69
- *
70
- * @since 1.5.0
71
- */
72
- public function cookiebot_addon_analytify() {
73
- $this->buffer_output->add_tag( 'wp_head', 10, array(
74
- 'GoogleAnalyticsObject' => $this->get_cookie_types()
75
- ), false );
76
- }
77
-
78
- /**
79
- * Return addon/plugin name
80
- *
81
- * @return string
82
- *
83
- * @since 1.5.0
84
- */
85
- public function get_addon_name() {
86
- return 'Analytify';
87
- }
88
-
89
- /**
90
- * Option name in the database
91
- *
92
- * @return string
93
- *
94
- * @since 1.5.0
95
- */
96
- public function get_option_name() {
97
- return 'analytify';
98
- }
99
-
100
- /**
101
- * Plugin file name
102
- *
103
- * @return string
104
- *
105
- * @since 1.5.0
106
- */
107
- public function get_plugin_file() {
108
- return 'wp-analytify/wp-analytify.php';
109
- }
110
-
111
- /**
112
- * Returns checked cookie types
113
- * @return mixed
114
- *
115
- * @since 1.5.0
116
- */
117
- public function get_cookie_types() {
118
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
119
- }
120
-
121
- /**
122
- * Returns default cookie types
123
- * @return array
124
- *
125
- * @since 1.5.0
126
- */
127
- public function get_default_cookie_types() {
128
- return array( 'statistics' );
129
- }
130
-
131
- /**
132
- * Check if plugin is activated and checked in the backend
133
- *
134
- * @since 1.5.0
135
- */
136
- public function is_addon_enabled() {
137
- return $this->settings->is_addon_enabled( $this->get_option_name() );
138
- }
139
-
140
- /**
141
- * Checks if addon is installed
142
- *
143
- * @since 1.5.0
144
- */
145
- public function is_addon_installed() {
146
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
147
- }
148
-
149
- /**
150
- * Checks if addon is activated
151
- *
152
- * @since 1.5.0
153
- */
154
- public function is_addon_activated() {
155
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
156
- }
157
-
158
- /**
159
- * Retrieves current installed version of the addon
160
- *
161
- * @return bool
162
- *
163
- * @since 2.2.1
164
- */
165
- public function get_addon_version() {
166
- return $this->settings->get_addon_version( $this->get_plugin_file() );
167
- }
168
-
169
- /**
170
- * Default placeholder content
171
- *
172
- * @return string
173
- *
174
- * @since 1.8.0
175
- */
176
- public function get_default_placeholder() {
177
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
178
- }
179
-
180
- /**
181
- * Get placeholder content
182
- *
183
- * This function will check following features:
184
- * - Current language
185
- *
186
- * @param $src
187
- *
188
- * @return bool|mixed
189
- *
190
- * @since 1.8.0
191
- */
192
- public function get_placeholder( $src = '' ) {
193
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
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 false;
238
- }
239
-
240
- /**
241
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
242
- *
243
- * @return boolean
244
- *
245
- * @since 1.8.0
246
- */
247
- public function get_svn_url() {
248
- return 'http://plugins.svn.wordpress.org/wp-analytify/trunk/wp-analytify.php';
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/wp-google-analytics-events/wp-google-analytics-events.php DELETED
@@ -1,333 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\wp_google_analytics_events;
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 Wp_Google_Analytics_Events 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(
52
- Settings_Service_Interface $settings,
53
- Script_Loader_Tag_Interface $script_loader_tag,
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
- /**
64
- * Loads addon configuration
65
- *
66
- * @since 1.3.0
67
- */
68
- public function load_configuration() {
69
- add_action( 'wp_loaded', array( $this, 'cookiebot_addon_wp_google_analytics_events' ), 5 );
70
- }
71
-
72
- /**
73
- * Disable scripts if state not accepted
74
- *
75
- * @since 1.3.0
76
- */
77
- public function cookiebot_addon_wp_google_analytics_events() {
78
- $this->script_loader_tag->add_tag( 'ga_events_frontend_bundle', $this->get_cookie_types() );
79
- $this->script_loader_tag->add_tag( 'ga_events_main_script', $this->get_cookie_types() );
80
- cookiebot_addons_remove_class_action( 'wp_head', 'GAESnippets', 'add_snippet_to_header', 0 );
81
- }
82
-
83
- /**
84
- * Return addon/plugin name
85
- *
86
- * @return string
87
- *
88
- * @since 1.3.0
89
- */
90
- public function get_addon_name() {
91
- return 'WP Google Analytics Events';
92
- }
93
-
94
- /**
95
- * Default placeholder content
96
- *
97
- * @return string
98
- *
99
- * @since 1.8.0
100
- */
101
- public function get_default_placeholder() {
102
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to enable WP Google Analytics Events.';
103
- }
104
-
105
- /**
106
- * Get placeholder content
107
- *
108
- * This function will check following features:
109
- * - Current language
110
- *
111
- * @param $src
112
- *
113
- * @return bool|mixed
114
- *
115
- * @since 1.8.0
116
- */
117
- public function get_placeholder( $src = '' ) {
118
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(),
119
- cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
120
- }
121
-
122
- /**
123
- * Option name in the database
124
- *
125
- * @return string
126
- *
127
- * @since 1.3.0
128
- */
129
- public function get_option_name() {
130
- return 'wp_google_analytics_events';
131
- }
132
-
133
- /**
134
- * Plugin file name
135
- *
136
- * @return string
137
- *
138
- * @since 1.3.0
139
- */
140
- public function get_plugin_file() {
141
- return 'wp-google-analytics-events/ga-scroll-event.php';
142
- }
143
-
144
- /**
145
- * Returns checked cookie types
146
- * @return mixed
147
- *
148
- * @since 1.3.0
149
- */
150
- public function get_cookie_types() {
151
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
152
- }
153
-
154
- /**
155
- * Returns default cookie types
156
- * @return array
157
- *
158
- * @since 1.5.0
159
- */
160
- public function get_default_cookie_types() {
161
- return array( 'statistics' );
162
- }
163
-
164
- /**
165
- * Check if plugin is activated and checked in the backend
166
- *
167
- * @since 1.3.0
168
- */
169
- public function is_addon_enabled() {
170
- return $this->settings->is_addon_enabled( $this->get_option_name() );
171
- }
172
-
173
- /**
174
- * Checks if addon is installed
175
- *
176
- * @since 1.3.0
177
- */
178
- public function is_addon_installed() {
179
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
180
- }
181
-
182
- /**
183
- * Checks if addon is activated
184
- *
185
- * @since 1.3.0
186
- */
187
- public function is_addon_activated() {
188
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
189
- }
190
-
191
- /**
192
- * Retrieves current installed version of the addon
193
- *
194
- * @return bool
195
- *
196
- * @since 2.2.1
197
- */
198
- public function get_addon_version() {
199
- return $this->settings->get_addon_version( $this->get_plugin_file() );
200
- }
201
-
202
- /**
203
- * Checks if it does have custom placeholder content
204
- *
205
- * @return mixed
206
- *
207
- * @since 1.8.0
208
- */
209
- public function has_placeholder() {
210
- return $this->settings->has_placeholder( $this->get_option_name() );
211
- }
212
-
213
- /**
214
- * returns all placeholder contents
215
- *
216
- * @return mixed
217
- *
218
- * @since 1.8.0
219
- */
220
- public function get_placeholders() {
221
- return $this->settings->get_placeholders( $this->get_option_name() );
222
- }
223
-
224
- /**
225
- * Return true if the placeholder is enabled
226
- *
227
- * @return mixed
228
- *
229
- * @since 1.8.0
230
- */
231
- public function is_placeholder_enabled() {
232
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
233
- }
234
-
235
- /**
236
- * Adds extra information under the label
237
- *
238
- * @return string
239
- *
240
- * @since 1.8.0
241
- */
242
- public function get_extra_information() {
243
- return '<p>' . esc_html__( 'The plugin allows you to fire events whenever someone interacts or views elements on your website.',
244
- 'cookiebot-addons' ) . '</p>';
245
- }
246
-
247
- /**
248
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
249
- *
250
- * @return string
251
- *
252
- * @since 1.8.0
253
- */
254
- public function get_svn_url() {
255
- return 'http://plugins.svn.wordpress.org/wp-google-analytics-events/trunk/ga-scroll-event.php';
256
- }
257
-
258
- /**
259
- * Placeholder helper overlay in the settings page.
260
- *
261
- * @return string
262
- *
263
- * @since 1.8.0
264
- */
265
- public function get_placeholder_helper() {
266
- 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>';
267
- }
268
-
269
-
270
- /**
271
- * Returns parent class or false
272
- *
273
- * @return string|bool
274
- *
275
- * @since 2.1.3
276
- */
277
- public function get_parent_class() {
278
- return get_parent_class( $this );
279
- }
280
-
281
- /**
282
- * Action after enabling the addon on the settings page
283
- *
284
- * @since 2.2.0
285
- */
286
- public function post_hook_after_enabling() {
287
- //do nothing
288
- }
289
-
290
- /**
291
- * Cookiebot plugin is deactivated
292
- *
293
- * @since 2.2.0
294
- */
295
- public function plugin_deactivated() {
296
- //do nothing
297
- }
298
-
299
- /**
300
- * @return mixed
301
- *
302
- * @since 2.4.5
303
- */
304
- public function extra_available_addon_option() {
305
- //do nothing
306
- }
307
-
308
- /**
309
- * Returns boolean to enable/disable plugin by default
310
- *
311
- * @return bool
312
- *
313
- * @since 3.6.3
314
- */
315
- public function enable_by_default() {
316
- return false;
317
- }
318
-
319
- /**
320
- * Sets default settings for this addon
321
- *
322
- * @return array
323
- *
324
- * @since 3.6.3
325
- */
326
- public function get_default_enable_setting() {
327
- return array(
328
- 'enabled' => 1,
329
- 'cookie_type' => $this->get_default_cookie_types(),
330
- 'placeholder' => $this->get_default_placeholder(),
331
- );
332
- }
333
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/wp-mautic/wp-mautic.php DELETED
@@ -1,334 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\wp_mautic;
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 Wp_Mautic implements Cookiebot_Addons_Interface {
12
-
13
- /**
14
- * @var Settings_Service_Interface
15
- *
16
- * @since 1.5.0
17
- */
18
- protected $settings;
19
-
20
- /**
21
- * @var Script_Loader_Tag_Interface
22
- *
23
- * @since 1.5.0
24
- */
25
- protected $script_loader_tag;
26
-
27
- /**
28
- * @var Cookie_Consent_Interface
29
- *
30
- * @since 1.5.0
31
- */
32
- public $cookie_consent;
33
-
34
- /**
35
- * @var Buffer_Output_Interface
36
- *
37
- * @since 1.5.0
38
- */
39
- protected $buffer_output;
40
-
41
- /**
42
- * 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.5.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.5.0
62
- */
63
- public function load_configuration() {
64
- add_action( 'wp_loaded', array( $this, 'cookiebot_addon_mautic' ), 5 );
65
- }
66
-
67
- /**
68
- * Disable scripts if state not accepted
69
- *
70
- * @since 1.5.0
71
- */
72
- public function cookiebot_addon_mautic() {
73
- $this->buffer_output->add_tag( 'wp_head', 10, array(
74
- 'MauticTrackingObject' => $this->get_cookie_types()
75
- ), false );
76
- $this->buffer_output->add_tag( 'wp_footer', 10, array(
77
- 'MauticTrackingObject' => $this->get_cookie_types()
78
- ), false );
79
-
80
- //Remove noscript tracking
81
- if( has_action( 'wp_footer', 'wpmautic_inject_noscript' ) ) {
82
- remove_action( 'wp_footer', 'wpmautic_inject_noscript' );
83
- }
84
- }
85
-
86
- /**
87
- * Return addon/plugin name
88
- *
89
- * @return string
90
- *
91
- * @since 1.5.0
92
- */
93
- public function get_addon_name() {
94
- return 'Mautic';
95
- }
96
-
97
- /**
98
- * Option name in the database
99
- *
100
- * @return string
101
- *
102
- * @since 1.5.0
103
- */
104
- public function get_option_name() {
105
- return 'mautic';
106
- }
107
-
108
- /**
109
- * Plugin file name
110
- *
111
- * @return string
112
- *
113
- * @since 1.5.0
114
- */
115
- public function get_plugin_file() {
116
- return 'wp-mautic/wpmautic.php';
117
- }
118
-
119
- /**
120
- * Returns checked cookie types
121
- * @return mixed
122
- *
123
- * @since 1.5.0
124
- */
125
- public function get_cookie_types() {
126
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
127
- }
128
-
129
- /**
130
- * Returns default cookie types
131
- * @return array
132
- *
133
- * @since 1.5.0
134
- */
135
- public function get_default_cookie_types() {
136
- return array( 'statistics' );
137
- }
138
-
139
- /**
140
- * Check if plugin is activated and checked in the backend
141
- *
142
- * @since 1.5.0
143
- */
144
- public function is_addon_enabled() {
145
- return $this->settings->is_addon_enabled( $this->get_option_name() );
146
- }
147
-
148
- /**
149
- * Checks if addon is installed
150
- *
151
- * @since 1.5.0
152
- */
153
- public function is_addon_installed() {
154
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
155
- }
156
-
157
- /**
158
- * Checks if addon is activated
159
- *
160
- * @since 1.5.0
161
- */
162
- public function is_addon_activated() {
163
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
164
- }
165
-
166
- /**
167
- * Retrieves current installed version of the addon
168
- *
169
- * @return bool
170
- *
171
- * @since 2.2.1
172
- */
173
- public function get_addon_version() {
174
- return $this->settings->get_addon_version( $this->get_plugin_file() );
175
- }
176
-
177
- /**
178
- * Default placeholder content
179
- *
180
- * @return string
181
- *
182
- * @since 1.8.0
183
- */
184
- public function get_default_placeholder() {
185
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
186
- }
187
-
188
- /**
189
- * Get placeholder content
190
- *
191
- * This function will check following features:
192
- * - Current language
193
- *
194
- * @param $src
195
- *
196
- * @return bool|mixed
197
- *
198
- * @since 1.8.0
199
- */
200
- public function get_placeholder( $src = '' ) {
201
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
202
- }
203
-
204
- /**
205
- * Checks if it does have custom placeholder content
206
- *
207
- * @return mixed
208
- *
209
- * @since 1.8.0
210
- */
211
- public function has_placeholder() {
212
- return $this->settings->has_placeholder( $this->get_option_name() );
213
- }
214
-
215
- /**
216
- * returns all placeholder contents
217
- *
218
- * @return mixed
219
- *
220
- * @since 1.8.0
221
- */
222
- public function get_placeholders() {
223
- return $this->settings->get_placeholders( $this->get_option_name() );
224
- }
225
-
226
- /**
227
- * Return true if the placeholder is enabled
228
- *
229
- * @return mixed
230
- *
231
- * @since 1.8.0
232
- */
233
- public function is_placeholder_enabled() {
234
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
235
- }
236
-
237
- /**
238
- * Adds extra information under the label
239
- *
240
- * @return string
241
- *
242
- * @since 1.8.0
243
- */
244
- public function get_extra_information() {
245
- return false;
246
- }
247
-
248
- /**
249
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
250
- *
251
- * @return boolean
252
- *
253
- * @since 1.8.0
254
- */
255
- public function get_svn_url() {
256
- return 'https://plugins.svn.wordpress.org/wp-mautic/trunk/wpmautic.php';
257
- }
258
-
259
- /**
260
- * Placeholder helper overlay in the settings page.
261
- *
262
- * @return string
263
- *
264
- * @since 1.8.0
265
- */
266
- public function get_placeholder_helper() {
267
- 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>';
268
- }
269
-
270
-
271
- /**
272
- * Returns parent class or false
273
- *
274
- * @return string|bool
275
- *
276
- * @since 2.1.3
277
- */
278
- public function get_parent_class() {
279
- return get_parent_class( $this );
280
- }
281
-
282
- /**
283
- * Action after enabling the addon on the settings page
284
- *
285
- * @since 2.2.0
286
- */
287
- public function post_hook_after_enabling() {
288
- //do nothing
289
- }
290
-
291
- /**
292
- * Cookiebot plugin is deactivated
293
- *
294
- * @since 2.2.0
295
- */
296
- public function plugin_deactivated() {
297
- //do nothing
298
- }
299
-
300
- /**
301
- * @return mixed
302
- *
303
- * @since 2.4.5
304
- */
305
- public function extra_available_addon_option() {
306
- //do nothing
307
- }
308
-
309
- /**
310
- * Returns boolean to enable/disable plugin by default
311
- *
312
- * @return bool
313
- *
314
- * @since 3.6.3
315
- */
316
- public function enable_by_default() {
317
- return false;
318
- }
319
-
320
- /**
321
- * Sets default settings for this addon
322
- *
323
- * @return array
324
- *
325
- * @since 3.6.3
326
- */
327
- public function get_default_enable_setting() {
328
- return array(
329
- 'enabled' => 1,
330
- 'cookie_type' => $this->get_default_cookie_types(),
331
- 'placeholder' => $this->get_default_placeholder(),
332
- );
333
- }
334
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/wp-piwik/wp-piwik.php DELETED
@@ -1,354 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\wp_piwik;
4
-
5
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
6
-
7
- use cookiebot_addons\controller\addons\Cookiebot_Addons_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\buffer\Buffer_Output_Interface;
11
- use cookiebot_addons\lib\Settings_Service_Interface;
12
- use WP_Piwik\Settings;
13
-
14
- class Wp_Piwik implements Cookiebot_Addons_Interface {
15
-
16
- /**
17
- * @var Settings_Service_Interface
18
- *
19
- * @since 1.3.0
20
- */
21
- protected $settings;
22
-
23
- /**
24
- * @var Script_Loader_Tag_Interface
25
- *
26
- * @since 1.3.0
27
- */
28
- protected $script_loader_tag;
29
-
30
- /**
31
- * @var Cookie_Consent_Interface
32
- *
33
- * @since 1.3.0
34
- */
35
- public $cookie_consent;
36
-
37
- /**
38
- * @var Buffer_Output_Interface
39
- *
40
- * @since 1.3.0
41
- */
42
- protected $buffer_output;
43
-
44
- /**
45
- * Jetpack constructor.
46
- *
47
- * @param $settings Settings_Service_Interface
48
- * @param $script_loader_tag Script_Loader_Tag_Interface
49
- * @param $cookie_consent Cookie_Consent_Interface
50
- * @param $buffer_output Buffer_Output_Interface
51
- *
52
- * @since 1.3.0
53
- */
54
- public function __construct(
55
- Settings_Service_Interface $settings,
56
- Script_Loader_Tag_Interface $script_loader_tag,
57
- Cookie_Consent_Interface $cookie_consent,
58
- Buffer_Output_Interface $buffer_output
59
- ) {
60
- $this->settings = $settings;
61
- $this->script_loader_tag = $script_loader_tag;
62
- $this->cookie_consent = $cookie_consent;
63
- $this->buffer_output = $buffer_output;
64
- }
65
-
66
- /**
67
- * Loads addon configuration
68
- *
69
- * @since 1.3.0
70
- */
71
- public function load_configuration() {
72
- /**
73
- * We add the action after wp_loaded and check cookie settings from wp-piwik
74
- */
75
- add_action( 'wp_loaded', array( $this, 'cookiebot_addon_wp_piwik' ), 10 );
76
- }
77
-
78
- /**
79
- * Manipulate the scripts if they are loaded.
80
- *
81
- * @since 1.3.0
82
- */
83
- public function cookiebot_addon_wp_piwik() {
84
- if ( ! $this->cookie_consent->are_cookie_states_accepted( $this->get_cookie_types() ) ) {
85
- // wp_footer
86
- $this->buffer_output->add_tag( 'wp_footer',
87
- 10,
88
- array(
89
- 'matomo' => $this->get_cookie_types(),
90
- ),
91
- false );
92
-
93
- // wp_head
94
- $this->buffer_output->add_tag( 'wp_head',
95
- 10,
96
- array(
97
- 'matomo' => $this->get_cookie_types(),
98
- ),
99
- false );
100
- }
101
- }
102
-
103
- /**
104
- * Check if plugin is activated and checked in the backend
105
- *
106
- * @since 1.3.0
107
- */
108
- public function is_addon_enabled() {
109
- return $this->settings->is_addon_enabled( $this->get_option_name() );
110
- }
111
-
112
- /**
113
- * Option name in the database
114
- *
115
- * @return string
116
- *
117
- * @since 1.3.0
118
- */
119
- public function get_option_name() {
120
- return 'wp_piwik';
121
- }
122
-
123
- /**
124
- * Returns checked cookie types
125
- * @return mixed
126
- *
127
- * @since 1.3.0
128
- */
129
- public function get_cookie_types() {
130
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
131
- }
132
-
133
- /**
134
- * Returns default cookie types
135
- * @return array
136
- *
137
- * @since 1.3.0
138
- */
139
- public function get_default_cookie_types() {
140
- return array( 'statistics' );
141
- }
142
-
143
- /**
144
- * Return addon/plugin name
145
- *
146
- * @return string
147
- *
148
- * @since 1.3.0
149
- */
150
- public function get_addon_name() {
151
- return 'WP Piwik';
152
- }
153
-
154
- /**
155
- * Checks if addon is installed
156
- *
157
- * @since 1.3.0
158
- */
159
- public function is_addon_installed() {
160
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
161
- }
162
-
163
- /**
164
- * Plugin file name
165
- *
166
- * @return string
167
- *
168
- * @since 1.3.0
169
- */
170
- public function get_plugin_file() {
171
- return 'wp-piwik/wp-piwik.php';
172
- }
173
-
174
- /**
175
- * Checks if addon is activated
176
- *
177
- * @since 1.3.0
178
- */
179
- public function is_addon_activated() {
180
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
181
- }
182
-
183
- /**
184
- * Retrieves current installed version of the addon
185
- *
186
- * @return bool
187
- *
188
- * @since 2.2.1
189
- */
190
- public function get_addon_version() {
191
- return $this->settings->get_addon_version( $this->get_plugin_file() );
192
- }
193
-
194
- /**
195
- * Default placeholder content
196
- *
197
- * @return string
198
- *
199
- * @since 1.8.0
200
- */
201
- public function get_default_placeholder() {
202
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
203
- }
204
-
205
- /**
206
- * Get placeholder content
207
- *
208
- * This function will check following features:
209
- * - Current language
210
- *
211
- * @param $src
212
- *
213
- * @return bool|mixed
214
- *
215
- * @since 1.8.0
216
- */
217
- public function get_placeholder( $src = '' ) {
218
- return $this->settings->get_placeholder( $this->get_option_name(),
219
- $this->get_default_placeholder(),
220
- cookiebot_addons_output_cookie_types( $this->get_cookie_types() ),
221
- $src );
222
- }
223
-
224
- /**
225
- * Checks if it does have custom placeholder content
226
- *
227
- * @return mixed
228
- *
229
- * @since 1.8.0
230
- */
231
- public function has_placeholder() {
232
- return $this->settings->has_placeholder( $this->get_option_name() );
233
- }
234
-
235
- /**
236
- * returns all placeholder contents
237
- *
238
- * @return mixed
239
- *
240
- * @since 1.8.0
241
- */
242
- public function get_placeholders() {
243
- return $this->settings->get_placeholders( $this->get_option_name() );
244
- }
245
-
246
- /**
247
- * Return true if the placeholder is enabled
248
- *
249
- * @return mixed
250
- *
251
- * @since 1.8.0
252
- */
253
- public function is_placeholder_enabled() {
254
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
255
- }
256
-
257
- /**
258
- * Adds extra information under the label
259
- *
260
- * @return string
261
- *
262
- * @since 1.8.0
263
- */
264
- public function get_extra_information() {
265
- return false;
266
- }
267
-
268
- /**
269
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
270
- *
271
- * @return boolean
272
- *
273
- * @since 1.8.0
274
- */
275
- public function get_svn_url() {
276
- return 'http://plugins.svn.wordpress.org/wp-piwik/trunk/wp-piwik.php';
277
- }
278
-
279
- /**
280
- * Placeholder helper overlay in the settings page.
281
- *
282
- * @return string
283
- *
284
- * @since 1.8.0
285
- */
286
- public function get_placeholder_helper() {
287
- 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>';
288
- }
289
-
290
-
291
- /**
292
- * Returns parent class or false
293
- *
294
- * @return string|bool
295
- *
296
- * @since 2.1.3
297
- */
298
- public function get_parent_class() {
299
- return get_parent_class( $this );
300
- }
301
-
302
- /**
303
- * Action after enabling the addon on the settings page
304
- *
305
- * @since 2.2.0
306
- */
307
- public function post_hook_after_enabling() {
308
- //do nothing
309
- }
310
-
311
- /**
312
- * Cookiebot plugin is deactivated
313
- *
314
- * @since 2.2.0
315
- */
316
- public function plugin_deactivated() {
317
- //do nothing
318
- }
319
-
320
- /**
321
- * @return mixed
322
- *
323
- * @since 2.4.5
324
- */
325
- public function extra_available_addon_option() {
326
- //do nothing
327
- }
328
-
329
- /**
330
- * Returns boolean to enable/disable plugin by default
331
- *
332
- * @return bool
333
- *
334
- * @since 3.6.3
335
- */
336
- public function enable_by_default() {
337
- return false;
338
- }
339
-
340
- /**
341
- * Sets default settings for this addon
342
- *
343
- * @return array
344
- *
345
- * @since 3.6.3
346
- */
347
- public function get_default_enable_setting() {
348
- return array(
349
- 'enabled' => 1,
350
- 'cookie_type' => $this->get_default_cookie_types(),
351
- 'placeholder' => $this->get_default_placeholder(),
352
- );
353
- }
354
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/wp-rocket/wp-rocket.php DELETED
@@ -1,343 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\wp_rocket;
4
-
5
- use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
6
- use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
7
- use cookiebot_addons\lib\Cookie_Consent_Interface;
8
- use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
9
- use cookiebot_addons\lib\Settings_Service_Interface;
10
-
11
- class Wp_Rocket 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(
52
- Settings_Service_Interface $settings,
53
- Script_Loader_Tag_Interface $script_loader_tag,
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
- /**
64
- * Loads addon configuration
65
- *
66
- * @since 1.3.0
67
- */
68
- public function load_configuration() {
69
- /**
70
- * Exclude Cookiebot files from defer setting
71
- */
72
- add_filter( 'rocket_exclude_defer_js', array( $this, 'exclude_files' ) );
73
- }
74
-
75
- /**
76
- * Exclude scripts from WP Rocket’s defer JS option.
77
- *
78
- * @param array $excluded_files Array of script URLs to be excluded
79
- *
80
- * @return array Extended array script URLs to be excluded
81
- *
82
- * @author Caspar Hübinger
83
- * @since 3.6.2
84
- */
85
- public function exclude_files( $excluded_files = array() ) {
86
- $excluded_files[] = 'consent.cookiebot.com';
87
-
88
- return $excluded_files;
89
- }
90
-
91
- /**
92
- * Check if plugin is activated and checked in the backend
93
- *
94
- * @since 1.3.0
95
- */
96
- public function is_addon_enabled() {
97
- return $this->settings->is_addon_enabled( $this->get_option_name() );
98
- }
99
-
100
- /**
101
- * Option name in the database
102
- *
103
- * @return string
104
- *
105
- * @since 1.3.0
106
- */
107
- public function get_option_name() {
108
- return 'wp_rocket';
109
- }
110
-
111
- /**
112
- * Returns checked cookie types
113
- * @return mixed
114
- *
115
- * @since 1.3.0
116
- */
117
- public function get_cookie_types() {
118
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
119
- }
120
-
121
- /**
122
- * Returns default cookie types
123
- * @return array
124
- *
125
- * @since 1.3.0
126
- */
127
- public function get_default_cookie_types() {
128
- return array( 'statistics' );
129
- }
130
-
131
- /**
132
- * Return addon/plugin name
133
- *
134
- * @return string
135
- *
136
- * @since 1.3.0
137
- */
138
- public function get_addon_name() {
139
- return 'WP Rocket';
140
- }
141
-
142
- /**
143
- * Checks if addon is installed
144
- *
145
- * @since 1.3.0
146
- */
147
- public function is_addon_installed() {
148
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
149
- }
150
-
151
- /**
152
- * Plugin file name
153
- *
154
- * @return string
155
- *
156
- * @since 1.3.0
157
- */
158
- public function get_plugin_file() {
159
- return 'wp-rocket/wp-rocket.php';
160
- }
161
-
162
- /**
163
- * Checks if addon is activated
164
- *
165
- * @since 1.3.0
166
- */
167
- public function is_addon_activated() {
168
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
169
- }
170
-
171
- /**
172
- * Retrieves current installed version of the addon
173
- *
174
- * @return bool
175
- *
176
- * @since 2.2.1
177
- */
178
- public function get_addon_version() {
179
- return $this->settings->get_addon_version( $this->get_plugin_file() );
180
- }
181
-
182
- /**
183
- * Default placeholder content
184
- *
185
- * @return string
186
- *
187
- * @since 1.8.0
188
- */
189
- public function get_default_placeholder() {
190
- return '';
191
- }
192
-
193
- /**
194
- * Get placeholder content
195
- *
196
- * This function will check following features:
197
- * - Current language
198
- *
199
- * @param $src
200
- *
201
- * @return bool|mixed
202
- *
203
- * @since 1.8.0
204
- */
205
- public function get_placeholder( $src = '' ) {
206
- return $this->settings->get_placeholder( $this->get_option_name(),
207
- $this->get_default_placeholder(),
208
- cookiebot_addons_output_cookie_types( $this->get_cookie_types() ),
209
- $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 '<p>' . esc_html__( 'Excludes cookiebot javascript files when the WP-Rocket deter option is enabled.',
254
- 'cookiebot-addons' ) . '</p>';;
255
- }
256
-
257
- /**
258
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
259
- *
260
- * @return boolean
261
- *
262
- * @since 1.8.0
263
- */
264
- public function get_svn_url() {
265
- return false;
266
- }
267
-
268
- /**
269
- * Placeholder helper overlay in the settings page.
270
- *
271
- * @return string
272
- *
273
- * @since 1.8.0
274
- */
275
- public function get_placeholder_helper() {
276
- 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>';
277
- }
278
-
279
-
280
- /**
281
- * Returns parent class or false
282
- *
283
- * @return string|bool
284
- *
285
- * @since 2.1.3
286
- */
287
- public function get_parent_class() {
288
- return get_parent_class( $this );
289
- }
290
-
291
- /**
292
- * Action after enabling the addon on the settings page
293
- *
294
- * @since 2.2.0
295
- */
296
- public function post_hook_after_enabling() {
297
- //do nothing
298
- }
299
-
300
- /**
301
- * Cookiebot plugin is deactivated
302
- *
303
- * @since 2.2.0
304
- */
305
- public function plugin_deactivated() {
306
- //do nothing
307
- }
308
-
309
- /**
310
- * @return mixed
311
- *
312
- * @since 2.4.5
313
- */
314
- public function extra_available_addon_option() {
315
- //do nothing
316
- }
317
-
318
- /**
319
- * Returns boolean to enable/disable plugin by default
320
- *
321
- * @return bool
322
- *
323
- * @since 3.6.3
324
- */
325
- public function enable_by_default() {
326
- return true;
327
- }
328
-
329
- /**
330
- * Sets default settings for this addon
331
- *
332
- * @return array
333
- *
334
- * @since 3.6.3
335
- */
336
- public function get_default_enable_setting() {
337
- return array(
338
- 'enabled' => 1,
339
- 'cookie_type' => $this->get_default_cookie_types(),
340
- 'placeholder' => $this->get_default_placeholder(),
341
- );
342
- }
343
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/wpforms/cookie-after-consent.js DELETED
@@ -1,51 +0,0 @@
1
- ( function ( $ ) {
2
-
3
- var cookiebot_wpforms = {
4
-
5
- init: function () {
6
- $( document ).ready( cookiebot_wpforms.update_after_consent );
7
- },
8
-
9
- /**
10
- * Async wpfuuid after the visitor clicked on cookie accept
11
- */
12
- update_after_consent: function () {
13
- window.addEventListener( 'CookiebotOnAccept', function ( e ) {
14
-
15
- if ( Cookiebot
16
- && Cookiebot.consent
17
- && Cookiebot.consent.preferences
18
- && window.wpforms
19
- && !window.wpforms.getCookie( '_wpfuuid' ) ) {
20
- window.wpforms.setUserIndentifier();
21
- }
22
- }, false );
23
- }
24
- };
25
-
26
- /**
27
- * Make global hasRequiredConsent function to check cookie consent status
28
- *
29
- * @return {boolean}
30
- */
31
- window.hasRequiredConsent = function hasRequiredConsent() {
32
- if ( Cookiebot && Cookiebot.consent ) {
33
- let cookie_types = cookiebot_wpforms_settings.cookie_types;
34
- let required = cookie_types.length;
35
-
36
- const consent_given = cookie_types.filter(function(cookie_type){
37
- return Cookiebot.consent[cookie_type];
38
- });
39
-
40
- if( required == consent_given.length ) {
41
- return true;
42
- }
43
- }
44
-
45
- return false;
46
- };
47
-
48
- cookiebot_wpforms.init();
49
-
50
-
51
- } )( jQuery );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/addons/wpforms/wpforms.php DELETED
@@ -1,395 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller\addons\wpforms;
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 Wpforms 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_wpforms' ), 5 );
65
- }
66
-
67
- /**
68
- * Disable scripts if state not accepted
69
- *
70
- * @since 1.3.0
71
- */
72
- public function cookiebot_addon_wpforms() {
73
- add_filter( 'wpforms_disable_entry_user_ip', array( $this, 'gdpr_consent_is_given' ) );
74
- add_action( 'wp_footer', array( $this, 'enqueue_script_for_adding_the_cookie_after_the_consent' ), 18 );
75
- }
76
-
77
- /**
78
- * Create cookie when the visitor gives consent
79
- */
80
- public function enqueue_script_for_adding_the_cookie_after_the_consent() {
81
- wp_enqueue_script( 'wpforms-gdpr-cookiebot',
82
- COOKIEBOT_URL . 'addons/controller/addons/wpforms/cookie-after-consent.js',
83
- array( 'jquery' ),
84
- '',
85
- true );
86
- wp_localize_script( 'wpforms-gdpr-cookiebot', 'cookiebot_wpforms_settings', array( 'cookie_types' => $this->get_cookie_types() ) );
87
- }
88
-
89
- /**
90
- * Retrieve if the cookie consent is given
91
- *
92
- * @return bool
93
- *
94
- * @since 2.1.4
95
- */
96
- public function gdpr_consent_is_given() {
97
- if ( $this->cookie_consent->are_cookie_states_accepted( $this->get_cookie_types() ) ) {
98
- return true;
99
- }
100
-
101
- return false;
102
- }
103
-
104
- /**
105
- * Return addon/plugin name
106
- *
107
- * @return string
108
- *
109
- * @since 1.3.0
110
- */
111
- public function get_addon_name() {
112
- return 'WPForms';
113
- }
114
-
115
- /**
116
- * Default placeholder content
117
- *
118
- * @return string
119
- *
120
- * @since 1.8.0
121
- */
122
- public function get_default_placeholder() {
123
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to enable saving user information.';
124
- }
125
-
126
- /**
127
- * Get placeholder content
128
- *
129
- * This function will check following features:
130
- * - Current language
131
- *
132
- * @param $src
133
- *
134
- * @return bool|mixed
135
- *
136
- * @since 1.8.0
137
- */
138
- public function get_placeholder( $src = '' ) {
139
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
140
- }
141
-
142
- /**
143
- * Option name in the database
144
- *
145
- * @return string
146
- *
147
- * @since 1.3.0
148
- */
149
- public function get_option_name() {
150
- return 'wpforms';
151
- }
152
-
153
- /**
154
- * Plugin file name
155
- *
156
- * @return string
157
- *
158
- * @since 1.3.0
159
- */
160
- public function get_plugin_file() {
161
- return 'wpforms/wpforms.php';
162
- }
163
-
164
- /**
165
- * Returns checked cookie types
166
- * @return mixed
167
- *
168
- * @since 1.3.0
169
- */
170
- public function get_cookie_types() {
171
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
172
- }
173
-
174
- /**
175
- * Returns default cookie types
176
- * @return array
177
- *
178
- * @since 1.5.0
179
- */
180
- public function get_default_cookie_types() {
181
- return array( 'preferences' );
182
- }
183
-
184
- /**
185
- * Check if plugin is activated and checked in the backend
186
- *
187
- * @since 1.3.0
188
- */
189
- public function is_addon_enabled() {
190
- return $this->settings->is_addon_enabled( $this->get_option_name() );
191
- }
192
-
193
- /**
194
- * Checks if addon is installed
195
- *
196
- * @since 1.3.0
197
- */
198
- public function is_addon_installed() {
199
- $installed = $this->settings->is_addon_installed( $this->get_plugin_file() );
200
-
201
- if ( $installed && version_compare( $this->get_addon_version(), '1.5.1', '<' ) ) {
202
- $installed = false;
203
- }
204
-
205
- return $installed;
206
- }
207
-
208
- /**
209
- * Checks if addon is activated
210
- *
211
- * @since 1.3.0
212
- */
213
- public function is_addon_activated() {
214
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
215
- }
216
-
217
- /**
218
- * Retrieves current installed version of the addon
219
- *
220
- * @return bool
221
- *
222
- * @since 2.2.1
223
- */
224
- public function get_addon_version() {
225
- return $this->settings->get_addon_version( $this->get_plugin_file() );
226
- }
227
-
228
- /**
229
- * Checks if it does have custom placeholder content
230
- *
231
- * @return mixed
232
- *
233
- * @since 1.8.0
234
- */
235
- public function has_placeholder() {
236
- return $this->settings->has_placeholder( $this->get_option_name() );
237
- }
238
-
239
- /**
240
- * returns all placeholder contents
241
- *
242
- * @return mixed
243
- *
244
- * @since 1.8.0
245
- */
246
- public function get_placeholders() {
247
- return $this->settings->get_placeholders( $this->get_option_name() );
248
- }
249
-
250
- /**
251
- * Return true if the placeholder is enabled
252
- *
253
- * @return mixed
254
- *
255
- * @since 1.8.0
256
- */
257
- public function is_placeholder_enabled() {
258
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
259
- }
260
-
261
- /**
262
- * Adds extra information under the label
263
- *
264
- * @return string
265
- *
266
- * @since 1.8.0
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
-
276
- /**
277
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
278
- *
279
- * @return string
280
- *
281
- * @since 1.8.0
282
- */
283
- public function get_svn_url() {
284
- return false;
285
- }
286
-
287
- /**
288
- * Placeholder helper overlay in the settings page.
289
- *
290
- * @return string
291
- *
292
- * @since 1.8.0
293
- */
294
- public function get_placeholder_helper() {
295
- 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>';
296
- }
297
-
298
- /**
299
- * Returns parent class or false
300
- *
301
- * @return string|bool
302
- *
303
- * @since 2.1.3
304
- */
305
- public function get_parent_class() {
306
- return get_parent_class( $this );
307
- }
308
-
309
- /**
310
- * Action after enabling the addon on the settings page
311
- *
312
- * Clear gdpr settings in the wpforms
313
- *
314
- * @since 2.2.0
315
- */
316
- public function post_hook_after_enabling() {
317
- $wpforms_settings = get_option( 'wpforms_settings' );
318
-
319
- $wpforms_settings['gdpr'] = false;
320
- $wpforms_settings['gdpr-disable-uuid'] = false;
321
- $wpforms_settings['gdpr-disable-details'] = false;
322
-
323
- update_option( 'wpforms_settings', $wpforms_settings );
324
- }
325
-
326
- /**
327
- * Cookiebot plugin is deactivated
328
- *
329
- * @since 2.2.0
330
- */
331
- public function plugin_deactivated() {
332
- // if the checkbox was checked and the cookiebot plugin is deactivated
333
- // remove the setting so the default gdpr checkboxes are still visible
334
- $this->wpforms_set_setting( 'gdpr-cookiebot', false );
335
- }
336
-
337
- /**
338
- * Set the value of a specific WPForms setting.
339
- *
340
- * @since 1.5.0.4
341
- *
342
- * @param string $key
343
- * @param mixed $new_value
344
- * @param string $option
345
- *
346
- * @return mixed
347
- */
348
- public function wpforms_set_setting( $key, $new_value, $option = 'wpforms_settings' ) {
349
-
350
- $key = wpforms_sanitize_key( $key );
351
- $options = get_option( $option, false );
352
- $option_value = is_array( $options ) && ! empty( $options[ $key ] ) ? $options[ $key ] : false;
353
-
354
- if ( $new_value !== $option_value ) {
355
- $options[ $key ] = $new_value;
356
- }
357
-
358
- update_option( $option, $options );
359
- }
360
-
361
- /**
362
- * @return mixed
363
- *
364
- * @since 2.4.5
365
- */
366
- public function extra_available_addon_option() {
367
- //do nothing
368
- }
369
-
370
- /**
371
- * Returns boolean to enable/disable plugin by default
372
- *
373
- * @return bool
374
- *
375
- * @since 3.6.3
376
- */
377
- public function enable_by_default() {
378
- return false;
379
- }
380
-
381
- /**
382
- * Sets default settings for this addon
383
- *
384
- * @return array
385
- *
386
- * @since 3.6.3
387
- */
388
- public function get_default_enable_setting() {
389
- return array(
390
- 'enabled' => 1,
391
- 'cookie_type' => $this->get_default_cookie_types(),
392
- 'placeholder' => $this->get_default_placeholder(),
393
- );
394
- }
395
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/controller/plugin-controller.php DELETED
@@ -1,129 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\controller;
4
-
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 Cookiebot_WP;
9
- use Cybot\Dependencies\DI;
10
- use Exception;
11
-
12
- /**
13
- * Class Plugin_Controller
14
- * @package cookiebot_addons\controller
15
- */
16
- class Plugin_Controller {
17
-
18
- /**
19
- * IoC container - Dependency Injection
20
- *
21
- * @var Settings_Service_Interface
22
- *
23
- * @since 1.1.0
24
- */
25
- private $settings_service;
26
-
27
- /**
28
- * Plugin_Controller constructor.
29
- *
30
- * @param $settings_service Settings_Service_Interface IoC Container
31
- *
32
- * @since 1.2.0
33
- */
34
- public function __construct( Settings_Service_Interface $settings_service ) {
35
- $this->settings_service = $settings_service;
36
- $this->load_init_files();
37
- }
38
-
39
- /**
40
- * Load init files to use 'validate_plugin' and 'is_plugin_active'
41
- *
42
- * @since 1.3.0
43
- */
44
- protected function load_init_files() {
45
- if ( ! function_exists( 'is_plugin_active' ) ) {
46
- require_once ABSPATH . '/wp-admin/includes/plugin.php';
47
- require_once ABSPATH . '/wp-includes/l10n.php';
48
- require_once ABSPATH . '/wp-admin/includes/translation-install.php';
49
- }
50
- }
51
-
52
- /**
53
- * Load addon configuration if the plugin is activated
54
- *
55
- * @throws Exception
56
- * @since 1.2.0
57
- * @version 1.3.0
58
- */
59
- public function load_active_addons() {
60
- /**
61
- * Check if Cookiebot is activated and active. Return if cookiebot is inactive
62
- */
63
- if ( ! function_exists( 'cookiebot_active' ) || ! cookiebot_active() ) {
64
- return;
65
- }
66
-
67
- if ( Cookiebot_WP::cookiebot_disabled_in_admin() === true && is_admin() ) {
68
- return;
69
- }
70
-
71
- /**
72
- * Check plugins one by one and load configuration if it is active
73
- *
74
- * @var $plugin Cookiebot_Addons_Interface
75
- */
76
- $addons_enabled_counter = 0;
77
- foreach ( $this->settings_service->get_active_addons() as $plugin ) {
78
- if ( ! $plugin->cookie_consent->are_cookie_states_accepted( $plugin->get_cookie_types() )
79
- || cookiebot_addons_enabled_cache_plugin() ) {
80
- $plugin->load_configuration();
81
- $addons_enabled_counter++;
82
- }
83
- }
84
-
85
- /**
86
- * After WordPress is fully loaded
87
- *
88
- * Run buffer output actions - this runs after scanning of every addons
89
- */
90
- add_action( 'parse_request', array( $this, 'run_buffer_output_manipulations' ) );
91
-
92
- /**
93
- * Add notice for the user if any addons is enabled and cookie
94
- * blocking mode is set to auto.
95
- */
96
- if ( $addons_enabled_counter > 0 && Cookiebot_WP::get_cookie_blocking_mode() === 'auto' ) {
97
- //phpcs:ignore WordPress.Security.NonceVerification.Recommended
98
- if ( isset( $_GET['page'] ) && in_array( $_GET['page'], array( 'cookiebot', 'cookiebot-addons' ), true ) ) {
99
- add_action(
100
- 'admin_notices',
101
- function() {
102
- echo '<div class="notice notice-warning">
103
- <p>
104
- <strong>' . esc_html__( 'You enabled Cookiebot auto blocking mode but still using addons' ) . '</strong><br>
105
- ' . 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.' ) . '
106
- </p>
107
- </div>';
108
- }
109
- );
110
- }
111
- }
112
- }
113
-
114
- /**
115
- * Runs every added action hooks to manipulate script tag
116
- *
117
- * @since 1.3.0
118
- */
119
- public function run_buffer_output_manipulations() {
120
- /**
121
- * @var $buffer_output Buffer_Output_Interface
122
- */
123
- $buffer_output = $this->settings_service->container->get( 'Buffer_Output_Interface' );
124
-
125
- if ( $buffer_output->has_action() ) {
126
- $buffer_output->run_actions();
127
- }
128
- }
129
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/cookiebot-addons-init.php DELETED
@@ -1,230 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons;
4
-
5
- use cookiebot_addons\config\Settings_Config;
6
- use cookiebot_addons\controller\Plugin_Controller;
7
- use cookiebot_addons\lib\buffer\Buffer_Output;
8
- use cookiebot_addons\lib\Cookie_Consent;
9
- use cookiebot_addons\lib\Dependency_Container;
10
- use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag;
11
- use cookiebot_addons\lib\Settings_Service;
12
- use cookiebot_addons\lib\Theme_Settings_Service;
13
- use Exception;
14
-
15
- if ( ! defined( 'ABSPATH' ) ) {
16
- exit;
17
- } // Exit if accessed directly
18
-
19
-
20
- /**
21
- * __DIR__ of this plugin
22
- */
23
- define( 'COOKIEBOT_ADDONS_DIR', __DIR__ . DIRECTORY_SEPARATOR );
24
-
25
- if ( ! defined( 'COOKIEBOT_ADDONS_URL' ) ) {
26
- define( 'COOKIEBOT_ADDONS_URL', plugin_dir_url( __FILE__ ) );
27
- }
28
-
29
- define( 'COOKIEBOT_ADDONS_BASE_NAME', dirname( plugin_basename( __FILE__ ) ) );
30
-
31
- /**
32
- * Same version as the CookiebotWP
33
- */
34
- define( 'COOKIEBOT_ADDONS_VERSION', '3.9.0' );
35
-
36
- /**
37
- * Register autoloader to load files/classes dynamically
38
- */
39
- require_once COOKIEBOT_ADDONS_DIR . 'lib/autoloader.php';
40
-
41
- /**
42
- * Load global functions for this plugin
43
- */
44
- require_once COOKIEBOT_ADDONS_DIR . 'lib/helper.php';
45
-
46
- class Cookiebot_Addons {
47
-
48
- /**
49
- * Dependency Container - is used for dependency injections
50
- *
51
- * @var Dependency_Container
52
- *
53
- * @since 1.3.0
54
- */
55
- public $container;
56
-
57
- /**
58
- * List of all supported addons
59
- *
60
- * @var object
61
- *
62
- * @since 1.3.0
63
- */
64
- public $plugins;
65
-
66
- /**
67
- * @var Cookiebot_Addons The single instance of the class
68
- * @since 1.0.0
69
- */
70
- private static $instance = null;
71
-
72
- /**
73
- * Main Cookiebot_WP Instance
74
- *
75
- * Ensures only one instance of Cookiebot_Addons is loaded or can be loaded.
76
- *
77
- * @return Cookiebot_Addons
78
- * @since 2.2.0
79
- * @static
80
- *
81
- * @version 2.2.0
82
- */
83
- public static function instance() {
84
- if ( is_null( self::$instance ) ) {
85
- try {
86
- self::$instance = new self();
87
- } catch ( Exception $e ) {
88
- echo 'Could not initialize Cookiebot addons: ' . esc_html( $e->getMessage() );
89
- }
90
- }
91
-
92
- return self::$instance;
93
- }
94
-
95
- /**
96
- * Cookiebot_Addons constructor.
97
- *
98
- * @throws Exception
99
- *
100
- * @since 1.3.0
101
- */
102
- public function __construct() {
103
- $this->get_plugins();
104
- $this->build_container();
105
- $this->assign_addons_to_container();
106
-
107
- /**
108
- * Load plugin controller to check if addons are active
109
- * If active then load the plugin addon configuration class
110
- * Else skip it
111
- *
112
- * @since 1.1.0
113
- */
114
- add_action(
115
- 'after_setup_theme',
116
- array(
117
- new Plugin_Controller( $this->container->get( 'Settings_Service_Interface' ) ),
118
- 'load_active_addons',
119
- )
120
- );
121
- /**
122
- * Load settings config
123
- *
124
- * @since 1.1.0
125
- */
126
- $settings = new Settings_Config( $this->container->get( 'Settings_Service_Interface' ) );
127
- $settings->load();
128
- }
129
-
130
- /**
131
- * if the cookiebot is activated
132
- * run this script to start up
133
- *
134
- * @since 2.2.0
135
- */
136
- public function cookiebot_activated() {
137
- $settings_service = $this->container->get( 'Settings_Service_Interface' );
138
- $settings_service->cookiebot_activated();
139
- }
140
-
141
- /**
142
- * if the cookiebot is deactivated
143
- * run this script to clean up addons.
144
- *
145
- * @since 2.2.0
146
- */
147
- public function cookiebot_deactivated() {
148
- $settings_service = $this->container->get( 'Settings_Service_Interface' );
149
- $settings_service->cookiebot_deactivated();
150
- }
151
-
152
- /**
153
- * Loads plugins from json file
154
- *
155
- * All the addon plugins are defined there.
156
- *
157
- * The file is located at the root map of this plugin
158
- *
159
- * @throws Exception
160
- * @since 1.3.0
161
- */
162
- protected function get_plugins() {
163
- $file = cookiebot_get_local_file_json_contents( COOKIEBOT_ADDONS_DIR . 'addons.json' );
164
-
165
- $this->plugins = apply_filters( 'cookiebot_addons_list', $file );
166
- }
167
-
168
- /**
169
- * @throws Exception
170
- */
171
- protected function build_container() {
172
- $dependencies = array(
173
- 'Script_Loader_Tag_Interface' => new Script_Loader_Tag(),
174
- 'Cookie_Consent_Interface' => new Cookie_Consent(),
175
- 'Buffer_Output_Interface' => new Buffer_Output(),
176
- 'plugins' => $this->plugins,
177
- );
178
-
179
- $this->container = new Dependency_Container( $dependencies );
180
-
181
- $this->container->set(
182
- 'Settings_Service_Interface',
183
- new Settings_Service( $this->container )
184
- );
185
-
186
- $this->container->set(
187
- 'Theme_Settings_Service_Interface',
188
- new Theme_Settings_Service( $this->container )
189
- );
190
- }
191
-
192
- /**
193
- * Assign addon class to the container to use it later
194
- *
195
- * @throws Exception
196
- *
197
- * @since 1.3.0
198
- */
199
- protected function assign_addons_to_container() {
200
- /**
201
- * Check plugins one by one and load addon configuration
202
- */
203
- foreach ( $this->plugins as $plugin_class => $plugin ) {
204
- /**
205
- * Load addon class to the container
206
- */
207
-
208
- if ( class_exists( $plugin->class ) ) {
209
- $this->container->set(
210
- $plugin->class,
211
- new $plugin->class(
212
- isset( $plugin->is_theme ) && $plugin->is_theme
213
- ? $this->container->get( 'Theme_Settings_Service_Interface' )
214
- : $this->container->get( 'Settings_Service_Interface' ),
215
- $this->container->get( 'Script_Loader_Tag_Interface' ),
216
- $this->container->get( 'Cookie_Consent_Interface' ),
217
- $this->container->get( 'Buffer_Output_Interface' )
218
- )
219
- );
220
- } else {
221
- throw new Exception( 'Class ' . $plugin->class . ' not found' );
222
- }
223
- }
224
- }
225
- }
226
-
227
- /**
228
- * Initiate the cookiebot addons framework plugin
229
- */
230
- Cookiebot_Addons::instance();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/DI/Annotation/Inject.php DELETED
@@ -1,95 +0,0 @@
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 DELETED
@@ -1,74 +0,0 @@
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 DELETED
@@ -1,340 +0,0 @@
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 DELETED
@@ -1,258 +0,0 @@
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 DELETED
@@ -1,39 +0,0 @@
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 DELETED
@@ -1,82 +0,0 @@
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 DELETED
@@ -1,66 +0,0 @@
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 DELETED
@@ -1,66 +0,0 @@
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 DELETED
@@ -1,61 +0,0 @@
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 DELETED
@@ -1,19 +0,0 @@
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 DELETED
@@ -1,48 +0,0 @@
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 DELETED
@@ -1,32 +0,0 @@
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 DELETED
@@ -1,48 +0,0 @@
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 DELETED
@@ -1,65 +0,0 @@
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 DELETED
@@ -1,37 +0,0 @@
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 DELETED
@@ -1,30 +0,0 @@
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 DELETED
@@ -1,68 +0,0 @@
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 DELETED
@@ -1,63 +0,0 @@
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 DELETED
@@ -1,37 +0,0 @@
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 DELETED
@@ -1,156 +0,0 @@
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 DELETED
@@ -1,37 +0,0 @@
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 DELETED
@@ -1,44 +0,0 @@
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 DELETED
@@ -1,52 +0,0 @@
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 DELETED
@@ -1,116 +0,0 @@
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 DELETED
@@ -1,19 +0,0 @@
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 DELETED
@@ -1,30 +0,0 @@
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 DELETED
@@ -1,75 +0,0 @@
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 DELETED
@@ -1,28 +0,0 @@
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 DELETED
@@ -1,46 +0,0 @@
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 DELETED
@@ -1,24 +0,0 @@
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 DELETED
@@ -1,64 +0,0 @@
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 DELETED
@@ -1,72 +0,0 @@
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 DELETED
@@ -1,273 +0,0 @@
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 DELETED
@@ -1,39 +0,0 @@
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 DELETED
@@ -1,42 +0,0 @@
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 DELETED
@@ -1,76 +0,0 @@
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 DELETED
@@ -1,294 +0,0 @@
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 DELETED
@@ -1,54 +0,0 @@
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 DELETED
@@ -1,56 +0,0 @@
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 DELETED
@@ -1,77 +0,0 @@
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 DELETED
@@ -1,105 +0,0 @@
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 DELETED
@@ -1,107 +0,0 @@
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 DELETED
@@ -1,44 +0,0 @@
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 DELETED
@@ -1,94 +0,0 @@
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 DELETED
@@ -1,85 +0,0 @@
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 DELETED
@@ -1,67 +0,0 @@
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 DELETED
@@ -1,266 +0,0 @@
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 DELETED
@@ -1,138 +0,0 @@
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 DELETED
@@ -1,141 +0,0 @@
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 DELETED
@@ -1,95 +0,0 @@
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 DELETED
@@ -1,58 +0,0 @@
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 DELETED
@@ -1,298 +0,0 @@
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\Source;
11
-
12
- use Cybot\Dependencies\DI\Annotation\Inject;
13
- use Cybot\Dependencies\DI\Annotation\Injectable;
14
- use Cybot\Dependencies\DI\Definition\ObjectDefinition;
15
- use Cybot\Dependencies\DI\Definition\EntryReference;
16
- use Cybot\Dependencies\DI\Definition\Exception\AnnotationException;
17
- use Cybot\Dependencies\DI\Definition\Exception\DefinitionException;
18
- use Cybot\Dependencies\DI\Definition\ObjectDefinition\MethodInjection;
19
- use Cybot\Dependencies\DI\Definition\ObjectDefinition\PropertyInjection;
20
- use Doctrine\Common\Annotations\AnnotationRegistry;
21
- use Doctrine\Common\Annotations\Reader;
22
- use Doctrine\Common\Annotations\SimpleAnnotationReader;
23
- use InvalidArgumentException;
24
- use Cybot\Dependencies\PhpDocReader\PhpDocReader;
25
- use ReflectionClass;
26
- use ReflectionMethod;
27
- use ReflectionParameter;
28
- use ReflectionProperty;
29
- use UnexpectedValueException;
30
-
31
- /**
32
- * Provides DI definitions by reading annotations such as @ Inject and @ var annotations.
33
- *
34
- * Uses Autowiring, Doctrine's Annotations and regex docblock parsing.
35
- * This source automatically includes the reflection source.
36
- *
37
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
38
- */
39
- class AnnotationReader implements DefinitionSource
40
- {
41
- /**
42
- * @var Reader
43
- */
44
- private $annotationReader;
45
-
46
- /**
47
- * @var PhpDocReader
48
- */
49
- private $phpDocReader;
50
-
51
- /**
52
- * @var bool
53
- */
54
- private $ignorePhpDocErrors;
55
-
56
- /**
57
- * @param bool $ignorePhpDocErrors
58
- */
59
- public function __construct($ignorePhpDocErrors = false)
60
- {
61
- $this->ignorePhpDocErrors = (bool) $ignorePhpDocErrors;
62
- }
63
-
64
- /**
65
- * {@inheritdoc}
66
- * @throws AnnotationException
67
- * @throws InvalidArgumentException The class doesn't exist
68
- */
69
- public function getDefinition($name)
70
- {
71
- if (!class_exists($name) && !interface_exists($name)) {
72
- return null;
73
- }
74
-
75
- $class = new ReflectionClass($name);
76
- $definition = new ObjectDefinition($name);
77
-
78
- $this->readInjectableAnnotation($class, $definition);
79
-
80
- // Browse the class properties looking for annotated properties
81
- $this->readProperties($class, $definition);
82
-
83
- // Browse the object's methods looking for annotated methods
84
- $this->readMethods($class, $definition);
85
-
86
- return $definition;
87
- }
88
-
89
- /**
90
- * Browse the class properties looking for annotated properties.
91
- *
92
- * @param ReflectionClass $reflectionClass
93
- * @param ObjectDefinition $objectDefinition
94
- */
95
- private function readProperties(ReflectionClass $reflectionClass, ObjectDefinition $objectDefinition)
96
- {
97
- // This will look in all the properties, including those of the parent classes
98
- foreach ($reflectionClass->getProperties() as $property) {
99
- // Ignore static properties
100
- if ($property->isStatic()) {
101
- continue;
102
- }
103
-
104
- $propertyInjection = $this->getPropertyInjection($property);
105
-
106
- if ($propertyInjection) {
107
- $objectDefinition->addPropertyInjection($propertyInjection);
108
- }
109
- }
110
- }
111
-
112
- /**
113
- * @param ReflectionProperty $property
114
- * @return PropertyInjection|null
115
- */
116
- private function getPropertyInjection(ReflectionProperty $property)
117
- {
118
- // Look for @Inject annotation
119
- /** @var $annotation Inject */
120
- $annotation = $this->getAnnotationReader()->getPropertyAnnotation($property, 'Cybot\Dependencies\DI\Annotation\Inject');
121
- if ($annotation === null) {
122
- return null;
123
- }
124
-
125
- // @Inject("name") or look for @var content
126
- $entryName = $annotation->getName() ?: $this->getPhpDocReader()->getPropertyClass($property);
127
-
128
- if ($entryName === null) {
129
- throw new AnnotationException(sprintf(
130
- '@Inject found on property %s::%s but unable to guess what to inject, use a @var annotation',
131
- $property->getDeclaringClass()->getName(),
132
- $property->getName()
133
- ));
134
- }
135
-
136
- return new PropertyInjection($property->getName(), new EntryReference($entryName));
137
- }
138
-
139
- /**
140
- * Browse the object's methods looking for annotated methods.
141
- *
142
- * @param ReflectionClass $class
143
- * @param ObjectDefinition $objectDefinition
144
- */
145
- private function readMethods(ReflectionClass $class, ObjectDefinition $objectDefinition)
146
- {
147
- // This will look in all the methods, including those of the parent classes
148
- foreach ($class->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
149
- if ($method->isStatic()) {
150
- continue;
151
- }
152
-
153
- $methodInjection = $this->getMethodInjection($method);
154
-
155
- if (! $methodInjection) {
156
- continue;
157
- }
158
-
159
- if ($method->isConstructor()) {
160
- $objectDefinition->setConstructorInjection($methodInjection);
161
- } else {
162
- $objectDefinition->addMethodInjection($methodInjection);
163
- }
164
- }
165
- }
166
-
167
- /**
168
- * {@inheritdoc}
169
- */
170
- private function getMethodInjection(ReflectionMethod $method)
171
- {
172
- // Look for @Inject annotation
173
- /** @var $annotation Inject|null */
174
- try {
175
- $annotation = $this->getAnnotationReader()->getMethodAnnotation($method, 'Cybot\Dependencies\DI\Annotation\Inject');
176
- } catch (AnnotationException $e) {
177
- throw new AnnotationException(sprintf(
178
- '@Inject annotation on %s::%s is malformed. %s',
179
- $method->getDeclaringClass()->getName(),
180
- $method->getName(),
181
- $e->getMessage()
182
- ), 0, $e);
183
- }
184
- $annotationParameters = $annotation ? $annotation->getParameters() : [];
185
-
186
- // @Inject on constructor is implicit
187
- if (! ($annotation || $method->isConstructor())) {
188
- return null;
189
- }
190
-
191
- $parameters = [];
192
- foreach ($method->getParameters() as $index => $parameter) {
193
- $entryName = $this->getMethodParameter($index, $parameter, $annotationParameters);
194
-
195
- if ($entryName !== null) {
196
- $parameters[$index] = new EntryReference($entryName);
197
- }
198
- }
199
-
200
- if ($method->isConstructor()) {
201
- return MethodInjection::constructor($parameters);
202
- } else {
203
- return new MethodInjection($method->getName(), $parameters);
204
- }
205
- }
206
-
207
- /**
208
- * @param int $parameterIndex
209
- * @param ReflectionParameter $parameter
210
- * @param array $annotationParameters
211
- *
212
- * @return string|null Entry name or null if not found.
213
- */
214
- private function getMethodParameter($parameterIndex, ReflectionParameter $parameter, array $annotationParameters)
215
- {
216
- // @Inject has definition for this parameter (by index, or by name)
217
- if (isset($annotationParameters[$parameterIndex])) {
218
- return $annotationParameters[$parameterIndex];
219
- }
220
- if (isset($annotationParameters[$parameter->getName()])) {
221
- return $annotationParameters[$parameter->getName()];
222
- }
223
-
224
- // Skip optional parameters if not explicitly defined
225
- if ($parameter->isOptional()) {
226
- return null;
227
- }
228
-
229
- // Try to use the type-hinting
230
- $parameterClass = $parameter->getClass();
231
- if ($parameterClass) {
232
- return $parameterClass->getName();
233
- }
234
-
235
- // Last resort, look for @param tag
236
- return $this->getPhpDocReader()->getParameterClass($parameter);
237
- }
238
-
239
- /**
240
- * @return Reader The annotation reader
241
- */
242
- public function getAnnotationReader()
243
- {
244
- if ($this->annotationReader == null) {
245
- AnnotationRegistry::registerAutoloadNamespace('Cybot\Dependencies\DI\Annotation', __DIR__ . '/../../../');
246
- $this->annotationReader = new SimpleAnnotationReader();
247
- $this->annotationReader->addNamespace('Cybot\Dependencies\DI\Annotation');
248
- }
249
-
250
- return $this->annotationReader;
251
- }
252
-
253
- /**
254
- * @param Reader $annotationReader The annotation reader
255
- */
256
- public function setAnnotationReader(Reader $annotationReader)
257
- {
258
- $this->annotationReader = $annotationReader;
259
- }
260
-
261
- /**
262
- * @return PhpDocReader
263
- */
264
- private function getPhpDocReader()
265
- {
266
- if ($this->phpDocReader === null) {
267
- $this->phpDocReader = new PhpDocReader($this->ignorePhpDocErrors);
268
- }
269
-
270
- return $this->phpDocReader;
271
- }
272
-
273
- private function readInjectableAnnotation(ReflectionClass $class, ObjectDefinition $definition)
274
- {
275
- try {
276
- /** @var $annotation Injectable|null */
277
- $annotation = $this->getAnnotationReader()
278
- ->getClassAnnotation($class, 'Cybot\Dependencies\DI\Annotation\Injectable');
279
- } catch (UnexpectedValueException $e) {
280
- throw new DefinitionException(sprintf(
281
- 'Error while reading @Injectable on %s: %s',
282
- $class->getName(),
283
- $e->getMessage()
284
- ), 0, $e);
285
- }
286
-
287
- if (! $annotation) {
288
- return;
289
- }
290
-
291
- if ($annotation->getScope()) {
292
- $definition->setScope($annotation->getScope());
293
- }
294
- if ($annotation->isLazy() !== null) {
295
- $definition->setLazy($annotation->isLazy());
296
- }
297
- }
298
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/DI/Definition/Source/Autowiring.php DELETED
@@ -1,68 +0,0 @@
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\Source;
11
-
12
- use Cybot\Dependencies\DI\Definition\ObjectDefinition;
13
- use Cybot\Dependencies\DI\Definition\EntryReference;
14
- use Cybot\Dependencies\DI\Definition\ObjectDefinition\MethodInjection;
15
-
16
- /**
17
- * Reads DI class definitions using reflection.
18
- *
19
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
20
- */
21
- class Autowiring implements DefinitionSource
22
- {
23
- /**
24
- * {@inheritdoc}
25
- */
26
- public function getDefinition($name)
27
- {
28
- if (!class_exists($name) && !interface_exists($name)) {
29
- return null;
30
- }
31
-
32
- $definition = new ObjectDefinition($name);
33
-
34
- // Constructor
35
- $class = new \ReflectionClass($name);
36
- $constructor = $class->getConstructor();
37
- if ($constructor && $constructor->isPublic()) {
38
- $definition->setConstructorInjection(
39
- MethodInjection::constructor($this->getParametersDefinition($constructor))
40
- );
41
- }
42
-
43
- return $definition;
44
- }
45
-
46
- /**
47
- * Read the type-hinting from the parameters of the function.
48
- */
49
- private function getParametersDefinition(\ReflectionFunctionAbstract $constructor)
50
- {
51
- $parameters = [];
52
-
53
- foreach ($constructor->getParameters() as $index => $parameter) {
54
- // Skip optional parameters
55
- if ($parameter->isOptional()) {
56
- continue;
57
- }
58
-
59
- $parameterClass = $parameter->getClass();
60
-
61
- if ($parameterClass) {
62
- $parameters[$index] = new EntryReference($parameterClass->getName());
63
- }
64
- }
65
-
66
- return $parameters;
67
- }
68
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/DI/Definition/Source/CachedDefinitionSource.php DELETED
@@ -1,104 +0,0 @@
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\Source;
11
-
12
- use Cybot\Dependencies\DI\Definition\CacheableDefinition;
13
- use Cybot\Dependencies\DI\Definition\Definition;
14
- use Doctrine\Common\Cache\Cache;
15
-
16
- /**
17
- * Caches another definition source.
18
- *
19
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
20
- */
21
- class CachedDefinitionSource implements DefinitionSource
22
- {
23
- /**
24
- * Prefix for cache key, to avoid conflicts with other systems using the same cache
25
- * @var string
26
- */
27
- const CACHE_PREFIX = 'Cybot\Dependencies\DI\\Definition\\';
28
-
29
- /**
30
- * @var DefinitionSource
31
- */
32
- private $source;
33
-
34
- /**
35
- * @var Cache
36
- */
37
- private $cache;
38
-
39
- public function __construct(DefinitionSource $source, Cache $cache)
40
- {
41
- $this->source = $source;
42
- $this->cache = $cache;
43
- }
44
-
45
- /**
46
- * {@inheritdoc}
47
- */
48
- public function getDefinition($name)
49
- {
50
- // Look in cache
51
- $definition = $this->fetchFromCache($name);
52
-
53
- if ($definition === false) {
54
- $definition = $this->source->getDefinition($name);
55
-
56
- // Save to cache
57
- if ($definition === null || ($definition instanceof CacheableDefinition)) {
58
- $this->saveToCache($name, $definition);
59
- }
60
- }
61
-
62
- return $definition;
63
- }
64
-
65
- /**
66
- * @return Cache
67
- */
68
- public function getCache()
69
- {
70
- return $this->cache;
71
- }
72
-
73
- /**
74
- * Fetches a definition from the cache
75
- *
76
- * @param string $name Entry name
77
- * @return Definition|null|boolean The cached definition, null or false if the value is not already cached
78
- */
79
- private function fetchFromCache($name)
80
- {
81
- $cacheKey = self::CACHE_PREFIX . $name;
82
-
83
- $data = $this->cache->fetch($cacheKey);
84
-
85
- if ($data !== false) {
86
- return $data;
87
- }
88
-
89
- return false;
90
- }
91
-
92
- /**
93
- * Saves a definition to the cache
94
- *
95
- * @param string $name Entry name
96
- * @param Definition|null $definition
97
- */
98
- private function saveToCache($name, Definition $definition = null)
99
- {
100
- $cacheKey = self::CACHE_PREFIX . $name;
101
-
102
- $this->cache->save($cacheKey, $definition);
103
- }
104
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/DI/Definition/Source/DefinitionArray.php DELETED
@@ -1,142 +0,0 @@
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\Source;
11
-
12
- use Cybot\Dependencies\DI\Definition\ArrayDefinition;
13
- use Cybot\Dependencies\DI\Definition\ObjectDefinition;
14
- use Cybot\Dependencies\DI\Definition\Definition;
15
- use Cybot\Dependencies\DI\Definition\FactoryDefinition;
16
- use Cybot\Dependencies\DI\Definition\ValueDefinition;
17
- use Cybot\Dependencies\DI\Definition\Helper\DefinitionHelper;
18
-
19
- /**
20
- * Reads DI definitions from a PHP array.
21
- *
22
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
23
- */
24
- class DefinitionArray implements DefinitionSource, MutableDefinitionSource
25
- {
26
- const WILDCARD = '*';
27
- /**
28
- * Matches anything except "\"
29
- */
30
- const WILDCARD_PATTERN = '([^\\\\]+)';
31
-
32
- /**
33
- * DI definitions in a PHP array
34
- * @var array
35
- */
36
- private $definitions = [];
37
-
38
- /**
39
- * @param array $definitions
40
- */
41
- public function __construct(array $definitions = [])
42
- {
43
- $this->definitions = $definitions;
44
- }
45
-
46
- /**
47
- * @param array $definitions DI definitions in a PHP array indexed by the definition name.
48
- */
49
- public function addDefinitions(array $definitions)
50
- {
51
- // The newly added data prevails
52
- // "for keys that exist in both arrays, the elements from the left-hand array will be used"
53
- $this->definitions = $definitions + $this->definitions;
54
- }
55
-
56
- /**
57
- * {@inheritdoc}
58
- */
59
- public function addDefinition(Definition $definition)
60
- {
61
- $this->definitions[$definition->getName()] = $definition;
62
- }
63
-
64
- /**
65
- * {@inheritdoc}
66
- */
67
- public function getDefinition($name)
68
- {
69
- // Look for the definition by name
70
- if (array_key_exists($name, $this->definitions)) {
71
- return $this->castDefinition($this->definitions[$name], $name);
72
- }
73
-
74
- // Look if there are wildcards definitions
75
- foreach ($this->definitions as $key => $definition) {
76
- if (strpos($key, self::WILDCARD) === false) {
77
- continue;
78
- }
79
-
80
- // Turn the pattern into a regex
81
- $key = addslashes($key);
82
- $key = '#' . str_replace(self::WILDCARD, self::WILDCARD_PATTERN, $key) . '#';
83
- if (preg_match($key, $name, $matches) === 1) {
84
- $definition = $this->castDefinition($definition, $name);
85
-
86
- // For a class definition, we replace * in the class name with the matches
87
- // *Interface -> *Impl => FooInterface -> FooImpl
88
- if ($definition instanceof ObjectDefinition) {
89
- array_shift($matches);
90
- $definition->setClassName(
91
- $this->replaceWildcards($definition->getClassName(), $matches)
92
- );
93
- }
94
-
95
- return $definition;
96
- }
97
- }
98
-
99
- return null;
100
- }
101
-
102
- /**
103
- * @param mixed $definition
104
- * @param string $name
105
- * @return Definition
106
- */
107
- private function castDefinition($definition, $name)
108
- {
109
- if ($definition instanceof DefinitionHelper) {
110
- $definition = $definition->getDefinition($name);
111
- }
112
- if (! $definition instanceof Definition && is_array($definition)) {
113
- $definition = new ArrayDefinition($name, $definition);
114
- }
115
- if ($definition instanceof \Closure) {
116
- $definition = new FactoryDefinition($name, $definition);
117
- }
118
- if (! $definition instanceof Definition) {
119
- $definition = new ValueDefinition($name, $definition);
120
- }
121
-
122
- return $definition;
123
- }
124
-
125
- /**
126
- * Replaces all the wildcards in the string with the given replacements.
127
- * @param string $string
128
- * @param string[] $replacements
129
- * @return string
130
- */
131
- private function replaceWildcards($string, array $replacements)
132
- {
133
- foreach ($replacements as $replacement) {
134
- $pos = strpos($string, self::WILDCARD);
135
- if ($pos !== false) {
136
- $string = substr_replace($string, $replacement, $pos, 1);
137
- }
138
- }
139
-
140
- return $string;
141
- }
142
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/DI/Definition/Source/DefinitionFile.php DELETED
@@ -1,74 +0,0 @@
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\Source;
11
-
12
- use Cybot\Dependencies\DI\Definition\Definition;
13
- use Cybot\Dependencies\DI\Definition\Exception\DefinitionException;
14
-
15
- /**
16
- * Reads DI definitions from a file returning a PHP array.
17
- *
18
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
19
- */
20
- class DefinitionFile extends DefinitionArray
21
- {
22
- /**
23
- * @var bool
24
- */
25
- private $initialized = false;
26
-
27
- /**
28
- * File containing definitions, or null if the definitions are given as a PHP array.
29
- * @var string|null
30
- */
31
- private $file;
32
-
33
- /**
34
- * @param string $file File in which the definitions are returned as an array.
35
- */
36
- public function __construct($file)
37
- {
38
- // Lazy-loading to improve performances
39
- $this->file = $file;
40
-
41
- parent::__construct([]);
42
- }
43
-
44
- /**
45
- * {@inheritdoc}
46
- */
47
- public function getDefinition($name)
48
- {
49
- $this->initialize();
50
-
51
- return parent::getDefinition($name);
52
- }
53
-
54
- /**
55
- * Lazy-loading of the definitions.
56
- * @throws DefinitionException
57
- */
58
- private function initialize()
59
- {
60
- if ($this->initialized === true) {
61
- return;
62
- }
63
-
64
- $definitions = require $this->file;
65
-
66
- if (! is_array($definitions)) {
67
- throw new DefinitionException("File {$this->file} should return an array of definitions");
68
- }
69
-
70
- $this->addDefinitions($definitions);
71
-
72
- $this->initialized = true;
73
- }
74
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/DI/Definition/Source/DefinitionSource.php DELETED
@@ -1,31 +0,0 @@
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\Source;
11
-
12
- use Cybot\Dependencies\DI\Definition\Definition;
13
- use Cybot\Dependencies\DI\Definition\Exception\DefinitionException;
14
-
15
- /**
16
- * Source of definitions for entries of the container.
17
- *
18
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
19
- */
20
- interface DefinitionSource
21
- {
22
- /**
23
- * Returns the DI definition for the entry name.
24
- *
25
- * @param string $name
26
- *
27
- * @throws DefinitionException An invalid definition was found.
28
- * @return Definition|null
29
- */
30
- public function getDefinition($name);
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/DI/Definition/Source/MutableDefinitionSource.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- namespace Cybot\Dependencies\DI\Definition\Source;
4
-
5
- use Cybot\Dependencies\DI\Definition\Definition;
6
-
7
- /**
8
- * Describes a definition source to which we can add new definitions.
9
- *
10
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
11
- */
12
- interface MutableDefinitionSource extends DefinitionSource
13
- {
14
- public function addDefinition(Definition $definition);
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/DI/Definition/Source/SourceChain.php DELETED
@@ -1,108 +0,0 @@
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\Source;
11
-
12
- use Cybot\Dependencies\DI\Definition\Definition;
13
- use Cybot\Dependencies\DI\Definition\HasSubDefinition;
14
-
15
- /**
16
- * Manages a chain of other definition sources.
17
- *
18
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
19
- */
20
- class SourceChain implements DefinitionSource, MutableDefinitionSource
21
- {
22
- /**
23
- * @var DefinitionSource[]
24
- */
25
- private $sources;
26
-
27
- /**
28
- * @var DefinitionSource
29
- */
30
- private $rootSource;
31
-
32
- /**
33
- * @var MutableDefinitionSource|null
34
- */
35
- private $mutableSource;
36
-
37
- /**
38
- * @param DefinitionSource[] $sources
39
- */
40
- public function __construct(array $sources)
41
- {
42
- // We want a numerically indexed array to ease the traversal later
43
- $this->sources = array_values($sources);
44
- $this->rootSource = $this;
45
- }
46
-
47
- /**
48
- * {@inheritdoc}
49
- * @param int $startIndex Use this parameter to start looking from a specific
50
- * point in the source chain.
51
- */
52
- public function getDefinition($name, $startIndex = 0)
53
- {
54
- $count = count($this->sources);
55
- for ($i = $startIndex; $i < $count; $i++) {
56
- $source = $this->sources[$i];
57
-
58
- $definition = $source->getDefinition($name);
59
-
60
- if ($definition) {
61
- if ($definition instanceof HasSubDefinition) {
62
- $this->resolveSubDefinition($definition, $i);
63
- }
64
- return $definition;
65
- }
66
- }
67
-
68
- return null;
69
- }
70
-
71
- public function addDefinition(Definition $definition)
72
- {
73
- if (! $this->mutableSource) {
74
- throw new \LogicException("The container's definition source has not been initialized correctly");
75
- }
76
-
77
- $this->mutableSource->addDefinition($definition);
78
- }
79
-
80
- public function setRootDefinitionSource(DefinitionSource $rootSource)
81
- {
82
- $this->rootSource = $rootSource;
83
- }
84
-
85
- private function resolveSubDefinition(HasSubDefinition $definition, $currentIndex)
86
- {
87
- $subDefinitionName = $definition->getSubDefinitionName();
88
-
89
- if ($subDefinitionName === $definition->getName()) {
90
- // Extending itself: look in the next sources only (else infinite recursion)
91
- $subDefinition = $this->getDefinition($subDefinitionName, $currentIndex + 1);
92
- } else {
93
- // Extending another definition: look from the root
94
- $subDefinition = $this->rootSource->getDefinition($subDefinitionName);
95
- }
96
-
97
- if ($subDefinition) {
98
- $definition->setSubDefinition($subDefinition);
99
- }
100
- }
101
-
102
- public function setMutableDefinitionSource(MutableDefinitionSource $mutableSource)
103
- {
104
- $this->mutableSource = $mutableSource;
105
-
106
- array_unshift($this->sources, $mutableSource);
107
- }
108
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/DI/Definition/StringDefinition.php DELETED
@@ -1,66 +0,0 @@
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 string composed of other strings.
16
- *
17
- * @since 5.0
18
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
19
- */
20
- class StringDefinition implements Definition
21
- {
22
- /**
23
- * Entry name
24
- * @var string
25
- */
26
- private $name;
27
-
28
- /**
29
- * @var string
30
- */
31
- private $expression;
32
-
33
- /**
34
- * @param string $name Entry name
35
- * @param string $expression
36
- */
37
- public function __construct($name, $expression)
38
- {
39
- $this->name = $name;
40
- $this->expression = $expression;
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 string
61
- */
62
- public function getExpression()
63
- {
64
- return $this->expression;
65
- }
66
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/DI/Definition/ValueDefinition.php DELETED
@@ -1,67 +0,0 @@
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 for dependency injection.
16
- *
17
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
18
- */
19
- class ValueDefinition implements Definition
20
- {
21
- /**
22
- * Entry name
23
- * @var string
24
- */
25
- private $name;
26
-
27
- /**
28
- * @var mixed
29
- */
30
- private $value;
31
-
32
- /**
33
- * @param string $name Entry name
34
- * @param mixed $value
35
- */
36
- public function __construct($name, $value)
37
- {
38
- $this->name = $name;
39
- $this->value = $value;
40
- }
41
-
42
- /**
43
- * @return string Entry name
44
- */
45
- public function getName()
46
- {
47
- return $this->name;
48
- }
49
-
50
- /**
51
- * A value definition is like a constant, there is nothing to compute, the value is the same for everyone.
52
- *
53
- * {@inheritdoc}
54
- */
55
- public function getScope()
56
- {
57
- return Scope::SINGLETON;
58
- }
59
-
60
- /**
61
- * @return mixed
62
- */
63
- public function getValue()
64
- {
65
- return $this->value;
66
- }
67
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/DI/DependencyException.php DELETED
@@ -1,19 +0,0 @@
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\Interop\Container\Exception\ContainerException;
13
-
14
- /**
15
- * Exception for the Container
16
- */
17
- class DependencyException extends \Exception implements ContainerException
18
- {
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/DI/FactoryInterface.php DELETED
@@ -1,34 +0,0 @@
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
- /**
13
- * Describes the basic interface of a factory.
14
- *
15
- * @since 4.0
16
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
17
- */
18
- interface FactoryInterface
19
- {
20
- /**
21
- * Resolves an entry by its name. If given a class name, it will return a new instance of that class.
22
- *
23
- * @param string $name Entry name or a class name.
24
- * @param array $parameters Optional parameters to use to build the entry. Use this to force specific
25
- * parameters to specific values. Parameters not defined in this array will
26
- * be automatically resolved.
27
- *
28
- * @throws \InvalidArgumentException The name parameter must be of type string.
29
- * @throws DependencyException Error while resolving the entry.
30
- * @throws NotFoundException No entry or class found for the given name.
31
- * @return mixed
32
- */
33
- public function make($name, array $parameters = []);
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/DI/Invoker/DefinitionParameterResolver.php DELETED
@@ -1,45 +0,0 @@
1
- <?php
2
-
3
- namespace Cybot\Dependencies\DI\Cybot\Dependencies\Invoker;
4
-
5
- use Cybot\Dependencies\DI\Definition\Helper\DefinitionHelper;
6
- use Cybot\Dependencies\DI\Definition\Resolver\DefinitionResolver;
7
- use Cybot\Dependencies\Invoker\ParameterResolver\ParameterResolver;
8
- use ReflectionFunctionAbstract;
9
-
10
- /**
11
- * Resolves callable parameters using definitions.
12
- *
13
- * @since 5.0
14
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
15
- */
16
- class DefinitionParameterResolver implements ParameterResolver
17
- {
18
- /**
19
- * @var DefinitionResolver
20
- */
21
- private $definitionResolver;
22
-
23
- public function __construct(DefinitionResolver $definitionResolver)
24
- {
25
- $this->definitionResolver = $definitionResolver;
26
- }
27
-
28
- /**
29
- * {@inheritdoc}
30
- */
31
- public function getParameters(
32
- ReflectionFunctionAbstract $reflection,
33
- array $providedParameters,
34
- array $resolvedParameters
35
- ) {
36
- foreach ($resolvedParameters as &$parameter) {
37
- if ($parameter instanceof DefinitionHelper) {
38
- $definition = $parameter->getDefinition('');
39
- $parameter = $this->definitionResolver->resolve($definition);
40
- }
41
- }
42
-
43
- return $resolvedParameters;
44
- }
45
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/DI/InvokerInterface.php DELETED
@@ -1,19 +0,0 @@
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
- /**
13
- * Invoke a callable.
14
- *
15
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
16
- */
17
- interface InvokerInterface extends \Cybot\Dependencies\Invoker\InvokerInterface
18
- {
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/DI/NotFoundException.php DELETED
@@ -1,19 +0,0 @@
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\Interop\Container\Exception\NotFoundException as BaseNotFoundException;
13
-
14
- /**
15
- * Exception thrown when a class or a value is not found in the container
16
- */
17
- class NotFoundException extends \Exception implements BaseNotFoundException
18
- {
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/DI/Proxy/ProxyFactory.php DELETED
@@ -1,88 +0,0 @@
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\Proxy;
11
-
12
- use ProxyManager\Configuration;
13
- use ProxyManager\Factory\LazyLoadingValueHolderFactory;
14
- use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy;
15
-
16
- /**
17
- * Creates proxy classes.
18
- *
19
- * Wraps Ocramius/ProxyManager LazyLoadingValueHolderFactory.
20
- *
21
- * @see ProxyManager\Factory\LazyLoadingValueHolderFactory
22
- *
23
- * @since 5.0
24
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
25
- */
26
- class ProxyFactory
27
- {
28
- /**
29
- * If true, write the proxies to disk to improve performances.
30
- * @var boolean
31
- */
32
- private $writeProxiesToFile;
33
-
34
- /**
35
- * Directory where to write the proxies (if $writeProxiesToFile is enabled).
36
- * @var string
37
- */
38
- private $proxyDirectory;
39
-
40
- /**
41
- * @var LazyLoadingValueHolderFactory|null
42
- */
43
- private $proxyManager;
44
-
45
- public function __construct($writeProxiesToFile, $proxyDirectory = null)
46
- {
47
- $this->writeProxiesToFile = $writeProxiesToFile;
48
- $this->proxyDirectory = $proxyDirectory;
49
- }
50
-
51
- /**
52
- * Creates a new lazy proxy instance of the given class with
53
- * the given initializer
54
- *
55
- * @param string $className name of the class to be proxied
56
- * @param \Closure $initializer initializer to be passed to the proxy
57
- *
58
- * @return \ProxyManager\Proxy\LazyLoadingInterface
59
- */
60
- public function createProxy($className, \Closure $initializer)
61
- {
62
- $this->createProxyManager();
63
-
64
- return $this->proxyManager->createProxy($className, $initializer);
65
- }
66
-
67
- private function createProxyManager()
68
- {
69
- if ($this->proxyManager !== null) {
70
- return;
71
- }
72
-
73
- if (! class_exists('ProxyManager\Configuration')) {
74
- throw new \RuntimeException('The ocramius/proxy-manager library is not installed. Lazy injection requires that library to be installed with Composer in order to work. Run "composer require ocramius/proxy-manager:~0.3".');
75
- }
76
-
77
- $config = new Configuration();
78
-
79
- if ($this->writeProxiesToFile) {
80
- $config->setProxiesTargetDir($this->proxyDirectory);
81
- spl_autoload_register($config->getProxyAutoloader());
82
- } else {
83
- $config->setGeneratorStrategy(new EvaluatingGeneratorStrategy());
84
- }
85
-
86
- $this->proxyManager = new LazyLoadingValueHolderFactory($config);
87
- }
88
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/DI/Reflection/CallableReflectionFactory.php DELETED
@@ -1,51 +0,0 @@
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\Reflection;
11
-
12
- /**
13
- * Create a reflection object from a callable.
14
- *
15
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
16
- */
17
- class CallableReflectionFactory
18
- {
19
- /**
20
- * @param callable $callable
21
- *
22
- * @return \ReflectionFunctionAbstract
23
- */
24
- public static function fromCallable($callable)
25
- {
26
- // Array callable
27
- if (is_array($callable)) {
28
- list($class, $method) = $callable;
29
-
30
- return new \ReflectionMethod($class, $method);
31
- }
32
-
33
- // Closure
34
- if ($callable instanceof \Closure) {
35
- return new \ReflectionFunction($callable);
36
- }
37
-
38
- // Callable object (i.e. implementing __invoke())
39
- if (is_object($callable) && method_exists($callable, '__invoke')) {
40
- return new \ReflectionMethod($callable, '__invoke');
41
- }
42
-
43
- // Callable class (i.e. implementing __invoke())
44
- if (is_string($callable) && class_exists($callable) && method_exists($callable, '__invoke')) {
45
- return new \ReflectionMethod($callable, '__invoke');
46
- }
47
-
48
- // Standard function
49
- return new \ReflectionFunction($callable);
50
- }
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/DI/Scope.php DELETED
@@ -1,54 +0,0 @@
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
- /**
13
- * Scope enum.
14
- *
15
- * The scope defines the lifecycle of an entry.
16
- *
17
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
18
- */
19
- class Scope
20
- {
21
- /**
22
- * A singleton entry will be computed once and shared.
23
- *
24
- * For a class, only a single instance of the class will be created.
25
- */
26
- const SINGLETON = 'singleton';
27
-
28
- /**
29
- * A prototype entry will be recomputed each time it is asked.
30
- *
31
- * For a class, this will create a new instance each time.
32
- */
33
- const PROTOTYPE = 'prototype';
34
-
35
- /**
36
- * Method kept for backward compatibility, use the constant instead.
37
- *
38
- * @return string
39
- */
40
- public static function SINGLETON()
41
- {
42
- return self::SINGLETON;
43
- }
44
-
45
- /**
46
- * Method kept for backward compatibility, use the constant instead.
47
- *
48
- * @return string
49
- */
50
- public static function PROTOTYPE()
51
- {
52
- return self::PROTOTYPE;
53
- }
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/DI/functions.php DELETED
@@ -1,181 +0,0 @@
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\EntryReference;
13
- use Cybot\Dependencies\DI\Definition\Helper\ArrayDefinitionExtensionHelper;
14
- use Cybot\Dependencies\DI\Definition\Helper\FactoryDefinitionHelper;
15
- use Cybot\Dependencies\DI\Definition\Helper\ObjectDefinitionHelper;
16
- use Cybot\Dependencies\DI\Definition\Helper\EnvironmentVariableDefinitionHelper;
17
- use Cybot\Dependencies\DI\Definition\Helper\ValueDefinitionHelper;
18
- use Cybot\Dependencies\DI\Definition\Helper\StringDefinitionHelper;
19
-
20
- if (! function_exists('Cybot\Dependencies\DI\value')) {
21
- /**
22
- * Helper for defining an object.
23
- *
24
- * @param mixed $value
25
- *
26
- * @return ValueDefinitionHelper
27
- */
28
- function value($value)
29
- {
30
- return new ValueDefinitionHelper($value);
31
- }
32
- }
33
-
34
- if (! function_exists('Cybot\Dependencies\DI\object')) {
35
- /**
36
- * Helper for defining an object.
37
- *
38
- * @param string|null $className Class name of the object.
39
- * If null, the name of the entry (in the container) will be used as class name.
40
- *
41
- * @return ObjectDefinitionHelper
42
- */
43
- function object($className = null)
44
- {
45
- return new ObjectDefinitionHelper($className);
46
- }
47
- }
48
-
49
- if (! function_exists('Cybot\Dependencies\DI\factory')) {
50
- /**
51
- * Helper for defining a container entry using a factory function/callable.
52
- *
53
- * @param callable $factory The factory is a callable that takes the container as parameter
54
- * and returns the value to register in the container.
55
- *
56
- * @return FactoryDefinitionHelper
57
- */
58
- function factory($factory)
59
- {
60
- return new FactoryDefinitionHelper($factory);
61
- }
62
- }
63
-
64
- if (! function_exists('Cybot\Dependencies\DI\decorate')) {
65
- /**
66
- * Decorate the previous definition using a callable.
67
- *
68
- * Example:
69
- *
70
- * 'foo' => decorate(function ($foo, $container) {
71
- * return new CachedFoo($foo, $container->get('cache'));
72
- * })
73
- *
74
- * @param callable $callable The callable takes the decorated object as first parameter and
75
- * the container as second.
76
- *
77
- * @return FactoryDefinitionHelper
78
- */
79
- function decorate($callable)
80
- {
81
- return new FactoryDefinitionHelper($callable, true);
82
- }
83
- }
84
-
85
- if (! function_exists('Cybot\Dependencies\DI\get')) {
86
- /**
87
- * Helper for referencing another container entry in an object definition.
88
- *
89
- * @param string $entryName
90
- *
91
- * @return EntryReference
92
- */
93
- function get($entryName)
94
- {
95
- return new EntryReference($entryName);
96
- }
97
- }
98
-
99
- if (! function_exists('Cybot\Dependencies\DI\link')) {
100
- /**
101
- * Helper for referencing another container entry in an object definition.
102
- *
103
- * @deprecated \Cybot\Dependencies\DI\link() has been replaced by \Cybot\Dependencies\DI\get()
104
- *
105
- * @param string $entryName
106
- *
107
- * @return EntryReference
108
- */
109
- function link($entryName)
110
- {
111
- return new EntryReference($entryName);
112
- }
113
- }
114
-
115
- if (! function_exists('Cybot\Dependencies\DI\env')) {
116
- /**
117
- * Helper for referencing environment variables.
118
- *
119
- * @param string $variableName The name of the environment variable.
120
- * @param mixed $defaultValue The default value to be used if the environment variable is not defined.
121
- *
122
- * @return EnvironmentVariableDefinitionHelper
123
- */
124
- function env($variableName, $defaultValue = null)
125
- {
126
- // Only mark as optional if the default value was *explicitly* provided.
127
- $isOptional = 2 === func_num_args();
128
-
129
- return new EnvironmentVariableDefinitionHelper($variableName, $isOptional, $defaultValue);
130
- }
131
- }
132
-
133
- if (! function_exists('Cybot\Dependencies\DI\add')) {
134
- /**
135
- * Helper for extending another definition.
136
- *
137
- * Example:
138
- *
139
- * 'log.backends' => Cybot\Dependencies\DI\add(Cybot\Dependencies\DI\get('My\Custom\LogBackend'))
140
- *
141
- * or:
142
- *
143
- * 'log.backends' => Cybot\Dependencies\DI\add([
144
- * Cybot\Dependencies\DI\get('My\Custom\LogBackend')
145
- * ])
146
- *
147
- * @param mixed|array $values A value or an array of values to add to the array.
148
- *
149
- * @return ArrayDefinitionExtensionHelper
150
- *
151
- * @since 5.0
152
- */
153
- function add($values)
154
- {
155
- if (! is_array($values)) {
156
- $values = [$values];
157
- }
158
-
159
- return new ArrayDefinitionExtensionHelper($values);
160
- }
161
- }
162
-
163
- if (! function_exists('Cybot\Dependencies\DI\string')) {
164
- /**
165
- * Helper for concatenating strings.
166
- *
167
- * Example:
168
- *
169
- * 'log.filename' => Cybot\Dependencies\DI\string('{app.path}/app.log')
170
- *
171
- * @param string $expression A string expression. Use the `{}` placeholders to reference other container entries.
172
- *
173
- * @return StringDefinitionHelper
174
- *
175
- * @since 5.0
176
- */
177
- function string($expression)
178
- {
179
- return new StringDefinitionHelper((string) $expression);
180
- }
181
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Interop/Container/ContainerInterface.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
- /**
3
- * @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
4
- */
5
-
6
- namespace Cybot\Dependencies\Interop\Container;
7
-
8
- use Cybot\Dependencies\Psr\Container\ContainerInterface as PsrContainerInterface;
9
-
10
- /**
11
- * Describes the interface of a container that exposes methods to read its entries.
12
- */
13
- interface ContainerInterface extends PsrContainerInterface
14
- {
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Interop/Container/Exception/ContainerException.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
- /**
3
- * @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
4
- */
5
-
6
- namespace Cybot\Dependencies\Interop\Container\Exception;
7
-
8
- use Cybot\Dependencies\Psr\Container\ContainerExceptionInterface as PsrContainerException;
9
-
10
- /**
11
- * Base interface representing a generic exception in a container.
12
- */
13
- interface ContainerException extends PsrContainerException
14
- {
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Interop/Container/Exception/NotFoundException.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
- /**
3
- * @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
4
- */
5
-
6
- namespace Cybot\Dependencies\Interop\Container\Exception;
7
-
8
- use Cybot\Dependencies\Psr\Container\NotFoundExceptionInterface as PsrNotFoundException;
9
-
10
- /**
11
- * No entry was found in the container.
12
- */
13
- interface NotFoundException extends ContainerException, PsrNotFoundException
14
- {
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Invoker/CallableResolver.php DELETED
@@ -1,127 +0,0 @@
1
- <?php
2
-
3
- namespace Cybot\Dependencies\Invoker;
4
-
5
- use Cybot\Dependencies\Interop\Container\ContainerInterface;
6
- use Cybot\Dependencies\Interop\Container\Exception\NotFoundException;
7
- use Cybot\Dependencies\Invoker\Exception\NotCallableException;
8
-
9
- /**
10
- * Resolves a callable from a container.
11
- *
12
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
13
- */
14
- class CallableResolver
15
- {
16
- /**
17
- * @var ContainerInterface
18
- */
19
- private $container;
20
-
21
- public function __construct(ContainerInterface $container)
22
- {
23
- $this->container = $container;
24
- }
25
-
26
- /**
27
- * Resolve the given callable into a real PHP callable.
28
- *
29
- * @param callable|string|array $callable
30
- *
31
- * @return callable Real PHP callable.
32
- *
33
- * @throws NotCallableException
34
- */
35
- public function resolve($callable)
36
- {
37
- if (is_string($callable) && strpos($callable, '::') !== false) {
38
- $callable = explode('::', $callable, 2);
39
- }
40
-
41
- $callable = $this->resolveFromContainer($callable);
42
-
43
- if (! is_callable($callable)) {
44
- throw NotCallableException::fromInvalidCallable($callable, true);
45
- }
46
-
47
- return $callable;
48
- }
49
-
50
- /**
51
- * @param callable|string|array $callable
52
- * @return callable
53
- * @throws NotCallableException
54
- */
55
- private function resolveFromContainer($callable)
56
- {
57
- // Shortcut for a very common use case
58
- if ($callable instanceof \Closure) {
59
- return $callable;
60
- }
61
-
62
- $isStaticCallToNonStaticMethod = false;
63
-
64
- // If it's already a callable there is nothing to do
65
- if (is_callable($callable)) {
66
- $isStaticCallToNonStaticMethod = $this->isStaticCallToNonStaticMethod($callable);
67
- if (! $isStaticCallToNonStaticMethod) {
68
- return $callable;
69
- }
70
- }
71
-
72
- // The callable is a container entry name
73
- if (is_string($callable)) {
74
- try {
75
- return $this->container->get($callable);
76
- } catch (NotFoundException $e) {
77
- throw NotCallableException::fromInvalidCallable($callable, true);
78
- }
79
- }
80
-
81
- // The callable is an array whose first item is a container entry name
82
- // e.g. ['some-container-entry', 'methodToCall']
83
- if (is_array($callable) && is_string($callable[0])) {
84
- try {
85
- // Replace the container entry name by the actual object
86
- $callable[0] = $this->container->get($callable[0]);
87
- return $callable;
88
- } catch (NotFoundException $e) {
89
- if ($isStaticCallToNonStaticMethod) {
90
- throw new NotCallableException(sprintf(
91
- 'Cannot call %s::%s() because %s() is not a static method and "%s" is not a container entry',
92
- $callable[0],
93
- $callable[1],
94
- $callable[1],
95
- $callable[0]
96
- ));
97
- }
98
- throw new NotCallableException(sprintf(
99
- 'Cannot call %s on %s because it is not a class nor a valid container entry',
100
- $callable[1],
101
- $callable[0]
102
- ));
103
- }
104
- }
105
-
106
- // Unrecognized stuff, we let it fail later
107
- return $callable;
108
- }
109
-
110
- /**
111
- * Check if the callable represents a static call to a non-static method.
112
- *
113
- * @param mixed $callable
114
- * @return bool
115
- */
116
- private function isStaticCallToNonStaticMethod($callable)
117
- {
118
- if (is_array($callable) && is_string($callable[0])) {
119
- list($class, $method) = $callable;
120
- $reflection = new \ReflectionMethod($class, $method);
121
-
122
- return ! $reflection->isStatic();
123
- }
124
-
125
- return false;
126
- }
127
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Invoker/Exception/InvocationException.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
-
3
- namespace Cybot\Dependencies\Invoker\Exception;
4
-
5
- /**
6
- * Impossible to invoke the callable.
7
- *
8
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
9
- */
10
- class InvocationException extends \Exception
11
- {
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Invoker/Exception/NotCallableException.php DELETED
@@ -1,35 +0,0 @@
1
- <?php
2
-
3
- namespace Cybot\Dependencies\Invoker\Exception;
4
-
5
- /**
6
- * The given callable is not actually callable.
7
- *
8
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
9
- */
10
- class NotCallableException extends InvocationException
11
- {
12
- /**
13
- * @param string $value
14
- * @param bool $containerEntry
15
- * @return self
16
- */
17
- public static function fromInvalidCallable($value, $containerEntry = false)
18
- {
19
- if (is_object($value)) {
20
- $message = sprintf('Instance of %s is not a callable', get_class($value));
21
- } elseif (is_array($value) && isset($value[0]) && isset($value[1])) {
22
- $class = is_object($value[0]) ? get_class($value[0]) : $value[0];
23
- $extra = method_exists($class, '__call') ? ' A __call() method exists but magic methods are not supported.' : '';
24
- $message = sprintf('%s::%s() is not a callable.%s', $class, $value[1], $extra);
25
- } else {
26
- if ($containerEntry) {
27
- $message = var_export($value, true) . ' is neither a callable nor a valid container entry';
28
- } else {
29
- $message = var_export($value, true) . ' is not a callable';
30
- }
31
- }
32
-
33
- return new self($message);
34
- }
35
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Invoker/Exception/NotEnoughParametersException.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
-
3
- namespace Cybot\Dependencies\Invoker\Exception;
4
-
5
- /**
6
- * Not enough parameters could be resolved to invoke the callable.
7
- *
8
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
9
- */
10
- class NotEnoughParametersException extends InvocationException
11
- {
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Invoker/Invoker.php DELETED
@@ -1,122 +0,0 @@
1
- <?php
2
-
3
- namespace Cybot\Dependencies\Invoker;
4
-
5
- use Cybot\Dependencies\Interop\Container\ContainerInterface;
6
- use Cybot\Dependencies\Invoker\Exception\NotCallableException;
7
- use Cybot\Dependencies\Invoker\Exception\NotEnoughParametersException;
8
- use Cybot\Dependencies\Invoker\ParameterResolver\AssociativeArrayResolver;
9
- use Cybot\Dependencies\Invoker\ParameterResolver\DefaultValueResolver;
10
- use Cybot\Dependencies\Invoker\ParameterResolver\NumericArrayResolver;
11
- use Cybot\Dependencies\Invoker\ParameterResolver\ParameterResolver;
12
- use Cybot\Dependencies\Invoker\ParameterResolver\ResolverChain;
13
- use Cybot\Dependencies\Invoker\Reflection\CallableReflection;
14
-
15
- /**
16
- * Invoke a callable.
17
- *
18
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
19
- */
20
- class Invoker implements InvokerInterface
21
- {
22
- /**
23
- * @var CallableResolver|null
24
- */
25
- private $callableResolver;
26
-
27
- /**
28
- * @var ParameterResolver
29
- */
30
- private $parameterResolver;
31
-
32
- /**
33
- * @var ContainerInterface|null
34
- */
35
- private $container;
36
-
37
- public function __construct(ParameterResolver $parameterResolver = null, ContainerInterface $container = null)
38
- {
39
- $this->parameterResolver = $parameterResolver ?: $this->createParameterResolver();
40
- $this->container = $container;
41
-
42
- if ($container) {
43
- $this->callableResolver = new CallableResolver($container);
44
- }
45
- }
46
-
47
- /**
48
- * {@inheritdoc}
49
- */
50
- public function call($callable, array $parameters = array())
51
- {
52
- if ($this->callableResolver) {
53
- $callable = $this->callableResolver->resolve($callable);
54
- }
55
-
56
- if (! is_callable($callable)) {
57
- throw new NotCallableException(sprintf(
58
- '%s is not a callable',
59
- is_object($callable) ? 'Instance of ' . get_class($callable) : var_export($callable, true)
60
- ));
61
- }
62
-
63
- $callableReflection = CallableReflection::create($callable);
64
-
65
- $args = $this->parameterResolver->getParameters($callableReflection, $parameters, array());
66
-
67
- // Sort by array key because call_user_func_array ignores numeric keys
68
- ksort($args);
69
-
70
- // Check all parameters are resolved
71
- $diff = array_diff_key($callableReflection->getParameters(), $args);
72
- if (! empty($diff)) {
73
- /** @var \ReflectionParameter $parameter */
74
- $parameter = reset($diff);
75
- throw new NotEnoughParametersException(sprintf(
76
- 'Unable to invoke the callable because no value was given for parameter %d ($%s)',
77
- $parameter->getPosition() + 1,
78
- $parameter->name
79
- ));
80
- }
81
-
82
- return call_user_func_array($callable, $args);
83
- }
84
-
85
- /**
86
- * Create the default parameter resolver.
87
- *
88
- * @return ParameterResolver
89
- */
90
- private function createParameterResolver()
91
- {
92
- return new ResolverChain(array(
93
- new NumericArrayResolver,
94
- new AssociativeArrayResolver,
95
- new DefaultValueResolver,
96
- ));
97
- }
98
-
99
- /**
100
- * @return ParameterResolver By default it's a ResolverChain
101
- */
102
- public function getParameterResolver()
103
- {
104
- return $this->parameterResolver;
105
- }
106
-
107
- /**
108
- * @return ContainerInterface|null
109
- */
110
- public function getContainer()
111
- {
112
- return $this->container;
113
- }
114
-
115
- /**
116
- * @return CallableResolver|null Returns null if no container was given in the constructor.
117
- */
118
- public function getCallableResolver()
119
- {
120
- return $this->callableResolver;
121
- }
122
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Invoker/InvokerInterface.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
-
3
- namespace Cybot\Dependencies\Invoker;
4
-
5
- use Cybot\Dependencies\Invoker\Exception\InvocationException;
6
- use Cybot\Dependencies\Invoker\Exception\NotCallableException;
7
- use Cybot\Dependencies\Invoker\Exception\NotEnoughParametersException;
8
-
9
- /**
10
- * Invoke a callable.
11
- *
12
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
13
- */
14
- interface InvokerInterface
15
- {
16
- /**
17
- * Call the given function using the given parameters.
18
- *
19
- * @param callable $callable Function to call.
20
- * @param array $parameters Parameters to use.
21
- *
22
- * @return mixed Result of the function.
23
- *
24
- * @throws InvocationException Base exception class for all the sub-exceptions below.
25
- * @throws NotCallableException
26
- * @throws NotEnoughParametersException
27
- */
28
- public function call($callable, array $parameters = array());
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Invoker/ParameterResolver/AssociativeArrayResolver.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
-
3
- namespace Cybot\Dependencies\Invoker\ParameterResolver;
4
-
5
- use ReflectionFunctionAbstract;
6
-
7
- /**
8
- * Tries to map an associative array (string-indexed) to the parameter names.
9
- *
10
- * E.g. `->call($callable, ['foo' => 'bar'])` will inject the string `'bar'`
11
- * in the parameter named `$foo`.
12
- *
13
- * Parameters that are not indexed by a string are ignored.
14
- *
15
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
16
- */
17
- class AssociativeArrayResolver implements ParameterResolver
18
- {
19
- public function getParameters(
20
- ReflectionFunctionAbstract $reflection,
21
- array $providedParameters,
22
- array $resolvedParameters
23
- ) {
24
- $parameters = $reflection->getParameters();
25
-
26
- // Skip parameters already resolved
27
- if (! empty($resolvedParameters)) {
28
- $parameters = array_diff_key($parameters, $resolvedParameters);
29
- }
30
-
31
- foreach ($parameters as $index => $parameter) {
32
- if (array_key_exists($parameter->name, $providedParameters)) {
33
- $resolvedParameters[$index] = $providedParameters[$parameter->name];
34
- }
35
- }
36
-
37
- return $resolvedParameters;
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Invoker/ParameterResolver/Container/ParameterNameContainerResolver.php DELETED
@@ -1,51 +0,0 @@
1
- <?php
2
-
3
- namespace Cybot\Dependencies\Invoker\ParameterResolver\Container;
4
-
5
- use Cybot\Dependencies\Interop\Container\ContainerInterface;
6
- use Cybot\Dependencies\Invoker\ParameterResolver\ParameterResolver;
7
- use ReflectionFunctionAbstract;
8
-
9
- /**
10
- * Inject entries from a DI container using the parameter names.
11
- *
12
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
13
- */
14
- class ParameterNameContainerResolver implements ParameterResolver
15
- {
16
- /**
17
- * @var ContainerInterface
18
- */
19
- private $container;
20
-
21
- /**
22
- * @param ContainerInterface $container The container to get entries from.
23
- */
24
- public function __construct(ContainerInterface $container)
25
- {
26
- $this->container = $container;
27
- }
28
-
29
- public function getParameters(
30
- ReflectionFunctionAbstract $reflection,
31
- array $providedParameters,
32
- array $resolvedParameters
33
- ) {
34
- $parameters = $reflection->getParameters();
35
-
36
- // Skip parameters already resolved
37
- if (! empty($resolvedParameters)) {
38
- $parameters = array_diff_key($parameters, $resolvedParameters);
39
- }
40
-
41
- foreach ($parameters as $index => $parameter) {
42
- $name = $parameter->name;
43
-
44
- if ($name && $this->container->has($name)) {
45
- $resolvedParameters[$index] = $this->container->get($name);
46
- }
47
- }
48
-
49
- return $resolvedParameters;
50
- }
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Invoker/ParameterResolver/Container/TypeHintContainerResolver.php DELETED
@@ -1,51 +0,0 @@
1
- <?php
2
-
3
- namespace Cybot\Dependencies\Invoker\ParameterResolver\Container;
4
-
5
- use Cybot\Dependencies\Interop\Container\ContainerInterface;
6
- use Cybot\Dependencies\Invoker\ParameterResolver\ParameterResolver;
7
- use ReflectionFunctionAbstract;
8
-
9
- /**
10
- * Inject entries from a DI container using the type-hints.
11
- *
12
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
13
- */
14
- class TypeHintContainerResolver implements ParameterResolver
15
- {
16
- /**
17
- * @var ContainerInterface
18
- */
19
- private $container;
20
-
21
- /**
22
- * @param ContainerInterface $container The container to get entries from.
23
- */
24
- public function __construct(ContainerInterface $container)
25
- {
26
- $this->container = $container;
27
- }
28
-
29
- public function getParameters(
30
- ReflectionFunctionAbstract $reflection,
31
- array $providedParameters,
32
- array $resolvedParameters
33
- ) {
34
- $parameters = $reflection->getParameters();
35
-
36
- // Skip parameters already resolved
37
- if (! empty($resolvedParameters)) {
38
- $parameters = array_diff_key($parameters, $resolvedParameters);
39
- }
40
-
41
- foreach ($parameters as $index => $parameter) {
42
- $parameterClass = $parameter->getClass();
43
-
44
- if ($parameterClass && $this->container->has($parameterClass->name)) {
45
- $resolvedParameters[$index] = $this->container->get($parameterClass->name);
46
- }
47
- }
48
-
49
- return $resolvedParameters;
50
- }
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Invoker/ParameterResolver/DefaultValueResolver.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
-
3
- namespace Cybot\Dependencies\Invoker\ParameterResolver;
4
-
5
- use ReflectionException;
6
- use ReflectionFunctionAbstract;
7
-
8
- /**
9
- * Finds the default value for a parameter, *if it exists*.
10
- *
11
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
12
- */
13
- class DefaultValueResolver implements ParameterResolver
14
- {
15
- public function getParameters(
16
- ReflectionFunctionAbstract $reflection,
17
- array $providedParameters,
18
- array $resolvedParameters
19
- ) {
20
- $parameters = $reflection->getParameters();
21
-
22
- // Skip parameters already resolved
23
- if (! empty($resolvedParameters)) {
24
- $parameters = array_diff_key($parameters, $resolvedParameters);
25
- }
26
-
27
- foreach ($parameters as $index => $parameter) {
28
- /** @var \ReflectionParameter $parameter */
29
- if ($parameter->isOptional()) {
30
- try {
31
- $resolvedParameters[$index] = $parameter->getDefaultValue();
32
- } catch (ReflectionException $e) {
33
- // Can't get default values from PHP internal classes and functions
34
- }
35
- }
36
- }
37
-
38
- return $resolvedParameters;
39
- }
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Invoker/ParameterResolver/NumericArrayResolver.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
-
3
- namespace Cybot\Dependencies\Invoker\ParameterResolver;
4
-
5
- use ReflectionFunctionAbstract;
6
-
7
- /**
8
- * Simply returns all the values of the $providedParameters array that are
9
- * indexed by the parameter position (i.e. a number).
10
- *
11
- * E.g. `->call($callable, ['foo', 'bar'])` will simply resolve the parameters
12
- * to `['foo', 'bar']`.
13
- *
14
- * Parameters that are not indexed by a number (i.e. parameter position)
15
- * will be ignored.
16
- *
17
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
18
- */
19
- class NumericArrayResolver implements ParameterResolver
20
- {
21
- public function getParameters(
22
- ReflectionFunctionAbstract $reflection,
23
- array $providedParameters,
24
- array $resolvedParameters
25
- ) {
26
- // Skip parameters already resolved
27
- if (! empty($resolvedParameters)) {
28
- $providedParameters = array_diff_key($providedParameters, $resolvedParameters);
29
- }
30
-
31
- foreach ($providedParameters as $key => $value) {
32
- if (is_int($key)) {
33
- $resolvedParameters[$key] = $value;
34
- }
35
- }
36
-
37
- return $resolvedParameters;
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Invoker/ParameterResolver/ParameterResolver.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
-
3
- namespace Cybot\Dependencies\Invoker\ParameterResolver;
4
-
5
- use ReflectionFunctionAbstract;
6
-
7
- /**
8
- * Resolves the parameters to use to call the callable.
9
- *
10
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
11
- */
12
- interface ParameterResolver
13
- {
14
- /**
15
- * Resolves the parameters to use to call the callable.
16
- *
17
- * `$resolvedParameters` contains parameters that have already been resolved.
18
- *
19
- * Each ParameterResolver must resolve parameters that are not already
20
- * in `$resolvedParameters`. That allows to chain multiple ParameterResolver.
21
- *
22
- * @param ReflectionFunctionAbstract $reflection Reflection object for the callable.
23
- * @param array $providedParameters Parameters provided by the caller.
24
- * @param array $resolvedParameters Parameters resolved (indexed by parameter position).
25
- *
26
- * @return array
27
- */
28
- public function getParameters(
29
- ReflectionFunctionAbstract $reflection,
30
- array $providedParameters,
31
- array $resolvedParameters
32
- );
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Invoker/ParameterResolver/ResolverChain.php DELETED
@@ -1,69 +0,0 @@
1
- <?php
2
-
3
- namespace Cybot\Dependencies\Invoker\ParameterResolver;
4
-
5
- use ReflectionFunctionAbstract;
6
-
7
- /**
8
- * Dispatches the call to other resolvers until all parameters are resolved.
9
- *
10
- * Chain of responsibility pattern.
11
- *
12
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
13
- */
14
- class ResolverChain implements ParameterResolver
15
- {
16
- /**
17
- * @var ParameterResolver[]
18
- */
19
- private $resolvers = array();
20
-
21
- public function __construct(array $resolvers = array())
22
- {
23
- $this->resolvers = $resolvers;
24
- }
25
-
26
- public function getParameters(
27
- ReflectionFunctionAbstract $reflection,
28
- array $providedParameters,
29
- array $resolvedParameters
30
- ) {
31
- $reflectionParameters = $reflection->getParameters();
32
-
33
- foreach ($this->resolvers as $resolver) {
34
- $resolvedParameters = $resolver->getParameters(
35
- $reflection,
36
- $providedParameters,
37
- $resolvedParameters
38
- );
39
-
40
- $diff = array_diff_key($reflectionParameters, $resolvedParameters);
41
- if (empty($diff)) {
42
- // Stop traversing: all parameters are resolved
43
- return $resolvedParameters;
44
- }
45
- }
46
-
47
- return $resolvedParameters;
48
- }
49
-
50
- /**
51
- * Push a parameter resolver after the ones already registered.
52
- *
53
- * @param ParameterResolver $resolver
54
- */
55
- public function appendResolver(ParameterResolver $resolver)
56
- {
57
- $this->resolvers[] = $resolver;
58
- }
59
-
60
- /**
61
- * Insert a parameter resolver before the ones already registered.
62
- *
63
- * @param ParameterResolver $resolver
64
- */
65
- public function prependResolver(ParameterResolver $resolver)
66
- {
67
- array_unshift($this->resolvers, $resolver);
68
- }
69
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Invoker/ParameterResolver/TypeHintResolver.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
-
3
- namespace Cybot\Dependencies\Invoker\ParameterResolver;
4
-
5
- use Cybot\Dependencies\Invoker\ParameterResolver\ParameterResolver;
6
- use ReflectionFunctionAbstract;
7
-
8
- /**
9
- * Inject entries using type-hints.
10
- *
11
- * Tries to match type-hints with the parameters provided.
12
- *
13
- * @author Felix Becker <f.becker@outlook.com>
14
- */
15
- class TypeHintResolver implements ParameterResolver
16
- {
17
- public function getParameters(
18
- ReflectionFunctionAbstract $reflection,
19
- array $providedParameters,
20
- array $resolvedParameters
21
- ) {
22
- $parameters = $reflection->getParameters();
23
-
24
- // Skip parameters already resolved
25
- if (! empty($resolvedParameters)) {
26
- $parameters = array_diff_key($parameters, $resolvedParameters);
27
- }
28
-
29
- foreach ($parameters as $index => $parameter) {
30
- $parameterClass = $parameter->getClass();
31
-
32
- if ($parameterClass && array_key_exists($parameterClass->name, $providedParameters)) {
33
- $resolvedParameters[$index] = $providedParameters[$parameterClass->name];
34
- }
35
- }
36
-
37
- return $resolvedParameters;
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Invoker/Reflection/CallableReflection.php DELETED
@@ -1,61 +0,0 @@
1
- <?php
2
-
3
- namespace Cybot\Dependencies\Invoker\Reflection;
4
-
5
- use Cybot\Dependencies\Invoker\Exception\NotCallableException;
6
-
7
- /**
8
- * Create a reflection object from a callable.
9
- *
10
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
11
- */
12
- class CallableReflection
13
- {
14
- /**
15
- * @param callable $callable
16
- *
17
- * @return \ReflectionFunctionAbstract
18
- *
19
- * @throws NotCallableException
20
- *
21
- * TODO Use the `callable` type-hint once support for PHP 5.4 and up.
22
- */
23
- public static function create($callable)
24
- {
25
- // Closure
26
- if ($callable instanceof \Closure) {
27
- return new \ReflectionFunction($callable);
28
- }
29
-
30
- // Array callable
31
- if (is_array($callable)) {
32
- list($class, $method) = $callable;
33
-
34
- if (! method_exists($class, $method)) {
35
- throw NotCallableException::fromInvalidCallable($callable);
36
- }
37
-
38
- return new \ReflectionMethod($class, $method);
39
- }
40
-
41
- // Callable object (i.e. implementing __invoke())
42
- if (is_object($callable) && method_exists($callable, '__invoke')) {
43
- return new \ReflectionMethod($callable, '__invoke');
44
- }
45
-
46
- // Callable class (i.e. implementing __invoke())
47
- if (is_string($callable) && class_exists($callable) && method_exists($callable, '__invoke')) {
48
- return new \ReflectionMethod($callable, '__invoke');
49
- }
50
-
51
- // Standard function
52
- if (is_string($callable) && function_exists($callable)) {
53
- return new \ReflectionFunction($callable);
54
- }
55
-
56
- throw new NotCallableException(sprintf(
57
- '%s is not a callable',
58
- is_string($callable) ? $callable : 'Instance of ' . get_class($callable)
59
- ));
60
- }
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/PhpDocReader/AnnotationException.php DELETED
@@ -1,10 +0,0 @@
1
- <?php declare(strict_types=1);
2
-
3
- namespace Cybot\Dependencies\PhpDocReader;
4
-
5
- /**
6
- * We stumbled upon an invalid class/property/method annotation.
7
- */
8
- class AnnotationException extends \Exception
9
- {
10
- }
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/PhpDocReader/PhpDocReader.php DELETED
@@ -1,307 +0,0 @@
1
- <?php declare(strict_types=1);
2
-
3
- namespace Cybot\Dependencies\PhpDocReader;
4
-
5
- use Cybot\Dependencies\PhpDocReader\PhpParser\UseStatementParser;
6
- use ReflectionClass;
7
- use ReflectionMethod;
8
- use ReflectionParameter;
9
- use ReflectionProperty;
10
- use Reflector;
11
-
12
- /**
13
- * PhpDoc reader
14
- */
15
- class PhpDocReader
16
- {
17
- /** @var UseStatementParser */
18
- private $parser;
19
-
20
- private const PRIMITIVE_TYPES = [
21
- 'bool' => 'bool',
22
- 'boolean' => 'bool',
23
- 'string' => 'string',
24
- 'int' => 'int',
25
- 'integer' => 'int',
26
- 'float' => 'float',
27
- 'double' => 'float',
28
- 'array' => 'array',
29
- 'object' => 'object',
30
- 'callable' => 'callable',
31
- 'resource' => 'resource',
32
- 'mixed' => 'mixed',
33
- 'iterable' => 'iterable',
34
- ];
35
-
36
- /** @var bool */
37
- private $ignorePhpDocErrors;
38
-
39
- /**
40
- * @param bool $ignorePhpDocErrors Enable or disable throwing errors when PhpDoc errors occur (when parsing annotations).
41
- */
42
- public function __construct(bool $ignorePhpDocErrors = false)
43
- {
44
- $this->parser = new UseStatementParser;
45
- $this->ignorePhpDocErrors = $ignorePhpDocErrors;
46
- }
47
-
48
- /**
49
- * Parse the docblock of the property to get the type (class or primitive type) of the var annotation.
50
- *
51
- * @return string|null Type of the property (content of var annotation)
52
- * @throws AnnotationException
53
- */
54
- public function getPropertyType(ReflectionProperty $property): ?string
55
- {
56
- return $this->readPropertyType($property, true);
57
- }
58
-
59
- /**
60
- * Parse the docblock of the property to get the class of the var annotation.
61
- *
62
- * @return string|null Type of the property (content of var annotation)
63
- * @throws AnnotationException
64
- */
65
- public function getPropertyClass(ReflectionProperty $property): ?string
66
- {
67
- return $this->readPropertyType($property, false);
68
- }
69
-
70
- private function readPropertyType(ReflectionProperty $property, bool $allowPrimitiveTypes): ?string
71
- {
72
- // Get the content of the @var annotation
73
- $docComment = $property->getDocComment();
74
- if (! $docComment) {
75
- return null;
76
- }
77
- if (preg_match('/@var\s+([^\s]+)/', $docComment, $matches)) {
78
- [, $type] = $matches;
79
- } else {
80
- return null;
81
- }
82
-
83
- // Ignore primitive types
84
- if (isset(self::PRIMITIVE_TYPES[$type])) {
85
- if ($allowPrimitiveTypes) {
86
- return self::PRIMITIVE_TYPES[$type];
87
- }
88
- return null;
89
- }
90
-
91
- // Ignore types containing special characters ([], <> ...)
92
- if (! preg_match('/^[a-zA-Z0-9\\\\_]+$/', $type)) {
93
- return null;
94
- }
95
-
96
- $class = $property->getDeclaringClass();
97
-
98
- // If the class name is not fully qualified (i.e. doesn't start with a \)
99
- if ($type[0] !== '\\') {
100
- // Try to resolve the FQN using the class context
101
- $resolvedType = $this->tryResolveFqn($type, $class, $property);
102
-
103
- if (! $resolvedType && ! $this->ignorePhpDocErrors) {
104
- throw new AnnotationException(sprintf(
105
- 'The @var annotation on %s::%s contains a non existent class "%s". '
106
- . 'Did you maybe forget to add a "use" statement for this annotation?',
107
- $class->name,
108
- $property->getName(),
109
- $type
110
- ));
111
- }
112
-
113
- $type = $resolvedType;
114
- }
115
-
116
- if (! $this->ignorePhpDocErrors && ! $this->classExists($type)) {
117
- throw new AnnotationException(sprintf(
118
- 'The @var annotation on %s::%s contains a non existent class "%s"',
119
- $class->name,
120
- $property->getName(),
121
- $type
122
- ));
123
- }
124
-
125
- // Remove the leading \ (FQN shouldn't contain it)
126
- $type = is_string($type) ? ltrim($type, '\\') : null;
127
-
128
- return $type;
129
- }
130
-
131
- /**
132
- * Parse the docblock of the property to get the type (class or primitive type) of the param annotation.
133
- *
134
- * @return string|null Type of the property (content of var annotation)
135
- * @throws AnnotationException
136
- */
137
- public function getParameterType(ReflectionParameter $parameter): ?string
138
- {
139
- return $this->readParameterClass($parameter, true);
140
- }
141
-
142
- /**
143
- * Parse the docblock of the property to get the class of the param annotation.
144
- *
145
- * @return string|null Type of the property (content of var annotation)
146
- * @throws AnnotationException
147
- */
148
- public function getParameterClass(ReflectionParameter $parameter): ?string
149
- {
150
- return $this->readParameterClass($parameter, false);
151
- }
152
-
153
- private function readParameterClass(ReflectionParameter $parameter, bool $allowPrimitiveTypes): ?string
154
- {
155
- // Use reflection
156
- $parameterType = $parameter->getType();
157
- if ($parameterType && $parameterType instanceof \ReflectionNamedType && ! $parameterType->isBuiltin()) {
158
- return $parameterType->getName();
159
- }
160
-
161
- $parameterName = $parameter->name;
162
- // Get the content of the @param annotation
163
- $method = $parameter->getDeclaringFunction();
164
- $docComment = $method->getDocComment();
165
- if (! $docComment) {
166
- return null;
167
- }
168
- if (preg_match('/@param\s+([^\s]+)\s+\$' . $parameterName . '/', $docComment, $matches)) {
169
- [, $type] = $matches;
170
- } else {
171
- return null;
172
- }
173
-
174
- // Ignore primitive types
175
- if (isset(self::PRIMITIVE_TYPES[$type])) {
176
- if ($allowPrimitiveTypes) {
177
- return self::PRIMITIVE_TYPES[$type];
178
- }
179
- return null;
180
- }
181
-
182
- // Ignore types containing special characters ([], <> ...)
183
- if (! preg_match('/^[a-zA-Z0-9\\\\_]+$/', $type)) {
184
- return null;
185
- }
186
-
187
- $class = $parameter->getDeclaringClass();
188
-
189
- // If the class name is not fully qualified (i.e. doesn't start with a \)
190
- if ($type[0] !== '\\') {
191
- // Try to resolve the FQN using the class context
192
- $resolvedType = $this->tryResolveFqn($type, $class, $parameter);
193
-
194
- if (! $resolvedType && ! $this->ignorePhpDocErrors) {
195
- throw new AnnotationException(sprintf(
196
- 'The @param annotation for parameter "%s" of %s::%s contains a non existent class "%s". '
197
- . 'Did you maybe forget to add a "use" statement for this annotation?',
198
- $parameterName,
199
- $class->name,
200
- $method->name,
201
- $type
202
- ));
203
- }
204
-
205
- $type = $resolvedType;
206
- }
207
-
208
- if (! $this->ignorePhpDocErrors && ! $this->classExists($type)) {
209
- throw new AnnotationException(sprintf(
210
- 'The @param annotation for parameter "%s" of %s::%s contains a non existent class "%s"',
211
- $parameterName,
212
- $class->name,
213
- $method->name,
214
- $type
215
- ));
216
- }
217
-
218
- // Remove the leading \ (FQN shouldn't contain it)
219
- $type = is_string($type) ? ltrim($type, '\\') : null;
220
-
221
- return $type;
222
- }
223
-
224
- /**
225
- * Attempts to resolve the FQN of the provided $type based on the $class and $member context.
226
- *
227
- * @return string|null Fully qualified name of the type, or null if it could not be resolved
228
- */
229
- private function tryResolveFqn(string $type, ReflectionClass $class, Reflector $member): ?string
230
- {
231
- $alias = ($pos = strpos($type, '\\')) === false ? $type : substr($type, 0, $pos);
232
- $loweredAlias = strtolower($alias);
233
-
234
- // Retrieve "use" statements
235
- $uses = $this->parser->parseUseStatements($class);
236
-
237
- if (isset($uses[$loweredAlias])) {
238
- // Imported classes
239
- if ($pos !== false) {
240
- return $uses[$loweredAlias] . substr($type, $pos);
241
- }
242
- return $uses[$loweredAlias];
243
- }
244
-
245
- if ($this->classExists($class->getNamespaceName() . '\\' . $type)) {
246
- return $class->getNamespaceName() . '\\' . $type;
247
- }
248
-
249
- if (isset($uses['__NAMESPACE__']) && $this->classExists($uses['__NAMESPACE__'] . '\\' . $type)) {
250
- // Class namespace
251
- return $uses['__NAMESPACE__'] . '\\' . $type;
252
- }
253
-
254
- if ($this->classExists($type)) {
255
- // No namespace
256
- return $type;
257
- }
258
-
259
- // If all fail, try resolving through related traits
260
- return $this->tryResolveFqnInTraits($type, $class, $member);
261
- }
262
-
263
- /**
264
- * Attempts to resolve the FQN of the provided $type based on the $class and $member context, specifically searching
265
- * through the traits that are used by the provided $class.
266
- *
267
- * @return string|null Fully qualified name of the type, or null if it could not be resolved
268
- */
269
- private function tryResolveFqnInTraits(string $type, ReflectionClass $class, Reflector $member): ?string
270
- {
271
- /** @var ReflectionClass[] $traits */
272
- $traits = [];
273
-
274
- // Get traits for the class and its parents
275
- while ($class) {
276
- $traits = array_merge($traits, $class->getTraits());
277
- $class = $class->getParentClass();
278
- }
279
-
280
- foreach ($traits as $trait) {
281
- // Eliminate traits that don't have the property/method/parameter
282
- if ($member instanceof ReflectionProperty && ! $trait->hasProperty($member->name)) {
283
- continue;
284
- }
285
- if ($member instanceof ReflectionMethod && ! $trait->hasMethod($member->name)) {
286
- continue;
287
- }
288
- if ($member instanceof ReflectionParameter && ! $trait->hasMethod($member->getDeclaringFunction()->name)) {
289
- continue;
290
- }
291
-
292
- // Run the resolver again with the ReflectionClass instance for the trait
293
- $resolvedType = $this->tryResolveFqn($type, $trait, $member);
294
-
295
- if ($resolvedType) {
296
- return $resolvedType;
297
- }
298
- }
299
-
300
- return null;
301
- }
302
-
303
- private function classExists(string $class): bool
304
- {
305
- return class_exists($class) || interface_exists($class);
306
- }
307
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/PhpDocReader/PhpParser/TokenParser.php DELETED
@@ -1,182 +0,0 @@
1
- <?php declare(strict_types=1);
2
-
3
- namespace Cybot\Dependencies\PhpDocReader\PhpParser;
4
-
5
- /**
6
- * Parses a file for namespaces/use/class declarations.
7
- *
8
- * Class taken and adapted from doctrine/annotations to avoid pulling the whole package.
9
- *
10
- * @author Fabien Potencier <fabien@symfony.com>
11
- * @author Christian Kaps <christian.kaps@mohiva.com>
12
- */
13
- class TokenParser
14
- {
15
- /**
16
- * The token list.
17
- *
18
- * @var list<mixed[]>
19
- */
20
- private $tokens;
21
-
22
- /**
23
- * The number of tokens.
24
- *
25
- * @var int
26
- */
27
- private $numTokens;
28
-
29
- /**
30
- * The current array pointer.
31
- *
32
- * @var int
33
- */
34
- private $pointer = 0;
35
-
36
- /**
37
- * @param string $contents
38
- */
39
- public function __construct($contents)
40
- {
41
- $this->tokens = token_get_all($contents);
42
-
43
- // The PHP parser sets internal compiler globals for certain things. Annoyingly, the last docblock comment it
44
- // saw gets stored in doc_comment. When it comes to compile the next thing to be include()d this stored
45
- // doc_comment becomes owned by the first thing the compiler sees in the file that it considers might have a
46
- // docblock. If the first thing in the file is a class without a doc block this would cause calls to
47
- // getDocBlock() on said class to return our long lost doc_comment. Argh.
48
- // To workaround, cause the parser to parse an empty docblock. Sure getDocBlock() will return this, but at least
49
- // it's harmless to us.
50
- token_get_all("<?php\n/**\n *\n */");
51
-
52
- $this->numTokens = count($this->tokens);
53
- }
54
-
55
- /**
56
- * Gets all use statements.
57
- *
58
- * @param string $namespaceName The namespace name of the reflected class.
59
- *
60
- * @return array<string, string> A list with all found use statements.
61
- */
62
- public function parseUseStatements($namespaceName)
63
- {
64
- $statements = [];
65
- while (($token = $this->next())) {
66
- if ($token[0] === T_USE) {
67
- $statements = array_merge($statements, $this->parseUseStatement());
68
- continue;
69
- }
70
-
71
- if ($token[0] !== T_NAMESPACE || $this->parseNamespace() !== $namespaceName) {
72
- continue;
73
- }
74
-
75
- // Get fresh array for new namespace. This is to prevent the parser to collect the use statements
76
- // for a previous namespace with the same name. This is the case if a namespace is defined twice
77
- // or if a namespace with the same name is commented out.
78
- $statements = [];
79
- }
80
-
81
- return $statements;
82
- }
83
-
84
- /**
85
- * Gets the next non whitespace and non comment token.
86
- *
87
- * @param bool $docCommentIsComment If TRUE then a doc comment is considered a comment and skipped.
88
- * If FALSE then only whitespace and normal comments are skipped.
89
- *
90
- * @return mixed[]|string|null The token if exists, null otherwise.
91
- */
92
- private function next($docCommentIsComment = true)
93
- {
94
- for ($i = $this->pointer; $i < $this->numTokens; $i++) {
95
- $this->pointer++;
96
- if (
97
- $this->tokens[$i][0] === T_WHITESPACE ||
98
- $this->tokens[$i][0] === T_COMMENT ||
99
- ($docCommentIsComment && $this->tokens[$i][0] === T_DOC_COMMENT)
100
- ) {
101
- continue;
102
- }
103
-
104
- return $this->tokens[$i];
105
- }
106
-
107
- return null;
108
- }
109
-
110
- /**
111
- * Parses a single use statement.
112
- *
113
- * @return array<string, string> A list with all found class names for a use statement.
114
- */
115
- private function parseUseStatement()
116
- {
117
- $groupRoot = '';
118
- $class = '';
119
- $alias = '';
120
- $statements = [];
121
- $explicitAlias = false;
122
- while (($token = $this->next())) {
123
- if (! $explicitAlias && $token[0] === T_STRING) {
124
- $class .= $token[1];
125
- $alias = $token[1];
126
- } elseif ($explicitAlias && $token[0] === T_STRING) {
127
- $alias = $token[1];
128
- } elseif (
129
- PHP_VERSION_ID >= 80000 &&
130
- ($token[0] === T_NAME_QUALIFIED || $token[0] === T_NAME_FULLY_QUALIFIED)
131
- ) {
132
- $class .= $token[1];
133
-
134
- $classSplit = explode('\\', $token[1]);
135
- $alias = $classSplit[count($classSplit) - 1];
136
- } elseif ($token[0] === T_NS_SEPARATOR) {
137
- $class .= '\\';
138
- $alias = '';
139
- } elseif ($token[0] === T_AS) {
140
- $explicitAlias = true;
141
- $alias = '';
142
- } elseif ($token === ',') {
143
- $statements[strtolower($alias)] = $groupRoot . $class;
144
- $class = '';
145
- $alias = '';
146
- $explicitAlias = false;
147
- } elseif ($token === ';') {
148
- $statements[strtolower($alias)] = $groupRoot . $class;
149
- break;
150
- } elseif ($token === '{') {
151
- $groupRoot = $class;
152
- $class = '';
153
- } elseif ($token === '}') {
154
- continue;
155
- } else {
156
- break;
157
- }
158
- }
159
-
160
- return $statements;
161
- }
162
-
163
- /**
164
- * Gets the namespace.
165
- *
166
- * @return string The found namespace.
167
- */
168
- private function parseNamespace()
169
- {
170
- $name = '';
171
- while (
172
- ($token = $this->next()) && ($token[0] === T_STRING || $token[0] === T_NS_SEPARATOR || (
173
- PHP_VERSION_ID >= 80000 &&
174
- ($token[0] === T_NAME_QUALIFIED || $token[0] === T_NAME_FULLY_QUALIFIED)
175
- ))
176
- ) {
177
- $name .= $token[1];
178
- }
179
-
180
- return $name;
181
- }
182
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/PhpDocReader/PhpParser/UseStatementParser.php DELETED
@@ -1,64 +0,0 @@
1
- <?php declare(strict_types=1);
2
-
3
- namespace Cybot\Dependencies\PhpDocReader\PhpParser;
4
-
5
- use SplFileObject;
6
-
7
- /**
8
- * Parses a file for "use" declarations.
9
- *
10
- * Class taken and adapted from doctrine/annotations to avoid pulling the whole package.
11
- *
12
- * Authors: Fabien Potencier <fabien@symfony.com> and Christian Kaps <christian.kaps@mohiva.com>
13
- */
14
- class UseStatementParser
15
- {
16
- /**
17
- * @return array A list with use statements in the form (Alias => FQN).
18
- */
19
- public function parseUseStatements(\ReflectionClass $class): array
20
- {
21
- $filename = $class->getFilename();
22
- if ($filename === false) {
23
- return [];
24
- }
25
-
26
- $content = $this->getFileContent($filename, $class->getStartLine());
27
-
28
- if ($content === null) {
29
- return [];
30
- }
31
-
32
- $namespace = preg_quote($class->getNamespaceName(), '/');
33
- $content = preg_replace('/^.*?(\bnamespace\s+' . $namespace . '\s*[;{].*)$/s', '\\1', $content);
34
- $tokenizer = new TokenParser('<?php ' . $content);
35
-
36
- return $tokenizer->parseUseStatements($class->getNamespaceName());
37
- }
38
-
39
- /**
40
- * Gets the content of the file right up to the given line number.
41
- *
42
- * @param string $filename The name of the file to load.
43
- * @param int $lineNumber The number of lines to read from file.
44
- */
45
- private function getFileContent(string $filename, int $lineNumber): string
46
- {
47
- if (! is_file($filename)) {
48
- throw new \RuntimeException("Unable to read file $filename");
49
- }
50
-
51
- $content = '';
52
- $lineCnt = 0;
53
- $file = new SplFileObject($filename);
54
- while (! $file->eof()) {
55
- if ($lineCnt++ === $lineNumber) {
56
- break;
57
- }
58
-
59
- $content .= $file->fgets();
60
- }
61
-
62
- return $content;
63
- }
64
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Psr/Container/ContainerExceptionInterface.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
- /**
3
- * @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
4
- */
5
-
6
- namespace Cybot\Dependencies\Psr\Container;
7
-
8
- /**
9
- * Base interface representing a generic exception in a container.
10
- */
11
- interface ContainerExceptionInterface
12
- {
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Psr/Container/ContainerInterface.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- /**
3
- * @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
4
- */
5
-
6
- namespace Cybot\Dependencies\Psr\Container;
7
-
8
- /**
9
- * Describes the interface of a container that exposes methods to read its entries.
10
- */
11
- interface ContainerInterface
12
- {
13
- /**
14
- * Finds an entry of the container by its identifier and returns it.
15
- *
16
- * @param string $id Identifier of the entry to look for.
17
- *
18
- * @throws NotFoundExceptionInterface No entry was found for **this** identifier.
19
- * @throws ContainerExceptionInterface Error while retrieving the entry.
20
- *
21
- * @return mixed Entry.
22
- */
23
- public function get($id);
24
-
25
- /**
26
- * Returns true if the container can return an entry for the given identifier.
27
- * Returns false otherwise.
28
- *
29
- * `has($id)` returning true does not mean that `get($id)` will not throw an exception.
30
- * It does however mean that `get($id)` will not throw a `NotFoundExceptionInterface`.
31
- *
32
- * @param string $id Identifier of the entry to look for.
33
- *
34
- * @return bool
35
- */
36
- public function has($id);
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/Dependencies/Psr/Container/NotFoundExceptionInterface.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
- /**
3
- * @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
4
- */
5
-
6
- namespace Cybot\Dependencies\Psr\Container;
7
-
8
- /**
9
- * No entry was found in the container.
10
- */
11
- interface NotFoundExceptionInterface extends ContainerExceptionInterface
12
- {
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/inc/classes/dependencies/.gitkeep DELETED
File without changes
addons/js/jquery.tipTip.js DELETED
@@ -1,193 +0,0 @@
1
- /*
2
- * TipTip
3
- * Copyright 2010 Drew Wilson
4
- * www.drewwilson.com
5
- * code.drewwilson.com/entry/tiptip-jquery-plugin
6
- *
7
- * Version 1.3 - Updated: Mar. 23, 2010
8
- *
9
- * This Plug-In will create a custom tooltip to replace the default
10
- * browser tooltip. It is extremely lightweight and very smart in
11
- * that it detects the edges of the browser window and will make sure
12
- * the tooltip stays within the current window size. As a result the
13
- * tooltip will adjust itself to be displayed above, below, to the left
14
- * or to the right depending on what is necessary to stay within the
15
- * browser window. It is completely customizable as well via CSS.
16
- *
17
- * This TipTip jQuery plug-in is dual licensed under the MIT and GPL licenses:
18
- * http://www.opensource.org/licenses/mit-license.php
19
- * http://www.gnu.org/licenses/gpl.html
20
- */
21
-
22
- (function($){
23
- $.fn.tipTip = function(options) {
24
- var defaults = {
25
- activation: "hover",
26
- keepAlive: false,
27
- maxWidth: "200px",
28
- edgeOffset: 3,
29
- defaultPosition: "bottom",
30
- delay: 400,
31
- fadeIn: 200,
32
- fadeOut: 200,
33
- attribute: "title",
34
- content: false, // HTML or String to fill TipTIp with
35
- enter: function(){},
36
- exit: function(){}
37
- };
38
- var opts = $.extend(defaults, options);
39
-
40
- // Setup tip tip elements and render them to the DOM
41
- if($("#tiptip_holder").length <= 0){
42
- var tiptip_holder = $('<div id="tiptip_holder" style="max-width:'+ opts.maxWidth +';"></div>');
43
- var tiptip_content = $('<div id="tiptip_content"></div>');
44
- var tiptip_arrow = $('<div id="tiptip_arrow"></div>');
45
- $("body").append(tiptip_holder.html(tiptip_content).prepend(tiptip_arrow.html('<div id="tiptip_arrow_inner"></div>')));
46
- } else {
47
- var tiptip_holder = $("#tiptip_holder");
48
- var tiptip_content = $("#tiptip_content");
49
- var tiptip_arrow = $("#tiptip_arrow");
50
- }
51
-
52
- return this.each(function(){
53
- var org_elem = $(this);
54
- if(opts.content){
55
- var org_title = opts.content;
56
- } else {
57
- var org_title = org_elem.attr(opts.attribute);
58
- }
59
-
60
- if(org_title != ""){
61
- if(!opts.content){
62
- org_elem.removeAttr(opts.attribute); //remove original Attribute
63
- }
64
- var timeout = false;
65
-
66
- if(opts.activation == "hover"){
67
- org_elem.hover(function(){
68
- active_tiptip();
69
- }, function(){
70
- if(!opts.keepAlive){
71
- deactive_tiptip();
72
- }
73
- });
74
- if(opts.keepAlive){
75
- tiptip_holder.hover(function(){}, function(){
76
- deactive_tiptip();
77
- });
78
- }
79
- } else if(opts.activation == "focus"){
80
- org_elem.focus(function(){
81
- active_tiptip();
82
- }).blur(function(){
83
- deactive_tiptip();
84
- });
85
- } else if(opts.activation == "click"){
86
- org_elem.click(function(){
87
- active_tiptip();
88
- return false;
89
- }).hover(function(){},function(){
90
- if(!opts.keepAlive){
91
- deactive_tiptip();
92
- }
93
- });
94
- if(opts.keepAlive){
95
- tiptip_holder.hover(function(){}, function(){
96
- deactive_tiptip();
97
- });
98
- }
99
- }
100
-
101
- function active_tiptip(){
102
- opts.enter.call(this);
103
- tiptip_content.html(org_title);
104
- tiptip_holder.hide().removeAttr("class").css("margin","0");
105
- tiptip_arrow.removeAttr("style");
106
-
107
- var top = parseInt(org_elem.offset()['top']);
108
- var left = parseInt(org_elem.offset()['left']);
109
- var org_width = parseInt(org_elem.outerWidth());
110
- var org_height = parseInt(org_elem.outerHeight());
111
- var tip_w = tiptip_holder.outerWidth();
112
- var tip_h = tiptip_holder.outerHeight();
113
- var w_compare = Math.round((org_width - tip_w) / 2);
114
- var h_compare = Math.round((org_height - tip_h) / 2);
115
- var marg_left = Math.round(left + w_compare);
116
- var marg_top = Math.round(top + org_height + opts.edgeOffset);
117
- var t_class = "";
118
- var arrow_top = "";
119
- var arrow_left = Math.round(tip_w - 12) / 2;
120
-
121
- if(opts.defaultPosition == "bottom"){
122
- t_class = "_bottom";
123
- } else if(opts.defaultPosition == "top"){
124
- t_class = "_top";
125
- } else if(opts.defaultPosition == "left"){
126
- t_class = "_left";
127
- } else if(opts.defaultPosition == "right"){
128
- t_class = "_right";
129
- }
130
-
131
- var right_compare = (w_compare + left) < parseInt($(window).scrollLeft());
132
- var left_compare = (tip_w + left) > parseInt($(window).width());
133
-
134
- if((right_compare && w_compare < 0) || (t_class == "_right" && !left_compare) || (t_class == "_left" && left < (tip_w + opts.edgeOffset + 5))){
135
- t_class = "_right";
136
- arrow_top = Math.round(tip_h - 13) / 2;
137
- arrow_left = -12;
138
- marg_left = Math.round(left + org_width + opts.edgeOffset);
139
- marg_top = Math.round(top + h_compare);
140
- } else if((left_compare && w_compare < 0) || (t_class == "_left" && !right_compare)){
141
- t_class = "_left";
142
- arrow_top = Math.round(tip_h - 13) / 2;
143
- arrow_left = Math.round(tip_w);
144
- marg_left = Math.round(left - (tip_w + opts.edgeOffset + 5));
145
- marg_top = Math.round(top + h_compare);
146
- }
147
-
148
- var top_compare = (top + org_height + opts.edgeOffset + tip_h + 8) > parseInt($(window).height() + $(window).scrollTop());
149
- var bottom_compare = ((top + org_height) - (opts.edgeOffset + tip_h + 8)) < 0;
150
-
151
- if(top_compare || (t_class == "_bottom" && top_compare) || (t_class == "_top" && !bottom_compare)){
152
- if(t_class == "_top" || t_class == "_bottom"){
153
- t_class = "_top";
154
- } else {
155
- t_class = t_class+"_top";
156
- }
157
- arrow_top = tip_h;
158
- marg_top = Math.round(top - (tip_h + 5 + opts.edgeOffset));
159
- } else if(bottom_compare | (t_class == "_top" && bottom_compare) || (t_class == "_bottom" && !top_compare)){
160
- if(t_class == "_top" || t_class == "_bottom"){
161
- t_class = "_bottom";
162
- } else {
163
- t_class = t_class+"_bottom";
164
- }
165
- arrow_top = -12;
166
- marg_top = Math.round(top + org_height + opts.edgeOffset);
167
- }
168
-
169
- if(t_class == "_right_top" || t_class == "_left_top"){
170
- marg_top = marg_top + 5;
171
- } else if(t_class == "_right_bottom" || t_class == "_left_bottom"){
172
- marg_top = marg_top - 5;
173
- }
174
- if(t_class == "_left_top" || t_class == "_left_bottom"){
175
- marg_left = marg_left + 5;
176
- }
177
-
178
- tiptip_arrow.css({"margin-left": arrow_left+"px", "margin-top": arrow_top+"px"});
179
- tiptip_holder.css({"margin-left": marg_left+"px", "margin-top": marg_top+"px"}).attr("class","tip"+t_class);
180
-
181
- if (timeout){ clearTimeout(timeout); }
182
- timeout = setTimeout(function(){ tiptip_holder.stop(true,true).fadeIn(opts.fadeIn); }, opts.delay);
183
- }
184
-
185
- function deactive_tiptip(){
186
- opts.exit.call(this);
187
- if (timeout){ clearTimeout(timeout); }
188
- tiptip_holder.fadeOut(opts.fadeOut);
189
- }
190
- }
191
- });
192
- }
193
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/js/settings.js DELETED
@@ -1,203 +0,0 @@
1
- /**
2
- * Load init function when the page is ready
3
- *
4
- * @since 1.8.0
5
- */
6
- jQuery( document ).ready( init );
7
-
8
- /**
9
- * Init settings
10
- *
11
- * @since 1.8.0
12
- */
13
- function init() {
14
- placeholder_select_language();
15
- placeholder_toggle();
16
- button_add_placeholder_language();
17
- button_delete_language();
18
- tooltip();
19
- show_advanced_options();
20
- edit_embed_regex();
21
- set_default_embed_regex();
22
- }
23
-
24
- /**
25
- * Enable/disable placeholder
26
- *
27
- * @since 1.8.0
28
- */
29
- function placeholder_toggle() {
30
- jQuery( document ).on( 'change', '.placeholder_enable', function () {
31
- var status = jQuery( this ).is( ':checked' );
32
- var addon = jQuery( this ).data( 'addon' );
33
-
34
- if ( status ) {
35
- placeholder_enable( addon );
36
- } else {
37
- placeholder_disable( addon );
38
- }
39
- } );
40
- }
41
-
42
- /**
43
- * Placeholder disable
44
- *
45
- * @param addon
46
- *
47
- * @since 1.8.0
48
- */
49
- function placeholder_disable( addon ) {
50
- jQuery( '.placeholder[data-addon="' + addon + '"]' ).hide();
51
- }
52
-
53
- /**
54
- * Placeholder enable
55
- *
56
- * @param addon
57
- *
58
- * @since 1.8.0
59
- */
60
- function placeholder_enable( addon ) {
61
- jQuery( '.placeholder[data-addon="' + addon + '"]' ).show();
62
- }
63
-
64
- /**
65
- * Add language for placeholder
66
- *
67
- * @since 1.8.0
68
- */
69
- function button_add_placeholder_language() {
70
- jQuery( '.btn_add_language' ).on( 'click', function ( e ) {
71
- e.preventDefault();
72
-
73
- var addon = jQuery( this ).data( 'addon' );
74
-
75
- add_placeholder_language_content( addon );
76
-
77
- return false;
78
- } );
79
- }
80
-
81
- /**
82
- * Add placeholder language div
83
- *
84
- * @param addon
85
- *
86
- * @since 1.8.0
87
- */
88
- function add_placeholder_language_content( addon ) {
89
- var data = jQuery( '.placeholder[data-addon="' + addon + '"] .placeholder_content:first' )[ 0 ].outerHTML;
90
-
91
-
92
- jQuery( '.placeholder[data-addon="' + addon + '"] .add_placeholder_language' ).before( data );
93
-
94
- jQuery( '.placeholder[data-addon="' + addon + '"] .placeholder_content:last select' ).after( php.remove_link );
95
-
96
- tooltip();
97
- }
98
-
99
- /**
100
- * Replace select and textarea name
101
- *
102
- * @since 1.8.0
103
- */
104
- function placeholder_select_language() {
105
- jQuery( document ).on( 'change', '.placeholder_select_language', function () {
106
- var new_value = jQuery( this ).val();
107
- var select_name = jQuery( this ).attr( 'name' );
108
-
109
- // get new name
110
- select_name = select_name.substr( 0, select_name.lastIndexOf( '[' ) );
111
- select_name += '[' + new_value + ']';
112
-
113
- // rename select field
114
- jQuery( this ).attr( 'name', select_name );
115
-
116
- // rename textarea
117
- jQuery( this ).parent().next().find( 'textarea' ).attr( 'name', select_name );
118
- } )
119
- }
120
-
121
- /**
122
- * Delete language
123
- *
124
- * @since 1.8.0
125
- */
126
- function button_delete_language() {
127
- jQuery( document ).on( 'click', '.submitdelete', function ( e ) {
128
- e.preventDefault();
129
-
130
- jQuery( this ).parent().parent().remove();
131
-
132
- return false;
133
- } );
134
- }
135
-
136
- /**
137
- * Show tooltip
138
- *
139
- * @since 1.8.0
140
- */
141
- function tooltip() {
142
- jQuery( '.help-tip' ).tipTip( {
143
- 'maxWidth': 300,
144
- 'fadeIn': 50,
145
- 'fadeOut': 50,
146
- 'delay': 200
147
- } );
148
- }
149
-
150
- /**
151
- * Show advanced options
152
- *
153
- * @since 2.4.5
154
- */
155
- function show_advanced_options() {
156
- jQuery(document).on('click', '.show_advanced_options', function( e ) {
157
- e.preventDefault();
158
-
159
- /** Toggle displaying advanced options **/
160
- jQuery( this ).next().toggle();
161
-
162
- return false;
163
- } );
164
- }
165
-
166
- function edit_embed_regex() {
167
- jQuery(document).on('click', '#edit_embed_regex', function(e) {
168
- e.preventDefault();
169
-
170
- /** Get the textarea for the embed regex **/
171
- let embed_regex = document.getElementById("embed_regex");
172
-
173
- /** Remove the disable attribute in the textarea **/
174
- embed_regex.disabled = false;
175
-
176
- /** Make the Reset default button back visible **/
177
- let default_button = document.getElementById('btn_default_embed_regex');
178
- default_button.classList.remove('hidden');
179
-
180
- jQuery(this).hide();
181
-
182
- return false;
183
- });
184
- }
185
-
186
- /**
187
- * Set default embed regex
188
- *
189
- * @since 2.4.5
190
- */
191
- function set_default_embed_regex() {
192
- jQuery(document).on('click', '#btn_default_embed_regex', function( e ) {
193
- e.preventDefault();
194
-
195
- /** get the value of the default embed regex **/
196
- let default_regex = jQuery( "#default_embed_regex").val();
197
-
198
- /** Update the textarea of the embed regex **/
199
- jQuery( '#embed_regex' ).val( default_regex );
200
-
201
- return false;
202
- } );
203
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/autoloader.php DELETED
@@ -1,54 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Class Cookiebot_Addons_Autoloader
5
- *
6
- * @since 1.1.0
7
- */
8
- class Cookiebot_Addons_Autoloader {
9
-
10
- /**
11
- * plugin root namespace
12
- *
13
- * @sice 1.1.0
14
- */
15
- const ROOT_NAMESPACE = 'cookiebot_addons\\';
16
-
17
- /**
18
- * Register autoload method
19
- *
20
- * @since 1.1.0
21
- */
22
- public function __construct() {
23
- spl_autoload_register( array( $this, 'cookiebot_autoloader_callback' ) );
24
- }
25
-
26
- /**
27
- * Includes file from the correct namespace
28
- * else it will do nothing
29
- *
30
- * @param $class
31
- *
32
- * @since 1.1.0
33
- */
34
- public function cookiebot_autoloader_callback($class) {
35
- if ( strpos( $class, self::ROOT_NAMESPACE ) === 0 ) {
36
- $path = substr( $class, strlen( self::ROOT_NAMESPACE ) );
37
- $path = strtolower( $path );
38
- $path = str_replace( '_', '-', $path );
39
- $path = str_replace( '\\', DIRECTORY_SEPARATOR, $path ) . '.php';
40
- $path = COOKIEBOT_ADDONS_DIR . DIRECTORY_SEPARATOR . $path;
41
-
42
- if ( file_exists( $path ) ) {
43
- include $path;
44
- }
45
- }
46
- }
47
- }
48
-
49
- /**
50
- * Start autoloader
51
- *
52
- * @since 1.1.0
53
- */
54
- new Cookiebot_Addons_Autoloader();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/buffer/buffer-output-interface.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\lib\buffer;
4
-
5
- Interface Buffer_Output_Interface {
6
-
7
- /**
8
- * @param $tag_name string Hook name
9
- * @param $priority integer Hook priority
10
- * @param array $keywords List of words to search for in the script
11
- * @param boolean $use_cache Use Cache
12
- *
13
- * @since 1.2.0
14
- */
15
- public function add_tag( $tag_name, $priority, $keywords = array(), $use_cache = true );
16
-
17
- /**
18
- * Process every tag
19
- *
20
- * @since 1.2.0
21
- */
22
- public function run_actions();
23
-
24
- /**
25
- * Returns true if tags has more than 0 item
26
- *
27
- * @return bool
28
- *
29
- * @since 1.2.0
30
- */
31
- public function has_action();
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/buffer/buffer-output-tag-interface.php DELETED
@@ -1,43 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\lib\buffer;
4
-
5
- Interface Buffer_Output_Tag_Interface {
6
-
7
- /**
8
- * Buffer_Output_Tag_Interface constructor.
9
- *
10
- * @param $tag
11
- * @param $priority
12
- * @param array $keywords
13
- *
14
- * @version 1.3.0
15
- * @since 1.1.0
16
- */
17
- public function __construct( $tag, $priority, $keywords = array() );
18
-
19
- /**
20
- * Start buffering
21
- *
22
- * @since 1.1.0
23
- */
24
- public function cookiebot_start_buffer();
25
-
26
- /**
27
- * End buffer and return manipulated output
28
- *
29
- * @since 1.1.0
30
- */
31
- public function cookiebot_stop_buffer();
32
-
33
- /**
34
- * Manipulate the output and add scritp attributes if it does match the criterion
35
- *
36
- * @param $buffer string Catched output
37
- *
38
- * @return mixed string Manipulated Output
39
- *
40
- * @since 1.1.0
41
- */
42
- public function manipulate_script( $buffer );
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/buffer/buffer-output-tag.php DELETED
@@ -1,147 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\lib\buffer;
4
-
5
- class Buffer_Output_Tag implements Buffer_Output_Tag_Interface {
6
-
7
- /**
8
- * Hook priority
9
- *
10
- * @var integer
11
- *
12
- * @since 1.1.0
13
- */
14
- public $priority;
15
-
16
- /**
17
- * Hook tag name
18
- *
19
- * @var string
20
- *
21
- * @since 1.2.0
22
- */
23
- public $tag;
24
-
25
- /**
26
- * Keywords to allow in the scripts
27
- *
28
- * @var array array
29
- *
30
- * @since 1.2.0
31
- */
32
- private $keywords;
33
-
34
- /**
35
- * Transient unique name
36
- *
37
- * @var string
38
- *
39
- * @since 1.1.0
40
- */
41
- private $transient_name;
42
-
43
- /**
44
- *
45
- * Use transient cache
46
- *
47
- * @var boolean
48
- *
49
- * @since 1.2.0
50
- */
51
- private $use_cache;
52
-
53
- /**
54
- * Cookiebot_Buffer_Output_Tag constructor.
55
- *
56
- * @param $tag
57
- * @param $priority
58
- * @param array $keywords
59
- * @param boolean $use_cache
60
- *
61
- * @since 1.2.0
62
- */
63
- public function __construct( $tag, $priority, $keywords = array(), $use_cache = true ) {
64
- $this->tag = $tag;
65
- $this->priority = $priority;
66
- $this->keywords = $keywords;
67
-
68
- $this->transient_name = "cookiebot_output_buffer_{$tag}_{$priority}";
69
-
70
- $this->set_use_cache( $use_cache );
71
- }
72
-
73
- /**
74
- * Merges new keywords in existence keywords variable
75
- *
76
- * @param $keywords
77
- *
78
- * @since 1.2.0
79
- */
80
- public function merge_keywords( $keywords ) {
81
- $this->keywords = array_merge( $this->keywords, $keywords );
82
- }
83
-
84
- /**
85
- * Set use cache
86
- *
87
- * @param $use_cache
88
- */
89
- public function set_use_cache( $use_cache ) {
90
- $this->use_cache = $use_cache;
91
- }
92
-
93
- /**
94
- * Start reading the buffer/output
95
- *
96
- * @since 1.1.0
97
- */
98
- public function cookiebot_start_buffer() {
99
- ob_start( array( $this, 'manipulate_script' ) );
100
- }
101
-
102
- /**
103
- * Stop reading the output and output buffered data through manipulate script filter.
104
- *
105
- * @since 1.1.0
106
- */
107
- public function cookiebot_stop_buffer() {
108
- ob_end_flush();
109
- }
110
-
111
- /**
112
- * Manipulate google analytic scripts to cookiebot and return it back
113
- *
114
- * @param $buffer
115
- *
116
- * @return null|string|string[]
117
- *
118
- * @since 1.1.0
119
- */
120
- public function manipulate_script( $buffer ) {
121
- /**
122
- * Get wp head scripts from the cache
123
- */
124
- if ( $this->use_cache ) {
125
- $updated_scripts = get_transient( $this->transient_name );
126
- }
127
-
128
- /**
129
- * If cache is not set then build it
130
- */
131
- if ( ! $this->use_cache || $updated_scripts === false ) {
132
- /**
133
- * Get all scripts and add cookieconsent if it does match with the criterion
134
- */
135
- $updated_scripts = cookiebot_addons_manipulate_script( $buffer, $this->keywords );
136
-
137
- if ( $this->use_cache ) {
138
- /**
139
- * Set cache for 15 minutes
140
- */
141
- set_transient( $this->transient_name, $updated_scripts, 60 * 15 );
142
- }
143
- }
144
-
145
- return $updated_scripts;
146
- }
147
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/buffer/buffer-output.php DELETED
@@ -1,65 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\lib\buffer;
4
-
5
- class Buffer_Output implements Buffer_Output_Interface {
6
-
7
- /**
8
- * Hook tag names
9
- *
10
- * @var array
11
- *
12
- * @since 1.2.0
13
- */
14
- private $tags = array();
15
-
16
- /**
17
- * @param $tag_name string Hook name
18
- * @param $priority integer Hook priority
19
- * @param array $keywords array List of words to search for in the script
20
- * @param boolean $use_cache Use Cache
21
- *
22
- * @since 1.2.0
23
- */
24
- public function add_tag( $tag_name, $priority, $keywords = array(), $use_cache = true ) {
25
- $tag = new Buffer_Output_Tag( $tag_name, $priority, $keywords, $use_cache );
26
- $unique_id = $tag->tag . '_' . $tag->priority;
27
-
28
- /**
29
- * If tag_name and priority exists
30
- * Then merge the keywords
31
- */
32
- if ( isset( $this->tags[ $unique_id ] ) ) {
33
- $this->tags[ $unique_id ]->merge_keywords( $keywords );
34
-
35
- if ( ! $use_cache ) {
36
- $this->tags[ $unique_id ]->set_use_cache( false );
37
- }
38
- } else {
39
- $this->tags[ $unique_id ] = $tag;
40
- }
41
- }
42
-
43
- /**
44
- * Process every tag
45
- *
46
- * @since 1.2.0
47
- */
48
- public function run_actions() {
49
- foreach ( $this->tags as $tag ) {
50
- add_action( $tag->tag, array( $tag, 'cookiebot_start_buffer' ), $tag->priority - 1 );
51
- add_action( $tag->tag, array( $tag, 'cookiebot_stop_buffer' ), $tag->priority + 1 );
52
- }
53
- }
54
-
55
- /**
56
- * Returns true if tags has more than 0 item
57
- *
58
- * @return bool
59
- *
60
- * @since 1.2.0
61
- */
62
- public function has_action() {
63
- return ( count( $this->tags ) > 0 ) ? true : false;
64
- }
65
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/cookie-consent-interface.php DELETED
@@ -1,53 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\lib;
4
-
5
- Interface Cookie_Consent_Interface {
6
-
7
- /**
8
- * Scans cookiebot consent cookie and fills in $states with accepted consents.
9
- *
10
- * @since 1.2.0
11
- */
12
- public function scan_cookie();
13
-
14
- /**
15
- * Adds state to $states variable
16
- *
17
- * @param $state string new state
18
- *
19
- * @since 1.2.0
20
- */
21
- public function add_state( $state );
22
-
23
- /**
24
- * Returns cookiebot cookie consent state
25
- *
26
- * @return array array List of accepted cookiebot consents
27
- *
28
- * @since 1.2.0
29
- */
30
- public function get_cookie_states();
31
-
32
- /**
33
- * Checks if the cookie state is accepted
34
- *
35
- * @param $state string Cookie state to check if it is accepted
36
- *
37
- * @return bool
38
- *
39
- * @since 1.2.0
40
- */
41
- public function is_cookie_state_accepted( $state );
42
-
43
- /**
44
- * Checks if the cookie states are accepted.
45
- *
46
- * @param $states array Cookie states to check if it is accepted.
47
- *
48
- * @return bool
49
- *
50
- * @since 1.3.0
51
- */
52
- public function are_cookie_states_accepted( $states );
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/cookie-consent.php DELETED
@@ -1,166 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\lib;
4
-
5
- /**
6
- * Class Cookie_Consent
7
- * @package cookiebot_addons\lib
8
- */
9
- class Cookie_Consent implements Cookie_Consent_Interface {
10
-
11
- /**
12
- * Array of cookiebot consent states
13
- *
14
- * It can have 4 items:
15
- * - necessary
16
- * - preferences
17
- * - statistics
18
- * - marketing
19
- *
20
- * @var array consent state
21
- *
22
- * @since 1.2.0
23
- */
24
- private $states = array();
25
-
26
- /**
27
- * @var array|null
28
- */
29
- private $cookie;
30
-
31
- /**
32
- * Scan cookiebot cookie
33
- *
34
- * @param $default_cookie
35
- *
36
- * @since 1.2.0
37
- * @version 2.4.1
38
- */
39
- public function __construct( $default_cookie = null ) {
40
- $this->cookie = ( isset( $_COOKIE['CookieConsent'] ) ) ? $_COOKIE['CookieConsent'] : $default_cookie;
41
-
42
- $this->scan_cookie();
43
- }
44
-
45
- /**
46
- * Scans cookiebot consent cookie and fills in $states with accepted consents.
47
- *
48
- * @since 1.2.0
49
- * @version 2.4.1
50
- */
51
- public function scan_cookie() {
52
- //default - set strictly necessary cookies
53
- $this->add_state( 'necessary' );
54
-
55
- if ( ! empty( $this->cookie ) ) {
56
- switch ( $this->cookie ) {
57
- case '0':
58
- //The user has not accepted cookies - set strictly necessary cookies only
59
- break;
60
-
61
- case '-1':
62
- //The user is not within a region that requires consent - all cookies are accepted
63
- $this->add_state( 'preferences' );
64
- $this->add_state( 'statistics' );
65
- $this->add_state( 'marketing' );
66
- break;
67
-
68
- default:
69
- //Read current user consent in encoded JavaScript format
70
- $valid_php_json = preg_replace(
71
- '/\s*:\s*([a-zA-Z0-9_]+?)([}\[,])/',
72
- ':"$1"$2',
73
- preg_replace(
74
- '/([{\[,])\s*([a-zA-Z0-9_]+?):/',
75
- '$1"$2":',
76
- str_replace( "'", '"', stripslashes( $this->cookie ) )
77
- )
78
- );
79
- $cookie_consent = json_decode( $valid_php_json );
80
-
81
- if ( isset( $cookie_consent->preferences ) && filter_var( $cookie_consent->preferences, FILTER_VALIDATE_BOOLEAN ) ) {
82
- //Current user accepts preference cookies
83
- $this->add_state( 'preferences' );
84
- } else {
85
- //Current user does NOT accept preference cookies
86
- }
87
-
88
- if ( isset( $cookie_consent->statistics ) && filter_var( $cookie_consent->statistics, FILTER_VALIDATE_BOOLEAN ) ) {
89
- //Current user accepts statistics cookies
90
- $this->add_state( 'statistics' );
91
- } else {
92
- //Current user does NOT accept statistics cookies
93
- }
94
-
95
- if ( isset( $cookie_consent->marketing ) && filter_var( $cookie_consent->marketing, FILTER_VALIDATE_BOOLEAN ) ) {
96
- //Current user accepts marketing cookies
97
- $this->add_state( 'marketing' );
98
- } else {
99
- //Current user does NOT accept marketing cookies
100
- }
101
- }
102
- } else {
103
- //The user has not accepted cookies - set strictly necessary cookies only
104
- }
105
- }
106
-
107
- /**
108
- * Adds state to $states variable
109
- *
110
- * @param $state string new state
111
- *
112
- * @since 1.2.0
113
- */
114
- public function add_state( $state ) {
115
- if ( ! in_array( $state, $this->states ) ) {
116
- $this->states[] = $state;
117
- }
118
- }
119
-
120
- /**
121
- * Returns cookiebot cookie consent state
122
- *
123
- * @return array array List of accepted cookiebot consents
124
- *
125
- * @since 1.2.0
126
- */
127
- public function get_cookie_states() {
128
- if ( count( $this->states ) == 0 ) {
129
- $this->scan_cookie();
130
- }
131
-
132
- return $this->states;
133
- }
134
-
135
- /**
136
- * Checks if the cookie states are accepted.
137
- *
138
- * @param $states array Cookie states to check if it is accepted.
139
- *
140
- * @return bool
141
- *
142
- * @since 1.3.0
143
- */
144
- public function are_cookie_states_accepted( $states ) {
145
- if ( is_array( $states ) ) {
146
- foreach ( $states as $state ) {
147
- if ( ! in_array( $state, $this->states ) ) {
148
- return false;
149
- }
150
- }
151
- }
152
-
153
- return true;
154
- }
155
-
156
- /**
157
- * Checks if the cookie state is accepted
158
- *
159
- * @param $state string Cookie state to check if it is accepted
160
- *
161
- * @return bool
162
- */
163
- public function is_cookie_state_accepted( $state ) {
164
- return in_array( $state, $this->states );
165
- }
166
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/dependency-container.php DELETED
@@ -1,53 +0,0 @@
1
- <?php
2
-
3
- namespace cookiebot_addons\lib;
4
-
5
- use Exception;
6
-
7
- /**
8
- * Class Dependency_Container
9
- * @package cookiebot_addons\lib
10
- */
11
- class Dependency_Container {
12
-
13
- /**
14
- * @var array
15
- */
16
- private $dependencies;
17
-
18
- /**
19
- * Dependency_Container constructor.
20
- *
21
- * @param array $dependencies
22
- */
23
- public function __construct( array $dependencies = array() ) {
24
- $this->dependencies = $dependencies;
25
- }
26
-
27
- /**
28
- * @param $key
29
- * @param $dependency
30
- *
31
- * @throws Exception
32
- */
33
- public function set( $key, $dependency ) {
34
- if ( isset( $this->dependencies[ $key ] ) ) {
35
- throw new Exception( 'Dependency key ' . $key . ' already exists' );
36
- }
37
- $this->dependencies[ $key ] = $dependency;
38
- }
39
-
40
- /**
41
- * @param $key
42
- *
43
- * @return mixed
44
- * @throws Exception
45
- */
46
- public function get( $key ) {
47
- if ( ! isset( $this->dependencies[ $key ] ) ) {
48
- throw new Exception( 'Dependency key ' . $key . ' does not exists' );
49
- }
50
-
51
- return $this->dependencies[ $key ];
52
- }
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/helper.php DELETED
@@ -1,474 +0,0 @@
1
- <?php
2
- /**
3
- * Check if a cache plugin is activated and in function.
4
- *
5
- * @return boolean True If attributes always should be added
6
- * False If attributes only should be added if consent no given
7
- */
8
-
9
- function cookiebot_addons_enabled_cache_plugin() {
10
- if ( defined( 'WP_ROCKET_PATH' ) ) {
11
- return true; //WP Rocket - We need to ensure we not cache tags without attributes
12
- }
13
- if ( defined( 'W3TC' ) ) {
14
- return true; //W3 Total Cache
15
- }
16
- if ( defined( 'WPCACHEHOME' ) ) {
17
- return true; //WP Super Cache
18
- }
19
- if ( defined( 'WPFC_WP_PLUGIN_DIR' ) ) {
20
- return true; //WP Fastest Cache
21
- }
22
- if ( defined( 'LSCWP_CONTENT_DIR' ) ) {
23
- return true; //Litespeed Cache
24
- }
25
-
26
- return false;
27
- }
28
-
29
-
30
- /**
31
- * Removes action with class in callback
32
- *
33
- * @param $action string action name
34
- * @param $class string class name
35
- * @param $method string method name
36
- * @param $priority integer action priority number
37
- *
38
- * @return boolean True if the action hook is deleted
39
- * False If the action hook is not deleted
40
- *
41
- * @since 1.2.0
42
- */
43
- function cookiebot_addons_remove_class_action( $action, $class, $method, $priority = 10 ) {
44
- global $wp_filter;
45
- $deleted = false;
46
-
47
- if ( isset( $wp_filter[ $action ] ) && isset( $wp_filter[ $action ][ $priority ] ) ) {
48
- $len = strlen( $method );
49
- foreach ( $wp_filter[ $action ][ $priority ] as $name => $def ) {
50
- if ( substr( $name, - $len ) == $method ) {
51
- if ( is_array( $def['function'] ) ) {
52
- if ( is_string( $def['function'][0] ) !== false ) {
53
- $def_class = $def['function'][0];
54
- } else {
55
- $def_class = get_class( $def['function'][0] );
56
- }
57
-
58
- if ( $def_class == $class ) {
59
- if ( is_object( $wp_filter[ $action ] ) && isset( $wp_filter[ $action ]->callbacks ) ) {
60
- $wp_filter[ $action ]->remove_filter( $action, $name, $priority );
61
- $deleted = true;
62
- } else {
63
- unset( $wp_filter[ $action ][ $priority ][ $name ] );
64
- $deleted = true;
65
- }
66
- }
67
- }
68
- }
69
- }
70
- }
71
-
72
- return $deleted;
73
- }
74
-
75
- /**
76
- * Custom manipulation of the script
77
- *
78
- * @param $buffer
79
- * @param $keywords
80
- * @param $cookie_type
81
- *
82
- * @return mixed|null|string|string[]
83
- *
84
- * @version 2.0.4
85
- * @since 1.2.0
86
- */
87
- function cookiebot_addons_manipulate_script( $buffer, $keywords ) {
88
- /**
89
- * normalize potential self-closing script tags
90
- */
91
-
92
- $normalized_buffer = preg_replace( '/(<script(.*?)\/>)/is', '<script$2></script>', $buffer );
93
-
94
- if ( $normalized_buffer !== null ) {
95
- $buffer = $normalized_buffer;
96
- }
97
-
98
- /**
99
- * Pattern to get all scripts
100
- *
101
- * @version 2.0.4
102
- * @since 1.2.0
103
- */
104
- $pattern = '/(<script(?:.*?)>)(.*?)(<\/script>)/is';
105
-
106
- /**
107
- * Get all scripts and add cookieconsent if it does match with the criterion
108
- */
109
- $updated_scripts = preg_replace_callback(
110
- $pattern,
111
- function ( $matches ) use ( $keywords ) {
112
-
113
- $script = $matches[0]; // the full script html
114
- $script_tag_open = $matches[1]; // only the script open tag with all attributes
115
- $script_tag_inner = $matches[2]; // only the script's innerText
116
- $script_tag_close = $matches[3]; // only the script closing tag
117
-
118
- /**
119
- * Check if the script contains the keywords, checks keywords one by one
120
- *
121
- * If one match, then the rest of the keywords will be skipped.
122
- **/
123
- foreach ( $keywords as $needle => $cookie_type ) {
124
- /**
125
- * The script contains the needle
126
- **/
127
- if ( strpos( $script, $needle ) !== false ) {
128
- /**
129
- * replace all single quotes with double quotes in the open tag
130
- * remove previously set data-cookieconsent attribute
131
- * remove type attribute
132
- */
133
- $script_tag_open = preg_replace( '/\'/', '"', $script_tag_open );
134
- $script_tag_open = preg_replace( '/\sdata-cookieconsent=\"(?:.*?)\"/', '', $script_tag_open );
135
- $script_tag_open = preg_replace( '/\stype=\"(?:.*?)\"/', '', $script_tag_open );
136
-
137
- /**
138
- * set the type attribute to text/plain to prevent javascript execution
139
- * add data-cookieconsent attribute
140
- */
141
- $cookie_types = cookiebot_addons_output_cookie_types( $cookie_type );
142
- $replacement = '<script type="text/plain" data-cookieconsent="' . $cookie_types . '"';
143
- $script_tag_open = preg_replace( '/<script/', $replacement, $script_tag_open );
144
-
145
- /**
146
- * reconstruct the script and break the foreach loop
147
- */
148
- $script = $script_tag_open . $script_tag_inner . $script_tag_close;
149
- continue;
150
- }
151
- }
152
-
153
- /**
154
- * return the reconstructed script
155
- */
156
- return $script;
157
- },
158
- $buffer
159
- );
160
-
161
- /**
162
- * Fallback when the regex fails to work due to PCRE_ERROR_JIT_STACKLIMIT
163
- *
164
- * @version 2.0.4
165
- * @since 2.0.4
166
- */
167
- if ( $updated_scripts === null ) {
168
- $updated_scripts = $buffer;
169
-
170
- if ( get_option( 'cookiebot_regex_stacklimit' ) === false ) {
171
- update_option( 'cookiebot_regex_stacklimit', 1 );
172
- }
173
- }
174
-
175
- return $updated_scripts;
176
- }
177
-
178
- /**
179
- * Compares array to string to add checked attribute in checkbox
180
- *
181
- * @param $helper
182
- * @param $current
183
- * @param bool $echo
184
- * @param string $type
185
- *
186
- * @return string
187
- *
188
- * @since 1.3.0
189
- */
190
- function cookiebot_addons_checked_selected_helper( $helper, $current, $echo = true, $type = 'checked' ) {
191
- $current_in_helper_array = is_array( $helper ) && in_array( $current, $helper, true );
192
- $current_equals_helper_string = is_string( $helper ) && is_string( $current ) && $helper === $current;
193
-
194
- if ( $current_in_helper_array || $current_equals_helper_string ) {
195
- if ( $echo ) {
196
- echo ' ' . esc_attr( $type ) . '=\'' . esc_attr( $type ) . '\'';
197
- }
198
-
199
- return " $type='$type'";
200
- }
201
-
202
- return '';
203
- }
204
-
205
- /**
206
- * Returns cookie types in a string
207
- * Default is statistics
208
- *
209
- * @param $cookie_types
210
- *
211
- * @return string
212
- *
213
- * @since 1.3.0
214
- * @version 3.9.1
215
- */
216
- function cookiebot_addons_output_cookie_types( $cookie_types ) {
217
- if ( is_array( $cookie_types ) && count( $cookie_types ) > 0 ) {
218
- return implode(
219
- ', ',
220
- array_map(
221
- function ( $value ) {
222
- return cookiebot_translate_type_name( $value );
223
- },
224
- $cookie_types
225
- )
226
- );
227
- } elseif ( is_string( $cookie_types ) && $cookie_types != '' ) {
228
- return cookiebot_translate_type_name( $cookie_types );
229
- }
230
-
231
- return cookiebot_translate_type_name( 'statistics' );
232
- }
233
-
234
- /**
235
- * Translates the cookie type to different language
236
- *
237
- * @param $type string
238
- *
239
- * @return string
240
- *
241
- * @since 3.9.1
242
- */
243
- function cookiebot_translate_type_name( $type ) {
244
- switch ( $type ) {
245
- case 'marketing':
246
- return esc_html__( 'marketing', 'cookiebot' );
247
- case 'statistics':
248
- return esc_html__( 'statistics', 'cookiebot' );
249
- case 'preferences':
250
- return esc_html__( 'preferences', 'cookiebot' );
251
- case 'necessary':
252
- return esc_html__( 'necessary', 'cookiebot' );
253
- default:
254
- return $type;
255
- }
256
- }
257
-
258
- /**
259
- * Return 1 cookie type if more than 1 is selected
260
- *
261
- * @param $cookie_types
262
- *
263
- * @return string
264
- *
265
- * @since 1.3.0
266
- */
267
- function cookiebot_addons_get_one_cookie_type( $cookie_types ) {
268
- if ( is_array( $cookie_types ) ) {
269
- if ( in_array( 'marketing', $cookie_types ) ) {
270
- return 'marketing';
271
- } elseif ( in_array( 'statistics', $cookie_types ) ) {
272
- return 'statistics';
273
- } elseif ( in_array( 'preferences', $cookie_types ) ) {
274
- return 'preferences';
275
- }
276
- }
277
-
278
- return '';
279
- }
280
-
281
- /**
282
- * @param $cookie_types
283
- *
284
- * @return string
285
- *
286
- * @version 3.9.0
287
- */
288
- function cookiebot_addons_cookieconsent_optout( $cookie_types ) {
289
- $output = '';
290
-
291
- foreach ( $cookie_types as $cookie_type ) {
292
- $output .= 'cookieconsent-optout-' . $cookie_type . ' ';
293
- }
294
-
295
- return trim( $output );
296
- }
297
-
298
- /**
299
- * Returns current site language
300
- *
301
- * @return mixed|string
302
- *
303
- * @since 1.9.0
304
- */
305
- function cookiebot_addons_get_language() {
306
- $lang = get_locale(); //Gets language in en-US format
307
-
308
- /**
309
- * Add support for 3rd party plugins
310
- */
311
- $lang = apply_filters( 'cookiebot_addons_language', $lang );
312
-
313
- return $lang;
314
- }
315
-
316
- /**
317
- * @param array $cookie_names
318
- *
319
- * @return array
320
- */
321
- function cookiebot_translate_cookie_names( $cookie_names ) {
322
- $translated_cookie_names = array(
323
- 'preferences' => esc_html__( 'preferences', 'cookiebot' ),
324
- 'statistics' => esc_html__( 'statistics', 'cookiebot' ),
325
- 'marketing' => esc_html__( 'marketing', 'cookiebot' ),
326
- );
327
-
328
- return array_map(
329
- function ( string $cookie_name ) use ( $translated_cookie_names ) {
330
- $cookie_name = trim( $cookie_name );
331
- if ( isset( $translated_cookie_names[ $cookie_name ] ) ) {
332
- return $translated_cookie_names[ $cookie_name ];
333
- }
334
-
335
- return $cookie_name;
336
- },
337
- $cookie_names
338
- );
339
- }
340
-
341
- /**
342
- * Get supported languages by the cookiebot
343
- *
344
- * @return array
345
- *
346
- * @since 1.9.0
347
- */
348
- function cookiebot_addons_get_supported_languages() {
349
- $cookiebot = cookiebot();
350
-
351
- return $cookiebot->get_supported_languages();
352
- }
353
-
354
- /**
355
- * Returns an escaped HTML "select" element
356
- * Show languages in a select field
357
- *
358
- * @param $class
359
- * @param $name
360
- * @param $selected
361
- *
362
- * @return string
363
- *
364
- * @since 1.8.0
365
- */
366
- function cookiebot_addons_get_dropdown_languages( $class, $name, $selected ) {
367
- $args = array(
368
- 'name' => $name,
369
- 'selected' => $selected,
370
- 'show_option_site_default' => true,
371
- 'echo' => false,
372
- 'languages' => get_available_languages(),
373
- );
374
- $dropdown = wp_dropdown_languages( $args );
375
- $output = str_replace( '<select ', '<select class="' . esc_attr( $class ) . '" ', $dropdown );
376
-
377
- return str_replace( ' value="" ', 'value="en_US" ', $output );
378
- }
379
-
380
- /**
381
- * Run actions when the cookiebot plugin is deactivated
382
- *
383
- * @since 2.2.0
384
- */
385
- function cookiebot_addons_plugin_deactivated() {
386
- $cookiebot_addons = \cookiebot_addons\Cookiebot_Addons::instance();
387
- $cookiebot_addons->cookiebot_deactivated();
388
- }
389
-
390
- /**
391
- * Run actions when the cookiebot plugin is deactivated
392
- *
393
- * @since 3.6.3
394
- */
395
- function cookiebot_addons_plugin_activated() {
396
- $cookiebot_addons = \cookiebot_addons\Cookiebot_Addons::instance();
397
- $cookiebot_addons->cookiebot_activated();
398
- }
399
-
400
- /**
401
- * @param string $url
402
- *
403
- * @return string
404
- *
405
- * @since 3.11.0
406
- */
407
- function cookiebot_addons_get_domain_from_url( $url ) {
408
- $parsed_url = parse_url( $url );
409
-
410
- // relative url does not have host so use home url domain
411
- $host = isset( $parsed_url['host'] ) ? $parsed_url['host'] : cookiebot_addons_get_home_url_domain();
412
-
413
- $url_parts = explode( '.', $host );
414
-
415
- $url_parts = array_slice( $url_parts, - 2 );
416
-
417
- return implode( '.', $url_parts );
418
- }
419
-
420
- /**
421
- * @return string
422
- * @throws Exception
423
- *
424
- * @since 3.11.0
425
- */
426
- function cookiebot_addons_get_home_url_domain() {
427
- $home_url = parse_url( home_url() );
428
- /** @var $host string */
429
- $host = $home_url['host'];
430
-
431
- if ( empty( $host ) ) {
432
- throw new Exception( 'Home url domain is not found.' );
433
- }
434
-
435
- return $host;
436
- }
437
-
438
- /**
439
- * @param $file_path
440
- *
441
- * @return false|string
442
- * @throws Exception
443
- */
444
- function cookiebot_get_local_file_contents( $file_path ) {
445
- if ( ! file_exists( $file_path ) ) {
446
- throw new Exception( 'File ' . $file_path . ' does not exist' );
447
- }
448
-
449
- ob_start();
450
- include $file_path;
451
-
452
- return ob_get_clean();
453
- }
454
-
455
- /**
456
- * @param $file_path
457
- *
458
- * @return array
459
- * @throws Exception
460
- */
461
- function cookiebot_get_local_file_json_contents( $file_path ) {
462
- $json = cookiebot_get_local_file_contents( $file_path );
463
-
464
- $decoded_json = json_decode( $json );
465
-
466
- if ( ! is_a( $decoded_json, stdClass::class ) ) {
467
- throw new Exception( 'Filepath ' . $file_path . ' could not be parsed as json file' );
468
- }
469
-
470
- /**
471
- * @var array $decoded_json
472
- */
473
- return $decoded_json;
474
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/autoload.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
-
3
- // autoload.php @generated by Composer
4
-
5
- require_once __DIR__ . '/composer/autoload_real.php';
6
-
7
- return ComposerAutoloaderInit8a2128fc5718e70d5efac860b1783350::getLoader();
 
 
 
 
 
 
 
addons/lib/ioc/composer/ClassLoader.php DELETED
@@ -1,445 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This file is part of Composer.
5
- *
6
- * (c) Nils Adermann <naderman@naderman.de>
7
- * Jordi Boggiano <j.boggiano@seld.be>
8
- *
9
- * For the full copyright and license information, please view the LICENSE
10
- * file that was distributed with this source code.
11
- */
12
-
13
- namespace Composer\Autoload;
14
-
15
- /**
16
- * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
17
- *
18
- * $loader = new \Composer\Autoload\ClassLoader();
19
- *
20
- * // register classes with namespaces
21
- * $loader->add('Symfony\Component', __DIR__.'/component');
22
- * $loader->add('Symfony', __DIR__.'/framework');
23
- *
24
- * // activate the autoloader
25
- * $loader->register();
26
- *
27
- * // to enable searching the include path (eg. for PEAR packages)
28
- * $loader->setUseIncludePath(true);
29
- *
30
- * In this example, if you try to use a class in the Symfony\Component
31
- * namespace or one of its children (Symfony\Component\Console for instance),
32
- * the autoloader will first look for the class under the component/
33
- * directory, and it will then fallback to the framework/ directory if not
34
- * found before giving up.
35
- *
36
- * This class is loosely based on the Symfony UniversalClassLoader.
37
- *
38
- * @author Fabien Potencier <fabien@symfony.com>
39
- * @author Jordi Boggiano <j.boggiano@seld.be>
40
- * @see http://www.php-fig.org/psr/psr-0/
41
- * @see http://www.php-fig.org/psr/psr-4/
42
- */
43
- class ClassLoader
44
- {
45
- // PSR-4
46
- private $prefixLengthsPsr4 = array();
47
- private $prefixDirsPsr4 = array();
48
- private $fallbackDirsPsr4 = array();
49
-
50
- // PSR-0
51
- private $prefixesPsr0 = array();
52
- private $fallbackDirsPsr0 = array();
53
-
54
- private $useIncludePath = false;
55
- private $classMap = array();
56
- private $classMapAuthoritative = false;
57
- private $missingClasses = array();
58
- private $apcuPrefix;
59
-
60
- public function getPrefixes()
61
- {
62
- if (!empty($this->prefixesPsr0)) {
63
- return call_user_func_array('array_merge', $this->prefixesPsr0);
64
- }
65
-
66
- return array();
67
- }
68
-
69
- public function getPrefixesPsr4()
70
- {
71
- return $this->prefixDirsPsr4;
72
- }
73
-
74
- public function getFallbackDirs()
75
- {
76
- return $this->fallbackDirsPsr0;
77
- }
78
-
79
- public function getFallbackDirsPsr4()
80
- {
81
- return $this->fallbackDirsPsr4;
82
- }
83
-
84
- public function getClassMap()
85
- {
86
- return $this->classMap;
87
- }
88
-
89
- /**
90
- * @param array $classMap Class to filename map
91
- */
92
- public function addClassMap(array $classMap)
93
- {
94
- if ($this->classMap) {
95
- $this->classMap = array_merge($this->classMap, $classMap);
96
- } else {
97
- $this->classMap = $classMap;
98
- }
99
- }
100
-
101
- /**
102
- * Registers a set of PSR-0 directories for a given prefix, either
103
- * appending or prepending to the ones previously set for this prefix.
104
- *
105
- * @param string $prefix The prefix
106
- * @param array|string $paths The PSR-0 root directories
107
- * @param bool $prepend Whether to prepend the directories
108
- */
109
- public function add($prefix, $paths, $prepend = false)
110
- {
111
- if (!$prefix) {
112
- if ($prepend) {
113
- $this->fallbackDirsPsr0 = array_merge(
114
- (array) $paths,
115
- $this->fallbackDirsPsr0
116
- );
117
- } else {
118
- $this->fallbackDirsPsr0 = array_merge(
119
- $this->fallbackDirsPsr0,
120
- (array) $paths
121
- );
122
- }
123
-
124
- return;
125
- }
126
-
127
- $first = $prefix[0];
128
- if (!isset($this->prefixesPsr0[$first][$prefix])) {
129
- $this->prefixesPsr0[$first][$prefix] = (array) $paths;
130
-
131
- return;
132
- }
133
- if ($prepend) {
134
- $this->prefixesPsr0[$first][$prefix] = array_merge(
135
- (array) $paths,
136
- $this->prefixesPsr0[$first][$prefix]
137
- );
138
- } else {
139
- $this->prefixesPsr0[$first][$prefix] = array_merge(
140
- $this->prefixesPsr0[$first][$prefix],
141
- (array) $paths
142
- );
143
- }
144
- }
145
-
146
- /**
147
- * Registers a set of PSR-4 directories for a given namespace, either
148
- * appending or prepending to the ones previously set for this namespace.
149
- *
150
- * @param string $prefix The prefix/namespace, with trailing '\\'
151
- * @param array|string $paths The PSR-4 base directories
152
- * @param bool $prepend Whether to prepend the directories
153
- *
154
- * @throws \InvalidArgumentException
155
- */
156
- public function addPsr4($prefix, $paths, $prepend = false)
157
- {
158
- if (!$prefix) {
159
- // Register directories for the root namespace.
160
- if ($prepend) {
161
- $this->fallbackDirsPsr4 = array_merge(
162
- (array) $paths,
163
- $this->fallbackDirsPsr4
164
- );
165
- } else {
166
- $this->fallbackDirsPsr4 = array_merge(
167
- $this->fallbackDirsPsr4,
168
- (array) $paths
169
- );
170
- }
171
- } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
172
- // Register directories for a new namespace.
173
- $length = strlen($prefix);
174
- if ('\\' !== $prefix[$length - 1]) {
175
- throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
176
- }
177
- $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
178
- $this->prefixDirsPsr4[$prefix] = (array) $paths;
179
- } elseif ($prepend) {
180
- // Prepend directories for an already registered namespace.
181
- $this->prefixDirsPsr4[$prefix] = array_merge(
182
- (array) $paths,
183
- $this->prefixDirsPsr4[$prefix]
184
- );
185
- } else {
186
- // Append directories for an already registered namespace.
187
- $this->prefixDirsPsr4[$prefix] = array_merge(
188
- $this->prefixDirsPsr4[$prefix],
189
- (array) $paths
190
- );
191
- }
192
- }
193
-
194
- /**
195
- * Registers a set of PSR-0 directories for a given prefix,
196
- * replacing any others previously set for this prefix.
197
- *
198
- * @param string $prefix The prefix
199
- * @param array|string $paths The PSR-0 base directories
200
- */
201
- public function set($prefix, $paths)
202
- {
203
- if (!$prefix) {
204
- $this->fallbackDirsPsr0 = (array) $paths;
205
- } else {
206
- $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
207
- }
208
- }
209
-
210
- /**
211
- * Registers a set of PSR-4 directories for a given namespace,
212
- * replacing any others previously set for this namespace.
213
- *
214
- * @param string $prefix The prefix/namespace, with trailing '\\'
215
- * @param array|string $paths The PSR-4 base directories
216
- *
217
- * @throws \InvalidArgumentException
218
- */
219
- public function setPsr4($prefix, $paths)
220
- {
221
- if (!$prefix) {
222
- $this->fallbackDirsPsr4 = (array) $paths;
223
- } else {
224
- $length = strlen($prefix);
225
- if ('\\' !== $prefix[$length - 1]) {
226
- throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
227
- }
228
- $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
229
- $this->prefixDirsPsr4[$prefix] = (array) $paths;
230
- }
231
- }
232
-
233
- /**
234
- * Turns on searching the include path for class files.
235
- *
236
- * @param bool $useIncludePath
237
- */
238
- public function setUseIncludePath($useIncludePath)
239
- {
240
- $this->useIncludePath = $useIncludePath;
241
- }
242
-
243
- /**
244
- * Can be used to check if the autoloader uses the include path to check
245
- * for classes.
246
- *
247
- * @return bool
248
- */
249
- public function getUseIncludePath()
250
- {
251
- return $this->useIncludePath;
252
- }
253
-
254
- /**
255
- * Turns off searching the prefix and fallback directories for classes
256
- * that have not been registered with the class map.
257
- *
258
- * @param bool $classMapAuthoritative
259
- */
260
- public function setClassMapAuthoritative($classMapAuthoritative)
261
- {
262
- $this->classMapAuthoritative = $classMapAuthoritative;
263
- }
264
-
265
- /**
266
- * Should class lookup fail if not found in the current class map?
267
- *
268
- * @return bool
269
- */
270
- public function isClassMapAuthoritative()
271
- {
272
- return $this->classMapAuthoritative;
273
- }
274
-
275
- /**
276
- * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
277
- *
278
- * @param string|null $apcuPrefix
279
- */
280
- public function setApcuPrefix($apcuPrefix)
281
- {
282
- $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
283
- }
284
-
285
- /**
286
- * The APCu prefix in use, or null if APCu caching is not enabled.
287
- *
288
- * @return string|null
289
- */
290
- public function getApcuPrefix()
291
- {
292
- return $this->apcuPrefix;
293
- }
294
-
295
- /**
296
- * Registers this instance as an autoloader.
297
- *
298
- * @param bool $prepend Whether to prepend the autoloader or not
299
- */
300
- public function register($prepend = false)
301
- {
302
- spl_autoload_register(array($this, 'loadClass'), true, $prepend);
303
- }
304
-
305
- /**
306
- * Unregisters this instance as an autoloader.
307
- */
308
- public function unregister()
309
- {
310
- spl_autoload_unregister(array($this, 'loadClass'));
311
- }
312
-
313
- /**
314
- * Loads the given class or interface.
315
- *
316
- * @param string $class The name of the class
317
- * @return bool|null True if loaded, null otherwise
318
- */
319
- public function loadClass($class)
320
- {
321
- if ($file = $this->findFile($class)) {
322
- includeFile($file);
323
-
324
- return true;
325
- }
326
- }
327
-
328
- /**
329
- * Finds the path to the file where the class is defined.
330
- *
331
- * @param string $class The name of the class
332
- *
333
- * @return string|false The path if found, false otherwise
334
- */
335
- public function findFile($class)
336
- {
337
- // class map lookup
338
- if (isset($this->classMap[$class])) {
339
- return $this->classMap[$class];
340
- }
341
- if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
342
- return false;
343
- }
344
- if (null !== $this->apcuPrefix) {
345
- $file = apcu_fetch($this->apcuPrefix.$class, $hit);
346
- if ($hit) {
347
- return $file;
348
- }
349
- }
350
-
351
- $file = $this->findFileWithExtension($class, '.php');
352
-
353
- // Search for Hack files if we are running on HHVM
354
- if (false === $file && defined('HHVM_VERSION')) {
355
- $file = $this->findFileWithExtension($class, '.hh');
356
- }
357
-
358
- if (null !== $this->apcuPrefix) {
359
- apcu_add($this->apcuPrefix.$class, $file);
360
- }
361
-
362
- if (false === $file) {
363
- // Remember that this class does not exist.
364
- $this->missingClasses[$class] = true;
365
- }
366
-
367
- return $file;
368
- }
369
-
370
- private function findFileWithExtension($class, $ext)
371
- {
372
- // PSR-4 lookup
373
- $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
374
-
375
- $first = $class[0];
376
- if (isset($this->prefixLengthsPsr4[$first])) {
377
- $subPath = $class;
378
- while (false !== $lastPos = strrpos($subPath, '\\')) {
379
- $subPath = substr($subPath, 0, $lastPos);
380
- $search = $subPath . '\\';
381
- if (isset($this->prefixDirsPsr4[$search])) {
382
- $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
383
- foreach ($this->prefixDirsPsr4[$search] as $dir) {
384
- if (file_exists($file = $dir . $pathEnd)) {
385
- return $file;
386
- }
387
- }
388
- }
389
- }
390
- }
391
-
392
- // PSR-4 fallback dirs
393
- foreach ($this->fallbackDirsPsr4 as $dir) {
394
- if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
395
- return $file;
396
- }
397
- }
398
-
399
- // PSR-0 lookup
400
- if (false !== $pos = strrpos($class, '\\')) {
401
- // namespaced class name
402
- $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
403
- . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
404
- } else {
405
- // PEAR-like class name
406
- $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
407
- }
408
-
409
- if (isset($this->prefixesPsr0[$first])) {
410
- foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
411
- if (0 === strpos($class, $prefix)) {
412
- foreach ($dirs as $dir) {
413
- if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
414
- return $file;
415
- }
416
- }
417
- }
418
- }
419
- }
420
-
421
- // PSR-0 fallback dirs
422
- foreach ($this->fallbackDirsPsr0 as $dir) {
423
- if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
424
- return $file;
425
- }
426
- }
427
-
428
- // PSR-0 include paths.
429
- if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
430
- return $file;
431
- }
432
-
433
- return false;
434
- }
435
- }
436
-
437
- /**
438
- * Scope isolated include.
439
- *
440
- * Prevents access to $this/self from included files.
441
- */
442
- function includeFile($file)
443
- {
444
- include $file;
445
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/composer/LICENSE DELETED
@@ -1,21 +0,0 @@
1
-
2
- Copyright (c) Nils Adermann, Jordi Boggiano
3
-
4
- Permission is hereby granted, free of charge, to any person obtaining a copy
5
- of this software and associated documentation files (the "Software"), to deal
6
- in the Software without restriction, including without limitation the rights
7
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- copies of the Software, and to permit persons to whom the Software is furnished
9
- to do so, subject to the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be included in all
12
- copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- THE SOFTWARE.
21
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/composer/autoload_classmap.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- // autoload_classmap.php @generated by Composer
4
-
5
- $vendorDir = dirname(dirname(__FILE__));
6
- $baseDir = dirname($vendorDir);
7
-
8
- return array(
9
- );
 
 
 
 
 
 
 
 
 
addons/lib/ioc/composer/autoload_files.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
-
3
- // autoload_files.php @generated by Composer
4
-
5
- $vendorDir = dirname(dirname(__FILE__));
6
- $baseDir = dirname($vendorDir);
7
-
8
- return array(
9
- 'bbf73f3db644d3dced353b837903e74c' => $vendorDir . '/php-di/php-di/src/DI/functions.php',
10
- );
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/composer/autoload_namespaces.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- // autoload_namespaces.php @generated by Composer
4
-
5
- $vendorDir = dirname(dirname(__FILE__));
6
- $baseDir = dirname($vendorDir);
7
-
8
- return array(
9
- );
 
 
 
 
 
 
 
 
 
addons/lib/ioc/composer/autoload_psr4.php DELETED
@@ -1,14 +0,0 @@
1
- <?php
2
-
3
- // autoload_psr4.php @generated by Composer
4
-
5
- $vendorDir = dirname(dirname(__FILE__));
6
- $baseDir = dirname($vendorDir);
7
-
8
- return array(
9
- 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'),
10
- 'PhpDocReader\\' => array($vendorDir . '/php-di/phpdoc-reader/src/PhpDocReader'),
11
- 'Invoker\\' => array($vendorDir . '/php-di/invoker/src'),
12
- 'Interop\\Container\\' => array($vendorDir . '/container-interop/container-interop/src/Interop/Container'),
13
- 'DI\\' => array($vendorDir . '/php-di/php-di/src/DI'),
14
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/composer/autoload_real.php DELETED
@@ -1,70 +0,0 @@
1
- <?php
2
-
3
- // autoload_real.php @generated by Composer
4
-
5
- class ComposerAutoloaderInit8a2128fc5718e70d5efac860b1783350
6
- {
7
- private static $loader;
8
-
9
- public static function loadClassLoader($class)
10
- {
11
- if ('Composer\Autoload\ClassLoader' === $class) {
12
- require __DIR__ . '/ClassLoader.php';
13
- }
14
- }
15
-
16
- public static function getLoader()
17
- {
18
- if (null !== self::$loader) {
19
- return self::$loader;
20
- }
21
-
22
- spl_autoload_register(array('ComposerAutoloaderInit8a2128fc5718e70d5efac860b1783350', 'loadClassLoader'), true, false);
23
- self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit8a2128fc5718e70d5efac860b1783350', 'loadClassLoader'));
25
-
26
- $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
- if ($useStaticLoader) {
28
- require_once __DIR__ . '/autoload_static.php';
29
-
30
- call_user_func(\Composer\Autoload\ComposerStaticInit8a2128fc5718e70d5efac860b1783350::getInitializer($loader));
31
- } else {
32
- $map = require __DIR__ . '/autoload_namespaces.php';
33
- foreach ($map as $namespace => $path) {
34
- $loader->set($namespace, $path);
35
- }
36
-
37
- $map = require __DIR__ . '/autoload_psr4.php';
38
- foreach ($map as $namespace => $path) {
39
- $loader->setPsr4($namespace, $path);
40
- }
41
-
42
- $classMap = require __DIR__ . '/autoload_classmap.php';
43
- if ($classMap) {
44
- $loader->addClassMap($classMap);
45
- }
46
- }
47
-
48
- $loader->register(false);
49
-
50
- if ($useStaticLoader) {
51
- $includeFiles = Composer\Autoload\ComposerStaticInit8a2128fc5718e70d5efac860b1783350::$files;
52
- } else {
53
- $includeFiles = require __DIR__ . '/autoload_files.php';
54
- }
55
- foreach ($includeFiles as $fileIdentifier => $file) {
56
- composerRequire8a2128fc5718e70d5efac860b1783350($fileIdentifier, $file);
57
- }
58
-
59
- return $loader;
60
- }
61
- }
62
-
63
- function composerRequire8a2128fc5718e70d5efac860b1783350($fileIdentifier, $file)
64
- {
65
- if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
- require $file;
67
-
68
- $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
69
- }
70
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/composer/autoload_static.php DELETED
@@ -1,61 +0,0 @@
1
- <?php
2
-
3
- // autoload_static.php @generated by Composer
4
-
5
- namespace Composer\Autoload;
6
-
7
- class ComposerStaticInit8a2128fc5718e70d5efac860b1783350
8
- {
9
- public static $files = array (
10
- 'bbf73f3db644d3dced353b837903e74c' => __DIR__ . '/..' . '/php-di/php-di/src/DI/functions.php',
11
- );
12
-
13
- public static $prefixLengthsPsr4 = array (
14
- 'P' =>
15
- array (
16
- 'Psr\\Container\\' => 14,
17
- 'PhpDocReader\\' => 13,
18
- ),
19
- 'I' =>
20
- array (
21
- 'Invoker\\' => 8,
22
- 'Interop\\Container\\' => 18,
23
- ),
24
- 'D' =>
25
- array (
26
- 'DI\\' => 3,
27
- ),
28
- );
29
-
30
- public static $prefixDirsPsr4 = array (
31
- 'Psr\\Container\\' =>
32
- array (
33
- 0 => __DIR__ . '/..' . '/psr/container/src',
34
- ),
35
- 'PhpDocReader\\' =>
36
- array (
37
- 0 => __DIR__ . '/..' . '/php-di/phpdoc-reader/src/PhpDocReader',
38
- ),
39
- 'Invoker\\' =>
40
- array (
41
- 0 => __DIR__ . '/..' . '/php-di/invoker/src',
42
- ),
43
- 'Interop\\Container\\' =>
44
- array (
45
- 0 => __DIR__ . '/..' . '/container-interop/container-interop/src/Interop/Container',
46
- ),
47
- 'DI\\' =>
48
- array (
49
- 0 => __DIR__ . '/..' . '/php-di/php-di/src/DI',
50
- ),
51
- );
52
-
53
- public static function getInitializer(ClassLoader $loader)
54
- {
55
- return \Closure::bind(function () use ($loader) {
56
- $loader->prefixLengthsPsr4 = ComposerStaticInit8a2128fc5718e70d5efac860b1783350::$prefixLengthsPsr4;
57
- $loader->prefixDirsPsr4 = ComposerStaticInit8a2128fc5718e70d5efac860b1783350::$prefixDirsPsr4;
58
-
59
- }, null, ClassLoader::class);
60
- }
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/composer/installed.json DELETED
@@ -1,226 +0,0 @@
1
- [
2
- {
3
- "name": "container-interop/container-interop",
4
- "version": "1.2.0",
5
- "version_normalized": "1.2.0.0",
6
- "source": {
7
- "type": "git",
8
- "url": "https://github.com/container-interop/container-interop.git",
9
- "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8"
10
- },
11
- "dist": {
12
- "type": "zip",
13
- "url": "https://api.github.com/repos/container-interop/container-interop/zipball/79cbf1341c22ec75643d841642dd5d6acd83bdb8",
14
- "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8",
15
- "shasum": ""
16
- },
17
- "require": {
18
- "psr/container": "^1.0"
19
- },
20
- "time": "2017-02-14T19:40:03+00:00",
21
- "type": "library",
22
- "installation-source": "dist",
23
- "autoload": {
24
- "psr-4": {
25
- "Interop\\Container\\": "src/Interop/Container/"
26
- }
27
- },
28
- "notification-url": "https://packagist.org/downloads/",
29
- "license": [
30
- "MIT"
31
- ],
32
- "description": "Promoting the interoperability of container objects (DIC, SL, etc.)",
33
- "homepage": "https://github.com/container-interop/container-interop"
34
- },
35
- {
36
- "name": "php-di/invoker",
37
- "version": "1.3.3",
38
- "version_normalized": "1.3.3.0",
39
- "source": {
40
- "type": "git",
41
- "url": "https://github.com/PHP-DI/Invoker.git",
42
- "reference": "1f4ca63b9abc66109e53b255e465d0ddb5c2e3f7"
43
- },
44
- "dist": {
45
- "type": "zip",
46
- "url": "https://api.github.com/repos/PHP-DI/Invoker/zipball/1f4ca63b9abc66109e53b255e465d0ddb5c2e3f7",
47
- "reference": "1f4ca63b9abc66109e53b255e465d0ddb5c2e3f7",
48
- "shasum": ""
49
- },
50
- "require": {
51
- "container-interop/container-interop": "~1.1"
52
- },
53
- "require-dev": {
54
- "athletic/athletic": "~0.1.8",
55
- "phpunit/phpunit": "~4.5"
56
- },
57
- "time": "2016-07-14T13:09:58+00:00",
58
- "type": "library",
59
- "installation-source": "dist",
60
- "autoload": {
61
- "psr-4": {
62
- "Invoker\\": "src/"
63
- }
64
- },
65
- "notification-url": "https://packagist.org/downloads/",
66
- "license": [
67
- "MIT"
68
- ],
69
- "description": "Generic and extensible callable invoker",
70
- "homepage": "https://github.com/PHP-DI/Invoker",
71
- "keywords": [
72
- "callable",
73
- "dependency",
74
- "dependency-injection",
75
- "injection",
76
- "invoke",
77
- "invoker"
78
- ]
79
- },
80
- {
81
- "name": "php-di/php-di",
82
- "version": "5.0.0",
83
- "version_normalized": "5.0.0.0",
84
- "source": {
85
- "type": "git",
86
- "url": "https://github.com/PHP-DI/PHP-DI.git",
87
- "reference": "c3bbc0d334b888ec8baa75f95b4900ee17b18fa7"
88
- },
89
- "dist": {
90
- "type": "zip",
91
- "url": "https://api.github.com/repos/PHP-DI/PHP-DI/zipball/c3bbc0d334b888ec8baa75f95b4900ee17b18fa7",
92
- "reference": "c3bbc0d334b888ec8baa75f95b4900ee17b18fa7",
93
- "shasum": ""
94
- },
95
- "require": {
96
- "container-interop/container-interop": "~1.0",
97
- "php": ">=5.4.0",
98
- "php-di/invoker": "~1.0",
99
- "php-di/phpdoc-reader": "~2.0"
100
- },
101
- "require-dev": {
102
- "doctrine/annotations": "~1.2",
103
- "doctrine/cache": "~1.0",
104
- "mnapoli/phpunit-easymock": "~0.1.4",
105
- "ocramius/proxy-manager": "~1.0",
106
- "phpunit/phpunit": "~4.5"
107
- },
108
- "suggest": {
109
- "doctrine/annotations": "Install it if you want to use annotations (version ~1.2)",
110
- "doctrine/cache": "Install it if you want to use the cache (version ~1.0)",
111
- "ocramius/proxy-manager": "Install it if you want to use lazy injection (version ~1.0)"
112
- },
113
- "time": "2015-06-10T06:16:52+00:00",
114
- "type": "library",
115
- "installation-source": "dist",
116
- "autoload": {
117
- "psr-4": {
118
- "DI\\": "src/DI/"
119
- },
120
- "files": [
121
- "src/DI/functions.php"
122
- ]
123
- },
124
- "notification-url": "https://packagist.org/downloads/",
125
- "license": [
126
- "MIT"
127
- ],
128
- "description": "The dependency injection container for humans",
129
- "homepage": "http://php-di.org/",
130
- "keywords": [
131
- "container",
132
- "dependency injection",
133
- "di"
134
- ]
135
- },
136
- {
137
- "name": "php-di/phpdoc-reader",
138
- "version": "2.1.1",
139
- "version_normalized": "2.1.1.0",
140
- "source": {
141
- "type": "git",
142
- "url": "https://github.com/PHP-DI/PhpDocReader.git",
143
- "reference": "15678f7451c020226807f520efb867ad26fbbfcf"
144
- },
145
- "dist": {
146
- "type": "zip",
147
- "url": "https://api.github.com/repos/PHP-DI/PhpDocReader/zipball/15678f7451c020226807f520efb867ad26fbbfcf",
148
- "reference": "15678f7451c020226807f520efb867ad26fbbfcf",
149
- "shasum": ""
150
- },
151
- "require": {
152
- "php": ">=5.4.0"
153
- },
154
- "require-dev": {
155
- "phpunit/phpunit": "~4.6"
156
- },
157
- "time": "2019-09-26T11:24:58+00:00",
158
- "type": "library",
159
- "installation-source": "dist",
160
- "autoload": {
161
- "psr-4": {
162
- "PhpDocReader\\": "src/PhpDocReader"
163
- }
164
- },
165
- "notification-url": "https://packagist.org/downloads/",
166
- "license": [
167
- "MIT"
168
- ],
169
- "description": "PhpDocReader parses @var and @param values in PHP docblocks (supports namespaced class names with the same resolution rules as PHP)",
170
- "keywords": [
171
- "phpdoc",
172
- "reflection"
173
- ]
174
- },
175
- {
176
- "name": "psr/container",
177
- "version": "1.0.0",
178
- "version_normalized": "1.0.0.0",
179
- "source": {
180
- "type": "git",
181
- "url": "https://github.com/php-fig/container.git",
182
- "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f"
183
- },
184
- "dist": {
185
- "type": "zip",
186
- "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
187
- "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
188
- "shasum": ""
189
- },
190
- "require": {
191
- "php": ">=5.3.0"
192
- },
193
- "time": "2017-02-14T16:28:37+00:00",
194
- "type": "library",
195
- "extra": {
196
- "branch-alias": {
197
- "dev-master": "1.0.x-dev"
198
- }
199
- },
200
- "installation-source": "dist",
201
- "autoload": {
202
- "psr-4": {
203
- "Psr\\Container\\": "src/"
204
- }
205
- },
206
- "notification-url": "https://packagist.org/downloads/",
207
- "license": [
208
- "MIT"
209
- ],
210
- "authors": [
211
- {
212
- "name": "PHP-FIG",
213
- "homepage": "http://www.php-fig.org/"
214
- }
215
- ],
216
- "description": "Common Container Interface (PHP FIG PSR-11)",
217
- "homepage": "https://github.com/php-fig/container",
218
- "keywords": [
219
- "PSR-11",
220
- "container",
221
- "container-interface",
222
- "container-interop",
223
- "psr"
224
- ]
225
- }
226
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/container-interop/container-interop/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- composer.lock
2
- composer.phar
3
- /vendor/
 
 
 
addons/lib/ioc/container-interop/container-interop/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2013 container-interop
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/container-interop/container-interop/README.md DELETED
@@ -1,148 +0,0 @@
1
- # Container Interoperability
2
-
3
- [![Latest Stable Version](https://poser.pugx.org/container-interop/container-interop/v/stable.png)](https://packagist.org/packages/container-interop/container-interop)
4
- [![Total Downloads](https://poser.pugx.org/container-interop/container-interop/downloads.svg)](https://packagist.org/packages/container-interop/container-interop)
5
-
6
- ## Deprecation warning!
7
-
8
- Starting Feb. 13th 2017, container-interop is officially deprecated in favor of [PSR-11](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-11-container.md).
9
- Container-interop has been the test-bed of PSR-11. From v1.2, container-interop directly extends PSR-11 interfaces.
10
- Therefore, all containers implementing container-interop are now *de-facto* compatible with PSR-11.
11
-
12
- - Projects implementing container-interop interfaces are encouraged to directly implement PSR-11 interfaces instead.
13
- - Projects consuming container-interop interfaces are very strongly encouraged to directly type-hint on PSR-11 interfaces, in order to be compatible with PSR-11 containers that are not compatible with container-interop.
14
-
15
- Regarding the delegate lookup feature, that is present in container-interop and not in PSR-11, the feature is actually a design pattern. It is therefore not deprecated. Documentation regarding this design pattern will be migrated from this repository into a separate website in the future.
16
-
17
- ## About
18
-
19
- *container-interop* tries to identify and standardize features in *container* objects (service locators,
20
- dependency injection containers, etc.) to achieve interoperability.
21
-
22
- Through discussions and trials, we try to create a standard, made of common interfaces but also recommendations.
23
-
24
- If PHP projects that provide container implementations begin to adopt these common standards, then PHP
25
- applications and projects that use containers can depend on the common interfaces instead of specific
26
- implementations. This facilitates a high-level of interoperability and flexibility that allows users to consume
27
- *any* container implementation that can be adapted to these interfaces.
28
-
29
- The work done in this project is not officially endorsed by the [PHP-FIG](http://www.php-fig.org/), but it is being
30
- worked on by members of PHP-FIG and other good developers. We adhere to the spirit and ideals of PHP-FIG, and hope
31
- this project will pave the way for one or more future PSRs.
32
-
33
-
34
- ## Installation
35
-
36
- You can install this package through Composer:
37
-
38
- ```json
39
- composer require container-interop/container-interop
40
- ```
41
-
42
- The packages adheres to the [SemVer](http://semver.org/) specification, and there will be full backward compatibility
43
- between minor versions.
44
-
45
- ## Standards
46
-
47
- ### Available
48
-
49
- - [`ContainerInterface`](src/Interop/Container/ContainerInterface.php).
50
- [Description](docs/ContainerInterface.md) [Meta Document](docs/ContainerInterface-meta.md).
51
- Describes the interface of a container that exposes methods to read its entries.
52
- - [*Delegate lookup feature*](docs/Delegate-lookup.md).
53
- [Meta Document](docs/Delegate-lookup-meta.md).
54
- Describes the ability for a container to delegate the lookup of its dependencies to a third-party container. This
55
- feature lets several containers work together in a single application.
56
-
57
- ### Proposed
58
-
59
- View open [request for comments](https://github.com/container-interop/container-interop/labels/RFC)
60
-
61
- ## Compatible projects
62
-
63
- ### Projects implementing `ContainerInterface`
64
-
65
- - [Acclimate](https://github.com/jeremeamia/acclimate-container): Adapters for
66
- Aura.Di, Laravel, Nette DI, Pimple, Symfony DI, ZF2 Service manager, ZF2
67
- Dependency injection and any container using `ArrayAccess`
68
- - [Aura.Di](https://github.com/auraphp/Aura.Di)
69
- - [auryn-container-interop](https://github.com/elazar/auryn-container-interop)
70
- - [Burlap](https://github.com/codeeverything/burlap)
71
- - [Chernozem](https://github.com/pyrsmk/Chernozem)
72
- - [Data Manager](https://github.com/chrismichaels84/data-manager)
73
- - [Disco](https://github.com/bitexpert/disco)
74
- - [InDI](https://github.com/idealogica/indi)
75
- - [League/Container](http://container.thephpleague.com/)
76
- - [Mouf](http://mouf-php.com)
77
- - [Njasm Container](https://github.com/njasm/container)
78
- - [PHP-DI](http://php-di.org)
79
- - [Picotainer](https://github.com/thecodingmachine/picotainer)
80
- - [PimpleInterop](https://github.com/moufmouf/pimple-interop)
81
- - [Pimple3-ContainerInterop](https://github.com/Sam-Burns/pimple3-containerinterop) (using Pimple v3)
82
- - [SitePoint Container](https://github.com/sitepoint/Container)
83
- - [Thruster Container](https://github.com/ThrusterIO/container) (PHP7 only)
84
- - [Ultra-Lite Container](https://github.com/ultra-lite/container)
85
- - [Unbox](https://github.com/mindplay-dk/unbox)
86
- - [XStatic](https://github.com/jeremeamia/xstatic)
87
- - [Zend\ServiceManager](https://github.com/zendframework/zend-servicemanager)
88
- - [Zit](https://github.com/inxilpro/Zit)
89
-
90
- ### Projects implementing the *delegate lookup* feature
91
-
92
- - [Aura.Di](https://github.com/auraphp/Aura.Di)
93
- - [Burlap](https://github.com/codeeverything/burlap)
94
- - [Chernozem](https://github.com/pyrsmk/Chernozem)
95
- - [InDI](https://github.com/idealogica/indi)
96
- - [League/Container](http://container.thephpleague.com/)
97
- - [Mouf](http://mouf-php.com)
98
- - [Picotainer](https://github.com/thecodingmachine/picotainer)
99
- - [PHP-DI](http://php-di.org)
100
- - [PimpleInterop](https://github.com/moufmouf/pimple-interop)
101
- - [Ultra-Lite Container](https://github.com/ultra-lite/container)
102
-
103
- ### Middlewares implementing `ContainerInterface`
104
-
105
- - [Alias-Container](https://github.com/thecodingmachine/alias-container): add
106
- aliases support to any container
107
- - [Prefixer-Container](https://github.com/thecodingmachine/prefixer-container):
108
- dynamically prefix identifiers
109
- - [Lazy-Container](https://github.com/snapshotpl/lazy-container): lazy services
110
-
111
- ### Projects using `ContainerInterface`
112
-
113
- The list below contains only a sample of all the projects consuming `ContainerInterface`. For a more complete list have a look [here](http://packanalyst.com/class?q=Interop%5CContainer%5CContainerInterface).
114
-
115
- | | Downloads |
116
- | --- | --- |
117
- | [Adroit](https://github.com/bitexpert/adroit) | ![](https://img.shields.io/packagist/dt/bitexpert/adroit.svg) |
118
- | [Behat](https://github.com/Behat/Behat/pull/974) | ![](https://img.shields.io/packagist/dt/behat/behat.svg) |
119
- | [blast-facades](https://github.com/phpthinktank/blast-facades): Minimize complexity and represent dependencies as facades. | ![](https://img.shields.io/packagist/dt/blast/facades.svg) |
120
- | [interop.silex.di](https://github.com/thecodingmachine/interop.silex.di): an extension to [Silex](http://silex.sensiolabs.org/) that adds support for any *container-interop* compatible container | ![](https://img.shields.io/packagist/dt/mouf/interop.silex.di.svg) |
121
- | [mindplay/walkway](https://github.com/mindplay-dk/walkway): a modular request router | ![](https://img.shields.io/packagist/dt/mindplay/walkway.svg) |
122
- | [mindplay/middleman](https://github.com/mindplay-dk/middleman): minimalist PSR-7 middleware dispatcher | ![](https://img.shields.io/packagist/dt/mindplay/middleman.svg) |
123
- | [PHP-DI/Invoker](https://github.com/PHP-DI/Invoker): extensible and configurable invoker/dispatcher | ![](https://img.shields.io/packagist/dt/php-di/invoker.svg) |
124
- | [Prophiler](https://github.com/fabfuel/prophiler) | ![](https://img.shields.io/packagist/dt/fabfuel/prophiler.svg) |
125
- | [Silly](https://github.com/mnapoli/silly): CLI micro-framework | ![](https://img.shields.io/packagist/dt/mnapoli/silly.svg) |
126
- | [Slim v3](https://github.com/slimphp/Slim) | ![](https://img.shields.io/packagist/dt/slim/slim.svg) |
127
- | [Splash](http://mouf-php.com/packages/mouf/mvc.splash-common/version/8.0-dev/README.md) | ![](https://img.shields.io/packagist/dt/mouf/mvc.splash-common.svg) |
128
- | [Woohoo Labs. Harmony](https://github.com/woohoolabs/harmony): a flexible micro-framework | ![](https://img.shields.io/packagist/dt/woohoolabs/harmony.svg) |
129
- | [zend-expressive](https://github.com/zendframework/zend-expressive) | ![](https://img.shields.io/packagist/dt/zendframework/zend-expressive.svg) |
130
-
131
-
132
- ## Workflow
133
-
134
- Everyone is welcome to join and contribute.
135
-
136
- The general workflow looks like this:
137
-
138
- 1. Someone opens a discussion (GitHub issue) to suggest an interface
139
- 1. Feedback is gathered
140
- 1. The interface is added to a development branch
141
- 1. We release alpha versions so that the interface can be experimented with
142
- 1. Discussions and edits ensue until the interface is deemed stable by a general consensus
143
- 1. A new minor version of the package is released
144
-
145
- We try to not break BC by creating new interfaces instead of editing existing ones.
146
-
147
- While we currently work on interfaces, we are open to anything that might help towards interoperability, may that
148
- be code, best practices, etc.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/container-interop/container-interop/composer.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "name": "container-interop/container-interop",
3
- "type": "library",
4
- "description": "Promoting the interoperability of container objects (DIC, SL, etc.)",
5
- "homepage": "https://github.com/container-interop/container-interop",
6
- "license": "MIT",
7
- "autoload": {
8
- "psr-4": {
9
- "Interop\\Container\\": "src/Interop/Container/"
10
- }
11
- },
12
- "require": {
13
- "psr/container": "^1.0"
14
- }
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/container-interop/container-interop/docs/ContainerInterface-meta.md DELETED
@@ -1,114 +0,0 @@
1
- # ContainerInterface Meta Document
2
-
3
- ## Introduction
4
-
5
- This document describes the process and discussions that lead to the `ContainerInterface`.
6
- Its goal is to explain the reasons behind each decision.
7
-
8
- ## Goal
9
-
10
- The goal set by `ContainerInterface` is to standardize how frameworks and libraries make use of a
11
- container to obtain objects and parameters.
12
-
13
- By standardizing such a behavior, frameworks and libraries using the `ContainerInterface`
14
- could work with any compatible container.
15
- That would allow end users to choose their own container based on their own preferences.
16
-
17
- It is important to distinguish the two usages of a container:
18
-
19
- - configuring entries
20
- - fetching entries
21
-
22
- Most of the time, those two sides are not used by the same party.
23
- While it is often end users who tend to configure entries, it is generally the framework that fetch
24
- entries to build the application.
25
-
26
- This is why this interface focuses only on how entries can be fetched from a container.
27
-
28
- ## Interface name
29
-
30
- The interface name has been thoroughly discussed and was decided by a vote.
31
-
32
- The list of options considered with their respective votes are:
33
-
34
- - `ContainerInterface`: +8
35
- - `ProviderInterface`: +2
36
- - `LocatorInterface`: 0
37
- - `ReadableContainerInterface`: -5
38
- - `ServiceLocatorInterface`: -6
39
- - `ObjectFactory`: -6
40
- - `ObjectStore`: -8
41
- - `ConsumerInterface`: -9
42
-
43
- [Full results of the vote](https://github.com/container-interop/container-interop/wiki/%231-interface-name:-Vote)
44
-
45
- The complete discussion can be read in [the issue #1](https://github.com/container-interop/container-interop/issues/1).
46
-
47
- ## Interface methods
48
-
49
- The choice of which methods the interface would contain was made after a statistical analysis of existing containers.
50
- The results of this analysis are available [in this document](https://gist.github.com/mnapoli/6159681).
51
-
52
- The summary of the analysis showed that:
53
-
54
- - all containers offer a method to get an entry by its id
55
- - a large majority name such method `get()`
56
- - for all containers, the `get()` method has 1 mandatory parameter of type string
57
- - some containers have an optional additional argument for `get()`, but it doesn't have the same purpose between containers
58
- - a large majority of the containers offer a method to test if it can return an entry by its id
59
- - a majority name such method `has()`
60
- - for all containers offering `has()`, the method has exactly 1 parameter of type string
61
- - a large majority of the containers throw an exception rather than returning null when an entry is not found in `get()`
62
- - a large majority of the containers don't implement `ArrayAccess`
63
-
64
- The question of whether to include methods to define entries has been discussed in
65
- [issue #1](https://github.com/container-interop/container-interop/issues/1).
66
- It has been judged that such methods do not belong in the interface described here because it is out of its scope
67
- (see the "Goal" section).
68
-
69
- As a result, the `ContainerInterface` contains two methods:
70
-
71
- - `get()`, returning anything, with one mandatory string parameter. Should throw an exception if the entry is not found.
72
- - `has()`, returning a boolean, with one mandatory string parameter.
73
-
74
- ### Number of parameters in `get()` method
75
-
76
- While `ContainerInterface` only defines one mandatory parameter in `get()`, it is not incompatible with
77
- existing containers that have additional optional parameters. PHP allows an implementation to offer more parameters
78
- as long as they are optional, because the implementation *does* satisfy the interface.
79
-
80
- This issue has been discussed in [issue #6](https://github.com/container-interop/container-interop/issues/6).
81
-
82
- ### Type of the `$id` parameter
83
-
84
- The type of the `$id` parameter in `get()` and `has()` has been discussed in
85
- [issue #6](https://github.com/container-interop/container-interop/issues/6).
86
- While `string` is used in all the containers that were analyzed, it was suggested that allowing
87
- anything (such as objects) could allow containers to offer a more advanced query API.
88
-
89
- An example given was to use the container as an object builder. The `$id` parameter would then be an
90
- object that would describe how to create an instance.
91
-
92
- The conclusion of the discussion was that this was beyond the scope of getting entries from a container without
93
- knowing how the container provided them, and it was more fit for a factory.
94
-
95
- ## Contributors
96
-
97
- Are listed here all people that contributed in the discussions or votes, by alphabetical order:
98
-
99
- - [Amy Stephen](https://github.com/AmyStephen)
100
- - [David Négrier](https://github.com/moufmouf)
101
- - [Don Gilbert](https://github.com/dongilbert)
102
- - [Jason Judge](https://github.com/judgej)
103
- - [Jeremy Lindblom](https://github.com/jeremeamia)
104
- - [Marco Pivetta](https://github.com/Ocramius)
105
- - [Matthieu Napoli](https://github.com/mnapoli)
106
- - [Paul M. Jones](https://github.com/pmjones)
107
- - [Stephan Hochdörfer](https://github.com/shochdoerfer)
108
- - [Taylor Otwell](https://github.com/taylorotwell)
109
-
110
- ## Relevant links
111
-
112
- - [`ContainerInterface.php`](https://github.com/container-interop/container-interop/blob/master/src/Interop/Container/ContainerInterface.php)
113
- - [List of all issues](https://github.com/container-interop/container-interop/issues?labels=ContainerInterface&milestone=&page=1&state=closed)
114
- - [Vote for the interface name](https://github.com/container-interop/container-interop/wiki/%231-interface-name:-Vote)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/container-interop/container-interop/docs/ContainerInterface.md DELETED
@@ -1,158 +0,0 @@
1
- Container interface
2
- ===================
3
-
4
- This document describes a common interface for dependency injection containers.
5
-
6
- The goal set by `ContainerInterface` is to standardize how frameworks and libraries make use of a
7
- container to obtain objects and parameters (called *entries* in the rest of this document).
8
-
9
- The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
10
- "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
11
- interpreted as described in [RFC 2119][].
12
-
13
- The word `implementor` in this document is to be interpreted as someone
14
- implementing the `ContainerInterface` in a dependency injection-related library or framework.
15
- Users of dependency injections containers (DIC) are referred to as `user`.
16
-
17
- [RFC 2119]: http://tools.ietf.org/html/rfc2119
18
-
19
- 1. Specification
20
- -----------------
21
-
22
- ### 1.1 Basics
23
-
24
- - The `Interop\Container\ContainerInterface` exposes two methods : `get` and `has`.
25
-
26
- - `get` takes one mandatory parameter: an entry identifier. It MUST be a string.
27
- A call to `get` can return anything (a *mixed* value), or throws an exception if the identifier
28
- is not known to the container. Two successive calls to `get` with the same
29
- identifier SHOULD return the same value. However, depending on the `implementor`
30
- design and/or `user` configuration, different values might be returned, so
31
- `user` SHOULD NOT rely on getting the same value on 2 successive calls.
32
- While `ContainerInterface` only defines one mandatory parameter in `get()`, implementations
33
- MAY accept additional optional parameters.
34
-
35
- - `has` takes one unique parameter: an entry identifier. It MUST return `true`
36
- if an entry identifier is known to the container and `false` if it is not.
37
- `has($id)` returning true does not mean that `get($id)` will not throw an exception.
38
- It does however mean that `get($id)` will not throw a `NotFoundException`.
39
-
40
- ### 1.2 Exceptions
41
-
42
- Exceptions directly thrown by the container MUST implement the
43
- [`Interop\Container\Exception\ContainerException`](../src/Interop/Container/Exception/ContainerException.php).
44
-
45
- A call to the `get` method with a non-existing id SHOULD throw a
46
- [`Interop\Container\Exception\NotFoundException`](../src/Interop/Container/Exception/NotFoundException.php).
47
-
48
- ### 1.3 Additional features
49
-
50
- This section describes additional features that MAY be added to a container. Containers are not
51
- required to implement these features to respect the ContainerInterface.
52
-
53
- #### 1.3.1 Delegate lookup feature
54
-
55
- The goal of the *delegate lookup* feature is to allow several containers to share entries.
56
- Containers implementing this feature can perform dependency lookups in other containers.
57
-
58
- Containers implementing this feature will offer a greater lever of interoperability
59
- with other containers. Implementation of this feature is therefore RECOMMENDED.
60
-
61
- A container implementing this feature:
62
-
63
- - MUST implement the `ContainerInterface`
64
- - MUST provide a way to register a delegate container (using a constructor parameter, or a setter,
65
- or any possible way). The delegate container MUST implement the `ContainerInterface`.
66
-
67
- When a container is configured to use a delegate container for dependencies:
68
-
69
- - Calls to the `get` method should only return an entry if the entry is part of the container.
70
- If the entry is not part of the container, an exception should be thrown
71
- (as requested by the `ContainerInterface`).
72
- - Calls to the `has` method should only return `true` if the entry is part of the container.
73
- If the entry is not part of the container, `false` should be returned.
74
- - If the fetched entry has dependencies, **instead** of performing
75
- the dependency lookup in the container, the lookup is performed on the *delegate container*.
76
-
77
- Important! By default, the lookup SHOULD be performed on the delegate container **only**, not on the container itself.
78
-
79
- It is however allowed for containers to provide exception cases for special entries, and a way to lookup
80
- into the same container (or another container) instead of the delegate container.
81
-
82
- 2. Package
83
- ----------
84
-
85
- The interfaces and classes described as well as relevant exception are provided as part of the
86
- [container-interop/container-interop](https://packagist.org/packages/container-interop/container-interop) package.
87
-
88
- 3. `Interop\Container\ContainerInterface`
89
- -----------------------------------------
90
-
91
- ```php
92
- <?php
93
- namespace Interop\Container;
94
-
95
- use Interop\Container\Exception\ContainerException;
96
- use Interop\Container\Exception\NotFoundException;
97
-
98
- /**
99
- * Describes the interface of a container that exposes methods to read its entries.
100
- */
101
- interface ContainerInterface
102
- {
103
- /**
104
- * Finds an entry of the container by its identifier and returns it.
105
- *
106
- * @param string $id Identifier of the entry to look for.
107
- *
108
- * @throws NotFoundException No entry was found for this identifier.
109
- * @throws ContainerException Error while retrieving the entry.
110
- *
111
- * @return mixed Entry.
112
- */
113
- public function get($id);
114
-
115
- /**
116
- * Returns true if the container can return an entry for the given identifier.
117
- * Returns false otherwise.
118
- *
119
- * `has($id)` returning true does not mean that `get($id)` will not throw an exception.
120
- * It does however mean that `get($id)` will not throw a `NotFoundException`.
121
- *
122
- * @param string $id Identifier of the entry to look for.
123
- *
124
- * @return boolean
125
- */
126
- public function has($id);
127
- }
128
- ```
129
-
130
- 4. `Interop\Container\Exception\ContainerException`
131
- ---------------------------------------------------
132
-
133
- ```php
134
- <?php
135
- namespace Interop\Container\Exception;
136
-
137
- /**
138
- * Base interface representing a generic exception in a container.
139
- */
140
- interface ContainerException
141
- {
142
- }
143
- ```
144
-
145
- 5. `Interop\Container\Exception\NotFoundException`
146
- ---------------------------------------------------
147
-
148
- ```php
149
- <?php
150
- namespace Interop\Container\Exception;
151
-
152
- /**
153
- * No entry was found in the container.
154
- */
155
- interface NotFoundException extends ContainerException
156
- {
157
- }
158
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/container-interop/container-interop/docs/Delegate-lookup-meta.md DELETED
@@ -1,259 +0,0 @@
1
- Delegate lookup feature Meta Document
2
- =====================================
3
-
4
- 1. Summary
5
- ----------
6
-
7
- This document describes the *delegate lookup feature*.
8
- Containers are not required to implement this feature to respect the `ContainerInterface`.
9
- However, containers implementing this feature will offer a greater lever of interoperability
10
- with other containers, allowing multiple containers to share entries in the same application.
11
- Implementation of this feature is therefore recommanded.
12
-
13
- 2. Why Bother?
14
- --------------
15
-
16
- The [`ContainerInterface`](../src/Interop/Container/ContainerInterface.php) ([meta doc](ContainerInterface.md))
17
- standardizes how frameworks and libraries make use of a container to obtain objects and parameters.
18
-
19
- By standardizing such a behavior, frameworks and libraries relying on the `ContainerInterface`
20
- could work with any compatible container.
21
- That would allow end users to choose their own container based on their own preferences.
22
-
23
- The `ContainerInterface` is also enough if we want to have several containers side-by-side in the same
24
- application. For instance, this is what the [CompositeContainer](https://github.com/jeremeamia/acclimate-container/blob/master/src/CompositeContainer.php)
25
- class of [Acclimate](https://github.com/jeremeamia/acclimate-container) is designed for:
26
-
27
- ![Side by side containers](images/side_by_side_containers.png)
28
-
29
- However, an instance in container 1 cannot reference an instance in container 2.
30
-
31
- It would be better if an instance of container 1 could reference an instance in container 2,
32
- and the opposite should be true.
33
-
34
- ![Interoperating containers](images/interoperating_containers.png)
35
-
36
- In the sample above, entry 1 in container 1 is referencing entry 3 in container 2.
37
-
38
- 3. Scope
39
- --------
40
-
41
- ### 3.1 Goals
42
-
43
- The goal of the *delegate lookup* feature is to allow several containers to share entries.
44
-
45
- 4. Approaches
46
- -------------
47
-
48
- ### 4.1 Chosen Approach
49
-
50
- Containers implementing this feature can perform dependency lookups in other containers.
51
-
52
- A container implementing this feature:
53
-
54
- - must implement the `ContainerInterface`
55
- - must provide a way to register a *delegate container* (using a constructor parameter, or a setter, or any
56
- possible way). The *delegate container* must implement the `ContainerInterface`.
57
-
58
- When a *delegate container* is configured on a container:
59
-
60
- - Calls to the `get` method should only return an entry if the entry is part of the container.
61
- If the entry is not part of the container, an exception should be thrown (as required in the `ContainerInterface`).
62
- - Calls to the `has` method should only return *true* if the entry is part of the container.
63
- If the entry is not part of the container, *false* should be returned.
64
- - Finally, the important part: if the entry we are fetching has dependencies,
65
- **instead** of perfoming the dependency lookup in the container, the lookup is performed on the *delegate container*.
66
-
67
- Important! By default, the lookup should be performed on the delegate container **only**, not on the container itself.
68
-
69
- It is however allowed for containers to provide exception cases for special entries, and a way to lookup into
70
- the same container (or another container) instead of the delegate container.
71
-
72
- ### 4.2 Typical usage
73
-
74
- The *delegate container* will usually be a composite container. A composite container is a container that
75
- contains several other containers. When performing a lookup on a composite container, the inner containers are
76
- queried until one container returns an entry.
77
- An inner container implementing the *delegate lookup feature* will return entries it contains, but if these
78
- entries have dependencies, the dependencies lookup calls will be performed on the composite container, giving
79
- a chance to all containers to answer.
80
-
81
- Interestingly enough, the order in which containers are added in the composite container matters. Indeed,
82
- the first containers to be added in the composite container can "override" the entries of containers with
83
- lower priority.
84
-
85
- ![Containers priority](images/priority.png)
86
-
87
- In the example above, "container 2" contains a controller "myController" and the controller is referencing an
88
- "entityManager" entry. "Container 1" contains also an entry named "entityManager".
89
- Without the *delegate lookup* feature, when requesting the "myController" instance to container 2, it would take
90
- in charge the instanciation of both entries.
91
-
92
- However, using the *delegate lookup* feature, here is what happens when we ask the composite container for the
93
- "myController" instance:
94
-
95
- - The composite container asks container 1 if if contains the "myController" instance. The answer is no.
96
- - The composite container asks container 2 if if contains the "myController" instance. The answer is yes.
97
- - The composite container performs a `get` call on container 2 for the "myController" instance.
98
- - Container 2 sees that "myController" has a dependency on "entityManager".
99
- - Container 2 delegates the lookup of "entityManager" to the composite container.
100
- - The composite container asks container 1 if if contains the "entityManager" instance. The answer is yes.
101
- - The composite container performs a `get` call on container 1 for the "entityManager" instance.
102
-
103
- In the end, we get a controller instanciated by container 2 that references an entityManager instanciated
104
- by container 1.
105
-
106
- ### 4.3 Alternative: the fallback strategy
107
-
108
- The first proposed approach we tried was to perform all the lookups in the "local" container,
109
- and if a lookup fails in the container, to use the delegate container. In this scenario, the
110
- delegate container is used in "fallback" mode.
111
-
112
- This strategy has been described in @moufmouf blog post: http://mouf-php.com/container-interop-whats-next (solution 1).
113
- It was also discussed [here](https://github.com/container-interop/container-interop/pull/8#issuecomment-33570697) and
114
- [here](https://github.com/container-interop/container-interop/pull/20#issuecomment-56599631).
115
-
116
- Problems with this strategy:
117
-
118
- - Heavy problem regarding infinite loops
119
- - Unable to overload a container entry with the delegate container entry
120
-
121
- ### 4.4 Alternative: force implementing an interface
122
-
123
- The first proposed approach was to develop a `ParentAwareContainerInterface` interface.
124
- It was proposed here: https://github.com/container-interop/container-interop/pull/8
125
-
126
- The interface would have had the behaviour of the delegate lookup feature but would have forced the addition of
127
- a `setParentContainter` method:
128
-
129
- ```php
130
- interface ParentAwareContainerInterface extends ReadableContainerInterface {
131
- /**
132
- * Sets the parent container associated to that container. This container will call
133
- * the parent container to fetch dependencies.
134
- *
135
- * @param ContainerInterface $container
136
- */
137
- public function setParentContainer(ContainerInterface $container);
138
- }
139
- ```
140
-
141
- The interface idea was first questioned by @Ocramius [here](https://github.com/container-interop/container-interop/pull/8#issuecomment-51721777).
142
- @Ocramius expressed the idea that an interface should not contain setters, otherwise, it is forcing implementation
143
- details on the class implementing the interface.
144
- Then @mnapoli made a proposal for a "convention" [here](https://github.com/container-interop/container-interop/pull/8#issuecomment-51841079),
145
- this idea was further discussed until all participants in the discussion agreed to remove the interface idea
146
- and replace it with a "standard" feature.
147
-
148
- **Pros:**
149
-
150
- If we had had an interface, we could have delegated the registration of the delegate/composite container to the
151
- the delegate/composite container itself.
152
- For instance:
153
-
154
- ```php
155
- $containerA = new ContainerA();
156
- $containerB = new ContainerB();
157
-
158
- $compositeContainer = new CompositeContainer([$containerA, $containerB]);
159
-
160
- // The call to 'setParentContainer' is delegated to the CompositeContainer
161
- // It is not the responsibility of the user anymore.
162
- class CompositeContainer {
163
- ...
164
-
165
- public function __construct($containers) {
166
- foreach ($containers as $container) {
167
- if ($container instanceof ParentAwareContainerInterface) {
168
- $container->setParentContainer($this);
169
- }
170
- }
171
- ...
172
- }
173
- }
174
-
175
- ```
176
-
177
- **Cons:**
178
-
179
- Cons have been extensively discussed [here](https://github.com/container-interop/container-interop/pull/8#issuecomment-51721777).
180
- Basically, forcing a setter into an interface is a bad idea. Setters are similar to constructor arguments,
181
- and it's a bad idea to standardize a constructor: how the delegate container is configured into a container is an implementation detail. This outweights the benefits of the interface.
182
-
183
- ### 4.4 Alternative: no exception case for delegate lookups
184
-
185
- Originally, the proposed wording for delegate lookup calls was:
186
-
187
- > Important! The lookup MUST be performed on the delegate container **only**, not on the container itself.
188
-
189
- This was later replaced by:
190
-
191
- > Important! By default, the lookup SHOULD be performed on the delegate container **only**, not on the container itself.
192
- >
193
- > It is however allowed for containers to provide exception cases for special entries, and a way to lookup
194
- > into the same container (or another container) instead of the delegate container.
195
-
196
- Exception cases have been allowed to avoid breaking dependencies with some services that must be provided
197
- by the container (on @njasm proposal). This was proposed here: https://github.com/container-interop/container-interop/pull/20#issuecomment-56597235
198
-
199
- ### 4.5 Alternative: having one of the containers act as the composite container
200
-
201
- In real-life scenarios, we usually have a big framework (Symfony 2, Zend Framework 2, etc...) and we want to
202
- add another DI container to this container. Most of the time, the "big" framework will be responsible for
203
- creating the controller's instances, using it's own DI container. Until *container-interop* is fully adopted,
204
- the "big" framework will not be aware of the existence of a composite container that it should use instead
205
- of its own container.
206
-
207
- For this real-life use cases, @mnapoli and @moufmouf proposed to extend the "big" framework's DI container
208
- to make it act as a composite container.
209
-
210
- This has been discussed [here](https://github.com/container-interop/container-interop/pull/8#issuecomment-40367194)
211
- and [here](http://mouf-php.com/container-interop-whats-next#solution4).
212
-
213
- This was implemented in Symfony 2 using:
214
-
215
- - [interop.symfony.di](https://github.com/thecodingmachine/interop.symfony.di/tree/v0.1.0)
216
- - [framework interop](https://github.com/mnapoli/framework-interop/)
217
-
218
- This was implemented in Silex using:
219
-
220
- - [interop.silex.di](https://github.com/thecodingmachine/interop.silex.di)
221
-
222
- Having a container act as the composite container is not part of the delegate lookup standard because it is
223
- simply a temporary design pattern used to make existing frameworks that do not support yet ContainerInterop
224
- play nice with other DI containers.
225
-
226
-
227
- 5. Implementations
228
- ------------------
229
-
230
- The following projects already implement the delegate lookup feature:
231
-
232
- - [Mouf](http://mouf-php.com), through the [`setDelegateLookupContainer` method](https://github.com/thecodingmachine/mouf/blob/2.0/src/Mouf/MoufManager.php#L2120)
233
- - [PHP-DI](http://php-di.org/), through the [`$wrapperContainer` parameter of the constructor](https://github.com/mnapoli/PHP-DI/blob/master/src/DI/Container.php#L72)
234
- - [pimple-interop](https://github.com/moufmouf/pimple-interop), through the [`$container` parameter of the constructor](https://github.com/moufmouf/pimple-interop/blob/master/src/Interop/Container/Pimple/PimpleInterop.php#L62)
235
-
236
- 6. People
237
- ---------
238
-
239
- Are listed here all people that contributed in the discussions, by alphabetical order:
240
-
241
- - [Alexandru Pătrănescu](https://github.com/drealecs)
242
- - [Ben Peachey](https://github.com/potherca)
243
- - [David Négrier](https://github.com/moufmouf)
244
- - [Jeremy Lindblom](https://github.com/jeremeamia)
245
- - [Marco Pivetta](https://github.com/Ocramius)
246
- - [Matthieu Napoli](https://github.com/mnapoli)
247
- - [Nelson J Morais](https://github.com/njasm)
248
- - [Phil Sturgeon](https://github.com/philsturgeon)
249
- - [Stephan Hochdörfer](https://github.com/shochdoerfer)
250
-
251
- 7. Relevant Links
252
- -----------------
253
-
254
- _**Note:** Order descending chronologically._
255
-
256
- - [Pull request on the delegate lookup feature](https://github.com/container-interop/container-interop/pull/20)
257
- - [Pull request on the interface idea](https://github.com/container-interop/container-interop/pull/8)
258
- - [Original article exposing the delegate lookup idea along many others](http://mouf-php.com/container-interop-whats-next)
259
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/container-interop/container-interop/docs/Delegate-lookup.md DELETED
@@ -1,60 +0,0 @@
1
- Delegate lookup feature
2
- =======================
3
-
4
- This document describes a standard for dependency injection containers.
5
-
6
- The goal set by the *delegate lookup* feature is to allow several containers to share entries.
7
- Containers implementing this feature can perform dependency lookups in other containers.
8
-
9
- Containers implementing this feature will offer a greater lever of interoperability
10
- with other containers. Implementation of this feature is therefore RECOMMENDED.
11
-
12
- The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
13
- "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
14
- interpreted as described in [RFC 2119][].
15
-
16
- The word `implementor` in this document is to be interpreted as someone
17
- implementing the delegate lookup feature in a dependency injection-related library or framework.
18
- Users of dependency injections containers (DIC) are referred to as `user`.
19
-
20
- [RFC 2119]: http://tools.ietf.org/html/rfc2119
21
-
22
- 1. Vocabulary
23
- -------------
24
-
25
- In a dependency injection container, the container is used to fetch entries.
26
- Entries can have dependencies on other entries. Usually, these other entries are fetched by the container.
27
-
28
- The *delegate lookup* feature is the ability for a container to fetch dependencies in
29
- another container. In the rest of the document, the word "container" will reference the container
30
- implemented by the implementor. The word "delegate container" will reference the container we are
31
- fetching the dependencies from.
32
-
33
- 2. Specification
34
- ----------------
35
-
36
- A container implementing the *delegate lookup* feature:
37
-
38
- - MUST implement the [`ContainerInterface`](ContainerInterface.md)
39
- - MUST provide a way to register a delegate container (using a constructor parameter, or a setter,
40
- or any possible way). The delegate container MUST implement the [`ContainerInterface`](ContainerInterface.md).
41
-
42
- When a container is configured to use a delegate container for dependencies:
43
-
44
- - Calls to the `get` method should only return an entry if the entry is part of the container.
45
- If the entry is not part of the container, an exception should be thrown
46
- (as requested by the [`ContainerInterface`](ContainerInterface.md)).
47
- - Calls to the `has` method should only return `true` if the entry is part of the container.
48
- If the entry is not part of the container, `false` should be returned.
49
- - If the fetched entry has dependencies, **instead** of performing
50
- the dependency lookup in the container, the lookup is performed on the *delegate container*.
51
-
52
- Important: By default, the dependency lookups SHOULD be performed on the delegate container **only**, not on the container itself.
53
-
54
- It is however allowed for containers to provide exception cases for special entries, and a way to lookup
55
- into the same container (or another container) instead of the delegate container.
56
-
57
- 3. Package / Interface
58
- ----------------------
59
-
60
- This feature is not tied to any code, interface or package.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/container-interop/container-interop/docs/images/interoperating_containers.png DELETED
Binary file
addons/lib/ioc/container-interop/container-interop/docs/images/priority.png DELETED
Binary file
addons/lib/ioc/container-interop/container-interop/docs/images/side_by_side_containers.png DELETED
Binary file
addons/lib/ioc/container-interop/container-interop/src/Interop/Container/ContainerInterface.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
- /**
3
- * @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
4
- */
5
-
6
- namespace Interop\Container;
7
-
8
- use Psr\Container\ContainerInterface as PsrContainerInterface;
9
-
10
- /**
11
- * Describes the interface of a container that exposes methods to read its entries.
12
- */
13
- interface ContainerInterface extends PsrContainerInterface
14
- {
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/container-interop/container-interop/src/Interop/Container/Exception/ContainerException.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
- /**
3
- * @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
4
- */
5
-
6
- namespace Interop\Container\Exception;
7
-
8
- use Psr\Container\ContainerExceptionInterface as PsrContainerException;
9
-
10
- /**
11
- * Base interface representing a generic exception in a container.
12
- */
13
- interface ContainerException extends PsrContainerException
14
- {
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/container-interop/container-interop/src/Interop/Container/Exception/NotFoundException.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
- /**
3
- * @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
4
- */
5
-
6
- namespace Interop\Container\Exception;
7
-
8
- use Psr\Container\NotFoundExceptionInterface as PsrNotFoundException;
9
-
10
- /**
11
- * No entry was found in the container.
12
- */
13
- interface NotFoundException extends ContainerException, PsrNotFoundException
14
- {
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/invoker/CONTRIBUTING.md DELETED
@@ -1,15 +0,0 @@
1
- # Contributing
2
-
3
- First of all, **thank you** for contributing!
4
-
5
- Here are a few rules to follow in order to ease code reviews and merging:
6
-
7
- - follow [PSR-1](http://www.php-fig.org/psr/1/) and [PSR-2](http://www.php-fig.org/psr/2/)
8
- - run the test suite
9
- - write (or update) unit tests when applicable
10
- - write documentation for new features
11
- - use [commit messages that make sense](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
12
-
13
- One may ask you to [squash your commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html) too. This is used to "clean" your pull request before merging it (we don't want commits such as `fix tests`, `fix 2`, `fix 3`, etc.).
14
-
15
- When creating your pull request on GitHub, please write a description which gives the context and/or explains why you are creating it.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/invoker/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) Matthieu Napoli
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/invoker/README.md DELETED
@@ -1,234 +0,0 @@
1
- # Invoker
2
-
3
- Generic and extensible callable invoker.
4
-
5
- [![Build Status](https://img.shields.io/travis/PHP-DI/Invoker.svg?style=flat-square)](https://travis-ci.org/PHP-DI/Invoker)
6
- [![Coverage Status](https://img.shields.io/coveralls/PHP-DI/Invoker/master.svg?style=flat-square)](https://coveralls.io/r/PHP-DI/Invoker?branch=master)
7
- [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/PHP-DI/Invoker.svg?style=flat-square)](https://scrutinizer-ci.com/g/PHP-DI/Invoker/?branch=master)
8
- [![Latest Version](https://img.shields.io/github/release/PHP-DI/invoker.svg?style=flat-square)](https://packagist.org/packages/PHP-DI/invoker)
9
-
10
- ## Why?
11
-
12
- Who doesn't need an over-engineered `call_user_func()`?
13
-
14
- ### Named parameters
15
-
16
- Does this [Silex](http://silex.sensiolabs.org) example look familiar:
17
-
18
- ```php
19
- $app->get('/project/{project}/issue/{issue}', function ($project, $issue) {
20
- // ...
21
- });
22
- ```
23
-
24
- Or this command defined with [Silly](https://github.com/mnapoli/silly#usage):
25
-
26
- ```php
27
- $app->command('greet [name] [--yell]', function ($name, $yell) {
28
- // ...
29
- });
30
- ```
31
-
32
- Same pattern in [Slim](http://www.slimframework.com):
33
-
34
- ```php
35
- $app->get('/hello/:name', function ($name) {
36
- // ...
37
- });
38
- ```
39
-
40
- You get the point. These frameworks invoke the controller/command/handler using something akin to named parameters: whatever the order of the parameters, they are matched by their name.
41
-
42
- **This library allows to invoke callables with named parameters in a generic and extensible way.**
43
-
44
- ### Dependency injection
45
-
46
- Anyone familiar with AngularJS is familiar with how dependency injection is performed:
47
-
48
- ```js
49
- angular.controller('MyController', ['dep1', 'dep2', function(dep1, dep2) {
50
- // ...
51
- }]);
52
- ```
53
-
54
- In PHP we find this pattern again in some frameworks and DI containers with partial to full support. For example in Silex you can type-hint the application to get it injected, but it only works with `Silex\Application`:
55
-
56
- ```php
57
- $app->get('/hello/{name}', function (Silex\Application $app, $name) {
58
- // ...
59
- });
60
- ```
61
-
62
- In Silly, it only works with `OutputInterface` to inject the application output:
63
-
64
- ```php
65
- $app->command('greet [name]', function ($name, OutputInterface $output) {
66
- // ...
67
- });
68
- ```
69
-
70
- [PHP-DI](http://php-di.org/doc/container.html) provides a way to invoke a callable and resolve all dependencies from the container using type-hints:
71
-
72
- ```php
73
- $container->call(function (Logger $logger, EntityManager $em) {
74
- // ...
75
- });
76
- ```
77
-
78
- **This library provides clear extension points to let frameworks implement any kind of dependency injection support they want.**
79
-
80
- ### TL/DR
81
-
82
- In short, this library is meant to be a base building block for calling a function with named parameters and/or dependency injection.
83
-
84
- ## Installation
85
-
86
- ```sh
87
- $ composer require PHP-DI/invoker
88
- ```
89
-
90
- ## Usage
91
-
92
- ### Default behavior
93
-
94
- By default the `Invoker` can call using named parameters:
95
-
96
- ```php
97
- $invoker = new Invoker\Invoker;
98
-
99
- $invoker->call(function () {
100
- echo 'Hello world!';
101
- });
102
-
103
- // Simple parameter array
104
- $invoker->call(function ($name) {
105
- echo 'Hello ' . $name;
106
- }, ['John']);
107
-
108
- // Named parameters
109
- $invoker->call(function ($name) {
110
- echo 'Hello ' . $name;
111
- }, [
112
- 'name' => 'John'
113
- ]);
114
-
115
- // Use the default value
116
- $invoker->call(function ($name = 'world') {
117
- echo 'Hello ' . $name;
118
- });
119
-
120
- // Invoke any PHP callable
121
- $invoker->call(['MyClass', 'myStaticMethod']);
122
-
123
- // Using Class::method syntax
124
- $invoker->call('MyClass::myStaticMethod');
125
- ```
126
-
127
- Dependency injection in parameters is supported but needs to be configured with your container. Read on or jump to [*Built-in support for dependency injection*](#built-in-support-for-dependency-injection) if you are impatient.
128
-
129
- Additionally, callables can also be resolved from your container. Read on or jump to [*Resolving callables from a container*](#resolving-callables-from-a-container) if you are impatient.
130
-
131
- ### Parameter resolvers
132
-
133
- Extending the behavior of the `Invoker` is easy and is done by implementing a [`ParameterResolver`](https://github.com/PHP-DI/Invoker/blob/master/src/ParameterResolver/ParameterResolver.php).
134
-
135
- This is explained in details the [Parameter resolvers documentation](doc/parameter-resolvers.md).
136
-
137
- #### Built-in support for dependency injection
138
-
139
- Rather than have you re-implement support for dependency injection with different containers every time, this package ships with 2 optional resolvers:
140
-
141
- - [`TypeHintContainerResolver`](https://github.com/PHP-DI/Invoker/blob/master/src/ParameterResolver/Container/TypeHintContainerResolver.php)
142
-
143
- This resolver will inject container entries by searching for the class name using the type-hint:
144
-
145
- ```php
146
- $invoker->call(function (Psr\Logger\LoggerInterface $logger) {
147
- // ...
148
- });
149
- ```
150
-
151
- In this example it will `->get('Psr\Logger\LoggerInterface')` from the container and inject it.
152
-
153
- This resolver is only useful if you store objects in your container using the class (or interface) name. Silex or Symfony for example store services under a custom name (e.g. `twig`, `db`, etc.) instead of the class name: in that case use the resolver shown below.
154
-
155
- - [`ParameterNameContainerResolver`](https://github.com/PHP-DI/Invoker/blob/master/src/ParameterResolver/Container/ParameterNameContainerResolver.php)
156
-
157
- This resolver will inject container entries by searching for the name of the parameter:
158
-
159
- ```php
160
- $invoker->call(function ($twig) {
161
- // ...
162
- });
163
- ```
164
-
165
- In this example it will `->get('twig')` from the container and inject it.
166
-
167
- These resolvers can work with any dependency injection container compliant with [container-interop](https://github.com/container-interop/container-interop). If you container is not compliant you can use the [Acclimate](https://github.com/jeremeamia/acclimate-container) package.
168
-
169
- Setting up those resolvers is simple:
170
-
171
- ```php
172
- // $container must be an instance of Interop\Container\ContainerInterface
173
- $container = ...
174
-
175
- $containerResolver = new TypeHintContainerResolver($container);
176
- // or
177
- $containerResolver = new ParameterNameContainerResolver($container);
178
-
179
- $invoker = new Invoker\Invoker;
180
- // Register it before all the other parameter resolvers
181
- $invoker->getParameterResolver()->prependResolver($containerResolver);
182
- ```
183
-
184
- You can also register both resolvers at the same time if you wish by prepending both. Implementing support for more tricky things is easy and up to you!
185
-
186
- ### Resolving callables from a container
187
-
188
- The `Invoker` can be wired to your DI container to resolve the callables.
189
-
190
- For example with an invokable class:
191
-
192
- ```php
193
- class MyHandler
194
- {
195
- public function __invoke()
196
- {
197
- // ...
198
- }
199
- }
200
-
201
- // By default this doesn't work: an instance of the class should be provided
202
- $invoker->call('MyHandler');
203
-
204
- // If we set up the container to use
205
- $invoker = new Invoker\Invoker(null, $container);
206
- // Now 'MyHandler' is resolved using the container!
207
- $invoker->call('MyHandler');
208
- ```
209
-
210
- The same works for a class method:
211
-
212
- ```php
213
- class WelcomeController
214
- {
215
- public function home()
216
- {
217
- // ...
218
- }
219
- }
220
-
221
- // By default this doesn't work: home() is not a static method
222
- $invoker->call(['WelcomeController', 'home']);
223
-
224
- // If we set up the container to use
225
- $invoker = new Invoker\Invoker(null, $container);
226
- // Now 'WelcomeController' is resolved using the container!
227
- $invoker->call(['WelcomeController', 'home']);
228
- // Alternatively we can use the Class::method syntax
229
- $invoker->call('WelcomeController::home');
230
- ```
231
-
232
- That feature can be used as the base building block for a framework's dispatcher.
233
-
234
- Again, any [container-interop](https://github.com/container-interop/container-interop) compliant container can be provided, and [Acclimate](https://github.com/jeremeamia/acclimate-container) can be used for incompatible containers.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/invoker/composer.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- "name": "php-di/invoker",
3
- "description": "Generic and extensible callable invoker",
4
- "keywords": ["invoker", "dependency-injection", "dependency", "injection", "callable", "invoke"],
5
- "homepage": "https://github.com/PHP-DI/Invoker",
6
- "license": "MIT",
7
- "type": "library",
8
- "autoload": {
9
- "psr-4": {
10
- "Invoker\\": "src/"
11
- }
12
- },
13
- "autoload-dev": {
14
- "psr-4": {
15
- "Invoker\\Test\\": "tests/"
16
- }
17
- },
18
- "require": {
19
- "container-interop/container-interop": "~1.1"
20
- },
21
- "require-dev": {
22
- "phpunit/phpunit": "~4.5",
23
- "athletic/athletic": "~0.1.8"
24
- }
25
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/invoker/doc/parameter-resolvers.md DELETED
@@ -1,109 +0,0 @@
1
- # Parameter resolvers
2
-
3
- Extending the behavior of the `Invoker` is easy and is done by implementing a [`ParameterResolver`](https://github.com/PHP-DI/Invoker/blob/master/src/ParameterResolver/ParameterResolver.php):
4
-
5
- ```php
6
- interface ParameterResolver
7
- {
8
- public function getParameters(
9
- ReflectionFunctionAbstract $reflection,
10
- array $providedParameters,
11
- array $resolvedParameters
12
- );
13
- }
14
- ```
15
-
16
- - `$providedParameters` contains the parameters provided by the user when calling `$invoker->call($callable, $parameters)`
17
- - `$resolvedParameters` contains parameters that have already been resolved by other parameter resolvers
18
-
19
- An `Invoker` can chain multiple parameter resolvers to mix behaviors, e.g. you can mix "named parameters" support with "dependency injection" support. This is why a `ParameterResolver` should skip parameters that are already resolved in `$resolvedParameters`.
20
-
21
- Here is an implementation example for dumb dependency injection that creates a new instance of the classes type-hinted:
22
-
23
- ```php
24
- class MyParameterResolver implements ParameterResolver
25
- {
26
- public function getParameters(
27
- ReflectionFunctionAbstract $reflection,
28
- array $providedParameters,
29
- array $resolvedParameters
30
- ) {
31
- foreach ($reflection->getParameters() as $index => $parameter) {
32
- if (array_key_exists($index, $resolvedParameters)) {
33
- // Skip already resolved parameters
34
- continue;
35
- }
36
-
37
- $class = $parameter->getClass();
38
-
39
- if ($class) {
40
- $resolvedParameters[$index] = $class->newInstance();
41
- }
42
- }
43
-
44
- return $resolvedParameters;
45
- }
46
- }
47
- ```
48
-
49
- To use it:
50
-
51
- ```php
52
- $invoker = new Invoker\Invoker(new MyParameterResolver);
53
-
54
- $invoker->call(function (ArticleManager $articleManager) {
55
- $articleManager->publishArticle('Hello world', 'This is the article content.');
56
- });
57
- ```
58
-
59
- A new instance of `ArticleManager` will be created by our parameter resolver.
60
-
61
- ## Chaining parameter resolvers
62
-
63
- The fun starts to happen when we want to add support for many things:
64
-
65
- - named parameters
66
- - dependency injection for type-hinted parameters
67
- - ...
68
-
69
- This is where we should use the [`ResolverChain`](https://github.com/PHP-DI/Invoker/blob/master/src/ParameterResolver/ResolverChain.php). This resolver implements the [Chain of responsibility](http://en.wikipedia.org/wiki/Chain-of-responsibility_pattern) design pattern.
70
-
71
- For example the default chain is:
72
-
73
- ```php
74
- $parameterResolver = new ResolverChain([
75
- new NumericArrayResolver,
76
- new AssociativeArrayResolver,
77
- new DefaultValueResolver,
78
- ]);
79
- ```
80
-
81
- It allows to support even the weirdest use cases like:
82
-
83
- ```php
84
- $parameters = [];
85
-
86
- // First parameter will receive "Welcome"
87
- $parameters[] = 'Welcome';
88
-
89
- // Parameter named "content" will receive "Hello world!"
90
- $parameters['content'] = 'Hello world!';
91
-
92
- // $published is not defined so it will use its default value
93
- $invoker->call(function ($title, $content, $published = true) {
94
- // ...
95
- }, $parameters);
96
- ```
97
-
98
- We can put our custom parameter resolver in the list and created a super-duper invoker that also supports basic dependency injection:
99
-
100
- ```php
101
- $parameterResolver = new ResolverChain([
102
- new MyParameterResolver, // Our resolver is at the top for highest priority
103
- new NumericArrayResolver,
104
- new AssociativeArrayResolver,
105
- new DefaultValueResolver,
106
- ]);
107
-
108
- $invoker = new Invoker\Invoker($parameterResolver);
109
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/invoker/src/CallableResolver.php DELETED
@@ -1,127 +0,0 @@
1
- <?php
2
-
3
- namespace Invoker;
4
-
5
- use Interop\Container\ContainerInterface;
6
- use Interop\Container\Exception\NotFoundException;
7
- use Invoker\Exception\NotCallableException;
8
-
9
- /**
10
- * Resolves a callable from a container.
11
- *
12
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
13
- */
14
- class CallableResolver
15
- {
16
- /**
17
- * @var ContainerInterface
18
- */
19
- private $container;
20
-
21
- public function __construct(ContainerInterface $container)
22
- {
23
- $this->container = $container;
24
- }
25
-
26
- /**
27
- * Resolve the given callable into a real PHP callable.
28
- *
29
- * @param callable|string|array $callable
30
- *
31
- * @return callable Real PHP callable.
32
- *
33
- * @throws NotCallableException
34
- */
35
- public function resolve($callable)
36
- {
37
- if (is_string($callable) && strpos($callable, '::') !== false) {
38
- $callable = explode('::', $callable, 2);
39
- }
40
-
41
- $callable = $this->resolveFromContainer($callable);
42
-
43
- if (! is_callable($callable)) {
44
- throw NotCallableException::fromInvalidCallable($callable, true);
45
- }
46
-
47
- return $callable;
48
- }
49
-
50
- /**
51
- * @param callable|string|array $callable
52
- * @return callable
53
- * @throws NotCallableException
54
- */
55
- private function resolveFromContainer($callable)
56
- {
57
- // Shortcut for a very common use case
58
- if ($callable instanceof \Closure) {
59
- return $callable;
60
- }
61
-
62
- $isStaticCallToNonStaticMethod = false;
63
-
64
- // If it's already a callable there is nothing to do
65
- if (is_callable($callable)) {
66
- $isStaticCallToNonStaticMethod = $this->isStaticCallToNonStaticMethod($callable);
67
- if (! $isStaticCallToNonStaticMethod) {
68
- return $callable;
69
- }
70
- }
71
-
72
- // The callable is a container entry name
73
- if (is_string($callable)) {
74
- try {
75
- return $this->container->get($callable);
76
- } catch (NotFoundException $e) {
77
- throw NotCallableException::fromInvalidCallable($callable, true);
78
- }
79
- }
80
-
81
- // The callable is an array whose first item is a container entry name
82
- // e.g. ['some-container-entry', 'methodToCall']
83
- if (is_array($callable) && is_string($callable[0])) {
84
- try {
85
- // Replace the container entry name by the actual object
86
- $callable[0] = $this->container->get($callable[0]);
87
- return $callable;
88
- } catch (NotFoundException $e) {
89
- if ($isStaticCallToNonStaticMethod) {
90
- throw new NotCallableException(sprintf(
91
- 'Cannot call %s::%s() because %s() is not a static method and "%s" is not a container entry',
92
- $callable[0],
93
- $callable[1],
94
- $callable[1],
95
- $callable[0]
96
- ));
97
- }
98
- throw new NotCallableException(sprintf(
99
- 'Cannot call %s on %s because it is not a class nor a valid container entry',
100
- $callable[1],
101
- $callable[0]
102
- ));
103
- }
104
- }
105
-
106
- // Unrecognized stuff, we let it fail later
107
- return $callable;
108
- }
109
-
110
- /**
111
- * Check if the callable represents a static call to a non-static method.
112
- *
113
- * @param mixed $callable
114
- * @return bool
115
- */
116
- private function isStaticCallToNonStaticMethod($callable)
117
- {
118
- if (is_array($callable) && is_string($callable[0])) {
119
- list($class, $method) = $callable;
120
- $reflection = new \ReflectionMethod($class, $method);
121
-
122
- return ! $reflection->isStatic();
123
- }
124
-
125
- return false;
126
- }
127
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/invoker/src/Exception/InvocationException.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
-
3
- namespace Invoker\Exception;
4
-
5
- /**
6
- * Impossible to invoke the callable.
7
- *
8
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
9
- */
10
- class InvocationException extends \Exception
11
- {
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/invoker/src/Exception/NotCallableException.php DELETED
@@ -1,35 +0,0 @@
1
- <?php
2
-
3
- namespace Invoker\Exception;
4
-
5
- /**
6
- * The given callable is not actually callable.
7
- *
8
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
9
- */
10
- class NotCallableException extends InvocationException
11
- {
12
- /**
13
- * @param string $value
14
- * @param bool $containerEntry
15
- * @return self
16
- */
17
- public static function fromInvalidCallable($value, $containerEntry = false)
18
- {
19
- if (is_object($value)) {
20
- $message = sprintf('Instance of %s is not a callable', get_class($value));
21
- } elseif (is_array($value) && isset($value[0]) && isset($value[1])) {
22
- $class = is_object($value[0]) ? get_class($value[0]) : $value[0];
23
- $extra = method_exists($class, '__call') ? ' A __call() method exists but magic methods are not supported.' : '';
24
- $message = sprintf('%s::%s() is not a callable.%s', $class, $value[1], $extra);
25
- } else {
26
- if ($containerEntry) {
27
- $message = var_export($value, true) . ' is neither a callable nor a valid container entry';
28
- } else {
29
- $message = var_export($value, true) . ' is not a callable';
30
- }
31
- }
32
-
33
- return new self($message);
34
- }
35
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/invoker/src/Exception/NotEnoughParametersException.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
-
3
- namespace Invoker\Exception;
4
-
5
- /**
6
- * Not enough parameters could be resolved to invoke the callable.
7
- *
8
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
9
- */
10
- class NotEnoughParametersException extends InvocationException
11
- {
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/invoker/src/Invoker.php DELETED
@@ -1,122 +0,0 @@
1
- <?php
2
-
3
- namespace Invoker;
4
-
5
- use Interop\Container\ContainerInterface;
6
- use Invoker\Exception\NotCallableException;
7
- use Invoker\Exception\NotEnoughParametersException;
8
- use Invoker\ParameterResolver\AssociativeArrayResolver;
9
- use Invoker\ParameterResolver\DefaultValueResolver;
10
- use Invoker\ParameterResolver\NumericArrayResolver;
11
- use Invoker\ParameterResolver\ParameterResolver;
12
- use Invoker\ParameterResolver\ResolverChain;
13
- use Invoker\Reflection\CallableReflection;
14
-
15
- /**
16
- * Invoke a callable.
17
- *
18
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
19
- */
20
- class Invoker implements InvokerInterface
21
- {
22
- /**
23
- * @var CallableResolver|null
24
- */
25
- private $callableResolver;
26
-
27
- /**
28
- * @var ParameterResolver
29
- */
30
- private $parameterResolver;
31
-
32
- /**
33
- * @var ContainerInterface|null
34
- */
35
- private $container;
36
-
37
- public function __construct(ParameterResolver $parameterResolver = null, ContainerInterface $container = null)
38
- {
39
- $this->parameterResolver = $parameterResolver ?: $this->createParameterResolver();
40
- $this->container = $container;
41
-
42
- if ($container) {
43
- $this->callableResolver = new CallableResolver($container);
44
- }
45
- }
46
-
47
- /**
48
- * {@inheritdoc}
49
- */
50
- public function call($callable, array $parameters = array())
51
- {
52
- if ($this->callableResolver) {
53
- $callable = $this->callableResolver->resolve($callable);
54
- }
55
-
56
- if (! is_callable($callable)) {
57
- throw new NotCallableException(sprintf(
58
- '%s is not a callable',
59
- is_object($callable) ? 'Instance of ' . get_class($callable) : var_export($callable, true)
60
- ));
61
- }
62
-
63
- $callableReflection = CallableReflection::create($callable);
64
-
65
- $args = $this->parameterResolver->getParameters($callableReflection, $parameters, array());
66
-
67
- // Sort by array key because call_user_func_array ignores numeric keys
68
- ksort($args);
69
-
70
- // Check all parameters are resolved
71
- $diff = array_diff_key($callableReflection->getParameters(), $args);
72
- if (! empty($diff)) {
73
- /** @var \ReflectionParameter $parameter */
74
- $parameter = reset($diff);
75
- throw new NotEnoughParametersException(sprintf(
76
- 'Unable to invoke the callable because no value was given for parameter %d ($%s)',
77
- $parameter->getPosition() + 1,
78
- $parameter->name
79
- ));
80
- }
81
-
82
- return call_user_func_array($callable, $args);
83
- }
84
-
85
- /**
86
- * Create the default parameter resolver.
87
- *
88
- * @return ParameterResolver
89
- */
90
- private function createParameterResolver()
91
- {
92
- return new ResolverChain(array(
93
- new NumericArrayResolver,
94
- new AssociativeArrayResolver,
95
- new DefaultValueResolver,
96
- ));
97
- }
98
-
99
- /**
100
- * @return ParameterResolver By default it's a ResolverChain
101
- */
102
- public function getParameterResolver()
103
- {
104
- return $this->parameterResolver;
105
- }
106
-
107
- /**
108
- * @return ContainerInterface|null
109
- */
110
- public function getContainer()
111
- {
112
- return $this->container;
113
- }
114
-
115
- /**
116
- * @return CallableResolver|null Returns null if no container was given in the constructor.
117
- */
118
- public function getCallableResolver()
119
- {
120
- return $this->callableResolver;
121
- }
122
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/invoker/src/InvokerInterface.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
-
3
- namespace Invoker;
4
-
5
- use Invoker\Exception\InvocationException;
6
- use Invoker\Exception\NotCallableException;
7
- use Invoker\Exception\NotEnoughParametersException;
8
-
9
- /**
10
- * Invoke a callable.
11
- *
12
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
13
- */
14
- interface InvokerInterface
15
- {
16
- /**
17
- * Call the given function using the given parameters.
18
- *
19
- * @param callable $callable Function to call.
20
- * @param array $parameters Parameters to use.
21
- *
22
- * @return mixed Result of the function.
23
- *
24
- * @throws InvocationException Base exception class for all the sub-exceptions below.
25
- * @throws NotCallableException
26
- * @throws NotEnoughParametersException
27
- */
28
- public function call($callable, array $parameters = array());
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/invoker/src/ParameterResolver/AssociativeArrayResolver.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
-
3
- namespace Invoker\ParameterResolver;
4
-
5
- use ReflectionFunctionAbstract;
6
-
7
- /**
8
- * Tries to map an associative array (string-indexed) to the parameter names.
9
- *
10
- * E.g. `->call($callable, ['foo' => 'bar'])` will inject the string `'bar'`
11
- * in the parameter named `$foo`.
12
- *
13
- * Parameters that are not indexed by a string are ignored.
14
- *
15
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
16
- */
17
- class AssociativeArrayResolver implements ParameterResolver
18
- {
19
- public function getParameters(
20
- ReflectionFunctionAbstract $reflection,
21
- array $providedParameters,
22
- array $resolvedParameters
23
- ) {
24
- $parameters = $reflection->getParameters();
25
-
26
- // Skip parameters already resolved
27
- if (! empty($resolvedParameters)) {
28
- $parameters = array_diff_key($parameters, $resolvedParameters);
29
- }
30
-
31
- foreach ($parameters as $index => $parameter) {
32
- if (array_key_exists($parameter->name, $providedParameters)) {
33
- $resolvedParameters[$index] = $providedParameters[$parameter->name];
34
- }
35
- }
36
-
37
- return $resolvedParameters;
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/invoker/src/ParameterResolver/Container/ParameterNameContainerResolver.php DELETED
@@ -1,51 +0,0 @@
1
- <?php
2
-
3
- namespace Invoker\ParameterResolver\Container;
4
-
5
- use Interop\Container\ContainerInterface;
6
- use Invoker\ParameterResolver\ParameterResolver;
7
- use ReflectionFunctionAbstract;
8
-
9
- /**
10
- * Inject entries from a DI container using the parameter names.
11
- *
12
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
13
- */
14
- class ParameterNameContainerResolver implements ParameterResolver
15
- {
16
- /**
17
- * @var ContainerInterface
18
- */
19
- private $container;
20
-
21
- /**
22
- * @param ContainerInterface $container The container to get entries from.
23
- */
24
- public function __construct(ContainerInterface $container)
25
- {
26
- $this->container = $container;
27
- }
28
-
29
- public function getParameters(
30
- ReflectionFunctionAbstract $reflection,
31
- array $providedParameters,
32
- array $resolvedParameters
33
- ) {
34
- $parameters = $reflection->getParameters();
35
-
36
- // Skip parameters already resolved
37
- if (! empty($resolvedParameters)) {
38
- $parameters = array_diff_key($parameters, $resolvedParameters);
39
- }
40
-
41
- foreach ($parameters as $index => $parameter) {
42
- $name = $parameter->name;
43
-
44
- if ($name && $this->container->has($name)) {
45
- $resolvedParameters[$index] = $this->container->get($name);
46
- }
47
- }
48
-
49
- return $resolvedParameters;
50
- }
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/invoker/src/ParameterResolver/Container/TypeHintContainerResolver.php DELETED
@@ -1,51 +0,0 @@
1
- <?php
2
-
3
- namespace Invoker\ParameterResolver\Container;
4
-
5
- use Interop\Container\ContainerInterface;
6
- use Invoker\ParameterResolver\ParameterResolver;
7
- use ReflectionFunctionAbstract;
8
-
9
- /**
10
- * Inject entries from a DI container using the type-hints.
11
- *
12
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
13
- */
14
- class TypeHintContainerResolver implements ParameterResolver
15
- {
16
- /**
17
- * @var ContainerInterface
18
- */
19
- private $container;
20
-
21
- /**
22
- * @param ContainerInterface $container The container to get entries from.
23
- */
24
- public function __construct(ContainerInterface $container)
25
- {
26
- $this->container = $container;
27
- }
28
-
29
- public function getParameters(
30
- ReflectionFunctionAbstract $reflection,
31
- array $providedParameters,
32
- array $resolvedParameters
33
- ) {
34
- $parameters = $reflection->getParameters();
35
-
36
- // Skip parameters already resolved
37
- if (! empty($resolvedParameters)) {
38
- $parameters = array_diff_key($parameters, $resolvedParameters);
39
- }
40
-
41
- foreach ($parameters as $index => $parameter) {
42
- $parameterClass = $parameter->getClass();
43
-
44
- if ($parameterClass && $this->container->has($parameterClass->name)) {
45
- $resolvedParameters[$index] = $this->container->get($parameterClass->name);
46
- }
47
- }
48
-
49
- return $resolvedParameters;
50
- }
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/invoker/src/ParameterResolver/DefaultValueResolver.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
-
3
- namespace Invoker\ParameterResolver;
4
-
5
- use ReflectionException;
6
- use ReflectionFunctionAbstract;
7
-
8
- /**
9
- * Finds the default value for a parameter, *if it exists*.
10
- *
11
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
12
- */
13
- class DefaultValueResolver implements ParameterResolver
14
- {
15
- public function getParameters(
16
- ReflectionFunctionAbstract $reflection,
17
- array $providedParameters,
18
- array $resolvedParameters
19
- ) {
20
- $parameters = $reflection->getParameters();
21
-
22
- // Skip parameters already resolved
23
- if (! empty($resolvedParameters)) {
24
- $parameters = array_diff_key($parameters, $resolvedParameters);
25
- }
26
-
27
- foreach ($parameters as $index => $parameter) {
28
- /** @var \ReflectionParameter $parameter */
29
- if ($parameter->isOptional()) {
30
- try {
31
- $resolvedParameters[$index] = $parameter->getDefaultValue();
32
- } catch (ReflectionException $e) {
33
- // Can't get default values from PHP internal classes and functions
34
- }
35
- }
36
- }
37
-
38
- return $resolvedParameters;
39
- }
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/invoker/src/ParameterResolver/NumericArrayResolver.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
-
3
- namespace Invoker\ParameterResolver;
4
-
5
- use ReflectionFunctionAbstract;
6
-
7
- /**
8
- * Simply returns all the values of the $providedParameters array that are
9
- * indexed by the parameter position (i.e. a number).
10
- *
11
- * E.g. `->call($callable, ['foo', 'bar'])` will simply resolve the parameters
12
- * to `['foo', 'bar']`.
13
- *
14
- * Parameters that are not indexed by a number (i.e. parameter position)
15
- * will be ignored.
16
- *
17
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
18
- */
19
- class NumericArrayResolver implements ParameterResolver
20
- {
21
- public function getParameters(
22
- ReflectionFunctionAbstract $reflection,
23
- array $providedParameters,
24
- array $resolvedParameters
25
- ) {
26
- // Skip parameters already resolved
27
- if (! empty($resolvedParameters)) {
28
- $providedParameters = array_diff_key($providedParameters, $resolvedParameters);
29
- }
30
-
31
- foreach ($providedParameters as $key => $value) {
32
- if (is_int($key)) {
33
- $resolvedParameters[$key] = $value;
34
- }
35
- }
36
-
37
- return $resolvedParameters;
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/invoker/src/ParameterResolver/ParameterResolver.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
-
3
- namespace Invoker\ParameterResolver;
4
-
5
- use ReflectionFunctionAbstract;
6
-
7
- /**
8
- * Resolves the parameters to use to call the callable.
9
- *
10
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
11
- */
12
- interface ParameterResolver
13
- {
14
- /**
15
- * Resolves the parameters to use to call the callable.
16
- *
17
- * `$resolvedParameters` contains parameters that have already been resolved.
18
- *
19
- * Each ParameterResolver must resolve parameters that are not already
20
- * in `$resolvedParameters`. That allows to chain multiple ParameterResolver.
21
- *
22
- * @param ReflectionFunctionAbstract $reflection Reflection object for the callable.
23
- * @param array $providedParameters Parameters provided by the caller.
24
- * @param array $resolvedParameters Parameters resolved (indexed by parameter position).
25
- *
26
- * @return array
27
- */
28
- public function getParameters(
29
- ReflectionFunctionAbstract $reflection,
30
- array $providedParameters,
31
- array $resolvedParameters
32
- );
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/invoker/src/ParameterResolver/ResolverChain.php DELETED
@@ -1,69 +0,0 @@
1
- <?php
2
-
3
- namespace Invoker\ParameterResolver;
4
-
5
- use ReflectionFunctionAbstract;
6
-
7
- /**
8
- * Dispatches the call to other resolvers until all parameters are resolved.
9
- *
10
- * Chain of responsibility pattern.
11
- *
12
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
13
- */
14
- class ResolverChain implements ParameterResolver
15
- {
16
- /**
17
- * @var ParameterResolver[]
18
- */
19
- private $resolvers = array();
20
-
21
- public function __construct(array $resolvers = array())
22
- {
23
- $this->resolvers = $resolvers;
24
- }
25
-
26
- public function getParameters(
27
- ReflectionFunctionAbstract $reflection,
28
- array $providedParameters,
29
- array $resolvedParameters
30
- ) {
31
- $reflectionParameters = $reflection->getParameters();
32
-
33
- foreach ($this->resolvers as $resolver) {
34
- $resolvedParameters = $resolver->getParameters(
35
- $reflection,
36
- $providedParameters,
37
- $resolvedParameters
38
- );
39
-
40
- $diff = array_diff_key($reflectionParameters, $resolvedParameters);
41
- if (empty($diff)) {
42
- // Stop traversing: all parameters are resolved
43
- return $resolvedParameters;
44
- }
45
- }
46
-
47
- return $resolvedParameters;
48
- }
49
-
50
- /**
51
- * Push a parameter resolver after the ones already registered.
52
- *
53
- * @param ParameterResolver $resolver
54
- */
55
- public function appendResolver(ParameterResolver $resolver)
56
- {
57
- $this->resolvers[] = $resolver;
58
- }
59
-
60
- /**
61
- * Insert a parameter resolver before the ones already registered.
62
- *
63
- * @param ParameterResolver $resolver
64
- */
65
- public function prependResolver(ParameterResolver $resolver)
66
- {
67
- array_unshift($this->resolvers, $resolver);
68
- }
69
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/invoker/src/ParameterResolver/TypeHintResolver.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
-
3
- namespace Invoker\ParameterResolver;
4
-
5
- use Invoker\ParameterResolver\ParameterResolver;
6
- use ReflectionFunctionAbstract;
7
-
8
- /**
9
- * Inject entries using type-hints.
10
- *
11
- * Tries to match type-hints with the parameters provided.
12
- *
13
- * @author Felix Becker <f.becker@outlook.com>
14
- */
15
- class TypeHintResolver implements ParameterResolver
16
- {
17
- public function getParameters(
18
- ReflectionFunctionAbstract $reflection,
19
- array $providedParameters,
20
- array $resolvedParameters
21
- ) {
22
- $parameters = $reflection->getParameters();
23
-
24
- // Skip parameters already resolved
25
- if (! empty($resolvedParameters)) {
26
- $parameters = array_diff_key($parameters, $resolvedParameters);
27
- }
28
-
29
- foreach ($parameters as $index => $parameter) {
30
- $parameterClass = $parameter->getClass();
31
-
32
- if ($parameterClass && array_key_exists($parameterClass->name, $providedParameters)) {
33
- $resolvedParameters[$index] = $providedParameters[$parameterClass->name];
34
- }
35
- }
36
-
37
- return $resolvedParameters;
38
- }
39
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/invoker/src/Reflection/CallableReflection.php DELETED
@@ -1,61 +0,0 @@
1
- <?php
2
-
3
- namespace Invoker\Reflection;
4
-
5
- use Invoker\Exception\NotCallableException;
6
-
7
- /**
8
- * Create a reflection object from a callable.
9
- *
10
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
11
- */
12
- class CallableReflection
13
- {
14
- /**
15
- * @param callable $callable
16
- *
17
- * @return \ReflectionFunctionAbstract
18
- *
19
- * @throws NotCallableException
20
- *
21
- * TODO Use the `callable` type-hint once support for PHP 5.4 and up.
22
- */
23
- public static function create($callable)
24
- {
25
- // Closure
26
- if ($callable instanceof \Closure) {
27
- return new \ReflectionFunction($callable);
28
- }
29
-
30
- // Array callable
31
- if (is_array($callable)) {
32
- list($class, $method) = $callable;
33
-
34
- if (! method_exists($class, $method)) {
35
- throw NotCallableException::fromInvalidCallable($callable);
36
- }
37
-
38
- return new \ReflectionMethod($class, $method);
39
- }
40
-
41
- // Callable object (i.e. implementing __invoke())
42
- if (is_object($callable) && method_exists($callable, '__invoke')) {
43
- return new \ReflectionMethod($callable, '__invoke');
44
- }
45
-
46
- // Callable class (i.e. implementing __invoke())
47
- if (is_string($callable) && class_exists($callable) && method_exists($callable, '__invoke')) {
48
- return new \ReflectionMethod($callable, '__invoke');
49
- }
50
-
51
- // Standard function
52
- if (is_string($callable) && function_exists($callable)) {
53
- return new \ReflectionFunction($callable);
54
- }
55
-
56
- throw new NotCallableException(sprintf(
57
- '%s is not a callable',
58
- is_string($callable) ? $callable : 'Instance of ' . get_class($callable)
59
- ));
60
- }
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/.coveralls.yml DELETED
@@ -1,2 +0,0 @@
1
- coverage_clover: clover.xml
2
- json_path: coveralls-upload.json
 
 
addons/lib/ioc/php-di/php-di/.gitattributes DELETED
@@ -1,8 +0,0 @@
1
- # .gitattributes
2
- tests/ export-ignore
3
- website/ export-ignore
4
- doc/ export-ignore
5
- news/ export-ignore
6
-
7
- # Auto detect text files and perform LF normalization
8
- * text=auto
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- /.idea/
2
- /vendor/
3
- /composer.phar
4
- /composer.lock
5
- /theme/
6
- /.couscous/
7
- /website/bower_components/
8
- /website/css/all.min.css
9
- /logo/
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/.travis.yml DELETED
@@ -1,26 +0,0 @@
1
- language: php
2
-
3
- php:
4
- - 5.4
5
- - 5.5
6
- - 5.6
7
- - 7.0
8
- - hhvm
9
-
10
- matrix:
11
- include:
12
- - php: 5.4
13
- env: dependencies=lowest
14
-
15
- before_script:
16
- - composer self-update
17
- - if [[ $(phpenv version-name) == '5.6' ]]; then composer require satooshi/php-coveralls:dev-master -n ; fi
18
- - if [[ $(phpenv version-name) != '5.6' ]]; then composer install -n ; fi
19
- - if [ "$dependencies" = "lowest" ]; then composer update --prefer-lowest --prefer-stable -n; fi;
20
-
21
- script:
22
- - if [[ $(phpenv version-name) == '5.6' ]]; then phpunit --coverage-clover clover.xml ; fi
23
- - if [[ $(phpenv version-name) != '5.6' ]]; then phpunit ; fi
24
-
25
- after_script:
26
- - if [[ $(phpenv version-name) == '5.6' ]]; then php vendor/bin/coveralls -v ; fi
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/404.md DELETED
@@ -1,3 +0,0 @@
1
- ---
2
- layout: 404
3
- ---
 
 
 
addons/lib/ioc/php-di/php-di/CONTRIBUTING.md DELETED
@@ -1,52 +0,0 @@
1
- # Contributing
2
-
3
- [![Build Status](https://travis-ci.org/PHP-DI/PHP-DI.png?branch=master)](https://travis-ci.org/PHP-DI/PHP-DI) [![Coverage Status](https://coveralls.io/repos/PHP-DI/PHP-DI/badge.png?branch=master)](https://coveralls.io/r/PHP-DI/PHP-DI?branch=master)
4
-
5
- PHP-DI is license under the MIT License.
6
-
7
-
8
- ## Set up
9
-
10
- * Check out the sources using git or download them
11
-
12
- ```bash
13
- $ git clone https://github.com/PHP-DI/PHP-DI.git
14
- ```
15
-
16
- * Install the libraries using composer:
17
-
18
- ```bash
19
- $ curl -s http://getcomposer.org/installer | php
20
- $ php composer.phar install
21
- ```
22
-
23
- If you are running Windows or are having trouble, read [the official documentation](http://getcomposer.org/doc/00-intro.md#installation).
24
-
25
-
26
- ## Run the tests
27
-
28
- The tests are run with [PHPUnit](http://www.phpunit.de/manual/current/en/installation.html):
29
-
30
- ```bash
31
- $ phpunit
32
- ```
33
-
34
-
35
- ## Learning the internals
36
-
37
- Read the [How it works](doc/how-it-works.md) documentation.
38
-
39
-
40
- ## What to do?
41
-
42
- - Add tests: pick up uncovered situations in the [code coverage report](https://coveralls.io/r/PHP-DI/PHP-DI)
43
- - Resolve issues: [issue list](https://github.com/PHP-DI/PHP-DI/issues)
44
- - Improve the documentation
45
- - …
46
-
47
-
48
- ## Coding style
49
-
50
- The code follows PSR0, PSR1 and [PSR2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md).
51
-
52
- Also, do not hesitate to add your name to the author list of a class in the docblock if you improve it.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/LICENSE DELETED
@@ -1,18 +0,0 @@
1
- PHP-DI - PHP Dependency Injection
2
-
3
- Copyright (C) Matthieu Napoli
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6
- associated documentation files (the "Software"), to deal in the Software without restriction,
7
- including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
- and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
9
- subject to the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be included in all copies or substantial
12
- portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
15
- NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
18
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/README.md DELETED
@@ -1,23 +0,0 @@
1
- ---
2
- layout: home
3
- ---
4
-
5
- PHP-DI is a Dependency Injection Container made for humans.
6
-
7
- [![Build Status](https://img.shields.io/travis/PHP-DI/PHP-DI.svg?style=flat-square)](https://travis-ci.org/PHP-DI/PHP-DI)
8
- [![HHVM Status](https://img.shields.io/hhvm/php-di/php-di.svg?style=flat-square)](http://hhvm.h4cc.de/package/php-di/php-di)
9
- [![Coverage Status](https://img.shields.io/coveralls/PHP-DI/PHP-DI/master.svg?style=flat-square)](https://coveralls.io/r/PHP-DI/PHP-DI?branch=master)
10
- [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/PHP-DI/PHP-DI.svg?style=flat-square)](https://scrutinizer-ci.com/g/PHP-DI/PHP-DI/?branch=master)
11
- [![Latest Version](https://img.shields.io/github/release/PHP-DI/PHP-DI.svg?style=flat-square)](https://packagist.org/packages/php-di/php-di)
12
- [![Total Downloads](https://img.shields.io/packagist/dt/mnapoli/PHP-DI.svg?style=flat-square)](https://packagist.org/packages/mnapoli/php-di)
13
-
14
- [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/PHP-DI/PHP-DI.svg)](http://isitmaintained.com/project/PHP-DI/PHP-DI "Average time to resolve an issue")
15
- [![Percentage of issues still open](http://isitmaintained.com/badge/open/PHP-DI/PHP-DI.svg)](http://isitmaintained.com/project/PHP-DI/PHP-DI "Percentage of issues still open")
16
-
17
- It is meant to be practical, powerful, and framework-agnostic.
18
-
19
- Read more on the website: **[php-di.org](http://php-di.org)**
20
-
21
- Join us in the Gitter chat room: [![Gitter chat](https://badges.gitter.im/PHP-DI/PHP-DI.png)](https://gitter.im/PHP-DI/PHP-DI)
22
-
23
- Support is always appreciated: [![Gratipay](https://img.shields.io/gratipay/mnapoli.svg)](https://gratipay.com/mnapoli/)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/change-log.md DELETED
@@ -1,280 +0,0 @@
1
- # Change log
2
-
3
- ## 5.0
4
-
5
- This is the complete change log. You can also read the [migration guide](doc/migration/5.0.md) for upgrading, or [the news article](news/15-php-di-5-0-released.md) for a nicer introduction to this new version.
6
-
7
- Improvements:
8
-
9
- - Moved to an organization on GitHub: [github.com/PHP-DI/PHP-DI](https://github.com/PHP-DI/PHP-DI)
10
- - The package has been renamed to: from `mnapoli/php-di` to [`php-di/php-di`](https://packagist.org/packages/php-di/php-di)
11
- - New [Silex integration](doc/frameworks/silex.md)
12
- - Lighter package: from 10 to 3 Composer dependencies!
13
- - [#235](https://github.com/PHP-DI/PHP-DI/issues/235): `DI\link()` is now deprecated in favor of `DI\get()`. There is no BC break as `DI\link()` still works.
14
- - [#207](https://github.com/PHP-DI/PHP-DI/issues/207): Support for `DI\link()` in arrays
15
- - [#203](https://github.com/PHP-DI/PHP-DI/issues/203): New `DI\string()` helper ([documentation](doc/php-definitions.md))
16
- - [#208](https://github.com/PHP-DI/PHP-DI/issues/208): Support for nested definitions
17
- - [#226](https://github.com/PHP-DI/PHP-DI/pull/226): `DI\factory()` can now be omitted with closures:
18
-
19
- ```php
20
- // before
21
- 'My\Class' => DI\factory(function () { ... })
22
- // now (optional shortcut)
23
- 'My\Class' => function () { ... }
24
- ```
25
- - [#193](https://github.com/PHP-DI/PHP-DI/issues/193): `DI\object()->method()` now supports calling the same method twice (or more).
26
- - [#248](https://github.com/PHP-DI/PHP-DI/issues/248): New `DI\decorate()` helper to decorate a previously defined entry ([documentation](doc/definition-overriding.md))
27
- - [#215](https://github.com/PHP-DI/PHP-DI/pull/215): New `DI\add()` helper to add entries to an existing array ([documentation](doc/definition-overriding.md))
28
- - [#218](https://github.com/PHP-DI/PHP-DI/issues/218): `ContainerBuilder::addDefinitions()` can now take an array of definitions
29
- - [#211](https://github.com/PHP-DI/PHP-DI/pull/211): `ContainerBuilder::addDefinitions()` is now fluent (return `$this`)
30
- - [#250](https://github.com/PHP-DI/PHP-DI/issues/250): `Container::call()` now also accepts parameters not indexed by name as well as embedded definitions ([documentation](doc/container.md))
31
- - Various performance improvements, e.g. lower the number of files loaded, simpler architecture, …
32
-
33
- BC breaks:
34
-
35
- - PHP-DI now requires a version of PHP >= 5.4.0
36
- - The package is lighter by default:
37
- - [#251](https://github.com/PHP-DI/PHP-DI/issues/251): Annotations are disabled by default, if you use annotations enable them with `$containerBuilder->useAnnotations(true)`. Additionally the `doctrine/annotations` package isn't required by default anymore, so you also need to run `composer require doctrine/annotations`.
38
- - `doctrine/cache` is not installed by default anymore, you need to require it in `composer.json` (`~1.0`) if you want to configure a cache for PHP-DI
39
- - [#198](https://github.com/PHP-DI/PHP-DI/issues/198): `ocramius/proxy-manager` is not installed by default anymore, you need to require it in `composer.json` (`~1.0`) if you want to use **lazy injection**
40
- - Closures are now converted into factory definitions automatically. If you ever defined a closure as a value (e.g. to have the closure injected in a class), you need to wrap the closure with the new `DI\value()` helper.
41
- - [#223](https://github.com/PHP-DI/PHP-DI/issues/223): `DI\ContainerInterface` was deprecated since v4.1 and has been removed
42
-
43
- Internal changes in case you were replacing/extending some parts:
44
-
45
- - the definition sources architecture has been refactored, if you defined custom definition sources you will need to update your code (it should be much easier now)
46
- - [#252](https://github.com/PHP-DI/PHP-DI/pull/252): `DI\Scope` internal implementation has changed. You are encouraged to use the constants (`DI\Scope::SINGLETON` and `DI\Scope::PROTOTYPE`) instead of the static methods, but backward compatibility is kept (static methods still work).
47
- - [#241](https://github.com/PHP-DI/PHP-DI/issues/241): `Container::call()` now uses the *Invoker* external library
48
-
49
- ## 4.4
50
-
51
- Read the [news entry](news/13-php-di-4-4-released.md).
52
-
53
- - [#185](https://github.com/PHP-DI/PHP-DI/issues/185) Support for invokable objects in `Container::call()`
54
- - [#192](https://github.com/PHP-DI/PHP-DI/pull/192) Support for invokable classes in `Container::call()` (will instantiate the class)
55
- - [#184](https://github.com/PHP-DI/PHP-DI/pull/184) Option to ignore phpdoc errors
56
-
57
- ## 4.3
58
-
59
- Read the [news entry](news/11-php-di-4-3-released.md).
60
-
61
- - [#176](https://github.com/PHP-DI/PHP-DI/pull/176) New definition type for reading environment variables: `DI\env()`
62
- - [#181](https://github.com/PHP-DI/PHP-DI/pull/181) `DI\FactoryInterface` and `DI\InvokerInterface` are now auto-registered inside the container so that you can inject them without any configuration needed
63
- - [#173](https://github.com/PHP-DI/PHP-DI/pull/173) `$container->call(['MyClass', 'method]);` will get `MyClass` from the container if `method()` is not a static method
64
-
65
- ## 4.2.2
66
-
67
- - Fixed [#180](https://github.com/PHP-DI/PHP-DI/pull/180): `Container::call()` with object methods (`[$object, 'method']`) is now supported
68
-
69
- ## 4.2.1
70
-
71
- - Support for PHP 5.3.3, which was previously incomplete because of a bug in the reflection (there is now a workaround for this bug)
72
-
73
- But if you can, seriously avoid this (really old) PHP version and upgrade.
74
-
75
- ## 4.2
76
-
77
- Read the [news entry](news/10-php-di-4-2-released.md).
78
-
79
- **Minor BC-break**: Optional parameters (that were not configured) were injected, they are now ignored, which is what naturally makes sense since they are optional.
80
- Example:
81
-
82
- ```php
83
- public function __construct(Bar $bar = null)
84
- {
85
- $this->bar = $bar ?: $this->createDefaultBar();
86
- }
87
- ```
88
-
89
- Before 4.2, PHP-DI would try to inject a `Bar` instance. From 4.2 and onwards, it will inject `null`.
90
-
91
- Of course, you can still explicitly define an injection for the optional parameters and that will work.
92
-
93
- All changes:
94
-
95
- * [#162](https://github.com/PHP-DI/PHP-DI/pull/162) Added `Container::call()` to call functions with dependency injection
96
- * [#156](https://github.com/PHP-DI/PHP-DI/issues/156) Wildcards (`*`) in definitions
97
- * [#164](https://github.com/PHP-DI/PHP-DI/issues/164) Prototype scope is now available for `factory()` definitions too
98
- * FIXED [#168](https://github.com/PHP-DI/PHP-DI/pull/168) `Container::has()` now returns false for interfaces and abstract classes that are not mapped in the definitions
99
- * FIXED [#171](https://github.com/PHP-DI/PHP-DI/issues/171) Optional parameters are now ignored (not injected) if not set in the definitions (see the BC-break warning above)
100
-
101
- ## 4.1
102
-
103
- Read the [news entry](news/09-php-di-4-1-released.md).
104
-
105
- BC-breaks: None.
106
-
107
- * [#138](https://github.com/PHP-DI/PHP-DI/issues/138) [Container-interop](https://github.com/container-interop/container-interop) compliance
108
- * [#143](https://github.com/PHP-DI/PHP-DI/issues/143) Much more explicit exception messages
109
- * [#157](https://github.com/PHP-DI/PHP-DI/issues/157) HHVM support
110
- * [#158](https://github.com/PHP-DI/PHP-DI/issues/158) Improved the documentation for [Symfony 2 integration](http://php-di.org/doc/frameworks/symfony2.html)
111
-
112
- ## 4.0
113
-
114
- Major changes:
115
-
116
- * The configuration format has changed ([read more here to understand why](news/06-php-di-4-0-new-definitions.md))
117
-
118
- Read the migration guide if you are using 3.x: [Migration guide from 3.x to 4.0](doc/migration/4.0.md).
119
-
120
- BC-breaks:
121
-
122
- * YAML, XML and JSON definitions have been removed, and the PHP definition format has changed (see above)
123
- * `ContainerSingleton` has been removed
124
- * You cannot configure an injection as lazy anymore, you can only configure a container entry as lazy
125
- * The Container constructor now takes mandatory parameters. Use the ContainerBuilder to create a Container.
126
- * Removed `ContainerBuilder::setDefinitionsValidation()` (no definition validation anymore)
127
- * `ContainerBuilder::useReflection()` is now named: `ContainerBuilder::useAutowiring()`
128
- * `ContainerBuilder::addDefinitionsFromFile()` is now named: `ContainerBuilder::addDefinitions()`
129
- * The `$proxy` parameter in `Container::get($name, $proxy = true)` hase been removed. To get a proxy, you now need to define an entry as "lazy".
130
-
131
- Other changes:
132
-
133
- * Added `ContainerInterface` and `FactoryInterface`, both implemented by the container.
134
- * [#115](https://github.com/PHP-DI/PHP-DI/issues/115) Added `Container::has()`
135
- * [#142](https://github.com/PHP-DI/PHP-DI/issues/142) Added `Container::make()` to resolve an entry
136
- * [#127](https://github.com/PHP-DI/PHP-DI/issues/127) Added support for cases where PHP-DI is wrapped by another container (like Acclimate): PHP-DI can now use the wrapping container to perform injections
137
- * [#128](https://github.com/PHP-DI/PHP-DI/issues/128) Configure entry aliases
138
- * [#110](https://github.com/PHP-DI/PHP-DI/issues/110) XML definitions are not supported anymore
139
- * [#122](https://github.com/PHP-DI/PHP-DI/issues/122) JSON definitions are not supported anymore
140
- * `ContainerSingleton` has finally been removed
141
- * Added `ContainerBuilder::buildDevContainer()` to get started with a default container very easily.
142
- * [#99](https://github.com/PHP-DI/PHP-DI/issues/99) Fixed "`@param` with PHP internal type throws exception"
143
-
144
- ## 3.5.1
145
-
146
- * FIXED [#126](https://github.com/PHP-DI/PHP-DI/issues/126): `Container::set` without effect if a value has already been set and retrieved
147
-
148
- ## 3.5
149
-
150
- Read the [news entry](news/05-php-di-3-5.md).
151
-
152
- * Importing `@Inject` and `@Injectable` annotations is now optional! It means that you don't have to write `use DI\Annotation\Inject` anymore
153
- * FIXED [#124](https://github.com/PHP-DI/PHP-DI/issues/124): `@Injects` annotation conflicts with other annotations
154
-
155
- ## 3.4
156
-
157
- Read the [news entry](news/04-php-di-3-4.md).
158
-
159
- * [#106](https://github.com/PHP-DI/PHP-DI/pull/106) You can now define arrays of values (in YAML, PHP, …) thanks to [@unkind](https://github.com/unkind)
160
- * [#98](https://github.com/PHP-DI/PHP-DI/issues/98) `ContainerBuilder` is now fluent thanks to [@drdamour](https://github.com/drdamour)
161
- * [#101](https://github.com/PHP-DI/PHP-DI/pull/101) Optional parameters are now supported: if you don't define a value to inject, their default value will be used
162
- * XML definitions have been deprecated, there weren't even documented and were not maintained. They will be removed in 4.0.
163
- * FIXED [#100](https://github.com/PHP-DI/PHP-DI/issues/100): bug for lazy injection in constructors
164
-
165
- ## 3.3
166
-
167
- Read the [news entry](news/03-php-di-3-3.md).
168
-
169
- * Inject dependencies on an existing instance with `Container::injectOn` (work from [Jeff Flitton](https://github.com/jflitton): [#89](https://github.com/PHP-DI/PHP-DI/pull/89)).
170
- * [#86](https://github.com/PHP-DI/PHP-DI/issues/86): Optimized definition lookup (faster)
171
- * FIXED [#87](https://github.com/PHP-DI/PHP-DI/issues/87): Rare bug in the `PhpDocParser`, fixed by [drdamour](https://github.com/drdamour)
172
-
173
- ## 3.2
174
-
175
- Read the [news entry](news/02-php-di-3-2.md).
176
-
177
- Small BC-break: PHP-DI 3.0 and 3.1 injected properties before calling the constructor. This was confusing and [not supported for internal classes](https://github.com/PHP-DI/PHP-DI/issues/74).
178
- From 3.2 and on, properties are injected after calling the constructor.
179
-
180
- * **[Lazy injection](doc/lazy-injection.md)**: it is now possible to use lazy injection on properties and methods (setters and constructors).
181
- * Lazy dependencies are now proxies that extend the class they proxy, so type-hinting works.
182
- * Addition of the **`ContainerBuilder`** object, that helps to [create and configure a `Container`](doc/container-configuration.md).
183
- * Some methods for configuring the Container have gone **deprecated** in favor of the `ContainerBuilder`. Fear not, these deprecated methods will remain until next major version (4.0).
184
- * `Container::useReflection`, use ContainerBuilder::useReflection instead
185
- * `Container::useAnnotations`, use ContainerBuilder::useAnnotations instead
186
- * `Container::setDefinitionCache`, use ContainerBuilder::setDefinitionCache instead
187
- * `Container::setDefinitionsValidation`, use ContainerBuilder::setDefinitionsValidation instead
188
- * The container is now auto-registered (as 'DI\Container'). You can now inject the container without registering it.
189
-
190
- ## 3.1.1
191
-
192
- * Value definitions (`$container->set('foo', 80)`) are not cached anymore
193
- * FIXED [#82](https://github.com/PHP-DI/PHP-DI/issues/82): Serialization error when using a cache
194
-
195
- ## 3.1
196
-
197
- Read the [news entry](news/01-php-di-3-1.md).
198
-
199
- * Zend Framework 1 integration through the [PHP-DI-ZF1 project](https://github.com/PHP-DI/PHP-DI-ZF1)
200
- * Fixed the order of priorities when you mix different definition sources (reflection, annotations, files, …). See [Definition overriding](doc/definition-overriding.md)
201
- * Now possible to define null values with `$container->set('foo', null)` (see [#79](https://github.com/PHP-DI/PHP-DI/issues/79)).
202
- * Deprecated usage of `ContainerSingleton`, will be removed in next major version (4.0)
203
-
204
- ## 3.0.6
205
-
206
- * FIXED [#76](https://github.com/PHP-DI/PHP-DI/issues/76): Definition conflict when setting a closure for a class name
207
-
208
- ## 3.0.5
209
-
210
- * FIXED [#70](https://github.com/PHP-DI/PHP-DI/issues/70): Definition conflict when setting a value for a class name
211
-
212
- ## 3.0.4
213
-
214
- * FIXED [#69](https://github.com/PHP-DI/PHP-DI/issues/69): YamlDefinitionFileLoader crashes if YAML file is empty
215
-
216
- ## 3.0.3
217
-
218
- * Fixed over-restrictive dependencies in composer.json
219
-
220
- ## 3.0.2
221
-
222
- * [#64](https://github.com/PHP-DI/PHP-DI/issues/64): Non PHP-DI exceptions are not captured-rethrown anymore when injecting dependencies (cleaner stack trace)
223
-
224
- ## 3.0.1
225
-
226
- * [#62](https://github.com/PHP-DI/PHP-DI/issues/62): When using aliases, definitions are now merged
227
-
228
- ## 3.0
229
-
230
- Major compatibility breaks with 2.x.
231
-
232
- * The container is no longer a Singleton (but `ContainerSingleton::getInstance()` is available for fools who like it)
233
- * Setter injection
234
- * Constructor injection
235
- * Scopes: singleton (share the same instance of the class) or prototype (create a new instance each time it is fetched). Defined at class level.
236
- * Configuration is reworked from scratch. Now every configuration backend can do 100% of the job.
237
- * Provided configuration backends:
238
- * Reflection
239
- * Annotations: @Inject, @Injectable
240
- * PHP code (`Container::set()`)
241
- * PHP array
242
- * YAML file
243
- * As a consequence, annotations are not mandatory anymore, all functionalities can be used with or without annotations.
244
- * Renamed `DI\Annotations\` to `DI\Annotation\`
245
- * `Container` no longer implements ArrayAccess, use only `$container->get($key)` now
246
- * ZF1 integration broken and removed (work in progress for next releases)
247
- * Code now follows PSR1 and PSR2 coding styles
248
- * FIXED: [#58](https://github.com/PHP-DI/PHP-DI/issues/58) Getting a proxy of an alias didn't work
249
-
250
- ## 2.1
251
-
252
- * `use` statements to import classes from other namespaces are now taken into account with the `@var` annotation
253
- * Updated and lightened the dependencies : `doctrine/common` has been replaced with more specific `doctrine/annotations` and `doctrine/cache`
254
-
255
- ## 2.0
256
-
257
- Major compatibility breaks with 1.x.
258
-
259
- * `Container::resolveDependencies()` has been renamed to `Container::injectAll()`
260
- * Dependencies are now injected **before** the constructor is called, and thus are available in the constructor
261
- * Merged `@Value` annotation with `@Inject`: no difference between value and bean injection anymore
262
- * Container implements ArrayAccess for get() and set() (`$container['db.host'] = 'localhost';`)
263
- * Ini configuration files removed: configuration is done in PHP
264
- * Allow to define beans within closures for lazy-loading
265
- * Switched to MIT License
266
-
267
- Warning:
268
-
269
- * If you use PHP 5.3 and __wakeup() methods, they will be called when PHP-DI creates new instances of those classes.
270
-
271
- ## 1.1
272
-
273
- * Caching of annotations based on Doctrine caches
274
-
275
- ## 1.0
276
-
277
- * DependencyManager renamed to Container
278
- * Refactored basic Container usage with `get` and `set`
279
- * Allow named injection `@Inject(name="")`
280
- * Zend Framework integration
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/composer.json DELETED
@@ -1,40 +0,0 @@
1
- {
2
- "name": "php-di/php-di",
3
- "type": "library",
4
- "description": "The dependency injection container for humans",
5
- "keywords": ["di", "dependency injection", "container"],
6
- "homepage": "http://php-di.org/",
7
- "license": "MIT",
8
- "autoload": {
9
- "psr-4": {
10
- "DI\\": "src/DI/"
11
- },
12
- "files": [
13
- "src/DI/functions.php"
14
- ]
15
- },
16
- "autoload-dev": {
17
- "psr-4": {
18
- "DI\\Test\\IntegrationTest\\": "tests/IntegrationTest/",
19
- "DI\\Test\\UnitTest\\": "tests/UnitTest/"
20
- }
21
- },
22
- "require": {
23
- "php": ">=5.4.0",
24
- "container-interop/container-interop": "~1.0",
25
- "php-di/invoker": "~1.0",
26
- "php-di/phpdoc-reader": "~2.0"
27
- },
28
- "require-dev": {
29
- "phpunit/phpunit": "~4.5",
30
- "mnapoli/phpunit-easymock": "~0.1.4",
31
- "doctrine/cache": "~1.0",
32
- "doctrine/annotations": "~1.2",
33
- "ocramius/proxy-manager": "~1.0"
34
- },
35
- "suggest": {
36
- "doctrine/cache": "Install it if you want to use the cache (version ~1.0)",
37
- "doctrine/annotations": "Install it if you want to use annotations (version ~1.2)",
38
- "ocramius/proxy-manager": "Install it if you want to use lazy injection (version ~1.0)"
39
- }
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/couscous.yml DELETED
@@ -1,107 +0,0 @@
1
- baseUrl: http://php-di.org
2
-
3
- scripts:
4
- before:
5
- - lessc --clean-css website/less/main.less website/css/all.min.css
6
-
7
- menu:
8
- items:
9
- introduction:
10
- section: Introduction
11
- items:
12
- getting-started:
13
- text: Getting started
14
- url: doc/getting-started.html
15
- understanding-di:
16
- text: Understanding dependency injection
17
- url: doc/understanding-di.html
18
- best-practices:
19
- text: "\"Best practices\" guide"
20
- url: doc/best-practices.html
21
- usage:
22
- section: Usage
23
- items:
24
- container-configuration:
25
- text: Configuring the container
26
- url: doc/container-configuration.html
27
- container:
28
- text: Using the container
29
- url: doc/container.html
30
- definition:
31
- section: Definitions
32
- items:
33
- introduction:
34
- text: Introduction
35
- url: doc/definition.html
36
- autowiring:
37
- text: Autowiring
38
- url: doc/autowiring.html
39
- php:
40
- text: PHP definitions
41
- url: doc/php-definitions.html
42
- annotations:
43
- text: Annotations
44
- url: doc/annotations.html
45
- definition-overriding:
46
- text: Definition extensions and overriding
47
- url: doc/definition-overriding.html
48
- frameworks:
49
- section: Frameworks
50
- items:
51
- symfony2:
52
- text: Symfony 2
53
- url: doc/frameworks/symfony2.html
54
- silex:
55
- text: Silex
56
- url: doc/frameworks/silex.html
57
- zf1:
58
- text: Zend Framework 1
59
- url: doc/frameworks/zf1.html
60
- silly:
61
- text: Silly
62
- url: doc/frameworks/silly.html
63
- advanced:
64
- section: Advanced topics
65
- items:
66
- performances:
67
- text: Performances
68
- url: doc/performances.html
69
- scopes:
70
- text: Scopes
71
- url: doc/scopes.html
72
- lazy-injection:
73
- text: Lazy injection
74
- url: doc/lazy-injection.html
75
- inject-on-instance:
76
- text: Inject on an existing instance
77
- url: doc/inject-on-instance.html
78
- environments:
79
- text: Injections depending on the environment
80
- url: doc/environments.html
81
- migration:
82
- section: Migration guides
83
- items:
84
- 4:
85
- text: From PHP-DI 3.x to 4.0
86
- url: doc/migration/4.0.html
87
- 5:
88
- text: From PHP-DI 4.x to 5.0
89
- url: doc/migration/5.0.html
90
- internals:
91
- section: Internals
92
- items:
93
- contributing:
94
- text: Contributing
95
- url: contributing.html
96
- how-it-works:
97
- text: How PHP-DI works
98
- url: doc/how-it-works.html
99
- versions:
100
- section: Old documentation
101
- items:
102
- v3:
103
- text: PHP-DI 3.x
104
- absoluteUrl: https://github.com/PHP-DI/PHP-DI/tree/3.x/doc
105
- v4:
106
- text: PHP-DI 4.x
107
- absoluteUrl: https://github.com/PHP-DI/PHP-DI/tree/4.x/doc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/phpunit.xml.dist DELETED
@@ -1,30 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!--
3
- phpunit -c phpunit.xml
4
- -->
5
- <phpunit backupGlobals="false"
6
- backupStaticAttributes="false"
7
- colors="true"
8
- convertErrorsToExceptions="true"
9
- convertNoticesToExceptions="true"
10
- convertWarningsToExceptions="true"
11
- syntaxCheck="true"
12
- forceCoversAnnotation="true"
13
- bootstrap="./vendor/autoload.php">
14
-
15
- <testsuites>
16
- <testsuite name="unit">
17
- <directory>./tests/UnitTest/</directory>
18
- </testsuite>
19
- <testsuite name="integration">
20
- <directory>./tests/IntegrationTest/</directory>
21
- </testsuite>
22
- </testsuites>
23
-
24
- <filter>
25
- <whitelist processUncoveredFilesFromWhitelist="true">
26
- <directory suffix=".php">src</directory>
27
- </whitelist>
28
- </filter>
29
-
30
- </phpunit>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/Annotation/Inject.php DELETED
@@ -1,95 +0,0 @@
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 DI\Annotation;
11
-
12
- use 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/lib/ioc/php-di/php-di/src/DI/Annotation/Injectable.php DELETED
@@ -1,74 +0,0 @@
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 DI\Annotation;
11
-
12
- use 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/lib/ioc/php-di/php-di/src/DI/Container.php DELETED
@@ -1,340 +0,0 @@
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 DI;
11
-
12
- use DI\Definition\ObjectDefinition;
13
- use DI\Definition\Definition;
14
- use DI\Definition\FactoryDefinition;
15
- use DI\Definition\InstanceDefinition;
16
- use DI\Definition\Resolver\ResolverDispatcher;
17
- use DI\Definition\Source\CachedDefinitionSource;
18
- use DI\Definition\Source\DefinitionSource;
19
- use DI\Definition\Source\MutableDefinitionSource;
20
- use DI\Definition\Helper\DefinitionHelper;
21
- use DI\Definition\Resolver\DefinitionResolver;
22
- use DI\Invoker\DefinitionParameterResolver;
23
- use DI\Proxy\ProxyFactory;
24
- use Exception;
25
- use Interop\Container\ContainerInterface;
26
- use InvalidArgumentException;
27
- use Invoker\Invoker;
28
- use Invoker\ParameterResolver\AssociativeArrayResolver;
29
- use Invoker\ParameterResolver\Container\TypeHintContainerResolver;
30
- use Invoker\ParameterResolver\NumericArrayResolver;
31
- use Invoker\ParameterResolver\ResolverChain;
32
-
33
- /**
34
- * Dependency Injection Container.
35
- *
36
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
37
- */
38
- class Container implements ContainerInterface, FactoryInterface, \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 \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['DI\Container'] = $this;
95
- $this->singletonEntries['DI\ContainerInterface'] = $this;
96
- $this->singletonEntries['DI\FactoryInterface'] = $this;
97
- $this->singletonEntries['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. 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 \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/lib/ioc/php-di/php-di/src/DI/ContainerBuilder.php DELETED
@@ -1,258 +0,0 @@
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 DI;
11
-
12
- use DI\Definition\Source\AnnotationReader;
13
- use DI\Definition\Source\DefinitionArray;
14
- use DI\Definition\Source\CachedDefinitionSource;
15
- use DI\Definition\Source\DefinitionSource;
16
- use DI\Definition\Source\DefinitionFile;
17
- use DI\Definition\Source\Autowiring;
18
- use DI\Definition\Source\SourceChain;
19
- use DI\Proxy\ProxyFactory;
20
- use Doctrine\Common\Cache\Cache;
21
- use 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 = '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/lib/ioc/php-di/php-di/src/DI/Debug.php DELETED
@@ -1,39 +0,0 @@
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 DI;
11
-
12
- use DI\Definition\Definition;
13
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/AbstractFunctionCallDefinition.php DELETED
@@ -1,82 +0,0 @@
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 DI\Definition;
11
-
12
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/AliasDefinition.php DELETED
@@ -1,66 +0,0 @@
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 DI\Definition;
11
-
12
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/ArrayDefinition.php DELETED
@@ -1,66 +0,0 @@
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 DI\Definition;
11
-
12
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/ArrayDefinitionExtension.php DELETED
@@ -1,61 +0,0 @@
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 DI\Definition;
11
-
12
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/CacheableDefinition.php DELETED
@@ -1,19 +0,0 @@
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 DI\Definition;
11
-
12
- /**
13
- * Cacheable definition
14
- *
15
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
16
- */
17
- interface CacheableDefinition extends Definition
18
- {
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/Definition/DecoratorDefinition.php DELETED
@@ -1,48 +0,0 @@
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 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/lib/ioc/php-di/php-di/src/DI/Definition/Definition.php DELETED
@@ -1,32 +0,0 @@
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 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/lib/ioc/php-di/php-di/src/DI/Definition/Dumper/AliasDefinitionDumper.php DELETED
@@ -1,48 +0,0 @@
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 DI\Definition\Dumper;
11
-
12
- use DI\Definition\AliasDefinition;
13
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Dumper/ArrayDefinitionDumper.php DELETED
@@ -1,65 +0,0 @@
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 DI\Definition\Dumper;
11
-
12
- use DI\Debug;
13
- use DI\Definition\ArrayDefinition;
14
- use DI\Definition\Definition;
15
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Dumper/DecoratorDefinitionDumper.php DELETED
@@ -1,37 +0,0 @@
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 DI\Definition\Dumper;
11
-
12
- use DI\Definition\DecoratorDefinition;
13
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Dumper/DefinitionDumper.php DELETED
@@ -1,30 +0,0 @@
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 DI\Definition\Dumper;
11
-
12
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Dumper/DefinitionDumperDispatcher.php DELETED
@@ -1,68 +0,0 @@
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 DI\Definition\Dumper;
11
-
12
- use 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
- 'DI\Definition\ValueDefinition' => new ValueDefinitionDumper(),
60
- 'DI\Definition\FactoryDefinition' => new FactoryDefinitionDumper(),
61
- 'DI\Definition\DecoratorDefinition' => new DecoratorDefinitionDumper(),
62
- 'DI\Definition\AliasDefinition' => new AliasDefinitionDumper(),
63
- 'DI\Definition\ObjectDefinition' => new ObjectDefinitionDumper(),
64
- 'DI\Definition\EnvironmentVariableDefinition' => new EnvironmentVariableDefinitionDumper(),
65
- ];
66
- }
67
- }
68
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/Definition/Dumper/EnvironmentVariableDefinitionDumper.php DELETED
@@ -1,63 +0,0 @@
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 DI\Definition\Dumper;
11
-
12
- use DI\Debug;
13
- use DI\Definition\Definition;
14
- use DI\Definition\EntryReference;
15
- use DI\Definition\EnvironmentVariableDefinition;
16
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Dumper/FactoryDefinitionDumper.php DELETED
@@ -1,37 +0,0 @@
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 DI\Definition\Dumper;
11
-
12
- use DI\Definition\Definition;
13
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Dumper/ObjectDefinitionDumper.php DELETED
@@ -1,156 +0,0 @@
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 DI\Definition\Dumper;
11
-
12
- use DI\Definition\ObjectDefinition;
13
- use DI\Definition\ObjectDefinition\MethodInjection;
14
- use DI\Definition\Definition;
15
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Dumper/StringDefinitionDumper.php DELETED
@@ -1,37 +0,0 @@
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 DI\Definition\Dumper;
11
-
12
- use DI\Definition\Definition;
13
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Dumper/ValueDefinitionDumper.php DELETED
@@ -1,44 +0,0 @@
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 DI\Definition\Dumper;
11
-
12
- use DI\Definition\Definition;
13
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/EntryReference.php DELETED
@@ -1,52 +0,0 @@
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 DI\Definition;
11
-
12
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/EnvironmentVariableDefinition.php DELETED
@@ -1,116 +0,0 @@
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 DI\Definition;
11
-
12
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Exception/AnnotationException.php DELETED
@@ -1,19 +0,0 @@
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 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/lib/ioc/php-di/php-di/src/DI/Definition/Exception/DefinitionException.php DELETED
@@ -1,30 +0,0 @@
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 DI\Definition\Exception;
11
-
12
- use DI\Debug;
13
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/FactoryDefinition.php DELETED
@@ -1,75 +0,0 @@
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 DI\Definition;
11
-
12
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/HasSubDefinition.php DELETED
@@ -1,28 +0,0 @@
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 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/lib/ioc/php-di/php-di/src/DI/Definition/Helper/ArrayDefinitionExtensionHelper.php DELETED
@@ -1,46 +0,0 @@
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 DI\Definition\Helper;
11
-
12
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Helper/DefinitionHelper.php DELETED
@@ -1,24 +0,0 @@
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 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 \DI\Definition\Definition
22
- */
23
- public function getDefinition($entryName);
24
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/Definition/Helper/EnvironmentVariableDefinitionHelper.php DELETED
@@ -1,64 +0,0 @@
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 DI\Definition\Helper;
11
-
12
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Helper/FactoryDefinitionHelper.php DELETED
@@ -1,72 +0,0 @@
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 DI\Definition\Helper;
11
-
12
- use DI\Definition\DecoratorDefinition;
13
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Helper/ObjectDefinitionHelper.php DELETED
@@ -1,273 +0,0 @@
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 DI\Definition\Helper;
11
-
12
- use DI\Definition\ObjectDefinition;
13
- use DI\Definition\ObjectDefinition\MethodInjection;
14
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Helper/StringDefinitionHelper.php DELETED
@@ -1,39 +0,0 @@
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 DI\Definition\Helper;
11
-
12
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Helper/ValueDefinitionHelper.php DELETED
@@ -1,42 +0,0 @@
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 DI\Definition\Helper;
11
-
12
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/InstanceDefinition.php DELETED
@@ -1,76 +0,0 @@
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 DI\Definition;
11
-
12
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/ObjectDefinition.php DELETED
@@ -1,294 +0,0 @@
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 DI\Definition;
11
-
12
- use DI\Definition\ObjectDefinition\MethodInjection;
13
- use DI\Definition\ObjectDefinition\PropertyInjection;
14
- use DI\Definition\Exception\DefinitionException;
15
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/ObjectDefinition/MethodInjection.php DELETED
@@ -1,54 +0,0 @@
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 DI\Definition\ObjectDefinition;
11
-
12
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/ObjectDefinition/PropertyInjection.php DELETED
@@ -1,56 +0,0 @@
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 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/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/AliasResolver.php DELETED
@@ -1,77 +0,0 @@
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 DI\Definition\Resolver;
11
-
12
- use DI\Definition\AliasDefinition;
13
- use DI\Definition\Definition;
14
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/ArrayResolver.php DELETED
@@ -1,105 +0,0 @@
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 DI\Definition\Resolver;
11
-
12
- use DI\Definition\ArrayDefinition;
13
- use DI\Definition\Definition;
14
- use DI\Definition\Helper\DefinitionHelper;
15
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/DecoratorResolver.php DELETED
@@ -1,107 +0,0 @@
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 DI\Definition\Resolver;
11
-
12
- use DI\Definition\DecoratorDefinition;
13
- use DI\Definition\Exception\DefinitionException;
14
- use DI\Definition\Definition;
15
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/DefinitionResolver.php DELETED
@@ -1,44 +0,0 @@
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 DI\Definition\Resolver;
11
-
12
- use DI\Definition\Definition;
13
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/EnvironmentVariableResolver.php DELETED
@@ -1,94 +0,0 @@
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 DI\Definition\Resolver;
11
-
12
- use DI\Definition\Definition;
13
- use DI\Definition\EnvironmentVariableDefinition;
14
- use DI\Definition\Exception\DefinitionException;
15
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/FactoryResolver.php DELETED
@@ -1,85 +0,0 @@
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 DI\Definition\Resolver;
11
-
12
- use DI\Definition\Exception\DefinitionException;
13
- use DI\Definition\FactoryDefinition;
14
- use DI\Definition\Definition;
15
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/InstanceInjector.php DELETED
@@ -1,67 +0,0 @@
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 DI\Definition\Resolver;
11
-
12
- use DI\Definition\Definition;
13
- use DI\Definition\InstanceDefinition;
14
- use DI\DependencyException;
15
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/ObjectCreator.php DELETED
@@ -1,266 +0,0 @@
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 DI\Definition\Resolver;
11
-
12
- use DI\Definition\ObjectDefinition;
13
- use DI\Definition\Definition;
14
- use DI\Definition\Exception\DefinitionException;
15
- use DI\Definition\ObjectDefinition\PropertyInjection;
16
- use DI\Definition\Helper\DefinitionHelper;
17
- use DI\DependencyException;
18
- use DI\Proxy\ProxyFactory;
19
- use Exception;
20
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/ParameterResolver.php DELETED
@@ -1,138 +0,0 @@
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 DI\Definition\Resolver;
11
-
12
- use DI\Definition\AbstractFunctionCallDefinition;
13
- use DI\Definition\ObjectDefinition;
14
- use DI\Definition\Exception\DefinitionException;
15
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/ResolverDispatcher.php DELETED
@@ -1,141 +0,0 @@
1
- <?php
2
-
3
- namespace DI\Definition\Resolver;
4
-
5
- use DI\Definition\Definition;
6
- use DI\Definition\Exception\DefinitionException;
7
- use DI\Proxy\ProxyFactory;
8
- use 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 'DI\Definition\ValueDefinition':
92
- if (! $this->valueResolver) {
93
- $this->valueResolver = new ValueResolver();
94
- }
95
- return $this->valueResolver;
96
- case 'DI\Definition\ArrayDefinition':
97
- case 'DI\Definition\ArrayDefinitionExtension':
98
- if (! $this->arrayResolver) {
99
- $this->arrayResolver = new ArrayResolver($this);
100
- }
101
- return $this->arrayResolver;
102
- case 'DI\Definition\FactoryDefinition':
103
- if (! $this->factoryResolver) {
104
- $this->factoryResolver = new FactoryResolver($this->container);
105
- }
106
- return $this->factoryResolver;
107
- case 'DI\Definition\DecoratorDefinition':
108
- if (! $this->decoratorResolver) {
109
- $this->decoratorResolver = new DecoratorResolver($this->container, $this);
110
- }
111
- return $this->decoratorResolver;
112
- case 'DI\Definition\AliasDefinition':
113
- if (! $this->aliasResolver) {
114
- $this->aliasResolver = new AliasResolver($this->container);
115
- }
116
- return $this->aliasResolver;
117
- case 'DI\Definition\ObjectDefinition':
118
- if (! $this->objectResolver) {
119
- $this->objectResolver = new ObjectCreator($this, $this->proxyFactory);
120
- }
121
- return $this->objectResolver;
122
- case 'DI\Definition\InstanceDefinition':
123
- if (! $this->instanceResolver) {
124
- $this->instanceResolver = new InstanceInjector($this, $this->proxyFactory);
125
- }
126
- return $this->instanceResolver;
127
- case 'DI\Definition\EnvironmentVariableDefinition':
128
- if (! $this->envVariableResolver) {
129
- $this->envVariableResolver = new EnvironmentVariableResolver($this);
130
- }
131
- return $this->envVariableResolver;
132
- case '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/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/StringResolver.php DELETED
@@ -1,95 +0,0 @@
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 DI\Definition\Resolver;
11
-
12
- use DI\Definition\Definition;
13
- use DI\Definition\StringDefinition;
14
- use DI\DependencyException;
15
- use DI\NotFoundException;
16
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Resolver/ValueResolver.php DELETED
@@ -1,58 +0,0 @@
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 DI\Definition\Resolver;
11
-
12
- use DI\Definition\Definition;
13
- use 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/lib/ioc/php-di/php-di/src/DI/Definition/Source/AnnotationReader.php DELETED
@@ -1,298 +0,0 @@
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 DI\Definition\Source;
11
-
12
- use DI\Annotation\Inject;
13
- use DI\Annotation\Injectable;
14
- use DI\Definition\ObjectDefinition;
15
- use DI\Definition\EntryReference;
16
- use DI\Definition\Exception\AnnotationException;
17
- use DI\Definition\Exception\DefinitionException;
18
- use DI\Definition\ObjectDefinition\MethodInjection;
19
- use DI\Definition\ObjectDefinition\PropertyInjection;
20
- use Doctrine\Common\Annotations\AnnotationRegistry;
21
- use Doctrine\Common\Annotations\Reader;
22
- use Doctrine\Common\Annotations\SimpleAnnotationReader;
23
- use InvalidArgumentException;
24
- use PhpDocReader\PhpDocReader;
25
- use ReflectionClass;
26
- use ReflectionMethod;
27
- use ReflectionParameter;
28
- use ReflectionProperty;
29
- use UnexpectedValueException;
30
-
31
- /**
32
- * Provides DI definitions by reading annotations such as @ Inject and @ var annotations.
33
- *
34
- * Uses Autowiring, Doctrine's Annotations and regex docblock parsing.
35
- * This source automatically includes the reflection source.
36
- *
37
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
38
- */
39
- class AnnotationReader implements DefinitionSource
40
- {
41
- /**
42
- * @var Reader
43
- */
44
- private $annotationReader;
45
-
46
- /**
47
- * @var PhpDocReader
48
- */
49
- private $phpDocReader;
50
-
51
- /**
52
- * @var bool
53
- */
54
- private $ignorePhpDocErrors;
55
-
56
- /**
57
- * @param bool $ignorePhpDocErrors
58
- */
59
- public function __construct($ignorePhpDocErrors = false)
60
- {
61
- $this->ignorePhpDocErrors = (bool) $ignorePhpDocErrors;
62
- }
63
-
64
- /**
65
- * {@inheritdoc}
66
- * @throws AnnotationException
67
- * @throws InvalidArgumentException The class doesn't exist
68
- */
69
- public function getDefinition($name)
70
- {
71
- if (!class_exists($name) && !interface_exists($name)) {
72
- return null;
73
- }
74
-
75
- $class = new ReflectionClass($name);
76
- $definition = new ObjectDefinition($name);
77
-
78
- $this->readInjectableAnnotation($class, $definition);
79
-
80
- // Browse the class properties looking for annotated properties
81
- $this->readProperties($class, $definition);
82
-
83
- // Browse the object's methods looking for annotated methods
84
- $this->readMethods($class, $definition);
85
-
86
- return $definition;
87
- }
88
-
89
- /**
90
- * Browse the class properties looking for annotated properties.
91
- *
92
- * @param ReflectionClass $reflectionClass
93
- * @param ObjectDefinition $objectDefinition
94
- */
95
- private function readProperties(ReflectionClass $reflectionClass, ObjectDefinition $objectDefinition)
96
- {
97
- // This will look in all the properties, including those of the parent classes
98
- foreach ($reflectionClass->getProperties() as $property) {
99
- // Ignore static properties
100
- if ($property->isStatic()) {
101
- continue;
102
- }
103
-
104
- $propertyInjection = $this->getPropertyInjection($property);
105
-
106
- if ($propertyInjection) {
107
- $objectDefinition->addPropertyInjection($propertyInjection);
108
- }
109
- }
110
- }
111
-
112
- /**
113
- * @param ReflectionProperty $property
114
- * @return PropertyInjection|null
115
- */
116
- private function getPropertyInjection(ReflectionProperty $property)
117
- {
118
- // Look for @Inject annotation
119
- /** @var $annotation Inject */
120
- $annotation = $this->getAnnotationReader()->getPropertyAnnotation($property, 'DI\Annotation\Inject');
121
- if ($annotation === null) {
122
- return null;
123
- }
124
-
125
- // @Inject("name") or look for @var content
126
- $entryName = $annotation->getName() ?: $this->getPhpDocReader()->getPropertyClass($property);
127
-
128
- if ($entryName === null) {
129
- throw new AnnotationException(sprintf(
130
- '@Inject found on property %s::%s but unable to guess what to inject, use a @var annotation',
131
- $property->getDeclaringClass()->getName(),
132
- $property->getName()
133
- ));
134
- }
135
-
136
- return new PropertyInjection($property->getName(), new EntryReference($entryName));
137
- }
138
-
139
- /**
140
- * Browse the object's methods looking for annotated methods.
141
- *
142
- * @param ReflectionClass $class
143
- * @param ObjectDefinition $objectDefinition
144
- */
145
- private function readMethods(ReflectionClass $class, ObjectDefinition $objectDefinition)
146
- {
147
- // This will look in all the methods, including those of the parent classes
148
- foreach ($class->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
149
- if ($method->isStatic()) {
150
- continue;
151
- }
152
-
153
- $methodInjection = $this->getMethodInjection($method);
154
-
155
- if (! $methodInjection) {
156
- continue;
157
- }
158
-
159
- if ($method->isConstructor()) {
160
- $objectDefinition->setConstructorInjection($methodInjection);
161
- } else {
162
- $objectDefinition->addMethodInjection($methodInjection);
163
- }
164
- }
165
- }
166
-
167
- /**
168
- * {@inheritdoc}
169
- */
170
- private function getMethodInjection(ReflectionMethod $method)
171
- {
172
- // Look for @Inject annotation
173
- /** @var $annotation Inject|null */
174
- try {
175
- $annotation = $this->getAnnotationReader()->getMethodAnnotation($method, 'DI\Annotation\Inject');
176
- } catch (AnnotationException $e) {
177
- throw new AnnotationException(sprintf(
178
- '@Inject annotation on %s::%s is malformed. %s',
179
- $method->getDeclaringClass()->getName(),
180
- $method->getName(),
181
- $e->getMessage()
182
- ), 0, $e);
183
- }
184
- $annotationParameters = $annotation ? $annotation->getParameters() : [];
185
-
186
- // @Inject on constructor is implicit
187
- if (! ($annotation || $method->isConstructor())) {
188
- return null;
189
- }
190
-
191
- $parameters = [];
192
- foreach ($method->getParameters() as $index => $parameter) {
193
- $entryName = $this->getMethodParameter($index, $parameter, $annotationParameters);
194
-
195
- if ($entryName !== null) {
196
- $parameters[$index] = new EntryReference($entryName);
197
- }
198
- }
199
-
200
- if ($method->isConstructor()) {
201
- return MethodInjection::constructor($parameters);
202
- } else {
203
- return new MethodInjection($method->getName(), $parameters);
204
- }
205
- }
206
-
207
- /**
208
- * @param int $parameterIndex
209
- * @param ReflectionParameter $parameter
210
- * @param array $annotationParameters
211
- *
212
- * @return string|null Entry name or null if not found.
213
- */
214
- private function getMethodParameter($parameterIndex, ReflectionParameter $parameter, array $annotationParameters)
215
- {
216
- // @Inject has definition for this parameter (by index, or by name)
217
- if (isset($annotationParameters[$parameterIndex])) {
218
- return $annotationParameters[$parameterIndex];
219
- }
220
- if (isset($annotationParameters[$parameter->getName()])) {
221
- return $annotationParameters[$parameter->getName()];
222
- }
223
-
224
- // Skip optional parameters if not explicitly defined
225
- if ($parameter->isOptional()) {
226
- return null;
227
- }
228
-
229
- // Try to use the type-hinting
230
- $parameterClass = $parameter->getClass();
231
- if ($parameterClass) {
232
- return $parameterClass->getName();
233
- }
234
-
235
- // Last resort, look for @param tag
236
- return $this->getPhpDocReader()->getParameterClass($parameter);
237
- }
238
-
239
- /**
240
- * @return Reader The annotation reader
241
- */
242
- public function getAnnotationReader()
243
- {
244
- if ($this->annotationReader == null) {
245
- AnnotationRegistry::registerAutoloadNamespace('DI\Annotation', __DIR__ . '/../../../');
246
- $this->annotationReader = new SimpleAnnotationReader();
247
- $this->annotationReader->addNamespace('DI\Annotation');
248
- }
249
-
250
- return $this->annotationReader;
251
- }
252
-
253
- /**
254
- * @param Reader $annotationReader The annotation reader
255
- */
256
- public function setAnnotationReader(Reader $annotationReader)
257
- {
258
- $this->annotationReader = $annotationReader;
259
- }
260
-
261
- /**
262
- * @return PhpDocReader
263
- */
264
- private function getPhpDocReader()
265
- {
266
- if ($this->phpDocReader === null) {
267
- $this->phpDocReader = new PhpDocReader($this->ignorePhpDocErrors);
268
- }
269
-
270
- return $this->phpDocReader;
271
- }
272
-
273
- private function readInjectableAnnotation(ReflectionClass $class, ObjectDefinition $definition)
274
- {
275
- try {
276
- /** @var $annotation Injectable|null */
277
- $annotation = $this->getAnnotationReader()
278
- ->getClassAnnotation($class, 'DI\Annotation\Injectable');
279
- } catch (UnexpectedValueException $e) {
280
- throw new DefinitionException(sprintf(
281
- 'Error while reading @Injectable on %s: %s',
282
- $class->getName(),
283
- $e->getMessage()
284
- ), 0, $e);
285
- }
286
-
287
- if (! $annotation) {
288
- return;
289
- }
290
-
291
- if ($annotation->getScope()) {
292
- $definition->setScope($annotation->getScope());
293
- }
294
- if ($annotation->isLazy() !== null) {
295
- $definition->setLazy($annotation->isLazy());
296
- }
297
- }
298
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/Definition/Source/Autowiring.php DELETED
@@ -1,68 +0,0 @@
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 DI\Definition\Source;
11
-
12
- use DI\Definition\ObjectDefinition;
13
- use DI\Definition\EntryReference;
14
- use DI\Definition\ObjectDefinition\MethodInjection;
15
-
16
- /**
17
- * Reads DI class definitions using reflection.
18
- *
19
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
20
- */
21
- class Autowiring implements DefinitionSource
22
- {
23
- /**
24
- * {@inheritdoc}
25
- */
26
- public function getDefinition($name)
27
- {
28
- if (!class_exists($name) && !interface_exists($name)) {
29
- return null;
30
- }
31
-
32
- $definition = new ObjectDefinition($name);
33
-
34
- // Constructor
35
- $class = new \ReflectionClass($name);
36
- $constructor = $class->getConstructor();
37
- if ($constructor && $constructor->isPublic()) {
38
- $definition->setConstructorInjection(
39
- MethodInjection::constructor($this->getParametersDefinition($constructor))
40
- );
41
- }
42
-
43
- return $definition;
44
- }
45
-
46
- /**
47
- * Read the type-hinting from the parameters of the function.
48
- */
49
- private function getParametersDefinition(\ReflectionFunctionAbstract $constructor)
50
- {
51
- $parameters = [];
52
-
53
- foreach ($constructor->getParameters() as $index => $parameter) {
54
- // Skip optional parameters
55
- if ($parameter->isOptional()) {
56
- continue;
57
- }
58
-
59
- $parameterClass = $parameter->getClass();
60
-
61
- if ($parameterClass) {
62
- $parameters[$index] = new EntryReference($parameterClass->getName());
63
- }
64
- }
65
-
66
- return $parameters;
67
- }
68
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/Definition/Source/CachedDefinitionSource.php DELETED
@@ -1,104 +0,0 @@
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 DI\Definition\Source;
11
-
12
- use DI\Definition\CacheableDefinition;
13
- use DI\Definition\Definition;
14
- use Doctrine\Common\Cache\Cache;
15
-
16
- /**
17
- * Caches another definition source.
18
- *
19
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
20
- */
21
- class CachedDefinitionSource implements DefinitionSource
22
- {
23
- /**
24
- * Prefix for cache key, to avoid conflicts with other systems using the same cache
25
- * @var string
26
- */
27
- const CACHE_PREFIX = 'DI\\Definition\\';
28
-
29
- /**
30
- * @var DefinitionSource
31
- */
32
- private $source;
33
-
34
- /**
35
- * @var Cache
36
- */
37
- private $cache;
38
-
39
- public function __construct(DefinitionSource $source, Cache $cache)
40
- {
41
- $this->source = $source;
42
- $this->cache = $cache;
43
- }
44
-
45
- /**
46
- * {@inheritdoc}
47
- */
48
- public function getDefinition($name)
49
- {
50
- // Look in cache
51
- $definition = $this->fetchFromCache($name);
52
-
53
- if ($definition === false) {
54
- $definition = $this->source->getDefinition($name);
55
-
56
- // Save to cache
57
- if ($definition === null || ($definition instanceof CacheableDefinition)) {
58
- $this->saveToCache($name, $definition);
59
- }
60
- }
61
-
62
- return $definition;
63
- }
64
-
65
- /**
66
- * @return Cache
67
- */
68
- public function getCache()
69
- {
70
- return $this->cache;
71
- }
72
-
73
- /**
74
- * Fetches a definition from the cache
75
- *
76
- * @param string $name Entry name
77
- * @return Definition|null|boolean The cached definition, null or false if the value is not already cached
78
- */
79
- private function fetchFromCache($name)
80
- {
81
- $cacheKey = self::CACHE_PREFIX . $name;
82
-
83
- $data = $this->cache->fetch($cacheKey);
84
-
85
- if ($data !== false) {
86
- return $data;
87
- }
88
-
89
- return false;
90
- }
91
-
92
- /**
93
- * Saves a definition to the cache
94
- *
95
- * @param string $name Entry name
96
- * @param Definition|null $definition
97
- */
98
- private function saveToCache($name, Definition $definition = null)
99
- {
100
- $cacheKey = self::CACHE_PREFIX . $name;
101
-
102
- $this->cache->save($cacheKey, $definition);
103
- }
104
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/Definition/Source/DefinitionArray.php DELETED
@@ -1,142 +0,0 @@
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 DI\Definition\Source;
11
-
12
- use DI\Definition\ArrayDefinition;
13
- use DI\Definition\ObjectDefinition;
14
- use DI\Definition\Definition;
15
- use DI\Definition\FactoryDefinition;
16
- use DI\Definition\ValueDefinition;
17
- use DI\Definition\Helper\DefinitionHelper;
18
-
19
- /**
20
- * Reads DI definitions from a PHP array.
21
- *
22
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
23
- */
24
- class DefinitionArray implements DefinitionSource, MutableDefinitionSource
25
- {
26
- const WILDCARD = '*';
27
- /**
28
- * Matches anything except "\"
29
- */
30
- const WILDCARD_PATTERN = '([^\\\\]+)';
31
-
32
- /**
33
- * DI definitions in a PHP array
34
- * @var array
35
- */
36
- private $definitions = [];
37
-
38
- /**
39
- * @param array $definitions
40
- */
41
- public function __construct(array $definitions = [])
42
- {
43
- $this->definitions = $definitions;
44
- }
45
-
46
- /**
47
- * @param array $definitions DI definitions in a PHP array indexed by the definition name.
48
- */
49
- public function addDefinitions(array $definitions)
50
- {
51
- // The newly added data prevails
52
- // "for keys that exist in both arrays, the elements from the left-hand array will be used"
53
- $this->definitions = $definitions + $this->definitions;
54
- }
55
-
56
- /**
57
- * {@inheritdoc}
58
- */
59
- public function addDefinition(Definition $definition)
60
- {
61
- $this->definitions[$definition->getName()] = $definition;
62
- }
63
-
64
- /**
65
- * {@inheritdoc}
66
- */
67
- public function getDefinition($name)
68
- {
69
- // Look for the definition by name
70
- if (array_key_exists($name, $this->definitions)) {
71
- return $this->castDefinition($this->definitions[$name], $name);
72
- }
73
-
74
- // Look if there are wildcards definitions
75
- foreach ($this->definitions as $key => $definition) {
76
- if (strpos($key, self::WILDCARD) === false) {
77
- continue;
78
- }
79
-
80
- // Turn the pattern into a regex
81
- $key = addslashes($key);
82
- $key = '#' . str_replace(self::WILDCARD, self::WILDCARD_PATTERN, $key) . '#';
83
- if (preg_match($key, $name, $matches) === 1) {
84
- $definition = $this->castDefinition($definition, $name);
85
-
86
- // For a class definition, we replace * in the class name with the matches
87
- // *Interface -> *Impl => FooInterface -> FooImpl
88
- if ($definition instanceof ObjectDefinition) {
89
- array_shift($matches);
90
- $definition->setClassName(
91
- $this->replaceWildcards($definition->getClassName(), $matches)
92
- );
93
- }
94
-
95
- return $definition;
96
- }
97
- }
98
-
99
- return null;
100
- }
101
-
102
- /**
103
- * @param mixed $definition
104
- * @param string $name
105
- * @return Definition
106
- */
107
- private function castDefinition($definition, $name)
108
- {
109
- if ($definition instanceof DefinitionHelper) {
110
- $definition = $definition->getDefinition($name);
111
- }
112
- if (! $definition instanceof Definition && is_array($definition)) {
113
- $definition = new ArrayDefinition($name, $definition);
114
- }
115
- if ($definition instanceof \Closure) {
116
- $definition = new FactoryDefinition($name, $definition);
117
- }
118
- if (! $definition instanceof Definition) {
119
- $definition = new ValueDefinition($name, $definition);
120
- }
121
-
122
- return $definition;
123
- }
124
-
125
- /**
126
- * Replaces all the wildcards in the string with the given replacements.
127
- * @param string $string
128
- * @param string[] $replacements
129
- * @return string
130
- */
131
- private function replaceWildcards($string, array $replacements)
132
- {
133
- foreach ($replacements as $replacement) {
134
- $pos = strpos($string, self::WILDCARD);
135
- if ($pos !== false) {
136
- $string = substr_replace($string, $replacement, $pos, 1);
137
- }
138
- }
139
-
140
- return $string;
141
- }
142
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/Definition/Source/DefinitionFile.php DELETED
@@ -1,74 +0,0 @@
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 DI\Definition\Source;
11
-
12
- use DI\Definition\Definition;
13
- use DI\Definition\Exception\DefinitionException;
14
-
15
- /**
16
- * Reads DI definitions from a file returning a PHP array.
17
- *
18
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
19
- */
20
- class DefinitionFile extends DefinitionArray
21
- {
22
- /**
23
- * @var bool
24
- */
25
- private $initialized = false;
26
-
27
- /**
28
- * File containing definitions, or null if the definitions are given as a PHP array.
29
- * @var string|null
30
- */
31
- private $file;
32
-
33
- /**
34
- * @param string $file File in which the definitions are returned as an array.
35
- */
36
- public function __construct($file)
37
- {
38
- // Lazy-loading to improve performances
39
- $this->file = $file;
40
-
41
- parent::__construct([]);
42
- }
43
-
44
- /**
45
- * {@inheritdoc}
46
- */
47
- public function getDefinition($name)
48
- {
49
- $this->initialize();
50
-
51
- return parent::getDefinition($name);
52
- }
53
-
54
- /**
55
- * Lazy-loading of the definitions.
56
- * @throws DefinitionException
57
- */
58
- private function initialize()
59
- {
60
- if ($this->initialized === true) {
61
- return;
62
- }
63
-
64
- $definitions = require $this->file;
65
-
66
- if (! is_array($definitions)) {
67
- throw new DefinitionException("File {$this->file} should return an array of definitions");
68
- }
69
-
70
- $this->addDefinitions($definitions);
71
-
72
- $this->initialized = true;
73
- }
74
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/Definition/Source/DefinitionSource.php DELETED
@@ -1,31 +0,0 @@
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 DI\Definition\Source;
11
-
12
- use DI\Definition\Definition;
13
- use DI\Definition\Exception\DefinitionException;
14
-
15
- /**
16
- * Source of definitions for entries of the container.
17
- *
18
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
19
- */
20
- interface DefinitionSource
21
- {
22
- /**
23
- * Returns the DI definition for the entry name.
24
- *
25
- * @param string $name
26
- *
27
- * @throws DefinitionException An invalid definition was found.
28
- * @return Definition|null
29
- */
30
- public function getDefinition($name);
31
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/Definition/Source/MutableDefinitionSource.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- namespace DI\Definition\Source;
4
-
5
- use DI\Definition\Definition;
6
-
7
- /**
8
- * Describes a definition source to which we can add new definitions.
9
- *
10
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
11
- */
12
- interface MutableDefinitionSource extends DefinitionSource
13
- {
14
- public function addDefinition(Definition $definition);
15
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/Definition/Source/SourceChain.php DELETED
@@ -1,108 +0,0 @@
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 DI\Definition\Source;
11
-
12
- use DI\Definition\Definition;
13
- use DI\Definition\HasSubDefinition;
14
-
15
- /**
16
- * Manages a chain of other definition sources.
17
- *
18
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
19
- */
20
- class SourceChain implements DefinitionSource, MutableDefinitionSource
21
- {
22
- /**
23
- * @var DefinitionSource[]
24
- */
25
- private $sources;
26
-
27
- /**
28
- * @var DefinitionSource
29
- */
30
- private $rootSource;
31
-
32
- /**
33
- * @var MutableDefinitionSource|null
34
- */
35
- private $mutableSource;
36
-
37
- /**
38
- * @param DefinitionSource[] $sources
39
- */
40
- public function __construct(array $sources)
41
- {
42
- // We want a numerically indexed array to ease the traversal later
43
- $this->sources = array_values($sources);
44
- $this->rootSource = $this;
45
- }
46
-
47
- /**
48
- * {@inheritdoc}
49
- * @param int $startIndex Use this parameter to start looking from a specific
50
- * point in the source chain.
51
- */
52
- public function getDefinition($name, $startIndex = 0)
53
- {
54
- $count = count($this->sources);
55
- for ($i = $startIndex; $i < $count; $i++) {
56
- $source = $this->sources[$i];
57
-
58
- $definition = $source->getDefinition($name);
59
-
60
- if ($definition) {
61
- if ($definition instanceof HasSubDefinition) {
62
- $this->resolveSubDefinition($definition, $i);
63
- }
64
- return $definition;
65
- }
66
- }
67
-
68
- return null;
69
- }
70
-
71
- public function addDefinition(Definition $definition)
72
- {
73
- if (! $this->mutableSource) {
74
- throw new \LogicException("The container's definition source has not been initialized correctly");
75
- }
76
-
77
- $this->mutableSource->addDefinition($definition);
78
- }
79
-
80
- public function setRootDefinitionSource(DefinitionSource $rootSource)
81
- {
82
- $this->rootSource = $rootSource;
83
- }
84
-
85
- private function resolveSubDefinition(HasSubDefinition $definition, $currentIndex)
86
- {
87
- $subDefinitionName = $definition->getSubDefinitionName();
88
-
89
- if ($subDefinitionName === $definition->getName()) {
90
- // Extending itself: look in the next sources only (else infinite recursion)
91
- $subDefinition = $this->getDefinition($subDefinitionName, $currentIndex + 1);
92
- } else {
93
- // Extending another definition: look from the root
94
- $subDefinition = $this->rootSource->getDefinition($subDefinitionName);
95
- }
96
-
97
- if ($subDefinition) {
98
- $definition->setSubDefinition($subDefinition);
99
- }
100
- }
101
-
102
- public function setMutableDefinitionSource(MutableDefinitionSource $mutableSource)
103
- {
104
- $this->mutableSource = $mutableSource;
105
-
106
- array_unshift($this->sources, $mutableSource);
107
- }
108
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/Definition/StringDefinition.php DELETED
@@ -1,66 +0,0 @@
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 DI\Definition;
11
-
12
- use DI\Scope;
13
-
14
- /**
15
- * Definition of a string composed of other strings.
16
- *
17
- * @since 5.0
18
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
19
- */
20
- class StringDefinition implements Definition
21
- {
22
- /**
23
- * Entry name
24
- * @var string
25
- */
26
- private $name;
27
-
28
- /**
29
- * @var string
30
- */
31
- private $expression;
32
-
33
- /**
34
- * @param string $name Entry name
35
- * @param string $expression
36
- */
37
- public function __construct($name, $expression)
38
- {
39
- $this->name = $name;
40
- $this->expression = $expression;
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 string
61
- */
62
- public function getExpression()
63
- {
64
- return $this->expression;
65
- }
66
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/Definition/ValueDefinition.php DELETED
@@ -1,67 +0,0 @@
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 DI\Definition;
11
-
12
- use DI\Scope;
13
-
14
- /**
15
- * Definition of a value for dependency injection.
16
- *
17
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
18
- */
19
- class ValueDefinition implements Definition
20
- {
21
- /**
22
- * Entry name
23
- * @var string
24
- */
25
- private $name;
26
-
27
- /**
28
- * @var mixed
29
- */
30
- private $value;
31
-
32
- /**
33
- * @param string $name Entry name
34
- * @param mixed $value
35
- */
36
- public function __construct($name, $value)
37
- {
38
- $this->name = $name;
39
- $this->value = $value;
40
- }
41
-
42
- /**
43
- * @return string Entry name
44
- */
45
- public function getName()
46
- {
47
- return $this->name;
48
- }
49
-
50
- /**
51
- * A value definition is like a constant, there is nothing to compute, the value is the same for everyone.
52
- *
53
- * {@inheritdoc}
54
- */
55
- public function getScope()
56
- {
57
- return Scope::SINGLETON;
58
- }
59
-
60
- /**
61
- * @return mixed
62
- */
63
- public function getValue()
64
- {
65
- return $this->value;
66
- }
67
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/DependencyException.php DELETED
@@ -1,19 +0,0 @@
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 DI;
11
-
12
- use Interop\Container\Exception\ContainerException;
13
-
14
- /**
15
- * Exception for the Container
16
- */
17
- class DependencyException extends \Exception implements ContainerException
18
- {
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/FactoryInterface.php DELETED
@@ -1,34 +0,0 @@
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 DI;
11
-
12
- /**
13
- * Describes the basic interface of a factory.
14
- *
15
- * @since 4.0
16
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
17
- */
18
- interface FactoryInterface
19
- {
20
- /**
21
- * Resolves an entry by its name. If given a class name, it will return a new instance of that class.
22
- *
23
- * @param string $name Entry name or a class name.
24
- * @param array $parameters Optional parameters to use to build the entry. Use this to force specific
25
- * parameters to specific values. Parameters not defined in this array will
26
- * be automatically resolved.
27
- *
28
- * @throws \InvalidArgumentException The name parameter must be of type string.
29
- * @throws DependencyException Error while resolving the entry.
30
- * @throws NotFoundException No entry or class found for the given name.
31
- * @return mixed
32
- */
33
- public function make($name, array $parameters = []);
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/Invoker/DefinitionParameterResolver.php DELETED
@@ -1,45 +0,0 @@
1
- <?php
2
-
3
- namespace DI\Invoker;
4
-
5
- use DI\Definition\Helper\DefinitionHelper;
6
- use DI\Definition\Resolver\DefinitionResolver;
7
- use Invoker\ParameterResolver\ParameterResolver;
8
- use ReflectionFunctionAbstract;
9
-
10
- /**
11
- * Resolves callable parameters using definitions.
12
- *
13
- * @since 5.0
14
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
15
- */
16
- class DefinitionParameterResolver implements ParameterResolver
17
- {
18
- /**
19
- * @var DefinitionResolver
20
- */
21
- private $definitionResolver;
22
-
23
- public function __construct(DefinitionResolver $definitionResolver)
24
- {
25
- $this->definitionResolver = $definitionResolver;
26
- }
27
-
28
- /**
29
- * {@inheritdoc}
30
- */
31
- public function getParameters(
32
- ReflectionFunctionAbstract $reflection,
33
- array $providedParameters,
34
- array $resolvedParameters
35
- ) {
36
- foreach ($resolvedParameters as &$parameter) {
37
- if ($parameter instanceof DefinitionHelper) {
38
- $definition = $parameter->getDefinition('');
39
- $parameter = $this->definitionResolver->resolve($definition);
40
- }
41
- }
42
-
43
- return $resolvedParameters;
44
- }
45
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/InvokerInterface.php DELETED
@@ -1,19 +0,0 @@
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 DI;
11
-
12
- /**
13
- * Invoke a callable.
14
- *
15
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
16
- */
17
- interface InvokerInterface extends \Invoker\InvokerInterface
18
- {
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/NotFoundException.php DELETED
@@ -1,19 +0,0 @@
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 DI;
11
-
12
- use Interop\Container\Exception\NotFoundException as BaseNotFoundException;
13
-
14
- /**
15
- * Exception thrown when a class or a value is not found in the container
16
- */
17
- class NotFoundException extends \Exception implements BaseNotFoundException
18
- {
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/Proxy/ProxyFactory.php DELETED
@@ -1,88 +0,0 @@
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 DI\Proxy;
11
-
12
- use ProxyManager\Configuration;
13
- use ProxyManager\Factory\LazyLoadingValueHolderFactory;
14
- use ProxyManager\GeneratorStrategy\EvaluatingGeneratorStrategy;
15
-
16
- /**
17
- * Creates proxy classes.
18
- *
19
- * Wraps Ocramius/ProxyManager LazyLoadingValueHolderFactory.
20
- *
21
- * @see ProxyManager\Factory\LazyLoadingValueHolderFactory
22
- *
23
- * @since 5.0
24
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
25
- */
26
- class ProxyFactory
27
- {
28
- /**
29
- * If true, write the proxies to disk to improve performances.
30
- * @var boolean
31
- */
32
- private $writeProxiesToFile;
33
-
34
- /**
35
- * Directory where to write the proxies (if $writeProxiesToFile is enabled).
36
- * @var string
37
- */
38
- private $proxyDirectory;
39
-
40
- /**
41
- * @var LazyLoadingValueHolderFactory|null
42
- */
43
- private $proxyManager;
44
-
45
- public function __construct($writeProxiesToFile, $proxyDirectory = null)
46
- {
47
- $this->writeProxiesToFile = $writeProxiesToFile;
48
- $this->proxyDirectory = $proxyDirectory;
49
- }
50
-
51
- /**
52
- * Creates a new lazy proxy instance of the given class with
53
- * the given initializer
54
- *
55
- * @param string $className name of the class to be proxied
56
- * @param \Closure $initializer initializer to be passed to the proxy
57
- *
58
- * @return \ProxyManager\Proxy\LazyLoadingInterface
59
- */
60
- public function createProxy($className, \Closure $initializer)
61
- {
62
- $this->createProxyManager();
63
-
64
- return $this->proxyManager->createProxy($className, $initializer);
65
- }
66
-
67
- private function createProxyManager()
68
- {
69
- if ($this->proxyManager !== null) {
70
- return;
71
- }
72
-
73
- if (! class_exists('ProxyManager\Configuration')) {
74
- throw new \RuntimeException('The ocramius/proxy-manager library is not installed. Lazy injection requires that library to be installed with Composer in order to work. Run "composer require ocramius/proxy-manager:~0.3".');
75
- }
76
-
77
- $config = new Configuration();
78
-
79
- if ($this->writeProxiesToFile) {
80
- $config->setProxiesTargetDir($this->proxyDirectory);
81
- spl_autoload_register($config->getProxyAutoloader());
82
- } else {
83
- $config->setGeneratorStrategy(new EvaluatingGeneratorStrategy());
84
- }
85
-
86
- $this->proxyManager = new LazyLoadingValueHolderFactory($config);
87
- }
88
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/Reflection/CallableReflectionFactory.php DELETED
@@ -1,51 +0,0 @@
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 DI\Reflection;
11
-
12
- /**
13
- * Create a reflection object from a callable.
14
- *
15
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
16
- */
17
- class CallableReflectionFactory
18
- {
19
- /**
20
- * @param callable $callable
21
- *
22
- * @return \ReflectionFunctionAbstract
23
- */
24
- public static function fromCallable($callable)
25
- {
26
- // Array callable
27
- if (is_array($callable)) {
28
- list($class, $method) = $callable;
29
-
30
- return new \ReflectionMethod($class, $method);
31
- }
32
-
33
- // Closure
34
- if ($callable instanceof \Closure) {
35
- return new \ReflectionFunction($callable);
36
- }
37
-
38
- // Callable object (i.e. implementing __invoke())
39
- if (is_object($callable) && method_exists($callable, '__invoke')) {
40
- return new \ReflectionMethod($callable, '__invoke');
41
- }
42
-
43
- // Callable class (i.e. implementing __invoke())
44
- if (is_string($callable) && class_exists($callable) && method_exists($callable, '__invoke')) {
45
- return new \ReflectionMethod($callable, '__invoke');
46
- }
47
-
48
- // Standard function
49
- return new \ReflectionFunction($callable);
50
- }
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/Scope.php DELETED
@@ -1,54 +0,0 @@
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 DI;
11
-
12
- /**
13
- * Scope enum.
14
- *
15
- * The scope defines the lifecycle of an entry.
16
- *
17
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
18
- */
19
- class Scope
20
- {
21
- /**
22
- * A singleton entry will be computed once and shared.
23
- *
24
- * For a class, only a single instance of the class will be created.
25
- */
26
- const SINGLETON = 'singleton';
27
-
28
- /**
29
- * A prototype entry will be recomputed each time it is asked.
30
- *
31
- * For a class, this will create a new instance each time.
32
- */
33
- const PROTOTYPE = 'prototype';
34
-
35
- /**
36
- * Method kept for backward compatibility, use the constant instead.
37
- *
38
- * @return string
39
- */
40
- public static function SINGLETON()
41
- {
42
- return self::SINGLETON;
43
- }
44
-
45
- /**
46
- * Method kept for backward compatibility, use the constant instead.
47
- *
48
- * @return string
49
- */
50
- public static function PROTOTYPE()
51
- {
52
- return self::PROTOTYPE;
53
- }
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/php-di/src/DI/functions.php DELETED
@@ -1,181 +0,0 @@
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 DI;
11
-
12
- use DI\Definition\EntryReference;
13
- use DI\Definition\Helper\ArrayDefinitionExtensionHelper;
14
- use DI\Definition\Helper\FactoryDefinitionHelper;
15
- use DI\Definition\Helper\ObjectDefinitionHelper;
16
- use DI\Definition\Helper\EnvironmentVariableDefinitionHelper;
17
- use DI\Definition\Helper\ValueDefinitionHelper;
18
- use DI\Definition\Helper\StringDefinitionHelper;
19
-
20
- if (! function_exists('DI\value')) {
21
- /**
22
- * Helper for defining an object.
23
- *
24
- * @param mixed $value
25
- *
26
- * @return ValueDefinitionHelper
27
- */
28
- function value($value)
29
- {
30
- return new ValueDefinitionHelper($value);
31
- }
32
- }
33
-
34
- if (! function_exists('DI\object')) {
35
- /**
36
- * Helper for defining an object.
37
- *
38
- * @param string|null $className Class name of the object.
39
- * If null, the name of the entry (in the container) will be used as class name.
40
- *
41
- * @return ObjectDefinitionHelper
42
- */
43
- function object($className = null)
44
- {
45
- return new ObjectDefinitionHelper($className);
46
- }
47
- }
48
-
49
- if (! function_exists('DI\factory')) {
50
- /**
51
- * Helper for defining a container entry using a factory function/callable.
52
- *
53
- * @param callable $factory The factory is a callable that takes the container as parameter
54
- * and returns the value to register in the container.
55
- *
56
- * @return FactoryDefinitionHelper
57
- */
58
- function factory($factory)
59
- {
60
- return new FactoryDefinitionHelper($factory);
61
- }
62
- }
63
-
64
- if (! function_exists('DI\decorate')) {
65
- /**
66
- * Decorate the previous definition using a callable.
67
- *
68
- * Example:
69
- *
70
- * 'foo' => decorate(function ($foo, $container) {
71
- * return new CachedFoo($foo, $container->get('cache'));
72
- * })
73
- *
74
- * @param callable $callable The callable takes the decorated object as first parameter and
75
- * the container as second.
76
- *
77
- * @return FactoryDefinitionHelper
78
- */
79
- function decorate($callable)
80
- {
81
- return new FactoryDefinitionHelper($callable, true);
82
- }
83
- }
84
-
85
- if (! function_exists('DI\get')) {
86
- /**
87
- * Helper for referencing another container entry in an object definition.
88
- *
89
- * @param string $entryName
90
- *
91
- * @return EntryReference
92
- */
93
- function get($entryName)
94
- {
95
- return new EntryReference($entryName);
96
- }
97
- }
98
-
99
- if (! function_exists('DI\link')) {
100
- /**
101
- * Helper for referencing another container entry in an object definition.
102
- *
103
- * @deprecated \DI\link() has been replaced by \DI\get()
104
- *
105
- * @param string $entryName
106
- *
107
- * @return EntryReference
108
- */
109
- function link($entryName)
110
- {
111
- return new EntryReference($entryName);
112
- }
113
- }
114
-
115
- if (! function_exists('DI\env')) {
116
- /**
117
- * Helper for referencing environment variables.
118
- *
119
- * @param string $variableName The name of the environment variable.
120
- * @param mixed $defaultValue The default value to be used if the environment variable is not defined.
121
- *
122
- * @return EnvironmentVariableDefinitionHelper
123
- */
124
- function env($variableName, $defaultValue = null)
125
- {
126
- // Only mark as optional if the default value was *explicitly* provided.
127
- $isOptional = 2 === func_num_args();
128
-
129
- return new EnvironmentVariableDefinitionHelper($variableName, $isOptional, $defaultValue);
130
- }
131
- }
132
-
133
- if (! function_exists('DI\add')) {
134
- /**
135
- * Helper for extending another definition.
136
- *
137
- * Example:
138
- *
139
- * 'log.backends' => DI\add(DI\get('My\Custom\LogBackend'))
140
- *
141
- * or:
142
- *
143
- * 'log.backends' => DI\add([
144
- * DI\get('My\Custom\LogBackend')
145
- * ])
146
- *
147
- * @param mixed|array $values A value or an array of values to add to the array.
148
- *
149
- * @return ArrayDefinitionExtensionHelper
150
- *
151
- * @since 5.0
152
- */
153
- function add($values)
154
- {
155
- if (! is_array($values)) {
156
- $values = [$values];
157
- }
158
-
159
- return new ArrayDefinitionExtensionHelper($values);
160
- }
161
- }
162
-
163
- if (! function_exists('DI\string')) {
164
- /**
165
- * Helper for concatenating strings.
166
- *
167
- * Example:
168
- *
169
- * 'log.filename' => DI\string('{app.path}/app.log')
170
- *
171
- * @param string $expression A string expression. Use the `{}` placeholders to reference other container entries.
172
- *
173
- * @return StringDefinitionHelper
174
- *
175
- * @since 5.0
176
- */
177
- function string($expression)
178
- {
179
- return new StringDefinitionHelper((string) $expression);
180
- }
181
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/phpdoc-reader/.gitattributes DELETED
@@ -1,7 +0,0 @@
1
- # .gitattributes
2
- tests/ export-ignore
3
- phpunit.xml.dist export-ignore
4
- .travis.yml export-ignore
5
-
6
- # Auto detect text files and perform LF normalization
7
- * text=auto
 
 
 
 
 
 
 
addons/lib/ioc/php-di/phpdoc-reader/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- .DS_Store
2
- .idea/*
3
- vendor/*
4
- composer.phar
5
- composer.lock
 
 
 
 
 
addons/lib/ioc/php-di/phpdoc-reader/LICENSE DELETED
@@ -1,16 +0,0 @@
1
- Copyright (C) 2015 Matthieu Napoli
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
4
- associated documentation files (the "Software"), to deal in the Software without restriction,
5
- including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
6
- and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
7
- subject to the following conditions:
8
-
9
- The above copyright notice and this permission notice shall be included in all copies or substantial
10
- portions of the Software.
11
-
12
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
13
- NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
14
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
15
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
16
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/phpdoc-reader/README.md DELETED
@@ -1,58 +0,0 @@
1
- # PhpDocReader
2
-
3
- [![Build Status](https://img.shields.io/travis/PHP-DI/PhpDocReader.svg)](https://travis-ci.org/mnapoli/PhpDocReader)
4
- ![](https://img.shields.io/packagist/dt/PHP-DI/phpdoc-reader.svg)
5
-
6
- This project is used by:
7
-
8
- - [PHP-DI](http://php-di.org/)
9
- - [phockito-unit-php-di](https://github.com/balihoo/phockito-unit-php-di)
10
-
11
- Fork the README to add your project here.
12
-
13
- ## Features
14
-
15
- PhpDocReader parses `@var` and `@param` values in PHP docblocks:
16
-
17
- ```php
18
-
19
- use My\Cache\Backend;
20
-
21
- class Cache
22
- {
23
- /**
24
- * @var Backend
25
- */
26
- protected $backend;
27
-
28
- /**
29
- * @param Backend $backend
30
- */
31
- public function __construct($backend)
32
- {
33
- }
34
- }
35
- ```
36
-
37
- It supports namespaced class names with the same resolution rules as PHP:
38
-
39
- - fully qualified name (starting with `\`)
40
- - imported class name (eg. `use My\Cache\Backend;`)
41
- - relative class name (from the current namespace, like `SubNamespace\MyClass`)
42
- - aliased class name (eg. `use My\Cache\Backend as FooBar;`)
43
-
44
- Primitive types (`@var string`) are ignored (returns null), only valid class names are returned.
45
-
46
- ## Usage
47
-
48
- ```php
49
- $reader = new PhpDocReader();
50
-
51
- // Read a property type (@var phpdoc)
52
- $property = new ReflectionProperty($className, $propertyName);
53
- $propertyClass = $reader->getPropertyClass($property);
54
-
55
- // Read a parameter type (@param phpdoc)
56
- $parameter = new ReflectionParameter(array($className, $methodName), $parameterName);
57
- $parameterClass = $reader->getParameterClass($parameter);
58
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/phpdoc-reader/composer.json DELETED
@@ -1,23 +0,0 @@
1
- {
2
- "name": "php-di/phpdoc-reader",
3
- "type": "library",
4
- "description": "PhpDocReader parses @var and @param values in PHP docblocks (supports namespaced class names with the same resolution rules as PHP)",
5
- "keywords": ["phpdoc", "reflection"],
6
- "license": "MIT",
7
- "autoload": {
8
- "psr-4": {
9
- "PhpDocReader\\": "src/PhpDocReader"
10
- }
11
- },
12
- "autoload-dev": {
13
- "psr-4": {
14
- "UnitTest\\PhpDocReader\\": "tests/"
15
- }
16
- },
17
- "require": {
18
- "php": ">=5.4.0"
19
- },
20
- "require-dev": {
21
- "phpunit/phpunit": "~4.6"
22
- }
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/phpdoc-reader/src/PhpDocReader/AnnotationException.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
-
3
- namespace PhpDocReader;
4
-
5
- /**
6
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
7
- */
8
- class AnnotationException extends \Exception
9
- {
10
- }
 
 
 
 
 
 
 
 
 
 
addons/lib/ioc/php-di/phpdoc-reader/src/PhpDocReader/PhpDocReader.php DELETED
@@ -1,312 +0,0 @@
1
- <?php
2
-
3
- namespace PhpDocReader;
4
-
5
- use PhpDocReader\PhpParser\UseStatementParser;
6
- use ReflectionClass;
7
- use ReflectionMethod;
8
- use ReflectionParameter;
9
- use ReflectionProperty;
10
- use Reflector;
11
-
12
- /**
13
- * PhpDoc reader
14
- *
15
- * @author Matthieu Napoli <matthieu@mnapoli.fr>
16
- */
17
- class PhpDocReader
18
- {
19
- /**
20
- * @var UseStatementParser
21
- */
22
- private $parser;
23
-
24
- private $ignoredTypes = array(
25
- 'bool',
26
- 'boolean',
27
- 'string',
28
- 'int',
29
- 'integer',
30
- 'float',
31
- 'double',
32
- 'array',
33
- 'object',
34
- 'callable',
35
- 'resource',
36
- 'mixed',
37
- 'iterable',
38
- );
39
-
40
- /**
41
- * Enable or disable throwing errors when PhpDoc Errors occur (when parsing annotations)
42
- *
43
- * @var bool
44
- */
45
- private $ignorePhpDocErrors;
46
-
47
- /**
48
- *
49
- * @param bool $ignorePhpDocErrors
50
- */
51
- public function __construct($ignorePhpDocErrors = false)
52
- {
53
- $this->parser = new UseStatementParser();
54
- $this->ignorePhpDocErrors = $ignorePhpDocErrors;
55
- }
56
-
57
- /**
58
- * Parse the docblock of the property to get the class of the var annotation.
59
- *
60
- * @param ReflectionProperty $property
61
- *
62
- * @throws AnnotationException
63
- * @return string|null Type of the property (content of var annotation)
64
- *
65
- * @deprecated Use getPropertyClass instead.
66
- */
67
- public function getPropertyType(ReflectionProperty $property)
68
- {
69
- return $this->getPropertyClass($property);
70
- }
71
-
72
- /**
73
- * Parse the docblock of the property to get the class of the var annotation.
74
- *
75
- * @param ReflectionProperty $property
76
- *
77
- * @throws AnnotationException
78
- * @return string|null Type of the property (content of var annotation)
79
- */
80
- public function getPropertyClass(ReflectionProperty $property)
81
- {
82
- // Get the content of the @var annotation
83
- if (preg_match('/@var\s+([^\s]+)/', $property->getDocComment(), $matches)) {
84
- list(, $type) = $matches;
85
- } else {
86
- return null;
87
- }
88
-
89
- // Ignore primitive types
90
- if (in_array($type, $this->ignoredTypes)) {
91
- return null;
92
- }
93
-
94
- // Ignore types containing special characters ([], <> ...)
95
- if (! preg_match('/^[a-zA-Z0-9\\\\_]+$/', $type)) {
96
- return null;
97
- }
98
-
99
- $class = $property->getDeclaringClass();
100
-
101
- // If the class name is not fully qualified (i.e. doesn't start with a \)
102
- if ($type[0] !== '\\') {
103
- // Try to resolve the FQN using the class context
104
- $resolvedType = $this->tryResolveFqn($type, $class, $property);
105
-
106
- if (!$resolvedType && !$this->ignorePhpDocErrors) {
107
- throw new AnnotationException(sprintf(
108
- 'The @var annotation on %s::%s contains a non existent class "%s". '
109
- . 'Did you maybe forget to add a "use" statement for this annotation?',
110
- $class->name,
111
- $property->getName(),
112
- $type
113
- ));
114
- }
115
-
116
- $type = $resolvedType;
117
- }
118
-
119
- if (!$this->classExists($type) && !$this->ignorePhpDocErrors) {
120
- throw new AnnotationException(sprintf(
121
- 'The @var annotation on %s::%s contains a non existent class "%s"',
122
- $class->name,
123
- $property->getName(),
124
- $type
125
- ));
126
- }
127
-
128
- // Remove the leading \ (FQN shouldn't contain it)
129
- $type = ltrim($type, '\\');
130
-
131
- return $type;
132
- }
133
-
134
- /**
135
- * Parse the docblock of the property to get the class of the param annotation.
136
- *
137
- * @param ReflectionParameter $parameter
138
- *
139
- * @throws AnnotationException
140
- * @return string|null Type of the property (content of var annotation)
141
- *
142
- * @deprecated Use getParameterClass instead.
143
- */
144
- public function getParameterType(ReflectionParameter $parameter)
145
- {
146
- return $this->getParameterClass($parameter);
147
- }
148
-
149
- /**
150
- * Parse the docblock of the property to get the class of the param annotation.
151
- *
152
- * @param ReflectionParameter $parameter
153
- *
154
- * @throws AnnotationException
155
- * @return string|null Type of the property (content of var annotation)
156
- */
157
- public function getParameterClass(ReflectionParameter $parameter)
158
- {
159
- // Use reflection
160
- $parameterClass = $parameter->getClass();
161
- if ($parameterClass !== null) {
162
- return $parameterClass->name;
163
- }
164
-
165
- $parameterName = $parameter->name;
166
- // Get the content of the @param annotation
167
- $method = $parameter->getDeclaringFunction();
168
- if (preg_match('/@param\s+([^\s]+)\s+\$' . $parameterName . '/', $method->getDocComment(), $matches)) {
169
- list(, $type) = $matches;
170
- } else {
171
- return null;
172
- }
173
-
174
- // Ignore primitive types
175
- if (in_array($type, $this->ignoredTypes)) {
176
- return null;
177
- }
178
-
179
- // Ignore types containing special characters ([], <> ...)
180
- if (! preg_match('/^[a-zA-Z0-9\\\\_]+$/', $type)) {
181
- return null;
182
- }
183
-
184
- $class = $parameter->getDeclaringClass();
185
-
186
- // If the class name is not fully qualified (i.e. doesn't start with a \)
187
- if ($type[0] !== '\\') {
188
- // Try to resolve the FQN using the class context
189
- $resolvedType = $this->tryResolveFqn($type, $class, $parameter);
190
-
191
- if (!$resolvedType && !$this->ignorePhpDocErrors) {
192
- throw new AnnotationException(sprintf(
193
- 'The @param annotation for parameter "%s" of %s::%s contains a non existent class "%s". '
194
- . 'Did you maybe forget to add a "use" statement for this annotation?',
195
- $parameterName,
196
- $class->name,
197
- $method->name,
198
- $type
199
- ));
200
- }
201
-
202
- $type = $resolvedType;
203
- }
204
-
205
- if (!$this->classExists($type) && !$this->ignorePhpDocErrors) {
206
- throw new AnnotationException(sprintf(
207
- 'The @param annotation for parameter "%s" of %s::%s contains a non existent class "%s"',
208
- $parameterName,
209
- $class->name,
210
- $method->name,
211
- $type
212
- ));
213
- }
214
-
215
- // Remove the leading \ (FQN shouldn't contain it)
216
- $type = ltrim($type, '\\');
217
-
218
- return $type;
219
- }
220
-
221
- /**
222
- * Attempts to resolve the FQN of the provided $type based on the $class and $member context.
223
- *
224
- * @param string $type
225
- * @param ReflectionClass $class
226
- * @param Reflector $member
227
- *
228
- * @return string|null Fully qualified name of the type, or null if it could not be resolved
229
- */
230
- private function tryResolveFqn($type, ReflectionClass $class, Reflector $member)
231
- {
232
- $alias = ($pos = strpos($type, '\\')) === false ? $type : substr($type, 0, $pos);
233
- $loweredAlias = strtolower($alias);
234
-
235
- // Retrieve "use" statements
236
- $uses = $this->parser->parseUseStatements($class);
237
-
238
- if (isset($uses[$loweredAlias])) {
239
- // Imported classes
240
- if ($pos !== false) {
241
- return $uses[$loweredAlias] . substr($type, $pos);
242
- } else {
243
- return $uses[$loweredAlias];
244
- }
245
- } elseif ($this->classExists($class->getNamespaceName() . '\\' . $type)) {
246
- return $class->getNamespaceName() . '\\' . $type;
247
- } elseif (isset($uses['__NAMESPACE__']) && $this->classExists($uses['__NAMESPACE__'] . '\\' . $type)) {
248
- // Class namespace
249
- return $uses['__NAMESPACE__'] .