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
added alias field, callback and tags_title inserttag #6
Conversation
@qzminski Is there something I can do about the coveralls issue? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to comments in the review please provide unit tests that will keep the code coverage at the same level and apply the code style (php-cs-fixer
is a dev requirement already).
composer.json
Outdated
@@ -1,5 +1,5 @@ | |||
{ | |||
"name": "codefog/tags-bundle", | |||
"name": "heimrichhannot/tags-bundle", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
* | ||
* @throws \Exception | ||
*/ | ||
public function generateAlias($value, DataContainer $dc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole method needs to be reworked to use strict types and comparisons, database service, etc.
* | ||
* @return array | ||
*/ | ||
public function addAliasButton($buttons, \DataContainer $dc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole method needs to be reworked to use strict types and comparisons, database service, etc.
switch ($insertTag) { | ||
case 'tags_title': | ||
return $tags->first()->name; | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This break statement is not needed here.
break; | ||
} | ||
|
||
return ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should throw an exception here and not return an empty string.
src/Manager/DefaultManager.php
Outdated
@@ -190,7 +190,7 @@ private function createTag(string $value): Tag | |||
* | |||
* @return array | |||
*/ | |||
private function getCriteria(array $criteria = []): array | |||
protected function getCriteria(array $criteria = []): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason you changed the properties and methods visibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We adjusted it so that inheriting services can use the attributes and methods themselves without needing to redefine them.
src/Model/TagModel.php
Outdated
throw new NoTagsException(); | ||
} | ||
|
||
$columns[] = 'alias IN ('.implode(',', array_map(function($alias) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use "alias IN ('" . implode("','", $criteria['aliases']) . "')"
.
'inputType' => 'text', | ||
'eval' => ['rgxp' => 'alias', 'unique' => true, 'maxlength' => 128, 'tl_class' => 'w50'], | ||
'save_callback' => [['codefog_tags.listener.data_container.tag', 'generateAlias']], | ||
'sql' => "varchar(128) COLLATE utf8_bin NOT NULL default ''", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please adjust the SQL format just like it is for the other fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, I can do that, but at the moment I have no idea how to define the collation:
I tried 'collation' => 'utf8_bin'
and 'collate' => 'utf8_bin'
. None of them worked out :-(
Still working on the tests. I'll write again after finishing the work. |
OK, I'm done with the tests. Some thoughts on them:
in /src/EventListener/InsertTagsListener.php on line 89: When debugging the test case in my local phpStorm, the debugger jumps at this line, so it indeed is covered. Might be an issue in coveralls?? line 109: How can I cover this line if it's logically never reached? An unsupported tag is filtered out beforehands. So the interpreter can't reach this line at all.
So is the request now ready for pulling? |
I guess I will have to tweak this PR a little bit and write the tests in a correct way but in general looks good. Because of the changes I have to make this will be merged in the upcoming weeks. Thanks @Defcon0 ! |
@qzminski Great to hear that :-) I'll review the tweaked tests to do it better next time ;-) |
Hey @Defcon0 some of the features have been already implemented on the |
Hi @qzminski ,
we just added an alias field to your tags_bundle and would very much appreciate it if you could merge the commit into the main project. The commit in detail contains:
We also added the translation for German for all existing strings.