本文整理汇总了PHP中ClassTools::getFilePath方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassTools::getFilePath方法的具体用法?PHP ClassTools::getFilePath怎么用?PHP ClassTools::getFilePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassTools
的用法示例。
在下文中一共展示了ClassTools::getFilePath方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getClassFilePath
/**
* Gets the full path to the file for the current class.
* @return string
*/
public function getClassFilePath()
{
return ClassTools::getFilePath($this->getPackage(), $this->getClassname());
}
示例2: getClassFilePath
public function getClassFilePath()
{
return ClassTools::getFilePath('lib.model.om', $this->getClassname());
}
示例3: getParentClassFilePath
/**
* Gets the file path to the parent class.
* @return string
*/
protected function getParentClassFilePath()
{
return ClassTools::getFilePath($this->getParentClasspath());
}
示例4: 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;
}
示例5: addClassClose
protected function addClassClose(&$script)
{
parent::addClassClose($script);
$behaviors = $this->getTable()->getAttribute('behaviors');
if ($behaviors) {
$behavior_file_name = 'Base' . $this->getTable()->getPhpName() . 'Behaviors';
$behavior_file_path = ClassTools::getFilePath($this->getStubObjectBuilder()->getPackage() . '.om', $behavior_file_name);
$behavior_include_script = <<<EOF
if (sfProjectConfiguration::getActive() instanceof sfApplicationConfiguration)
{
include_once '%s';
}
EOF;
$script .= sprintf($behavior_include_script, $behavior_file_path);
}
}
示例6: addClassClose
protected function addClassClose(&$script)
{
parent::addClassClose($script);
$behavior_file_name = 'Base' . $this->getTable()->getPhpName() . 'Behaviors';
$behavior_file_path = ClassTools::getFilePath($this->getStubObjectBuilder()->getPackage() . '.om', $behavior_file_name);
$absolute_behavior_file_path = sfConfig::get('sf_root_dir') . '/' . $behavior_file_path;
if (file_exists($absolute_behavior_file_path)) {
unlink($absolute_behavior_file_path);
}
$behaviors = $this->getTable()->getAttribute('behaviors');
if ($behaviors) {
file_put_contents($absolute_behavior_file_path, sprintf("<?php\nsfPropelBehavior::add('%s', %s);\n", $this->getTable()->getPhpName(), var_export(unserialize($behaviors), true)));
$behavior_include_script = <<<EOF
if (sfProjectConfiguration::getActive() instanceof sfApplicationConfiguration)
{
include_once '%s';
}
EOF;
$script .= sprintf($behavior_include_script, $behavior_file_path);
}
}
示例7: getBehaviorsFilePath
/**
* Returns the path to the current model's behaviors configuration file.
*
* @param boolean $absolute
*
* @return string
*/
protected function getBehaviorsFilePath($absolute = false)
{
$base = $absolute ? sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR : '';
return $base . ClassTools::getFilePath($this->getTable()->getPackage() . '.om', sprintf('Base%sBehaviors', $this->getTable()->getPhpName()));
}
示例8: main
public function main()
{
// check to make sure task received all correct params
$this->validate();
$basepath = $this->getOutputDirectory();
// Get new Capsule context
$generator = $this->createContext();
$generator->put("basepath", $basepath);
// make available to other templates
$targetPlatform = $this->getTargetPlatform();
// convenience for embedding in strings below
// we need some values that were loaded into the template context
$basePrefix = $generator->get('basePrefix');
$project = $generator->get('project');
foreach ($this->getDataModels() as $dataModel) {
$this->log("Processing Datamodel : " . $dataModel->getName());
foreach ($dataModel->getDatabases() as $database) {
$this->log(" - processing database : " . $database->getName());
$generator->put("platform", $database->getPlatform());
foreach ($database->getTables() as $table) {
if (!$table->isForReferenceOnly()) {
if ($table->getPackage()) {
$package = $table->getPackage();
} else {
$package = $this->targetPackage;
}
$pkbase = "{$package}.om";
$pkpeer = "{$package}";
$pkmap = "{$package}.map";
// make these available
$generator->put("package", $package);
$generator->put("pkbase", $pkbase);
//$generator->put("pkpeer", $pkpeer); -- we're not using this yet
$generator->put("pkmap", $pkmap);
foreach (array($pkpeer, $pkmap, $pkbase) as $pk) {
$path = strtr($pk, '.', '/');
$f = new PhingFile($this->getOutputDirectory(), $path);
if (!$f->exists()) {
if (!$f->mkdirs()) {
throw new Exception("Error creating directories: " . $f->getPath());
}
}
}
// for each package
$this->log("\t+ " . $table->getName());
$generator->put("table", $table);
// Create the Base Peer class
$this->log("\t\t-> " . $basePrefix . $table->getPhpName() . "Peer");
$path = ClassTools::getFilePath($pkbase, $basePrefix . $table->getPhpName() . "Peer");
$generator->parse("om/{$targetPlatform}/Peer.tpl", $path);
// Create the Base object class
$this->log("\t\t-> " . $basePrefix . $table->getPhpName());
$path = ClassTools::getFilePath($pkbase, $basePrefix . $table->getPhpName());
$generator->parse("om/{$targetPlatform}/Object.tpl", $path);
if ($table->isTree()) {
// Create the Base NodePeer class
$this->log("\t\t-> " . $basePrefix . $table->getPhpName() . "NodePeer");
$path = ClassTools::getFilePath($pkbase, $basePrefix . $table->getPhpName() . "NodePeer");
$generator->parse("om/{$targetPlatform}/NodePeer.tpl", $path);
// Create the Base Node class if the table is a tree
$this->log("\t\t-> " . $basePrefix . $table->getPhpName() . "Node");
$path = ClassTools::getFilePath($pkbase, $basePrefix . $table->getPhpName() . "Node");
$generator->parse("om/{$targetPlatform}/Node.tpl", $path);
}
// Create MapBuilder class if this table is not an alias
if (!$table->isAlias()) {
$this->log("\t\t-> " . $table->getPhpName() . "MapBuilder");
$path = ClassTools::getFilePath($pkmap, $table->getPhpName() . "MapBuilder");
$generator->parse("om/{$targetPlatform}/MapBuilder.tpl", $path);
}
// if !$table->isAlias()
// Create [empty] stub Peer class if it does not already exist
$path = ClassTools::getFilePath($package, $table->getPhpName() . "Peer");
$_f = new PhingFile($basepath, $path);
if (!$_f->exists()) {
$this->log("\t\t-> " . $table->getPhpName() . "Peer");
$generator->parse("om/{$targetPlatform}/ExtensionPeer.tpl", $path);
} else {
$this->log("\t\t-> (exists) " . $table->getPhpName() . "Peer");
}
// Create [empty] stub object class if it does not already exist
$path = ClassTools::getFilePath($package, $table->getPhpName());
$_f = new PhingFile($basepath, $path);
if (!$_f->exists()) {
$this->log("\t\t-> " . $table->getPhpName());
$generator->parse("om/{$targetPlatform}/ExtensionObject.tpl", $path);
} else {
$this->log("\t\t-> (exists) " . $table->getPhpName());
}
if ($table->isTree()) {
// Create [empty] stub Node Peer class if it does not already exist
$path = ClassTools::getFilePath($package, $table->getPhpName() . "NodePeer");
$_f = new PhingFile($basepath, $path);
if (!$_f->exists()) {
$this->log("\t\t-> " . $table->getPhpName() . "NodePeer");
$generator->parse("om/{$targetPlatform}/ExtensionNodePeer.tpl", $path);
} else {
$this->log("\t\t-> (exists) " . $table->getPhpName() . "NodePeer");
}
// Create [empty] stub Node class if it does not already exist
//.........这里部分代码省略.........
示例9: addClassClose
protected function addClassClose(&$script)
{
parent::addClassClose($script);
$behaviors = $this->getTable()->getAttribute('behaviors');
if ($behaviors) {
$behavior_file_name = 'Base' . $this->getTable()->getPhpName() . 'Behaviors';
$behavior_file_path = ClassTools::getFilePath($this->getStubObjectBuilder()->getPackage() . '.om', $behavior_file_name);
$script .= sprintf("\ninclude_once '%s';\n", $behavior_file_path);
}
}
示例10: 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;
}
示例11: 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(";
//.........这里部分代码省略.........