-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
581b43a
commit b9dae41
Showing
7 changed files
with
202 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* baserCMS : Based Website Development Project <https://basercms.net> | ||
* Copyright (c) NPO baser foundation <https://baserfoundation.org/> | ||
* | ||
* @copyright Copyright (c) NPO baser foundation | ||
* @link https://basercms.net baserCMS Project | ||
* @since 5.0.0 | ||
* @license https://basercms.net/license/index.html MIT License | ||
*/ | ||
|
||
namespace BcThemeFile\Service; | ||
|
||
use BaserCore\Annotation\NoTodo; | ||
use BaserCore\Annotation\Checked; | ||
use BaserCore\Annotation\UnitTest; | ||
use Cake\Core\Plugin; | ||
|
||
/** | ||
* BcThemeFileService | ||
* | ||
*/ | ||
class BcThemeFileService implements BcThemeFileServiceInterface | ||
{ | ||
/** | ||
* fullpathを作成 | ||
* @param string $theme | ||
* @param string $type | ||
* @param string $path | ||
* @return string | ||
* | ||
* @checked | ||
* @noTodo | ||
*/ | ||
public function getFullpath(string $theme, string $type, string $path) | ||
{ | ||
$assets = [ | ||
'css', | ||
'js', | ||
'img' | ||
]; | ||
if (in_array($type, $assets)) { | ||
$viewPath = Plugin::path($theme) . 'webroot' . DS . $type . DS . $path; | ||
} else { | ||
$viewPath = Plugin::templatePath($theme) . $type . DS . $path; | ||
} | ||
return $viewPath; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
plugins/bc-theme-file/src/Service/BcThemeFileServiceInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
/** | ||
* baserCMS : Based Website Development Project <https://basercms.net> | ||
* Copyright (c) NPO baser foundation <https://baserfoundation.org/> | ||
* | ||
* @copyright Copyright (c) NPO baser foundation | ||
* @link https://basercms.net baserCMS Project | ||
* @since 5.0.0 | ||
* @license https://basercms.net/license/index.html MIT License | ||
*/ | ||
|
||
namespace BcThemeFile\Service; | ||
|
||
use BaserCore\Annotation\NoTodo; | ||
use BaserCore\Annotation\Checked; | ||
use BaserCore\Annotation\UnitTest; | ||
|
||
/** | ||
* BcThemeFileServiceInterface | ||
*/ | ||
interface BcThemeFileServiceInterface | ||
{ | ||
/** | ||
* fullpathを作成 | ||
* @param string $theme | ||
* @param string $type | ||
* @param string $path | ||
* @return string | ||
* | ||
* @checked | ||
* @noTodo | ||
* @unitTest | ||
*/ | ||
public function getFullpath(string $theme, string $type, string $path); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
plugins/bc-theme-file/tests/TestCase/Service/BcThemeFileServiceTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* baserCMS : Based Website Development Project <https://basercms.net> | ||
* Copyright (c) NPO baser foundation <https://baserfoundation.org/> | ||
* | ||
* @copyright Copyright (c) NPO baser foundation | ||
* @link https://basercms.net baserCMS Project | ||
* @since 5.0.0 | ||
* @license https://basercms.net/license/index.html MIT License | ||
*/ | ||
|
||
namespace BcThemeFile\Test\TestCase\Service; | ||
|
||
use BaserCore\TestSuite\BcTestCase; | ||
use BcThemeFile\Service\BcThemeFileService; | ||
|
||
/** | ||
* BcThemeFileServiceTest | ||
*/ | ||
class BcThemeFileServiceTest extends BcTestCase | ||
{ | ||
|
||
public $BcThemeFileService = null; | ||
|
||
/** | ||
* set up | ||
*/ | ||
public function setUp(): void | ||
{ | ||
$this->setFixtureTruncate(); | ||
parent::setUp(); | ||
$this->BcThemeFileService = new BcThemeFileService(); | ||
} | ||
|
||
/** | ||
* tear down | ||
*/ | ||
public function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
} | ||
|
||
/** | ||
* test getFullpath | ||
*/ | ||
public function test_getFullpath() | ||
{ | ||
//typeが$assetsではない場合、 | ||
$themePath = $this->BcThemeFileService->getFullpath('BcThemeSample', 'layout', 'default.php'); | ||
$this->assertEquals('/var/www/html/plugins/BcThemeSample/templates/layout/default.php', $themePath); | ||
|
||
//typeがimgの場合、 | ||
$themePath = $this->BcThemeFileService->getFullpath('BcFront', 'img', 'logo.png'); | ||
$this->assertEquals('/var/www/html/plugins/bc-front/webroot/img/logo.png', $themePath); | ||
} | ||
} |