Пример #1
0
 /**
  * Adds locale test data.
  */
 protected function process()
 {
     $iface = '\\Aimeos\\MShop\\Context\\Item\\Iface';
     if (!$this->additional instanceof $iface) {
         throw new \Aimeos\MW\Setup\Exception(sprintf('Additionally provided object is not of type "%1$s"', $iface));
     }
     $this->msg('Adding test data for MShop locale domain', 0);
     $this->status('');
     // Set editor for further tasks
     $this->additional->setEditor('core:unittest');
     if ($this->additional->getConfig()->get('setup/site') === 'unittest') {
         $ds = DIRECTORY_SEPARATOR;
         $filename = __DIR__ . $ds . 'data' . $ds . 'locale.php';
         if (($testdata = (include $filename)) == false) {
             throw new \Aimeos\MW\Setup\Exception(sprintf('No data file "%1$s" found', $filename));
         }
         $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($this->additional);
         $this->cleanupSites($localeManager);
         $siteIds = array();
         if (isset($testdata['locale/site'])) {
             $siteIds = $this->addLocaleSiteData($localeManager, $testdata['locale/site']);
         }
         if (isset($testdata['locale/currency'])) {
             $this->addLocaleCurrencyData($localeManager, $testdata['locale/currency']);
         }
         if (isset($testdata['locale/language'])) {
             $this->addLocaleLanguageData($localeManager, $testdata['locale/language']);
         }
         if (isset($testdata['locale'])) {
             $this->addLocaleData($localeManager, $testdata['locale'], $siteIds);
         }
     }
 }
 /**
  * Creates new locale data if necessary
  */
 protected function process()
 {
     $iface = '\\Aimeos\\MShop\\Context\\Item\\Iface';
     if (!$this->additional instanceof $iface) {
         throw new \Aimeos\MW\Setup\Exception(sprintf('Additionally provided object is not of type "%1$s"', $iface));
     }
     $this->msg('Add locale data for languages and currencies', 0);
     $this->status('');
     $ds = DIRECTORY_SEPARATOR;
     $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($this->additional, 'Standard');
     $filename = __DIR__ . $ds . 'default' . $ds . 'data' . $ds . 'language.php';
     if (($data = (include $filename)) == false) {
         throw new \Aimeos\MW\Setup\Exception(sprintf('No data file "%1$s" found', $filename));
     }
     if (isset($data['locale/language'])) {
         $this->addLocaleLanguageData($localeManager, $data['locale/language']);
     }
     $filename = __DIR__ . $ds . 'default' . $ds . 'data' . $ds . 'currency.php';
     if (($data = (include $filename)) == false) {
         throw new \Aimeos\MW\Setup\Exception(sprintf('No data file "%1$s" found', $filename));
     }
     if (isset($data['locale/currency'])) {
         $this->addLocaleCurrencyData($localeManager, $data['locale/currency']);
     }
 }
Пример #3
0
 /**
  * @param string $site
  */
 private static function createContext($site)
 {
     $ctx = new \Aimeos\MShop\Context\Item\Standard();
     $aimeos = self::getAimeos();
     $paths = $aimeos->getConfigPaths('mysql');
     $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config';
     $file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser';
     $conf = new \Aimeos\MW\Config\PHPArray(array(), $paths);
     $conf = new \Aimeos\MW\Config\Decorator\Memory($conf);
     $conf = new \Aimeos\MW\Config\Decorator\Documentor($conf, $file);
     $ctx->setConfig($conf);
     $dbm = new \Aimeos\MW\DB\Manager\PDO($conf);
     $ctx->setDatabaseManager($dbm);
     $logger = new \Aimeos\MW\Logger\File($site . '.log', \Aimeos\MW\Logger\Base::DEBUG);
     $ctx->setLogger($logger);
     $cache = new \Aimeos\MW\Cache\None();
     $ctx->setCache($cache);
     $i18n = new \Aimeos\MW\Translation\None('de');
     $ctx->setI18n(array('de' => $i18n));
     $session = new \Aimeos\MW\Session\None();
     $ctx->setSession($session);
     $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx);
     $locale = $localeManager->bootstrap($site, '', '', false);
     $ctx->setLocale($locale);
     $ctx->setEditor('core:admin/jqadm');
     return $ctx;
 }
 /**
  * Creates new locale data if necessary
  */
 protected function process()
 {
     $iface = '\\Aimeos\\MShop\\Context\\Item\\Iface';
     if (!$this->additional instanceof $iface) {
         throw new \Aimeos\MW\Setup\Exception(sprintf('Additionally provided object is not of type "%1$s"', $iface));
     }
     $this->msg('Adding locale data if not yet present', 0);
     // Set editor for further tasks
     $this->additional->setEditor('core:setup');
     $code = $this->additional->getConfig()->get('setup/site', 'default');
     $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($this->additional, 'Standard');
     $siteManager = $localeManager->getSubManager('site');
     try {
         $siteItem = $siteManager->createItem();
         $siteItem->setLabel($code);
         $siteItem->setCode($code);
         $siteManager->insertItem($siteItem);
     } catch (\Aimeos\MW\DB\Exception $e) {
         $this->status('OK');
         return;
     }
     $localeItem = $localeManager->createItem();
     $localeItem->setSiteId($siteItem->getId());
     $localeItem->setLanguageId('en');
     $localeItem->setCurrencyId('EUR');
     $localeManager->saveItem($localeItem, false);
     $this->status('done');
 }
