Example #1
0
 public function testWork()
 {
     $sm = Registry::getServiceManager();
     /** @var \Rzn\Memcache\Service $memcache */
     $memcache = $sm->get('rzn_memcache');
     $memcache->setPort('11211');
     $this->assertTrue(false != $memcache->getConnection());
     $test = 'test';
     $memcache->set('test', $test);
     $this->assertEquals($test, $memcache->get('test'));
 }
Example #2
0
 public function testLog()
 {
     $sm = Registry::getServiceManager();
     /** @var \Rzn\Library\Mediator\Mediator $mediator */
     $mediator = $sm->get('mediator');
     $file = __DIR__ . '/log.txt';
     $uniq = uniqid();
     $mediator->publish('log', ['code' => $uniq], ['file' => $file]);
     $content = file_get_contents($file);
     $this->assertTrue((bool) preg_match('|code=' . $uniq . '|', $content));
     unlink($file);
 }
Example #3
0
 public function testWithError()
 {
     /** @var \Rzn\Order\Order $orderService */
     $orderService = Registry::getServiceManager()->get('rzn_order');
     $orderService->setPrice(10)->setXml(10)->setStatus(0)->setUserId(1)->setPersonType(10);
     $id = $orderService->prepareData()->save();
     /** @var \CApplicationException $saveError */
     $saveError = $orderService->getSaveError();
     $this->assertEquals('EMPTY_CURRENCY', $saveError->GetID());
     $this->assertEmpty($id, 'Заказ не должен быть сохранен');
     $orderService->clear();
     $orderService->setPrice(10)->setXml(10)->setStatus(0)->setCurrency()->setUserId(1)->setPersonType(10);
     $id = $orderService->prepareData()->save();
     /** @var \CApplicationException $saveError */
     $saveError = $orderService->getSaveError();
     $this->assertEquals('ERROR_NO_PERSON_TYPE', $saveError->GetID());
     $this->assertEmpty($id, 'Заказ не должен быть сохранен');
 }
Example #4
0
function pr($value, $is_die = false)
{
    echo '<pre>';
    print_r($value);
    echo '</pre>';
    if ($is_die)
        die();
}


if (Loader::includeModule('rzn.library'))
{
    $sm = Registry::getServiceManager();

    Registry::set('DOCUMENT_ROOT', $_SERVER['DOCUMENT_ROOT'], true);

    $parts = explode('.', $_SERVER['HTTP_HOST']);
    $countParts = count($parts);

    if ($countParts > 1)
    {
        Registry::set('HTTP_HOST_BASE', $parts[$countParts - 2] . '.' . $parts[$countParts - 1]);
    }
    else {
        $config = $sm->get('config');
        Registry::set('HTTP_HOST_BASE', $config['main']['domain']);
    }

}

Example #5
0
    /**
     * Подключение файла с компонентом в рамках текущего шаблона
     * @param Rzn\Library\Component\IncludeWithTemplate $includeWithTemplate
     */
    /** @var Rzn\Library\Component\IncludeWithTemplate  $includeWithTemplate */
    $includeWithTemplate = $sm->get('IncludeComponentWithTemplate');
    $includeWithTemplate->setFreeInclude();
    $includeWithTemplate->includeComponent($params['component']);
    // имеет метод __invoke
    if (!$includeWithTemplate->isSuccess()) {
        throw new Exception('Компонент с таким кодовым именем не зарегистрирован.');
    }
    $eventManager->trigger('direct.include.component.success', null, $params);
    /*
        $path = $_SERVER['DOCUMENT_ROOT'] . '/local/templates/' . SITE_TEMPLATE_ID . '/include/component/' . $_REQUEST['component'] . '.php';
    
        if (!is_file($path)) {
            throw new Exception('Компонент с таким кодовым именем не зарегистрирован.');
        }
    
        include($path);
    */
} catch (Exception $e) {
    //echo SITE_TEMPLATE_ID;
    $APP = Registry::getApplication();
    CHTTP::SetStatus("404 Not Found");
    @define("ERROR_404", "Y");
    $APP->SetTitle("Страница не найдена");
    include __DIR__ . '/templates/' . SITE_TEMPLATE_ID . '/404.php';
}
//require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");
Example #6
0
if (!isset($_SERVER['DOCUMENT_ROOT']) or !$_SERVER['DOCUMENT_ROOT']) {
    $dir = __DIR__ . '/..';
    //
    $_SERVER['DOCUMENT_ROOT'] = $dir;
    if (isset($_SERVER['argv'][1])) {
        $_REQUEST['event'] = $_SERVER['argv'][1];
    }
    if (isset($_SERVER['argv'][2]) and $_SERVER['argv'][2]) {
        parse_str($_SERVER['argv'][2], $params);
    }
} else {
    parse_str($_SERVER['QUERY_STRING'], $params);
}
use Rzn\Library\Registry;
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
$sm = Registry::getServiceManager();
/** @var Rzn\Library\EventManager\EventManager $events */
$events = $sm->get('event_manager');
$config = $sm->get('config');
$cron = $config['cron'];
/** @var \Rzn\Library\Waterfall\WaterfallCollection $waterfall */
$waterfall = $sm->get('waterfall');
$minute = str_replace('0', '', date('i'));
$hour = date('G');
if (!isset($cron['tasks'])) {
    return null;
}
$tasks = $cron['tasks']->toArray();
try {
    if ($cron['direct'] and isset($_REQUEST['event'])) {
        if (isset($tasks[$_REQUEST['event']])) {