Improved style
This commit is contained in:
parent
584d06a7f1
commit
2f12ec0a5e
4 changed files with 23 additions and 13 deletions
|
@ -167,17 +167,18 @@ abstract class AbstractSearchParser
|
|||
|
||||
protected function matches($text, $array)
|
||||
{
|
||||
$transform = function($text)
|
||||
{
|
||||
return str_replace('_', '', strtolower($text));
|
||||
};
|
||||
|
||||
$text = $transform($text);
|
||||
$text = $this->transformText($text);
|
||||
foreach ($array as $elem)
|
||||
{
|
||||
if ($transform($elem) == $text)
|
||||
if ($this->transformText($elem) === $text)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function transformText($text)
|
||||
{
|
||||
return str_replace('_', '', strtolower($text));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -106,7 +106,11 @@ class PostSnapshotProvider implements ISnapshotProvider
|
|||
|
||||
sort($data['tags']);
|
||||
sort($data['relations']);
|
||||
usort($data['notes'], function ($note1, $note2) { return $note1['x'] - $note2['x']; });
|
||||
usort($data['notes'],
|
||||
function ($note1, $note2)
|
||||
{
|
||||
return $note1['x'] - $note2['x'];
|
||||
});
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
|
|
@ -194,10 +194,15 @@ class TagService
|
|||
foreach ($posts as $post)
|
||||
{
|
||||
$newTags = $post->getTags();
|
||||
$newTags = array_filter($newTags, function(Tag $tag) use ($sourceTag) {
|
||||
$newTags[] = $targetTag;
|
||||
|
||||
$newTags = array_filter(
|
||||
$newTags,
|
||||
function(Tag $tag) use ($sourceTag)
|
||||
{
|
||||
return $tag->getId() !== $sourceTag->getId();
|
||||
});
|
||||
$newTags []= $targetTag;
|
||||
|
||||
$post->setTags($newTags);
|
||||
$this->postDao->save($post);
|
||||
$this->postHistoryService->savePostChange($post);
|
||||
|
|
Loading…
Reference in a new issue