Пример #5
0
 /**
  * Insert records from file containing the SQL records.
  *
  */
 public function migrate()
 {
     $iface = '\\Aimeos\\MShop\\Context\\Item\\Iface';
     if (!$this->additional instanceof $iface) {
         throw new \Aimeos\MW\Setup\Exception(sprintf('Additionally provided object is not of type "%1$s"', $iface));
     }
     $this->msg('Adding performance data for MShop locale domain', 0);
     $this->status('');
     // Set editor for further tasks
     $this->additional->setEditor('unitperf:core');
     if ($this->additional->getConfig()->get('setup/site') === 'unitperf') {
         $ds = DIRECTORY_SEPARATOR;
         $filename = __DIR__ . $ds . 'data' . $ds . 'locale.php';
         if (($testdata = (include $filename)) == false) {
             throw new \Aimeos\MW\Setup\Exception(sprintf('No data file "%1$s" found', $filename));
         }
         $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($this->additional);
         $localeSiteManager = $localeManager->getSubManager('site');
         $siteIds = array();
         $search = $localeSiteManager->createSearch();
         $search->setConditions($search->compare('==', 'locale.site.code', 'unitperf'));
         foreach ($localeSiteManager->searchItems($search) as $site) {
             $this->additional->setLocale($localeManager->bootstrap($site->getCode(), '', '', false));
             $localeSiteManager->deleteItem($site->getId());
         }
         if (isset($testdata['locale/site'])) {
             $siteIds = $this->addLocaleSiteData($localeManager, $testdata['locale/site']);
         }
         if (isset($testdata['locale'])) {
             $this->addLocaleData($localeManager, $testdata['locale'], $siteIds);
         }
     }
 }
Пример #6
0
 /**
  * Adds order test data.
  */
 protected function process()
 {
     $iface = '\\Aimeos\\MShop\\Context\\Item\\Iface';
     if (!$this->additional instanceof $iface) {
         throw new \Aimeos\MW\Setup\Exception(sprintf('Additionally provided object is not of type "%1$s"', $iface));
     }
     $this->msg('Adding order test data', 0);
     $this->additional->setEditor('core:unittest');
     $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($this->additional, 'Standard');
     $orderManager = \Aimeos\MShop\Order\Manager\Factory::createManager($this->additional, 'Standard');
     $orderBaseManager = $orderManager->getSubManager('base');
     $search = $orderBaseManager->createSearch();
     $search->setConditions($search->compare('==', 'order.base.sitecode', array('unittest', 'unit')));
     foreach ($orderBaseManager->searchItems($search) as $order) {
         $orderBaseManager->deleteItem($order->getId());
     }
     $ds = DIRECTORY_SEPARATOR;
     $path = __DIR__ . $ds . 'data' . $ds . 'order.php';
     if (($testdata = (include $path)) == false) {
         throw new \Aimeos\MShop\Exception(sprintf('No file "%1$s" found for order domain', $path));
     }
     $bases = $this->addOrderBaseData($localeManager, $orderBaseManager, $testdata);
     $bases['items'] = $this->addOrderBaseProductData($orderBaseManager, $bases, $testdata);
     $bases['items'] = $this->addOrderBaseServiceData($orderBaseManager, $bases, $testdata);
     //update order bases (getPrice)
     foreach ($bases['items'] as $baseItem) {
         $orderBaseManager->saveItem($baseItem, false);
     }
     $this->addOrderData($orderManager, $bases['ids'], $testdata);
     $this->status('done');
 }
 /**
  * Adds locale data.
  */
 public function migrate()
 {
     $iface = '\\Aimeos\\MShop\\Context\\Item\\Iface';
     if (!$this->additional instanceof $iface) {
         throw new \Aimeos\MW\Setup\Exception(sprintf('Additionally provided object is not of type "%1$s"', $iface));
     }
     $this->msg('Adding data for MShop locale domain', 0);
     $this->status('');
     // Set editor for further tasks
     $this->additional->setEditor('core:setup');
     if ($this->additional->getConfig()->get('setup/site', 'default') === 'default') {
         $ds = DIRECTORY_SEPARATOR;
         $filename = __DIR__ . $ds . 'data' . $ds . 'locale.php';
         if (($data = (include $filename)) == false) {
             throw new \Aimeos\MW\Setup\Exception(sprintf('No data file "%1$s" found', $filename));
         }
         $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($this->additional, 'Standard');
         $siteIds = array();
         if (isset($data['locale/site'])) {
             $siteIds = $this->addLocaleSiteData($localeManager, $data['locale/site']);
         }
         if (isset($data['locale'])) {
             $this->addLocaleData($localeManager, $data['locale'], $siteIds);
         }
     }
 }
