/**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var DepositRepository $repo */
     $repo = $this->em->getRepository('AppBundle:Deposit');
     $summary = $repo->stateSummary();
     $count = 0;
     foreach ($summary as $row) {
         $output->writeln(sprintf('%6d - %s', $row['ct'], $row['state']));
         $count += $row['ct'];
     }
     $output->writeln(sprintf('%6d - total', $count));
 }
Exemplo n.º 2
0
 public function __construct(Container $di, Wordpress $wp, Options $options, ProductServiceInterface $productService)
 {
     $this->wp = $wp;
     $this->options = $options;
     $types = $options->getEnabledProductTypes();
     foreach ($types as $typeClass) {
         /** @var Types\Product\Type $type */
         $type = $di->get($typeClass);
         if (!$type instanceof Types\Product\Type) {
             if (WP_DEBUG) {
                 throw new Exception(sprintf(__('Invalid type definition! Offending class: "%s".', 'jigoshop'), $typeClass));
             }
             Registry::getInstance(JIGOSHOP_LOGGER)->addWarning(sprintf('Invalid type definition! Offending class: "%s".', $typeClass));
             continue;
         }
         $this->enabledTypes[$type->getId()] = $type;
         $productService->addType($type->getId(), $type->getClass());
         $wp->addAction('jigoshop\\product\\type\\init', array($type, 'initialize'), 10, 2);
     }
     $wp->doAction('jigoshop\\product\\type\\init', $wp, $this->enabledTypes);
     // Enable comments for all orders, disable pings
     $wp->addFilter('wp_insert_post_data', function ($data) {
         if ($data['post_type'] == Product::NAME) {
             $data['comment_status'] = 'open';
             $data['ping_status'] = 'closed';
         }
         return $data;
     });
 }
 public function boot()
 {
     $em = $this->container->get("doctrine.orm.entity_manager");
     try {
         Registry::getInstance("app");
     } catch (InvalidArgumentException $e) {
         Registry::addLogger($this->container->get("logger"), "app");
     }
     try {
         Type::addType("encryptedstring", "\\Keboola\\ProvisioningBundle\\Types\\EncryptedStringType");
         Type::addType("enumservertype", "\\Keboola\\ProvisioningBundle\\Types\\EnumServerTypeType");
         Type::addType("enumservermode", "\\Keboola\\ProvisioningBundle\\Types\\EnumServerModeType");
         Type::addType("enumaccounttype", "\\Keboola\\ProvisioningBundle\\Types\\EnumAccountTypeType");
         Type::addType("enumwrdbaccounttype", "\\Keboola\\ProvisioningBundle\\Types\\EnumWrdbAccountTypeType");
         Type::addType("enumredshiftaccounttype", "\\Keboola\\ProvisioningBundle\\Types\\EnumRedshiftAccountTypeType");
         Type::addType("enumsnowflakeaccounttype", "\\Keboola\\ProvisioningBundle\\Types\\EnumSnowflakeAccountTypeType");
         Type::addType("enumsnowflakeaccountwithluckyguesstype", "\\Keboola\\ProvisioningBundle\\Types\\EnumSnowflakeAccountWithLuckyguessTypeType");
         Type::addType("enumsnowflakeaccountwithluckyguessandwritertype", "\\Keboola\\ProvisioningBundle\\Types\\EnumSnowflakeAccountWithLuckyguessAndWriterTypeType");
         Type::addType("enumredshiftworkspaceaccounttype", "\\Keboola\\ProvisioningBundle\\Types\\EnumRedshiftWorkspaceAccountTypeType");
         Type::addType("enumdockeraccounttype", "\\Keboola\\ProvisioningBundle\\Types\\EnumDockerAccountTypeType");
         Type::addType("enumredshiftworkspaceaccountwithluckyguestype", "\\Keboola\\ProvisioningBundle\\Types\\EnumRedshiftWorkspaceAccountWithLuckyguessTypeType");
         Type::addType("enumredshiftworkspaceaccountwithluckyguessandwritertype", "\\Keboola\\ProvisioningBundle\\Types\\EnumRedshiftWorkspaceAccountWithLuckyguessAndWriterTypeType");
         $encryptor = new AesEncryptor($this->container->getParameter("provisioning_api.key"));
         // 256 bit key
         EncryptedStringType::setEncryptor($encryptor);
         $em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping("encryptedstring", "encryptedstring");
     } catch (\Doctrine\DBAL\DBALException $e) {
         // For some reason this exception gets thrown during
         // the clearing of the cache. I didn't have time to
         // find out why :-)
     }
 }
