Esempio n. 1
0
 public function registerBundles()
 {
     $bundles = array(new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(), new Symfony\Bundle\MonologBundle\MonologBundle(), new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), new Symfony\Bundle\AsseticBundle\AsseticBundle(), new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(), new FOS\RestBundle\FOSRestBundle(), new JMS\SerializerBundle\JMSSerializerBundle($this), new Nelmio\ApiDocBundle\NelmioApiDocBundle(), new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(), new Oneup\UploaderBundle\OneupUploaderBundle(), new Liip\ImagineBundle\LiipImagineBundle(), new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(), new FOS\ElasticaBundle\FOSElasticaBundle(), new Braincrafted\Bundle\BootstrapBundle\BraincraftedBootstrapBundle(), new Problematic\AclManagerBundle\ProblematicAclManagerBundle(), new JMS\DiExtraBundle\JMSDiExtraBundle($this), new JMS\AopBundle\JMSAopBundle(), new APY\DataGridBundle\APYDataGridBundle(), new PUGX\AutocompleterBundle\PUGXAutocompleterBundle(), new SC\DatetimepickerBundle\SCDatetimepickerBundle(), new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(), new A2lix\TranslationFormBundle\A2lixTranslationFormBundle(), new Prezent\Doctrine\TranslatableBundle\PrezentDoctrineTranslatableBundle(), new FOS\JsRoutingBundle\FOSJsRoutingBundle(), new Norzechowicz\AceEditorBundle\NorzechowiczAceEditorBundle(), new Knp\Bundle\GaufretteBundle\KnpGaufretteBundle(), new Jb\Bundle\FileUploaderBundle\JbFileUploaderBundle(), new Okulbilisim\OjsToolsBundle\OkulbilisimOjsToolsBundle(), new Okulbilisim\FeedbackBundle\OkulbilisimFeedbackBundle(), new Ojs\CoreBundle\OjsCoreBundle(), new Ojs\SiteBundle\OjsSiteBundle(), new Ojs\AdminBundle\OjsAdminBundle(), new Ojs\SearchBundle\OjsSearchBundle(), new Ojs\ApiBundle\OjsApiBundle(), new Ojs\CliBundle\OjsCliBundle(), new Ojs\JournalBundle\OjsJournalBundle(), new Ojs\UserBundle\OjsUserBundle(), new Ojs\OAIBundle\OjsOAIBundle(), new Ojs\LocationBundle\OjsLocationBundle(), new Ojs\InstallerBundle\OjsInstallerBundle(), new Ojs\CmsBundle\OjsCmsBundle(), new FOS\UserBundle\FOSUserBundle(), new Ojs\AnalyticsBundle\OjsAnalyticsBundle(), new Knp\Bundle\MenuBundle\KnpMenuBundle(), new JMS\TranslationBundle\JMSTranslationBundle());
     if (in_array($this->getEnvironment(), array('dev', 'test'))) {
         $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
         $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
         $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
         $bundles[] = new h4cc\AliceFixturesBundle\h4ccAliceFixturesBundle();
     }
     $thirdPartyDir = __DIR__ . '/../thirdparty';
     $fs = new \Symfony\Component\Filesystem\Filesystem();
     if ($fs->exists($thirdPartyDir)) {
         $finder = new \Symfony\Component\Finder\Finder();
         $finder->files()->in($thirdPartyDir);
         foreach ($finder as $file) {
             /** @var \Symfony\Component\Finder\SplFileInfo $file */
             $bundleConfig = json_decode(file_get_contents($file->getRealpath()), true);
             if ($bundleConfig) {
                 if (isset($bundleConfig['extra']) && isset($bundleConfig['extra']['bundle-class'])) {
                     if (class_exists($bundleConfig['extra']['bundle-class'])) {
                         $bundles[] = new $bundleConfig['extra']['bundle-class']();
                     }
                 }
             }
         }
     }
     return $bundles;
 }
