public function add(Request $request)
    {
        $fileName = $request->request->get('filename');
        $stack = $this->app['stack'];
        $twig = $this->app['twig'];

        /** @var FileInterface|null $removed */
        $file = $stack->add($fileName, $removed);
        $type = $file->getType();
        $type = !in_array($type, ['image', 'document']) ? 'other' : $type;
        $panel = $twig->resolveTemplate('@bolt/components/stack/panel-item.twig')->render(['file' => $file]);
        $list = $twig->resolveTemplate('@bolt/components/stack/list-item.twig')->render(['file' => $file]);

        return $this->json([
            'type'    => $type,
            'removed' => $removed ? $removed->getFullPath() : null,
            'panel'   => $panel,
            'list'    => $list,
        ]);
    }
public function add(Request $request)
    {
        $fileName = $request->request->get('filename');
        $stack = $this->app['stack'];
        $twig = $this->app['twig'];

        /** @var FileInterface|null $removed */
        $file = $stack->add($fileName, $removed);
        $type = $file->getType();
        $type = !in_array($type, ['image', 'document']) ? 'other' : $type;
        $panel = $twig->resolveTemplate('@bolt/components/stack/panel-item.twig')->render(['file' => $file]);
        $list = $twig->resolveTemplate('@bolt/components/stack/list-item.twig')->render(['file' => $file]);

        return $this->json([
            'type'    => $type,
            'removed' => $removed ? $removed->getFullPath() : null,
            'panel'   => $panel,
            'list'    => $list,
        ]);
    }
public function add ( Request $ request ) { $ fileName = $ request -> request -> get ( 'filename' ) ; $ stack = $ this -> app [ 'stack' ] ; $ twig = $ this -> app [ 'twig' ] ; /** @var FileInterface|null $removed */ $ file = $ stack -> add ( $ fileName , $ removed ) ; $ type = $ file -> getType ( ) ; $ type = ! in_array ( $ type , [ 'image' , 'document' ] ) ? 'other' : $ type ; $ panel = $ twig -> resolveTemplate ( '@bolt/components/stack/panel-item.twig' ) -> render ( [ 'file' => $ file ] ) ; $ list = $ twig -> resolveTemplate ( '@bolt/components/stack/list-item.twig' ) -> render ( [ 'file' => $ file ] ) ; return $ this -> json ( [ 'type' => $ type , 'removed' => $ removed ? $ removed -> getFullPath ( ) : null , 'panel' => $ panel , 'list' => $ list , ] ) ; }
Add a file to the user's stack.

@param Request $request

@return JsonResponse
Add a file to the user s stack .