Bolt\Controller\Async\Stack::add PHP Метод

add() публичный Метод

Add a file to the user's stack.
public add ( Request $request ) : Symfony\Component\HttpFoundation\JsonResponse
$request Symfony\Component\HttpFoundation\Request
Результат Symfony\Component\HttpFoundation\JsonResponse
    public function add(Request $request)
    {
        $filename = $request->request->get('filename');
        $stack = $this->app['stack'];
        /** @var FileInterface|null $removed */
        $file = $stack->add($filename, $removed);
        $panel = $this->render('@bolt/components/stack/panel-item.twig', ['file' => $file]);
        $list = $this->render('@bolt/components/stack/list-item.twig', ['file' => $file]);
        $type = $file->getType();
        $type = !in_array($type, ['image', 'document']) ? 'other' : $type;
        return $this->json(['type' => $type, 'removed' => $removed ? $removed->getFullPath() : null, 'panel' => $panel->getContent(), 'list' => $list->getContent()]);
    }