本文整理汇总了PHP中Nette\DI\Container::expand方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::expand方法的具体用法?PHP Container::expand怎么用?PHP Container::expand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\DI\Container
的用法示例。
在下文中一共展示了Container::expand方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param \Nette\DI\Container
* @param array
*/
public function __construct(DI\Container $context, array $configuration = array())
{
$this->context = $context;
$this->configuration = \Nette\Utils\Arrays::mergeTree(array(
'productionMode' => $context->params['productionMode'],
'proxyDir' => $context->expand("%appDir%/proxies"),
'proxyNamespace' => 'App\Models\Proxies',
'entityDirs' => array($context->params['appDir'], NELLA_FRAMEWORK_DIR),
'migrations' => array(
'name' => \Nella\Framework::NAME . " DB Migrations",
'table' => "db_version",
'directory' => $context->expand("%appDir%/migrations"),
'namespace' => 'App\Models\Migrations',
)
), $configuration);
}
示例2: getAllClasses
/**
* @param \Venne\Module\IModule $module
* @return array
* @throws \Exception
*/
protected function getAllClasses()
{
// find files
$robotLoader = new \Nette\Loaders\RobotLoader();
$robotLoader->setCacheStorage(new \Nette\Caching\Storages\MemoryStorage());
foreach ($this->context->parameters['modules'] as $name => $item) {
if ($item[ModuleManager::MODULE_STATUS] === ModuleManager::STATUS_INSTALLED) {
$path = $this->context->expand($item[ModuleManager::MODULE_PATH]) . '/' . ucfirst($name) . 'Module';
if (file_exists($path)) {
$robotLoader->addDirectory($path);
}
}
}
$robotLoader->register();
$entities = $robotLoader->getIndexedClasses();
// classes
$classes = array();
foreach ($entities as $class => $item) {
if (\Nette\Reflection\ClassType::from('\\' . $class)->hasAnnotation('ORM\\Entity')) {
$classes[] = $class;
}
}
$robotLoader->unregister();
return $classes;
}
示例3: __construct
/**
* @param Container $container
* @param EntityManager $entityManager
*/
public function __construct(Container $container, EntityManager $entityManager)
{
parent::__construct('dwarfSearch:import');
$this->entityManager = $entityManager;
$this->seasonsRepository = $entityManager->getRepository(Season::class);
$this->episodesRepository = $entityManager->getRepository(Episode::class);
$this->languagesRepository = $entityManager->getRepository(Language::class);
$this->charactersRepository = $entityManager->getRepository(Character::class);
$this->scenariosDir = $container->expand('%appDir%/../scenarios');
}
示例4: validate
protected function validate(InputInterface $input, OutputInterface $output)
{
if (!in_array($this->outputFormat = trim($input->getOption('output-format'), '='), $formats = $this->writer->getFormats(), TRUE)) {
$output->writeln('<error>Unknown --output-format</error>');
$output->writeln(sprintf("<info>Choose one of: %s</info>", implode(', ', $formats)));
return FALSE;
}
$this->scanDirs = $this->serviceLocator->expand($input->getOption('scan-dir'));
foreach ($this->scanDirs as $dir) {
if (!is_dir($dir)) {
$output->writeln(sprintf('<error>Given --scan-dir "%s" does not exists.</error>', $dir));
return FALSE;
}
}
if (!is_dir($this->outputDir = $this->serviceLocator->expand($input->getOption('output-dir'))) || !is_writable($this->outputDir)) {
$output->writeln(sprintf('<error>Given --output-dir "%s" does not exists or is not writable.</error>', $this->outputDir));
return FALSE;
}
return TRUE;
}
示例5: getModulesForUnregister
/**
* @return array
*/
protected function getModulesForUnregister()
{
$ret = array();
foreach ($this->modules as $name => $args) {
$path = $this->context->expand($args[self::MODULE_PATH]);
if (!file_exists($path)) {
$ret[$name] = $args;
}
}
return $ret;
}
示例6: boot
public function boot(Nette\DI\Container $container, $databaseName)
{
$this->windows = array();
$this->waitForSeleniumSlot();
$this->serviceLocator = $container;
TesterHelpers::setup();
// ensure error & exception helpers are registered
$this->httpServer = new HttpServer();
$env = (array) $this->options[self::OPTION_ENV_VARIABLES] + array($this->options[self::OPTION_ENV_PREFIX] . '_DEBUG' => '0', $this->options[self::OPTION_ENV_PREFIX] . '_SELENIUM' => '1', $this->options[self::OPTION_ENV_PREFIX] . '_DATABASE' => $databaseName, $this->options[self::OPTION_ENV_PREFIX] . '_LOG_DIR' => TEMP_DIR, $this->options[self::OPTION_ENV_PREFIX] . '_TEMP_DIR' => TEMP_DIR);
$this->httpServer->start($this->serviceLocator->expand($this->options[self::OPTION_ROUTER]), $env);
$httpRequest = new Nette\Http\Request($this->httpServer->getUrl(), array(), array(), array(), array(), array(), 'GET');
$this->serviceLocator->removeService('httpRequest');
$this->serviceLocator->addService('httpRequest', $httpRequest);
$this->sessionFactory = new SessionFactory($this->serviceLocator, $this->httpServer, $this->options);
$this->currentSession = $this->sessionFactory->create();
$this->currentSession->setContext($this);
$this->windows[] = $this->currentSession;
if ($this->options[self::OPTION_VIDEO_ENABLE]) {
$this->videoRecorder = new VideoRecorder(TEMP_DIR);
$this->videoRecorder->start();
}
}
示例7: preloadEnvironment
public static function preloadEnvironment(DI\Container $container)
{
$code = '';
$dir = $container->expand('%tempDir%/cache');
umask(00);
@mkdir($dir, 0777);
// @ - directory may exists
// checks whether directory is writable
$uniq = uniqid('_', TRUE);
umask(00);
if (!@mkdir("{$dir}/{$uniq}", 0777)) {
// @ - is escalated to exception
throw new Nette\InvalidStateException("Unable to write to directory '{$dir}'. Make this directory writable.");
}
// tests subdirectory mode
$useDirs = @file_put_contents("{$dir}/{$uniq}/_", '') !== FALSE;
// @ - error is expected
@unlink("{$dir}/{$uniq}/_");
@rmdir("{$dir}/{$uniq}");
// @ - directory may not already exist
$code .= self::generateCode('Nette\\Caching\\Storages\\FileStorage::$useDirectories = ?', $useDirs);
return $code;
}
示例8: preloadEnvironment
static function preloadEnvironment(DI\Container $container)
{
$code = '';
$dir = $container->expand('%tempDir%/cache');
umask(00);
@mkdir($dir, 0777);
$uniq = uniqid('_', TRUE);
umask(00);
if (!@mkdir("{$dir}/{$uniq}", 0777)) {
throw new Nette\InvalidStateException("Unable to write to directory '{$dir}'. Make this directory writable.");
}
$useDirs = @file_put_contents("{$dir}/{$uniq}/_", '') !== FALSE;
@unlink("{$dir}/{$uniq}/_");
@rmdir("{$dir}/{$uniq}");
$code .= self::generateCode('Nette\\Caching\\Storages\\FileStorage::$useDirectories = ?', $useDirs);
return $code;
}