Example #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;
 }
 public function setUp()
 {
     $this->numberOfPayloads = 5;
     $this->realDirectory = sys_get_temp_dir() . '/storage';
     $this->chunkDirectory = $this->realDirectory . '/' . $this->chunksKey;
     $this->tempDirectory = $this->realDirectory . '/' . $this->orphanageKey;
     $this->payloads = array();
     if (!$this->checkIfTempnameMatchesAfterCreation()) {
         $this->markTestSkipped('Temporary directories do not match');
     }
     $filesystem = new \Symfony\Component\Filesystem\Filesystem();
     $filesystem->mkdir($this->realDirectory);
     $filesystem->mkdir($this->chunkDirectory);
     $filesystem->mkdir($this->tempDirectory);
     $adapter = new Adapter($this->realDirectory, true);
     $filesystem = new GaufretteFilesystem($adapter);
     $this->storage = new GaufretteStorage($filesystem, 100000);
     $chunkStorage = new GaufretteChunkStorage($filesystem, 100000, null, 'chunks');
     // create orphanage
     $session = new Session(new MockArraySessionStorage());
     $session->start();
     $config = array('directory' => 'orphanage');
     $this->orphanage = new GaufretteOrphanageStorage($this->storage, $session, $chunkStorage, $config, 'cat');
     for ($i = 0; $i < $this->numberOfPayloads; $i++) {
         // create temporary file as if it was reassembled by the chunk manager
         $file = tempnam($this->chunkDirectory, 'uploader');
         $pointer = fopen($file, 'w+');
         fwrite($pointer, str_repeat('A', 1024), 1024);
         fclose($pointer);
         //gaufrette needs the key relative to it's root
         $fileKey = str_replace($this->realDirectory, '', $file);
         $this->payloads[] = new GaufretteFile(new File($fileKey, $filesystem), $filesystem);
     }
 }
Example #3
0
 /**
  * Deletes the cache folder
  */
 public function nukeCache()
 {
     $this->clearSessionItems();
     $cacheDir = $this->factory->getSystemPath('cache', true);
     $fs = new \Symfony\Component\Filesystem\Filesystem();
     $fs->remove($cacheDir);
 }
 public function testBoot()
 {
     $fs = new \Symfony\Component\Filesystem\Filesystem();
     $fakeCacheDir = sys_get_temp_dir() . '/foo/bar/hello';
     $fs->remove($fakeCacheDir);
     $result = mkdir($fakeCacheDir, 0755, true);
     $this->assertTrue($result);
     $result = touch($fakeCacheDir . '/hi.txt');
     $this->assertTrue($result);
     $this->_mockContainerSupplier->shouldReceive('getServiceContainer')->once()->andReturn($this->_mockServiceContainer);
     $mockLogger = $this->mock(tubepress_api_log_LoggerInterface::_);
     $mockLogger->shouldReceive('debug')->atLeast(1);
     $mockLogger->shouldReceive('onBootComplete')->once();
     $this->_mockServiceContainer->shouldReceive('get')->once()->with(tubepress_api_log_LoggerInterface::_)->andReturn($mockLogger);
     $this->_bootSettings->shouldReceive('isClassLoaderEnabled')->once()->andReturn(true);
     $this->_bootSettings->shouldReceive('shouldClearCache')->once()->andReturn(true);
     $this->_bootSettings->shouldReceive('getPathToSystemCacheDirectory')->twice()->andReturn($fakeCacheDir);
     $this->_mockBootLogger->shouldReceive('flushTo')->once()->with($mockLogger);
     $this->_mockBootLogger->shouldReceive('onBootComplete')->once();
     $result = $this->_sut->getServiceContainer();
     $this->assertTrue(is_dir($fakeCacheDir));
     $this->assertSame($this->_mockServiceContainer, $result);
     $result = $this->_sut->getServiceContainer();
     $this->assertSame($this->_mockServiceContainer, $result);
 }
