protected function createFootprint($footprintName, $footprintData) { $fileService = $this->get("partkeepr_uploadedfile_service"); $footprintCategoryService = $this->get("partkeepr.footprint.category_service"); $footprintCategoryRootNode = $footprintCategoryService->getRootNode(); $footprint = new Footprint(); $footprint->setName($footprintName); if (array_key_exists("description", $footprintData)) { $footprint->setDescription($footprintData["description"]); } if (array_key_exists("category", $footprintData)) { $footprintCategory = $this->addFootprintCategoryPath(explode("/", $footprintData["category"]), $footprintCategoryRootNode); $footprint->setCategory($footprintCategory); } if (array_key_exists("image", $footprintData)) { $footprintImage = new FootprintImage(); $file = $this->get("kernel")->locateResource(self::FOOTPRINT_PATH . $footprintData["image"]); $fileService->replaceFromFilesystem($footprintImage, new File($file)); $footprint->setImage($footprintImage); } $this->get("doctrine.orm.default_entity_manager")->persist($footprint); }
protected function createFootprint($footprintName, $footprintData) { /** * @var FootprintCategory */ $footprintCategoryRootNode = $this->footprintCategoryService->getRootNode(); $footprint = new Footprint(); $footprint->setName($footprintName); if (array_key_exists('description', $footprintData)) { $footprint->setDescription($footprintData['description']); } if (array_key_exists('category', $footprintData)) { $footprintCategory = $this->addFootprintCategoryPath(explode('/', $footprintData['category']), $footprintCategoryRootNode); $footprint->setCategory($footprintCategory); } if (array_key_exists('image', $footprintData)) { $footprintImage = new FootprintImage(); $file = $this->kernel->locateResource(self::FOOTPRINT_PATH . $footprintData['image']); $this->uploadedFileService->replaceFromFilesystem($footprintImage, new File($file)); $footprint->setImage($footprintImage); } $this->entityManager->persist($footprint); }