Example #1
0
 public function testGetConfigValueWithInValidKey()
 {
     $mockConfigValues = ["key1" => "val2"];
     $path = $this->getMockPath();
     $mockConfigFileName = "mockConfigFile";
     $this->saveMockConfig($path . "/{$mockConfigFileName}.php", $mockConfigValues);
     $this->config->setConfigRoot($path);
     $val1 = $this->config->get("{$mockConfigFileName}-invalid.key1");
     $this->assertSame(null, $val1);
 }
 /**
  * Create a new Controller instance.
  */
 public function __construct()
 {
     // Setup the used Template to default, if it is not already defined.
     if (!isset($this->template)) {
         $this->template = Config::get('app.template');
     }
 }
Example #3
0
 /**
  * Initializes, only the 1st instance, the static $customFields for this entity.
  * 
  * @return void
  */
 public function __construct()
 {
     if (!empty(self::$customFieldsConfig)) {
         return;
     }
     $config = Config::get('custom_fields');
     self::$customFieldsConfig = $config[self::CUSTOM_FIELDS_CONFIG_KEY];
 }
 /**
  * Create a new URL Generator instance.
  *
  * @param  \Routing\RouteCollection  $routes
  * @param  \Symfony\Component\HttpFoundation\Request   $request
  * @return void
  */
 public function __construct(RouteCollection $routes, Request $request)
 {
     $this->routes = $routes;
     $this->setRequest($request);
     // Wheter or not are used the Unnamed Parameters.
     if ('unnamed' == Config::get('routing.parameters', 'named')) {
         $this->legacyRouting = true;
     }
 }
 public static function process($fetch = false)
 {
     $config = Config::get('profiler');
     if ($config['useForensics'] != true) {
         return null;
     }
     // The QuickProfiller was enabled into Configuration.
     $profiler = new static();
     return $profiler->display($fetch);
 }
 /**
  * Static method get
  *
  * @param  array $group
  * @return Helpers\Database
  */
 public static function get($name = null)
 {
     $name = $name ?: Config::get('database.default');
     // Check if the instance is the same.
     if (isset(self::$instances[$name])) {
         return self::$instances[$name];
     }
     // Set the Database into $instances to avoid any potential duplication.
     return self::$instances[$name] = new static($name);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $error = false;
     $path = Config::get('cache.path', 'app/Storage/Cache');
     if (!is_dir($path)) {
         $output->writeln("<error>Cache directory does not exist. path: {$path}</>");
         $error = true;
     }
     self::cleanCache($path);
     $output->writeln("<info>Cache directory has been cleaned. path: {$path}</>");
 }
 /**
  * Change the Framework Language.
  */
 public function change($language)
 {
     $languages = Config::get('languages');
     // Only set language if it's in the Languages array
     if (preg_match('/[a-z]/', $language) && in_array($language, array_keys($languages))) {
         Session::set('language', $language);
         // Store the current Language in a Cookie lasting five years.
         Cookie::queue(PREFIX . 'language', $language, Cookie::FIVEYEARS);
     }
     return Redirect::back();
 }
 /**
  * Register the Assets Dispatcher.
  */
 public function registerAssetsDispatcher()
 {
     // NOTE: When this method is executed, the Config Store is not yet available.
     $driver = Config::get('routing.assets.driver', 'default');
     if ($driver == 'custom') {
         $className = Config::get('routing.assets.dispatcher');
     } else {
         $className = 'Routing\\Assets\\' . ucfirst($driver) . 'Dispatcher';
     }
     // Bind the calculated class name to the Assets Dispatcher Interface.
     $this->app->bind('Routing\\Assets\\DispatcherInterface', $className);
 }
 public function index($token)
 {
     if ($this->token != $token) {
         return Response::make('', 403);
         // Error 403 (Access denied)
     }
     // Get the execution date and time as translated string.
     $format = __d('system', '%d %b %Y, %R');
     $date = Carbon::now()->formatLocalized($format);
     // Execute the CRON tasks.
     $result = $this->executeCron();
     // Create the page information.
     $title = __d('system', '{0} - Cron executed on {1}', Config::get('app.name'), $date);
     return $this->getView()->with('title', $title)->with('content', $result);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $error = false;
     $path = Config::get('session.files', 'app/Storage/Sessions');
     if ($input->getArgument('lifeTime')) {
         $lifeTime = $input->getArgument('lifeTime');
     } else {
         $lifeTime = Config::get('session.lifetime', 180);
     }
     if (!is_dir($path)) {
         $output->writeln("<error>Session directory does not exist. path: {$path}</>");
         $error = true;
     }
     self::clearSessions($path, $lifeTime);
     $output->writeln("<info>The sessions have been cleared. Lifetime: {$lifeTime}, path: {$path}</>");
 }
 public static function getReport()
 {
     $options = Config::get('profiler');
     // Calculate the variables.
     $execTime = microtime(true) - HttpRequest::server('REQUEST_TIME_FLOAT');
     $elapsedTime = sprintf("%01.4f", $execTime);
     $memoryUsage = Number::humanSize(memory_get_usage());
     if ($options['withDatabase'] == true) {
         $connection = DB::connection();
         $queries = $connection->getQueryLog();
         $totalQueries = count($queries);
         $queriesStr = $totalQueries == 1 ? __d('nova', 'query') : __d('nova', 'queries');
     } else {
         $totalQueries = 0;
         $queriesStr = __d('nova', 'queries');
     }
     $estimatedUsers = sprintf("%0d", intval(25 / $execTime));
     //
     $retval = __d('nova', 'Elapsed Time: <b>{0}</b> sec | Memory Usage: <b>{1}</b> | SQL: <b>{2}</b> {3} | UMAX: <b>{4}</b>', $elapsedTime, $memoryUsage, $totalQueries, $queriesStr, $estimatedUsers);
     return $retval;
 }