Example #5
0
 /**
  * @Rest\Post("/publish", name="admin_json_editor_publish")
  * @Rest\View()
  *
  * @return
  */
 public function publishAction(Request $request)
 {
     $path = $this->root . '/Resources/translations/messages.' . $request->getLocale() . '.json';
     file_put_contents($path, file_get_contents('php://input'));
     $fs = new \Symfony\Component\Filesystem\Filesystem();
     $fs->remove($this->root . '/cache/prod/translations');
     return array();
 }
 protected function setUp()
 {
     parent::setUp();
     $fs = new \Symfony\Component\Filesystem\Filesystem();
     $fs->remove($this->getAbsPath($this->buildName));
     $fs->remove($this->getAbsPath($this->buildName . '.sh'));
     ProcessUtil::runOk($this->cmd('amp cleanup'));
 }
 protected function moveFile($original, $destination)
 {
     $fs = new \Symfony\Component\Filesystem\Filesystem();
     $fileDir = dirname($destination);
     if (!$fs->exists($fileDir)) {
         $fs->mkdir($fileDir);
     }
     $fs->rename($original, $destination, true);
 }
Example #8
0
 public static function prepareLogFiles(array $paths)
 {
     $fs = new \Symfony\Component\Filesystem\Filesystem();
     foreach ($paths as $path) {
         $fs->remove($path);
         $fs->touch($paths);
         $fs->chmod($path, 0777);
     }
 }
Example #9
0
 public function __construct($environment, $debug)
 {
     if (!static::$runned) {
         $fileSystem = new Symfony\Component\Filesystem\Filesystem();
         $fileSystem->remove($this->getCacheDir());
         $fileSystem->remove($this->getLogDir());
         static::$runned = true;
     }
     parent::__construct($environment, $debug);
 }
Example #10
0
 private function dumpLocal()
 {
     $filesystem = new \Symfony\Component\Filesystem\Filesystem();
     if (!$filesystem->exists($this->databasePath)) {
         $this->result['status'] = 0;
         $this->result['message'] = "Defined Redis dump does not exist!";
         return $this->result;
     }
     $filesystem->copy($this->databasePath, $this->backupPath . $this->backupFilename);
     return true;
 }
Example #11
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());
         }
     }
 }
Example #12
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // throw new \Exception('boo');
     $directory = realpath($input->getArgument('directory'));
     $directoryOutput = $input->getArgument('outputdirectory');
     /* @var $logger Psr\Log\LoggerInterface */
     $this->logger = $this->getContainer()->get('logger');
     $io = new SymfonyStyle($input, $output);
     $io->title('DDD Model Generation');
     $clean = $input->hasOption('clean');
     if ($clean) {
         $io->section('Clean output directoty');
         $fs = new \Symfony\Component\Filesystem\Filesystem();
         try {
             $fs->remove($directoryOutput);
         } catch (IOExceptionInterface $e) {
             $io->error($e->getMessage());
         }
         $io->text('clean of ' . $directoryOutput . ' completed');
     }
     if (is_dir($directory)) {
         $finder = new Finder();
         $finder->search($directory);
         foreach ($finder->getFindedFiles() as $file) {
             if (pathinfo($file, PATHINFO_FILENAME) == 'model.yml') {
                 $io->text('Analizzo model.yml in ' . pathinfo($file, PATHINFO_DIRNAME));
                 $dddGenerator = new DDDGenerator();
                 $dddGenerator->setLogger($this->logger);
                 $dddGenerator->analyze($file);
                 $dddGenerator->generate($directoryOutput);
             }
         }
         $io->section('Php-Cs-Fixer on generated files');
         $fixer = new \Symfony\CS\Console\Command\FixCommand();
         $input = new ArrayInput(['path' => $directoryOutput, '--level' => 'psr2', '--fixers' => 'eof_ending,strict_param,short_array_syntax,trailing_spaces,indentation,line_after_namespace,php_closing_tag']);
         $output = new BufferedOutput();
         $fixer->run($input, $output);
         $content = $output->fetch();
         $io->text($content);
         if (count($this->errors) == 0) {
             $io->success('Completed generation');
         } else {
             $io->error($this->errors);
         }
     } else {
         $io->caution('Directory ' . $directory . ' not valid');
     }
     // PER I WARNING RECUPERABILI
     //$io->note('Generate Class');
 }
