当前位置: 首页>>代码示例>>PHP>>正文


PHP App::themePath方法代码示例

本文整理汇总了PHP中Cake\Core\App::themePath方法的典型用法代码示例。如果您正苦于以下问题:PHP App::themePath方法的具体用法?PHP App::themePath怎么用?PHP App::themePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\Core\App的用法示例。


在下文中一共展示了App::themePath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _getAssetFile

 /**
  * Builds asset file path based off url
  *
  * @param string $url
  * @return string Absolute path for asset file
  */
 protected function _getAssetFile($url)
 {
     $parts = explode('/', $url);
     if ($parts[0] === 'theme') {
         $themeName = $parts[1];
         unset($parts[0], $parts[1]);
         $fileFragment = implode(DS, $parts);
         $path = App::themePath($themeName) . 'webroot' . DS;
         return $path . $fileFragment;
     }
     $plugin = Inflector::camelize($parts[0]);
     if ($plugin && Plugin::loaded($plugin)) {
         unset($parts[0]);
         $fileFragment = implode(DS, $parts);
         $pluginWebroot = Plugin::path($plugin) . 'webroot' . DS;
         return $pluginWebroot . $fileFragment;
     }
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:24,代码来源:AssetDispatcher.php

示例2: testNotModified

 /**
  * Tests that $response->checkNotModified() is called and bypasses
  * file dispatching
  *
  * @return void
  */
 public function testNotModified()
 {
     $filter = new AssetDispatcher();
     $time = filemtime(App::themePath('TestTheme') . 'webroot/img/cake.power.gif');
     $time = new \DateTime('@' . $time);
     $response = $this->getMock('Cake\\Network\\Response', array('send', 'checkNotModified'));
     $request = new Request('theme/test_theme/img/cake.power.gif');
     $response->expects($this->once())->method('checkNotModified')->with($request)->will($this->returnValue(true));
     $event = new Event('DispatcherTest', $this, compact('request', 'response'));
     ob_start();
     $this->assertSame($response, $filter->beforeDispatch($event));
     ob_end_clean();
     $this->assertEquals(200, $response->statusCode());
     $this->assertEquals($time->format('D, j M Y H:i:s') . ' GMT', $response->modified());
     $response = $this->getMock('Cake\\Network\\Response', array('_sendHeader', 'checkNotModified'));
     $request = new Request('theme/test_theme/img/cake.power.gif');
     $response->expects($this->once())->method('checkNotModified')->with($request)->will($this->returnValue(true));
     $response->expects($this->never())->method('send');
     $event = new Event('DispatcherTest', $this, compact('request', 'response'));
     $this->assertSame($response, $filter->beforeDispatch($event));
     $this->assertEquals($time->format('D, j M Y H:i:s') . ' GMT', $response->modified());
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:28,代码来源:AssetDispatcherTest.php

示例3: assetTimestamp

 /**
  * Adds a timestamp to a file based resource based on the value of `Asset.timestamp` in
  * Configure. If Asset.timestamp is true and debug is true, or Asset.timestamp === 'force'
  * a timestamp will be added.
  *
  * @param string $path The file path to timestamp, the path must be inside WWW_ROOT
  * @return string Path with a timestamp added, or not.
  */
 public function assetTimestamp($path)
 {
     $stamp = Configure::read('Asset.timestamp');
     $timestampEnabled = $stamp === 'force' || $stamp === true && Configure::read('debug');
     if ($timestampEnabled && strpos($path, '?') === false) {
         $filepath = preg_replace('/^' . preg_quote($this->request->webroot, '/') . '/', '', urldecode($path));
         $webrootPath = WWW_ROOT . str_replace('/', DS, $filepath);
         if (file_exists($webrootPath)) {
             //@codingStandardsIgnoreStart
             return $path . '?' . @filemtime($webrootPath);
             //@codingStandardsIgnoreEnd
         }
         $segments = explode('/', ltrim($filepath, '/'));
         if ($segments[0] === 'theme') {
             $theme = $segments[1];
             unset($segments[0], $segments[1]);
             $themePath = App::themePath($theme) . 'webroot' . DS . implode(DS, $segments);
             //@codingStandardsIgnoreStart
             return $path . '?' . @filemtime($themePath);
             //@codingStandardsIgnoreEnd
         } else {
             $plugin = Inflector::camelize($segments[0]);
             if (Plugin::loaded($plugin)) {
                 unset($segments[0]);
                 $pluginPath = Plugin::path($plugin) . 'webroot' . DS . implode(DS, $segments);
                 //@codingStandardsIgnoreStart
                 return $path . '?' . @filemtime($pluginPath);
                 //@codingStandardsIgnoreEnd
             }
         }
     }
     return $path;
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:41,代码来源:Helper.php

示例4: testThemePath

 /**
  * test that themePath can find paths for themes.
  *
  * @return void
  */
 public function testThemePath()
 {
     $path = App::themePath('test_theme');
     $expected = TEST_APP . 'TestApp' . DS . 'Template' . DS . 'Themed' . DS . 'TestTheme' . DS;
     $this->assertPathEquals($expected, $path);
     $path = App::themePath('TestTheme');
     $expected = TEST_APP . 'TestApp' . DS . 'Template' . DS . 'Themed' . DS . 'TestTheme' . DS;
     $this->assertPathEquals($expected, $path);
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:14,代码来源:AppTest.php


注:本文中的Cake\Core\App::themePath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。