PHPonTrax
[ class tree: PHPonTrax ] [ index: PHPonTrax ] [ all elements ]

Class: TraxGenerator

Source Location: /vendor/trax/trax_generator.php

Class Overview


Generate application files in the Trax work area


Variables

Methods



Class Details

[line 44]
Generate application files in the Trax work area

Implements the commands of script/generate.php <p>Legal commands:</p>




[ Top ]


Class Variables

$controller_class =

[line 135]

CamelCase name of the controller class



Tags:

usedby:  TraxGenerator::create_view() - Must be set before call. Not changed during call.
usedby:  TraxGenerator::create_helper() - Must be set before call. Not changed during call.
usedby:  TraxGenerator::create_controller() - Must be set before call. Not changed during call.
usedby:  TraxGenerator::generate_controller() - Set during call
access:  private

Type:   string


[ Top ]

$controller_path =

[line 56]

Filesystem path to the app/controllers directory in the Trax work area



Tags:

usedby:  TraxGenerator::generate_controller() - Must be set before call.
usedby:  TraxGenerator::create_controller() - Must be set before call. Not changed during call.
usedby:  TraxGenerator::__construct()
access:  private

Type:   string


[ Top ]

$controller_template_file =

[line 89]

Filesystem path to the templates/controller.php file



Tags:

usedby:  TraxGenerator::create_controller() - Must be set before call. Not changed during call.
usedby:  TraxGenerator::__construct()
access:  private

Type:   string


[ Top ]

$extra_path =

[line 77]

Generated subdirectories in the Trax work area

When a controller is generated with a name that includes '/', $extra_path is set to the implied subdirectories.




Tags:

usedby:  TraxGenerator::generate_controller() - Set during call
access:  private

Type:   string


[ Top ]

$helper_path =

[line 62]

Filesystem path to the app/helpers directory in the Trax work area



Tags:

usedby:  TraxGenerator::generate_controller() - Must be set before call.
usedby:  TraxGenerator::create_helper() - Must be set before call. Not changed during call.
usedby:  TraxGenerator::__construct()
access:  private

Type:   string


[ Top ]

$helper_template_file =

[line 95]

Filesystem path to the templates/helper.php file



Tags:

usedby:  TraxGenerator::create_helper() - Must be set before call. Not changed during call.
usedby:  TraxGenerator::__construct()
access:  private

Type:   string


[ Top ]

$layouts_path =

[line 120]

Filesystem path to the app/views/layouts/ directory in the

Trax work area




Tags:

usedby:  TraxGenerator::__construct()
usedby:  TraxGenerator::generate_controller() - Must be set before call.
access:  private

Type:   string


[ Top ]

$layout_filename =

[line 129]



Tags:

usedby:  TraxGenerator::generate_scaffold() - Set as output from generate_controller(). Not changed afterward.
usedby:  TraxGenerator::generate_controller() - Set during call
access:  private
todo:  

Document this variable

Value is set by generate_controller() and used by generate_scaffold()


Type:   string


[ Top ]

$mkdir_cmd =

[line 83]

Platform-dependent command to make a directory



Tags:

access:  private

Type:   string


[ Top ]

$model_path =

[line 68]

Filesystem path to the app/model directory in the Trax work area



Tags:

usedby:  TraxGenerator::generate_model() - Must be set before call. Not changed during call.
usedby:  TraxGenerator::__construct()
access:  private

Type:   string


[ Top ]

$model_template_file =

[line 107]

Filesystem path to the templates/model.php file



Tags:

usedby:  TraxGenerator::generate_model() - Must be set before call. Not changed during call.
usedby:  TraxGenerator::__construct()
access:  private

Type:   string


[ Top ]

$scaffold_template_path =

[line 113]

Filesystem path to templates/scaffolds/generator_templates directory



Tags:

usedby:  TraxGenerator::__construct()
access:  private

Type:   string


[ Top ]

$view_file_extention =  TRAX_VIEWS_EXTENTION

[line 141]

Value of the view files extension (usually '.phtml')



Tags:

access:  public

Type:   string


[ Top ]

$view_path =

[line 50]

Filesystem path to the app/views directory in the Trax work area



Tags:

usedby:  TraxGenerator::generate_controller() - Must be set before call.
usedby:  TraxGenerator::create_view() - Must be set before call. Not changed during call.
usedby:  TraxGenerator::__construct()
access:  private

Type:   string


[ Top ]

$view_template_file =

[line 101]

Filesystem path to the templates/view.phtml file



Tags:

usedby:  TraxGenerator::create_view() - Must be set before call. Not changed during call.
usedby:  TraxGenerator::__construct()
access:  private

Type:   string


[ Top ]



Class Methods


constructor __construct [line 163]

TraxGenerator __construct( )

Constructor for the TraxGenerator object

Compute and store filesystem paths to the various subdirectories of the Trax work area and the template files used to generate application files




Tags:



[ Top ]

method controller_help [line 800]

void controller_help( )

Output console help message for "generate controller"



Tags:



[ Top ]

method create_controller [line 647]

void create_controller( string $controller, [string[] $views = ""])

Create a controller file with optional view methods



Tags:

