/**
 * @param string $configFile
 * @return \SystemContainer|Nette\DI\Container
 */
function createContainer($configFile)
{
    $config = new Nette\Configurator();
    $config->setTempDirectory(TEMP_DIR);
    $config->addParameters(array('container' => array('class' => 'SystemContainer_' . md5($configFile))));
    $config->addConfig(__DIR__ . '/config/' . $configFile . '.neon');
    JP\LeanMapperExtension\LeanMapperExtension::register($config);
    return $config->createContainer();
}
Esempio n. 2
0
/**
 * @param  string|NULL  $&onfig
 * @return Nette\DI\Container
 */
function createContainer($config = NULL)
{
    $builder = new Nette\Configurator();
    $builder->addConfig(__DIR__ . '/config.neon');
    $builder->setTempDirectory(TEMP_DIR);
    if (!is_null($config)) {
        $builder->addConfig($config);
    }
    $builder->addParameters(['container' => ['class' => 'SystemContainer_' . md5($config)], 'appDir' => dirname(__DIR__), 'wwwDir' => __DIR__]);
    return $builder->createContainer();
}
Esempio n. 3
0
 public function testExtensionName()
 {
     $tempDir = __DIR__ . '/../temp';
     $class = 'ExtensionNameServiceContainer';
     $configurator = new \Nette\Configurator();
     $configurator->setTempDirectory($tempDir);
     $configurator->addParameters(array('container' => array('class' => $class)));
     $configurator->onCompile[] = function ($configurator, \Nette\DI\Compiler $compiler) {
         $compiler->addExtension('Foo', new \WebLoader\Nette\Extension());
     };
     $configurator->addConfig(__DIR__ . '/../fixtures/extensionName.neon', false);
     $container = $configurator->createContainer();
     $this->assertInstanceOf('WebLoader\\Compiler', $container->getService('Foo.cssDefaultCompiler'));
     $this->assertInstanceOf('WebLoader\\Compiler', $container->getService('Foo.jsDefaultCompiler'));
 }
Esempio n. 4
0
 private function prepareContainer($class, $configFiles)
 {
     $tempDir = __DIR__ . '/../temp';
     foreach (Finder::findFiles('*')->exclude('.gitignore')->from($tempDir . '/cache') as $file) {
         unlink((string) $file);
     }
     $configurator = new \Nette\Configurator();
     $configurator->setTempDirectory($tempDir);
     foreach ($configFiles as $file) {
         $configurator->addConfig($file, FALSE);
     }
     $configurator->addParameters(array('fixturesDir' => __DIR__ . '/../fixtures', 'tempDir' => $tempDir, 'container' => array('class' => $class)));
     $extension = new \WebLoader\Nette\Extension();
     $extension->install($configurator);
     $this->container = @$configurator->createContainer();
     // sends header X-Powered-By, ...
 }
Esempio n. 5
0
 /**
  * @return \Nette\DI\Container
  */
 public static final function create($new = FALSE, $config = [])
 {
     if ($new || self::$container === NULL) {
         $configurator = new \Nette\Configurator();
         $configurator->addParameters($config);
         $configurator->onCompile[] = function (\Nette\Configurator $configurator, \Nette\DI\Compiler $compiler) use($config) {
             $compiler->addConfig($config);
             $compiler->addExtension('testbench', new \Testbench\TestbenchExtension());
             self::registerAdditionalExtension($compiler, 'fakeSession', new \Kdyby\FakeSession\DI\FakeSessionExtension());
             if (class_exists('Kdyby\\Console\\DI\\ConsoleExtension')) {
                 self::registerAdditionalExtension($compiler, 'console', new \Kdyby\Console\DI\ConsoleExtension());
             }
         };
         $configurator->setTempDirectory(\Testbench\Bootstrap::$tempDir);
         // shared container for performance purposes
         $configurator->setDebugMode(FALSE);
         if (is_callable(\Testbench\Bootstrap::$onBeforeContainerCreate)) {
             call_user_func_array(\Testbench\Bootstrap::$onBeforeContainerCreate, [$configurator]);
         }
         self::$container = $configurator->createContainer();
     }
     return self::$container;
 }
