Emit.php 842 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * PHP表单生成器
  4. *
  5. * @package FormBuilder
  6. * @author xaboy <xaboy2005@qq.com>
  7. * @version 2.0
  8. * @license MIT
  9. * @link https://github.com/xaboy/form-builder
  10. * @document http://php.form-create.com
  11. */
  12. namespace FormBuilder\Annotation;
  13. use FormBuilder\Contract\AnnotationInterface;
  14. /**
  15. * @Annotation
  16. */
  17. final class Emit implements AnnotationInterface
  18. {
  19. /**
  20. * @var array
  21. */
  22. public $emit = [];
  23. /**
  24. * @var string
  25. */
  26. public $prefix = '';
  27. public function parseRule($rule)
  28. {
  29. $rule['emit'] = $this->emit;
  30. if ($this->prefix)
  31. $rule['emitPrefix'] = $this->prefix;
  32. return $rule;
  33. }
  34. public function parseComponent($component)
  35. {
  36. $component->emit($this->emit)->emitPrefix($this->prefix);
  37. return $component;
  38. }
  39. }