|
5 | 5 | #include "php_agent.h"
|
6 | 6 | #include "php_call.h"
|
7 | 7 | #include "php_error.h"
|
| 8 | +#include "php_globals.h" |
8 | 9 | #include "php_wrapper.h"
|
9 | 10 | #include "fw_hooks.h"
|
10 | 11 | #include "fw_support.h"
|
@@ -214,6 +215,56 @@ NR_PHP_WRAPPER(nr_symfony4_name_the_wt) {
|
214 | 215 | }
|
215 | 216 | NR_PHP_WRAPPER_END
|
216 | 217 |
|
| 218 | +void nr_get_package_information() { |
| 219 | + zval retval; |
| 220 | + int result = -1; |
| 221 | + char* func_string |
| 222 | + = "" |
| 223 | + "(function() {" |
| 224 | + " try {" |
| 225 | + " if (class_exists('Composer\\InstalledVersions')) {" |
| 226 | + " if (method_exists('Composer\\InstalledVersions', " |
| 227 | + " 'getInstalledPackages') && method_exists('Composer\\InstalledVersions', " |
| 228 | + " 'getVersion')) {" |
| 229 | + " return Composer\\InstalledVersions::getInstalledPackages();" |
| 230 | + " } else {" |
| 231 | + " return NULL;" |
| 232 | + " }" |
| 233 | + " } else {" |
| 234 | + " return NULL;" |
| 235 | + " }" |
| 236 | + " } catch (Exception $e) {" |
| 237 | + " return NULL;" |
| 238 | + " }" |
| 239 | + "})();"; |
| 240 | + |
| 241 | + char* getVersion = "Composer\\InstalledVersions::getVersion(\"%s\");"; |
| 242 | + zend_eval_string(func_string, &retval, "Retrieve symfony package name"); |
| 243 | + |
| 244 | + if (result == SUCCESS) { |
| 245 | + if (Z_TYPE(retval) == IS_ARRAY) { |
| 246 | + zval* value; |
| 247 | + char buf[512]; |
| 248 | + int result2; |
| 249 | + zval retval2; |
| 250 | + char* version; |
| 251 | + (void)version; |
| 252 | + ZEND_HASH_FOREACH_VAL(Z_ARRVAL(retval), value) { |
| 253 | + if (Z_TYPE_P(value) == IS_STRING) { |
| 254 | + snprintf(buf, sizeof(buf), getVersion, Z_STRVAL_P(value)); |
| 255 | + result2 = zend_eval_string(buf, &retval2, "Retrieve symfony Version"); |
| 256 | + if (SUCCESS == result2) { |
| 257 | + if (nr_php_is_zval_valid_string(&retval2)) { |
| 258 | + version = Z_STRVAL(retval2); |
| 259 | + } |
| 260 | + } |
| 261 | + } |
| 262 | + } ZEND_HASH_FOREACH_END(); |
| 263 | + } |
| 264 | + zval_dtor(&retval); |
| 265 | + } |
| 266 | +} |
| 267 | + |
217 | 268 | void nr_symfony4_enable(TSRMLS_D) {
|
218 | 269 | /*
|
219 | 270 | * We set the path to 'unknown' to prevent having to name routing errors.
|
|
0 commit comments