getValue() public static method

If value does not exist it will return empty array.
public static getValue ( ) : mixed
return mixed
示例#1
0
文件: Stats.php 项目: letsdrink/ouzo
 public static function trace($query, $params, $function)
 {
     if (Config::getValue('debug')) {
         return self::traceNoCheck($query, $params, $function);
     }
     return $function();
 }
示例#2
0
 private function generateModel()
 {
     $tableName = $this->input->getArgument('table');
     $className = $this->input->getOption('class');
     $fileName = $this->input->getOption('file');
     $nameSpace = $this->input->getOption('namespace');
     $tablePrefixToRemove = $this->input->getOption('remove-prefix') ?: 't';
     $shortArrays = $this->input->getOption('short-arrays');
     if (empty($tableName)) {
         $this->fail("Specify table name e.g. users");
     }
     try {
         $modelGenerator = new Generator($tableName, $className, $nameSpace, $tablePrefixToRemove, $shortArrays);
         $this->output->writeln('---------------------------------');
         $this->writeInfo('Database name: <info>%s</info>', Config::getValue('db', 'dbname'));
         $this->writeInfo('Class name: <info>%s</info>', $modelGenerator->getTemplateClassName());
         $this->writeInfo('Class namespace: <info>%s</info>', $modelGenerator->getClassNamespace());
         $this->output->writeln('---------------------------------');
         $this->output->writeln($modelGenerator->templateContents());
         $this->output->writeln('---------------------------------');
         if ($fileName) {
             $this->saveClassToFile($modelGenerator, $fileName);
         } else {
             $classFileName = ClassPathResolver::forClassAndNamespace($modelGenerator->getTemplateClassName(), $modelGenerator->getClassNamespace())->getClassFileName();
             $this->saveClassToFile($modelGenerator, $classFileName);
         }
     } catch (GeneratorException $e) {
         $this->fail($e->getMessage());
     }
 }
示例#3
0
文件: Logger.php 项目: letsdrink/ouzo
 private static function _loadLogger($name, $configuration)
 {
     $logger = Config::getValue('logger', $configuration);
     if (!$logger || !isset($logger['class'])) {
         return new SyslogLogger($name, $configuration);
     }
     return new $logger['class']($name, $configuration);
 }
示例#4
0
 public function setUp()
 {
     $driver = Config::getValue('db', 'driver');
     if ($driver == 'sqlite') {
         $this->markTestSkipped('This test is not for SQLite database.');
     }
     parent::setUp();
 }
示例#5
0
 private function initialize(Twig_Environment $environment)
 {
     $initializerClass = Config::getValue('twig', 'initializer');
     if ($initializerClass) {
         $initializer = new $initializerClass();
         $initializer->initialize($environment);
     }
 }
示例#6
0
 /**
  * @return void
  */
 private function registerErrorHandlers()
 {
     if (Config::getValue('debug')) {
         $handler = new DebugErrorHandler();
     } else {
         $handler = new ErrorHandler();
     }
     $handler->register();
 }
示例#7
0
 /**
  * @test
  */
 public function shouldCreateCorrectUrlWithExtraParams()
 {
     //given
     $defaults = Config::getValue('global');
     //when
     $url = ControllerUrl::createUrl(array('controller' => 'users', 'action' => 'add', 'extraParams' => array('id' => 5, 'name' => 'john')));
     //then
     $this->assertEquals($defaults['prefix_system'] . '/users/add/id/5/name/john', $url);
 }
示例#8
0
文件: Db.php 项目: letsdrink/ouzo
 public function __construct($loadDefault = true)
 {
     if ($loadDefault) {
         $configDb = Config::getValue('db');
         if (!empty($configDb)) {
             $this->connectDb($configDb);
         }
     }
 }
示例#9
0
 private static function _setSavePath()
 {
     $path = Config::getValue('session', 'path');
     if ($path) {
         if (!is_dir($path)) {
             mkdir($path, 0700, true);
         }
         session_save_path($path);
     }
 }
示例#10
0
文件: Error.php 项目: letsdrink/ouzo
 public static function forException(Exception $exception)
 {
     if (Config::getValue('debug')) {
         return new Error($exception->getCode(), self::_classNameAndMessage($exception));
     }
     if ($exception instanceof UserException) {
         return new Error($exception->getCode(), $exception->getMessage());
     }
     return new Error($exception->getCode(), I18n::t('exception.unknown'), $exception->getMessage());
 }
