~ubuntu-branches/ubuntu/vivid/zendframework/vivid

« back to all changes in this revision

Viewing changes to library/Zend/Tool/Project/Provider/DbTable.php

  • Committer: Bazaar Package Importer
  • Author(s): Frank Habermann
  • Date: 2010-04-28 20:10:00 UTC
  • mfrom: (1.3.1 upstream) (9.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100428201000-o347bj5qb5i3tpot
Tags: 1.10.4-1
new upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
    {
94
94
        $this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION);
95
95
 
 
96
        // Check that there is not a dash or underscore, return if doesnt match regex
 
97
        if (preg_match('#[_-]#', $name)) {
 
98
            throw new Zend_Tool_Project_Provider_Exception('DbTable names should be camel cased.');
 
99
        }
 
100
        
 
101
        $originalName = $name;
 
102
        $name = ucfirst($name);
 
103
        
96
104
        if ($actualTableName == '') {
97
105
            throw new Zend_Tool_Project_Provider_Exception('You must provide both the DbTable name as well as the actual db table\'s name.');
98
106
        }
101
109
            throw new Zend_Tool_Project_Provider_Exception('This project already has a DbTable named ' . $name);
102
110
        }
103
111
 
104
 
        // Check that there is not a dash or underscore, return if doesnt match regex
105
 
        if (preg_match('#[_-]#', $name)) {
106
 
            throw new Zend_Tool_Project_Provider_Exception('DbTable names should be camel cased.');
 
112
        // get request/response object
 
113
        $request = $this->_registry->getRequest();
 
114
        $response = $this->_registry->getResponse();
 
115
        
 
116
        // alert the user about inline converted names
 
117
        $tense = (($request->isPretend()) ? 'would be' : 'is');
 
118
        
 
119
        if ($name !== $originalName) {
 
120
            $response->appendContent(
 
121
                'Note: The canonical model name that ' . $tense
 
122
                    . ' used with other providers is "' . $name . '";'
 
123
                    . ' not "' . $originalName . '" as supplied',
 
124
                array('color' => array('yellow'))
 
125
                );
107
126
        }
108
127
        
109
 
        $name = ucwords($name);
110
 
        
111
128
        try {
112
129
            $tableResource = self::createResource($this->_loadedProfile, $name, $actualTableName, $module);
113
130
        } catch (Exception $e) {
117
134
        }
118
135
 
119
136
        // do the creation
120
 
        if ($this->_registry->getRequest()->isPretend()) {
121
 
 
122
 
            $this->_registry->getResponse()->appendContent('Would create a DbTable at '  . $tableResource->getContext()->getPath());
123
 
 
 
137
        if ($request->isPretend()) {
 
138
            $response->appendContent('Would create a DbTable at '  . $tableResource->getContext()->getPath());
124
139
        } else {
125
 
 
126
 
            $this->_registry->getResponse()->appendContent('Creating a DbTable at ' . $tableResource->getContext()->getPath());
 
140
            $response->appendContent('Creating a DbTable at ' . $tableResource->getContext()->getPath());
127
141
            $tableResource->create();
128
 
 
129
142
            $this->_storeProfile();
130
143
        }
131
144
    }