src/BackendBundle/Helper/GraphQlCommonHelper.php line 504

Open in your IDE?
  1. <?php
  2. namespace App\BackendBundle\Helper;
  3. use DateTime;
  4. use Doctrine\ORM\EntityManagerInterface;
  5. use Liip\ImagineBundle\Imagine\Cache\CacheManager;
  6. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  7. use App\BackendBundle\Helper\AddressHelper;
  8. use App\BackendBundle\Helper\MediaHelper;
  9. use App\BackendBundle\Helper\VideoHelper;
  10. use App\BackendBundle\Model\GraphQL\Address as AddressGQL;
  11. use App\BackendBundle\Model\GraphQL\AddressCity as AddressCityGQL;
  12. use App\BackendBundle\Model\GraphQL\AddressDistrict as AddressDistrictGQL;
  13. use App\BackendBundle\Model\GraphQL\AddressLatLon as AddressLatLonGQL;
  14. use App\BackendBundle\Model\GraphQL\Contact as ContactGQL;
  15. use App\BackendBundle\Model\GraphQL\ContactGallery as ContactGalleryGQL;
  16. use App\BackendBundle\Model\GraphQL\ContactGalleryEntry as ContactGalleryEntryGQL;
  17. use App\BackendBundle\Model\GraphQL\Communication as CommunicationGQL;
  18. use App\BackendBundle\Model\GraphQL\CommunicationEntry as CommunicationEntryGQL;
  19. use App\BackendBundle\Model\GraphQL\CommunicationType as CommunicationTypeGQL;
  20. use App\BackendBundle\Model\GraphQL\Document as DocumentGQL;
  21. use App\BackendBundle\Model\GraphQL\EventTag as EventTagGQL;
  22. use App\BackendBundle\Model\GraphQL\Gallery as GalleryGQL;
  23. use App\BackendBundle\Model\GraphQL\Image;
  24. use App\BackendBundle\Model\GraphQL\ImageData;
  25. use App\BackendBundle\Model\GraphQL\ImageInfo;
  26. use App\BackendBundle\Model\GraphQL\Media as MediaGQL;
  27. use App\BackendBundle\Model\GraphQL\Person as PersonGQL;
  28. use App\BackendBundle\Model\GraphQL\ProfileLink as ProfileLinkGQL;
  29. use App\BackendBundle\Model\GraphQL\ProfileLinkEntry as ProfileLinkEntryGQL;
  30. use App\BackendBundle\Model\GraphQL\ProfileType as ProfileTypeGQL;
  31. use App\BackendBundle\Model\GraphQL\Title as TitleGQL;
  32. use App\BackendBundle\Interfaces\ProfileInterface;
  33. use App\Entity\Address;
  34. use App\Entity\AddressCity;
  35. use App\Entity\AddressDistrict;
  36. use App\Entity\AddressLatLon;
  37. use App\Entity\Communication;
  38. use App\Entity\CommunicationEntry;
  39. use App\Entity\CommunicationType;
  40. use App\Entity\Contact;
  41. use App\Entity\ContactGallery;
  42. use App\Entity\ContactGalleryEntry;
  43. use App\Entity\Event;
  44. use App\Entity\EventState;
  45. use App\Entity\EventTagMapping;
  46. use App\Entity\EventTag;
  47. use App\Entity\Gallery;
  48. use App\Entity\GalleryHasMedia;
  49. use App\Entity\Job;
  50. use App\Entity\JobDailyRoutine;
  51. use App\Entity\Media;
  52. use App\Entity\Person;
  53. use App\Entity\ProfileLink;
  54. use App\Entity\ProfileLinkEntry;
  55. use App\Entity\ProfileLinkType;
  56. use App\Entity\ProfileType;
  57. use App\Entity\Title;
  58. class GraphQlCommonHelper {
  59.     private EntityManagerInterface $em;
  60.     private AddressHelper $addressHelper;
  61.     private CacheManager $imagineCacheManager;
  62.     private MediaHelper $mediaHelper;
  63.     private VideoHelper $videoHelper;
  64.     private $imageDomain;
  65.     public function __construct(EntityManagerInterface $em$imageDomainAddressHelper $addressHelperCacheManager $imagineCacheManager,
  66.             MediaHelper $mediaHelperVideoHelper $videoHelper) {
  67.         $this->em $em;
  68.         $this->addressHelper $addressHelper;
  69.         $this->imageDomain $imageDomain;
  70.         $this->imagineCacheManager $imagineCacheManager;
  71.         $this->mediaHelper $mediaHelper;
  72.         $this->videoHelper $videoHelper;
  73.     }
  74.     public function getAddress(Address $address null) {
  75.         if (empty($address)) {
  76.             return null;
  77.         }
  78.         $addressGQL = new AddressGQL();
  79.         $addressGQL->setId($address->getId());
  80.         $addressGQL->setStreet($address->getStreet());
  81.         $addressGQL->setNumber($address->getNumber());
  82.         $addressGQL->setFloor($address->getFloor());
  83.         $addressGQL->setStair($address->getStair());
  84.         /* @var $addressCity AddressCity */
  85.         $addressCity $address->getAddressCity();
  86.         if (!empty($addressCity)) {
  87.             $addressCityGQL $this->getAddressCity($addressCity);
  88.             $addressGQL->setAddressCity($addressCityGQL);
  89.         }
  90.         $this->setAddressLatLon($addressGQL$address);
  91.         return $addressGQL;
  92.     }
  93.     public function getAddressCity(AddressCity $addressCity) {
  94.         $addressCityGQL = new AddressCityGQL();
  95.         $addressCityGQL->setId($addressCity->getId());
  96.         $addressCityGQL->setName($addressCity->getName());
  97.         $addressCityGQL->setZip($addressCity->getZip());
  98.         /* @var $addressDistrict AddressDistrict */
  99.         $addressDistrict $addressCity->getAddressDistrict();
  100.         if (!empty($addressDistrict)) {
  101.             $addressDistrictGQL $this->getAddressDistrict($addressDistrict);
  102.             $addressCityGQL->setAddressDistrict($addressDistrictGQL);
  103.         }
  104.         return $addressCityGQL;
  105.     }
  106.     public function getAddressDistrict(AddressDistrict $addressDistrict) {
  107.         $addressDistrictGQL = new AddressDistrictGQL();
  108.         $addressDistrictGQL->setId($addressDistrict->getId());
  109.         $addressDistrictGQL->setBkz($addressDistrict->getBkz());
  110.         $addressDistrictGQL->setName($addressDistrict->getName());
  111.         return $addressDistrictGQL;
  112.     }
  113.     private function setAddressLatLon(AddressGQL $addressGQLAddress $address) {
  114.         /* @var $addressLatLon AddressLatLon */
  115.         $addressLatLon $address->getAddressLatLon();
  116.         if (empty($addressLatLon)) {
  117.             return;
  118.         }
  119.         $addressLatLonGQL = new AddressLatLonGQL();
  120.         $addressLatLonGQL->setId($addressLatLon->getId());
  121.         $addressLatLonGQL->setLat($addressLatLon->getLat());
  122.         $addressLatLonGQL->setLon($addressLatLon->getLon());
  123.         $addressGQL->setAddressLatLon($addressLatLonGQL);
  124.     }
  125.     public function getCommunication(Communication $comm null) {
  126.         if (empty($comm)) {
  127.             return null;
  128.         }
  129.         $commGQL = new CommunicationGQL();
  130.         $commGQL->setId($comm->getId());
  131.         $entriesSrc $comm->getCommunicationEntries();
  132.         foreach ($entriesSrc as $entrySrc) {
  133.             $entry $this->getCommuncationEntry($entrySrc);
  134.             $commGQL->addEntry($entry);
  135.         }
  136.         return $commGQL;
  137.     }
  138.     public function getCommuncationEntry(CommunicationEntry $commEntry null) {
  139.         if (empty($commEntry)) {
  140.             return null;
  141.         }
  142.         $commEntryGQL = new CommunicationEntryGQL();
  143.         $commEntryGQL->setId($commEntry->getId());
  144.         $commEntryGQL->setEntryValue($commEntry->getEntryValue());
  145.         $commType $this->getCommunicationType($commEntry->getCommunicationType());
  146.         $commEntryGQL->setCommunicationType($commType);
  147.         return $commEntryGQL;
  148.     }
  149.     public function getCommunicationType(CommunicationType $commType null) {
  150.         if (empty($commType)) {
  151.             return null;
  152.         }
  153.         $commTypeGQL = new CommunicationTypeGQL();
  154.         $commTypeGQL->setName($commType->getName());
  155.         $commTypeGQL->setShortName($commType->getShortName());
  156.         return $commTypeGQL;
  157.     }
  158.     public function getContactGallery(ContactGallery $contactGallery null$showAllContacts false) {
  159.         if (empty($contactGallery)) {
  160.             return null;
  161.         }
  162.         $contactGalleryGQL = new ContactGalleryGQL();
  163.         $contactGalleryGQL->setId($contactGallery->getId());
  164.         $this->addContactGalleryEntries($contactGalleryGQL$contactGallery$showAllContacts);
  165.         return $contactGalleryGQL;
  166.     }
  167.     public function addContactGalleryEntries(ContactGalleryGQL $contactGalleryGQLContactGallery $contactGallery$showAllContacts) {
  168.         $contactGalleryEntries $contactGallery->getGalleryEntries();
  169.         /* @var $contactGalleryEntry ContactGalleryEntry */
  170.         foreach ($contactGalleryEntries as $contactGalleryEntry) {
  171.             $isEnabled $contactGalleryEntry->getEnabled();
  172.             if (!$showAllContacts && !$isEnabled) {
  173.                 continue;
  174.             }
  175.             $contactGalleryEntryGQL $this->getContactGalleryEntry($contactGalleryEntry);
  176.             $contactGalleryGQL->addGalleryEntry($contactGalleryEntryGQL);
  177.         }
  178.     }
  179.     public function getContactGalleryEntry(ContactGalleryEntry $contactGalleryEntry) {
  180.         $contactGalleryEntryGQL = new ContactGalleryEntryGQL();
  181.         $contactGalleryEntryGQL->setId($contactGalleryEntry->getId());
  182.         $contactGalleryEntryGQL->setEnabled($contactGalleryEntry->getEnabled());
  183.         $contact $contactGalleryEntry->getContact();
  184.         $contactGQL $this->getContact($contact);
  185.         $contactGalleryEntryGQL->setContact($contactGQL);
  186.         return $contactGalleryEntryGQL;
  187.     }
  188.     public function getContact(Contact $contact null) {
  189.         if (empty($contact)) {
  190.             return null;
  191.         }
  192.         $contactGQL = new ContactGQL();
  193.         $contactGQL->setId($contact->getId());
  194.         $contactGQL->setEmployeePosition($contact->getEmployeePosition());
  195.         $personGQL $this->getPerson($contact->getPerson());
  196.         $contactGQL->setPerson($personGQL);
  197.         $picture $this->generateThumbnails($contact->getContactProfilePicture());
  198.         $contactGQL->setPicture($picture);
  199.         $commSrc $contact->getCommunication();
  200.         $communication $this->getCommunication($commSrc);
  201.         $contactGQL->setCommunication($communication);
  202.         return $contactGQL;
  203.     }
  204.     public function getDateString(DateTime $dateTime null) {
  205.         if (empty($dateTime)) {
  206.             return '';
  207.         }
  208.         return $dateTime->format("d.m.Y");
  209.     }
  210.     public function getEventState(EventState $eventState null) {
  211.         if (empty($eventState)) {
  212.             return null;
  213.         }
  214.         $stateID $eventState->getId();
  215.         switch ($stateID) {
  216.             case 1:
  217.                 return 'ACTIVE';
  218.             case 2:
  219.                 return 'INACTIVE';
  220.             case 3:
  221.                 return 'DELETED';
  222.             default:
  223.                 return null;
  224.         }
  225.     }
  226.     public function getEventTag(EventTagMapping $eventTagMapping null) {
  227.         if (empty($eventTagMapping)) {
  228.             return null;
  229.         }
  230.         /* @var $eventTag EventTag */
  231.         $eventTag $eventTagMapping->getEventTag();
  232.         $eventTagGQL = new EventTagGQL();
  233.         $eventTagGQL->setTagName($eventTag->getName());
  234.         return $eventTagGQL;
  235.     }
  236.     private function getVideoUrl(Job $job) {
  237.         $jobDailyRoutines $this->jobHelper->getJobDailyRoutinesByJob($job);
  238.         if (count($jobDailyRoutines) == 0) {
  239.             return null;
  240.         }
  241.         /* @var $jobDailyRoutine JobDailyRoutine */
  242.         $jobDailyRoutine $jobDailyRoutines[0];
  243.         return $jobDailyRoutine->getVideoUrl();
  244.     }
  245.     public function getImageByID($mediaID) {
  246.         $image = new Image();
  247.         $media $this->mediaHelper->getMediaById($mediaID);
  248.         if (empty($media)) {
  249.             return $image;
  250.         }
  251.         $imagePath $this->mediaHelper->getPath($media);
  252.         $pathMedium $this->imagineCacheManager->getBrowserPath($imagePath'tn_medium');
  253.         $image->setMedium($pathMedium);
  254.         return $image;
  255.     }
  256.     public function generateThumbnailFilter(Media $media null$liipFilter) {
  257.         $image = new Image();
  258.         if (empty('media')) {
  259.             return $image;
  260.         }
  261.         $imagePath $this->mediaHelper->getPath($media);
  262.         $this->imagineCacheManager->getBrowserPath($imagePath$liipFilter);
  263.         return $image;
  264.     }
  265.     public function generateThumbnailsByID($mediaID) {
  266.         $media $this->mediaHelper->getMediaById($mediaID);
  267.         if (empty($media)) {
  268.             $image = new Image();
  269.             return $image;
  270.         }
  271.         return $this->generateThumbnails($media);
  272.     }
  273.     public function generateThumbnails(Media $media null) {
  274.         if (empty($media)) {
  275.             return null;
  276.         }
  277.         $image = new Image();
  278.         $image->setId($media->getId());
  279.         $imagePath $this->mediaHelper->getPath($media);
  280.         /* set image info */
  281.         $imageInfo = new ImageInfo();
  282.         $imageInfo->setCaption($media->getName());
  283.         $copyright $media->getCopyright();
  284.         $imageInfo->setCopyright($copyright);
  285.         $image->setInfo($imageInfo);
  286.         /* set image data */
  287.         $image->setMedium($this->getImageData($imagePath'tn_medium'527));
  288.         $image->setPortrait($this->getImageData($imagePath'tn_portrait'1000));
  289.         $image->setLandscape($this->getImageData($imagePath'tn_landscape'1240));
  290.         $image->setLarge($this->getImageData($imagePath'tn_large'1560));
  291.         $image->setXlarge($this->getImageData($imagePath'tn_xlarge'1900));
  292.         $image->setHuge($this->getImageData($imagePath'tn_huge'2800));
  293.         return $image;
  294.     }
  295.     private function getImageData($imagePath$filter$width) {
  296.         /* Generate path for the filter */
  297.         $relativePath $this->imagineCacheManager->generateUrl($imagePath$filter, [], nullUrlGeneratorInterface::ABSOLUTE_PATH);
  298.         $mediaPath $this->imageDomain $relativePath;
  299.         $imageData = new ImageData();
  300.         $imageData->setUrl($mediaPath);
  301.         $imageData->setWidth($width);
  302.         return $imageData;
  303.     }
  304.     public function getMediaDocument(Media $media null) {
  305.         if (empty($media)) {
  306.             return null;
  307.         }
  308.         $mediaID $media->getId();
  309.         $mediaName $media->getName();
  310.         $mediaGQL = new MediaGQL();
  311.         $mediaGQL->setId($mediaID);
  312.         $mediaGQL->setContentType("DOCUMENT");
  313.         $mediaGQL->setName($mediaName);
  314.         $document = new DocumentGQL();
  315.         $document->setId($mediaID);
  316.         $document->setName($mediaName);
  317.         $mediaLink $this->mediaHelper->getMediaLink($media);
  318.         $document->setFilePath($mediaLink);
  319.         $mediaGQL->setDocument($document);
  320.         return $mediaGQL;
  321.     }
  322.     public function getMediaImage(Media $media null) {
  323.         if (empty($media)) {
  324.             return null;
  325.         }
  326.         $mediaID $media->getId();
  327.         $mediaGQL = new MediaGQL();
  328.         $mediaGQL->setId($mediaID);
  329.         $mediaGQL->setContentType("IMAGE");
  330.         $image $this->generateThumbnails($media);
  331.         $mediaGQL->setImage($image);
  332.         return $mediaGQL;
  333.     }
  334.     public function getGalleryHasMediaImage(GalleryHasMedia $galleryHasMedia null) {
  335.         if (empty($galleryHasMedia)) {
  336.             return null;
  337.         }
  338.         $media $galleryHasMedia->getMedia();
  339.         if (empty($media)) {
  340.             return null;
  341.         }
  342.         $galleryHasMediaID $galleryHasMedia->getId();
  343.         $mediaGQL = new MediaGQL();
  344.         $mediaGQL->setContentType("IMAGE");
  345.         $mediaGQL->setId($galleryHasMediaID);
  346.         $mediaGQL->setPosition($galleryHasMedia->getPosition());
  347.         $mediaGQL->setVisible($galleryHasMedia->getEnabled());
  348.         $image $this->generateThumbnails($media);
  349.         $mediaGQL->setImage($image);
  350.         return $mediaGQL;
  351.     }
  352.     public function getMediaVideo(Media $media null) {
  353.         if (empty($media)) {
  354.             return null;
  355.         }
  356.         $mediaGQL = new MediaGQL();
  357.         $mediaGQL->setContentType("VIDEO");
  358.         $mediaGQL->setId($media->getId());
  359.         $video $this->videoHelper->getVideoByMedia($media);
  360.         $mediaGQL->setVideo($video);
  361.         return $mediaGQL;
  362.     }
  363.     public function getGalleryHasMediaVideo(GalleryHasMedia $galleryHasMedia null) {
  364.         if (empty($galleryHasMedia)) {
  365.             return null;
  366.         }
  367.         $media $galleryHasMedia->getMedia();
  368.         if (empty($media)) {
  369.             return null;
  370.         }
  371.         $galleryHasMediaID $galleryHasMedia->getId();
  372.         $mediaGQL = new MediaGQL();
  373.         $mediaGQL->setContentType("VIDEO");
  374.         $mediaGQL->setId($galleryHasMediaID);
  375.         $mediaGQL->setPosition($galleryHasMedia->getPosition());
  376.         $mediaGQL->setVisible($galleryHasMedia->getEnabled());
  377.         $video $this->videoHelper->getVideoByMedia($media);
  378.         $mediaGQL->setVideo($video);
  379.         return $mediaGQL;
  380.     }
  381.     public function getGalleryHasMediaDocument(GalleryHasMedia $galleryHasMedia null) {
  382.         if (empty($galleryHasMedia)) {
  383.             return null;
  384.         }
  385.         $media $galleryHasMedia->getMedia();
  386.         if (empty($media)) {
  387.             return null;
  388.         }
  389.         $mediaGQL = new MediaGQL();
  390.         $mediaGQL->setContentType("DOCUMENT");
  391.         $mediaGQL->setId($galleryHasMedia->getId());
  392.         $mediaGQL->setPosition($galleryHasMedia->getPosition());
  393.         $mediaGQL->setVisible($galleryHasMedia->getEnabled());
  394.         $document $this->getMediaDocument($media);
  395.         $mediaGQL->setDocument($document);
  396.         return $mediaGQL;
  397.     }
  398.     public function getPerson(Person $person null) {
  399.         if (empty($person)) {
  400.             return null;
  401.         }
  402.         $personGQL = new PersonGQL();
  403.         $personGQL->setId($person->getId());
  404.         $personGQL->setFirstname($person->getFirstname());
  405.         $personGQL->setLastname($person->getLastname());
  406.         $personGQL->setSex($person->getSex());
  407.         $titlesSrc $person->getTitles();
  408.         /* @var $titleSrc Title */
  409.         foreach ($titlesSrc as $titleSrc) {
  410.             $title = new TitleGQL();
  411.             $title->setId($titleSrc->getId());
  412.             $title->setShortName($titleSrc->getShortName());
  413.             $title->setDescription($titleSrc->getDescription());
  414.             $personGQL->addTitle($title);
  415.         }
  416.         return $personGQL;
  417.     }
  418.     public function getProfileLink(ProfileInterface $profileSrc) {
  419.         /* @var $profileLinkSrc ProfileLink */
  420.         $profileLinkSrc $profileSrc->getProfileLink();
  421.         if (empty($profileLinkSrc)) {
  422.             return null;
  423.         }
  424.         $profileLink = new ProfileLinkGQL();
  425.         /* @var $createdAt DateTime */
  426.         $createdAt $profileLinkSrc->getCreatedAt();
  427.         $profileLink->setCreatedAt($createdAt->format("d.m.Y H:m"));
  428.         $entries $profileLinkSrc->getProfileLinkEntries();
  429.         foreach ($entries as $entry) {
  430.             $this->addProfileLinkEntry($profileLink$entry);
  431.         }
  432.         return $profileLink;
  433.     }
  434.     private function addProfileLinkEntry(ProfileLinkGQL $profileLinkGQLProfileLinkEntry $profileLinkEntry) {
  435.         $linkValue $profileLinkEntry->getLinkValue();
  436.         // ignore empty link values -> can happen, if a previously present link is removed
  437.         if (empty($linkValue)) {
  438.             return;
  439.         }
  440.         /* @var $linkType ProfileLinkType */
  441.         $linkType $profileLinkEntry->getLinkType();
  442.         $typePosition $linkType->getPosition();
  443.         $profileLinkEntryGQL = new ProfileLinkEntryGQL();
  444.         $profileLinkEntryGQL->setId($profileLinkEntry->getId());
  445.         $profileLinkEntryGQL->setLinkType($linkType->getTypeName());
  446.         $profileLinkEntryGQL->setLinkValue($linkValue);
  447.         $profileLinkGQL->addEntry($profileLinkEntryGQL$typePosition);
  448.     }
  449.     public function getProfileMediaGallery(ProfileInterface $profile$showAllGalleryItems false) {
  450.         $galleryImages $profile->getGallery();
  451.         $galleryVideos $profile->getVideos();
  452.         $mediaGalleryGQL $this->getMediaGallery($galleryImages$galleryVideos$showAllGalleryItems);
  453.         /* sort items can only be done after all media items have been added - 
  454.          * media gallery contains items from different galleries pictures and videos */
  455.         $mediaGalleryGQL->sortItems();
  456.         return $mediaGalleryGQL;
  457.     }
  458.     public function getProfileType(ProfileType $profileType) {
  459.         $profileTypeGQL = new ProfileTypeGQL();
  460.         $profileTypeGQL->setId($profileType->getId());
  461.         $profileTypeGQL->setName($profileType->getName());
  462.         $profileTypeGQL->setShortName($profileType->getShortName());
  463.         $profileTypeGQL->setPosition($profileType->getPosition());
  464.         return $profileTypeGQL;
  465.     }
  466.     public function getProfileTypeByID($id) {
  467.         $profileTypeGQL = new ProfileTypeGQL();
  468.         /* @var $profileType ProfileType */
  469.         $profileType $this->em->getRepository(ProfileType::class)->find($id);
  470.         if (empty($profileType)) {
  471.             return $profileTypeGQL;
  472.         }
  473.         $profileTypeGQL->setId($profileType->getId());
  474.         $profileTypeGQL->setName($profileType->getName());
  475.         $profileTypeGQL->setShortName($profileType->getShortName());
  476.         $profileTypeGQL->setPosition($profileType->getPosition());
  477.         return $profileTypeGQL;
  478.     }
  479.     public function getProfileDocumentGallery(ProfileInterface $profile$showAllGalleryItems false) {
  480.         $documents $profile->getDocuments();
  481.         return $this->getDocumentGallery($documents$showAllGalleryItems);
  482.     }
  483.     public function getEventMediaGallery(Event $event) {
  484.         $galleryImages $event->getGallery();
  485.         $galleryVideos $event->getVideos();
  486.         return $this->getMediaGallery($galleryImages$galleryVideos);
  487.     }
  488.     public function getDocumentGallery($documents null$showAllGalleryItems false) {
  489.         $documentGalleryGQL = new GalleryGQL();
  490.         $documentGalleryGQL->setId(0);
  491.         $documentGalleryGQL->setName('documents');
  492.         if (empty($documents)) {
  493.             return $documentGalleryGQL;
  494.         }
  495.         $documentGalleryGQL->setId($documents->getId());
  496.         $documentGalleryGQL->setName($documents->getName());
  497.         $galleryHasMedias $documents->getGalleryItems();
  498.         /* @var $galleryHasMedia GalleryHasMedia */
  499.         foreach ($galleryHasMedias as $galleryHasMedia) {
  500.             $enabled $galleryHasMedia->getEnabled();
  501.             if (!$showAllGalleryItems && !$enabled) {
  502.                 continue;
  503.             }
  504.             $document $this->getGalleryHasMediaDocument($galleryHasMedia);
  505.             $documentGalleryGQL->addGalleryItem($document);
  506.         }
  507.         return $documentGalleryGQL;
  508.     }
  509.     private function getMediaGallery($galleryImages$galleryVideos$showAllGalleryItems false) {
  510.         $mediaGallery = new GalleryGQL();
  511.         $mediaGallery->setName("mixed");
  512.         if (!empty($galleryImages)) {
  513.             $this->addMediaImage($mediaGallery$galleryImages$showAllGalleryItems);
  514.         }
  515.         if (!empty($galleryVideos)) {
  516.             $this->addMediaVideo($mediaGallery$galleryVideos$showAllGalleryItems);
  517.         }
  518.         return $mediaGallery;
  519.     }
  520.     private function addMediaImage(GalleryGQL $mediaGalleryGallery $galleryImages$showAllGalleryItems) {
  521.         $imageItems $galleryImages->getGalleryItems();
  522.         /* @var $galleryHasMedia GalleryHasMedia */
  523.         foreach ($imageItems as $galleryHasMedia) {
  524.             $enabled $galleryHasMedia->getEnabled();
  525.             if (!$showAllGalleryItems && !$enabled) {
  526.                 continue;
  527.             }
  528.             $media $this->getGalleryHasMediaImage($galleryHasMedia);
  529.             if (empty($media)) {
  530.                 continue;
  531.             }
  532.             $mediaGallery->addGalleryItem($media);
  533.         }
  534.     }
  535.     private function addMediaVideo(GalleryGQL $mediaGalleryGallery $galleryVideos$showAllGalleryItems) {
  536.         $videoItems $galleryVideos->getGalleryItems();
  537.         /* @var $galleryHasMedia GalleryHasMedia */
  538.         foreach ($videoItems as $galleryHasMedia) {
  539.             $enabled $galleryHasMedia->getEnabled();
  540.             if (!$showAllGalleryItems && !$enabled) {
  541.                 continue;
  542.             }
  543.             $media $this->getGalleryHasMediaVideo($galleryHasMedia);
  544.             $mediaGallery->addGalleryItem($media);
  545.         }
  546.     }
  547. }