示例#11
0
function addFile(array $fileInfo = array(), $stringToRemove = '')
{
    if (!empty($fileInfo)) {
        $prefixSystem = Config::getValue('global', 'prefix_system');
        $suffixCache = Config::getValue('global', 'suffix_cache');
        $suffixCache = !empty($suffixCache) ? '?' . $suffixCache : '';
        $url = $prefixSystem . $fileInfo['params']['url'] . $suffixCache;
        $url = Strings::remove($url, $stringToRemove);
        return _getHtmlFileTag($fileInfo['type'], $url);
    }
    return null;
}
示例#12
0
 /**
  * @test
  */
 public function shouldResolveAction()
 {
     //given
     $routeRule = new RouteRule('GET', '/simple_test/action1', 'simple_test', 'action1', false);
     $factory = $this->injector->getInstance('\\Ouzo\\ControllerFactory');
     $config = Config::getValue('global');
     $_SERVER['REQUEST_URI'] = "{$config['prefix_system']}/simple_test/action1";
     //when
     $currentController = $factory->createController($routeRule);
     //then
     $this->assertEquals('action1', $currentController->currentAction);
 }
示例#13
0
 /**
  * @test
  */
 public function shouldReturnObjectForConfiguredDialect()
 {
     //given
     $generator = new Generator('products');
     //when
     $templateDialect = $generator->dialectAdapter();
     //then
     $configuredDialectClassPath = Config::getValue('sql_dialect');
     $dialectReflectionClass = new ReflectionClass($templateDialect);
     $generatorDialectClassName = $dialectReflectionClass->getShortName();
     $this->assertStringEndsWith($generatorDialectClassName, $configuredDialectClassPath);
 }
示例#14
0
 /**
  * @return Dialect
  * @throws Exception
  */
 public static function create()
 {
     $dialectClass = Config::getValue('sql_dialect');
     if (!$dialectClass) {
         throw new Exception('SQL dialect was not found in config. Please, check for option - sql_dialect.');
     }
     $dialectClass = new $dialectClass();
     if (!$dialectClass instanceof Dialect) {
         throw new Exception('Invalid sql_dialect. Dialect have to extend Dialect class.');
     }
     return $dialectClass;
 }
示例#15
0
 public static function create($viewName, $attributes)
 {
     $rendererClass = Config::getValue('renderer', $viewName);
     if ($rendererClass) {
         return new $rendererClass($viewName, $attributes);
     }
     $rendererClass = Config::getValue('renderer', 'default');
     if ($rendererClass) {
         return new $rendererClass($viewName, $attributes);
     }
     return new PhtmlRenderer($viewName, $attributes);
 }
示例#16
0
    private function createFunction(RouteRule $routeRule)
    {
        $applicationPrefix = Config::getValue("global", "prefix_system");
        $name = $routeRule->getName();
        $uri = $routeRule->getUri();
        $uriWithVariables = preg_replace('/:(\\w+)/', '" + $1 + "', $uri);
        $parameters = $this->prepareParameters($uri);
        $parametersString = implode(', ', $parameters);
        $checkParametersStatement = $this->createCheckParameters($parameters);
        $function = <<<FUNCTION
function {$name}({$parametersString}) {
{$checkParametersStatement}return "{$applicationPrefix}{$uriWithVariables}";
}


FUNCTION;
        return $name ? $function : '';
    }
示例#17
0
 private static function _createUrlFromArray($params)
 {
     $prefixSystem = Config::getValue('global', 'prefix_system');
     $controller = Arrays::getValue($params, 'controller');
     $action = Arrays::getValue($params, 'action');
     $extraParams = Arrays::getValue($params, 'extraParams');
     if ($controller && $action) {
         $url = Joiner::on('/')->join(array($prefixSystem, $controller, $action));
         if ($extraParams) {
             $url .= self::_mergeParams($extraParams);
         }
         return $url;
     }
     $string = Arrays::getValue($params, 'string');
     if ($string) {
         return $prefixSystem . $string;
     }
     throw new InvalidArgumentException('Illegal arguments');
 }
