vendor/sensio/framework-extra-bundle/src/Configuration/ParamConverter.php line 20

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Sensio\Bundle\FrameworkExtraBundle\Configuration;
  11. /**
  12. * The ParamConverter class handles the ParamConverter annotation parts.
  13. *
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. * @Annotation
  16. */
  17. class ParamConverter extends ConfigurationAnnotation
  18. {
  19. /**
  20. * The parameter name.
  21. *
  22. * @var string
  23. */
  24. private $name;
  25. /**
  26. * The parameter class.
  27. *
  28. * @var string
  29. */
  30. private $class;
  31. /**
  32. * An array of options.
  33. *
  34. * @var array
  35. */
  36. private $options = [];
  37. /**
  38. * Whether or not the parameter is optional.
  39. *
  40. * @var bool
  41. */
  42. private $isOptional = false;
  43. /**
  44. * Use explicitly named converter instead of iterating by priorities.
  45. *
  46. * @var string
  47. */
  48. private $converter;
  49. /**
  50. * Returns the parameter name.
  51. *
  52. * @return string
  53. */
  54. public function getName()
  55. {
  56. return $this->name;
  57. }
  58. /**
  59. * Sets the parameter name.
  60. *
  61. * @param string $name The parameter name
  62. */
  63. public function setValue($name)
  64. {
  65. $this->setName($name);
  66. }
  67. /**
  68. * Sets the parameter name.
  69. *
  70. * @param string $name The parameter name
  71. */
  72. public function setName($name)
  73. {
  74. $this->name = $name;
  75. }
  76. /**
  77. * Returns the parameter class name.
  78. *
  79. * @return string $name
  80. */
  81. public function getClass()
  82. {
  83. return $this->class;
  84. }
  85. /**
  86. * Sets the parameter class name.
  87. *
  88. * @param string $class The parameter class name
  89. */
  90. public function setClass($class)
  91. {
  92. $this->class = $class;
  93. }
  94. /**
  95. * Returns an array of options.
  96. *
  97. * @return array
  98. */
  99. public function getOptions()
  100. {
  101. return $this->options;
  102. }
  103. /**
  104. * Sets an array of options.
  105. *
  106. * @param array $options An array of options
  107. */
  108. public function setOptions($options)
  109. {
  110. $this->options = $options;
  111. }
  112. /**
  113. * Sets whether or not the parameter is optional.
  114. *
  115. * @param bool $optional Whether the parameter is optional
  116. */
  117. public function setIsOptional($optional)
  118. {
  119. $this->isOptional = (bool) $optional;
  120. }
  121. /**
  122. * Returns whether or not the parameter is optional.
  123. *
  124. * @return bool
  125. */
  126. public function isOptional()
  127. {
  128. return $this->isOptional;
  129. }
  130. /**
  131. * Get explicit converter name.
  132. *
  133. * @return string
  134. */
  135. public function getConverter()
  136. {
  137. return $this->converter;
  138. }
  139. /**
  140. * Set explicit converter name.
  141. *
  142. * @param string $converter
  143. */
  144. public function setConverter($converter)
  145. {
  146. $this->converter = $converter;
  147. }
  148. /**
  149. * Returns the annotation alias name.
  150. *
  151. * @return string
  152. *
  153. * @see ConfigurationInterface
  154. */
  155. public function getAliasName()
  156. {
  157. return 'converters';
  158. }
  159. /**
  160. * Multiple ParamConverters are allowed.
  161. *
  162. * @return bool
  163. *
  164. * @see ConfigurationInterface
  165. */
  166. public function allowArray()
  167. {
  168. return true;
  169. }
  170. }