/** * Set viewType * * @param \AppBundle\Entity\Core\Media $Media * * @return Attribute */ public function setMedia(\AppBundle\Entity\Core\Media $media = null) { $media->setEntityCode('slide'); $this->media = $media; return $this; }
public function loadBrendsCSV(ObjectManager $manager, $enables) { $data = getcwd() . '/src/AppBundle/DataFixtures/ORM/data/brends.csv'; if (($handle = fopen($data, "r")) !== FALSE) { $images = $this->getBrendImages(); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $media = false; if (isset($images[$data['0']])) { $media = new Media(); $media->setPath($images[$data['0']]); $media->setTitle($data['2']); $media->setPosition(1); } $entity = new Brend(); $entity->setEntryStatus($enables); $entity->setMetaDescription(strip_tags($data['4'])); $entity->setMetaKeywords(strip_tags($data['5'])); $entity->setMetaTitle($data['2']); $entity->setRoutePath('/brends/' . $this->slugify($data[2])); $entity->setContent($data['3']); $entity->setShortContent($data['4']); $entity->setTitle($data['2']); $site = mb_strlen($data[9]) < 5 ? '' : $data[9]; $entity->setWebsite($site); if ($media) { $entity->setMedia($media); } $manager->persist($entity); $manager->flush(); } fclose($handle); } }