示例#18
0
 private static function shouldWrap($viewName)
 {
     return Config::getValue('debug') && !self::isJavaScriptView($viewName);
 }
示例#19
0
 private static function _prefixSystem()
 {
     return Config::getValue('global', 'prefix_system');
 }
示例#20
0
 public static function getLayoutPath()
 {
     $controllerPath = Config::getValue('path', 'layout');
     return $controllerPath ? $controllerPath : Path::join('Application', 'Layout');
 }
示例#21
0
 private function _logRequestIfDebugEnabled()
 {
     if (Config::getValue('debug')) {
         Stats::traceHttpRequest($this->currentControllerObject->params);
     }
 }
示例#22
0
 public static function add($name, $path)
 {
     $prefixSystem = Config::getValue('global', 'prefix_system');
     $pathWithoutPrefix = $prefixSystem ? Strings::removePrefix($path, $prefixSystem) : $path;
     self::$breadcrumbsMap[] = new self($name, $pathWithoutPrefix);
 }
示例#23
0
 /**
  * @test
  */
 public function shouldClearProperty()
 {
     // given
     Config::overrideProperty('key_to_clear')->with('value');
     // when
     Config::clearProperty('key_to_clear');
     // then
     $value = Config::getValue('key_to_clear');
     $this->assertEmpty($value);
 }
示例#24
0
 public static function getWidgetNamespace()
 {
     $controllerPath = Config::getValue('namespace', 'widget');
     return $controllerPath ? $controllerPath : "\\Application\\Widget\\";
 }
示例#25
0
文件: Route.php 项目: letsdrink/ouzo
    }
    private static function createRouteAction($controller, $action)
    {
        return $controller . '#' . $action;
    }
    /**
     * @return RouteRule[]
     */
    public static function getRoutes()
    {
        return self::$routes;
    }
    public static function getRoutesForController($controller)
    {
        return Arrays::filter(self::getRoutes(), function (RouteRule $route) use($controller) {
            return Strings::equalsIgnoreCase($route->getController(), $controller);
        });
    }
    public static function group($name, $routeFunction)
    {
        GroupedRoute::setGroupName($name);
        $routeFunction();
    }
    public static function clear()
    {
        self::$routes = array();
        self::$routeKeys = array();
    }
}
Route::$isDebug = Config::getValue('debug');
示例#26
0
 /**
  * @test
  */
 public function shouldThrowOnBatchInsert()
 {
     //given
     $previous = Config::getValue('sql_dialect');
     Config::overrideProperty('sql_dialect')->with('Ouzo\\Db\\Dialect\\MySqlDialect');
     $inserter = new BatchInserter();
     $inserter->add(new Product(array('name' => 'product1')));
     //when
     CatchException::when($inserter)->execute();
     //then
     CatchException::assertThat()->hasMessage("Batch insert not supported in mysql")->isInstanceOf('InvalidArgumentException');
     Config::overrideProperty('sql_dialect')->with($previous);
 }
示例#27
0
 public function __construct($language, $labels)
 {
     $this->_labels = $labels;
     $this->language = $language;
     $this->pseudoLocalizationEnabled = Config::getValue('pseudo_localization') ? true : false;
 }
示例#28
0
文件: Uri.php 项目: letsdrink/ouzo
 public static function addPrefixIfNeeded($url)
 {
     $prefix = Config::getValue('global', 'prefix_system');
     $url = Strings::removePrefix($url, $prefix);
     return $prefix . $url;
 }
示例#29
0
文件: I18n.php 项目: letsdrink/ouzo
 private static function getLanguage()
 {
     return Config::getValue('language') ?: I18n::DEFAULT_LANGUAGE;
 }
示例#30
0
 /**
  * @test
  */
 public function shouldAddCacheSuffix()
 {
     //given
     $defaults = Config::getValue('global');
     //when
     $expected = '<script type="text/javascript" src="' . $defaults['prefix_system'] . '/public/js/test.js?' . $defaults['suffix_cache'] . '"></script>' . PHP_EOL;
     $actual = addFile(array('type' => 'script', 'params' => array('url' => '/public/js/test.js')));
     //then
     $this->assertEquals($expected, $actual);
 }