Пример #8
0
 protected function setUp()
 {
     $manager = \Aimeos\MShop\Locale\Manager\Factory::createManager(\TestHelperMShop::getContext());
     $this->siteItem = $manager->getSubManager('site')->createItem();
     $this->values = array('locale.id' => 1, 'locale.siteid' => 1, 'locale.languageid' => 'de', 'locale.currencyid' => 'EUR', 'locale.position' => 1, 'locale.status' => 1, 'locale.mtime' => '2011-01-01 00:00:02', 'locale.ctime' => '2011-01-01 00:00:01', 'locale.editor' => 'unitTestUser');
     $this->object = new \Aimeos\MShop\Locale\Item\Standard($this->values, $this->siteItem, array(1, 2), array(1, 3, 4));
 }
Пример #9
0
 /**
  * Returns the locale object for frontend
  *
  * @param \Aimeos\MShop\Context\Item\Iface $context Context object
  * @param \TYPO3\CMS\Extbase\Mvc\RequestInterface|null $request Request object
  * @return \Aimeos\MShop\Locale\Item\Iface Locale item object
  */
 public static function get(\Aimeos\MShop\Context\Item\Iface $context, \TYPO3\CMS\Extbase\Mvc\RequestInterface $request = null)
 {
     if (!isset(self::$locale)) {
         $config = $context->getConfig();
         $sitecode = $config->get('mshop/locale/site', 'default');
         $name = $config->get('typo3/param/name/site', 'loc_site');
         if ($request !== null && $request->hasArgument($name) === true) {
             $sitecode = $request->getArgument($name);
         } elseif (($value = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('S')) !== null) {
             $sitecode = $value;
         }
         $langid = $config->get('mshop/locale/language', '');
         $name = $config->get('typo3/param/name/language', 'loc_language');
         if ($request !== null && $request->hasArgument($name) === true) {
             $langid = $request->getArgument($name);
         } elseif (isset($GLOBALS['TSFE']->config['config']['language'])) {
             $langid = $GLOBALS['TSFE']->config['config']['language'];
         }
         $currency = $config->get('mshop/locale/currency', '');
         $name = $config->get('typo3/param/name/currency', 'loc_currency');
         if ($request !== null && $request->hasArgument($name) === true) {
             $currency = $request->getArgument($name);
         } elseif (($value = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('C')) !== null) {
             $currency = $value;
         }
         $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context);
         self::$locale = $localeManager->bootstrap($sitecode, $langid, $currency);
     }
     return self::$locale;
 }
Пример #10
0
 public function testSetLocale()
 {
     $locale = \Aimeos\MShop\Locale\Manager\Factory::createManager(\TestHelperMShop::getContext())->createItem();
     $return = $this->object->setLocale($locale);
     $this->assertInstanceOf('\\Aimeos\\MShop\\Order\\Item\\Base\\Iface', $return);
     $this->assertEquals($locale, $this->object->getLocale());
     $this->assertTrue($this->object->isModified());
 }
