AttributeMetadata.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\Model\Data;
  7. use Magento\Customer\Api\Data\AttributeMetadataInterface;
  8. /**
  9. * Customer attribute metadata class.
  10. */
  11. class AttributeMetadata extends \Magento\Framework\Api\AbstractSimpleObject implements
  12. \Magento\Customer\Api\Data\AttributeMetadataInterface,
  13. \Magento\Eav\Api\Data\AttributeDefaultValueInterface
  14. {
  15. /**
  16. * {@inheritdoc}
  17. */
  18. public function getAttributeCode()
  19. {
  20. return $this->_get(self::ATTRIBUTE_CODE);
  21. }
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function getFrontendInput()
  26. {
  27. return $this->_get(self::FRONTEND_INPUT);
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function getInputFilter()
  33. {
  34. return $this->_get(self::INPUT_FILTER);
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function getStoreLabel()
  40. {
  41. return $this->_get(self::STORE_LABEL);
  42. }
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function getValidationRules()
  47. {
  48. return $this->_get(self::VALIDATION_RULES);
  49. }
  50. /**
  51. * {@inheritdoc}
  52. */
  53. public function getMultilineCount()
  54. {
  55. return $this->_get(self::MULTILINE_COUNT);
  56. }
  57. /**
  58. * {@inheritdoc}
  59. */
  60. public function isVisible()
  61. {
  62. return $this->_get(self::VISIBLE);
  63. }
  64. /**
  65. * {@inheritdoc}
  66. */
  67. public function isRequired()
  68. {
  69. return $this->_get(self::REQUIRED);
  70. }
  71. /**
  72. * {@inheritdoc}
  73. */
  74. public function getDataModel()
  75. {
  76. return $this->_get(self::DATA_MODEL);
  77. }
  78. /**
  79. * {@inheritdoc}
  80. */
  81. public function getOptions()
  82. {
  83. return $this->_get(self::OPTIONS);
  84. }
  85. /**
  86. * {@inheritdoc}
  87. */
  88. public function getFrontendClass()
  89. {
  90. return $this->_get(self::FRONTEND_CLASS);
  91. }
  92. /**
  93. * {@inheritdoc}
  94. */
  95. public function isUserDefined()
  96. {
  97. return $this->_get(self::USER_DEFINED);
  98. }
  99. /**
  100. * {@inheritdoc}
  101. */
  102. public function getSortOrder()
  103. {
  104. return $this->_get(self::SORT_ORDER);
  105. }
  106. /**
  107. * {@inheritdoc}
  108. */
  109. public function getFrontendLabel()
  110. {
  111. return $this->_get(self::FRONTEND_LABEL);
  112. }
  113. /**
  114. * {@inheritdoc}
  115. */
  116. public function getNote()
  117. {
  118. return $this->_get(self::NOTE);
  119. }
  120. /**
  121. * {@inheritdoc}
  122. */
  123. public function isSystem()
  124. {
  125. return $this->_get(self::SYSTEM);
  126. }
  127. /**
  128. * {@inheritdoc}
  129. */
  130. public function getBackendType()
  131. {
  132. return $this->_get(self::BACKEND_TYPE);
  133. }
  134. /**
  135. * Set attribute code
  136. *
  137. * @param string $attributeCode
  138. * @return $this
  139. */
  140. public function setAttributeCode($attributeCode)
  141. {
  142. return $this->setData(self::ATTRIBUTE_CODE, $attributeCode);
  143. }
  144. /**
  145. * Set frontend HTML for input element.
  146. *
  147. * @param string $frontendInput
  148. * @return $this
  149. */
  150. public function setFrontendInput($frontendInput)
  151. {
  152. return $this->setData(self::FRONTEND_INPUT, $frontendInput);
  153. }
  154. /**
  155. * Set template used for input (e.g. "date")
  156. *
  157. * @param string $inputFilter
  158. * @return $this
  159. */
  160. public function setInputFilter($inputFilter)
  161. {
  162. return $this->setData(self::INPUT_FILTER, $inputFilter);
  163. }
  164. /**
  165. * Set label of the store.
  166. *
  167. * @param string $storeLabel
  168. * @return $this
  169. */
  170. public function setStoreLabel($storeLabel)
  171. {
  172. return $this->setData(self::STORE_LABEL, $storeLabel);
  173. }
  174. /**
  175. * Set validation rules.
  176. *
  177. * @param \Magento\Customer\Api\Data\ValidationRuleInterface[] $validationRules
  178. * @return $this
  179. */
  180. public function setValidationRules(array $validationRules)
  181. {
  182. return $this->setData(self::VALIDATION_RULES, $validationRules);
  183. }
  184. /**
  185. * Set number of lines of the attribute value.
  186. *
  187. * @param int $multilineCount
  188. * @return $this
  189. */
  190. public function setMultilineCount($multilineCount)
  191. {
  192. return $this->setData(self::MULTILINE_COUNT, $multilineCount);
  193. }
  194. /**
  195. * Set whether attribute is visible on frontend.
  196. *
  197. * @param bool $isVisible
  198. * @return $this
  199. */
  200. public function setIsVisible($isVisible)
  201. {
  202. return $this->setData(self::VISIBLE, $isVisible);
  203. }
  204. /**
  205. * Whether attribute is required.
  206. *
  207. * @param bool $isRequired
  208. * @return $this
  209. */
  210. public function setIsRequired($isRequired)
  211. {
  212. return $this->setData(self::REQUIRED, $isRequired);
  213. }
  214. /**
  215. * Get data model for attribute.
  216. *
  217. * @param string $dataModel
  218. * @return $this
  219. */
  220. public function setDataModel($dataModel)
  221. {
  222. return $this->setData(self::DATA_MODEL, $dataModel);
  223. }
  224. /**
  225. * Set options of the attribute (key => value pairs for select)
  226. *
  227. * @param \Magento\Customer\Api\Data\OptionInterface[] $options
  228. * @return $this
  229. */
  230. public function setOptions(array $options = null)
  231. {
  232. return $this->setData(self::OPTIONS, $options);
  233. }
  234. /**
  235. * Set class which is used to display the attribute on frontend.
  236. *
  237. * @param string $frontendClass
  238. * @return $this
  239. */
  240. public function setFrontendClass($frontendClass)
  241. {
  242. return $this->setData(self::FRONTEND_CLASS, $frontendClass);
  243. }
  244. /**
  245. * Set whether current attribute has been defined by a user.
  246. *
  247. * @param bool $isUserDefined
  248. * @return $this
  249. */
  250. public function setIsUserDefined($isUserDefined)
  251. {
  252. return $this->setData(self::USER_DEFINED, $isUserDefined);
  253. }
  254. /**
  255. * Get attributes sort order.
  256. *
  257. * @param int $sortOrder
  258. * @return $this
  259. */
  260. public function setSortOrder($sortOrder)
  261. {
  262. return $this->setData(self::SORT_ORDER, $sortOrder);
  263. }
  264. /**
  265. * Set label which supposed to be displayed on frontend.
  266. *
  267. * @param string $frontendLabel
  268. * @return $this
  269. */
  270. public function setFrontendLabel($frontendLabel)
  271. {
  272. return $this->setData(self::FRONTEND_LABEL, $frontendLabel);
  273. }
  274. /**
  275. * Set the note attribute for the element.
  276. *
  277. * @param string $note
  278. * @return $this
  279. */
  280. public function setNote($note)
  281. {
  282. return $this->setData(self::NOTE, $note);
  283. }
  284. /**
  285. * Set whether this is a system attribute.
  286. *
  287. * @param bool $isSystem
  288. * @return $this
  289. */
  290. public function setIsSystem($isSystem)
  291. {
  292. return $this->setData(self::SYSTEM, $isSystem);
  293. }
  294. /**
  295. * Set backend type.
  296. *
  297. * @param string $backendType
  298. * @return $this
  299. */
  300. public function setBackendType($backendType)
  301. {
  302. return $this->setData(self::BACKEND_TYPE, $backendType);
  303. }
  304. /**
  305. * @inheritDoc
  306. */
  307. public function getIsUsedInGrid()
  308. {
  309. return $this->_get(self::IS_USED_IN_GRID);
  310. }
  311. /**
  312. * @inheritDoc
  313. */
  314. public function getIsVisibleInGrid()
  315. {
  316. return $this->_get(self::IS_VISIBLE_IN_GRID);
  317. }
  318. /**
  319. * @inheritDoc
  320. */
  321. public function getIsFilterableInGrid()
  322. {
  323. return $this->_get(self::IS_FILTERABLE_IN_GRID);
  324. }
  325. /**
  326. * @inheritDoc
  327. */
  328. public function getIsSearchableInGrid()
  329. {
  330. return $this->_get(self::IS_SEARCHABLE_IN_GRID);
  331. }
  332. /**
  333. * @inheritDoc
  334. */
  335. public function setIsUsedInGrid($isUsedInGrid)
  336. {
  337. return $this->setData(self::IS_USED_IN_GRID, $isUsedInGrid);
  338. }
  339. /**
  340. * @inheritDoc
  341. */
  342. public function setIsVisibleInGrid($isVisibleInGrid)
  343. {
  344. return $this->setData(self::IS_VISIBLE_IN_GRID, $isVisibleInGrid);
  345. }
  346. /**
  347. * @inheritDoc
  348. */
  349. public function setIsFilterableInGrid($isFilterableInGrid)
  350. {
  351. return $this->setData(self::IS_FILTERABLE_IN_GRID, $isFilterableInGrid);
  352. }
  353. /**
  354. * @inheritDoc
  355. */
  356. public function setIsSearchableInGrid($isSearchableInGrid)
  357. {
  358. return $this->setData(self::IS_SEARCHABLE_IN_GRID, $isSearchableInGrid);
  359. }
  360. /**
  361. * @inheritdoc
  362. */
  363. public function getDefaultValue()
  364. {
  365. return $this->_get(self::DEFAULT_VALUE);
  366. }
  367. /**
  368. * @inheritdoc
  369. */
  370. public function setDefaultValue($defaultValue)
  371. {
  372. return $this->setData(self::DEFAULT_VALUE, $defaultValue);
  373. }
  374. }