File indexing completed on 2024-06-23 05:55:51

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Tool
0017  * @subpackage Framework
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  * @version    $Id$
0021  */
0022 
0023 /**
0024  * This class is the front most class for utilizing Zend_Tool_Project
0025  *
0026  * A profile is a hierarchical set of resources that keep track of
0027  * items within a specific project.
0028  *
0029  * @category   Zend
0030  * @package    Zend_Tool
0031  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0032  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0033  */
0034 class Zend_Tool_Project_Context_Zf_DbTableFile extends Zend_Tool_Project_Context_Zf_AbstractClassFile
0035 {
0036 
0037     protected $_dbTableName = null;
0038 
0039     protected $_actualTableName = null;
0040 
0041     /**
0042      * getName()
0043      *
0044      * @return string
0045      */
0046     public function getName()
0047     {
0048         return 'DbTableFile';
0049     }
0050 
0051     /**
0052      * init()
0053      *
0054      */
0055     public function init()
0056     {
0057         $this->_dbTableName = $this->_resource->getAttribute('dbTableName');
0058         $this->_actualTableName = $this->_resource->getAttribute('actualTableName');
0059         $this->_filesystemName = ucfirst($this->_dbTableName) . '.php';
0060         parent::init();
0061     }
0062 
0063     public function getPersistentAttributes()
0064     {
0065         return array('dbTableName' => $this->_dbTableName);
0066     }
0067 
0068     public function getContents()
0069     {
0070         $className = $this->getFullClassName($this->_dbTableName, 'Model_DbTable');
0071 
0072         $codeGenFile = new Zend_CodeGenerator_Php_File(array(
0073             'fileName' => $this->getPath(),
0074             'classes' => array(
0075                 new Zend_CodeGenerator_Php_Class(array(
0076                     'name' => $className,
0077                     'extendedClass' => 'Zend_Db_Table_Abstract',
0078                     'properties' => array(
0079                         new Zend_CodeGenerator_Php_Property(array(
0080                             'name' => '_name',
0081                             'visibility' => Zend_CodeGenerator_Php_Property::VISIBILITY_PROTECTED,
0082                             'defaultValue' => $this->_actualTableName
0083                             ))
0084                         ),
0085 
0086                     ))
0087                 )
0088             ));
0089         return $codeGenFile->generate();
0090     }
0091 
0092 }