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)
|
protected function matches($text, $array)
|
||||||
{
|
{
|
||||||
$transform = function($text)
|
$text = $this->transformText($text);
|
||||||
{
|
|
||||||
return str_replace('_', '', strtolower($text));
|
|
||||||
};
|
|
||||||
|
|
||||||
$text = $transform($text);
|
|
||||||
foreach ($array as $elem)
|
foreach ($array as $elem)
|
||||||
{
|
{
|
||||||
if ($transform($elem) == $text)
|
if ($this->transformText($elem) === $text)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function transformText($text)
|
||||||
|
{
|
||||||
|
return str_replace('_', '', strtolower($text));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,11 @@ class PostSnapshotProvider implements ISnapshotProvider
|
||||||
|
|
||||||
sort($data['tags']);
|
sort($data['tags']);
|
||||||
sort($data['relations']);
|
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;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,10 +194,15 @@ class TagService
|
||||||
foreach ($posts as $post)
|
foreach ($posts as $post)
|
||||||
{
|
{
|
||||||
$newTags = $post->getTags();
|
$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();
|
return $tag->getId() !== $sourceTag->getId();
|
||||||
});
|
});
|
||||||
$newTags []= $targetTag;
|
|
||||||
$post->setTags($newTags);
|
$post->setTags($newTags);
|
||||||
$this->postDao->save($post);
|
$this->postDao->save($post);
|
||||||
$this->postHistoryService->savePostChange($post);
|
$this->postHistoryService->savePostChange($post);
|
||||||
|
|
Loading…
Reference in a new issue