Example #13
0
 /**
  * Cope any local js libraries to export folder.
  * 
  * @param  string  $libraries
  * @param  string  $path
  * 
  * @return string  scripts html to insert before closing body tag
  */
 private function handleLibraries($libraries, $path)
 {
     $scripts = "<script src=\"js/jquery.js\"></script>\n<script src=\"js/bootstrap.js\"></script>\n";
     @$this->fs->copy($this->app['base_dir'] . '/assets/js/vendor/jquery.js', $path . 'js/jquery.js', true);
     @$this->fs->copy($this->app['base_dir'] . '/assets/js/vendor/bootstrap/bootstrap.min.js', $path . 'js/bootstrap.js', true);
     $libraries = json_decode($libraries);
     if ($libraries) {
         foreach ($libraries as $library) {
             if (is_string($library)) {
                 $library = Library::where('name', $library)->first();
             }
             if (!str_contains($library->path, '//')) {
                 $absolute = $this->relativeToAbsolute($library->path);
                 try {
                     @$this->fs->copy($absolute, $path . 'js/' . basename($absolute), true);
                 } catch (\Exception $e) {
                     continue;
                 }
                 $scripts .= '<script src="js/' . basename($library->path) . "\"></script>\n";
             } else {
                 $scripts .= '<script src="' . $library->path . "\"></script>\n";
             }
         }
     }
     return $scripts;
 }
 /**
  * @test
  * @covers Cocur\Bundle\BuildBundle\Command\CleanCommand::__construct()
  * @covers Cocur\Bundle\BuildBundle\Command\CleanCommand::configure()
  * @covers Cocur\Bundle\BuildBundle\Command\CleanCommand::execute()
  * @covers Cocur\Bundle\BuildBundle\Command\CleanCommand::cleanDirectory()
  */
 public function executeShouldOutputDetailedInformationInVerboseMode()
 {
     $this->buildDir->addChild(vfsStream::newFile('foo1.txt'));
     $this->buildDir->addChild($barDir = vfsStream::newDirectory('bar'));
     $barDir->addChild(vfsStream::newFile('foo2.txt'));
     $this->filesystem->shouldReceive('remove')->with(sprintf('%s/foo1.txt', $this->buildDir->url()))->once();
     $this->filesystem->shouldReceive('remove')->with(sprintf('%s/bar/foo2.txt', $this->buildDir->url()))->once();
     $this->filesystem->shouldReceive('remove')->with(sprintf('%s/bar', $this->buildDir->url()))->once();
     $command = $this->application->find('cocur:clean');
     $commandTester = new CommandTester($command);
     $commandTester->execute(['command' => $command->getName()], ['verbosity' => 2]);
     $this->assertRegExp('/Delete:(.*)foo1\\.txt/', $commandTester->getDisplay());
     $this->assertRegExp('/Delete:(.*)bar/', $commandTester->getDisplay());
     $this->assertRegExp('/Delete:(.*)bar\\/foo2\\.txt/', $commandTester->getDisplay());
     $this->assertRegExp('/Removed 3 files from/', $commandTester->getDisplay());
 }
    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);
    }
 /**
  * Executes a command via CLI
  *
  * @param Console\Input\InputInterface $input
  * @param Console\Output\OutputInterface $output
  *
  * @return int|null|void
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $tempFolder = $input->getOption('temp-folder');
     $destinationFolder = $input->getOption('src-destination');
     if (empty($destinationFolder)) {
         $destinationFolder = realpath(__DIR__ . '/../../../../');
     }
     if (!is_writable($destinationFolder)) {
         $output->writeln('Chash update failed: the "' . $destinationFolder . '" directory used to update the Chash file could not be written');
         return 0;
     }
     if (!is_writable($tempFolder)) {
         $output->writeln('Chash update failed: the "' . $tempFolder . '" directory used to download the temp file could not be written');
         return 0;
     }
     //$protocol = extension_loaded('openssl') ? 'https' : 'http';
     $protocol = 'http';
     $rfs = new RemoteFilesystem(new NullIO());
     // Chamilo version
     //$latest = trim($rfs->getContents('version.chamilo.org', $protocol . '://version.chamilo.org/version.php', false));
     //https://github.com/chamilo/chash/archive/master.zip
     $tempFile = $tempFolder . '/chash-master.zip';
     $rfs->copy('github.com', 'https://github.com/chamilo/chash/archive/master.zip', $tempFile);
     if (!file_exists($tempFile)) {
         $output->writeln('Chash update failed: the "' . $tempFile . '" file could not be written');
         return 0;
     }
     $folderPath = $tempFolder . '/chash';
     if (!is_dir($folderPath)) {
         mkdir($folderPath);
     }
     $zippy = Zippy::load();
     $archive = $zippy->open($tempFile);
     try {
         $archive->extract($folderPath);
     } catch (\Alchemy\Zippy\Exception\RunTimeException $e) {
         $output->writeln("<comment>Chash update failed during unzip.");
         $output->writeln($e->getMessage());
         return 0;
     }
     $fs = new \Symfony\Component\Filesystem\Filesystem();
     $fs->mirror($folderPath . '/chash-master', $destinationFolder, null, array('override' => true));
     $output->writeln('Copying ' . $folderPath . '/chash-master to ' . $destinationFolder);
 }
 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!");
 }
Example #18
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\AopBundle\JMSAopBundle(), new JMS\DiExtraBundle\JMSDiExtraBundle($this), new APY\DataGridBundle\APYDataGridBundle(), 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 Tetranz\Select2EntityBundle\TetranzSelect2EntityBundle(), new Presta\SitemapBundle\PrestaSitemapBundle(), new HWI\Bundle\OAuthBundle\HWIOAuthBundle(), new Baskin\HistoryBundle\BaskinHistoryBundle(), new Ojs\CoreBundle\OjsCoreBundle(), new Ojs\SiteBundle\OjsSiteBundle(), new Ojs\AdminBundle\OjsAdminBundle(), new Ojs\ApiBundle\OjsApiBundle(), new Ojs\JournalBundle\OjsJournalBundle(), new Ojs\UserBundle\OjsUserBundle(), new Ojs\OAIBundle\OjsOAIBundle(), new Ojs\ExportBundle\OjsExportBundle(), new BulutYazilim\LocationBundle\BulutYazilimLocationBundle(), new FOS\UserBundle\FOSUserBundle(), new Ojs\AnalyticsBundle\OjsAnalyticsBundle(), new Knp\Bundle\MenuBundle\KnpMenuBundle(), new JMS\TranslationBundle\JMSTranslationBundle(), new Ojs\ImportBundle\ImportBundle(), new \OpenJournalSoftware\BibtexBundle\OpenJournalSoftwareBibtexBundle(), new Exercise\HTMLPurifierBundle\ExerciseHTMLPurifierBundle(), new h4cc\AliceFixturesBundle\h4ccAliceFixturesBundle(), new Bazinga\Bundle\JsTranslationBundle\BazingaJsTranslationBundle());
     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 Symfony\Bundle\DebugBundle\DebugBundle();
         $bundles[] = new Liip\FunctionalTestBundle\LiipFunctionalTestBundle();
     }
     $accessor = PropertyAccess::createPropertyAccessor();
     $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) {
                 $class = $accessor->getValue($bundleConfig, '[extra][bundle-class]');
                 if ($class && class_exists($class)) {
                     $bundles[] = new $class();
                 }
                 $otherClasses = $accessor->getValue($bundleConfig, '[extra][other-bundle-classes]');
                 if (is_array($otherClasses)) {
                     foreach ($otherClasses as $otherClass) {
                         $otherClassInstance = new $otherClass();
                         if (!in_array($otherClassInstance, $bundles)) {
                             $bundles[] = $otherClassInstance;
                         }
                     }
                 }
             }
         }
     }
     return $bundles;
 }
Example #19
0
 /**
  * Use given template for given project.
  * 
  * @param  ProjectModel $project    
  * @param  integer      $templateId 
  * 
  * @return ProjectModel
  */
 private function useTemplate(Project $project, $templateId)
 {
     $template = Template::with('pages')->find($templateId);
     $pages = array();
     foreach ($template->pages as $page) {
         $pages[] = new Page(array_except($page->toArray(), array('id', 'pageable_id', 'pageable_type', 'created_at', 'updated_at')));
     }
     $project->pages()->saveMany($pages);
     $this->attachLibraries($project);
     //copy thumbnail from template to project
     $path = $this->app['base_dir'] . '/' . $template->thumbnail;
     $this->fs->copy($path, $this->app['base_dir'] . '/assets/images/projects/project-' . $project->id . '.png', true);
     return $project;
 }
 /**
  * @covers Alchemy\Zippy\Resource\ResourceManager::handle
  */
 public function testFunctionnal()
 {
     $wd = __DIR__;
     $tmpdir = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR);
     $filesystem = new \Symfony\Component\Filesystem\Filesystem();
     $filesystem->mkdir($tmpdir . '/path/to/local/');
     $filesystem->mkdir($tmpdir . '/to/');
     $filesystem->mkdir($tmpdir . '/path/to/a');
     touch($tmpdir . '/path/to/local/file.ext');
     touch($tmpdir . '/path/to/local/file2.ext');
     touch($tmpdir . '/to/file3.ext');
     $request = array($wd . '/input/path/to/local/file.ext', $wd . '/input/path/to/a/../local/file2.ext', $tmpdir . '/path/to/local/file.ext', $tmpdir . '/path/to/a/../local/file2.ext', 'http://www.google.com/+/business/images/plus-badge.png', 'http://www.google.com/+/business/images/plusone-button.png', 'file://' . $tmpdir . '/to/file3.ext', 'file://' . $wd . '/input/path/to/a/../local/file3.ext', '/I/want/this/file/to/go/there' => 'file://' . $wd . '/input/path/to/local/file2.ext', '/I/want/this/file/to/go/here' => 'file://' . $wd . '/input/path/to/local/file3.ext');
     $expected = array('input/path/to/local/file.ext', 'input/path/to/local/file2.ext', 'file.ext', 'file2.ext', 'plus-badge.png', 'plusone-button.png', 'file3.ext', 'input/path/to/local/file3.ext', 'I/want/this/file/to/go/there', 'I/want/this/file/to/go/here');
     $expectedSource = array($request[0], $request[1], $request[2], $request[3], $request[4], $request[5], $request[6], $request[7], $request['/I/want/this/file/to/go/there'], $request['/I/want/this/file/to/go/here']);
     $resourceManger = ResourceManager::create();
     $collection = $resourceManger->handle($wd, $request);
     $this->assertCount(10, $collection);
     $n = 0;
     foreach ($collection as $resource) {
         $this->assertEquals($expected[$n], $resource->getTarget());
         $this->assertEquals($expectedSource[$n], $resource->getOriginal());
         $n++;
     }
 }