Пример #11
0
 public function testSaveDeleteItem()
 {
     $ctx = \TestHelper::getContext();
     $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx);
     $siteManager = $localeManager->getSubManager('site');
     $search = $siteManager->createSearch();
     $search->setConditions($search->compare('==', 'locale.site.code', 'unittest'));
     $sites = $siteManager->searchItems($search);
     if (($siteItem = reset($sites)) === false) {
         throw new \Aimeos\Controller\ExtJS\Exception(sprintf('Site item for code "%1$s" not found', $site));
     }
     $localeItem = $localeManager->createItem();
     $localeItem->setCurrencyId('EUR');
     $localeItem->setLanguageId('en');
     $localeItem->setSiteId($siteItem->getId());
     $manager = \Aimeos\MShop\Order\Manager\Factory::createManager($ctx);
     $baseManager = $manager->getSubManager('base');
     $baseItem = $baseManager->createItem();
     $baseItem->setCustomerId('unituser');
     $baseItem->setComment('FoooBar');
     $baseItem->setLocale($localeItem);
     $baseManager->saveItem($baseItem);
     $saveParams = (object) array('site' => 'unittest', 'items' => (object) array('order.base.address.id' => null, 'order.base.address.baseid' => $baseItem->getId(), 'order.base.address.addressid' => '-1', 'order.base.address.type' => 'payment', 'order.base.address.company' => 'MusterMax', 'order.base.address.vatid' => 'DE999999999', 'order.base.address.salutation' => \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR, 'order.base.address.title' => 'Herr', 'order.base.address.firstname' => 'Max', 'order.base.address.lastname' => 'Mustermann', 'order.base.address.address1' => 'Addresse 1', 'order.base.address.address2' => 'Addresse 2', 'order.base.address.address3' => 'Addresse 3', 'order.base.address.postal' => '22222', 'order.base.address.city' => 'Hamburg', 'order.base.address.state' => 'Hamburg', 'order.base.address.countryid' => 'en', 'order.base.address.languageid' => 'en', 'order.base.address.telephone' => '0815-4711', 'order.base.address.email' => '*****@*****.**', 'order.base.address.telefax' => '0815-4712', 'order.base.address.website' => 'www.example.com'));
     $searchParams = (object) array('site' => 'unittest', 'condition' => (object) array('&&' => array(0 => array('==' => (object) array('order.base.address.type' => 'payment')), 1 => array('==' => (object) array('order.base.address.baseid' => $baseItem->getId())))));
     $savedAddress = $this->object->saveItems($saveParams);
     $searched = $this->object->searchItems($searchParams);
     $deleteParamsAddr = (object) array('site' => 'unittest', 'items' => $savedAddress['items']->{'order.base.address.id'});
     $this->object->deleteItems($deleteParamsAddr);
     $baseManager->deleteItem($baseItem->getId());
     $this->assertInternalType('object', $savedAddress['items']);
     $this->assertNotNull($savedAddress['items']->{'order.base.address.id'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.id'}, $searched['items'][0]->{'order.base.address.id'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.baseid'}, $searched['items'][0]->{'order.base.address.baseid'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.addressid'}, $searched['items'][0]->{'order.base.address.addressid'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.type'}, $searched['items'][0]->{'order.base.address.type'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.company'}, $searched['items'][0]->{'order.base.address.company'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.vatid'}, $searched['items'][0]->{'order.base.address.vatid'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.salutation'}, $searched['items'][0]->{'order.base.address.salutation'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.title'}, $searched['items'][0]->{'order.base.address.title'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.firstname'}, $searched['items'][0]->{'order.base.address.firstname'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.lastname'}, $searched['items'][0]->{'order.base.address.lastname'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.address1'}, $searched['items'][0]->{'order.base.address.address1'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.address2'}, $searched['items'][0]->{'order.base.address.address2'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.address3'}, $searched['items'][0]->{'order.base.address.address3'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.postal'}, $searched['items'][0]->{'order.base.address.postal'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.city'}, $searched['items'][0]->{'order.base.address.city'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.state'}, $searched['items'][0]->{'order.base.address.state'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.countryid'}, $searched['items'][0]->{'order.base.address.countryid'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.languageid'}, $searched['items'][0]->{'order.base.address.languageid'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.telephone'}, $searched['items'][0]->{'order.base.address.telephone'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.email'}, $searched['items'][0]->{'order.base.address.email'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.telefax'}, $searched['items'][0]->{'order.base.address.telefax'});
     $this->assertEquals($savedAddress['items']->{'order.base.address.website'}, $searched['items'][0]->{'order.base.address.website'});
     $this->assertEquals(1, count($searched['items']));
     $searched = $this->object->searchItems($searchParams);
     $this->assertEquals(0, $searched['total']);
     $this->assertTrue($searched['success']);
 }
Пример #12
0
 /**
  * Returns the enabled site items which may be limited by the input arguments.
  *
  * @param \Aimeos\MShop\Context\Item\Iface $context Context item object
  * @param InputInterface $input Input object
  * @return \Aimeos\MShop\Locale\Item\Site\Interface[] List of site items
  */
 protected function getSiteItems(\Aimeos\MShop\Context\Item\Iface $context, InputInterface $input)
 {
     $manager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context)->getSubManager('site');
     $search = $manager->createSearch();
     if (($codes = (string) $input->getArgument('site')) !== '') {
         $search->setConditions($search->compare('==', 'locale.site.code', explode(' ', $codes)));
     }
     return $manager->searchItems($search);
 }
