src/Api/Controller/ParseSlugController.php
public function handle(ServerRequestInterface $request)
    {
        $actor = $request->getAttribute('actor');
        $result = false;
        $counter = 0;

        if ($actor !== null && $actor->isAdmin() && $request->getMethod() === 'POST') {
            $discussions = $this->discussions->query()->whereVisibleTo($actor)->get();
            foreach ($discussions as $discussion) {
                $slug = Transliterator::transliterate($discussion->title);
                if ($discussion->slug !== $slug) {
                    $data = [
                        'type' => 'discussions',
                        'id' => $discussion->id,
                        'attributes' => [
                            'title' => $discussion->title
                        ]
                    ];
                    $this->bus->dispatch(
                        new EditDiscussion($discussion->id, $actor, $data)
                    );
                    $counter++;
                }
            }
            $result = true;
        }

        $string = $this->translator->trans('avatar4eg-transliterator.admin.settings.result');
        return new JsonResponse([
            'success'   => $result,
            'message'   => "$string $counter"
        ]);
    }
public function handle(ServerRequestInterface $request)
    {
        $actor = $request->getAttribute('actor');
        $result = false;
        $counter = 0;

        if ($actor !== null && $actor->isAdmin() && $request->getMethod() === 'POST') {
            $discussions = $this->discussions->query()->whereVisibleTo($actor)->get();
            foreach ($discussions as $discussion) {
                $slug = Transliterator::transliterate($discussion->title);
                if ($discussion->slug !== $slug) {
                    $data = [
                        'type' => 'discussions',
                        'id' => $discussion->id,
                        'attributes' => [
                            'title' => $discussion->title
                        ]
                    ];
                    $this->bus->dispatch(
                        new EditDiscussion($discussion->id, $actor, $data)
                    );
                    $counter++;
                }
            }
            $result = true;
        }

        $string = $this->translator->trans('avatar4eg-transliterator.admin.settings.result');
        return new JsonResponse([
            'success'   => $result,
            'message'   => "$string $counter"
        ]);
    }
public function handle ( ServerRequestInterface $ request ) { $ actor = $ request -> getAttribute ( 'actor' ) ; $ result = false ; $ counter = 0 ; if ( $ actor !== null && $ actor -> isAdmin ( ) && $ request -> getMethod ( ) === 'POST' ) { $ discussions = $ this -> discussions -> query ( ) -> whereVisibleTo ( $ actor ) -> get ( ) ; foreach ( $ discussions as $ discussion ) { $ slug = Transliterator :: transliterate ( $ discussion -> title ) ; if ( $ discussion -> slug !== $ slug ) { $ data = [ 'type' => 'discussions' , 'id' => $ discussion -> id , 'attributes' => [ 'title' => $ discussion -> title ] ] ; $ this -> bus -> dispatch ( new EditDiscussion ( $ discussion -> id , $ actor , $ data ) ) ; $ counter ++ ; } } $ result = true ; } $ string = $ this -> translator -> trans ( 'avatar4eg-transliterator.admin.settings.result' ) ; return new JsonResponse ( [ 'success' => $ result , 'message' => "$string $counter" ] ) ; }
{@inheritdoc}
@throws \InvalidArgumentException
{