Esempio n. 2
0
 /**
  * Creates release zip
  *
  * @param string $version
  */
 public function makeRelease($version = '')
 {
     if (empty($version)) {
         $version = $this->versionGet();
     }
     $name = basename(__DIR__);
     $this->taskFileSystemStack()->mkdir('release')->run();
     $this->taskCleanDir('release')->run();
     $this->taskExec('composer')->dir(__DIR__ . '/release')->arg("create-project rarst/{$name} {$name} " . $version)->arg('--prefer-dist --no-dev')->run();
     $this->taskExec('composer')->dir(__DIR__ . "/release/{$name}")->arg('dump-autoload --optimize')->run();
     $zipFile = "release/{$name}-{$version}.zip";
     $zipArchive = new ZipArchive();
     if (!$zipArchive->open($zipFile, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)) {
         die("Failed to create archive\n");
     }
     $finder = new Symfony\Component\Finder\Finder();
     $finder->files()->in("release/{$name}")->ignoreDotFiles(false);
     /** @var \Symfony\Component\Finder\SplFileInfo $file */
     foreach ($finder as $file) {
         $zipArchive->addFile($file->getRealPath(), "{$name}/" . $file->getRelativePathname());
     }
     if (!$zipArchive->status === ZIPARCHIVE::ER_OK) {
         echo "Failed to write files to zip\n";
     }
     $zipArchive->close();
     $this->taskDeleteDir("release/{$name}")->run();
 }
 /**
  * @see Command
  * @codeCoverageIgnore
  *
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $themeName = $input->getArgument('theme');
     $kernel = $this->getContainer()->get('kernel');
     $themePath = $kernel->locateResource('@' . $themeName);
     $slots = array();
     $finder = new \Symfony\Component\Finder\Finder();
     $templateFiles = $finder->files('*.twig')->in($themePath . '/Resources/views/Theme');
     foreach ($templateFiles as $template) {
         $template = (string) $template;
         $templateContents = file_get_contents($template);
         $currentTemplateContents = $templateContents;
         preg_match_all('/([^%]+)[^\\w]+BEGIN-SLOT.*?\\{% endblock[^%\\}]+%\\}/si', $templateContents, $matches, PREG_SET_ORDER);
         foreach ($matches as $match) {
             $block = '{%' . $match[0];
             $blockName = trim(str_replace('block ', '', $match[1]));
             $currentTemplateContents = str_replace($block, "{{ block('{$blockName}') }}", $currentTemplateContents);
             preg_match('/([\\r\\n][\\s]+)\\{# BEGIN-SLOT/', $block, $spacesMatch);
             if (array_key_exists(1, $spacesMatch)) {
                 $block = str_replace($spacesMatch[1], "\n    ", $block);
                 $block = preg_replace('/([\\r\\n][\\s]+)\\{% endblock/', "\n{% endblock", $block);
             }
             $slots[] = $block;
         }
         $useStatement = "{% use '{$themeName}:Slots:slots.html.twig' %}\n";
         preg_match('/\\{% extend[^\\}]+\\}/', $currentTemplateContents, $m);
         $currentTemplateContents = array_key_exists(0, $m) ? str_replace($m[0], $m[0] . "\n\n" . $useStatement, $currentTemplateContents) : ($currentTemplateContents = $useStatement . $currentTemplateContents);
         file_put_contents($template, $currentTemplateContents);
     }
     $slotsDir = $themePath . '/Resources/views/Slots';
     @mkdir($slotsDir);
     file_put_contents($slotsDir . '/slots.html.twig', implode("\n\n", $slots));
     $message = sprintf('The theme <info>%s</info> has been migrated', $themeName);
     $output->writeln($message);
 }
Esempio n. 4
0
 public static function getRoutes($path)
 {
     $routes = new \Symfony\Component\Routing\RouteCollection();
     $finder = new \Symfony\Component\Finder\Finder();
     $finder->name('*.php');
     $finder->files()->in($path);
     if (!$finder->count()) {
         throw new Exception('No routes found in ' . $path);
     }
     foreach ($finder as $entry) {
         $route_path = $entry->getRelativePath();
         $basename = $entry->getBasename('.php');
         $cleaned = str_replace('/', '_', str_replace('-', '_', $route_path . $basename));
         $route = $route_path . ($basename === 'index' ? '' : '/' . $basename);
         /*
                    if (strrchr($route, '-')) {
                        $sluglen = strlen(strrchr($route, '-'));
                        $route2 = substr($route, 0, strlen($route) - $sluglen + 1) . '{slug}';
                        $basename2 = substr($basename, 0, $basename - $sluglen + 1);
                    } else {
                        $route2 = $route;
                        $basename2 = $basename;
                    }
         */
         $routes->add($cleaned, new \Symfony\Component\Routing\Route($route, ['_controller' => 'build', 'php_file' => $entry->getRealPath(), 'file_root' => $route_path . '/' . $basename, 'name' => '.+']));
         $routes->add('slash' . $cleaned, new \Symfony\Component\Routing\Route($route . '/', ['_controller' => 'build', 'php_file' => $entry->getRealPath(), 'file_root' => $route_path . '/' . $basename, 'name' => '.+']));
     }
     return $routes;
 }
