@@ 388-413 (lines=26) @@ | ||
385 | * @return array |
|
386 | * The optimized list of all registered mutations. |
|
387 | */ |
|
388 | protected function buildMutationMap(MutationPluginManager $manager) { |
|
389 | $definitions = $manager->getDefinitions(); |
|
390 | $mutations = array_reduce(array_keys($definitions), function ($carry, $id) use ($definitions) { |
|
391 | $current = $definitions[$id]; |
|
392 | $name = $current['name']; |
|
393 | ||
394 | if (empty($carry[$name]) || $carry[$name]['weight'] < $current['weight']) { |
|
395 | $carry[$name] = [ |
|
396 | 'id' => $id, |
|
397 | 'class' => $current['class'], |
|
398 | 'weight' => !empty($current['weight']) ? $current['weight'] : 0, |
|
399 | ]; |
|
400 | } |
|
401 | ||
402 | return $carry; |
|
403 | }, []); |
|
404 | ||
405 | return array_map(function ($definition) use ($manager) { |
|
406 | $id = $definition['id']; |
|
407 | $instance = $manager->getInstance(['id' => $id]); |
|
408 | ||
409 | return [ |
|
410 | 'definition' => $instance->getDefinition(), |
|
411 | ] + $definition; |
|
412 | }, $mutations); |
|
413 | } |
|
414 | ||
415 | /** |
|
416 | * Builds an optimized representation of all registered subscriptions. |
|
@@ 424-449 (lines=26) @@ | ||
421 | * @return array |
|
422 | * The optimized list of all registered subscriptions. |
|
423 | */ |
|
424 | protected function buildSubscriptionMap(SubscriptionPluginManager $manager) { |
|
425 | $definitions = $manager->getDefinitions(); |
|
426 | $subscriptions = array_reduce(array_keys($definitions), function ($carry, $id) use ($definitions) { |
|
427 | $current = $definitions[$id]; |
|
428 | $name = $current['name']; |
|
429 | ||
430 | if (empty($carry[$name]) || $carry[$name]['weight'] < $current['weight']) { |
|
431 | $carry[$name] = [ |
|
432 | 'id' => $id, |
|
433 | 'class' => $current['class'], |
|
434 | 'weight' => !empty($current['weight']) ? $current['weight'] : 0, |
|
435 | ]; |
|
436 | } |
|
437 | ||
438 | return $carry; |
|
439 | }, []); |
|
440 | ||
441 | return array_map(function ($definition) use ($manager) { |
|
442 | $id = $definition['id']; |
|
443 | $instance = $manager->getInstance(['id' => $id]); |
|
444 | ||
445 | return [ |
|
446 | 'definition' => $instance->getDefinition(), |
|
447 | ] + $definition; |
|
448 | }, $subscriptions); |
|
449 | } |
|
450 | ||
451 | } |
|
452 |