Exemplo n.º 4
0
 public function setName($name)
 {
     if (WP_DEBUG) {
         throw new Exception(__('Guest customer cannot be updated!', 'jigoshop'));
     }
     Registry::getInstance(JIGOSHOP_LOGGER)->addDebug('Guest customer cannot be updated!');
 }
Exemplo n.º 5
0
 public function testCreateLogger()
 {
     $logger = Cascade::createLogger('test');
     $this->assertTrue($logger instanceof Logger);
     $this->assertEquals('test', $logger->getName());
     $this->assertTrue(Registry::hasLogger('test'));
 }
 /**
  * {@inheritdoc}
  */
 public function initialize(array $options)
 {
     if (!isset($options['logger'])) {
         throw new ArgumentNullException('logger');
     }
     $this->logger = Registry::getInstance($options['logger']);
 }
Exemplo n.º 7
0
 /**
  * @param $level
  * @param $message
  * @param array $context
  */
 public function log($level, $message, $context = array())
 {
     try {
         Registry::getInstance("app")->log($level, $message, $context);
     } catch (InvalidArgumentException $e) {
         // Nothing
     }
 }
Exemplo n.º 8
0
 /**
  * Returns method by its ID.
  *
  * @param $id string ID of method.
  *
  * @return Method Method found.
  * @throws Exception When no method is found for specified ID.
  */
 public function get($id)
 {
     if (!isset($this->methods[$id])) {
         Registry::getInstance(JIGOSHOP_LOGGER)->addWarning(sprintf(__('Shipping method "%s" does not exists', 'jigoshop'), $id));
         return new Dummy($id);
     }
     return $this->methods[$id];
 }
Exemplo n.º 9
0
 public function testLoad()
 {
     Logger::load($this->config);
     $logger = \Monolog\Registry::getInstance('MAIN');
     $this->assertInstanceOf('\\Monolog\\Logger', $logger);
     $handler = $logger->popHandler();
     $this->assertInstanceOf('\\Monolog\\Handler\\StreamHandler', $handler);
 }
Exemplo n.º 10
0
 /**
  * @dataProvider hasLoggerProvider
  * @covers Monolog\Registry::hasLogger
  */
 public function testHasLogger(array $loggersToAdd, array $loggersToCheck, array $expectedResult)
 {
     foreach ($loggersToAdd as $loggerToAdd) {
         Registry::addLogger($loggerToAdd);
     }
     foreach ($loggersToCheck as $index => $loggerToCheck) {
         $this->assertSame($expectedResult[$index], Registry::hasLogger($loggerToCheck));
     }
 }
 private function query($type, $fields, $where)
 {
     $fieldsClause = join(', ', $fields);
     $whereClause = $this->buildWhereClause($where);
     $query = "SELECT {$fieldsClause} FROM {$type} WHERE {$whereClause}";
     \Monolog\Registry::getInstance('logger')->debug("Query: '{$query}'");
     $response = $this->soapClient->query(['queryString' => $query]);
     \Monolog\Registry::getInstance('logger')->debug("Response: '" . json_encode($response->result->records) . "'");
     return $response->result->records;
 }