Example #13
0
 /**
  * Create the absolute address to the template folder.
  *
  * @param  boolean $custom
  * @return string url to template folder
  */
 public static function templatePath($custom = TEMPLATE, $folder = '/assets/')
 {
     $template = Inflector::tableize($custom);
     return Config::get('app.url') . 'templates/' . $template . $folder;
 }
Example #14
0
<?php

/**
 * Created by PhpStorm.
 * User: Jarne
 * Date: 07.08.16
 * Time: 17:24
 */
require_once "../vendor/autoload.php";
require_once "../src/Config/Config.php";
use Config\Config;
$config = new Config("test.yml");
var_dump($config->get("whats.the.value"));
Example #15
0
<?php

use config\Config;
use components\Helper;
?>

<a href="<?php 
echo Helper::generateUrl(Config::get('defaultController'), Config::get('mainViewAction'), ['code' => $options['code'], 'userName' => $options['userName']]);
?>
"><< Back to user</a>
 /**
  *
  */
 public function followsAction()
 {
     $code = Helper::requestGet('code', null);
     $userName = Helper::requestGet('userName', null);
     if ($userName) {
         $token = $this->getTokenByCode($code);
         $this->instagram->setAccessToken($token);
         $search = $this->instagram->searchUser($userName, self::COUNT_SEARCH_USER);
         $this->hasError($search);
         if ($search->meta->code == self::SUCCESS_RESPONSE && !empty($search->data)) {
             $userId = current($search->data)->id;
             $data = $this->instagram->getUserFollows($userId, self::COUNT_FOLLOWS_DATA);
             $this->hasError($data);
             if ($data->meta->code == self::SUCCESS_RESPONSE && !empty($data->data)) {
                 $media = $data->data;
                 $options = ['c' => Config::get('defaultController'), 'a' => 'follows', 'code' => $code, 'userName' => $userName];
                 Helper::renderStatic('main/follows', compact('media', 'options'));
                 exit;
             }
         }
     }
 }
 /**
  * Serve a File.
  *
  * @param string $path
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function serve($path, SymfonyRequest $request)
 {
     if (!file_exists($path)) {
         return new Response('File Not Found', 404);
     } else {
         if (!is_readable($path)) {
             return new Response('Unauthorized Access', 403);
         }
     }
     // Collect the current file information.
     $guesser = MimeTypeGuesser::getInstance();
     // Even the Symfony's HTTP Foundation have troubles with the CSS and JS files?
     //
     // Hard coding the correct mime types for presently needed file extensions.
     switch ($fileExt = pathinfo($path, PATHINFO_EXTENSION)) {
         case 'css':
             $contentType = 'text/css';
             break;
         case 'js':
             $contentType = 'application/javascript';
             break;
         default:
             $contentType = $guesser->guess($path);
             break;
     }
     if ($contentType == 'application/javascript' || str_is('text/*', $contentType)) {
         $response = $this->createFileResponse($path, $request);
     } else {
         $response = $this->createBinaryFileResponse($path);
     }
     // Set the Content type.
     $response->headers->set('Content-Type', $contentType);
     // Set the Cache Control.
     $cacheTime = Config::get('routing.assets.cacheTime', 10800);
     $response->setTtl(600);
     $response->setMaxAge($cacheTime);
     $response->setSharedMaxAge(600);
     // Prepare against the Request instance.
     $response->isNotModified($request);
     return $response;
 }
 /**
  * Site URL helper
  * @param string $path
  * @return string
  */
 function site_url($path = '/')
 {
     // The base URL.
     $siteUrl = Config::get('app.url');
     return $siteUrl . ltrim($path, '/');
 }
 /**
  * Configures error handling behavior
  * 
  * @param string $onErrorBehavior          Controls how to react to errors. 
  * Optional, defaults to null. {@see self::$_onErrorBehavior}
  * @param bool   $onErrorDisplayExceptions Define if displays exceptions when 
  * an error ocurred.
  * 
  * @return void
  */
 private static function _loadErrorConfig($onErrorBehavior = null, $onErrorDisplayExceptions = null)
 {
     $onError = Config::get('on_error');
     if (null === self::$_onErrorBehavior) {
         self::$_onErrorBehavior = null !== $onErrorBehavior ? $onErrorBehavior : $onError['behavior'];
     }
     if (null === self::$_onErrorBehavior) {
         self::$_onErrorDisplayExceptions = null !== $onErrorDisplayExceptions ? $onErrorDisplayExceptions : $onError['display_exceptions'];
     }
 }
 public function setCurrentProject()
 {
     $sheets = Config::get('sheets');
     $this->currentProject = $sheets[$this->sheet]['records'][$this->record]['project_id'];
     ini_set('xdebug.var_display_max_data', '99999');
 }
 /**
  * Load the Configuration Group for the key.
  *
  * @param    string     $group
  * @return     array
  */
 public function load($group)
 {
     return Config::get($group, array());
 }
