2021-02-09 14:16:16 +01:00
|
|
|
<?php
|
|
|
|
|
2021-04-19 16:23:22 +02:00
|
|
|
namespace MVC\Command\Sand;
|
2021-02-10 14:16:03 +01:00
|
|
|
/**
|
|
|
|
* Class Action
|
|
|
|
* Commande Système du Framework permettant de gérer les actions
|
2021-04-19 16:23:22 +02:00
|
|
|
* @package MVC\Command\Sand
|
2021-02-10 14:16:03 +01:00
|
|
|
*/
|
2021-02-09 14:16:16 +01:00
|
|
|
class Action
|
|
|
|
{
|
2021-02-10 14:16:03 +01:00
|
|
|
/**
|
|
|
|
* Méthode permettant d'afficher l'aide de la commande
|
|
|
|
*/
|
2021-02-09 14:16:16 +01:00
|
|
|
public static function help()
|
|
|
|
{
|
2021-02-10 13:56:18 +01:00
|
|
|
print "Cette commande permet de manipuler les actions du framework\n\n";
|
|
|
|
print "Elle peut accepter les attributs suivants\n";
|
|
|
|
print "\t- add : pour ajouter une action\n";
|
2021-02-09 14:16:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function add()
|
|
|
|
{
|
|
|
|
print "adding action...\n\n";
|
|
|
|
print "Quel est le nom de l'action a ajouter? ";
|
|
|
|
$action = trim(fgets(STDIN));
|
|
|
|
|
|
|
|
|
|
|
|
$shell_controlleur = shell_exec('cp ' . CONSOLE_PATH . '/skel/action.php.skel ' . ACTION_PATH . '/' . ucfirst($action) . 'Action.php');
|
|
|
|
$controlleur = file_get_contents(CONTROLLERS_PATH . '/' . ucfirst($action) . 'Action.php');
|
|
|
|
$controlleur = preg_replace('%%ACTION%%', ucfirst($action), $controlleur);
|
|
|
|
file_put_contents(CONTROLLERS_PATH . '/' . ucfirst($action) . 'Action.php', $controlleur);
|
|
|
|
print $shell_controlleur;
|
|
|
|
}
|
|
|
|
}
|