示例#1
0
 public static function scaffold($app, $model, $controller)
 {
     self::try_define('APP', $app);
     self::try_define('CONTROLLER', $controller);
     if (moojon_routes::has_rest_route($model)) {
         $route = moojon_routes::get_rest_route($model);
         if (APP != $route->get_app()) {
             throw new moojon_exception("Scaffold app & route app must be the same (" . APP . ' != ' . $route->get_app() . ")");
         }
         $id_property = $route->get_id_property();
     } else {
         $id_property = moojon_primary_key::NAME;
         self::add_route("new moojon_rest_route('{$model}', array('app' => '" . APP . "')),");
     }
     $swaps = array();
     $swaps['plural'] = moojon_inflect::pluralize($model);
     $swaps['singular'] = moojon_inflect::singularize($model);
     $swaps['Human'] = str_replace('_', ' ', ucfirst(moojon_inflect::singularize($model)));
     $swaps['human'] = str_replace('_', ' ', moojon_inflect::singularize($model));
     $swaps['Humans'] = str_replace('_', ' ', ucfirst(moojon_inflect::pluralize($model)));
     $swaps['humans'] = str_replace('_', ' ', moojon_inflect::pluralize($model));
     $swaps['id_property'] = $id_property;
     $views_path = moojon_paths::get_project_views_app_controller_directory(APP, CONTROLLER);
     moojon_files::attempt_mkdir($views_path);
     self::run(moojon_paths::get_moojon_templates_scaffolds_directory() . 'controller.template', moojon_paths::get_project_controllers_app_directory(APP, CONTROLLER) . "{$controller}.controller.class.php", $swaps, false, true);
     self::run(moojon_paths::get_moojon_templates_scaffolds_directory() . '_form.template', $views_path . '_form.php', $swaps, false, true);
     self::run(moojon_paths::get_moojon_templates_scaffolds_directory() . 'new.view.template', $views_path . 'new.view.php', $swaps, false, true);
     self::run(moojon_paths::get_moojon_templates_scaffolds_directory() . 'delete.view.template', $views_path . 'delete.view.php', $swaps, false, true);
     self::run(moojon_paths::get_moojon_templates_scaffolds_directory() . 'index.view.template', $views_path . 'index.view.php', $swaps, false, true);
     self::run(moojon_paths::get_moojon_templates_scaffolds_directory() . 'show.view.template', $views_path . 'show.view.php', $swaps, false, true);
     self::run(moojon_paths::get_moojon_templates_scaffolds_directory() . 'edit.view.template', $views_path . 'edit.view.php', $swaps, false, true);
 }
示例#2
0
 public static function get_actions()
 {
     $data = self::get_data();
     require_once moojon_paths::get_controller_path($data['app'], $data['controller']);
     $actions = get_class_methods(self::get_controller_class($data['controller']));
     $paths = array(moojon_paths::get_moojon_views_directory(), moojon_paths::get_moojon_views_app_directory(moojon_uri::get_app()), moojon_paths::get_moojon_views_app_controller_directory(moojon_uri::get_app(), moojon_uri::get_controller()), moojon_paths::get_project_views_directory(), moojon_paths::get_project_views_app_directory(moojon_uri::get_app()), moojon_paths::get_project_views_app_controller_directory(moojon_uri::get_app(), moojon_uri::get_controller()));
     foreach (self::colate_view($paths) as $view) {
         if (!in_array($actions, $view)) {
             $actions[] = $view;
         }
     }
     return $actions;
 }