Esempio n. 5
0
 public function testCreateMapFinderSupport()
 {
     if (!class_exists('Symfony\\Component\\Finder\\Finder')) {
         $this->markTestSkipped('Finder component is not available');
     }
     $finder = new \Symfony\Component\Finder\Finder();
     $finder->files()->in(__DIR__ . '/Fixtures/beta/NamespaceCollision');
     $this->assertEqualsNormalized(array('NamespaceCollision\\A\\B\\Bar' => realpath(__DIR__) . '/Fixtures/beta/NamespaceCollision/A/B/Bar.php', 'NamespaceCollision\\A\\B\\Foo' => realpath(__DIR__) . '/Fixtures/beta/NamespaceCollision/A/B/Foo.php'), ClassMapGenerator::createMap($finder));
 }
Esempio n. 6
0
 protected function loadConfigurationsFolder($folder)
 {
     $confs = array();
     $finder = new \Symfony\Component\Finder\Finder();
     foreach ($finder->in($folder) as $configuration) {
         $confs[] = array(file_get_contents($configuration->getPathname()));
     }
     return $confs;
 }
Esempio n. 7
0
 /**
  * @return array
  */
 public function dataProvider()
 {
     $data = [];
     $finder = new \Symfony\Component\Finder\Finder();
     $finder->files()->name('*.md')->in(__DIR__ . self::DIRECTORY);
     foreach ($finder as $file) {
         $data[] = [$file->getFilename(), str_replace('.md', '.html', $file->getFilename())];
     }
     return $data;
 }
 /**
  * {@inheritdoc}
  */
 public function find($directories)
 {
     $finder = new \Symfony\Component\Finder\Finder();
     $finder->files()->in($directories);
     $return = [];
     foreach ($finder as $file) {
         $return[] = $file;
     }
     return $return;
 }
Esempio n. 9
0
 function getFilesFromPathByEnv(\LaravelSeed\Contracts\ProviderInterface $provider)
 {
     $finder = new Symfony\Component\Finder\Finder();
     $files = [];
     $finder->name("/\\_" . $provider->getEnv() . "\\.(\\w{1,4})\$/i");
     foreach ($finder->in($provider->getConfig('path')) as $file) {
         $files[] = $file->getPath() . '/' . $file->getFilename();
     }
     return $files;
 }
 public function registerContainerConfiguration(LoaderInterface $loader)
 {
     $configFolder = __DIR__ . '/config/bundles/config/' . $this->getEnvironment();
     $finder = new \Symfony\Component\Finder\Finder();
     $configFiles = $finder->depth(0)->name('*.yml')->in($configFolder);
     foreach ($configFiles as $config) {
         $loader->load((string) $config);
     }
     $loader->load(__DIR__ . '/config/config_' . $this->getEnvironment() . '.yml');
 }