Example #21
0
 /**
  * Get the path for the specified namespace
  *
  * @param array $paths
  * @param string $group
  * @param string $mode
  * @param bool $exists
  * @return string
  */
 protected function findInPaths(array $paths, $group, $mode = null, $exists = false)
 {
     $items = [];
     foreach ($paths as $path) {
         if ($this->fs->exists($file = "{$path}/{$group}.php")) {
             if ($exists) {
                 return true;
             }
             $items = array_merge_recursive($this->fs->getRequire($file), $items);
         }
         if ($mode and $this->fs->exists($file = "{$path}/{$mode}/{$group}.php")) {
             if ($exists) {
                 return true;
             }
             $items = array_merge_recursive($this->fs->getRequire($file), $items);
         }
     }
     return $items;
 }
Example #22
0
 /**
  * Check if required folders are writable.
  * 
  * @return array
  */
 public function checkFolders()
 {
     $checked = array();
     $problem = false;
     $fs = App::make('Illuminate\\Filesystem\\Filesystem');
     $this->files = App::make('Symfony\\Component\\Filesystem\\Filesystem');
     $this->assetPath = public_path('assets');
     //push all the directories in storage folder to dirs
     //array so we check if they are writable as well
     foreach ($fs->directories(storage_path()) as $sdir) {
         $this->dirs[] = $sdir;
     }
     foreach ($this->dirs as $dir) {
         if (str_contains($dir, 'imdb')) {
             $path = public_path($dir);
         } else {
             $path = str_contains($dir, 'storage') ? $dir : $this->assetPath . $dir;
         }
         //if direcotry is not writable attempt to chmod it now
         if (!is_writable($path)) {
             try {
                 $this->files->chmod($path, 0777, 00, true);
             } catch (Exception $e) {
             }
         }
         $writable = is_writable($path);
         $checked[] = array('path' => $path, 'writable' => $writable);
         if (!$problem) {
             $problem = $writable ? false : true;
         }
     }
     //make a notice if there was a problem or not with folders if
     //there wasn't a problem with extensions already
     if (!array_key_exists('problem', $this->compatResults) || !$this->compatResults['problem']) {
         $this->compatResults['problem'] = $problem;
     }
     return $checked;
 }