Exemplo n.º 12
0
 /**
  * Zwraca zarejestrowany dziennik.
  * 
  * @param string $name Nazwa wybranego dziennika
  * @return LoggerInterface Dziennik
  * @throws InvalidArgumentException func_num_args() == 0
  * @throws InvalidArgumentException Dziennik nie zarejestrowany
  * @throws LogicException Niepoprawna nazwa dziennika
  */
 public function getLogger($name)
 {
     if (func_num_args() == 0) {
         throw new InvalidArgumentException("No arguments");
     }
     if (is_string($name) == false || $name == "") {
         throw new LogicException("Invalid or empty logger name");
     }
     return MonologRegistry::getInstance($name);
 }
Exemplo n.º 13
0
 /**
  * Get a Logger instance by name. Creates a new one if a Logger with the
  * provided name does not exist
  *
  * @param  string $name Name of the requested Logger instance
  *
  * @return Logger Requested instance of Logger or new instance
  */
 public static function getLogger($name)
 {
     if (Registry::hasLogger($name)) {
         return Registry::getInstance($name);
     } else {
         if (Registry::hasLogger('default')) {
             return Registry::getInstance('default');
         }
     }
     return self::createLogger($name);
 }
Exemplo n.º 14
0
 public function testLoggersConfigured()
 {
     $options = Fixtures::getPhpArrayConfig();
     // Mocking the ConfigLoader with the load method
     $configLoader = $this->getMockBuilder('Cascade\\Config\\ConfigLoader')->disableOriginalConstructor()->setMethods(array('load'))->getMock();
     $configLoader->method('load')->willReturn($options);
     $config = new Config($options, $configLoader);
     $config->load();
     $config->configure();
     $this->assertTrue(Registry::hasLogger('my_logger'));
 }
Exemplo n.º 15
0
 /**
  * Adds new page to Jigoshop admin panel.
  * Available parents:
  *   * jigoshop - main Jigoshop menu,
  *   * products - Jigoshop products menu
  *   * orders - Jigoshop orders menu
  *
  * @param $page PageInterface Page to add.
  *
  * @throws Exception When trying to add page not in Jigoshop menus.
  */
 public function addPage(PageInterface $page)
 {
     $parent = $page->getParent();
     if (!isset($this->pages[$parent])) {
         if (WP_DEBUG) {
             throw new Exception(sprintf('Trying to add page to invalid parent (%s). Available ones are: %s', $parent, join(', ', array_keys($this->pages))));
         }
         Registry::getInstance(JIGOSHOP_LOGGER)->addDebug(sprintf('Trying to add page to invalid parent (%s).', $parent), array('parents' => $this->pages));
         return;
     }
     $this->pages[$parent][] = $page;
 }
 /**
  * {@inheritdoc}
  */
 public function initialize(array $options)
 {
     if (!isset($options['logger'])) {
         throw new ArgumentNullException('logger');
     }
     if (is_array($options['rules']) && !empty($options['rules'])) {
         $this->rules = $options['rules'];
     }
     if (is_callable($options['context'])) {
         $this->context = $options['context'];
     }
     $this->logger = Registry::getInstance($options['logger']);
 }
Exemplo n.º 17
0
 /**
  * Load loggers and register them into \Monolog\Registry
  *
  * @param $config \Centreon\Config The application configuration
  */
 public static function load($config)
 {
     $logger = new \Monolog\Logger('MAIN');
     $loggers = $config->get('loggers', 'logger');
     foreach ($loggers as $loggerName) {
         $loggerType = $config->get('logger_' . $loggerName, 'type');
         if (!is_null($loggerType) && isset(self::$loggerHandler[$loggerType])) {
             try {
                 $handler = self::createHandler($config->getGroup('logger_' . $loggerName), $loggerName);
                 $logger->pushHandler($handler);
             } catch (\Exception $e) {
             }
         }
     }
     \Monolog\Registry::addLogger($logger, $logger->getName(), true);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var DepositRepository $repo */
     $repo = $this->em->getRepository('AppBundle:Deposit');
     $deposits = $repo->findAll();
     foreach ($deposits as $deposit) {
         $this->logger->notice("{$deposit->getDepositUuid()}");
         $checksum = strtoupper($this->getChecksum($deposit));
         if ($checksum !== $deposit->getChecksumValue()) {
             $this->logger->warning("Updating checksum for {$deposit->getDepositUuid()}");
             $deposit->setChecksumValue($checksum);
         }
     }
     if (!$input->getOption('dry-run')) {
         $this->em->flush();
     }
 }