Esempio n. 11
0
 public function prepare(\Silex\Application $app, $locale)
 {
     $templatesPath = APP_DIR . '/templates';
     $untranslatedMessagesFile = APP_DIR . '/locales/' . $locale . '_untranslated.yml';
     $extractor = new \Symfony\Bridge\Twig\Translation\TwigExtractor($app['twig']);
     /***** All translations *****/
     $catalogueAll = new \Symfony\Component\Translation\MessageCatalogue($locale);
     $extractor->extract($templatesPath, $catalogueAll);
     $allMessages = $catalogueAll->all('messages');
     // String from controller, controller provider, etc.
     $finder = new \Symfony\Component\Finder\Finder();
     $finder->files()->in(ROOT_DIR . '/src');
     foreach ($finder as $file) {
         $fileMessageStrings = array();
         $filePath = $file->getRealpath();
         $fileContent = file_get_contents($filePath);
         $pregMatch = "#->trans.*\\(\\s*'(.+?)(?=')#m";
         preg_match_all($pregMatch, $fileContent, $matches);
         $matches = $matches[1];
         if ($matches) {
             foreach ($matches as $match) {
                 $fileMessageStrings[] = $match;
             }
         }
         if ($fileMessageStrings) {
             foreach ($fileMessageStrings as $fileMessageString) {
                 if (!isset($allMessages[$fileMessageString])) {
                     $allMessages[$fileMessageString] = $fileMessageString;
                 }
             }
         }
     }
     /***** Already translated *****/
     $app['application.translator']->setLocale($locale, $ignoreUntranslated = true);
     $translatedMessages = $app['translator']->getMessages($locale);
     $translatedMessages = $translatedMessages['messages'];
     /***** Untranslated *****/
     $untranslatedMessages = array();
     if ($allMessages) {
         foreach ($allMessages as $singleMessageKey => $singleMessage) {
             if (!isset($translatedMessages[$singleMessageKey])) {
                 $untranslatedMessages[$singleMessageKey] = $singleMessage;
             }
         }
     }
     if (!empty($untranslatedMessages)) {
         $dumper = new \Symfony\Component\Yaml\Dumper();
         $yaml = $dumper->dump($untranslatedMessages, 1);
         if (file_exists($untranslatedMessagesFile)) {
             unlink($untranslatedMessagesFile);
         }
         file_put_contents($untranslatedMessagesFile, $yaml);
     }
     return array('allMessages' => $allMessages, 'translatedMessages' => $translatedMessages, 'untranslatedMessages' => $untranslatedMessages);
 }
Esempio n. 12
0
 /**
  * @return array
  */
 public function provideResources()
 {
     $finder = new \Symfony\Component\Finder\Finder();
     $finder->in(__DIR__ . '/../Resources/Text')->files()->name('*.out');
     $files = array();
     /* @var \Symfony\Component\Finder\SplFileInfo $file */
     foreach ($finder as $file) {
         $files[] = array(str_replace('.out', '.twig', $file->getFilename()), $file->getContents());
     }
     return $files;
 }
Esempio n. 13
0
 /**
  * @return $this
  */
 public function clearTheReportsDir()
 {
     $reportsDir = codecept_data_dir('actual');
     if (is_dir($reportsDir)) {
         $finder = new \Symfony\Component\Finder\Finder();
         $finder->in($reportsDir);
         foreach ($finder->files() as $file) {
             unlink($file->getPathname());
         }
     }
     return $this;
 }
Esempio n. 14
0
 /**
  * @\Nucleus\IService\EventDispatcher\Listen("ServiceContainer.warmUp")
  */
 public function warmUp()
 {
     $finder = new \Symfony\Component\Finder\Finder();
     $finder->files()->name('*.twig')->in($this->fileSystemLoader->getPaths());
     foreach ($finder as $file) {
         $fileName = $file->getRelativePathname();
         $this->generateCacheFile($fileName);
         if (strpos($fileName, DIRECTORY_SEPARATOR) !== 0) {
             $this->generateCacheFile(DIRECTORY_SEPARATOR . $fileName);
         }
     }
 }
 public function clearCache()
 {
     $container = $this->getConfigurationPool()->getContainer();
     $cacheDir = $container->get('kernel')->getCacheDir();
     $finder = new \Symfony\Component\Finder\Finder();
     $finder->in(array($cacheDir . "/../*/translations"))->files();
     foreach ($finder as $file) {
         unlink($file->getRealpath());
     }
     if (is_dir($cacheDir . '/translations')) {
         rmdir($cacheDir . '/translations');
     }
 }
