本文整理汇总了PHP中Aimeos\MShop\Locale\Manager\Factory类的典型用法代码示例。如果您正苦于以下问题:PHP Factory类的具体用法?PHP Factory怎么用?PHP Factory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Factory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* 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);
}
}
}
示例2: process
/**
* 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: createContext
/**
* @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;
}
示例4: process
/**
* 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: migrate
/**
* 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: process
/**
* 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');
}
示例7: migrate
/**
* 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: setUp
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: get
/**
* 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: testSetLocale
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: testSaveDeleteItem
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' => 'ich@du.de', '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: getSiteItems
/**
* 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: testCheckGroup
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: getCustomCache
/**
* @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: get
/**
* 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;
}