CompilesInjections.php 505B

123456789101112131415161718192021222324
  1. <?php
  2. namespace Illuminate\View\Compilers\Concerns;
  3. trait CompilesInjections
  4. {
  5. /**
  6. * Compile the inject statements into valid PHP.
  7. *
  8. * @param string $expression
  9. * @return string
  10. */
  11. protected function compileInject($expression)
  12. {
  13. $segments = explode(',', preg_replace("/[\(\)\\\"\']/", '', $expression));
  14. $variable = trim($segments[0]);
  15. $service = trim($segments[1]);
  16. return "<?php \${$variable} = app('{$service}'); ?>";
  17. }
  18. }