Example #23
0
 /**
  * @param string $code
  *
  * @When /^I wait for the "([^"]*)" job to finish$/
  */
 public function iWaitForTheJobToFinish($code)
 {
     $condition = '$("#status").length && /(COMPLETED|STOPPED|FAILED|TERMINÉ|ARRÊTÉ|EN ÉCHEC)$/.test($("#status").text().trim())';
     try {
         $this->wait($condition);
     } catch (BehaviorException $e) {
         $jobInstance = $this->getFixturesContext()->getJobInstance($code);
         $jobExecution = $jobInstance->getJobExecutions()->first();
         $log = $jobExecution->getLogFile();
         if (is_file($log)) {
             $dir = getenv('WORKSPACE');
             $id = getenv('BUILD_ID');
             if (false !== $dir && false !== $id) {
                 $target = sprintf('%s/../builds/%s/batch_log/%s', $dir, $id, pathinfo($log, PATHINFO_BASENAME));
                 $fs = new \Symfony\Component\Filesystem\Filesystem();
                 $fs->copy($log, $target);
                 $log = sprintf('http://ci.akeneo.com/screenshots/%s/%s/batch_log/%s', getenv('JOB_NAME'), $id, pathinfo($log, PATHINFO_BASENAME));
             }
             $message = sprintf('Job "%s" failed, log available at %s', $code, $log);
             $this->getMainContext()->addErrorMessage($message);
         } else {
             $this->getMainContext()->addErrorMessage(sprintf('Job "%s" failed, no log available', $code));
         }
         // Get and print the normalized jobexecution to ease debugging
         $this->getSession()->executeScript(sprintf('$.get("/%s/%s_execution/%d.json", function (resp) { window.executionLog = resp; });', $jobInstance->getType() === 'import' ? 'collect' : 'spread', $jobInstance->getType(), $jobExecution->getId()));
         $this->wait();
         $executionLog = $this->getSession()->evaluateScript("return window.executionLog;");
         $this->getMainContext()->addErrorMessage(sprintf('Job execution: %s', print_r($executionLog, true)));
         // Call the wait method again to trigger timeout failure
         $this->wait($condition);
     }
 }
