Zugriff auf Shopware()->Session() bevor postDistpatch

Wie wäre es mir möglich auf Shopware()->Session(), insbesondere auf Shopware()->Session()->sOutputNet bevor postDispatch, während Dispatch, zuzugreifen? Momentan erhalte ich beim Zugriff nur einen Fehler, daß die Dependency Injection “shop” nicht finden kann. Jemand evtl. ne Idee? code Fatal error: Uncaught exception ‘Exception’ with message ‘Resource “shop” not found failure’ in C:\dev\tools\xampp\htdocs\shopware\engine\Shopware\Components\DependencyInjection\Container.php on line 192 ( ! ) Exception: Resource “shop” not found failure in C:\dev\tools\xampp\htdocs\shopware\engine\Shopware\Components\DependencyInjection\Container.php on line 192 Call Stack # Time Memory Function Location 1 0.2000 150896 {main}( ) …\shopware.php:0 2 0.2200 1845904 Shopware\Components\HttpCache\AppCache->handle( ) …\shopware.php:109 3 0.2200 1851824 Symfony\Component\HttpKernel\HttpCache\HttpCache->handle( ) …\AppCache.php:113 4 0.2200 1867136 Shopware\Components\HttpCache\AppCache->lookup( ) …\HttpCache.php:193 5 0.2200 1867296 Symfony\Component\HttpKernel\HttpCache\HttpCache->lookup( ) …\AppCache.php:178 6 0.2200 1868240 Symfony\Component\HttpKernel\HttpCache\HttpCache->fetch( ) …\HttpCache.php:329 7 0.2200 1873552 Shopware\Components\HttpCache\AppCache->forward( ) …\HttpCache.php:429 8 0.2500 2703128 Symfony\Component\HttpKernel\HttpCache\HttpCache->forward( ) …\AppCache.php:256 9 0.2500 2703992 Shopware\Kernel->handle( ) …\HttpCache.php:472 10 0.3400 5212640 Enlight_Controller_Front->dispatch( ) …\Kernel.php:141[/code]

Der Fehler dürfte relativ wenig mit dem Zugriff auf die Session zu tun haben. Bitte poste mal deinen quellcode. Viele Grüße

Ich versuche es in einer API Resource @Aquatuning Edit: Problem ist Zeile 49 [code]<?php namespace Shopware\Components\Api\Resource;

use Shopware\Components\Api\Exception as ApiException;

class MobileShop extends Resource {
public function getRepository()
{
#return $this->getManager()->getRepository(’\Shopware\CustomModels\MyPlugin\Shop’); return $this->getManager()->getRepository(’\Shopware\Models\Shop\Shop’); } public function getList($mainLang = null) { $this->checkPrivilege(‚read‘); $return = array(); $builder = $this->getRepository()->createQueryBuilder(‚ms‘); $builder->select(array( ‚ms.id‘, ‚ms.categoryId‘, ‚ms.name‘, ‚ms.title‘, ‚ms.position‘, ‚ms.host‘, ‚ms.baseUrl‘, ‚ms.default‘, ‚locale.locale‘, ‚locale.id as locale_id‘, ‚currency.currency‘, )) ->where(‚ms.active=1‘) ->innerJoin(‚ms.locale‘, ‚locale‘) ->innerJoin(‚ms.currency‘, ‚currency‘) ; $query = $builder->getQuery(); $query->setHydrationMode($this->resultMode); $shopPaginator = $this->getManager()->createPaginator($query); $shops = $shopPaginator->getIterator()->getArrayCopy(); $ci = Shopware()->Models() ->getRepository(’\Shopware\CustomModels\MyPlugin\CorporateIdentity’) ->createQueryBuilder(‚ci‘) ->getQuery() ->getSingleResult($this->resultMode); //$shop = Shopware()->Shop(); //var_dump($shop); $session = Shopware()->Session(); //var_dump($this->sSYSTEM); foreach ($shops as &$shop) { $builder = Shopware()->Models()->getRepository(’\Shopware\Models\Snippet\Snippet’)->createQueryBuilder(‚s‘); $builder->select(array( ‚s.id‘, ‚s.name‘, ‚s.value‘ ) ) //->where(‚s.shopId = :shopId‘) ->andWhere(‚s.localeId = :localeId‘) ->andWhere(„s.namespace like ‚frontend/index/%footer%‘“) //->setParameter(‚shopId‘, $shop[‚id‘]) ->setParameter(‚localeId‘, $shop[‚locale_id‘]) ; $shop[‚footer‘] = $builder->getQuery()->getResult($this->resultMode); } $builder = Shopware()->Models()->getRepository(’\Shopware\Models\Site\Site’)->createQueryBuilder(‚s‘); $builder->select(array( ‚s.id‘, ‚s.parentId‘, ‚s.description‘, ‚s.pageTitle‘, ‚s.metaKeywords‘, ‚s.metaDescription‘, ‚s.html‘, ‚s.grouping‘, ‚s.position‘, ‚s.link‘, )) ->where(‚s.grouping != :disabledGrouping‘) ->addOrderBy(‚s.parentId‘, ‚ASC‘) ->addOrderBy(‚s.position‘, ‚ASC‘) ->setParameter(‚disabledGrouping‘, „gDisabled“) ; $siteObjects = $builder->getQuery()->getResult($this->resultMode); $siteGroups = array(); #http://stackoverflow.com/questions/4196157/create-array-tree-from-array-list $new = array(); foreach ( $siteObjects as $s ) { if ($s[‚parentId‘] === NULL) { $s[‚parentId‘] = 0; } $new[$s[‚parentId‘]] = $s; foreach (explode(’|’, $s[‚grouping‘]) as $grouping) { if (empty($siteGroups[$grouping])) { $siteGroups[$grouping] = array(); } $siteGroups[$grouping] = $s[‚id‘]; } } if(isset($siteGroups[‚gDisabled‘])) { unset($siteGroups[‚gDisabled‘]); } $sites = $this->createTree($new, $new[0]); $return[‚shops‘] = $shops; $return[‚ci‘] = $ci; $return[‚siteGroups‘] = $siteGroups; $return[‚sites‘] = $sites; return array(‚data‘ => $return); } private function createTree(&$list, $parent) { $tree = array(); foreach ($parent as $k=>$l){ if(isset($list[$l[‚id‘]])){ $l[‚children‘] = $this->createTree($list, $list[$l[‚id‘]]); } $tree = $l; } return $tree; } } ?>[/code]