Exemplo n.º 19
0
 private function inflate()
 {
     Registry::PhlowLog()->addInfo('Inflating');
     $this->workflowName = $this->raw['workflowType']['name'];
     $this->workflowVersion = $this->raw['workflowType']['version'];
     $this->workflowRunId = $this->raw['workflowExecution']['runId'];
     $this->workflowId = $this->raw['workflowExecution']['workflowId'];
     $this->token = $this->raw['taskToken'];
     $this->previousStartedEventId = $this->raw['previousStartedEventId'];
     $this->startedEventId = $this->raw['startedEventId'];
     foreach ($this->raw['events'] as $raw_event) {
         switch ($raw_event['eventType']) {
             case EventType::WORKFLOW_EXECUTION_STARTED:
                 $event = new \Phlow\Events\WorkflowExecutionStarted($raw_event);
                 $this->eventManager->setExecutionEvent($event);
                 $this->eventManager->setLastEvent($event);
                 break;
             case EventType::ACTIVITY_TASK_COMPLETED:
                 $event = new \Phlow\Events\ActivityTaskCompleted($raw_event);
                 $this->eventManager->setLastEvent($event);
                 break;
             case EventType::ACTIVITY_TASK_FAILED:
                 $event = new \Phlow\Events\ActivityTaskFailed($raw_event);
                 $this->eventManager->setLastEvent($event);
                 break;
             case EventType::ACTIVITY_TASK_SCHEDULED:
                 $event = new \Phlow\Events\ActivityTaskScheduled($raw_event);
                 break;
             case EventType::ACTIVITY_TASK_STARTED:
                 $event = new \Phlow\Events\ActivityTaskStarted($raw_event);
                 break;
             case EventType::WORKFLOW_EXECUTION_SIGNALED:
                 $event = new \Phlow\Events\WorkflowExecutionSignaled($raw_event);
                 break;
             case EventType::TIMER_STARTED:
                 $event = new \Phlow\Events\TimerStarted($raw_event);
                 break;
             default:
                 $event = new \Phlow\Events\BaseEvent($raw_event);
         }
         $this->eventManager->addEvent($event);
     }
     $this->eventManager->buildOptionData();
 }
Exemplo n.º 20
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $state = $input->getArgument('state');
     $uuids = $input->getArgument('deposit');
     $deposits = $this->getDeposits($uuids);
     foreach ($deposits as $deposit) {
         $this->logger->notice("Setting {$deposit->getDepositUuid()} to {$state}");
         $deposit->setState($state);
         if ($input->getOption('clear')) {
             $deposit->setErrorLog(array());
             $deposit->setPackageSize(null);
             $deposit->setPlnState(null);
             $deposit->setProcessingLog('');
             $deposit->addToProcessingLog('Deposit reset.');
             $deposit->setAuContainer(null);
         }
     }
     $this->em->flush();
 }
Exemplo n.º 21
0
 /**
  * Returns empty product of selected type.
  *
  * @param $type string Type name of product.
  *
  * @throws \Jigoshop\Exception When product type does not exists.
  * @return \Jigoshop\Entity\Product
  */
 public function get($type)
 {
     if (!isset($this->types[$type])) {
         if (WP_DEBUG) {
             throw new Exception(sprintf('Product type "%s" does not exists.', $type));
         }
         Registry::getInstance(JIGOSHOP_LOGGER)->addWarning(sprintf('Product type "%s" does not exists.', $type));
         $type = Simple::TYPE;
     }
     $class = $this->types[$type];
     /** @var \Jigoshop\Entity\Product $instance */
     $instance = new $class();
     if ($instance instanceof Purchasable) {
         /** @var \Jigoshop\Entity\Product\Purchasable $instance */
         $instance->getStock()->setManage($this->options->get('products.manage_stock'));
         $instance->getStock()->setStatus($this->options->get('products.stock_status'));
     }
     $instance->setTaxable($this->options->get('tax.defaults.taxable'));
     $instance->setTaxClasses($this->options->get('tax.defaults.classes'));
     return $instance;
 }
