Ejemplo n.º 1
0
 public function testLocateWithGlobalResourcePath()
 {
     $kernel = $this->getMock('Symfony\\Component\\HttpKernel\\KernelInterface');
     $kernel->expects($this->atLeastOnce())->method('locateResource')->with('@BundleName/some/path', '/global/resource/path', false);
     $locator = new FileLocator($kernel, '/global/resource/path');
     $locator->locate('@BundleName/some/path', null, false);
 }
Ejemplo n.º 2
0
 protected function setUp()
 {
     $this->fileLocator = $this->prophesize(FileLocator::class);
     $this->fileLocator->locate('@Resource/routes.yml')->willReturn(__DIR__ . '/../Resources/Yaml/routes.yml');
     $this->yamlParser = $yamlParser = $this->prophesize(Parser::CLASS);
     $this->loader = new YamlFileLoader($this->fileLocator->reveal());
 }
Ejemplo n.º 3
0
 /**
  * @param User $owner
  * @return PageAnimal
  * @throws HistoryException
  */
 public function create(User $owner)
 {
     $pageAnimalBranch = new PageAnimalBranch();
     $pageAnimalBranch->setOwner($owner);
     $noms = file($this->fileLocator->locate('@AppBundle/Resources/noms-animaux/noms.txt'));
     $nom = trim($noms[rand(0, count($noms) - 1)]);
     $pageAnimalBranch->setCommit(new PageAnimalCommit(null, $nom, $this->timeService->now(), null, PageAnimal::DISPONIBLE, PageAnimal::MALE, null));
     $this->doctrine->persist($pageAnimalBranch->getCommit());
     $this->doctrine->persist($pageAnimalBranch);
     $this->doctrine->flush([$pageAnimalBranch->getCommit(), $pageAnimalBranch]);
     return self::fromBranch($pageAnimalBranch);
 }
Ejemplo n.º 4
0
 public function __construct(FileLocator $fileLocator)
 {
     // in diesem configfile steht welche Usergruppe zugriff auf welche features hat.
     $configfile = $fileLocator->locate('@AppBundle/Resources/featureaccess.yml');
     $yaml = new Parser();
     $this->ACL = $yaml->parse(file_get_contents($configfile));
     // welche Features existieren in dem configfile?
     $this->supported_features = array();
     foreach ($this->ACL as $role => $features) {
         $this->supported_features = array_merge($this->supported_features, $features);
     }
     $this->supported_features = array_unique($this->supported_features);
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     $resourceLocator = new FileLocator($this->kernel);
     $definition = $container->getDefinition('grid.repository');
     $configs = [];
     foreach ($this->kernel->getBundles() as $bundle) {
         try {
             $file = $resourceLocator->locate(sprintf('@%s/Resources/config/grid.yml', $bundle->getName()));
         } catch (\InvalidArgumentException $e) {
             continue;
         }
         $container->addResource(new FileResource($file));
         $grid = Yaml::parse(file_get_contents($file));
         $config = $this->processConfiguration($grid);
         $this->setGridDefinition($definition, $config);
     }
     $container->setParameter('grid.definitions', $configs);
 }
Ejemplo n.º 6
0
 public function getRandomPartnerName()
 {
     if (!self::$partners) {
         $file = $this->type == ServicerService::TYPE_NEWS ? 'partners' : 'g_partners';
         $fileName = $this->fileLocator->locate("@AppBundle/Resources/texts/{$file}.txt");
         $file = fopen($fileName, 'r');
         while ($line = fgets($file)) {
             self::$partners[] = rtrim($line, "\n");
         }
     }
     return self::$partners[rand(0, count(self::$partners) - 1)];
 }
 /**
  * Parse editor themes from dir
  */
 protected function parseThemes()
 {
     foreach ($this->themesDirs as $dir) {
         $absDir = $this->fileLocator->locate($dir);
         $finder = Finder::create()->files()->in($absDir)->name('*.css');
         foreach ($finder as $file) {
             $this->addTheme($file->getBasename('.css'), $file->getPathname());
         }
     }
     #save to cache if env prod
     if ($this->env == 'prod') {
         $this->cacheDriver->save(static::CACHE_THEMES_NAME, $this->getThemes());
     }
 }
Ejemplo n.º 8
0
 /**
  * Gets a DecodaPhpEngine
  *
  * @return DecodaPhpEngine
  */
 private function getPhpEngine()
 {
     if (null === $this->phpEngine) {
         $this->phpEngine = new DecodaPhpEngine();
         foreach ($this->options['templates'] as $template) {
             // Use bundle hierachy
             $paths = $this->locator->locate($template['path'], null, false);
             krsort($paths);
             foreach ($paths as $path) {
                 $this->phpEngine->addPath($path);
             }
         }
     }
     return $this->phpEngine;
 }
 /**
  * Returns all directories for the given template resources
  *
  * @param array $templateDirectories List of directories containing handlebars templates
  *
  * @return array
  */
 private function getTemplateDirectories(array $templateDirectories)
 {
     return array_map(function ($templateDirectory) {
         return rtrim($this->fileLocator->locate($templateDirectory), '/');
     }, $templateDirectories);
 }
Ejemplo n.º 10
0
 /**
  * Constructor
  *
  * @param unknown     $cache
  * @param boolean     $debug       The debug environment
  * @param FileLocator $fileLocator
  */
 public function __construct($cache, $debug, FileLocator $fileLocator)
 {
     $this->cache = new $cache();
     $this->debug = $debug;
     $this->uniqId = md5($fileLocator->locate('@VictoireCoreBundle/Cache/ApcCache.php'));
 }
Ejemplo n.º 11
0
 /**
  * Load blacklist rules from xml file
  * @param FileLocator $fileLocator
  */
 private function loadBlackListRulesFromFile(FileLocator $fileLocator)
 {
     // Get path of default validation rules from file
     $defaultBlackListRulesPath = $fileLocator->locate('@HDIVSecurityBundle/Resources/config/defaultBlackListRules.xml');
     // Load default black list xml
     $xml = simplexml_load_file($defaultBlackListRulesPath);
     // Gets default EditableValidations from xml
     foreach ($xml->validation as $child) {
         $validationAttributes = $child->attributes();
         $validationRuleName = (string) $validationAttributes["name"];
         $rejectedPattern = $child->rejectedPattern->__toString();
         $newEditableValidation = new EditableValidation(trim($validationRuleName), NULL, $rejectedPattern);
         $this->defaultBlackListRules[trim($validationRuleName)] = $newEditableValidation;
     }
 }
 /**
  * Returns messages file path
  *
  * @return string
  */
 protected function getMessagesFilePath()
 {
     return $this->fileLocator->locate($this->loadingMessagesFile);
 }
Ejemplo n.º 13
0
 /**
  * {@inheritdoc}
  */
 public function getDefaultValue()
 {
     return $this->getData('image/png', file_get_contents($this->fileLocator->locate('@OroUIBundle/Resources/public/img/info-user.png')));
 }
 /**
  * Returns a random string from available messages list
  *
  * @return string
  */
 public function loadingMessage()
 {
     $path = $this->fileLocator->locate($this->file);
     $messages = file($path);
     return $messages[array_rand($messages)];
 }