/**
  * Gets translation files location.
  *
  * @return array
  */
 private function getLocations()
 {
     $locations = array();
     if (class_exists('Symfony\\Component\\Validator\\Validator')) {
         $r = new \ReflectionClass('Symfony\\Component\\Validator\\Validator');
         $locations[] = dirname($r->getFilename()) . '/Resources/translations';
     }
     if (class_exists('Symfony\\Component\\Form\\Form')) {
         $r = new \ReflectionClass('Symfony\\Component\\Form\\Form');
         $locations[] = dirname($r->getFilename()) . '/Resources/translations';
     }
     if (class_exists('Symfony\\Component\\Security\\Core\\Exception\\AuthenticationException')) {
         $r = new \ReflectionClass('Symfony\\Component\\Security\\Core\\Exception\\AuthenticationException');
         if (file_exists($dir = dirname($r->getFilename()) . '/../../Resources/translations')) {
             $locations[] = $dir;
         } else {
             // Symfony 2.4 and above
             $locations[] = dirname($r->getFilename()) . '/../Resources/translations';
         }
     }
     $overridePath = $this->kernel->getRootDir() . '/Resources/%s/translations';
     foreach ($this->kernel->getBundles() as $bundle => $class) {
         $reflection = new \ReflectionClass($class);
         if (is_dir($dir = dirname($reflection->getFilename()) . '/Resources/translations')) {
             $locations[] = $dir;
         }
         if (is_dir($dir = sprintf($overridePath, $bundle))) {
             $locations[] = $dir;
         }
     }
     if (is_dir($dir = $this->kernel->getRootDir() . '/Resources/translations')) {
         $locations[] = $dir;
     }
     return $locations;
 }
 /**
  * @AfterScenario
  */
 public function deleteDatabaseIfExist()
 {
     $dbFilePath = $this->kernel->getRootDir() . '/data.sqlite';
     if (file_exists($dbFilePath)) {
         unlink($dbFilePath);
     }
 }
 public function convert($cacheDir)
 {
     $fs = new Filesystem();
     $targetDir = $cacheDir . '/js_entities';
     $webDir = $this->kernel->getRootDir() . '/../web/js';
     $fs->mkdir($targetDir);
     $fs->mkdir($webDir);
     $namespaces = [];
     $metas = $this->entityManager->getMetadataFactory()->getAllMetadata();
     foreach ($metas as $metadata) {
         $meta = $this->convertMetadata($metadata);
         $directory = $targetDir . '/' . $meta->namespace;
         $fs->mkdir($directory);
         $meta->filename = $directory . '/' . $meta->functionName . '.js';
         $this->generator->generateEntity($meta);
         if (!isset($namespaces[$meta->namespace])) {
             $namespaces[$meta->namespace] = array();
         }
         $namespaces[$meta->namespace][] = $meta;
     }
     foreach ($namespaces as $namespace => $metas) {
         $targetFile = $targetDir . '/' . $namespace . '.js';
         $webFile = $webDir . '/' . $namespace . '.js';
         $this->generator->generateNamespace($namespace, $metas, $targetFile);
         $fs->copy($targetFile, $webFile);
     }
 }
 /**
  * Dumps all translation files.
  *
  * @param string  $targetDir Target directory.
  * @param boolean $symlink   True if generate symlink
  *
  * @return null
  */
 public function dump($targetDir = 'web', $symlink = false, $directory = null)
 {
     $route = $this->router->getRouteCollection()->get('bazinga_exposetranslation_js');
     $directory = null === $directory ? $this->kernel->getRootDir() . '/../' : $directory;
     $requirements = $route->getRequirements();
     $formats = explode('|', $requirements['_format']);
     $routeDefaults = $route->getDefaults();
     $defaultFormat = $routeDefaults['_format'];
     $parts = array_filter(explode('/', $route->getPattern()));
     $this->filesystem->remove($directory . $targetDir . "/" . current($parts));
     foreach ($this->getTranslationMessages() as $locale => $domains) {
         foreach ($domains as $domain => $messageList) {
             foreach ($formats as $format) {
                 $content = $this->engine->render('BazingaExposeTranslationBundle::exposeTranslation.' . $format . '.twig', array('messages' => array($domain => $messageList), 'locale' => $locale, 'defaultDomains' => $domain));
                 $path[$format] = $directory . $targetDir . strtr($route->getPattern(), array('{domain_name}' => $domain, '{_locale}' => $locale, '{_format}' => $format));
                 $this->filesystem->mkdir(dirname($path[$format]), 0777);
                 if (file_exists($path[$format])) {
                     $this->filesystem->remove($path[$format]);
                 }
                 file_put_contents($path[$format], $content);
             }
             $targetFile = $directory . $targetDir;
             $targetFile .= strtr($route->getPattern(), array('{domain_name}' => $domain, '{_locale}' => $locale, '.{_format}' => ''));
             if (true === $symlink) {
                 $this->filesystem->symlink($path[$defaultFormat], $targetFile);
             } else {
                 $this->filesystem->copy($path[$defaultFormat], $targetFile);
             }
         }
     }
 }
 /**
  * @Given there is a file named :filename with:
  */
 public function createFile($filename, PyStringNode $content)
 {
     $filesytem = new Filesystem();
     $file = str_replace('%kernel.root_dir%', $this->kernel->getRootDir(), $filename);
     $filesytem->mkdir(dirname($file));
     file_put_contents($file, (string) $content);
 }
 /**
  * @param JsonCoder $jsonCoder
  * @return Raml\DocNavigator
  */
 public function createNavigator(JsonCoder $jsonCoder)
 {
     $ramlDocPath = $this->kernel->getRootDir() . static::RAML_DOC_PATH;
     if (!is_readable($ramlDocPath)) {
         throw new \RuntimeException(static::ERROR_PARAM_TYPE);
     }
     $ramlDoc = $this->parser->parse($ramlDocPath);
     return new Raml\DocNavigator($ramlDoc, $jsonCoder);
 }
