public function writeIntoFile()
    {
        $this->countries = [['alaska'], ['alabama'], ['new york'], ['texas']];
        $j = 1;
        for ($i = 0; $i < count($this->countries); ++$i) {
            $name = implode("|", $this->countries[$i]);
            $this->output[] = '<tr><td>' . $j . '</td><td>' . $name . '</td><td>Response 200 ok</td></tr>';
            $j++;
        }
        $this->output[] = <<<HTML
                    </table>
                </body>
                            </html>
                
HTML;
        $fs = new \Symfony\Component\Filesystem\Filesystem();
        $fs->dumpFile('C:\\xampp\\htdocs\\raport\\src\\RaportBundle\\Resources\\views\\Default\\result.html', $this->output);
    }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getContainer()->get('doctrine')->getManager();
     $tokens = $em->createQuery("SELECT t.id, c.id as catalogue_id, s.id as site_id, t.token FROM SymbioOrangeGateTranslationBundle:LanguageToken t JOIN t.catalogue c LEFT JOIN t.site s")->execute();
     $cIds = [];
     foreach ($tokens as $token) {
         $cIds[$token['catalogue_id']] = $token['catalogue_id'];
         $tIds[$token['id']] = $token['id'];
     }
     $catalogues = $em->createQuery("SELECT c.id, c.name FROM SymbioOrangeGateTranslationBundle:LanguageCatalogue c WHERE c.id IN(:ids)")->setParameter('ids', $cIds)->execute();
     $translations = $em->createQuery("SELECT t.id, t.translation, t.language, lt.id as languageToken_id FROM SymbioOrangeGateTranslationBundle:LanguageTranslation t JOIN t.languageToken as lt WHERE lt.id IN(:ids)")->setParameter('ids', $tIds)->execute();
     $dump = [$catalogues, $tokens, $translations];
     $fs = new \Symfony\Component\Filesystem\Filesystem();
     try {
         $fs->dumpFile(__DIR__ . "/../Resources/dumps/translation_dump.json", json_encode($dump));
     } catch (IOException $e) {
         throw new \Exception("An error was occured in updateing \"translation_dump.json\" file");
     }
     $output->writeln("Operation complete!");
 }
 public function ffgAction()
 {
     // http://www.fantasyflightgames.com/ffg_content/organized-play/2013/private-security-force.png
     $em = $this->get('doctrine')->getManager();
     $fs = new \Symfony\Component\Filesystem\Filesystem();
     $old = array();
     $new = array();
     $fails = array();
     $base = 'http://www.fantasyflightgames.com/ffg_content/android-netrunner';
     $root = $this->get('kernel')->getRootDir() . "/../web/ffg_images";
     $segments = array('core' => 'core-set-cards', 'genesis' => 'genesis-cycle/cards', 'creation-and-control' => 'deluxe-expansions/creation-and-control', 'spin' => 'spin-cycle/cards', 'honor-and-profit' => 'deluxe-expansions/honor-and-profit/cards', 'lunar' => 'lunar-cycle/cards');
     $corrections = array('astroscript-pilot-program' => 'autoscript-pilot-program', 'melange-mining-corp-' => 'melange-mining-corp', 'haas-bioroid-stronger-together' => 'haas-bioroid-adn02', 'ash-2x3zb9cy' => 'ash', 'dj-vu' => 'deja-vu', 'drac' => 'draco', 'joshua-b-' => 'joshua-b', 'doppelgnger' => 'doppelganger', 'weyland-consortium-because-we-built-it' => 'weyland-consortium', 'mr--li' => 'mr-li');
     $cycles = $em->getRepository('NetrunnerdbCardsBundle:Cycle')->findBy(array(), array('number' => 'asc'));
     /* @var $cycle Cycle */
     foreach ($cycles as $cycle) {
         if (!isset($segments[$cycle->getCode()])) {
             continue;
         }
         $segment = $segments[$cycle->getCode()];
         $packs = $cycle->getPacks();
         /* @var $pack Pack */
         foreach ($packs as $pack) {
             $cards = $pack->getCards();
             /* @var $card Card */
             foreach ($cards as $card) {
                 $filepath = $root . "/" . $card->getCode() . ".png";
                 $imgpath = "/web/ffg_images/" . $card->getCode() . ".png";
                 if (file_exists($filepath)) {
                     $old[] = $imgpath;
                     continue;
                 }
                 $ffg = $title = $card->getTitle();
                 $ffg = str_replace(' ', '-', $ffg);
                 $ffg = str_replace('.', '-', $ffg);
                 $ffg = str_replace('&', '-', $ffg);
                 $ffg = str_replace('\'', '', $ffg);
                 if ($cycle->getCode() === 'core' || $card->getSide()->getName() === 'Runner' || $card->getKeywords() === 'Division' || $card->getKeywords() === 'Corp') {
                     $ffg = preg_replace('/:.*/', '', $ffg);
                 } else {
                     $ffg = str_replace(':', '', $ffg);
                 }
                 $ffg = strtolower($ffg);
                 $ffg = iconv('UTF-8', 'ASCII//TRANSLIT', $ffg);
                 $ffg = preg_replace('/[^a-z0-9\\-]/', '', $ffg);
                 if (isset($corrections[$ffg])) {
                     $ffg = $corrections[$ffg];
                 }
                 $url = "{$base}/{$segment}/{$ffg}.png";
                 $ch = curl_init($url);
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                 if ($response = curl_exec($ch)) {
                     $content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
                     if ($content_type === "image/png") {
                         $fs->dumpFile($filepath, $response);
                         $new[] = $imgpath;
                         continue;
                     }
                 }
                 $fails[] = $url;
             }
         }
     }
     print "<h2>Fails</h2>";
     foreach ($fails as $fail) {
         print "<p>{$fail}</p>";
     }
     print "<h2>New</h2>";
     foreach ($new as $img) {
         print "<p><img src='{$img}'></p>";
     }
     print "<h2>Old</h2>";
     foreach ($old as $img) {
         print "<p><img src='{$img}'></p>";
     }
     return new Response('');
 }
 protected function dump($content, $destination = '/var/www/test.html')
 {
     $filesystem = new \Symfony\Component\Filesystem\Filesystem();
     $filesystem->dumpFile($destination, $content);
 }
 private function _generateSchemas($table, $class)
 {
     $dir = $this->getDestinationDir();
     $file = $dir . $class . '.yml';
     Folder::create($dir);
     $structArray = array(array('comment' => $this->_writeComment($class)), array('colums' => $this->_getListTableColumn($table)), array('infos' => $this->_generaInfo($table)));
     $yaml = $this->dumpYaml($structArray);
     $fileSystem = new Symfony\Component\Filesystem\Filesystem();
     $fileSystem->dumpFile($file, $yaml);
     return $class . ".yml";
 }
