本文整理汇总了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;
}
}
示例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());
}
示例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;
}
示例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);
}