Commit bea3a7c5 authored by jwage's avatar jwage

Minor changes backported from 0.9 and 0.10

parent 23ab5b90
...@@ -385,6 +385,19 @@ abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable ...@@ -385,6 +385,19 @@ abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable
*/ */
public function getAttribute($attribute) public function getAttribute($attribute)
{ {
if (is_string($attribute)) {
$upper = strtoupper($attribute);
$const = 'Doctrine::ATTR_' . $upper;
if (defined($const)) {
$attribute = constant($const);
$this->_state = $attribute;
} else {
throw new Doctrine_Exception('Unknown attribute: "' . $attribute . '"');
}
}
$attribute = (int) $attribute; $attribute = (int) $attribute;
if ($attribute < 0) { if ($attribute < 0) {
......
...@@ -328,11 +328,26 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -328,11 +328,26 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
return $this->_name; return $this->_name;
} }
/**
* setName
*
* Sets the name of the connection
*
* @param string $name
* @return void
*/
public function setName($name) public function setName($name)
{ {
$this->_name = $name; $this->_name = $name;
} }
/**
* getDriverName
*
* Gets the name of the instance driver
*
* @return void
*/
public function getDriverName() public function getDriverName()
{ {
return $this->driverName; return $this->driverName;
......
...@@ -130,6 +130,9 @@ class Doctrine_Data_Import extends Doctrine_Data ...@@ -130,6 +130,9 @@ class Doctrine_Data_Import extends Doctrine_Data
foreach ($row as $key => $value) { foreach ($row as $key => $value) {
if ($obj->getTable()->hasField($key)) { if ($obj->getTable()->hasField($key)) {
$obj->set($key, $value); $obj->set($key, $value);
} else if (method_exists($obj, 'set' . Doctrine::classify($key))) {
$func = 'set' . Doctrine::classify($key);
$obj->$func($value);
} else if ($obj->getTable()->hasRelation($key)) { } else if ($obj->getTable()->hasRelation($key)) {
if (is_array($value)) { if (is_array($value)) {
if (isset($value[0])) { if (isset($value[0])) {
...@@ -149,9 +152,6 @@ class Doctrine_Data_Import extends Doctrine_Data ...@@ -149,9 +152,6 @@ class Doctrine_Data_Import extends Doctrine_Data
} else { } else {
$obj->set($key, $this->_getImportedObject($value)); $obj->set($key, $this->_getImportedObject($value));
} }
} else if (method_exists($obj, 'set' . Doctrine::classify($key))) {
$func = 'set' . Doctrine::classify($key);
$obj->$func($value);
} }
} }
} }
......
<?php <?php
require_once('PEAR/PackageFileManager2.php'); buildPearPackage('/Users/jwage/Sites/doctrine/trunk', '0.9.0', 'beta');
PEAR::setErrorHandling(PEAR_ERROR_DIE);
$packagexml = new PEAR_PackageFileManager2; function buildPearPackage($path, $version, $state)
{
$packageFile = $path . DIRECTORY_SEPARATOR . 'package.xml';
require_once('PEAR/packageFileManager2.php');
PEAR::setErrorHandling(PEAR_ERROR_DIE);
$version_release = '0.9'; $packagexml = new PEAR_packageFileManager2;
$version_api = $version_release;
$state = 'beta'; $notes = <<<EOT
-
$notes = <<<EOT
barfoo
EOT; EOT;
$summary = 'PHP5 Database ORM'; $summary = 'PHP5 Database ORM';
$description =<<<EOT $description =<<<EOT
Doctrine is an ORM (object relational mapper) for PHP 5.2.x+ that sits on top of Doctrine is an ORM (object relational mapper) for PHP 5.2.x+ that sits on top of
a powerful DBAL (database abstraction layer). One of its key features is the a powerful DBAL (database abstraction layer). One of its key features is the
ability to optionally write database queries in an OO (object oriented) ability to optionally write database queries in an OO (object oriented)
...@@ -24,57 +26,69 @@ a powerful alternative to SQL that maintains a maximum of flexibility without ...@@ -24,57 +26,69 @@ a powerful alternative to SQL that maintains a maximum of flexibility without
requiring needless code duplication. requiring needless code duplication.
EOT; EOT;
$packagefile = './package.xml'; $options = array(
'filelistgenerator' => 'svn',
$options = array( 'changelogoldtonew' => false,
'filelistgenerator' => 'svn', 'simpleoutput' => true,
'changelogoldtonew' => false, 'baseinstalldir' => '/',
'simpleoutput' => true, 'packagedirectory' => $path,
'baseinstalldir' => '/', 'packageFile' => $packageFile,
'packagedirectory' => './', 'clearcontents' => false,
'packagefile' => $packagefile, // What to ignore
'clearcontents' => false, 'ignore' => array(
'ignore' => array( $path . DIRECTORY_SEPARATOR . 'vendor/',
'vendor/', $path . DIRECTORY_SEPARATOR . 'package*.*',
'tools/', $path . DIRECTORY_SEPARATOR . 'tests_old/',
'package*.php', $path . DIRECTORY_SEPARATOR . 'tests/',
'package*.xml', $path . DIRECTORY_SEPARATOR . 'tools/'
), ),
'dir_roles' => array( // What to include in package
'lib' => 'php', 'include' => array(
'manual' => 'doc', $path . DIRECTORY_SEPARATOR . 'lib/',
'models' => 'doc', $path . DIRECTORY_SEPARATOR . 'manual/',
'tests' => 'test', $path . DIRECTORY_SEPARATOR . 'vendor/',
), $path . DIRECTORY_SEPARATOR . 'README',
'exceptions' => array( $path . DIRECTORY_SEPARATOR . 'CHANGELOG',
'README' => 'doc', $path . DIRECTORY_SEPARATOR . 'LICENSE',
'CHANGELOG' => 'doc', $path . DIRECTORY_SEPARATOR . 'COPYRIGHT'
'LICENSE' => 'doc', ),
'COPYRIGHT' => 'doc' // Dir roles
) 'dir_roles' => array(
); 'lib' => 'php',
'manual' => 'doc',
'vendor' => 'php'
),
// File roles
'exceptions' => array(
'README' => 'doc',
'CHANGELOG' => 'doc',
'LICENSE' => 'doc',
'COPYRIGHT' => 'doc'
)
);
$package = &PEAR_PackageFileManager2::importOptions($packagefile, $options); $package = &PEAR_packageFileManager2::importOptions($packageFile, $options);
$package->setPackageType('php'); $package->setPackageType('php');
$package->clearDeps(); $package->clearDeps();
$package->setPhpDep('5.2.3'); $package->setPhpDep('5.2.3');
$package->setPearInstallerDep('1.4.0b1'); $package->setPearInstallerDep('1.4.0b1');
$package->addPackageDepWithChannel('required', 'PEAR', 'pear.php.net', '1.3.6'); $package->addPackageDepWithChannel('required', 'PEAR', 'pear.php.net', '1.3.6');
$package->addRelease(); $package->addRelease();
$package->generateContents(); $package->generateContents();
$package->setReleaseVersion($version_release); $package->setReleaseVersion($version);
$package->setAPIVersion($version_api); $package->setAPIVersion($version);
$package->setReleaseStability($state); $package->setReleaseStability($state);
$package->setAPIStability($state); $package->setAPIStability($state);
$package->setNotes($notes); $package->setNotes($notes);
$package->setSummary($summary); $package->setSummary($summary);
$package->setDescription($description); $package->setDescription($description);
$package->addGlobalReplacement('package-info', '@package_version@', 'version'); $package->addGlobalReplacement('package-info', '@package_version@', 'version');
if (isset($_GET['make']) || (isset($_SERVER['argv']) && @$_SERVER['argv'][1] == 'make')) { if (isset($_GET['make']) || (isset($_SERVER['argv']) && @$_SERVER['argv'][1] == 'make')) {
$package->writePackageFile(); $package->writepackageFile();
} else { } else {
$package->debugPackageFile(); $package->debugpackageFile();
} }
}
\ No newline at end of file
...@@ -50,4 +50,4 @@ spl_autoload_register(array('Doctrine', 'autoload')); ...@@ -50,4 +50,4 @@ spl_autoload_register(array('Doctrine', 'autoload'));
Doctrine_Manager::connection(DSN, 'sandbox'); Doctrine_Manager::connection(DSN, 'sandbox');
Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE); Doctrine_Manager::getInstance()->setAttribute('model_loading', 'conservative');
\ No newline at end of file
#!/usr/bin/env php
<?php <?php
require_once('config.php'); chdir(dirname(__FILE__));
define('SANDBOX_PATH', dirname(__FILE__));
define('DOCTRINE_PATH', dirname(dirname(SANDBOX_PATH)) . DIRECTORY_SEPARATOR . 'lib');
define('DATA_FIXTURES_PATH', SANDBOX_PATH . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'fixtures');
define('MODELS_PATH', SANDBOX_PATH . DIRECTORY_SEPARATOR . 'models');
define('MIGRATIONS_PATH', SANDBOX_PATH . DIRECTORY_SEPARATOR . 'migrations');
define('SQL_PATH', SANDBOX_PATH . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'sql');
define('YAML_SCHEMA_PATH', SANDBOX_PATH . DIRECTORY_SEPARATOR . 'schema');
define('DB_PATH', SANDBOX_PATH . DIRECTORY_SEPARATOR . 'sandbox.db');
define('DSN', 'sqlite:///' . DB_PATH);
require_once(DOCTRINE_PATH . DIRECTORY_SEPARATOR . 'Doctrine.php');
spl_autoload_register(array('Doctrine', 'autoload'));
Doctrine_Manager::connection(DSN, 'sandbox');
Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);
// Configure Doctrine Cli // Configure Doctrine Cli
// Normally these are arguments to the cli tasks but if they are set here the arguments will be auto-filled // Normally these are arguments to the cli tasks but if they are set here the arguments will be auto-filled
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment