ParamConverter.php 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. namespace Sensio\Bundle\FrameworkExtraBundle\Configuration;
  3. /*
  4. * This file is part of the Symfony package.
  5. *
  6. * (c) Fabien Potencier <fabien@symfony.com>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. /**
  12. * The ParamConverter class handles the @ParamConverter annotation parts.
  13. *
  14. * @ParamConverter("post", class="BlogBundle:Post")
  15. *
  16. * @author Fabien Potencier <fabien@symfony.com>
  17. * @Annotation
  18. */
  19. class ParamConverter extends ConfigurationAnnotation
  20. {
  21. /**
  22. * The parameter name.
  23. *
  24. * @var string
  25. */
  26. protected $name;
  27. /**
  28. * The parameter class.
  29. *
  30. * @var string
  31. */
  32. protected $class;
  33. /**
  34. * An array of options.
  35. *
  36. * @var array
  37. */
  38. protected $options = array();
  39. /**
  40. * Whether or not the parameter is optional.
  41. *
  42. * @var Boolean
  43. */
  44. protected $optional = false;
  45. /**
  46. * Returns the parameter name.
  47. *
  48. * @return string
  49. */
  50. public function getName()
  51. {
  52. return $this->name;
  53. }
  54. /**
  55. * Sets the parameter name.
  56. *
  57. * @param string $name The parameter name
  58. */
  59. public function setValue($name)
  60. {
  61. $this->setName($name);
  62. }
  63. /**
  64. * Sets the parameter name.
  65. *
  66. * @param string $name The parameter name
  67. */
  68. public function setName($name)
  69. {
  70. $this->name = $name;
  71. }
  72. /**
  73. * Returns the parameter class name.
  74. *
  75. * @return string $name
  76. */
  77. public function getClass()
  78. {
  79. return $this->class;
  80. }
  81. /**
  82. * Sets the parameter class name.
  83. *
  84. * @param string $class The parameter class name
  85. */
  86. public function setClass($class)
  87. {
  88. $this->class = $class;
  89. }
  90. /**
  91. * Returns an array of options.
  92. *
  93. * @return array
  94. */
  95. public function getOptions()
  96. {
  97. return $this->options;
  98. }
  99. /**
  100. * Sets an array of options.
  101. *
  102. * @param array $options An array of options
  103. */
  104. public function setOptions($options)
  105. {
  106. $this->options = $options;
  107. }
  108. /**
  109. * Sets whether or not the parameter is optional.
  110. *
  111. * @param Boolean $optional Wether the parameter is optional
  112. */
  113. public function setIsOptional($optional)
  114. {
  115. $this->optional = (Boolean) $optional;
  116. }
  117. /**
  118. * Returns whether or not the parameter is optional.
  119. *
  120. * @return Boolean
  121. */
  122. public function isOptional()
  123. {
  124. return $this->optional;
  125. }
  126. /**
  127. * Returns the annotation alias name.
  128. *
  129. * @return string
  130. * @see ConfigurationInterface
  131. */
  132. public function getAliasName()
  133. {
  134. return 'converters';
  135. }
  136. }