-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[4.2] Load the actionlog params from model instead of the helper #37592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
roland-d
merged 15 commits into
joomla:4.2-dev
from
Digital-Peak:j4/actionlog/config-model
May 15, 2022
Merged
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6274c64
Load the actionlog params from model instead of the helper
laoneo e9358ce
Typehints and null test
laoneo 9214ecb
Use common function with stability checks
laoneo 750b863
Update plugins/actionlog/joomla/joomla.php
laoneo a366cc2
Update plugins/actionlog/joomla/joomla.php
laoneo 8b8f89e
Merge remote-tracking branch 'upstream/4.2-dev' into j4/actionlog/con…
laoneo 753980f
use samce code as branch
laoneo cf5cdbe
Merge branch '4.2-dev' into j4/actionlog/config-model
laoneo 5429927
Merge branch '4.2-dev' into j4/actionlog/config-model
laoneo c489f52
Merge branch '4.2-dev' into j4/actionlog/config-model
laoneo dd06e21
Merge branch '4.2-dev' into j4/actionlog/config-model
laoneo b664089
Merge branch '4.2-dev' into j4/actionlog/config-model
laoneo c30d8d2
import
laoneo ae0c004
Merge branch 'j4/actionlog/config-model' of github.com:Digital-Peak/j…
laoneo deefceb
Merge branch '4.2-dev' into j4/actionlog/config-model
roland-d File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
46 changes: 46 additions & 0 deletions
46
administrator/components/com_actionlogs/src/Model/ActionlogConfigModel.php
This file contains hidden or 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,46 @@ | ||
| <?php | ||
| /** | ||
| * @package Joomla.Administrator | ||
| * @subpackage com_actionlogs | ||
| * | ||
| * @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org> | ||
| * @license GNU General Public License version 2 or later; see LICENSE.txt | ||
| */ | ||
|
|
||
| namespace Joomla\Component\Actionlogs\Administrator\Model; | ||
|
|
||
| \defined('_JEXEC') or die; | ||
|
|
||
| use Joomla\CMS\MVC\Model\BaseDatabaseModel; | ||
| use stdClass; | ||
|
|
||
| /** | ||
| * Model to interact with the action log configuration. | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| class ActionlogConfigModel extends BaseDatabaseModel | ||
| { | ||
| /** | ||
| * Returns the action logs config for the given context. | ||
| * | ||
| * @param string $context The context of the content | ||
| * | ||
| * @return stdClass|null An object contains content type parameters, or null if not found | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| public function getLogContentTypeParams(string $context): ?stdClass | ||
| { | ||
| $db = $this->getDatabase(); | ||
| $query = $db->getQuery(true) | ||
| ->select('a.*') | ||
| ->from($db->quoteName('#__action_log_config', 'a')) | ||
| ->where($db->quoteName('a.type_alias') . ' = :context') | ||
| ->bind(':context', $context); | ||
|
|
||
| $db->setQuery($query); | ||
|
|
||
| return $db->loadObject(); | ||
| } | ||
| } |
This file contains hidden or 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
62 changes: 62 additions & 0 deletions
62
tests/Unit/Components/Actionlogs/ActionlogConfigModelTest.php
This file contains hidden or 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,62 @@ | ||
| <?php | ||
| /** | ||
| * @package Joomla.UnitTest | ||
| * @subpackage Extension | ||
| * | ||
| * @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org> | ||
| * @license GNU General Public License version 2 or later; see LICENSE.txt | ||
| */ | ||
|
|
||
| namespace Joomla\Tests\Unit\Components\Actionlogs; | ||
|
|
||
| use Joomla\CMS\MVC\Factory\MVCFactoryInterface; | ||
| use Joomla\Component\Actionlogs\Administrator\Model\ActionlogConfigModel; | ||
| use Joomla\Database\DatabaseInterface; | ||
| use Joomla\Tests\Unit\UnitTestCase; | ||
| use stdClass; | ||
|
|
||
| /** | ||
| * Test class for ActionlogConfigModel | ||
| * | ||
| * @package Joomla.UnitTest | ||
| * @subpackage Actionlog | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| class ActionlogConfigModelTest extends UnitTestCase | ||
| { | ||
| /** | ||
| * @testdox Test that getLogContentTypeParams returns the correct params | ||
| * | ||
| * @return void | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| public function testGetLogContentTypeParams() | ||
| { | ||
| $config = new stdClass; | ||
| $db = $this->createStub(DatabaseInterface::class); | ||
| $db->method('getQuery')->willReturn($this->getQueryStub($db)); | ||
| $db->method('loadObject')->willReturn($config); | ||
|
|
||
| $model = new ActionlogConfigModel(['dbo' => $db], $this->createStub(MVCFactoryInterface::class)); | ||
|
|
||
| $this->assertEquals($config, $model->getLogContentTypeParams('test')); | ||
| } | ||
|
|
||
| /** | ||
| * @testdox Test that getLogContentTypeParams returns null when not found | ||
| * | ||
| * @return void | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| public function testGetNullLogContentTypeParams() | ||
| { | ||
| $db = $this->createStub(DatabaseInterface::class); | ||
| $db->method('getQuery')->willReturn($this->getQueryStub($db)); | ||
|
|
||
| $model = new ActionlogConfigModel(['dbo' => $db], $this->createStub(MVCFactoryInterface::class)); | ||
|
|
||
| $this->assertNull($model->getLogContentTypeParams('test')); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.