private function generateApp()
 {
     Library::import('recess.lang.Inflector');
     $appName = $this->request->post['appName'];
     $programmaticName = Inflector::toProperCaps($this->request->post['programmaticName']);
     $camelProgrammaticName = Inflector::toCamelCaps($programmaticName);
     $this->applicationClass = $programmaticName . 'Application';
     $this->applicationFullClass = $camelProgrammaticName . '.' . $this->applicationClass;
     $this->appName = $appName;
     $routesPrefix = $this->request->post['routingPrefix'];
     if (substr($routesPrefix, -1) != '/') {
         $routesPrefix .= '/';
     }
     $appDir = $_ENV['dir.apps'] . $camelProgrammaticName;
     $this->messages = array();
     $this->messages[] = $this->tryCreatingDirectory($appDir, 'application');
     $appReplacements = array('appName' => $appName, 'programmaticName' => $programmaticName, 'camelProgrammaticName' => $camelProgrammaticName, 'routesPrefix' => $routesPrefix);
     $this->messages[] = $this->tryGeneratingFile('Application Class', $this->application->codeTemplatesDir . 'Application.template.php', $appDir . '/' . $programmaticName . 'Application.class.php', $appReplacements);
     $this->messages[] = $this->tryCreatingDirectory($appDir . '/models', 'models');
     $this->messages[] = $this->tryCreatingDirectory($appDir . '/controllers', 'controllers');
     $this->messages[] = $this->tryGeneratingFile('Home Controller', $this->application->codeTemplatesDir . 'scaffolding/controllers/HomeController.template.php', $appDir . '/controllers/' . $programmaticName . 'HomeController.class.php', $appReplacements);
     $this->messages[] = $this->tryCreatingDirectory($appDir . '/views', 'views');
     $this->messages[] = $this->tryCreatingDirectory($appDir . '/views/parts', 'common parts');
     $this->messages[] = $this->tryGeneratingFile('Navigation Part', $this->application->codeTemplatesDir . 'scaffolding/views/parts/navigation.part.template.php', $appDir . '/views/parts/navigation.part.php', $appReplacements);
     $this->messages[] = $this->tryGeneratingFile('Style Part', $this->application->codeTemplatesDir . 'scaffolding/views/parts/style.part.template.php', $appDir . '/views/parts/style.part.php', $appReplacements);
     $this->messages[] = $this->tryCreatingDirectory($appDir . '/views/home', 'home views');
     $this->messages[] = $this->tryCreatingDirectory($appDir . '/views/layouts', 'layouts');
     $this->messages[] = $this->tryGeneratingFile('Home Template', $this->application->codeTemplatesDir . 'scaffolding/views/home/index.template.php', $appDir . '/views/home/index.html.php', $appReplacements);
     $this->messages[] = $this->tryGeneratingFile('Master Layout', $this->application->codeTemplatesDir . 'scaffolding/views/master.layout.template.php', $appDir . '/views/layouts/master.layout.php', $appReplacements);
     $scaffolding_dir = $this->application->codeTemplatesDir . 'scaffolding';
     $this->messages[] = $this->tryCopyDirectory($scaffolding_dir . '/public', $appDir . '/public');
 }
 function init($modelClassName, $relationshipName)
 {
     $this->localClass = $modelClassName;
     $this->name = $relationshipName;
     $this->onDelete = Relationship::NULLIFY;
     $this->foreignKey = Inflector::toCamelCaps($relationshipName) . 'Id';
     $this->foreignClass = Inflector::toProperCaps($relationshipName);
 }
Esempio n. 3
0
 function init($modelClassName, $relationshipName)
 {
     $this->localClass = $modelClassName;
     $this->name = $relationshipName;
     $this->foreignKey = Inflector::toCamelCaps($modelClassName) . 'Id';
     $this->foreignClass = Inflector::toSingular(Inflector::toProperCaps($relationshipName));
     $this->onDelete = Relationship::UNSPECIFIED;
 }
Esempio n. 4
0
 function testToProperCaps()
 {
     $this->assertEquals('ProperCaps', Inflector::toProperCaps('properCaps'));
     $this->assertEquals('ProperCaps', Inflector::toProperCaps('proper_caps'));
 }
 public static function labelForObjectProperty($object, $field)
 {
     $descriptor = Model::getDescriptor(get_class($object));
     $property = isset($descriptor->properties[$field]) ? $descriptor->properties[$field] : new stdClass();
     return isset($property->label) ? $property->label : Inflector::toProperCaps($field);
 }