getRequire() public static method

Get the returned value of a file.
public static getRequire ( string $path ) : mixed
$path string
return mixed
Example #1
0
 /**
  * Funcao para edicao da config do [Modulo]
  * @param string $controller Nome do controlador
  * @return void
  */
 public function getFile($controller)
 {
     // $this->logic->_getConfigFiles();
     // Busca o arquivo especificado
     $cfg_file = mkny_model_config_path($controller) . '.php';
     // Field types
     $f_types = array_unique(array_values(app()->make('Mkny\\Cinimod\\Logic\\AppLogic')->_getFieldTypes()));
     // Se o diretorio nao existir
     if (!realpath(dirname($cfg_file))) {
         \File::makeDirectory(dirname($cfg_file));
     }
     // Config file data
     if (!\File::exists($cfg_file)) {
         $stub = \File::get(__DIR__ . '/../Commands/stubs/model_config.stub');
         \Mkny\Cinimod\Logic\UtilLogic::translateStub(array('var_fields_data' => ''), $stub);
         \File::put($cfg_file, $stub);
     }
     // Config file data
     $config_str = \File::getRequire($cfg_file)['fields'];
     // Pula o primeiro indice
     // array_shift($config_str);
     $valOrder = 1;
     // Fornece o tipo "types" para todos os campos, para selecao
     foreach ($config_str as $key => $value) {
         if (!is_array($config_str[$key])) {
             $config_str[$key] = array();
         }
         $config_str[$key]['name'] = $key;
         $config_str[$key]['type'] = isset($value['type']) ? $value['type'] : 'string';
         $config_str[$key]['form_add'] = isset($value['form_add']) ? $value['form_add'] : true;
         $config_str[$key]['form_edit'] = isset($value['form_edit']) ? $value['form_edit'] : true;
         $config_str[$key]['grid'] = isset($value['grid']) ? $value['grid'] : true;
         $config_str[$key]['relationship'] = isset($value['relationship']) ? $value['relationship'] : false;
         $config_str[$key]['required'] = isset($value['required']) ? $value['required'] : false;
         $config_str[$key]['searchable'] = isset($value['searchable']) ? $value['searchable'] : false;
         $config_str[$key]['order'] = isset($value['order']) ? $value['order'] : $valOrder++;
         $config_str[$key]['types'] = array_combine($f_types, $f_types);
     }
     if (isset(array_values($config_str)[1]['order'])) {
         usort($config_str, function ($dt, $db) {
             if (!isset($db['order'])) {
                 $db['order'] = 0;
             }
             if (isset($dt['order'])) {
                 return $dt['order'] - $db['order'];
             } else {
                 return 0;
             }
         });
         $newConfig = [];
         foreach ($config_str as $sortfix) {
             $newConfig[$sortfix['name']] = $sortfix;
         }
         $config_str = $newConfig;
     }
     $data['controller'] = $controller;
     $data['data'] = $config_str;
     return view('cinimod::admin.generator.config_detailed_new')->with($data);
     // return view('cinimod::admin.generator.config_detailed')->with($data);
 }
Example #2
0
 public function getFile($lang = false, $module = false)
 {
     // dd(view()->shared('controller'));
     // app('request')->attributes->get('controller');
     if (!$lang) {
         $lang = \App::getLocale();
     }
     // Busca o arquivo especificado
     $cfg_file = mkny_lang_path($lang . '/' . $module) . '.php';
     // Field types
     $f_types = array_unique(array_values(app()->make('Mkny\\Cinimod\\Logic\\AppLogic')->_getFieldTypes()));
     // Se o diretorio nao existir
     if (!realpath(dirname($cfg_file))) {
         \File::makeDirectory(dirname($cfg_file));
     }
     // Config file data
     if (!\File::exists($cfg_file)) {
         \File::put($cfg_file, "<?php return array( 'teste' => 'teste' );");
     }
     // Arquivo aberto
     $config_str = \File::getRequire($cfg_file);
     $arrFields = array();
     foreach ($config_str as $field_name => $field_value) {
         if (!is_string($field_value)) {
             $arrFields[$field_name] = array('name' => $field_name, 'trans' => $field_name, 'values' => $field_value, 'type' => 'multi');
         } else {
             $arrFields[$field_name] = array('name' => $field_name, 'trans' => $field_name, 'default_value' => $field_value, 'type' => 'string');
         }
     }
     return view('cinimod::admin.generator.trans_detailed')->with(['form' => app()->make('\\Mkny\\Cinimod\\Logic\\FormLogic', [['fields-default-class' => 'form-control']])->getForm(false, action('\\' . get_class($this) . '@postFile', [$lang, $module]), $arrFields, $module)]);
 }
Example #3
0
 /**
  * load mhvc file
  */
 protected function setConfig($path, array $data)
 {
     $conf = \File::getRequire($path);
     $this->controller = $conf['controller'];
     $this->attr = array_key_exists('attr', $conf) ? $conf['attr'] : array();
     // overwrite attr in file hmvc ?
     $this->attr = array_merge($this->attr, $data);
     $this->action = array_key_exists('action', $conf) ? $conf['action'] : 'index';
 }
