/** * Executes the specified seeder on this environment. * * @param SeedInterface $seed * @return void */ public function executeSeed(SeedInterface $seed) { $seed->setAdapter($this->getAdapter()); // begin the transaction if the adapter supports it if ($this->getAdapter()->hasTransactions()) { $this->getAdapter()->beginTransaction(); } // Run the seeder if (method_exists($seed, SeedInterface::RUN)) { $seed->run(); } // commit the transaction if the adapter supports it if ($this->getAdapter()->hasTransactions()) { $this->getAdapter()->commitTransaction(); } }
/** * Execute a seeder against the specified environment. * * @param string $name Environment Name * @param SeedInterface $seed Seed * @return void */ public function executeSeed($name, SeedInterface $seed) { $this->getOutput()->writeln(''); $this->getOutput()->writeln(' ==' . ' <info>' . $seed->getName() . ':</info>' . ' <comment>seeding</comment>'); // Execute the seeder and log the time elapsed. $start = microtime(true); $this->getEnvironment($name)->executeSeed($seed); $end = microtime(true); $this->getOutput()->writeln(' ==' . ' <info>' . $seed->getName() . ':</info>' . ' <comment>seeded' . ' ' . sprintf('%.4fs', $end - $start) . '</comment>'); }