Пример #1
0
 /**
  * Locate Resource Theme aware. Only working for app/Resources.
  *
  * @param string $name
  * @param string $dir
  * @param bool   $first
  *
  * @return string|array
  */
 protected function locateAppResource($name, $dir = null, $first = true)
 {
     if (false !== strpos($name, '..')) {
         throw new \RuntimeException(sprintf('File name "%s" contains invalid characters (..).', $name));
     }
     $files = array();
     $parameters = array('%app_path%' => $this->path, '%current_theme%' => $this->lastTheme, '%current_device%' => $this->activeTheme->getDeviceType(), '%template%' => substr($name, strlen('views/')));
     foreach ($this->getPathsForAppResource($parameters) as $checkPaths) {
         if (file_exists($checkPaths)) {
             if ($first) {
                 return $checkPaths;
             }
             $files[] = $checkPaths;
         }
     }
     return $files;
 }
Пример #2
0
 /**
  * @covers Liip\ThemeBundle\ActiveTheme::__construct
  * @covers Liip\ThemeBundle\ActiveTheme::getName
  */
 public function testDevicePhone()
 {
     $theme = new ActiveTheme('foo', array('foo'), new DeviceDetection('iphone'));
     $this->assertEquals('phone', $theme->getDeviceType());
 }