Пример #13
0
 public function testCheckGroup()
 {
     $context = $this->app->make('\\Aimeos\\Shop\\Base\\Context');
     $ctx = $context->get(false);
     $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx);
     $ctx->setLocale($localeManager->bootstrap('unittest', '', '', false));
     $ctxMock = $this->getMockBuilder('\\Aimeos\\Shop\\Base\\Context')->disableOriginalConstructor()->setMethods(array('get'))->getMock();
     $ctxMock->expects($this->once())->method('get')->will($this->returnValue($ctx));
     $object = new \Aimeos\Shop\Base\Support($ctxMock);
     $this->assertFalse($object->checkGroup(-1, 'admin'));
 }
Пример #14
0
 /**
  * @test
  */
 public function getCustomCache()
 {
     $request = $this->getMockBuilder('\\TYPO3\\Flow\\Mvc\\ActionRequest')->setMethods(array('getArguments'))->disableOriginalConstructor()->getMock();
     $request->expects($this->once())->method('getArguments')->will($this->returnValue(array()));
     $localeManager = $this->getMockBuilder('\\Aimeos\\MShop\\Locale\\Manager\\Standard')->setMethods(array('bootstrap'))->disableOriginalConstructor()->getMock();
     $localeManager->expects($this->once())->method('bootstrap')->will($this->returnValue(new \Aimeos\MShop\Locale\Item\Standard(array('locale.languageid' => 'de'))));
     \Aimeos\MShop\Locale\Manager\Factory::injectManager('\\Aimeos\\MShop\\Locale\\Manager\\Standard', $localeManager);
     $this->object->injectSettings(array('flow' => array('cache' => array('name' => 'Custom'))));
     $context = $this->object->get($request);
     $this->assertInstanceOf('\\Aimeos\\MShop\\Context\\Item\\Iface', $context);
 }
Пример #15
0
 /**
  * Returns the locale item for the current request
  *
  * @param \Aimeos\MShop\Context\Item\Iface $context Context object
  * @return \Aimeos\MShop\Locale\Item\Iface Locale item object
  */
 public function get(\Aimeos\MShop\Context\Item\Iface $context)
 {
     if ($this->locale === null) {
         $site = Route::input('site', Input::get('site', 'default'));
         $currency = Route::input('currency', Input::get('currency', ''));
         $lang = Route::input('locale', Input::get('locale', ''));
         $disableSites = $this->config->get('shop.disableSites', true);
         $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context);
         $this->locale = $localeManager->bootstrap($site, $lang, $currency, $disableSites);
     }
     return $this->locale;
 }
Пример #16
0
 /**
  * Returns the locale item for the current request
  *
  * @param \Aimeos\MShop\Context\Item\Iface $context Context object
  * @param array $attributes Associative list of URL parameter
  * @return \Aimeos\MShop\Locale\Item\Iface Locale item object
  */
 public function get(\Aimeos\MShop\Context\Item\Iface $context, array $attributes)
 {
     if ($this->locale === null) {
         $disableSites = $this->container->get('aimeos_config')->get('disableSites', true);
         $site = isset($attributes['site']) ? $attributes['site'] : 'default';
         $lang = isset($attributes['locale']) ? $attributes['locale'] : '';
         $currency = isset($attributes['currency']) ? $attributes['currency'] : '';
         $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context);
         $this->locale = $localeManager->bootstrap($site, $lang, $currency, $disableSites);
     }
     return $this->locale;
 }