Exemplo n.º 7
0
 /**
  * {@inheritdoc}
  */
 public function populate(EntityManager $em = null)
 {
     $process = new Process(sprintf("%s/console fos:elastica:populate --env=%s", $this->kernel->getRootDir(), $this->kernel->getEnvironment()));
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getErrorOutput());
     }
     $this->output = $process->getOutput();
     return $this;
 }
 /**
  * Returns paths to directories that *might* contain Twig views.
  *
  * Please note, that it is not guaranteed that these directories exist.
  *
  * @return string[]
  */
 protected function getPossibleViewDirectories()
 {
     $viewDirectories = array();
     $globalResourceDirectory = $this->kernel->getRootDir() . '/Resources';
     $viewDirectories[] = $globalResourceDirectory;
     foreach ($this->kernel->getBundles() as $bundle) {
         /* @var $bundle BundleInterface */
         $viewDirectory = $bundle->getPath() . '/Resources/views';
         $viewDirectories[] = $viewDirectory;
     }
     return $viewDirectories;
 }
 /**
  * Describe Worker.
  *
  * Given a output object and a Worker, dscribe it.
  *
  * @param OutputInterface $output             Output object
  * @param array           $worker             Worker array with Job to describe
  * @param Boolean         $tinyJobDescription If true also print job list
  */
 public function describeWorker(OutputInterface $output, array $worker, $tinyJobDescription = false)
 {
     /**
      * Commandline
      */
     $script = $this->kernel->getRootDir() . '/console gearman:worker:execute';
     $output->writeln('');
     $output->writeln('<info>@Worker\\className : ' . $worker['className'] . '</info>');
     $output->writeln('<info>@Worker\\fileName : ' . $worker['fileName'] . '</info>');
     $output->writeln('<info>@Worker\\nameSpace : ' . $worker['namespace'] . '</info>');
     $output->writeln('<info>@Worker\\callableName: ' . $worker['callableName'] . '</info>');
     /**
      * Also a complete and clean execution path is given , for supervisord
      */
     $output->writeln('<info>@Worker\\supervisord : </info><comment>/usr/bin/php ' . $script . ' ' . $worker['callableName'] . ' --no-interaction</comment>');
     /**
      * Service value is only explained if defined. Not mandatory
      */
     if (null !== $worker['service']) {
         $output->writeln('<info>@Worker\\service : ' . $worker['service'] . '</info>');
     }
     $output->writeln('<info>@worker\\iterations : ' . $worker['iterations'] . '</info>');
     $output->writeln('<info>@Worker\\#jobs : ' . count($worker['jobs']) . '</info>');
     if ($tinyJobDescription) {
         $output->writeln('<info>@Worker\\jobs</info>');
         $output->writeln('');
         foreach ($worker['jobs'] as $job) {
             if ($job['jobPrefix']) {
                 $output->writeln('<comment>    # ' . $job['realCallableNameNoPrefix'] . ' with jobPrefix: ' . $job['jobPrefix'] . '</comment>');
             } else {
                 $output->writeln('<comment>    # ' . $job['realCallableNameNoPrefix'] . ' </comment>');
             }
         }
     }
     /**
      * Printed every server is defined for current job
      */
     $output->writeln('');
     $output->writeln('<info>@worker\\servers :</info>');
     $output->writeln('');
     foreach ($worker['servers'] as $name => $server) {
         $output->writeln('<comment>    #' . $name . ' - ' . $server['host'] . ':' . $server['port'] . '</comment>');
     }
     /**
      * Description
      */
     $output->writeln('');
     $output->writeln('<info>@Worker\\description :</info>');
     $output->writeln('');
     $output->writeln('<comment>    ' . $worker['description'] . '</comment>');
     $output->writeln('');
 }