Esempio n. 16
0
 /**
  * Tests that the solver doesn't come to false conclusions
  *
  * Verifies only that all cells marked by the solver correspond to the actual solution
  * Does *not* check that the solver solved all cells (unknown cells are skipped)
  * @test
  */
 public function testSolverAllDataProvider()
 {
     $rootDir = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..') . DIRECTORY_SEPARATOR;
     $filePathFull = $rootDir . 'data' . DIRECTORY_SEPARATOR . 'Levels' . DIRECTORY_SEPARATOR;
     $finder = new \Symfony\Component\Finder\Finder();
     $finder->files()->in($filePathFull)->name('*.dat')->notName('sunflower_25x25.dat');
     $levelList = array();
     foreach ($finder as $file) {
         $levelFullPath = $file->getRealpath();
         $levelList[] = array(substr_replace($levelFullPath, '', strrpos($levelFullPath, '.')));
     }
     return $levelList;
 }
Esempio n. 17
0
 private function clearCache()
 {
     try {
         $sf2Refresh = new \PrestaShopBundle\Service\Cache\Refresh();
         $sf2Refresh->addCacheClear();
         $sf2Refresh->execute();
     } catch (\Exception $exception) {
         $finder = new \Symfony\Component\Finder\Finder();
         $fs = new \Symfony\Component\Filesystem\Filesystem();
         foreach ($finder->in(_PS_ROOT_DIR_ . '/app/cache') as $file) {
             $fs->remove($file->getFilename());
         }
     }
 }
 protected function _compareTemplateFiles()
 {
     $themeTemplateDirectory = $this->_magentoInstanceRootDirectory . '/app/design/frontend/' . $this->_currentTheme . '/template';
     $finder = new \Symfony\Component\Finder\Finder();
     $iterator = $finder->files()->name('*.phtml')->in($themeTemplateDirectory);
     foreach ($iterator as $file) {
         $comparisonItem = new \KJ\Magento\Util\ThemeComparison\TemplateItem($file);
         $comparisonItem->setComparison($this);
         if ($comparisonItem->fileToCompareAgainstExists()) {
             $this->_changedTemplateFiles[] = $comparisonItem;
         }
     }
     return $this;
 }
Esempio n. 19
0
 private static function _buildTubePress()
 {
     $finder = new \Symfony\Component\Finder\Finder();
     $distDir = sprintf('%s/build/dist', self::_getProjectRoot());
     $matches = iterator_to_array($finder->in($distDir)->files()->name('*.zip')->getIterator());
     if (count($matches) !== 1) {
         self::_runProcess('php build/php/scripts/build.php package', false, self::_getProjectRoot());
         $finder = new \Symfony\Component\Finder\Finder();
         $matches = iterator_to_array($finder->in($distDir)->files()->name('*.zip')->getIterator());
         if (count($matches) !== 1) {
             throw new RuntimeException('Failed to build TubePress');
         }
     }
 }
 /**
  * Test Register Finder
  *
  * @param integer $n Umpteenth Number
  *
  * @return void
  *
  * @dataProvider providerTestUmpteenth
  */
 public function testIntegratorSuccess($n)
 {
     $path = realpath(__DIR__ . "/../resources/") . "/";
     $oldFinder = new Symfony\Component\Finder\Finder();
     $app = new Silex\Application();
     $app->register(new \NachoNerd\Silex\Finder\Provider());
     $app->boot();
     $app['nn.finder']->sortByModifiedTimeDesc()->in($path);
     $newFinder = $app['nn.finder']->getNFirst($n);
     $filesNewWay = array();
     foreach ($newFinder as $files) {
         $filesNewWay[] = $files;
     }
     $oldFinder->sort(function ($a, $b) {
         return $b->getMTime() - $a->getMTime();
     })->in($path);
     $filesOldWay = array();
     $j = 0;
     foreach ($oldFinder as $files) {
         if ($j == $n) {
             break;
         }
         $j++;
         $filesOldWay[] = $files;
     }
     $this->assertEquals($filesOldWay, $filesNewWay);
 }