Example #24
0
 protected function getRootImageDir()
 {
     if (is_null($this->rootImageDir)) {
         $this->rootImageDir = $this->getParameter('kernel.root_dir') . '/../web/' . $this->getImageDir();
         $fs = new \Symfony\Component\Filesystem\Filesystem();
         if (!$fs->exists($this->rootImageDir)) {
             $fs->mkdir($this->rootImageDir);
         }
     }
     return $this->rootImageDir;
 }
Example #25
0
<?php

/*
 * This file is part of the Sonata package.
 *
 * (c) Thomas Rabaix <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
$rootDir = __DIR__;
require_once __DIR__ . '/app/bootstrap.php.cache';
// reset data
$fs = new \Symfony\Component\Filesystem\Filesystem();
$output = new \Symfony\Component\Console\Output\ConsoleOutput();
// does the parent directory have a parameters.yml file
if (is_file(__DIR__ . '/../parameters.demo.yml')) {
    $fs->copy(__DIR__ . '/../parameters.demo.yml', __DIR__ . '/app/config/parameters.yml', true);
}
if (!is_file(__DIR__ . '/app/config/parameters.yml')) {
    $output->writeln('<error>no default apps/config/parameters.yml file</error>');
    exit(1);
}
/**
 * @param $commands
 * @param \Symfony\Component\Console\Output\ConsoleOutput $output
 *
 * @return boolean
 */