<?php

use config\Config;
use components\Init;
use components\Helper;
error_reporting(E_ALL);
ini_set('display_errors', 'on');
// main loaders
include '../loader.php';
$code = isset($_GET['code']) ? $_GET['code'] : null;
// save token value for using in future
$saveToken = (new Init())->setToken($code);
// if token success saved - welcome to main view page!
if ($saveToken) {
    Helper::redirect(Config::get('defaultController'), Config::get('mainViewAction'), compact('code'));
}
exit;
 /**
  * Find the View file.
  *
  * @param    string     $view
  * @param    string     $template
  * @return    string
  */
 protected function find($view, $template = null)
 {
     // Calculate the current Template name.
     $template = $template ?: Config::get('app.template');
     // Calculate the search path.
     $path = sprintf('Templates/%s/%s', $template, $view);
     // Make the path absolute and adjust the directory separator.
     $path = str_replace('/', DS, APPDIR . $path);
     // Find the View file depending on the Language direction.
     $language = $this->getLanguage();
     if ($language->direction() == 'rtl') {
         // Search for the View file used on the RTL languages.
         $filePath = $this->finder->find($path . '-rtl');
     } else {
         $filePath = null;
     }
     if (is_null($filePath)) {
         $filePath = $this->finder->find($path);
     }
     if (!is_null($filePath)) {
         return $filePath;
     }
     throw new \InvalidArgumentException("Unable to load the view '" . $view . "' on template '" . $template . "'.", 1);
 }
 public function __construct()
 {
     $this->config = Config::get('recaptcha', array());
 }