本文整理汇总了PHP中ClassTools::classname方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassTools::classname方法的具体用法?PHP ClassTools::classname怎么用?PHP ClassTools::classname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassTools
的用法示例。
在下文中一共展示了ClassTools::classname方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getParentClassName
/**
* Returns classpath to parent class.
* @return string
*/
protected function getParentClassName()
{
$ancestorClassName = ClassTools::classname($this->getChild()->getAncestor());
if ($this->getDatabase()->hasTableByPhpName($ancestorClassName)) {
return $this->getNewStubQueryBuilder($this->getDatabase()->getTableByPhpName($ancestorClassName))->getClassname();
} else {
// find the inheritance for the parent class
foreach ($this->getTable()->getChildrenColumn()->getChildren() as $child) {
if ($child->getClassName() == $ancestorClassName) {
return $this->getNewStubQueryInheritanceBuilder($child)->getClassname();
}
}
}
}
示例2: addClassOpen
protected function addClassOpen(&$script)
{
$table = $this->getTable();
$tableName = $table->getName();
$tableDesc = $table->getDescription();
$interface = $this->getInterface();
$script .= "\n/**\n * Base class that represents a row from the '{$tableName}' table.\n *\n * {$tableDesc}\n *";
if ($this->getBuildProperty('addTimeStamp')) {
$now = strftime('%c');
$script .= "\n * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on:\n *\n * {$now}\n *";
}
$script .= "\n * @package " . $this->getPackage() . "\n * @subpackage " . $this->getSubpackage() . "\n */\nabstract class " . $this->getClassname() . " extends " . ClassTools::classname($this->getBaseClass()) . " ";
$interface = ClassTools::getInterface($table);
if ($interface) {
$script .= " implements " . ClassTools::classname($interface);
}
$script .= " {\n\n";
}
示例3: getUnprefixedClassname
/**
* Returns the name of the current class being built.
* @return string
*/
public function getUnprefixedClassname()
{
return ClassTools::classname($this->getInterface());
}
示例4: addClassOpen
/**
* Adds class phpdoc comment and openning of class.
* @param string &$script The script will be modified in this method.
*/
protected function addClassOpen(&$script)
{
$table = $this->getTable();
$tableName = $table->getName();
$tableDesc = $table->getDescription();
$interface = $this->getInterface();
$parentClass = $this->getBehaviorContent('parentClass');
$parentClass = null !== $parentClass ? $parentClass : ClassTools::classname($this->getBaseClass());
$script .= "\n/**\n * Base class that represents a row from the '{$tableName}' table.\n *\n * {$tableDesc}\n *";
if ($this->getBuildProperty('addTimeStamp')) {
$now = strftime('%c');
$script .= "\n * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on:\n *\n * {$now}\n *";
}
$script .= "\n * @package propel.generator." . $this->getPackage() . "\n */\nabstract class " . $this->getClassname() . " extends " . $parentClass . " ";
$interface = ClassTools::getInterface($table);
if ($interface) {
$script .= " implements " . ClassTools::classname($interface);
}
if ($this->getTable()->getInterface()) {
$this->declareClassFromBuilder($this->getInterfaceBuilder());
}
$script .= "\n{\n";
}
示例5: getClassMap
/**
* Lists data model classes and builds an associative array className => classPath
* To be used for autoloading
* @return array
*/
protected function getClassMap()
{
$phpconfClassmap = array();
$generatorConfig = $this->getGeneratorConfig();
foreach ($this->getDataModels() as $dataModel) {
foreach ($dataModel->getDatabases() as $database) {
$classMap = array();
foreach ($database->getTables() as $table) {
if (!$table->isForReferenceOnly()) {
// -----------------------------------------------------
// Add TableMap class,
// Peer, Object & Query stub classes,
// and Peer, Object & Query base classes
// -----------------------------------------------------
// (this code is based on PropelOMTask)
foreach (array('tablemap', 'peerstub', 'objectstub', 'querystub', 'peer', 'object', 'query') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath());
$classMap[$builder->getClassname()] = $builder->getClassFilePath();
}
// -----------------------------------------------------
// Add children classes for object and query,
// as well as base child query,
// for single tabel inheritance tables.
// -----------------------------------------------------
if ($col = $table->getChildrenColumn()) {
if ($col->isEnumeratedClasses()) {
foreach ($col->getChildren() as $child) {
foreach (array('objectmultiextend', 'queryinheritance', 'queryinheritancestub') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$builder->setChild($child);
$this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath());
$classMap[$builder->getClassname()] = $builder->getClassFilePath();
}
}
}
}
// -----------------------------------------------------
// Add base classes for alias tables (undocumented)
// -----------------------------------------------------
$baseClass = $table->getBaseClass();
if ($baseClass !== null) {
$className = ClassTools::classname($baseClass);
if (!isset($classMap[$className])) {
$classPath = ClassTools::getFilePath($baseClass);
$this->log('Adding class mapping: ' . $className . ' => ' . $classPath);
$classMap[$className] = $classPath;
}
}
$basePeer = $table->getBasePeer();
if ($basePeer !== null) {
$className = ClassTools::classname($basePeer);
if (!isset($classMap[$className])) {
$classPath = ClassTools::getFilePath($basePeer);
$this->log('Adding class mapping: ' . $className . ' => ' . $classPath);
$classMap[$className] = $classPath;
}
}
// ----------------------------------------------
// Add classes for interface
// ----------------------------------------------
if ($table->getInterface()) {
$builder = $generatorConfig->getConfiguredBuilder($table, 'interface');
$this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath());
$classMap[$builder->getClassname()] = $builder->getClassFilePath();
}
// ----------------------------------------------
// Add classes from old treeMode implementations
// ----------------------------------------------
if ($table->treeMode() == 'MaterializedPath') {
foreach (array('nodepeerstub', 'nodestub', 'nodepeer', 'node') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath());
$classMap[$builder->getClassname()] = $builder->getClassFilePath();
}
}
if ($table->treeMode() == 'NestedSet') {
foreach (array('nestedset', 'nestedsetpeer') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath());
$classMap[$builder->getClassname()] = $builder->getClassFilePath();
}
}
}
// if (!$table->isReferenceOnly())
}
$phpconfClassmap = array_merge($phpconfClassmap, $classMap);
}
}
return $phpconfClassmap;
}
示例6: getParentClassname
/**
* Returns classname of parent class.
* @return string
*/
protected function getParentClassname()
{
return ClassTools::classname($this->getParentClasspath());
}
示例7: addClassOpen
/**
* Adds class phpdoc comment and openning of class.
* @param string &$script The script will be modified in this method.
*/
protected function addClassOpen(&$script)
{
$table = $this->getTable();
$tableName = $table->getName();
$tableDesc = $table->getDescription();
$interface = $this->getInterface();
$script .= "
/**
* Base class that represents a row from the '$tableName' table.
*
* $tableDesc
*";
if ($this->getBuildProperty('addTimeStamp')) {
$now = strftime('%c');
$script .= "
* This class was autogenerated by Propel on:
*
* $now
*";
}
$script .= "
* @package ".$this->getPackage()."
*/
abstract class ".$this->getClassname()." extends ".ClassTools::classname($this->getBaseClass())." ";
$interface = ClassTools::getInterface($table);
if ($interface) {
$script .= " implements " . ClassTools::classname($interface);
}
$script .= " {
";
}
示例8: getClassMap
/**
* Lists data model classes and builds an associative array className => classPath
* To be used for autoloading
* @return array
*/
protected function getClassMap()
{
$phpconfClassmap = array();
$generatorConfig = $this->getGeneratorConfig();
foreach ($this->getDataModels() as $dataModel) {
foreach ($dataModel->getDatabases() as $database) {
$classMap = array();
foreach ($database->getTables() as $table) {
if (!$table->isForReferenceOnly()) {
// Classes that I'm assuming do not need to be mapped (because they will be required by subclasses):
// - base peer and object classes
// - interfaces
// - base node peer and object classes
// -----------------------------------------------------
// Add Peer & Object stub classes and MapBuilder classes
// -----------------------------------------------------
// (this code is based on PropelOMTask)
foreach (array('tablemap', 'peerstub', 'objectstub') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath());
$classMap[$builder->getClassname()] = $builder->getClassFilePath();
}
if ($col = $table->getChildrenColumn()) {
if ($col->isEnumeratedClasses()) {
foreach ($col->getChildren() as $child) {
$builder = $generatorConfig->getConfiguredBuilder($table, 'objectmultiextend');
$builder->setChild($child);
$this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath());
$classMap[$builder->getClassname()] = $builder->getClassFilePath();
}
}
}
$baseClass = $table->getBaseClass();
if ($baseClass !== null) {
$className = ClassTools::classname($baseClass);
if (!isset($classMap[$className])) {
$classPath = ClassTools::getFilePath($baseClass);
$this->log('Adding class mapping: ' . $className . ' => ' . $classPath);
$classMap[$className] = $classPath;
}
}
$basePeer = $table->getBasePeer();
if ($basePeer !== null) {
$className = ClassTools::classname($basePeer);
if (!isset($classMap[$className])) {
$classPath = ClassTools::getFilePath($basePeer);
$this->log('Adding class mapping: ' . $className . ' => ' . $classPath);
$classMap[$className] = $classPath;
}
}
// ------------------------
// Create tree Node classes
// ------------------------
if ('MaterializedPath' == $table->treeMode()) {
foreach (array('nodepeerstub', 'nodestub') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath());
$classMap[$builder->getClassname()] = $builder->getClassFilePath();
}
}
}
// if (!$table->isReferenceOnly())
}
$phpconfClassmap = array_merge($phpconfClassmap, $classMap);
}
}
return $phpconfClassmap;
}
示例9: main
/**
* The main method does the work of the task.
*/
public function main()
{
// Check to make sure the input and output files were specified and that the input file exists.
if (!$this->xmlConfFile || !$this->xmlConfFile->exists()) {
throw new BuildException("No valid xmlConfFile specified.", $this->getLocation());
}
if (!$this->outputFile) {
throw new BuildException("No outputFile specified.", $this->getLocation());
}
if (!$this->outputClassmapFile) {
// We'll create a default one for BC
$this->outputClassmapFile = 'classmap-' . $this->outputFile;
}
// Create a PHP array from the XML file
$xmlDom = new DOMDocument();
$xmlDom->load($this->xmlConfFile->getAbsolutePath());
$xml = simplexml_load_string($xmlDom->saveXML());
$phpconf = self::simpleXmlToArray($xml);
$phpconfClassmap = array();
// $this->log(var_export($phpconf,true));
// Create a map of all PHP classes and their filepaths for this data model
$generatorConfig = $this->getGeneratorConfig();
foreach ($this->getDataModels() as $dataModel) {
foreach ($dataModel->getDatabases() as $database) {
$classMap = array();
// $this->log("Processing class mappings in database: " . $database->getName());
//print the tables
foreach ($database->getTables() as $table) {
if (!$table->isForReferenceOnly()) {
// $this->log("\t+ " . $table->getName());
// Classes that I'm assuming do not need to be mapped (because they will be required by subclasses):
// - base peer and object classes
// - interfaces
// - base node peer and object classes
// -----------------------------------------------------------------------------------------
// Add Peer & Object stub classes and MapBuilder classes
// -----------------------------------------------------------------------------------------
// (this code is based on PropelOMTask)
foreach (array('mapbuilder', 'peerstub', 'objectstub') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath());
$classMap[$builder->getClassname()] = $builder->getClassFilePath();
}
if ($table->getChildrenColumn()) {
$col = $table->getChildrenColumn();
if ($col->isEnumeratedClasses()) {
foreach ($col->getChildren() as $child) {
$builder = $generatorConfig->getConfiguredBuilder($table, 'objectmultiextend');
$builder->setChild($child);
$this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath());
$classMap[$builder->getClassname()] = $builder->getClassFilePath();
}
}
}
$baseClass = $table->getBaseClass();
if ($baseClass !== null) {
$className = ClassTools::classname($baseClass);
if (!isset($classMap[$className])) {
$classPath = ClassTools::getFilePath($baseClass);
$this->log('Adding class mapping: ' . $className . ' => ' . $classPath);
$classMap[$className] = $classPath;
}
}
$basePeer = $table->getBasePeer();
if ($basePeer !== null) {
$className = ClassTools::classname($basePeer);
if (!isset($classMap[$className])) {
$classPath = ClassTools::getFilePath($basePeer);
$this->log('Adding class mapping: ' . $className . ' => ' . $classPath);
$classMap[$className] = $classPath;
}
}
// -----------------------------------------------------------------------------------------
// Create tree Node classes
// -----------------------------------------------------------------------------------------
if ('MaterializedPath' == $table->treeMode()) {
foreach (array('nodepeerstub', 'nodestub') as $target) {
$builder = $generatorConfig->getConfiguredBuilder($table, $target);
$this->log("Adding class mapping: " . $builder->getClassname() . ' => ' . $builder->getClassFilePath());
$classMap[$builder->getClassname()] = $builder->getClassFilePath();
}
}
// if Table->treeMode() == 'MaterializedPath'
}
// if (!$table->isReferenceOnly())
}
$phpconfClassmap['propel']['datasources'][$database->getName()]['classes'] = $classMap;
}
}
// $phpconf['propel']['classes'] = $classMap;
$phpconf['propel']['generator_version'] = $this->getGeneratorConfig()->getBuildProperty('version');
// Write resulting PHP data to output file:
$outfile = new PhingFile($this->outputDirectory, $this->outputFile);
$output = '<' . '?' . "php\n";
$output .= "// This file generated by Propel " . $phpconf['propel']['generator_version'] . " convert-props target" . ($this->getGeneratorConfig()->getBuildProperty('addTimestamp') ? " on " . strftime("%c") : '') . "\n";
$output .= "// from XML runtime conf file " . $this->xmlConfFile->getPath() . "\n";
$output .= "return array_merge_recursive(";
//.........这里部分代码省略.........