setStorageLocation() public method

Sets the storage location for this part.
public setStorageLocation ( StorageLocation $storageLocation )
$storageLocation PartKeepr\StorageLocationBundle\Entity\StorageLocation The storage location
Example #1
0
 public function load(ObjectManager $manager)
 {
     $partUnit = new PartMeasurementUnit();
     $partUnit->setName("pieces");
     $partUnit->setShortName("pcs");
     $partUnit->setDefault(true);
     $part = new Part();
     $part->setName("FOOBAR");
     $part->setPartUnit($partUnit);
     $category = $this->getReference("partcategory.first");
     $storageLocation = $this->getReference("storagelocation.first");
     $part->setCategory($category);
     $part->setStorageLocation($storageLocation);
     $part2 = new Part();
     $part2->setName("FOOBAR2");
     $category = $this->getReference("partcategory.first");
     $storageLocation = $this->getReference("storagelocation.first");
     $part2->setCategory($category);
     $part2->setStorageLocation($storageLocation);
     $part2->setPartUnit($partUnit);
     $manager->persist($partUnit);
     $manager->persist($part);
     $manager->persist($part2);
     $manager->flush();
     $this->addReference("part.1", $part);
     $this->addReference("part.2", $part2);
 }
Example #2
0
 public function load(ObjectManager $manager)
 {
     $partUnit = new PartMeasurementUnit();
     $partUnit->setName('pieces');
     $partUnit->setShortName('pcs');
     $partUnit->setDefault(true);
     $this->addReference("partunit.default", $partUnit);
     $part = new Part();
     $part->setName('FOOBAR');
     $part->setPartUnit($partUnit);
     $category = $this->getReference('partcategory.first');
     $storageLocation = $this->getReference('storagelocation.first');
     $part->setCategory($category);
     $part->setStorageLocation($storageLocation);
     $part2 = new Part();
     $part2->setName('FOOBAR2');
     $category = $this->getReference('partcategory.first');
     $storageLocation = $this->getReference('storagelocation.second');
     $part2->setCategory($category);
     $part2->setStorageLocation($storageLocation);
     $part2->setPartUnit($partUnit);
     $manager->persist($partUnit);
     $manager->persist($part);
     $manager->persist($part2);
     $manager->flush();
     $this->addReference('part.1', $part);
     $this->addReference('part.2', $part2);
 }
Example #3
0
 public function testAssociationRemoval()
 {
     $part = new Part();
     $part->setName("TEST");
     $part->setCategory($this->getContainer()->get("partkeepr.part.category_service")->getRootNode());
     $part->setStorageLocation($this->fixtures->getReference("storagelocation.first"));
     $partManufacturer = new PartManufacturer();
     $partManufacturer->setManufacturer($this->fixtures->getReference("manufacturer.first"));
     $part->addManufacturer($partManufacturer);
     $partDistributor = new PartDistributor();
     $partDistributor->setDistributor($this->fixtures->getReference("distributor.first"));
     $part->addDistributor($partDistributor);
     $partAttachment = new PartAttachment();
     $fileService = $this->getContainer()->get("partkeepr_uploadedfile_service");
     $fileService->replaceFromData($partAttachment, "BLA", "test.txt");
     $part->addAttachment($partAttachment);
     $this->getContainer()->get("doctrine.orm.default_entity_manager")->persist($part);
     $this->getContainer()->get("doctrine.orm.default_entity_manager")->flush($part);
     $part->removeDistributor($partDistributor);
     $part->removeManufacturer($partManufacturer);
     $part->removeAttachment($partAttachment);
     $this->getContainer()->get("doctrine.orm.default_entity_manager")->flush($part);
     $storage = $fileService->getStorage($partAttachment);
     $this->assertNull($partDistributor->getId());
     $this->assertNull($partDistributor->getId());
     $this->assertNull($partAttachment->getId());
     $this->assertFalse($storage->has($partAttachment->getFullFilename()));
 }