/** * Returns the current context. * * @param boolean $locale True to add locale object to context, false if not * @return \Aimeos\MShop\Context\Item\Iface Context object */ public function get($locale = true) { if (self::$context === null) { $context = new \Aimeos\MShop\Context\Item\Standard(); $config = $this->getConfig(); $context->setConfig($config); $dbm = new \Aimeos\MW\DB\Manager\PDO($config); $context->setDatabaseManager($dbm); $fs = new \Aimeos\MW\Filesystem\Manager\Standard($config); $context->setFilesystemManager($fs); $container = $this->container; $mail = new \Aimeos\MW\Mail\Swift(function () use($container) { return $container->get('mailer'); }); $context->setMail($mail); $logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager($context); $context->setLogger($logger); $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard($context); $context->setCache($cache); self::$context = $context; } $context = self::$context; if ($locale === true) { $localeItem = $this->getLocale($context); $langid = $localeItem->getLanguageId(); $context->setLocale($localeItem); $context->setI18n($this->container->get('aimeos_i18n')->get(array($langid))); } $session = new \Aimeos\MW\Session\Symfony2($this->container->get('session')); $context->setSession($session); $this->addUser($context); return $context; }
/** * Returns the current context * * @param boolean $locale True to add locale object to context, false if not * @return \Aimeos\MShop\Context\Item\Iface Context object */ public function get($locale = true) { if (self::$context === null) { $context = new \Aimeos\MShop\Context\Item\Standard(); $config = $this->getConfig(); $context->setConfig($config); $dbm = new \Aimeos\MW\DB\Manager\PDO($config); $context->setDatabaseManager($dbm); $fs = new \Aimeos\MW\Filesystem\Manager\Laravel(app('filesystem'), $config, storage_path('aimeos')); $context->setFilesystemManager($fs); $mail = new \Aimeos\MW\Mail\Swift(function () { return app('mailer')->getSwiftMailer(); }); $context->setMail($mail); $logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager($context); $context->setLogger($logger); $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard($context); $context->setCache($cache); self::$context = $context; } $context = self::$context; if ($locale === true) { $localeItem = $this->getLocale($context); $langid = $localeItem->getLanguageId(); $context->setLocale($localeItem); $context->setI18n(app('\\Aimeos\\Shop\\Base\\I18n')->get(array($langid))); } $session = new \Aimeos\MW\Session\Laravel5($this->session); $context->setSession($session); $this->addUser($context); return $context; }
public function testRun() { $config = $this->context->getConfig(); $mock = $this->getMockBuilder('\\Aimeos\\MAdmin\\Log\\Manager\\Standard')->setMethods(array('deleteItems'))->setConstructorArgs(array($this->context))->getMock(); $mock->expects($this->atLeastOnce())->method('deleteItems'); $tmppath = dirname(dirname(dirname(dirname(__DIR__)))) . DIRECTORY_SEPARATOR . 'tmp'; $name = 'ControllerJobsAdminLogDefaultRun'; $config->set('madmin/log/manager/name', $name); $config->set('controller/jobs/admin/log/standard/limit-days', 0); $config->set('controller/jobs/admin/log/standard/path', $tmppath); \Aimeos\MAdmin\Log\Manager\Factory::injectManager('\\Aimeos\\MAdmin\\Log\\Manager\\' . $name, $mock); if (!is_dir($tmppath) && mkdir($tmppath) === false) { throw new \RuntimeException(sprintf('Unable to create temporary path "%1$s"', $tmppath)); } $this->object->run(); foreach (new \DirectoryIterator($tmppath) as $file) { if ($file->isFile() && $file->getExtension() === 'zip') { $container = \Aimeos\MW\Container\Factory::getContainer($file->getPathName(), 'Zip', 'CSV', array()); $container->get('unittest facility.csv'); unlink($file->getPathName()); return; } } $this->fail('Log archive file not found'); }
/** * Adds the log test data. * * @throws \Aimeos\MW\Setup\Exception If a required ID is not available */ private function addLogTestData() { $adminLogManager = \Aimeos\MAdmin\Log\Manager\Factory::createManager($this->additional, 'Standard'); $ds = DIRECTORY_SEPARATOR; $path = __DIR__ . $ds . 'data' . $ds . 'log.php'; if (($testdata = (include $path)) == false) { throw new \Aimeos\MShop\Exception(sprintf('No file "%1$s" found for log domain', $path)); } $log = $adminLogManager->createItem(); $this->conn->begin(); foreach ($testdata['log'] as $dataset) { $log->setId(null); $log->setFacility($dataset['facility']); $log->setPriority($dataset['priority']); $log->setMessage($dataset['message']); $log->setRequest($dataset['request']); $adminLogManager->saveItem($log, false); } $this->conn->commit(); }
/** * Adds the logger object to the context * * @param \Aimeos\MShop\Context\Item\Iface $context Context object * @return \Aimeos\MShop\Context\Item\Iface Modified context object */ protected function addLogger(\Aimeos\MShop\Context\Item\Iface $context) { $logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager($context); $context->setLogger($logger); return $context; }
/** * Returns the current context. * * @param \Aimeos\MW\Config\Iface Configuration object * @return MShop_Context_Item_Interface Context object */ public static function getContext(\Aimeos\MW\Config\Iface $config) { if (self::$context === null) { $context = new \Aimeos\MShop\Context\Item\Typo3(); $context->setConfig($config); $dbm = new \Aimeos\MW\DB\Manager\PDO($config); $context->setDatabaseManager($dbm); $fsm = new \Aimeos\MW\Filesystem\Manager\Standard($config); $context->setFilesystemManager($fsm); $logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager($context); $context->setLogger($logger); $cache = self::getCache($context); $context->setCache($cache); $mailer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage'); $context->setMail(new \Aimeos\MW\Mail\Typo3($mailer)); if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('saltedpasswords') && \TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility::isUsageEnabled('FE')) { $object = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance(); $context->setHasherTypo3($object); } if (isset($GLOBALS['TSFE']->fe_user)) { $session = new \Aimeos\MW\Session\Typo3($GLOBALS['TSFE']->fe_user); } else { $session = new \Aimeos\MW\Session\None(); } $context->setSession($session); self::$context = $context; } self::$context->setConfig($config); return self::$context; }
/** * Adds the logger object to the context * * @param \Aimeos\MShop\Context\Item\Iface $context Context object * @return \Aimeos\MShop\Context\Item\Iface Modified context object */ protected static function addLogger(\Aimeos\MShop\Context\Item\Iface $context) { if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_logger']) && is_callable($fcn = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_logger'])) { return $fcn($context); } return $context->setLogger(\Aimeos\MAdmin\Log\Manager\Factory::createManager($context)); }
public function testCreateManagerNotExisting() { $this->setExpectedException('\\Aimeos\\MShop\\Exception'); \Aimeos\MAdmin\Log\Manager\Factory::createManager(\TestHelper::getContext(), 'unknown'); }
/** * Initializes the log controller. * * @param \Aimeos\MShop\Context\Item\Iface $context MShop context object */ public function __construct(\Aimeos\MShop\Context\Item\Iface $context) { parent::__construct($context, 'Admin_Log'); $this->manager = \Aimeos\MAdmin\Log\Manager\Factory::createManager($context); }