Пример #17
0
 /**
  * Adds locale data.
  */
 protected function process()
 {
     $iface = '\\Aimeos\\MShop\\Context\\Item\\Iface';
     if (!$this->additional instanceof $iface) {
         throw new \Aimeos\MW\Setup\Exception(sprintf('Additionally provided object is not of type "%1$s"', $iface));
     }
     $site = $this->additional->getConfig()->get('setup/site', 'default');
     $this->msg(sprintf('Setting locale to "%1$s"', $site), 0);
     // Set locale for further tasks
     $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($this->additional, 'Standard');
     $this->additional->setLocale($localeManager->bootstrap($site, '', '', false));
     $this->status('OK');
 }
Пример #18
0
 /**
  * Adds the privilege to the given user
  *
  * @param \Aimeos\MShop\Context\Item\Iface $context Aimeos context object
  * @param \Aimeos\MShop\Customer\Item\Iface $user Aimeos customer object
  * @param string $privilege Unique customer group code
  */
 protected function addPrivilege(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $user, $privilege)
 {
     $this->info(sprintf('Add "%1$s" privilege to user "%2$s" for sites', $privilege, $user->getCode()));
     $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context);
     foreach ($this->getSiteItems($context, $this->argument('site')) as $siteItem) {
         $localeItem = $localeManager->bootstrap($siteItem->getCode(), '', '', false);
         $lcontext = clone $context;
         $lcontext->setLocale($localeItem);
         $this->info('- ' . $siteItem->getCode());
         $groupItem = $this->getGroupItem($lcontext, $privilege);
         $this->addListItem($lcontext, $user->getId(), $groupItem->getId());
     }
 }
Пример #19
0
 /**
  * Adds the group to the given user
  *
  * @param InputInterface $input Input object
  * @param OutputInterface $output Output object
  * @param \Aimeos\MShop\Context\Item\Iface $context Aimeos context object
  * @param \Aimeos\MShop\Customer\Item\Iface $user Aimeos customer object
  * @param string $group Unique customer group code
  */
 protected function addGroup(InputInterface $input, OutputInterface $output, \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $user, $group)
 {
     $output->writeln(sprintf('Add "%1$s" group to user "%2$s" for sites', $group, $user->getCode()));
     $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context);
     foreach ($this->getSiteItems($context, $input) as $siteItem) {
         $localeItem = $localeManager->bootstrap($siteItem->getCode(), '', '', false);
         $lcontext = clone $context;
         $lcontext->setLocale($localeItem);
         $output->writeln('- ' . $siteItem->getCode());
         $groupItem = $this->getGroupItem($lcontext, $group);
         $this->addListItem($lcontext, $user->getId(), $groupItem->getId());
     }
 }
Пример #20
0
 /**
  * Returns the locale item for the current request
  *
  * @param \Aimeos\MShop\Context\Item\Iface $context Context object
  * @param \TYPO3\Flow\Mvc\RequestInterface $request Request object
  * @return \Aimeos\MShop\Locale\Item\Iface Locale item object
  */
 public function get(\Aimeos\MShop\Context\Item\Iface $context, \TYPO3\Flow\Mvc\RequestInterface $request)
 {
     if ($this->locale === null) {
         $params = $request->getArguments();
         $site = isset($params['site']) ? $params['site'] : 'default';
         $lang = isset($params['locale']) ? $params['locale'] : '';
         $currency = isset($params['currency']) ? $params['currency'] : '';
         $disableSites = (bool) (isset($this->settings['flow']['disableSites']) ? $this->settings['flow']['disableSites'] : true);
         $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context);
         $this->locale = $localeManager->bootstrap($site, $lang, $currency, $disableSites);
     }
     return $this->locale;
 }
Пример #21
0
 /**
  * Returns the locale item for the current request
  *
  * @param \Aimeos\MShop\Context\Item\Iface $context Context object
  * @return \Aimeos\MShop\Locale\Item\Iface Locale item object
  */
 public function get(\Aimeos\MShop\Context\Item\Iface $context)
 {
     if ($this->locale === null) {
         $status = $this->container->getParameter('aimeos_shop.disable_sites');
         $request = $this->requestStack->getMasterRequest();
         $site = $request->attributes->get('site', $request->query->get('site', 'default'));
         $currency = $request->attributes->get('currency', $request->query->get('currency', ''));
         $lang = $request->attributes->get('locale', $request->query->get('locale', ''));
         $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context);
         $this->locale = $localeManager->bootstrap($site, $lang, $currency, $status);
     }
     return $this->locale;
 }