Exemplo n.º 22
0
 /**
  * Waits for an activity task to come in from SWF and directs it to the appropriate handler
  */
 public function pollForTasks()
 {
     while (true) {
         try {
             $taskData = $this->swfClient->pollForActivityTask(array('domain' => $this->domain, 'taskList' => array("name" => $this->taskList), 'identity' => get_class() . '-' . microtime()));
         } catch (Exception $e) {
             var_dump($e);
             die('here');
         }
         if ($taskData['taskToken']) {
             $task = new Task($taskData->toArray());
             Registry::PhlowLog()->addInfo('Trying to process request');
             try {
                 $results = $this->handler->handle($this->swfClient, $task);
                 Registry::PhlowLog()->addInfo('Task Handled successfully');
                 $this->swfClient->respondActivityTaskCompleted(array('taskToken' => $task->getToken(), 'result' => base64_encode(json_encode($results))));
             } catch (\Exception $e) {
                 Registry::PhlowLog()->addInfo('There was a problem handling this Task');
                 $this->swfClient->respondActivityTaskFailed(array('taskToken' => $task->getToken(), 'reason' => $e->getMessage()));
             }
         }
     }
 }
Exemplo n.º 23
0
 /**
  * Loads proper template based on current page.
  *
  * @param $template string Template chain.
  *
  * @return string Template to load.
  */
 public function process($template)
 {
     if (!Pages::isJigoshop()) {
         return $template;
     }
     if ($this->page === null) {
         if (WP_DEBUG) {
             throw new Exception('Page object should already be set for Jigoshop pages, but none found.');
         }
         Registry::getInstance(JIGOSHOP_LOGGER)->addCritical('Page object should already be set for Jigoshop pages, but none found.');
         return false;
     }
     $content = $this->page->render();
     $template = $this->wp->getOption('template');
     $theme = $this->wp->wpGetTheme();
     if ($theme->get('Author') === 'WooThemes') {
         $template = 'woothemes';
     }
     if (!file_exists(\JigoshopInit::getDir() . '/templates/layout/' . $template . '.php')) {
         $template = 'default';
     }
     Render::output('layout/' . $template, array('content' => $content));
     return false;
 }
 public function testConstructor()
 {
     $loader = new LoggerLoader('testLogger');
     $this->assertTrue(Registry::hasLogger('testLogger'));
 }
Exemplo n.º 25
0
 /**
  * Outputs simple static (constant) field.
  *
  * Available parameters (with defaults):
  *   * id (null) - HTML id for the tag
  *   * name (null) - HTML name for the tag
  *   * label (null) - label for the tag
  *   * value (false) - HTML value of the tag
  *   * placeholder ('') - placeholder of the tag
  *   * classes (array()) - list of HTML classes for the tag
  *   * description (false) - description of the tag
  *   * tip (false) - tip for the tag
  *   * hidden (false) - whether to hide element by default
  *   * size (12) - default size of the element (Bootstrap column size 12)
  *
  * Field's name is required.
  *
  * @param $field array Field parameters.
  *
  * @throws \Jigoshop\Exception
  */
 public static function constant($field)
 {
     $defaults = array('id' => null, 'name' => null, 'label' => null, 'value' => false, 'placeholder' => '', 'classes' => array(), 'description' => false, 'tip' => false, 'hidden' => false, 'size' => 11, 'startDate' => false, 'endDate' => false);
     $field = wp_parse_args($field, $defaults);
     if (empty($field['name'])) {
         if (WP_DEBUG) {
             throw new Exception(sprintf('Field "%s" must have a name!', serialize($field)));
         }
         Registry::getInstance(JIGOSHOP_LOGGER)->addCritical('Field must have a name!', array('field' => $field));
         return;
     }
     if (empty($field['id'])) {
         $field['id'] = self::prepareIdFromName($field['name']);
     }
     Render::output(static::$constantTemplate, $field);
 }