Example #6
0
function createYaml($config, $path)
{
    $content = \Symfony\Component\Yaml\Yaml::dump($config);
    $fs = new \Symfony\Component\Filesystem\Filesystem();
    $fs->dumpFile($path, $content);
}
 /**
  * Take a screenshot when a step fails
  *
  * @param StepEvent $event
  *
  * @AfterStep
  */
 public function takeScreenshotAfterFailedStep(StepEvent $event)
 {
     if ($event->getResult() === StepEvent::FAILED) {
         $driver = $this->getSession()->getDriver();
         if ($driver instanceof Selenium2Driver) {
             $dir = getenv('WORKSPACE');
             $buildUrl = getenv('BUILD_URL');
             if (false !== $dir) {
                 $dir = sprintf('%s/app/build/screenshots', $dir);
             } else {
                 $dir = '/tmp/behat/screenshots';
             }
             $lineNum = $event->getStep()->getLine();
             $filename = strstr($event->getLogicalParent()->getFile(), 'features/');
             $filename = sprintf('%s.%d.png', str_replace('/', '__', $filename), $lineNum);
             $path = sprintf('%s/%s', $dir, $filename);
             $fs = new \Symfony\Component\Filesystem\Filesystem();
             $fs->dumpFile($path, $driver->getScreenshot());
             if (false !== $dir) {
                 $path = sprintf('%s/artifact/app/build/screenshots/%s', $buildUrl, $filename);
             }
             $this->addErrorMessage("Step {$lineNum} failed, screenshot available at {$path}");
         }
     }
 }
 /**
  * Take a screenshot when a step fails
  *
  * @param StepEvent $event
  *
  * @AfterStep
  */
 public function takeScreenshotAfterFailedStep(StepEvent $event)
 {
     if ($event->getResult() === StepEvent::FAILED) {
         $driver = $this->getSession()->getDriver();
         $rootDir = dirname($this->getContainer()->getParameter('kernel.root_dir'));
         $filePath = $event->getLogicalParent()->getFile();
         $stepStats = ['scenario_file' => substr($filePath, strlen($rootDir) + 1), 'scenario_line' => $event->getLogicalParent()->getLine(), 'scenario_label' => $event->getLogicalParent()->getTitle(), 'exception' => $event->getException()->getMessage(), 'step_line' => $event->getStep()->getLine(), 'step_label' => $event->getStep()->getText(), 'status' => 'failed'];
         if ($driver instanceof Selenium2Driver) {
             $dir = getenv('WORKSPACE');
             $buildUrl = getenv('BUILD_URL');
             if (false !== $dir) {
                 $dir = sprintf('%s/app/build/screenshots', $dir);
             } else {
                 $dir = '/tmp/behat/screenshots';
             }
             $lineNum = $event->getStep()->getLine();
             $filename = strstr($event->getLogicalParent()->getFile(), 'features/');
             $filename = sprintf('%s.%d.png', str_replace('/', '__', $filename), $lineNum);
             $path = sprintf('%s/%s', $dir, $filename);
             $fs = new \Symfony\Component\Filesystem\Filesystem();
             $fs->dumpFile($path, $driver->getScreenshot());
             if (false !== $dir) {
                 $path = sprintf('%s/artifact/app/build/screenshots/%s', $buildUrl, $filename);
             }
             $stepStats['screenshot'] = $path;
             $this->addErrorMessage("Step {$lineNum} failed, screenshot available at {$path}");
         }
         if ('JENKINS' === getenv('BEHAT_CONTEXT')) {
             echo sprintf("##glados_step##%s##glados_step##\n", json_encode($stepStats));
         }
     }
 }