Esempio n. 21
0
 /**
  * Parse and compile all custom elements in elements folder.
  * 
  * @return Response
  */
 public function customElements()
 {
     $elements = array();
     $files = $this->finder->in($this->app['base_dir'] . '/elements')->files();
     foreach ($files as $file) {
         $contents = $file->getContents();
         preg_match('/<script>(.+?)<\\/script>/s', $contents, $config);
         preg_match('/<style.*?>(.+?)<\\/style>/s', $contents, $css);
         preg_match('/<\\/style.*?>(.+?)<script>/s', $contents, $html);
         if (!isset($config[1]) || !isset($html[1])) {
             continue;
         }
         $elements[] = array('css' => isset($css[1]) ? trim($css[1]) : '', 'html' => trim($html[1]), 'config' => trim($config[1]));
     }
     return new Response(json_encode($elements));
 }
Esempio n. 22
0
 function convert($dir_path)
 {
     $html_dir_path = $dir_path . "/html";
     if (!is_dir()) {
         system("mkdir -p {$html_dir_path}");
     } else {
         system("rm -R {$html_dir_path}/*");
     }
     $finder = new \Symfony\Component\Finder\Finder();
     $finder->in($dir_path)->files()->name("SRMN*.docx");
     print "<!DOCTYPE html><html><head></head><body>";
     foreach ($finder as $file) {
         $this->convertOneFile($file, $html_dir_path);
     }
     return "</body></html>";
 }
 /**
  * Initializes the internal Symfony Finder with appropriate filters
  *
  * @param string $sources Path to source files to be archived
  * @param array $excludes Composer's own exclude rules from composer.json
  */
 public function __construct($sources, array $excludes)
 {
     $fs = new Filesystem();
     $sources = $fs->normalizePath($sources);
     $filters = array(new HgExcludeFilter($sources), new GitExcludeFilter($sources), new ComposerExcludeFilter($sources, $excludes));
     $this->finder = new Finder\Finder();
     $this->finder->in($sources)->filter(function (\SplFileInfo $file) use($sources, $filters, $fs) {
         $relativePath = preg_replace('#^' . preg_quote($sources, '#') . '#', '', $fs->normalizePath($file->getRealPath()));
         $exclude = false;
         foreach ($filters as $filter) {
             $exclude = $filter->filter($relativePath, $exclude);
         }
         return !$exclude;
     })->ignoreVCS(true)->ignoreDotFiles(false);
     parent::__construct($this->finder->getIterator());
 }
Esempio n. 24
0
 protected function getPluginsBundlesClassNames()
 {
     $list = array();
     $path = __DIR__ . '/../plugins';
     if (!file_exists($path)) {
         return [];
     }
     $finder = new \Symfony\Component\Finder\Finder();
     $files = $finder->files()->in($path)->name('*Bundle.php');
     foreach ($files as $file) {
         $relativePathName = $file->getRelativePathName();
         $classPath = str_replace('.php', '', $relativePathName);
         $classPath = str_replace('/', '\\', $classPath);
         $list[] = $classPath;
     }
     return $list;
 }
