vendor/blackbit/data-director/EventListener/ContextListener.php line 19

Open in your IDE?
  1. <?php
  2. /*
  3.  * Copyright Blackbit digital Commerce GmbH <info@blackbit.de>
  4.  *
  5.  *  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
  6.  *  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  7.  *
  8.  *  You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  9.  */
  10. namespace Blackbit\DataDirectorBundle\EventListener;
  11. use Pimcore\Http\Request\Resolver\PimcoreContextResolver;
  12. use Pimcore\Http\RequestHelper;
  13. use Symfony\Component\HttpKernel\Event\RequestEvent;
  14. class ContextListener
  15. {
  16.     public function onKernelRequest(RequestEvent $event)
  17.     {
  18.         $request $event->getRequest();
  19.         if(strpos($request->getPathInfo(), '/api/rest') === 0) {
  20.             $request->attributes->set(PimcoreContextResolver::ATTRIBUTE_PIMCORE_CONTEXT'webservice');
  21.             $request->attributes->set(RequestHelper::ATTRIBUTE_FRONTEND_REQUESTfalse);
  22.         }
  23.     }
  24. }