app\helpers\RequestParams::post PHP Method

post() public method

public post ( $name )
    public function post($name)
    {
        return $this->postParamData[$name];
    }

Usage Example

Example #1
0
 public function doAdd($req, $res)
 {
     $params = new RequestParams($req);
     $name = $params->post('name');
     $sys_name = $params->post('system_name');
     $desc = $params->post('description');
     $version = $params->post('version');
     $author = $params->post('author');
     $sys_name = preg_replace("/[^A-Za-z0-9_]/", "", $sys_name);
     if (!$sys_name) {
         $this->flash->addMessage('errors', 'Module system_name is empty!');
         return $res->withStatus(301)->withHeader('Location', $this->router->pathFor('developers.module.generator'));
     }
     $sys_name = Str::studly($sys_name);
     if (is_dir(MODULE_PATH . $sys_name)) {
         $this->flash->addMessage('errors', 'Module exist!');
         return $res->withStatus(301)->withHeader('Location', $this->router->pathFor('developers.module.generator'));
     }
     $path = MODULE_PATH . $sys_name;
     if (!Helpers::copy(MODULE_PATH . '.default', $path)) {
         $this->flash->addMessage('errors', 'Module dir \\"' . MODULE_PATH . '\\" - is write protect. Check permissions!');
         return $res->withStatus(301)->withHeader('Location', $this->router->pathFor('developers.module.generator'));
     }
     $ret = Helpers::replaseInFile($path . '/info.json', ["%name%", "%description%", "%system_name%", "%version%", "%author%"], [$name, $desc, $sys_name, $version, $author]);
     if ($ret === false) {
         $this->flash->addMessage('errors', 'Replace file content for \\"' . $path . '/info.json' . '\\" - is write protect. Check permissions!');
         return $res->withStatus(301)->withHeader('Location', $this->router->pathFor('developers.module.generator'));
     }
     $ret = Helpers::replaseInFile($path . '/Module.php', ["%system_name%"], [$sys_name]);
     if ($ret === false) {
         $this->flash->addMessage('errors', 'Replace file content for \\"' . $path . '/Module.php' . '\\" - is write protect. Check permissions!');
         return $res->withStatus(301)->withHeader('Location', $this->router->pathFor('developers.module.generator'));
     }
     $this->flash->addMessage('success', 'Module create!');
     return $res->withStatus(301)->withHeader('Location', $this->router->pathFor('developers.module.generator'));
 }
All Usage Examples Of app\helpers\RequestParams::post