Guest User

Untitled

a guest
Mar 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. namespace StagebitTestimonialModelFormData;
  2. use StagebitTestimonialModelResourceModelTestimonialCollectionFactory;
  3. use MagentoUiDataProviderAbstractDataProvider;
  4. class DataProvider extends AbstractDataProvider
  5. {
  6. /**
  7. * @param string $name
  8. * @param string $primaryFieldName
  9. * @param string $requestFieldName
  10. * @param CollectionFactory $testimonialCollectionFactory
  11. * @param array $meta
  12. * @param array $data
  13. */
  14. public function __construct(
  15. $name,
  16. $primaryFieldName,
  17. $requestFieldName,
  18. CollectionFactory $testimonialCollectionFactory,
  19. array $meta = [],
  20. array $data = []
  21. ) {
  22. $this->collection = $testimonialCollectionFactory->create();
  23. parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
  24. }
  25.  
  26. /**
  27. * Get data
  28. *
  29. * @return array
  30. */
  31. public function getData()
  32. {
  33. if (isset($this->_loadedData)) {
  34. return $this->_loadedData;
  35. }
  36. $items = $this->collection->getItems();
  37. foreach ($items as $testimonial) {
  38. $this->_loadedData[$testimonial->getTestimonialId()] = $testimonial->getData();
  39. }
  40. //return $this->_loadedData;
  41. }
  42. }
Add Comment
Please, Sign In to add comment