getValue() public static méthode

If value does not exist it will return empty array.
public static getValue ( ) : mixed
Résultat mixed
Exemple #1
0
 public static function trace($query, $params, $function)
 {
     if (Config::getValue('debug')) {
         return self::traceNoCheck($query, $params, $function);
     }
     return $function();
 }
 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());
     }
 }
Exemple #3
0
 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);
 }
Exemple #4
0
 public function setUp()
 {
     $driver = Config::getValue('db', 'driver');
     if ($driver == 'sqlite') {
         $this->markTestSkipped('This test is not for SQLite database.');
     }
     parent::setUp();
 }
Exemple #5
0
 private function initialize(Twig_Environment $environment)
 {
     $initializerClass = Config::getValue('twig', 'initializer');
     if ($initializerClass) {
         $initializer = new $initializerClass();
         $initializer->initialize($environment);
     }
 }
Exemple #6
0
 /**
  * @return void
  */
 private function registerErrorHandlers()
 {
     if (Config::getValue('debug')) {
         $handler = new DebugErrorHandler();
     } else {
         $handler = new ErrorHandler();
     }
     $handler->register();
 }
Exemple #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);
 }
Exemple #8
0
 public function __construct($loadDefault = true)
 {
     if ($loadDefault) {
         $configDb = Config::getValue('db');
         if (!empty($configDb)) {
             $this->connectDb($configDb);
         }
     }
 }
Exemple #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);
     }
 }
Exemple #10
0
 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());
 }
Exemple #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;
}
 /**
  * @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);
 }
Exemple #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);
 }
Exemple #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;
 }
 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);
 }
    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 : '';
    }
Exemple #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');
 }
Exemple #18
0
 private static function shouldWrap($viewName)
 {
     return Config::getValue('debug') && !self::isJavaScriptView($viewName);
 }
Exemple #19
0
 private static function _prefixSystem()
 {
     return Config::getValue('global', 'prefix_system');
 }
Exemple #20
0
 public static function getLayoutPath()
 {
     $controllerPath = Config::getValue('path', 'layout');
     return $controllerPath ? $controllerPath : Path::join('Application', 'Layout');
 }
Exemple #21
0
 private function _logRequestIfDebugEnabled()
 {
     if (Config::getValue('debug')) {
         Stats::traceHttpRequest($this->currentControllerObject->params);
     }
 }
 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);
 }
Exemple #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);
 }
Exemple #24
0
 public static function getWidgetNamespace()
 {
     $controllerPath = Config::getValue('namespace', 'widget');
     return $controllerPath ? $controllerPath : "\\Application\\Widget\\";
 }
Exemple #25
0
    }
    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');
Exemple #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);
 }
Exemple #27
0
 public function __construct($language, $labels)
 {
     $this->_labels = $labels;
     $this->language = $language;
     $this->pseudoLocalizationEnabled = Config::getValue('pseudo_localization') ? true : false;
 }
Exemple #28
0
 public static function addPrefixIfNeeded($url)
 {
     $prefix = Config::getValue('global', 'prefix_system');
     $url = Strings::removePrefix($url, $prefix);
     return $prefix . $url;
 }
Exemple #29
0
 private static function getLanguage()
 {
     return Config::getValue('language') ?: I18n::DEFAULT_LANGUAGE;
 }
Exemple #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);
 }