Exemplo n.º 10
0
 /**
  * @return string
  */
 public function getProjectDir()
 {
     $filesystem = new Filesystem();
     $lastPath = realpath($this->kernel->getRootDir());
     $parentCount = substr_count($lastPath, DIRECTORY_SEPARATOR);
     for ($i = 0; $i < $parentCount; $i++) {
         $lastPath = dirname($lastPath);
         if ($filesystem->exists($lastPath . DIRECTORY_SEPARATOR . 'composer.json') || $filesystem->exists($lastPath . DIRECTORY_SEPARATOR . 'composer.json')) {
             return $lastPath;
         }
     }
     throw new \RuntimeException('Could not find project root');
 }
 /**
  * @param Method $method
  * @return array
  */
 public function resolve(Method $method)
 {
     /** @var Annotation $annotation */
     $annotation = $method->annotations->withName('Template')->first();
     // テンプレート名を取得する
     $name = array_shift($annotation->parameters);
     if (!$name) {
         $templateReference = $this->guessTemplateName($method->class->getFQCN(), str_replace('Action', '', $method->name));
     } else {
         $templateReference = $this->templateNameParser->parse($this->kernel->getRootDir() . '/Resources/views/' . $name);
     }
     $template = $this->loader->load($templateReference);
     return ['method' => $method, 'name' => $name, 'template' => $templateReference, 'path' => $template];
 }
 /**
  * Returns an array of translation files for a given domain and a given locale.
  *
  * @param string $domainName    A domain translation name.
  * @param string $locale        A locale.
  * @return array                An array of translation files.
  */
 public function getResources($domainName, $locale)
 {
     $finder = new Finder();
     $locations = array();
     foreach ($this->kernel->getBundles() as $bundle) {
         if (is_dir($bundle->getPath() . '/Resources/translations')) {
             $locations[] = $bundle->getPath() . '/Resources/translations';
         }
     }
     if (is_dir($this->kernel->getRootDir() . '/Resources/translations')) {
         $locations[] = $this->kernel->getRootDir() . '/Resources/translations';
     }
     return $finder->files()->name($domainName . '.' . $locale . '.*')->followLinks()->in($locations);
 }