Esempio n. 25
0
 public static function convert(GinnyInput $input)
 {
     $path = $input->getOption('schema_path');
     $parser = new \Symfony\Component\Yaml\Parser();
     if (is_dir($path)) {
         $data['name'] = $input->getOption('bundle');
         $data['namespace'] = $input->getOption('namespace');
         $data['models'] = [];
         $data['associations'] = [];
         $data['manyToManys'] = [];
         $schema_filename = $input->getOption('schema_filename');
         if (empty($schema_filename)) {
             $filenames = [];
             $finder = new \Symfony\Component\Finder\Finder();
             $finder->files()->in($input->getFullSchemaPath());
             foreach ($finder as $file) {
                 if ($file->getFilename() != 'ginny.yml') {
                     $filenames[] = $file->getFilename();
                 }
             }
         } else {
             $filenames = explode(',', $schema_filename);
         }
         foreach ($filenames as $filename) {
             $file = $parser->parse(file_get_contents($path . $filename));
             if (!empty($file['model'])) {
                 $defaults = ['name' => '', 'description' => ''];
                 $model = array_merge($defaults, $file['model']);
                 $defaults = ['name' => '', 'type' => '', 'size' => '', 'default' => false, 'required' => false, 'unique' => false, 'primary' => false, 'autoIncrement' => false];
                 foreach ($model['fields'] as $n => $field) {
                     $model['fields'][$n] = array_merge($defaults, $field);
                 }
                 $data['models'][] = $model;
             }
             if (!empty($file['associations'])) {
                 $data['associations'] = array_merge($data['associations'], $file['associations']);
             }
             if (!empty($file['manyToManys'])) {
                 $data['manyToManys'] = array_merge($data['manyToManys'], $file['manyToManys']);
             }
         }
         return ['bundles' => [$data]];
     }
     echo 'booger!';
     exit;
 }
 /**
  * @param       $directory
  * @param array $exclude
  * @param array $pattern
  *
  * @return Translations
  */
 public function fromDirectory($directory, $translations = null, $exclude = ['languages'], $pattern = ['*.php', '*.phtml'])
 {
     if (!$translations) {
         $translations = new Translations();
     }
     // fetch strings
     $sourcesFinder = new \Symfony\Component\Finder\Finder();
     $sourcesFinder->files()->in($directory)->exclude($exclude);
     foreach ($pattern as $filePattern) {
         $sourcesFinder->name($filePattern);
     }
     $sourcesList = iterator_to_array($sourcesFinder->getIterator());
     $sourcesList = array_map('strval', $sourcesList);
     foreach ($sourcesList as $sourceFile) {
         $this->fromFile($sourceFile, $translations);
     }
     return $translations;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dir = __DIR__ . '/../../../../';
     $projectHome = realpath($dir);
     $output->writeln($projectHome);
     $finder = new \Symfony\Component\Finder\Finder();
     $finder->in($projectHome . '/Tekstove');
     $finder->name('*.php');
     $finder->path('/\\/Base\\//')->path('/\\/Map\\//');
     $this->handleFinder($finder, $output, $projectHome);
     $finderNewFiles = new \Symfony\Component\Finder\Finder();
     $finderNewFiles->in($projectHome . '/Tekstove');
     $finderNewFiles->name('*.php');
     $this->handleFinder($finderNewFiles, $output, $projectHome, false);
     $fs = new \Symfony\Component\Filesystem\Filesystem();
     $fs->remove($projectHome . '/Tekstove');
     $output->writeln('<info>Command result.</info>');
 }
