protected function execute(InputInterface $input, OutputInterface $output) { $listfilename = $input->getArgument('listfile'); $racklist = array(); if ($listfilename) { $listfile = fopen($listfilename, 'r'); if ($listfile) { while ($data = fgetcsv($listfile, 0, "\t")) { $racklist[] = array('name' => $data[0], 'contents' => $data[1]); } } } $dialog = $this->getHelperSet()->get('dialog'); $this->container = $this->getApplication()->getKernel()->getContainer(); $user = $this->container->get('user_provider')->loadUserByUsername($input->getArgument('owner')); $om = $this->container->get('vib.doctrine.registry')->getManagerForClass('VIB\\CoreBundle\\Entity\\Entity'); $om->disableAutoAcl(); $om->getConnection()->beginTransaction(); $racks = new ArrayCollection(); foreach ($racklist as $rackitem) { echo $rackitem['name'] . "\t" . $rackitem['contents'] . "\n"; $rack = new Rack(10, 10); $rack->setDescription($rackitem['name'] . "\n" . $rackitem['contents']); $racks[] = $rack; $om->persist($rack); } $output->writeln("Objects imported. Flushing DB buffer."); $om->flush(); $output->writeln("Creating ACLs."); $om->createACL($racks, $user); $message = 'Everything seems to be OK. Commit?'; if ($dialog->askConfirmation($output, '<question>' . $message . '</question>', true)) { $em->getConnection()->commit(); if ($input->getOption('print')) { echo "Will print labels now.\n"; $pdf = $this->container->get('vibfolks.pdflabel'); foreach ($racks as $rack) { $pdf->addLabel($rack); } $jobStatus = $pdf->printPDF(); echo $jobStatus . "\n"; } } else { $om->getConnection()->rollback(); $om->close(); } $om->enableAutoAcl(); }
public function positionProvider() { $rack = new Rack(3, 3); return array(array($rack->getPosition(1, 2))); }
public function __construct($rows = null, $columns = null) { parent::__construct($rows, $columns); $this->id = 1; $this->name = 'test'; }
/** * Incubate rack * * @param \VIB\FliesBundle\Entity\Rack $rack * @param \VIB\FliesBundle\Entity\Incubator $incubator */ public function incubateRack(Rack $rack, Incubator $incubator) { $om = $this->getObjectManager(); $rack->setStorageUnit($incubator); $om->persist($rack); $om->flush(); $this->addSessionFlash('success', 'Rack ' . $rack . ' was put in ' . $incubator . '.'); }
protected function getPosition() { $incubator = new Incubator(); $incubator->setName('Test'); $incubator->setTemperature(28); $rack = new Rack(1, 1); $rack->setStorageUnit($incubator); return new RackPosition($rack, 1, 1); }