usedby:  TraxGenerator::generate_controller()
todo:  Should return succeed/fail indication
uses:  TraxGenerator::$controller_template_file - Must be set before call. Not changed during call.
uses:  TraxGenerator::$controller_path - Must be set before call. Not changed during call.
uses:  TraxGenerator::$controller_class - Must be set before call. Not changed during call.


Parameters:

string   $controller   Name of the controller
string[]   $views   Name(s) of view(s), if any

[ Top ]

method create_helper [line 707]

void create_helper( string $controller)

Create a helper file for a controller



Tags:

usedby:  TraxGenerator::generate_controller()
todo:  Should return succeed/fail indication
uses:  TraxGenerator::$helper_template_file - Must be set before call. Not changed during call.
uses:  TraxGenerator::$helper_path - Must be set before call. Not changed during call.
uses:  TraxGenerator::$controller_class - Must be set before call. Not changed during call.


Parameters:

string   $controller   Name of the controller

[ Top ]

method create_view [line 749]

void create_view( string $view, string $controller)

Create a view file if it doesn't exist

Create a view file in the Trax work area if the required file does not yet exist. Generate the view file contents by customizing the view template file with information about the controller and view names.




Tags:

todo:  Should return succeed/fail indication
usedby:  TraxGenerator::generate_controller()
uses:  TraxGenerator::$view_template_file - Must be set before call. Not changed during call.
uses:  TraxGenerator::$view_path - Must be set before call. Not changed during call.
uses:  view_file_extension - Must be set before call. Not changed during call.
uses:  TraxGenerator::$controller_class - Must be set before call. Not changed during call.


Parameters:

string   $view   Name of the view
string   $controller   Name of the controller

[ Top ]

method exec [line 778]

void exec( string $cmd)

Execute an operating system command



Tags:

todo:  Replace with calls to filesystem methods


Parameters:

string   $cmd   Command to be executed

[ Top ]

method fix_php_brackets [line 792]

string fix_php_brackets( string $string)

Replace "< ?php ... ? >" with "<?php ... ?>"



Tags:

return:  Edited input string
usedby:  TraxGenerator::generate_scaffold()


Parameters:

string   $string   String to be edited

[ Top ]

method generate_controller [line 329]

void generate_controller( string $name, [string $views = ""], [boolean $scaffolding = false])

Implement "generate controller" command

Example:
php script/generate.php controller SomeName
will generate:

  • a file app/controllers/some_name_controller.php
    containing the class definition
    class SomeNameController extends ApplicationController {}
  • a file app/helpers/some_name_helper.php
  • a directory app/views/some_name
Optionally, one or more views can be appended to the command:
php script/generate.php controller SomeName view1 view2
which will additionally generate files:
app/views/some_name/view1.phtml
app/views/some_name/view2.phtml




Tags:

uses:  TraxGenerator::$layout_filename - Set during call
uses:  TraxGenerator::$layouts_path - Must be set before call.
uses:  TraxGenerator::$view_path - Must be set before call.
usedby:  TraxGenerator::run()
usedby:  TraxGenerator::generate_scaffold()
uses:  TraxGenerator::$helper_path - Must be set before call.
uses:  TraxGenerator::$extra_path - Set during call
uses:  TraxGenerator::$controller_path - Must be set before call.
uses:  TraxGenerator::$controller_class - Set during call
uses:  TraxGenerator::create_controller()
uses:  TraxGenerator::create_helper()
uses:  TraxGenerator::create_view()
uses:  Inflector::underscore()


Parameters:

string   $name   Name in CamelCase of the controller to generate. The value may include '/' which will cause creation of subdirectories indicated to hold the controller and view files.
string   $views   Optional list of views to generate
boolean   $scaffolding  

[ Top ]

method generate_model [line 407]

void generate_model( string $name)

Implement the "generate model" command

Example:
php script/generate.php model SomeName
will generate a file app/models/some_name.php
containing the class definition
class SomeName extends ActiveRecord {}




Tags:

usedby:  TraxGenerator::generate_scaffold()
usedby:  TraxGenerator::run()
uses:  TraxGenerator::$model_template_file - Must be set before call. Not changed during call.
uses:  TraxGenerator::$model_path - Must be set before call. Not changed during call.
uses:  Inflector::underscore()


Parameters:

string   $name   Name of the model. May be in either under_score or CamelCase. If no '_' exists in $name it is treated as CamelCase.

[ Top ]

method generate_scaffold [line 455]

void generate_scaffold( string $model_name, string $controller_name, [string $views = ""])

Implement the "generate scaffold" command



Tags:



Parameters:

string   $model_name  
string   $controller_name  
string   $views  

[ Top ]

method generator_help [line 874]

void generator_help( )

Output console help message for unrecognized command



Tags:



[ Top ]

method model_help [line 828]

void model_help( )

Output console help message for "generate model"



Tags:



[ Top ]

method run [line 204]

void run( )

Parse command line and carry out the command

Command line arguments, if any are in $_SERVER['argv']




Tags:



[ Top ]

method scaffold_help [line 844]

void scaffold_help( )

Output console help message for "generate scaffold"



Tags:



[ Top ]


Documentation generated on Thu, 04 May 2006 19:48:03 -0600 by phpDocumentor 1.3.0RC4