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:

access:  private
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

Type:   string


[ Top ]

$controller_path =

[line 56]

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



Tags:

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

Type:   string


[ Top ]

$controller_template_file =

[line 89]

Filesystem path to the templates/controller.php file



Tags:

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

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:

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

Type:   string


[ Top ]

$helper_path =

[line 62]

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



Tags:

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

Type:   string


[ Top ]

$helper_template_file =

[line 95]

Filesystem path to the templates/helper.php file



Tags:

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

Type:   string


[ Top ]

$layouts_path =

[line 120]

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

Trax work area




Tags:

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

Type:   string


[ Top ]

$layout_filename =

[line 129]



Tags:

todo:  

Document this variable

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

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

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:

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

Type:   string


[ Top ]

$model_template_file =

[line 107]

Filesystem path to the templates/model.php file



Tags:

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

Type:   string


[ Top ]

$scaffold_template_path =

[line 113]

Filesystem path to templates/scaffolds/generator_templates directory



Tags:

access:  private
usedby:  TraxGenerator::__construct()

Type:   string


[ Top ]

$view_path =

[line 50]

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



Tags:

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

Type:   string


[ Top ]

$view_template_file =

[line 101]

Filesystem path to the templates/view.phtml file



Tags:

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

Type:   string


[ Top ]



Class Methods


constructor __construct [line 155]

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 882]

void controller_help( )

Output console help message for "generate controller"



Tags:



[ Top ]

method create_controller [line 731]

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

Create a controller file with optional view methods



Tags:

todo:  Should return succeed/fail indication
usedby:  TraxGenerator::generate_controller()
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 791]

void create_helper( string $controller)

Create a helper file for a controller



Tags:

todo:  Should return succeed/fail indication
usedby:  TraxGenerator::generate_controller()
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 831]

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:  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 860]

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 874]

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 334]

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


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_mailer [line 393]

void generate_mailer( $name, [ $views = ""])



Parameters:

   $name  
   $views  

[ Top ]

method generate_model [line 494]

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 542]

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 974]

void generator_help( )

Output console help message for unrecognized command



Tags:



[ Top ]

method mailer_help [line 926]

void mailer_help( )

Output console help message for "generate mailer"



[ Top ]

method model_help [line 910]

void model_help( )

Output console help message for "generate model"



Tags:



[ Top ]

method run [line 195]

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 944]

void scaffold_help( )

Output console help message for "generate scaffold"



Tags:



[ Top ]


Documentation generated on Mon, 21 May 2007 22:29:28 -0600 by phpDocumentor 1.3.2