/** * Initialize a module-specific logger. * * @return Tlog a Tlog instance */ protected function getLog() { if ($this->log == null) { $this->log = Tlog::getNewInstance(); $logFilePath = sprintf(THELIA_ROOT . "log" . DS . "%s.log", strtolower($this->getModuleCode())); $this->log->setPrefix("#LEVEL: #DATE #HOUR: "); $this->log->setDestinations("\\Thelia\\Log\\Destination\\TlogDestinationFile"); $this->log->setConfig("\\Thelia\\Log\\Destination\\TlogDestinationFile", 0, $logFilePath); } return $this->log; }
/** * Returns the module-specific logger, initializing it if required. * * @return Tlog a Tlog instance */ public function getLogger() { if ($this->log == null) { $this->log = Tlog::getNewInstance(); $logFilePath = $this->getLogFilePath(); $this->log->setPrefix("#LEVEL: #DATE #HOUR: "); $this->log->setDestinations("\\Thelia\\Log\\Destination\\TlogDestinationFile"); $this->log->setConfig("\\Thelia\\Log\\Destination\\TlogDestinationFile", 0, $logFilePath); } return $this->log; }
public function __construct() { $this->logger = Tlog::getNewInstance(); $this->logger->setDestinations(static::LOG_CLASS); $this->logger->setConfig(self::LOG_CLASS, 0, THELIA_ROOT . "log" . DS . "log-shopping-flux.txt"); /** * Create a fake user ShoppingFlux if it doesn't exist */ $this->shoppingFluxCustomer = ShoppingFluxConfigQuery::createShoppingFluxCustomer(); $this->shoppingFluxPaymentModule = (new ShoppingFlux())->getModuleModel(); $this->shoppingFluxPaymentModuleId = $this->shoppingFluxPaymentModule->getId(); }
public function setUp() { new Translator(new Container()); Tlog::getNewInstance(); $cacheDir = THELIA_CACHE_DIR . "test"; if (!is_dir($cacheDir)) { mkdir($cacheDir); } $this->tar = $this->getArchiveBuilder(); if (!$this->tar->isAvailable()) { $this->markTestSkipped("The " . $this->tar->getExtension() . " archiver can't be tested as its dependencies are not installed/configured in this context"); } $this->tar->setEnvironment("test"); }
public function setUp() { new Translator(new Container()); Tlog::getNewInstance(); $cacheDir = THELIA_CACHE_DIR . "test"; if (!is_dir($cacheDir)) { mkdir($cacheDir); } $this->zip = new ZipArchiveBuilder(); if (!$this->zip->isAvailable()) { $this->markTestSkipped("The " . $this->zip->getExtension() . " archiver can't be tested as its dependencies are not installed/configured in this context"); } $this->zip->setEnvironment("test"); $this->loadedZip = $this->zip->loadArchive(__DIR__ . DS . "TestResources/well_formatted.zip"); }
public function setUp() { $logger = Tlog::getNewInstance(); $translator = new Translator(new Container()); $this->downloader = new FileDownloader($logger, $translator); }
public function __construct() { $this->translator = Translator::getInstance(); $this->logger = Tlog::getNewInstance(); }
public function setUp() { Tlog::getNewInstance(); $this->session = $this->getSession(); $this->container = $this->getContainer(); }
public function getExport($generateOnly = false) { $env = $this->container->getParameter("kernel.environment"); $theliaCacheDirectory = THELIA_CACHE_DIR . $env . DS; $generateFile = true; $writeCache = false; /** * Error logging tools */ $logger = Tlog::getNewInstance(); $logger->setDestinations(static::LOG_CLASS); $logger->setConfig(self::LOG_CLASS, 0, THELIA_ROOT . "log" . DS . "log-shopping-flux.txt"); $translator = Translator::getInstance(); $cacheDirectory = $theliaCacheDirectory . static::SHOPPING_FLUX_CACHE_DIR . DS; $cacheFile = $cacheDirectory . static::CACHE_FILE_NAME; /** * Check if the file exists, if it is readable and if * we have to get the cache or save it. */ if (file_exists($cacheFile)) { if (!is_readable($cacheFile)) { $logger->warning($translator->trans("The file %file is not readable, the cache can't be used", ["%file" => $cacheFile], ShoppingFlux::MESSAGE_DOMAIN)); } else { $time = @filemtime($cacheFile); if (false === $time) { $logger->error($translator->trans("Unknown error while getting %file update time", ["%file" => $cacheFile], ShoppingFlux::MESSAGE_DOMAIN)); } elseif ($time < ($limitTime = time() - static::CACHE_TIME_HOUR * 3600)) { /** * If the cache is too old */ if (!is_writable($cacheFile)) { $logger->warning($translator->trans("The file %file is not writable, the cache can't be saved", ["%file" => $cacheFile], ShoppingFlux::MESSAGE_DOMAIN)); } else { $writeCache = true; } } elseif ($time >= $limitTime) { $generateFile = false; } } } else { /** * Check if the cache directory exists, * if not, create it. */ if (!file_exists($cacheDirectory)) { if (!@mkdir($cacheDirectory)) { $logger->warning($translator->trans("Unable to create the cache directory %dir", ["%dir" => $cacheDirectory], ShoppingFlux::MESSAGE_DOMAIN)); } else { $writeCache = true; } } } if (is_file($cacheDirectory) && !unlink($cacheDirectory)) { $logger->warning($translator->trans("Unable to create the cache directory, a file named %dir exists and can't be deleted", ["%dir" => $cacheDirectory], ShoppingFlux::MESSAGE_DOMAIN)); } elseif (is_dir($cacheDirectory)) { if (!is_writable($cacheDirectory)) { $logger->warning($translator->trans("The directory %dir is not writable, the cache file can't be saved", ["%dir" => $cacheDirectory], ShoppingFlux::MESSAGE_DOMAIN)); } elseif (!file_exists($cacheFile)) { $writeCache = true; } } /** * Then when everything's ok ( directory created if not ) go. */ if ($generateFile) { $content = ShoppingFluxConfigQuery::exportXML($this->container); } elseif (!$generateOnly) { $content = file_get_contents($cacheFile); } else { $content = null; } if ($writeCache && $content !== null) { file_put_contents($cacheFile, $content); } if ($generateOnly) { return !($generateFile ^ $writeCache) && is_writable($cacheFile); } return new Response($content, 200, ["Content-type" => "application/xml"]); }