Example #4
0
 public static function updateConfigFile($file, $data)
 {
     // String do arquivo
     $arrConfigFileData = \File::getRequire($file);
     $config_new = array_except($data, array('_token'));
     // $config_new = array_only($data, array_merge(array_keys($arrConfigFileData),array('new_fields')));
     if (isset($config_new['new_fields'])) {
         $nf = $config_new['new_fields'];
         foreach ($nf as $n_field) {
             $config_new[$n_field['name']] = $n_field;
         }
         unset($config_new['new_fields']);
     }
     // Resultado gerado
     $arrCamposData = array_replace_recursive(isset($arrConfigFileData['fields']) ? $arrConfigFileData['fields'] : $arrConfigFileData, $config_new);
     // $arrCamposData = array_replace_recursive($arrConfigFileData['fields'], $config_new);
     // Tratamento do true / false
     foreach ($arrCamposData as $key => $value) {
         if (is_array($value)) {
             foreach ($value as $vKey => $vValue) {
                 if (in_array($vKey, array('order'))) {
                     continue;
                 }
                 if ($vValue == '0' || $vValue === false) {
                     // Forca false
                     $vValue = false;
                 } elseif ($vValue == '1' || $vValue === true) {
                     // Forca true
                     $vValue = true;
                 }
                 // Adiciona o valor no novo array
                 $arrCamposData[$key][$vKey] = $vValue;
             }
         }
     }
     if (isset($arrConfigFileData['fields'])) {
         $arrConfigFileData['fields'] = $arrCamposData;
     } else {
         $arrConfigFileData = $arrCamposData;
     }
     // $arrConfigFileData = isset($arrConfigFileData['fields']) ? ['fields' => $arrCamposData]:$arrCamposData;
     // mdd($arrConfigFileData);
     // mdd($arrCamposData);
     // $arrConfigFileData = isset($arrConfigFileData['fields']) ? ['fields' => $arrCamposData]:$arrCamposData;;
     // Monta a string corretamente para gravar
     $string = '<?php return ' . var_export($arrConfigFileData, true) . ';';
     // Grava no arquivo
     return \File::put($file, $string);
 }
 /**
  * http://localhost/debug/index
  *
  * @return String
  */
 public function getIndex()
 {
     echo '<pre>';
     echo '<h1>environment.php</h1>';
     $path = base_path() . '/environment.php';
     try {
         $contents = 'Contents: ' . File::getRequire($path);
         $exists = 'Yes';
     } catch (Exception $e) {
         $exists = 'No. Defaulting to `production`';
         $contents = '';
     }
     echo "Checking for: " . $path . '<br>';
     echo 'Exists: ' . $exists . '<br>';
     echo $contents;
     echo '<br>';
     echo '<h1>Environment</h1>';
     echo App::environment() . '</h1>';
     echo '<h1>Debugging?</h1>';
     if (Config::get('app.debug')) {
         echo "Yes";
     } else {
         echo "No";
     }
     echo '<h1>Database Config</h1>';
     print_r(Config::get('database.connections.mysql'));
     echo '<h1>Test Database Connection</h1>';
     try {
         $results = DB::select('SHOW DATABASES;');
         echo '<strong style="background-color:green; padding:5px;">Connection confirmed</strong>';
         echo "<br><br>Your Databases:<br><br>";
         print_r($results);
     } catch (Exception $e) {
         echo '<strong style="background-color:crimson; padding:5px;">Caught exception: ', $e->getMessage(), "</strong>\n";
     }
     echo '</pre>';
 }
Example #6
0
 public function getTranslation(Request $request, $type = null)
 {
     if (!is_null($request->input('edit'))) {
         $file = !is_null($request->input('file')) ? $request->input('file') : 'core.php';
         $files = scandir(base_path() . "/resources/lang/" . $request->input('edit') . "/");
         //$str = serialize(file_get_contents('./protected/app/lang/'.$request->input('edit').'/core.php'));
         $str = \File::getRequire(base_path() . "/resources/lang/" . $request->input('edit') . '/' . $file);
         $this->data = array('pageTitle' => 'Help Manual', 'pageNote' => 'Documentation', 'stringLang' => $str, 'lang' => $request->input('edit'), 'files' => $files, 'file' => $file);
         $template = 'edit';
     } else {
         $this->data = array('pageTitle' => 'Help Manual', 'pageNote' => 'Documentation');
         $template = 'index';
     }
     return view('sximo.config.translation.' . $template, $this->data);
 }
Example #7
0
 public function getTranslation($type = null)
 {
     if (!is_null(Input::get('edit'))) {
         $file = !is_null(Input::get('file')) ? Input::get('file') : 'core.php';
         $files = scandir('./protected/app/lang/' . Input::get('edit') . '/');
         //$str = serialize(file_get_contents('./protected/app/lang/'.Input::get('edit').'/core.php'));
         $str = File::getRequire(base_path() . '/app/lang/' . Input::get('edit') . '/' . $file);
         //	$arr = unserialize($str);
         //	echo '<pre>';print_r($str);echo '</pre>';
         $this->data = array('pageTitle' => 'Help Manual', 'pageNote' => 'Documentation', 'stringLang' => $str, 'lang' => Input::get('edit'), 'files' => $files, 'file' => $file);
         $template = 'edit';
     } else {
         $this->data = array('pageTitle' => 'Help Manual', 'pageNote' => 'Documentation');
         $template = 'index';
     }
     $this->layout->nest('content', 'admin.config.translation.' . $template, $this->data)->with('menus', $this->menus);
 }
