/** * Dump * * @return string */ public function dump() { $gherkin = $this->feature->getGherkin(); $description = array_pad(preg_split('!\\n!', $gherkin->getDescription(), 4), 4, ''); $result = array('title' => $gherkin->getTitle(), 'notes' => $description[3], 'inorder' => $description[0], 'as' => $description[1], 'should' => $description[2], 'scenarios' => array(), 'background' => array()); // // Scenarios foreach ($gherkin->getScenarios() as $scenario) { array_push($result['scenarios'], $this->_dumpSteppable($scenario)); } // // Background if ($gherkin->getBackground()) { $result['background'] = $this->_dumpSteppable($gherkin->getBackground()); } $jsonEncoder = new JsonEncoder(); return $jsonEncoder->encode($result, 'json'); }
/** * * Write configuration to file in given format * * @param $file */ public function writeToFile($file) { if ($this->getFormat() == 'yaml') { $yaml = new Yaml(); $serialized = $yaml->dump($this->getConfig(), 10); if ($serialized == 'null') { $serialized = '{}'; } } elseif ($this->getFormat() == 'json') { $encoder = new JsonEncoder(); $serialized = $encoder->encode($this->getConfig(), $encoder::FORMAT, ['json_encode_options' => JSON_PRETTY_PRINT]); } else { throw new InputOperationException("Invalid configuration format {$this->format}."); } $fs = new Filesystem(); $fs->dumpFile($file, $serialized); }
/** * @Route("/", name="admin_mainpage") * * @return string */ public function indexAction() { $mainMenuData = [['id' => "1", 'type' => "folder", 'value' => "Benutzer", 'css' => "folder_music"], ['id' => "2", 'type' => "folder", 'value' => "Lizenznehmer", 'css' => "folder_music"], ['id' => "3", 'type' => "folder", 'value' => "Themenfelder", 'css' => "folder_music"], ['id' => "4s", 'type' => "folder", 'value' => "Geschichten", 'css' => "folder_music"]]; $jsonEncoder = new JsonEncoder(); return $this->render('AdminBundle::index.html.twig', array('mainMenuData' => $jsonEncoder->encode($mainMenuData, 'json'))); }