Exemplo n.º 13
0
 /**
  * @return Application
  */
 private function registerCommandsToApplication(Application $application, KernelInterface $kernel)
 {
     chdir($kernel->getRootDir() . '/..');
     foreach ($this->getBundlesFromKernel($kernel) as $bundle) {
         $bundle->registerCommands($application);
     }
     return $application;
 }
Exemplo n.º 14
0
 /**
  * Load common fixtures
  *
  * @param KernelInterface $kernel Kernel
  *
  * @return $this Self object
  */
 private function loadCommonFixtures(KernelInterface $kernel)
 {
     $rootDir = $kernel->getRootDir();
     $command = 'doctrine:fixtures:load ' . '--fixtures=' . $rootDir . '/../src/Elcodi/Plugin/ ' . '--fixtures=' . $rootDir . '/../src/Elcodi/Fixtures ' . '--env=test ' . '--no-interaction ' . '--quiet ';
     $input = new StringInput($command);
     $this->application->run($input);
     return $this;
 }
Exemplo n.º 15
0
 /**
  * get subcommand
  *
  * @param array $args args
  *
  * @return string
  */
 private function getCmd(array $args)
 {
     // get path to console from kernel..
     $consolePath = $this->kernel->getRootDir() . '/console';
     $cmd = 'php ' . $consolePath . ' -n ';
     foreach ($args as $key => $val) {
         if (strlen($key) > 1) {
             $cmd .= ' ' . $key;
         }
         if (strlen($key) > 1 && !is_null($val)) {
             $cmd .= '=';
         }
         if (strlen($val) > 1) {
             $cmd .= escapeshellarg($val);
         }
     }
     return $cmd;
 }
Exemplo n.º 16
0
 /**
  * Constructor
  *
  * @param KernelInterface $kernel
  */
 public function __construct(KernelInterface $kernel)
 {
     $this->bundles = $kernel->getBundles();
     $this->appFolder = $this->realPath($kernel->getRootDir());
     $this->fileLoaders = array();
     $this->addFileLoader('php', 'Symfony\\Component\\Translation\\Loader\\PhpFileLoader');
     $this->addFileLoader('yml', 'Symfony\\Component\\Translation\\Loader\\YamlFileLoader');
     $this->addFileLoader('xlf', 'Symfony\\Component\\Translation\\Loader\\XliffFileLoader');
 }
 /**
  * @param $argument
  * @param $value
  * @return string
  */
 public function prepareValue($argument, $value)
 {
     switch ($argument) {
         case 'file':
             $value = $this->kernel->getRootDir() . DIRECTORY_SEPARATOR . $value;
             break;
     }
     return $value;
 }
Exemplo n.º 18
0
 private function asseticDump(OutputInterface $output, KernelInterface $kernel)
 {
     $consolePath = $kernel->getRootDir() . '/console';
     $assetProcess = new Process('php ' . $consolePath . ' assets:install --env=prod && php ' . $consolePath . ' assetic:dump --env=prod &&  php ' . $consolePath . ' cache:clear --env=prod', $kernel->getRootDir() . '/..', null, null, 600);
     $assetProcess->setPty(true);
     try {
         $assetProcess->mustRun();
         $output->writeln($assetProcess->getOutput());
     } catch (ProcessFailedException $e) {
         echo $e->getMessage();
         $output->writeln($e->getMessage());
     }
     if ($assetProcess->isSuccessful()) {
         $output->writeln('<info>Assets succesfully installed</info>');
     } else {
         $output->writeln('<error>Assets installation failed</error>');
     }
 }