Esempio n. 28
0
 public function __construct(array $values = [])
 {
     parent::__construct($values);
     // $this['debug'] = TRUE;
     // Default values
     $values += ['templates' => 'templates', 'data' => 'data', 'content' => 'content', 'twig.options' => ['strict_variables' => FALSE]];
     if ($values['debug']) {
         $this['debug'] = TRUE;
         $values['twig.options']['debug'] = TRUE;
     }
     $this->register(new \Silex\Provider\TwigServiceProvider(), array('twig.path' => $values['templates'], 'twig.options' => $values['twig.options']));
     if ($this['debug']) {
         $this['twig']->addExtension(new \Twig_Extension_Debug());
     }
     $yaml = new \Symfony\Component\Yaml\Parser();
     // Load all data files
     if (file_exists($values['data'])) {
         $finder = new \Symfony\Component\Finder\Finder();
         $finder->files()->in($values['data'])->name('*.yml');
         foreach ($finder as $file) {
             $data = $yaml->parse($file->getContents());
             $this['twig']->addGlobal($file->getBasename('.yml'), $data);
         }
     }
     // Load all sample content
     $content = [];
     if (file_exists($values['content'])) {
         $finder = new \Symfony\Component\Finder\Finder();
         $finder->files()->in($values['content'] . '/*')->name('*.md');
         foreach ($finder as $file) {
             list(, $data, $body) = explode("---\n", $file->getContents());
             $data = $yaml->parse($data);
             $data['content'] = \Michelf\Markdown::defaultTransform($body);
             $content[basename(dirname($file->getPathname()))][] = $data;
             $content[basename(dirname($file->getPathname()))][$file->getBasename('.md')] = $data;
         }
     }
     $this['twig']->addGlobal('content', $content);
     // Setup the front controller
     $this->get('/{page}', function ($page) {
         $this['twig']->addGlobal('current_page', '/' . ($page == 'index' ? '' : $page));
         return $this->render($page . '.html');
     })->value('page', 'index');
 }
Esempio n. 29
0
    function convert($dir_path)
    {
        $html_dir_path = $dir_path ."/html";
        $json_dir_path = $dir_path ."/json";
        
        ensure_clean_dir($html_dir_path);
        ensure_clean_dir($json_dir_path);

        $finder = new \Symfony\Component\Finder\Finder();
        $finder->in($dir_path)->files()->name("SRMN*.docx");

        print "Beginning convertsion\n";
        
        foreach($finder as $file){
             $this->convertOneFile($file, $html_dir_path, $json_dir_path);
        }
        
        return  "</body></html>";
    }
Esempio n. 30
-2
 /**
  * @TODO
  */
 public function fromRoute($route)
 {
     // $this->route = $route;
     // Find the files that match the route.
     $finder = new \Symfony\Component\Finder\Finder();
     $glob = '#^default\\.(?:md|markdown|textile|html|htm|txt)$#';
     if ($route !== '') {
         $glob = '#^(?:\\d\\d\\.)?' . implode('\\/(?:\\d\\d\\.)?', explode('/', $route)) . '(?:\\/default)?\\.(?:md|markdown|textile|html|htm|txt)' . '$#';
     }
     $finder->in($this->documentPath)->path($glob);
     $files = [];
     foreach ($finder as $file) {
         $files[] = $file->getRelativePathname();
     }
     // Work out if we have *any* matching documents.  If not, throw an
     // exception.
     if (empty($files)) {
         throw new Exceptions\NoCandidatesException($route);
     }
     // Sort functions.
     $indexSort = function ($a, $b) {
         // return 0;
         return $a > $b;
     };
     $extensionSort = function ($a, $b) {
         $allowedExtensions = explode('|', 'md|markdown|textile|html|htm|txt');
         $aExt = pathinfo($a, PATHINFO_EXTENSION);
         $bExt = pathinfo($b, PATHINFO_EXTENSION);
         $aExtPos = array_search($aExt, $allowedExtensions);
         $bExtPos = array_search($bExt, $allowedExtensions);
         return $aExtPos > $bExtPos;
     };
     $isDefaultSort = function ($a, $b) {
         $aHasDefault = strpos($a, 'default.');
         $bHasDefault = strpos($b, 'default.');
         return $aHasDefault < $bHasDefault;
     };
     // Sort the documents according to their priority.
     $complexSort = \pjdietz\ComplexSort\ComplexSort::makeComplexSortFunction([$indexSort, $extensionSort, $isDefaultSort]);
     usort($files, $complexSort);
     // Read the file content from the filesystem.
     $fileReader = new FileReader(new \League\Flysystem\Filesystem(new \League\Flysystem\Adapter\Local($this->documentPath)));
     $filepath = $files[0];
     $content = $fileReader->read($filepath);
     // Create a document from the file content.
     $document = new Document($content);
     $document->filepath = $filepath;
     $document->parse();
     return $document;
 }