[COMPONENT][Language][Tag] Update usage of Functional::cartesian_product

This commit is contained in:
Hugo Sales 2021-12-31 20:43:23 +00:00
parent 7aa90954eb
commit f346cd8167
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
2 changed files with 9 additions and 9 deletions

View File

@ -90,13 +90,13 @@ class Language extends Component
$note_expr = $temp_note_expr;
$actor_expr = $temp_actor_expr;
return Event::stop;
} elseif (Formatting::startsWith($term, GSF::cartesianProduct(['-', '_'], ['note', 'post'], ['lang', 'language'], [':']))) {
} elseif (Formatting::startsWith($term, GSF::cartesianProduct([['note', 'post'], ['lang', 'language'], [':']], separator: ['-', '_']))) {
$note_expr = $temp_note_expr;
return Event::stop;
} elseif (Formatting::startsWith($term, GSF::cartesianProduct(['-', '_'], ['note', 'post'], ['author', 'actor', 'people', 'person'], ['lang', 'language'], [':']))) {
} elseif (Formatting::startsWith($term, GSF::cartesianProduct([['note', 'post'], ['author', 'actor', 'people', 'person'], ['lang', 'language'], [':']], separator: ['-', '_']))) {
$note_expr = $temp_note_actor_expr;
return Event::stop;
} elseif (Formatting::startsWith($term, GSF::cartesianProduct(['-', '_'], ['actor', 'people', 'person'], ['lang', 'language'], [':']))) {
} elseif (Formatting::startsWith($term, GSF::cartesianProduct([['actor', 'people', 'person'], ['lang', 'language'], [':']], separator: ['-', '_']))) {
$actor_expr = $temp_actor_expr;
return Event::stop;
}

View File

@ -39,6 +39,7 @@ use App\Util\Exception\ClientException;
use App\Util\Formatting;
use App\Util\Functional as GSF;
use App\Util\HTML;
use App\Util\Nickname;
use Component\Language\Entity\Language;
use Component\Tag\Controller as C;
use Doctrine\Common\Collections\ExpressionBuilder;
@ -47,7 +48,6 @@ use Doctrine\ORM\QueryBuilder;
use Functional as F;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\HttpFoundation\Request;
use App\Util\Nickname;
/**
* Component responsible for extracting tags from posted notes, as well as normalizing them
@ -58,10 +58,10 @@ use App\Util\Nickname;
*/
class Tag extends Component
{
public const MAX_TAG_LENGTH = 64;
public const TAG_REGEX = '/(^|\\s)(#[\\pL\\pN_\\-]{1,64})/u'; // Brion Vibber 2011-02-23 v2:classes/Notice.php:367 function saveTags
public const TAG_CIRCLE_REGEX = '/' . Nickname::BEFORE_MENTIONS . '@#([\pL\pN_\-\.]{1,64})/';
public const TAG_SLUG_REGEX = '[A-Za-z0-9]{1,64}';
public const MAX_TAG_LENGTH = 64;
public const TAG_REGEX = '/(^|\\s)(#[\\pL\\pN_\\-]{1,64})/u'; // Brion Vibber 2011-02-23 v2:classes/Notice.php:367 function saveTags
public const TAG_CIRCLE_REGEX = '/' . Nickname::BEFORE_MENTIONS . '@#([\pL\pN_\-\.]{1,64})/';
public const TAG_SLUG_REGEX = '[A-Za-z0-9]{1,64}';
public function onAddRoute($r): bool
{
@ -177,7 +177,7 @@ class Tag extends Component
$note_expr = $temp_note_expr;
} elseif (Formatting::startsWith($term, ['people:', 'actor:'])) {
$actor_expr = $temp_actor_expr;
} elseif (Formatting::startsWith($term, GSF::cartesianProduct('-', ['people', 'actor'], ['circle:', 'list:']))) {
} elseif (Formatting::startsWith($term, GSF::cartesianProduct([['people', 'actor'], ['circle', 'list'], [':']], separator: ['-', '_']))) {
$null_tagger_expr = $eb->isNull('actor_circle.tagger');
$tagger_expr = \is_null($actor_expr) ? $null_tagger_expr : $eb->orX($null_tagger_expr, $eb->eq('actor_circle.tagger', $actor->getId()));
$tags = array_unique([$search_term, $canon_search_term]);