Example #8
0
<?php

// resources/lang/ja/validation.php
$label = File::getRequire(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'labels.php');
return ['accepted' => ':attributeを承認してください。', 'active_url' => ':attributeは正しいURLではありません。', 'after' => ':attributeは:date以降の日付にしてください。', 'alpha' => ':attributeは英字のみにしてください。', 'alpha_dash' => ':attributeは英数字とハイフンのみにしてください。', 'alpha_num' => ':attributeは英数字のみにしてください。', 'array' => ':attributeは配列にしてください。', 'before' => ':attributeは:date以前の日付にしてください。', 'between' => ['numeric' => ':attributeは:min〜:maxの範囲で入力してください。', 'file' => ':attributeは:min〜:max KBまでのファイルにしてください。', 'string' => ':attributeは:min〜:max文字にしてください。', 'array' => ':attributeは:min〜:max個までにしてください。'], 'boolean' => ':attributeはtrueかfalseにしてください。', 'confirmed' => ':attributeは確認用項目と一致していません。', 'date' => ':attributeは正しい日付ではありません。', 'date_format' => ':attributeが":format"書式と一致していません。', 'different' => ':attributeは:otherと違うものにしてください。', 'digits' => ':attributeは:digits桁にしてください', 'digits_between' => ':attributeは:min〜:max桁にしてください。', 'email' => ':attributeを正しいメールアドレスにしてください。', 'filled' => ':attributeは必須です。', 'exists' => '選択された:attributeは正しくありません。', 'image' => ':attributeは画像にしてください。', 'in' => '選択された:attributeは正しくありません。', 'integer' => ':attributeは整数にしてください。', 'ip' => ':attributeを正しいIPアドレスにしてください。', 'max' => ['numeric' => ':attributeは:max以下にしてください。', 'file' => ':attributeは:max KB以下のファイルにしてください。.', 'string' => ':attributeは:max文字以下にしてください。', 'array' => ':attributeは:max個以下にしてください。'], 'mimes' => ':attributeは:valuesタイプのファイルにしてください。', 'min' => ['numeric' => ':attributeは:min以上にしてください。', 'file' => ':attributeは:min KB以上のファイルにしてください。.', 'string' => ':attributeは:min文字以上にしてください。', 'array' => ':attributeは:min個以上にしてください。'], 'not_in' => '選択された:attributeは正しくありません。', 'numeric' => ':attributeは数字にしてください。', 'regex' => ':attributeの書式が正しくありません。', 'required' => ':attributeは必須です。', 'required_if' => ':otherが:valueの時、:attributeは必須です。', 'required_with' => ':valuesが存在する時、:attributeは必須です。', 'required_with_all' => ':valuesが存在する時、:attributeは必須です。', 'required_without' => ':valuesが存在しない時、:attributeは必須です。', 'required_without_all' => ':valuesが存在しない時、:attributeは必須です。', 'same' => ':attributeと:otherは一致していません。', 'size' => ['numeric' => ':attributeは:sizeにしてください。', 'file' => ':attributeは:size KBにしてください。.', 'string' => ':attribute:size文字にしてください。', 'array' => ':attributeは:size個にしてください。'], 'string' => ':attributeは文字列にしてください。', 'timezone' => ':attributeは正しいタイムゾーンをしていしてください。', 'unique' => ':attributeは既に存在します。', 'url' => ':attributeを正しい書式にしてください。', 'custom' => ['属性名' => ['ルール名' => 'カスタムメッセージ']], 'attributes' => $label + ['category_ids' => $label['category'], 'crop_id' => $label['crop'], 'crop_ids' => $label['crop'], 'field_ids' => $label['work_field'], 'work_diary_ids' => $label['work_diary'], 'datetime_input' => $label['datetime'], 'pesticide_id' => $label['pesticide_name'], 'work_id' => $label['work_content'], 'cultivar_id' => $label['cultivar']]];
Example #9
0
 public static function SendSms($to, $template)
 {
     $fileUrl = public_path() . "/packages/twilio/Services/Twilio.php";
     File::getRequire($fileUrl);
     //check if number contain + at start. if not concatenate
     $check_num = substr($to, 0, 1);
     if ($check_num !== '+') {
         $to = '+' . $to;
     }
     //set your AccountSid and AuthToken from www.twilio.com/user/account
     $AccountSid = "AC091be30fb3a12b4da6540a7ebacb420b";
     $AuthToken = "f430bbbc0a6433dfa00e18330cf6bda3";
     $client = new Services_Twilio($AccountSid, $AuthToken);
     try {
         $message = $client->account->messages->create(array("From" => "+12407725261", "To" => $to, "Body" => $template));
     } catch (Services_Twilio_RestException $e) {
         $e->getMessage();
     }
 }