Browse Source

Fix use of removed property.

ADmad 7 years ago
parent
commit
50e421c19f

+ 1 - 1
src/View/Helper.php

@@ -175,7 +175,7 @@ class Helper implements EventListenerInterface
     public function __set($name, $value)
     {
         $removed = [
-            'template' => 'setTemplate',
+            'theme' => 'setTheme',
             'plugin' => 'setPlugin',
         ];
         if (isset($removed[$name])) {

+ 3 - 3
src/View/Helper/UrlHelper.php

@@ -273,9 +273,9 @@ class UrlHelper extends Helper
         $webPath = $this->request->getAttribute('webroot') . $asset[0];
         $file = $asset[0];
 
-        if (!empty($this->theme)) {
+        if (!empty($this->_View->getTheme())) {
             $file = trim($file, '/');
-            $theme = $this->_inflectThemeName($this->theme) . '/';
+            $theme = $this->_inflectThemeName($this->_View->getTheme()) . '/';
 
             if (DIRECTORY_SEPARATOR === '\\') {
                 $file = str_replace('/', '\\', $file);
@@ -284,7 +284,7 @@ class UrlHelper extends Helper
             if (file_exists(Configure::read('App.wwwRoot') . $theme . $file)) {
                 $webPath = $this->request->getAttribute('webroot') . $theme . $asset[0];
             } else {
-                $themePath = Plugin::path($this->theme);
+                $themePath = Plugin::path($this->_View->getTheme());
                 $path = $themePath . 'webroot/' . $file;
                 if (file_exists($path)) {
                     $webPath = $this->request->getAttribute('webroot') . $theme . $asset[0];

+ 5 - 5
tests/TestCase/View/Helper/HtmlHelperTest.php

@@ -519,7 +519,7 @@ class HtmlHelperTest extends TestCase
         Configure::write('debug', true);
 
         $this->Html->Url->request = $this->Html->request->withAttribute('webroot', '/');
-        $this->Html->Url->theme = 'TestTheme';
+        $this->Html->Url->getView()->setTheme('TestTheme');
         $result = $this->Html->image('__cake_test_image.gif');
         $expected = [
             'img' => [
@@ -549,14 +549,14 @@ class HtmlHelperTest extends TestCase
     {
         Configure::write('App.wwwRoot', TEST_APP . 'webroot/');
 
-        $this->Html->Url->theme = 'TestTheme';
+        $this->Html->Url->getView()->setTheme('TestTheme');
         $result = $this->Html->css('webroot_test');
         $expected = [
             'link' => ['rel' => 'stylesheet', 'href' => 'preg:/.*test_theme\/css\/webroot_test\.css/']
         ];
         $this->assertHtml($expected, $result);
 
-        $this->Html->theme = 'TestTheme';
+        $this->Html->getView()->setTheme('TestTheme');
         $result = $this->Html->css('theme_webroot');
         $expected = [
             'link' => ['rel' => 'stylesheet', 'href' => 'preg:/.*test_theme\/css\/theme_webroot\.css/']
@@ -1128,7 +1128,7 @@ class HtmlHelperTest extends TestCase
         $File = new File($testfile, true);
 
         $this->Html->Url->request = $this->Html->request->withAttribute('webroot', '/');
-        $this->Html->Url->theme = 'TestTheme';
+        $this->Html->Url->getView()->setTheme('TestTheme');
         $result = $this->Html->script('__test_js.js');
         $expected = [
             'script' => ['src' => '/test_theme/js/__test_js.js']
@@ -1816,7 +1816,7 @@ class HtmlHelperTest extends TestCase
      */
     public function testMetaIconWithTheme()
     {
-        $this->Html->Url->theme = 'TestTheme';
+        $this->Html->Url->getView()->setTheme('TestTheme');
 
         $result = $this->Html->meta('icon', 'favicon.ico');
         $expected = [

+ 1 - 1
tests/TestCase/View/Helper/UrlHelperTest.php

@@ -498,7 +498,7 @@ class UrlHelperTest extends TestCase
         $expected = '/img/cake.power.gif';
         $this->assertEquals($expected, $result);
 
-        $this->Helper->theme = 'TestTheme';
+        $this->Helper->getView()->setTheme('TestTheme');
 
         $result = $this->Helper->webroot('/img/cake.power.gif');
         $expected = '/test_theme/img/cake.power.gif';