Esempio n. 1
0
 /**
  * Test that all slashes are converted to forward slashes (works for linux and windows).
  */
 public function testDs()
 {
     // linux
     $this->assertEquals(DS . 'some' . DS . 'fake' . DS . 'folder' . DS . 'path' . DS . 'fileName.php', Path::ds('/some/fake/folder/path/fileName.php'));
     $this->assertEquals(DS . 'some' . DS . 'fake' . DS . 'folder' . DS . 'path' . DS . 'fileName.php', Path::ds('/some\\fake/folder\\path/fileName.php'));
     // windows
     $this->assertEquals('C:' . DS . 'some' . DS . 'fake' . DS . 'folder' . DS . 'path' . DS . 'fileName.php', Path::ds('C:\\some\\fake\\folder\\path\\fileName.php'));
     $this->assertEquals('C:' . DS . 'some' . DS . 'fake' . DS . 'folder' . DS . 'path' . DS . 'fileName.php', Path::ds('C:\\some/fake\\folder/path\\fileName.php'));
     // linux
     $this->assertEquals(DS . 'some' . DS . 'fake' . DS . 'folder' . DS . 'path' . DS . 'fileName' . DS, Path::ds('/some/fake/folder/path/fileName', true));
     $this->assertEquals(DS . 'some' . DS . 'fake' . DS . 'folder' . DS . 'path' . DS . 'fileName' . DS, Path::ds('/some\\fake/folder\\path/fileName/', true));
     // windows
     $this->assertEquals('C:' . DS . 'some' . DS . 'fake' . DS . 'folder' . DS . 'path' . DS . 'fileName' . DS, Path::ds('C:\\some\\fake\\folder\\path\\fileName/'));
     $this->assertEquals('C:' . DS . 'some' . DS . 'fake' . DS . 'folder' . DS . 'path' . DS . 'fileName' . DS, Path::ds('C:\\some/fake\\folder/path\\fileName\\'));
 }
Esempio n. 2
0
 /**
  * Store the module key and path.
  *
  * @param string $path
  */
 public function __construct($path)
 {
     $this->_path = Path::ds($path, true);
     parent::__construct();
 }
Esempio n. 3
0
 function ds($string)
 {
     return Path::ds($string);
 }
Esempio n. 4
0
 /**
  * Create symbolic links to the webroot folder within each module.
  * This allows for direct static asset handling.
  *
  * @param string $web
  * @throws \Titon\Mvc\Exception\AssetSymlinkException
  */
 public function createLinks($web)
 {
     $web = Path::ds($web, true);
     foreach ($this->getModules() as $key => $module) {
         $moduleWeb = $module->getPath() . 'web' . Path::SEPARATOR;
         if (!file_exists($moduleWeb)) {
             continue;
         }
         $targetLink = $web . $key . Path::SEPARATOR;
         // Create symlink if folder doesn't exist
         if (!file_exists($targetLink)) {
             symlink($moduleWeb, $targetLink);
             // Throw an error if file exists but is not a symlink
         } else {
             if (is_file($targetLink) && !is_link($targetLink)) {
                 throw new AssetSymlinkException(sprintf('Webroot folder %s must not exist so that static assets can be symlinked', $key));
             }
         }
     }
 }