Esempio n. 6
0
<?php

/**
 * @author    Martin Procházka <*****@*****.**>
 * @package   www.juniwalk.cz
 * @link      https://github.com/juniwalk/www.juniwalk.cz
 * @copyright Martin Procházka (c) 2015
 * @license   MIT License
 */
include __DIR__ . '/../vendor/autoload.php';
$di = new \Nette\Configurator();
$di->addConfig(__DIR__ . '/config/config.neon');
$di->setTempDirectory(__DIR__ . '/../temp');
$di->addParameters(['pkgDir' => __DIR__ . '/../vendor', 'wwwDir' => __DIR__ . '/../www', 'appDir' => __DIR__]);
$di->setDebugMode(include __DIR__ . '/config/config-ipconf.php');
$di->enableDebugger(__DIR__ . '/../log');
$di->createRobotLoader()->addDirectory(__DIR__)->register();
return $di->createContainer();
require __DIR__ . '/../../../vendor/autoload.php';
/** START TEST */
@mkdir(__DIR__ . '/temp');
@mkdir(__DIR__ . '/temp/log');
/*foreach (\Nette\Utils\Finder::findFiles('*')->from(__DIR__ . '/temp') as $file) {
	@unlink((string) $file);
}*/
/** END TEST */
$configurator = new Nette\Configurator();
//$configurator->enableDebugger(__DIR__ . '/temp/log');
$configurator->setTempDirectory(__DIR__ . '/temp');
$configurator->createRobotLoader()->addDirectory(__DIR__ . '/../src')->addDirectory(__DIR__ . '/includes')->register();
if (file_exists(__DIR__ . '/_data/config.neon')) {
    $configurator->addConfig(__DIR__ . '/_data/config.neon');
}
$configurator->addParameters(array('dataDir' => __DIR__ . '/_data'));
$container = $configurator->createContainer();
/** START TEST */
new E($container);
/** END TEST */
class E
{
    /** @var \Nette\DI\Container */
    private static $container;
    public function __construct(\Nette\DI\Container $container)
    {
        self::$container = $container;
    }
    /**
     * @param $type
     * @return object
Esempio n. 8
0
<?php

require_once __DIR__ . '/../vendor/autoload.php';
Tester\Environment::setup();
define('TEMP_DIR', __DIR__ . '/tmp/' . getmypid());
@mkdir(TEMP_DIR);
@mkdir(TEMP_DIR . '/sessions');
$params = array('testingsqlitedb' => TEMP_DIR . '/db.sqlite');
$configurator = new Nette\Configurator();
$configurator->setDebugMode(true);
$configurator->setTempDirectory(TEMP_DIR);
$configurator->addParameters($params);
$configurator->createRobotLoader()->addDirectory(__DIR__ . '/../app')->register();
$configurator->addConfig(__DIR__ . '/../app/config/config.neon');
$configurator->addConfig(__DIR__ . '/config/db.neon');
$container = $configurator->createContainer();
$source = __DIR__ . '/db-image.sqlite';
$target = $params['testingsqlitedb'];
Nette\Utils\FileSystem::copy($source, $target);
return $container;
Esempio n. 9
0
<?php

return call_user_func(function () : Nette\Configurator {
    return call_user_func(function () : Nette\Configurator {
        Tracy\Debugger::$errorTemplate = __DIR__ . '/maintenance.php';
        if (!($configurator = is_file($local = __DIR__ . '/local.php') ? require $local : NULL) instanceof Nette\Configurator) {
            $configurator = new Nette\Configurator();
        }
        $configurator->addParameters(['appDir' => __DIR__, 'wwwDir' => __DIR__ . '/public', 'composer' => $composer = json_decode(file_get_contents(__DIR__ . '/../composer.json'), TRUE)]);
        $directory = isset($composer['name']) ? implode(DIRECTORY_SEPARATOR, [sys_get_temp_dir(), $composer['name']]) : NULL;
        if ($directory) {
            if (!is_dir($directory)) {
                @mkdir($directory, 0777, TRUE);
            }
            $configurator->enableDebugger($directory);
            $configurator->setTempDirectory($directory);
        }
        $configurator->addConfig(__DIR__ . '/../vendor/config.neon');
        $configurator->addConfig(__DIR__ . '/config.neon');
        if (is_file($local = __DIR__ . '/local.neon')) {
            $configurator->addConfig($local);
        }
        return $configurator;
    }, require __DIR__ . '/../vendor/autoload.php');
});
Esempio n. 10
0
<?php

require __DIR__ . '/bootstrap.php';
// create DI container
$configurator = new Nette\Configurator();
$configurator->setDebugMode(FALSE);
$configurator->setTempDirectory(TEMP_DIR);
$configurator->addParameters(array('wwwDir' => WWW_DIR, 'appDir' => APP_DIR, 'tempDir' => TEMP_DIR));
if (file_exists(__DIR__ . '/app/config/config.neon')) {
    $configurator->addConfig(__DIR__ . '/../app/config/config.neon');
}
if (file_exists(__DIR__ . '/config/config.neon')) {
    $configurator->addConfig(__DIR__ . '/config/config.neon');
}
if (file_exists(__DIR__ . '/config/config.local.neon')) {
    $configurator->addConfig(__DIR__ . '/config/config.local.neon');
}
$container = $configurator->createContainer();
return $container;
Esempio n. 11
0
<?php

require __DIR__ . '/../vendor/autoload.php';
$configurator = new Nette\Configurator();
$configurator->enableDebugger(__DIR__ . '/../log');
$configurator->setTempDirectory(__DIR__ . '/../temp');
$configurator->createRobotLoader()->addDirectory(__DIR__)->register();
$configurator->addParameters(['cipherKey' => 'PleaseChangeMe']);
$configurator->addConfig(__DIR__ . '/config/config.neon');
$container = $configurator->createContainer();
return $container;
Esempio n. 12
0
$libsDir = $rootDir . '/vendor';
$wwwDir = $rootDir . '/www';
$appDir = $rootDir . '/app';
$packagesDir = $rootDir . '/.venne.packages';
if (!file_exists($packagesDir)) {
    if (is_writable(dirname($packagesDir))) {
        mkdir($packagesDir);
    } else {
        die("Path '{$packagesDir}' does not exists.");
    }
}
if (!is_writable($packagesDir)) {
    die("Path '{$packagesDir}' it not writable.");
}
foreach (array('log', 'temp') as $dir) {
    if (!file_exists($packagesDir . '/' . $dir)) {
        mkdir($packagesDir . '/' . $dir);
    }
}
if (!file_exists($libsDir . '/autoload.php')) {
    die('autoload.php file can not be found.');
}
require_once $libsDir . '/autoload.php';
$configurator = new Nette\Configurator();
$configurator->addParameters(array('appDir' => $appDir, 'wwwDir' => $wwwDir));
//$configurator->setDebugMode(TRUE);  // debug mode MUST NOT be enabled on production server
$configurator->enableDebugger($packagesDir . '/log');
$configurator->setTempDirectory($packagesDir . '/temp');
$configurator->addConfig(dirname(__DIR__) . '/config/config.neon');
$container = $configurator->createContainer();
$container->getService('application')->run();
Esempio n. 13
0
        break;
    case "peknyden.cz":
    case "www.peknyden.cz":
        $environment = "production";
        break;
    default:
        $environment = "development";
        break;
}
$configurator->addConfig(__DIR__ . '/config/config.neon', $environment);
$configurator->onCompile[] = function ($configurator, $compiler) {
    $compiler->addExtension('dibi', new DibiNette21Extension());
};
$detect = new Mobile_Detect();
//$configurator->addParameters(array("isMobile" => $detect->isMobile()));
$configurator->addParameters(array("isMobile" => false));
/* @var $container \SystemContainer */
$container = $configurator->createContainer();
dibi::connect($container->parameters['database']);
// addDynamic / Replicator
\Kdyby\Replicator\Container::register();
// DatePicker.php registration
Container::extensionMethod('addDatePicker', function (\Nette\Forms\Container $container, $name, $label = NULL) {
    return $container[$name] = new \JanTvrdik\Components\DatePicker($label);
});
// TimePicker.php registration
Container::extensionMethod('addTimePicker', function (\Nette\Forms\Container $container, $name, $label = NULL) {
    return $container[$name] = new \soundake\Components\TimePicker($label);
});
// SuggestInput registration
Nette\Forms\Form::extensionMethod('Nette\\Forms\\Form::addSuggestInput', 'Nette\\Addons\\SuggestInput::addSuggestInput');
Esempio n. 14
0
<?php

require __DIR__ . '/../vendor/autoload.php';
$configurator = new Nette\Configurator();
//$configurator->setDebugMode('23.75.345.200'); // enable for your remote IP
$configurator->enableDebugger(__DIR__ . '/../log');
$configurator->setTempDirectory(__DIR__ . '/../temp');
$configurator->createRobotLoader()->addDirectory(__DIR__)->register();
$configurator->addConfig(__DIR__ . '/config/config.neon');
$configurator->addParameters(require __DIR__ . "/../../config.php");
$container = $configurator->createContainer();
return $container;
Esempio n. 15
0
<?php

require __DIR__ . '/../vendor/autoload.php';
use Tracy\Debugger;
$configurator = new Nette\Configurator();
//$configurator->setDebugMode('23.75.345.200'); // enable for your remote IP
$configurator->enableDebugger(__DIR__ . '/../log');
$configurator->setTempDirectory(__DIR__ . '/../temp');
$configurator->createRobotLoader()->addDirectory(__DIR__)->addDirectory(MODEL_DIR)->register();
//
// enable debugger
//
Debugger::enable(IS_PRODUCTION);
$configurator->setDebugMode(TRUE);
Debugger::$strictMode = FALSE;
$configurator->addParameters(array('generatedDir' => GENERATED_DIR));
$configurator->addConfig(__DIR__ . '/config/config.neon');
$configurator->addConfig(__DIR__ . '/config/config.local.neon');
$container = $configurator->createContainer();
\App\BackendModule\Grids\Boolean::register();
return $container;
Esempio n. 16
0
<?php

//TODO: test pro AOP, jestli jsou všechny \Model\ třídy zabezpečeny v aspektu...
require __DIR__ . '/../vendor/autoload.php';
if (!class_exists('Tester\\Assert')) {
    echo "Install Nette Tester using `composer update --dev`\n";
    exit(1);
}
Tester\Environment::setup();
date_default_timezone_set('Europe/Prague');
$configurator = new Nette\Configurator();
$configurator->setTempDirectory(__DIR__ . '/../temp');
$loader = $configurator->createRobotLoader()->addDirectory(__DIR__ . '/../app')->addDirectory(__DIR__ . '/../libs')->addDirectory(__DIR__ . '/../tests')->register();
define("WWW_DIR", __DIR__ . '/../www');
$configurator->addConfig(__DIR__ . '/../app/config/config.neon');
$configurator->addConfig(__DIR__ . '/../app/config/config.local.neon');
$configurator->addParameters(['wwwDir' => __DIR__ . '/../www']);
//because of %wwwDir% in config in CLI environment
$container = $configurator->createContainer();
return $container;
Esempio n. 17
0
<?php

require __DIR__ . '/../vendor/autoload.php';
umask(00);
$configurator = new Nette\Configurator();
$configurator->setDebugMode(FALSE);
// debug mode MUST NOT be enabled on production server
$configurator->enableDebugger(__DIR__ . '/../log');
$configurator->setTempDirectory(__DIR__ . '/../temp');
$configurator->createRobotLoader()->addDirectory(__DIR__)->addDirectory(__DIR__ . '/../vendor/others')->register();
$configurator->addParameters(array('vendorDir' => realpath(__DIR__ . '/../vendor')));
$configurator->addConfig(__DIR__ . '/config/_config.neon');
$configurator->addConfig($configurator->isDebugMode() ? __DIR__ . '/config/_dev.neon' : __DIR__ . '/config/_prod.neon');
$configurator->addConfig(__DIR__ . '/config/_config.local.neon');
$container = $configurator->createContainer();
return $container;