Exemplo n.º 19
0
 /**
  * @param FileSystemMap       $filesystemMap
  * @param EntityManager       $em
  * @param KernelInterface     $kernel
  * @param ServiceLink         $securityFacadeLink
  * @param ConfigFileValidator $configFileValidator
  * @param AttachmentConfig    $attachmentConfig
  */
 public function __construct(FilesystemMap $filesystemMap, EntityManager $em, KernelInterface $kernel, ServiceLink $securityFacadeLink, ConfigFileValidator $configFileValidator, AttachmentConfig $attachmentConfig)
 {
     $this->filesystem = $filesystemMap->get('attachments');
     $this->em = $em;
     $this->attachmentDir = $kernel->getRootDir() . DIRECTORY_SEPARATOR . self::ATTACHMENT_DIR;
     $this->securityFacadeLink = $securityFacadeLink;
     $this->configFileValidator = $configFileValidator;
     $this->attachmentConfig = $attachmentConfig;
 }
Exemplo n.º 20
0
 /**
  * Constructor.
  *
  * @DI\InjectParams({
  *     "em"              = @DI\Inject("claroline.persistence.object_manager"),
  *     "im"              = @DI\Inject("claroline.manager.icon_manager"),
  *     "mm"              = @DI\Inject("claroline.manager.mask_manager"),
  *     "fileSystem"      = @DI\Inject("filesystem"),
  *     "kernel"          = @DI\Inject("kernel"),
  *     "toolManager"     = @DI\Inject("claroline.manager.tool_manager"),
  *     "toolMaskManager" = @DI\Inject("claroline.manager.tool_mask_decoder_manager")
  * })
  */
 public function __construct(ObjectManager $em, IconManager $im, Filesystem $fileSystem, KernelInterface $kernel, MaskManager $mm, ToolManager $toolManager, ToolMaskDecoderManager $toolMaskManager)
 {
     $this->em = $em;
     $this->im = $im;
     $this->mm = $mm;
     $this->fileSystem = $fileSystem;
     $this->kernelRootDir = $kernel->getRootDir();
     $this->modifyTemplate = $kernel->getEnvironment() !== 'test';
     $this->toolManager = $toolManager;
     $this->toolMaskManager = $toolMaskManager;
 }
Exemplo n.º 21
0
 /**
  * Get relative path
  *
  * @param string $bundle_name The name of the bundle
  * @param string $asset       The name of the file
  *
  * @return string
  * @throws RuntimeException
  */
 public function getBundleRelativeWebPath($bundle_name, $asset)
 {
     $elements_path = $this->configuration->getPaths()->getElements();
     $root_path = $this->kernel->getRootDir();
     $bundle_path = $this->kernel->getBundle($bundle_name)->getPath();
     $common_path = $this->findCommonPath([$root_path, $bundle_path]);
     if (!$common_path || strpos($bundle_path, $common_path) !== 0) {
         throw new RuntimeException('Could not determine path to the src/ directory.');
     }
     $bundle_path = ltrim(substr($bundle_path, strlen($common_path)), '/');
     return "/../{$bundle_path}/Resources/public/{$elements_path}/{$asset}";
 }
Exemplo n.º 22
0
 private function initializeCache()
 {
     // We have to warm up the extend entities cache in separate process
     // to allow this process continue executing.
     // The problem is we need initialized DI contained for warming up this cache,
     // but in this moment we are exactly doing this for the current process.
     $pb = ProcessBuilder::create()->setTimeout(self::CACHE_GENERATION_TIMEOUT)->add(CommandExecutor::getPhpExecutable())->add($this->kernel->getRootDir() . '/console')->add('oro:entity-extend:cache:warmup')->add('--env')->add($this->kernel->getEnvironment())->add('--cache-dir')->add($this->cacheDir);
     $attempts = 0;
     do {
         if (!CommandExecutor::isCommandRunning('oro:entity-extend:cache:warmup')) {
             // if cache was generated there is no need to generate it again
             if ($attempts > 0) {
                 return;
             }
             $pb->getProcess()->run();
             return;
         } else {
             $attempts++;
             sleep(self::CACHE_CHECKOUT_INTERVAL);
         }
     } while ($attempts < self::CACHE_CHECKOUT_ATTEMPTS);
 }
