public function send()
 {
     $messages = 1;
     $fi = new \FilesystemIterator('../web/spooldir/default', \FilesystemIterator::SKIP_DOTS);
     $num = iterator_count($fi);
     $i = 0;
     for ($i; $i < $num; $i++) {
         //runcommand to send email from spool
         $kernel = $this->container->get('kernel');
         $application = new Application($kernel);
         $application->setAutoExit(false);
         $input = new ArrayInput(array('command' => 'swiftmailer:spool:send', '--message-limit' => $messages));
         // You can use NullOutput() if you don't need the output
         //$output = new BufferedOutput();
         $output = new NullOutput();
         $application->run($input, $output);
         sleep(5);
     }
 }
Example #2
0
 /**
  * Installs a plugin
  *
  * @param integer $p
  */
 public function installPlugin($pluginId)
 {
     $plugins = $this->entityManager->getRepository($this->modelNamespace)->findById($pluginId);
     if (count($plugins) != 1) {
         throw new PluginNotFoundException("The plugin cannot be found");
     }
     $plugin = $plugins[0];
     if ($plugin->isActive()) {
         throw new PluginStatusException("Plugin is already installed.");
     }
     $pluginInstance = $this->getPlugin($plugin->getName());
     $plugin->setActivated(true);
     $app = new Application($this->framework->getKernel());
     $app->setAutoExit(false);
     $input = new StringInput("doctrine:schema:update --force");
     $fp = fopen('php://temp/maxmemory:' . 1024 * 1024 * 512, 'r+');
     $output = new StreamOutput($fp);
     $error = $app->run($input, $output);
     rewind($fp);
     if ($error != 0) {
         $msg = "Error: {$error}\n" . stream_get_contents($fp);
         throw new PluginStatusException($msg);
     } else {
         $msg = stream_get_contents($fp);
     }
     $this->entityManager->flush();
     $pluginInstance->install();
 }