setName() публичный Метод

Sets the name for this unit.
public setName ( string $name )
$name string The name for this unit
Пример #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);
 }
Пример #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);
 }
Пример #3
0
 /**
  * Sets up the default part unit (pieces) if it doesn't exist.
  *
  * @return bool True if a default unit was created, false if it already exists
  */
 public function setupDefaultPartUnit()
 {
     $dql = "SELECT COUNT(p) FROM PartKeepr\\PartBundle\\Entity\\PartMeasurementUnit p WHERE p.default = :default";
     $query = $this->entityManager->createQuery($dql);
     $query->setParameter('default', true);
     if ($query->getSingleScalarResult() == 0) {
         $partUnit = new PartMeasurementUnit();
         $partUnit->setName('Pieces');
         $partUnit->setShortName('pcs');
         $partUnit->setDefault(true);
         $this->entityManager->persist($partUnit);
         $this->entityManager->flush();
         return true;
     } else {
         return false;
     }
 }
 /**
  * @Route("/setup/_int_create_part_units")
  */
 public function intCreatePartUnitsAction()
 {
     $response = array("success" => true, "errors" => [], "message" => "Default part unit successfully created");
     try {
         $entityManager = $this->get("doctrine.orm.default_entity_manager");
         $dql = "SELECT COUNT(p) FROM PartKeepr\\PartBundle\\Entity\\PartMeasurementUnit p WHERE p.default = :default";
         $query = $entityManager->createQuery($dql);
         $query->setParameter("default", true);
         if ($query->getSingleScalarResult() == 0) {
             $partUnit = new PartMeasurementUnit();
             $partUnit->setName("Pieces");
             $partUnit->setShortName("pcs");
             $partUnit->setDefault(true);
             $entityManager->persist($partUnit);
             $entityManager->flush();
         }
     } catch (\Exception $e) {
         $response["success"] = false;
         $response["message"] = "Part unit setup error";
         $response["errors"] = [$e->getMessage()];
     }
     return new JsonResponse($response);
 }