Exemplo n.º 26
0
/** Add information to the log file */
function add_log($text, $function, $type = LOG_INFO, $projectid = 0, $buildid = 0, $resourcetype = 0, $resourceid = 0)
{
    global $CDASH_LOG_FILE, $CDASH_LOG_FILE_MAXSIZE_MB, $CDASH_LOG_LEVEL, $CDASH_TESTING_MODE;
    $level = to_psr3_level($type);
    if (($buildid === 0 || is_null($buildid)) && isset($GLOBALS['PHP_ERROR_BUILD_ID'])) {
        $buildid = $GLOBALS['PHP_ERROR_BUILD_ID'];
    }
    $context = array('function' => $function);
    if ($projectid !== 0 && !is_null($projectid)) {
        $context['project_id'] = $projectid;
    }
    if ($buildid !== 0 && !is_null($buildid)) {
        $context['build_id'] = strval($buildid);
    }
    if ($resourcetype !== 0 && !is_null($resourcetype)) {
        $context['resource_type'] = $resourcetype;
    }
    if ($resourceid !== 0 && !is_null($resourceid)) {
        $context['resource_id'] = $resourceid;
    }
    $minLevel = to_psr3_level($CDASH_LOG_LEVEL);
    if (!is_null($CDASH_LOG_FILE)) {
        // If the size of the log file is bigger than 10 times the allocated memory
        // we rotate
        $logFileMaxSize = $CDASH_LOG_FILE_MAXSIZE_MB * 100000;
        if (file_exists($CDASH_LOG_FILE) && filesize($CDASH_LOG_FILE) > $logFileMaxSize) {
            $tempLogFile = $CDASH_LOG_FILE . '.tmp';
            if (!file_exists($tempLogFile)) {
                rename($CDASH_LOG_FILE, $tempLogFile);
                // This should be quick so we can keep logging
                for ($i = 9; $i >= 0; $i--) {
                    // If we do not have compression we just rename the files
                    if (function_exists('gzwrite') === false) {
                        $currentLogFile = $CDASH_LOG_FILE . '.' . $i;
                        $j = $i + 1;
                        $newLogFile = $CDASH_LOG_FILE . '.' . $j;
                        if (file_exists($newLogFile)) {
                            cdash_unlink($newLogFile);
                        }
                        if (file_exists($currentLogFile)) {
                            rename($currentLogFile, $newLogFile);
                        }
                    } else {
                        $currentLogFile = $CDASH_LOG_FILE . '.' . $i . '.gz';
                        $j = $i + 1;
                        $newLogFile = $CDASH_LOG_FILE . '.' . $j . '.gz';
                        if (file_exists($newLogFile)) {
                            cdash_unlink($newLogFile);
                        }
                        if (file_exists($currentLogFile)) {
                            $gz = gzopen($newLogFile, 'wb');
                            $f = fopen($currentLogFile, 'rb');
                            while ($f && !feof($f)) {
                                gzwrite($gz, fread($f, 8192));
                            }
                            fclose($f);
                            unset($f);
                            gzclose($gz);
                            unset($gz);
                        }
                    }
                }
                // Move the current backup
                if (function_exists('gzwrite') === false) {
                    rename($tempLogFile, $CDASH_LOG_FILE . '.0');
                } else {
                    $gz = gzopen($CDASH_LOG_FILE . '.0.gz', 'wb');
                    $f = fopen($tempLogFile, 'rb');
                    while ($f && !feof($f)) {
                        gzwrite($gz, fread($f, 8192));
                    }
                    fclose($f);
                    unset($f);
                    gzclose($gz);
                    unset($gz);
                    cdash_unlink($tempLogFile);
                }
            }
        }
        $pid = getmypid();
        if ($pid !== false) {
            $context['pid'] = getmypid();
        }
    }
    if (Registry::hasLogger('cdash') === false) {
        if ($CDASH_LOG_FILE === false) {
            $handler = new SyslogHandler('cdash', LOG_USER, $minLevel);
            $handler->getFormatter()->ignoreEmptyContextAndExtra();
        } else {
            if ($CDASH_TESTING_MODE) {
                $filePermission = 0666;
            } else {
                $filePermission = 0664;
            }
            $handler = new StreamHandler($CDASH_LOG_FILE, $minLevel, true, $filePermission);
            $handler->getFormatter()->allowInlineLineBreaks();
            $handler->getFormatter()->ignoreEmptyContextAndExtra();
        }
        $logger = new Logger('cdash');
        $logger->pushHandler($handler);
        Registry::addLogger($logger);
    } else {
        $logger = Registry::getInstance('cdash');
    }
    $logger->log($level, $text, $context);
}
Exemplo n.º 27
0
 /**
  * @param int $quantity New item quantity.
  *
  * @throws Exception When quantity is invalid.
  */
 public function setQuantity($quantity)
 {
     if ($quantity < 0) {
         if (WP_DEBUG) {
             throw new Exception(__('Item quantity cannot be below 0', 'jigoshop'));
         }
         Registry::getInstance(JIGOSHOP_LOGGER)->addCritical('Item quantity cannot be below 0');
         $quantity = 0;
     }
     $this->quantity = $quantity;
 }
