コード例 #1
0
ファイル: TemplatesManager.php プロジェクト: devisephp/cms
 /**
  * Validate and store a new variable for a given template path
  *
  * @param  string  $templatePath
  * @param  array   $input
  * @return bool
  */
 public function storeNewVariable($templatePath, $input)
 {
     $validator = $this->Validator->make($input, $this->createVarRules(), $this->messages);
     $copyVar = isset($input['copy_var']) && $input['copy_var'] !== '0' ? $input['copy_var'] : false;
     if ($copyVar || $validator->passes()) {
         $configContents = $this->ConfigFileManager->getAppOnly('devise.templates');
         if ($copyVar) {
             $configContents = $this->copyExistingVariable($configContents, $templatePath, $copyVar);
         } else {
             $configContents = $this->addNewVariable($configContents, $templatePath, $input);
         }
         return $this->ConfigFileManager->saveToFile($configContents, 'templates');
     }
     $this->errors = $validator->errors()->all();
     return false;
 }
コード例 #2
0
ファイル: PageManager.php プロジェクト: devisephp/cms
 /**
  * [isValidInputForNewPage description]
  * @param  [type]  $input
  * @return boolean
  */
 protected function isValidInputForNewPage($input)
 {
     // validate the input given before we create the page
     $this->validator = $this->Validator->make($input, $this->Page->createRules, $this->Page->messages);
     $fails = $this->validator->fails();
     if ($fails) {
         $this->errors = $this->validator->errors()->all();
         $this->message = "There were validation errors.";
     }
     // check to make sure that there is no duplicate slug/method out there
     $duplicatePage = $this->Page->where('http_verb', $input['http_verb'])->where('slug', $input['slug'])->first();
     if ($duplicatePage) {
         $this->errors = $this->validator->errors()->all();
         $this->errors['slug'] = 'There is already a page with this slug/verb pair';
         $this->message = "There were validation errors.";
     }
     return count($this->errors) == 0;
 }
コード例 #3
0
ファイル: PermissionsManager.php プロジェクト: devisephp/cms
 /**
  * Validates and updates a permission with the given input
  *
  * @param  string  $condition  Unique key from permissions config
  * @param  array   $input
  * @return bool
  */
 public function updatePermission($input)
 {
     $validator = $this->Validator->make($input, $this->updateRules(), $this->messages);
     if ($validator->passes()) {
         if (isset($input[$input['permission_name_edit']])) {
             $this->cleanInput($input[$input['permission_name_edit']]);
             $configContents = $this->ConfigFileManager->getAppOnly('devise.permissions');
             if ($input['permission_name'] != $input['permission_name_edit']) {
                 unset($configContents[$input['permission_name']]);
             }
             $this->includeRedirect($input, $input[$input['permission_name_edit']]);
             $configContents[$input['permission_name_edit']] = $input[$input['permission_name_edit']];
             return $this->ConfigFileManager->saveToFile($configContents, 'permissions');
         }
         $this->errors[] = 'At least 1 rule must be present to save the condition.';
         return false;
     }
     $this->errors = $validator->errors()->all();
     return false;
 }