Jarves\Command\ContentExportCommand::execute PHP Метод

execute() защищенный Метод

protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $domains = DomainQuery::create()->find();
        $exportPointer = new ExportPointer();
        //        $basePath = 'jarves-export/' . date('Ymd-His'). '/';
        $basePath = 'app/jarves/';
        $fs = new Filesystem();
        $fs->remove($basePath);
        foreach ($domains as $domain) {
            $domainData = $domain->toArray(TableMap::TYPE_CAMELNAME);
            $exportPointer->pushPath('website/' . $domainData['domain']);
            $nodes = NodeQuery::create()->filterByDomain($domain)->orderByLft()->filterByLft(1, Criteria::GREATER_THAN)->filterByLvl(1)->find();
            foreach ($nodes as $idx => $node) {
                $this->exportNode($idx, $domain, $node, $exportPointer);
            }
            $domainData = $this->clearData($domainData, ['id', 'startnodeId']);
            if ($domain->hasVirtualColumn('startnodePath')) {
                $domainData['startnode'] = $domain->getVirtualColumn('startnodePath');
            } else {
                $output->writeln(sprintf('<error>Domain %s has no start node defined</error>', $domain->getDomain()));
            }
            $exportPointer->addData($domainData, '.yml');
            $exportPointer->popPath();
        }
        $files = FileQuery::create()->find();
        $fileReferences = [];
        foreach ($files as $file) {
            $fileReferences[$file->getId()] = $file->getPath();
        }
        $exportPointer->addData($fileReferences, 'file_references.yml');
        foreach ($exportPointer->data as $path => $data) {
            $path = $basePath . $path;
            if (!is_dir(dirname($path))) {
                mkdir(dirname($path), 0770, true);
            }
            $yml = $this->dumpYaml($data);
            $output->writeln(sprintf('write %s', $path));
            file_put_contents($path, $yml);
        }
        $output->writeln(sprintf('Done.'));
    }