Backend\Modules\Extensions\Engine\Model::existsModule PHP Method

existsModule() public static method

This does not check for existence in the database but on the filesystem.
public static existsModule ( string $module ) : boolean
$module string Module to check for existence.
return boolean
    public static function existsModule($module)
    {
        return is_dir(BACKEND_MODULES_PATH . '/' . (string) $module);
    }

Usage Example

Example #1
0
 /**
  * Validate the form
  */
 protected function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $this->frm->cleanupFields();
         // validation
         $fields = $this->frm->getFields();
         $fields['title']->isFilled(Language::err('TitleIsRequired'));
         $fields['description']->isFilled(Language::err('FieldIsRequired'));
         $fields['author_name']->isFilled(Language::err('FieldIsRequired'));
         $fields['author_url']->isFilled(Language::err('FieldIsRequired'));
         $fields['author_email']->isFilled(Language::err('FieldIsRequired'));
         // cleanup the modulename
         $title = preg_replace('/[^A-Za-z ]/', '', $fields['title']->getValue());
         // check if there is already a module with this name
         if (BackendExtensionsModel::existsModule($title)) {
             $fields['title']->addError(Language::err('DuplicateModuleName'));
         }
         if ($this->frm->isCorrect()) {
             $this->record['title'] = $title;
             $this->record['description'] = trim($fields['description']->getValue());
             $this->record['author_name'] = $fields['author_name']->getValue();
             $this->record['author_url'] = $fields['author_url']->getValue();
             $this->record['author_email'] = $fields['author_email']->getValue();
             $this->record['camel_case_name'] = BackendModuleMakerHelper::buildCamelCasedName($title);
             $this->record['underscored_name'] = BackendModuleMakerHelper::buildUnderscoredName($title);
             \SpoonSession::set('module', $this->record);
             $this->redirect(Model::createURLForAction('AddStep2'));
         }
     }
 }
All Usage Examples Of Backend\Modules\Extensions\Engine\Model::existsModule