function execute_commands($commands, $output)
{
 /**
  * @BeforeScenario
  */
 public function removeTmpDir()
 {
     $fs = new \Symfony\Component\Filesystem\Filesystem();
     $fs->remove($this->placeholderValues['%tmp%']);
 }
Example #27
0
}
function module_hook($module, $hook)
{
    $function = $module . '_' . $hook;
    if (function_exists($function)) {
        return TRUE;
    } else {
        $file = __DIR__ . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . $module . '.module';
        if (file_exists($file)) {
            require_once __DIR__ . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . $module . '.module';
        }
    }
    return function_exists($function);
}
function module_invoke($module, $hook)
{
    $args = func_get_args();
    unset($args[0], $args[1]);
    if (module_hook($module, $hook)) {
        return call_user_func_array($module . '_' . $hook, $args);
    }
}
function conf_path()
{
    return 'sites/default';
}
$loader = (require __DIR__ . '/../vendor/autoload.php');
register_shutdown_function(function () {
    $fs = new \Symfony\Component\Filesystem\Filesystem();
    $fs->remove(DRUPONY_TEST_DIR);
});
Example #28
0
 /**
  * Recursiveley create a directory path.
  *
  * @param string  $path     The path we wish to generate.
  * @param string  $mode     The (UNIX) mode we wish to create the files with.
  * @param boolean $absolute Allow absolute paths (default=false) (optional).
  *
  * @deprecated since 1.3.0
  * @see    http://php.net/mkdir
  *
  * @return boolean TRUE on success, FALSE on failure.
  */
 public static function mkdirs($path, $mode = 0777, $absolute = false)
 {
     if (is_dir($path)) {
         return true;
     }
     $path = DataUtil::formatForOS($path, $absolute);
     // mkdir does not set chmod properly
     mkdir($path, $mode, true);
     $fs = new \Symfony\Component\Filesystem\Filesystem();
     $fs->chmod($path, $mode, 00, true);
 }
Example #29
0
File: config.php Project: sulu/sulu
<?php

/*
 * This file is part of Sulu.
 *
 * (c) MASSIVE ART WebServices GmbH
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */
$filesystem = new \Symfony\Component\Filesystem\Filesystem();
$context = $container->getParameter('sulu.context');
$path = __DIR__ . DIRECTORY_SEPARATOR;
if (!$filesystem->exists($path . 'parameters.yml')) {
    $filesystem->copy($path . 'parameters.yml.dist', $path . 'parameters.yml');
}
$loader->import('parameters.yml');
$loader->import('context_' . $context . '.yml');
Example #30
0
function createContents($faker, $folders, $con)
{
    echo "start creating contents\n";
    $fileSystem = new \Symfony\Component\Filesystem\Filesystem();
    $contents = array();
    if (($handle = fopen(THELIA_ROOT . '/setup/import/contents.csv', "r")) !== FALSE) {
        $row = 0;
        while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
            $row++;
            if ($row == 1) {
                continue;
            }
            $content = new \Thelia\Model\Content();
            $content->setVisible(1)->setPosition($row - 1)->setLocale('fr_FR')->setTitle(trim($data[0]))->setChapo($faker->text(20))->setDescription($faker->text(200))->setLocale('en_US')->setTitle(trim($data[1]))->setChapo($faker->text(20))->setDescription($faker->text(200));
            // folder
            $contentFolders = explode(';', $data[7]);
            $defaultFolder = null;
            foreach ($contentFolders as $contentFolder) {
                $contentFolder = trim($contentFolder);
                if (array_key_exists($contentFolder, $folders)) {
                    $content->addFolder($folders[$contentFolder]);
                    if (null === $defaultFolder) {
                        $defaultFolder = $folders[$contentFolder]->getId();
                    }
                }
            }
            $content->getContentFolders()->getFirst()->setDefaultFolder(true)->save($con);
            $content->save($con);
            $images = explode(';', $data[6]);
            foreach ($images as $image) {
                $image = trim($image);
                if (empty($image)) {
                    continue;
                }
                $contentImage = new \Thelia\Model\ContentImage();
                $contentImage->setContentId($content->getId())->setFile($image)->save($con);
                $fileSystem->copy(THELIA_ROOT . 'setup/import/images/' . $image, THELIA_ROOT . 'local/media/images/content/' . $image, true);
            }
            $contents[trim($data[1])] = $content;
        }
        fclose($handle);
    }
    echo "Contents created successfully\n";
    return $contents;
}