Пример #22
0
 /**
  * Returns a context object
  *
  * @return \Aimeos\MShop\Context\Item\Standard Context object
  */
 protected function getContext()
 {
     $container = $this->getContainer();
     $context = $container->get('aimeos_context')->get(false);
     $tmplPaths = $container->get('aimeos')->get()->getCustomPaths('controller/jobs/layouts');
     $view = $container->get('aimeos_view')->create($context->getConfig(), $tmplPaths);
     $langManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context)->getSubManager('language');
     $langids = array_keys($langManager->searchItems($langManager->createSearch(true)));
     $i18n = $this->getContainer()->get('aimeos_i18n')->get($langids);
     $context->setEditor('aimeos:jobs');
     $context->setView($view);
     $context->setI18n($i18n);
     return $context;
 }
Пример #23
0
 public function testIsAvailable()
 {
     $orderBaseManager = \Aimeos\MShop\Order\Manager\Factory::createManager(\TestHelperMShop::getContext())->getSubManager('base');
     $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager(\TestHelperMShop::getContext());
     $localeItem = $localeManager->createItem();
     $orderBaseDeItem = $orderBaseManager->createItem();
     $localeItem->setLanguageId('de');
     $orderBaseDeItem->setLocale($localeItem);
     $orderBaseEnItem = $orderBaseManager->createItem();
     $localeItem->setLanguageId('en');
     $orderBaseEnItem->setLocale($localeItem);
     $this->assertFalse($this->object->isAvailable($orderBaseDeItem));
     $this->assertTrue($this->object->isAvailable($orderBaseEnItem));
 }
Пример #24
0
 /**
  * Returns a context object
  *
  * @return \Aimeos\MShop\Context\Item\Standard Context object
  */
 protected function getContext()
 {
     $lv = $this->getLaravel();
     $aimeos = $lv->make('\\Aimeos\\Shop\\Base\\Aimeos')->get();
     $context = $lv->make('\\Aimeos\\Shop\\Base\\Context')->get(false, 'command');
     $tmplPaths = $aimeos->getCustomPaths('controller/jobs/templates');
     $view = $lv->make('\\Aimeos\\Shop\\Base\\View')->create($context, $tmplPaths);
     $langManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context)->getSubManager('language');
     $langids = array_keys($langManager->searchItems($langManager->createSearch(true)));
     $i18n = $lv->make('\\Aimeos\\Shop\\Base\\I18n')->get($langids);
     $context->setEditor('aimeos:jobs');
     $context->setView($view);
     $context->setI18n($i18n);
     return $context;
 }
Пример #25
0
 /**
  * Executes the job controllers.
  *
  * @param InputInterface $input Input object
  * @param OutputInterface $output Output object
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $context = $this->getContainer()->get('aimeos_context')->get(false);
     $context->setEditor('aimeos:cache');
     $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context);
     foreach ($this->getSiteItems($context, $input) as $siteItem) {
         $localeItem = $localeManager->bootstrap($siteItem->getCode(), '', '', false);
         $lcontext = clone $context;
         $lcontext->setLocale($localeItem);
         $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard($lcontext);
         $lcontext->setCache($cache);
         $output->writeln(sprintf('Clearing the Aimeos cache for site <info>%1$s</info>', $siteItem->getCode()));
         \Aimeos\MAdmin\Cache\Manager\Factory::createManager($lcontext)->getCache()->flush();
     }
 }
Пример #26
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $context = $this->getLaravel()->make('Aimeos\\Shop\\Base\\Context')->get(false, 'command');
     $context->setEditor('aimeos:cache');
     $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context);
     foreach ($this->getSiteItems($context, $this->argument('site')) as $siteItem) {
         $localeItem = $localeManager->bootstrap($siteItem->getCode(), '', '', false);
         $lcontext = clone $context;
         $lcontext->setLocale($localeItem);
         $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard($lcontext);
         $lcontext->setCache($cache);
         $this->info(sprintf('Clearing the Aimeos cache for site "%1$s"', $siteItem->getCode()));
         \Aimeos\MAdmin\Cache\Manager\Factory::createManager($lcontext)->getCache()->flush();
     }
 }
Пример #27
0
 /**
  * Creates a new context item.
  *
  * @param string $site Unique site code
  * @return \\Aimeos\MShop\Context\Item\Iface Context object
  */
 private static function createContext($site)
 {
     $ctx = new \Aimeos\MShop\Context\Item\Standard();
     $mshop = self::getAimeos();
     $paths = $mshop->getConfigPaths('mysql');
     $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config';
     $conf = new \Aimeos\MW\Config\PHPArray(array(), $paths);
     $ctx->setConfig($conf);
     $dbm = new \Aimeos\MW\DB\Manager\PDO($conf);
     $ctx->setDatabaseManager($dbm);
     $logger = new \Aimeos\MW\Logger\File($site . '.log', \Aimeos\MW\Logger\Base::DEBUG);
     $ctx->setLogger($logger);
     $session = new \Aimeos\MW\Session\None();
     $ctx->setSession($session);
     $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx);
     $localeItem = $localeManager->bootstrap($site, '', '', false);
     $ctx->setLocale($localeItem);
     $ctx->setEditor('zend:unittest');
     return $ctx;
 }