Exemplo n.º 23
0
 public function load($resource, $type = null)
 {
     $collection = new RouteCollection();
     $thirdPartyDir = $this->kernel->getRootDir() . '/../thirdparty';
     $fs = new Filesystem();
     if ($fs->exists($thirdPartyDir)) {
         $finder = new 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'])) {
                         $bundleClassParts = explode('\\', $bundleConfig['extra']['bundle-class']);
                         $bundleClassRef = end($bundleClassParts);
                         $resource = '@' . $bundleClassRef . '/Resources/config/routing.yml';
                         $type = 'yaml';
                         try {
                             $this->fileLocator->locate($resource);
                         } catch (\InvalidArgumentException $e) {
                             $resource = '@' . $bundleClassRef . '/Resources/config/routing.xml';
                             $type = 'xml';
                             try {
                                 $this->fileLocator->locate($resource);
                             } catch (\InvalidArgumentException $e) {
                                 continue;
                             }
                         }
                         $importedRoutes = $this->import($resource, $type);
                         $collection->addCollection($importedRoutes);
                     }
                 }
             }
         }
     }
     return $collection;
 }
Exemplo n.º 24
0
 /**
  * Установка рэндомного аватара
  * @return string
  */
 public function pickAvatar() : string
 {
     $finder = new Finder();
     $prefix = 'male';
     $avatarPath = $this->kernel->getRootDir() . '/../web/img/avatars/' . $prefix;
     $files = $finder->files()->in($avatarPath);
     $avatars = [];
     /** @var SplFileInfo $file */
     foreach ($files as $file) {
         $avatars[] = $file->getBasename('.jpg');
     }
     $avatar = $prefix . '/' . $avatars[array_rand($avatars)];
     return $avatar;
 }
 /**
  * Handle form entry of permission changes.
  *
  * @param Request $request
  *
  * @return bool
  */
 public function bindRequest(Request $request)
 {
     $changes = $request->request->get('permission-hidden-fields');
     if (empty($changes)) {
         return true;
     }
     // Just apply the changes to the current node (non recursively)
     $this->applyAclChangeset($this->resource, $changes, false);
     // Apply recursively (on request)
     $applyRecursive = $request->request->get('applyRecursive');
     if ($applyRecursive) {
         // Serialize changes & store them in DB
         $user = $this->tokenStorage->getToken()->getUser();
         $this->createAclChangeSet($this->resource, $changes, $user);
         $cmd = 'php ' . $this->kernel->getRootDir() . '/console kuma:acl:apply';
         $cmd .= ' --env=' . $this->kernel->getEnvironment();
         $this->shellHelper->runInBackground($cmd);
     }
     return true;
 }