Exemplo n.º 28
0
<?php

/*
 * This file is part of the Pathfinder package.
 *
 * (c) bitExpert AG
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
declare (strict_types=1);
// include and configure Composer autoloader
include __DIR__ . '/../vendor/autoload.php';
// configure the Simple Logging Facade for PSR-3 loggers with a Monolog backend
\bitExpert\Slf4PsrLog\LoggerFactory::registerFactoryCallback(function ($channel) {
    if (!\Monolog\Registry::hasLogger($channel)) {
        \Monolog\Registry::addLogger(new \Monolog\Logger($channel));
    }
    return \Monolog\Registry::getInstance($channel);
});
Exemplo n.º 29
0
 /**
  * Configure and register Logger(s) according to the options passed in
  */
 public function configure()
 {
     if (!isset($this->options['disable_existing_loggers'])) {
         // We disable any existing loggers by default
         $this->options['disable_existing_loggers'] = true;
     }
     if ($this->options['disable_existing_loggers']) {
         Registry::clear();
     }
     if (isset($this->options['formatters'])) {
         $this->configureFormatters($this->options['formatters']);
     }
     if (isset($this->options['handlers'])) {
         $this->configureHandlers($this->options['handlers']);
     }
     if (isset($this->options['processors'])) {
         $this->configureProcessors($this->options['processors']);
     }
     if (isset($this->options['loggers'])) {
         $this->configureLoggers($this->options['loggers']);
     } else {
         throw new \RuntimeException('Cannot configure loggers. No logger configuration options provided.');
     }
 }
Exemplo n.º 30
0
 /**
  * Selects which address is to be used as tax address.
  *
  * @param $address string Name of address to be used as tax address.
  */
 public function selectTaxAddress($address)
 {
     if (!in_array($address, array('billing', 'shipping'))) {
         if (WP_DEBUG) {
             throw new Exception(sprintf(__('Unknown address type: "%s".', 'jigoshop'), $address));
         }
         Registry::getInstance(JIGOSHOP_LOGGER)->addCritical(sprintf('Unknown address type: "%s".', $address));
         return;
     }
     $this->taxAddress = $address;
 }