Пример #28
0
 /**
  * @param string $site
  */
 private static function createContext($site)
 {
     $ctx = new \Aimeos\MShop\Context\Item\Standard();
     $aimeos = self::getAimeos();
     $paths = $aimeos->getConfigPaths('mysql');
     $paths[] = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config';
     $conf = new \Aimeos\MW\Config\PHPArray(array(), $paths);
     $ctx->setConfig($conf);
     $dbm = new \Aimeos\MW\DB\Manager\PDO($conf);
     $ctx->setDatabaseManager($dbm);
     $logger = new \Aimeos\MW\Logger\File($site . '.log', \Aimeos\MW\Logger\Base::DEBUG);
     $ctx->setLogger($logger);
     $i18n = new \Aimeos\MW\Translation\None('de');
     $ctx->setI18n(array('de' => $i18n));
     $session = new \Aimeos\MW\Session\None();
     $ctx->setSession($session);
     $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx);
     $localeItem = $localeManager->bootstrap($site, '', '', false);
     $ctx->setLocale($localeItem);
     $ctx->setEditor('ai-monolog:lib/custom');
     return $ctx;
 }
Пример #29
0
 /**
  * Retrieves all items matching the given criteria.
  *
  * @param \stdClass $params Associative array containing the parameters
  * @return array List of associative arrays with item properties, total number of items and success property
  */
 public function searchItems(\stdClass $params)
 {
     $manager = $this->getManager();
     $total = 0;
     $search = $manager->createSearch();
     if (isset($params->options->showall) && $params->options->showall == false) {
         $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($this->getContext());
         $langids = array();
         foreach ($localeManager->searchItems($localeManager->createSearch()) as $item) {
             $langids[] = $item->getLanguageId();
         }
         if (!empty($langids)) {
             $search->setConditions($search->compare('==', 'locale.language.id', $langids));
         }
     }
     $search = $this->initCriteria($search, $params);
     $sort = $search->getSortations();
     $sort[] = $search->sort('+', 'locale.language.label');
     $search->setSortations($sort);
     $items = $this->getManager()->searchItems($search, array(), $total);
     return array('items' => $this->toArray($items), 'total' => $total, 'success' => true);
 }
Пример #30
-1
 /**
  * Returns the list of categories with their ID.
  *
  * @param array $config Associative array of existing configurations
  * @param \TYPO3\CMS\Backend\Form\FormEngine|\TYPO3\CMS\Backend\Form\DataPreprocessor $tceForms TCE forms object
  * @param string $sitecode Unique code of the site to retrieve the categories for
  * @return array Associative array with existing and new entries
  */
 public function getCategories(array $config, $tceForms = null, $sitecode = 'default')
 {
     if (isset($config['flexParentDatabaseRow']['pid'])) {
         // TYPO3 7+
         $pid = $config['flexParentDatabaseRow']['pid'];
     } elseif (isset($config['row']['pid'])) {
         // TYPO3 6.2
         $pid = $config['row']['pid'];
     }
     $pageTSConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getModTSconfig($pid, 'tx_aimeos');
     if (isset($pageTSConfig['properties']['mshop.']['locale.']['site'])) {
         $sitecode = $pageTSConfig['properties']['mshop.']['locale.']['site'];
     }
     try {
         $context = Base::getContext(Base::getConfig());
         $context->setEditor('flexform');
         $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context);
         $context->setLocale($localeManager->bootstrap($sitecode, '', '', false));
         $manager = \Aimeos\MShop\Catalog\Manager\Factory::createManager($context);
         $item = $manager->getTree(null, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE);
         $config['items'] = array_merge($config['items'], $this->getCategoryList($item, $item->getName()));
     } catch (\Exception $e) {
         error_log($e->getMessage() . PHP_EOL . $e->getTraceAsString());
     }
     return $config;
 }