Exemplo n.º 26
0
    /**
     * @param KernelInterface $parent
     * @param string          $namespace
     * @param string          $parentClass
     * @param string          $warmupDir
     *
     * @return KernelInterface
     */
    protected function getTempKernel(KernelInterface $parent, $namespace, $parentClass, $warmupDir)
    {
        $rootDir = $parent->getRootDir();
        // the temp kernel class name must have the same length than the real one
        // to avoid the many problems in serialized resources files
        $class = substr($parentClass, 0, -1) . '_';
        // the temp kernel name must be changed too
        $name = substr($parent->getName(), 0, -1) . '_';
        $code = <<<EOF
<?php

namespace {$namespace}
{
    class {$class} extends {$parentClass}
    {
        public function getCacheDir()
        {
            return '{$warmupDir}';
        }

        public function getName()
        {
            return '{$name}';
        }

        public function getRootDir()
        {
            return '{$rootDir}';
        }
    }
}
EOF;
        $this->getContainer()->get('filesystem')->mkdir($warmupDir);
        file_put_contents($file = $warmupDir . '/kernel.tmp', $code);
        require_once $file;
        @unlink($file);
        $class = "{$namespace}\\{$class}";
        return new $class($parent->getEnvironment(), $parent->isDebug());
    }
    /**
     * @param KernelInterface $parent
     * @param string          $namespace
     * @param string          $parentClass
     * @param string          $warmupDir
     *
     * @return KernelInterface
     */
    protected function getTempKernel(KernelInterface $parent, $namespace, $parentClass, $warmupDir)
    {
        $cacheDir = var_export($warmupDir, true);
        $rootDir = var_export(realpath($parent->getRootDir()), true);
        $logDir = var_export(realpath($parent->getLogDir()), true);
        // the temp kernel class name must have the same length than the real one
        // to avoid the many problems in serialized resources files
        $class = substr($parentClass, 0, -1) . '_';
        // the temp kernel name must be changed too
        $name = var_export(substr($parent->getName(), 0, -1) . '_', true);
        $code = <<<EOF
<?php

namespace {$namespace}
{
    class {$class} extends {$parentClass}
    {
        public function getCacheDir()
        {
            return {$cacheDir};
        }

        public function getName()
        {
            return {$name};
        }

        public function getRootDir()
        {
            return {$rootDir};
        }

        public function getLogDir()
        {
            return {$logDir};
        }

        protected function buildContainer()
        {
            \$container = parent::buildContainer();

            // filter container's resources, removing reference to temp kernel file
            \$resources = \$container->getResources();
            \$filteredResources = array();
            foreach (\$resources as \$resource) {
                if ((string) \$resource !== __FILE__) {
                    \$filteredResources[] = \$resource;
                }
            }

            \$container->setResources(\$filteredResources);

            return \$container;
        }
    }
}
EOF;
        $this->getContainer()->get('filesystem')->mkdir($warmupDir);
        file_put_contents($file = $warmupDir . '/kernel.tmp', $code);
        require_once $file;
        $class = "{$namespace}\\{$class}";
        return new $class($parent->getEnvironment(), $parent->isDebug());
    }
Exemplo n.º 28
0
    protected function getTempKernel(KernelInterface $parent, $namespace, $class, $warmupDir)
    {
        $suffix = $this->getTempKernelSuffix();
        $rootDir = $parent->getRootDir();
        $code = <<<EOF
<?php

namespace {$namespace}
{
    class {$class}{$suffix} extends {$class}
    {
        public function getCacheDir()
        {
            return '{$warmupDir}';
        }

        public function getRootDir()
        {
            return '{$rootDir}';
        }

        protected function getContainerClass()
        {
            return parent::getContainerClass().'{$suffix}';
        }
    }
}
EOF;
        $this->getContainer()->get('filesystem')->mkdir($warmupDir);
        file_put_contents($file = $warmupDir . '/kernel.tmp', $code);
        require_once $file;
        @unlink($file);
        $class = "{$namespace}\\{$class}{$suffix}";
        return new $class($parent->getEnvironment(), $parent->isDebug());
    }
Exemplo n.º 29
0
 /**
  * @return string
  */
 public function getUploadRootDir()
 {
     $basePath = sprintf('%s/../%s/%s', $this->kernel->getRootDir(), $this->options['uploader']['www_root'], $this->options['uploader']['media_path']);
     return $basePath;
 }
Exemplo n.º 30
0
 /**
  * @param KernelInterface $kernel
  */
 public function __construct(KernelInterface $kernel)
 {
     $this->bundleRir = realpath($kernel->getRootDir() . '/../vendor/jms/job-queue-bundle/JMS/JobQueueBundle/');
     $this->name = 'JMSJobQueueBundle';
 }