initial commit

This commit is contained in:
Chris Sewell
2012-11-28 03:55:08 -05:00
parent 7adb399b2e
commit cf140a2e97
3247 changed files with 492437 additions and 0 deletions

344
lib/symfony/vendor/propel/map/ColumnMap.php vendored Executable file
View File

@ -0,0 +1,344 @@
<?php
/*
* $Id: ColumnMap.php 536 2007-01-10 14:30:38Z heltem $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information please see
* <http://propel.phpdb.org>.
*/
include_once 'propel/map/ValidatorMap.php';
/**
* ColumnMap is used to model a column of a table in a database.
*
* GENERAL NOTE
* ------------
* The propel.map classes are abstract building-block classes for modeling
* the database at runtime. These classes are similar (a lite version) to the
* propel.engine.database.model classes, which are build-time modeling classes.
* These classes in themselves do not do any database metadata lookups, but instead
* are used by the MapBuilder classes that were generated for your datamodel. The
* MapBuilder that was created for your datamodel build a representation of your
* database by creating instances of the DatabaseMap, TableMap, ColumnMap, etc.
* classes. See propel/templates/om/php5/MapBuilder.tpl and the classes generated
* by that template for your datamodel to further understand how these are put
* together.
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author John D. McNally <jmcnally@collab.net> (Torque)
* @version $Revision: 536 $
* @package propel.map
*/
class ColumnMap {
/** @var int Creole type for this column. */
private $creoleType;
/** @var string Native PHP type of the column. */
private $type = null;
/** Size of the column. */
private $size = 0;
/** Is it a primary key? */
private $pk = false;
/** Is null value allowed ?*/
private $notNull = false;
/** Name of the table that this column is related to. */
private $relatedTableName = "";
/** Name of the column that this column is related to. */
private $relatedColumnName = "";
/** The TableMap for this column. */
private $table;
/** The name of the column. */
private $columnName;
/** The php name of the column. */
private $phpName;
/** validators for this column */
private $validators = array();
/**
* Constructor.
*
* @param string $name The name of the column.
* @param TableMap containingTable TableMap of the table this column is in.
*/
public function __construct($name, TableMap $containingTable)
{
$this->columnName = $name;
$this->table = $containingTable;
}
/**
* Get the name of a column.
*
* @return string A String with the column name.
*/
public function getColumnName()
{
return $this->columnName;
}
/**
* Set the php anme of this column.
*
* @param string $phpName A string representing the PHP name.
* @return void
*/
public function setPhpName($phpName)
{
$this->phpName = $phpName;
}
/**
* Get the name of a column.
*
* @return string A String with the column name.
*/
public function getPhpName()
{
return $this->phpName;
}
/**
* Get the table name + column name.
*
* @return string A String with the full column name.
*/
public function getFullyQualifiedName()
{
return $this->table->getName() . "." . $this->columnName;
}
/**
* Get the table map this column belongs to.
* @return TableMap
*/
public function getTable()
{
return $this->table;
}
/**
* Get the name of the table this column is in.
*
* @return string A String with the table name.
*/
public function getTableName()
{
return $this->table->getName();
}
/**
* Set the type of this column.
*
* @param string $type A string representing the PHP native type.
* @return void
*/
public function setType($type)
{
$this->type = $type;
}
/**
* Set the Creole type of this column.
*
* @param int $type An int representing Creole type for this column.
* @return void
*/
public function setCreoleType($type)
{
$this->creoleType = $type;
}
/**
* Set the size of this column.
*
* @param int $size An int specifying the size.
* @return void
*/
public function setSize($size)
{
$this->size = $size;
}
/**
* Set if this column is a primary key or not.
*
* @param boolean $pk True if column is a primary key.
* @return void
*/
public function setPrimaryKey($pk)
{
$this->pk = $pk;
}
/**
* Set if this column may be null.
*
* @param boolean nn True if column may be null.
* @return void
*/
public function setNotNull($nn)
{
$this->notNull = $nn;
}
/**
* Gets the default value for this column.
* @return mixed String or NULL
*/
public function getDefaultValue()
{
return $this->defaultValue;
}
/**
* Set the foreign key for this column.
*
* @param string tableName The name of the table that is foreign.
* @param string columnName The name of the column that is foreign.
* @return void
*/
public function setForeignKey($tableName, $columnName)
{
if ($tableName && $columnName) {
$this->relatedTableName = $tableName;
$this->relatedColumnName = $columnName;
} else {
$this->relatedTableName = "";
$this->relatedColumnName = "";
}
}
public function addValidator($validator)
{
$this->validators[] = $validator;
}
public function hasValidators()
{
return count($this->validators) > 0;
}
public function getValidators()
{
return $this->validators;
}
/**
* Get the native PHP type of this column.
*
* @return string A string specifying the native PHP type.
*/
public function getType()
{
return $this->type;
}
/**
* Get the Creole type of this column.
*
* @return string A string specifying the native PHP type.
*/
public function getCreoleType()
{
return $this->creoleType;
}
/**
* Get the size of this column.
*
* @return int An int specifying the size.
*/
public function getSize()
{
return $this->size;
}
/**
* Is this column a primary key?
*
* @return boolean True if column is a primary key.
*/
public function isPrimaryKey()
{
return $this->pk;
}
/**
* Is null value allowed ?
*
* @return boolean True if column may be null.
*/
public function isNotNull()
{
return ($this->notNull || $this->isPrimaryKey());
}
/**
* Is this column a foreign key?
*
* @return boolean True if column is a foreign key.
*/
public function isForeignKey()
{
if ($this->relatedTableName) {
return true;
} else {
return false;
}
}
/**
* Get the table.column that this column is related to.
*
* @return string A String with the full name for the related column.
*/
public function getRelatedName()
{
return $this->relatedTableName . "." . $this->relatedColumnName;
}
/**
* Get the table name that this column is related to.
*
* @return string A String with the name for the related table.
*/
public function getRelatedTableName()
{
return $this->relatedTableName;
}
/**
* Get the column name that this column is related to.
*
* @return string A String with the name for the related column.
*/
public function getRelatedColumnName()
{
return $this->relatedColumnName;
}
}

127
lib/symfony/vendor/propel/map/DatabaseMap.php vendored Executable file
View File

@ -0,0 +1,127 @@
<?php
/*
* $Id: DatabaseMap.php 536 2007-01-10 14:30:38Z heltem $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information please see
* <http://propel.phpdb.org>.
*/
include_once 'propel/map/TableMap.php';
/**
* DatabaseMap is used to model a database.
*
* GENERAL NOTE
* ------------
* The propel.map classes are abstract building-block classes for modeling
* the database at runtime. These classes are similar (a lite version) to the
* propel.engine.database.model classes, which are build-time modeling classes.
* These classes in themselves do not do any database metadata lookups, but instead
* are used by the MapBuilder classes that were generated for your datamodel. The
* MapBuilder that was created for your datamodel build a representation of your
* database by creating instances of the DatabaseMap, TableMap, ColumnMap, etc.
* classes. See propel/templates/om/php5/MapBuilder.tpl and the classes generated
* by that template for your datamodel to further understand how these are put
* together.
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author John D. McNally <jmcnally@collab.net> (Torque)
* @author Daniel Rall <dlr@collab.net> (Torque)
* @version $Revision: 536 $
* @package propel.map
*/
class DatabaseMap {
/** Name of the database. */
private $name;
/** Name of the tables in the database. */
private $tables;
/**
* Constructor.
*
* @param string $name Name of the database.
*/
function __construct($name)
{
$this->name = $name;
$this->tables = array();
}
/**
* Does this database contain this specific table?
*
* @param string $name The String representation of the table.
* @return boolean True if the database contains the table.
*/
public function containsTable($name)
{
if ( strpos($name, '.') > 0) {
$name = substr($name, 0, strpos($name, '.'));
}
return isset($this->tables[$name]);
}
/**
* Get the name of this database.
*
* @return string The name of the database.
*/
public function getName()
{
return $this->name;
}
/**
* Get a TableMap for the table by name.
*
* @param string $name Name of the table.
* @return TableMap A TableMap
* @throws PropelException if the table is undefined
*/
public function getTable($name)
{
if (!isset($this->tables[$name])) {
throw new PropelException("Cannot fetch TableMap for undefined table: " . $name);
}
return $this->tables[$name];
}
/**
* Get a TableMap[] of all of the tables in the database.
*
* @return array A TableMap[].
*/
public function getTables()
{
return $this->tables;
}
/**
* Add a new table to the database by name. It creates an empty
* TableMap that you need to populate.
*
* @param string $tableName The name of the table.
* @return TableMap The newly created TableMap.
*/
public function addTable($tableName)
{
$this->tables[$tableName] = new TableMap($tableName, $this);
return $this->tables[$tableName];
}
}

75
lib/symfony/vendor/propel/map/MapBuilder.php vendored Executable file
View File

@ -0,0 +1,75 @@
<?php
/*
* $Id: MapBuilder.php 536 2007-01-10 14:30:38Z heltem $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information please see
* <http://propel.phpdb.org>.
*/
/**
* MapBuilders are classes that construct a model of a database at runtime.
*
* MapBuilders support a single database, so this class essentially serves as
* a wrapper around the DatabaseMap class. This interface can be used for any
* class that needs to construct a runtime database model; by default in Propel
* the MapBuilder.tpl generates a class for your datamodel that implements this
* interface and re-creates your database using the DatabaseMap, TableMap,
* ColumnMap, and ValidatorMap classes.
*
* GENERAL NOTE
* ------------
* The propel.map classes are abstract building-block classes for modeling
* the database at runtime. These classes are similar (a lite version) to the
* propel.engine.database.model classes, which are build-time modeling classes.
* These classes in themselves do not do any database metadata lookups, but instead
* are used by the MapBuilder classes that were generated for your datamodel. The
* MapBuilder that was created for your datamodel build a representation of your
* database by creating instances of the DatabaseMap, TableMap, ColumnMap, etc.
* classes. See propel/templates/om/php5/MapBuilder.tpl and the classes generated
* by that template for your datamodel to further understand how these are put
* together.
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author John D. McNally <jmcnally@collab.net> (Torque)
* @author Hans Lellelid <hans@xmpl.org> (Torque)
* @version $Revision: 536 $
* @package propel.map
*/
interface MapBuilder {
/**
* Build up the database mapping.
* @return void
* @throws Exception Couldn't build mapping.
*/
function doBuild();
/**
* Tells us if the database mapping is built so that we can avoid
* re-building it repeatedly.
*
* @return boolean Whether the DatabaseMap is built.
*/
function isBuilt();
/**
* Gets the database mapping this map builder built.
*
* @return DatabaseMap A DatabaseMap.
*/
function getDatabaseMap();
}

429
lib/symfony/vendor/propel/map/TableMap.php vendored Executable file
View File

@ -0,0 +1,429 @@
<?php
/*
* $Id: TableMap.php 536 2007-01-10 14:30:38Z heltem $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information please see
* <http://propel.phpdb.org>.
*/
include_once 'propel/map/ColumnMap.php';
include_once 'propel/map/ValidatorMap.php';
/**
* TableMap is used to model a table in a database.
*
* GENERAL NOTE
* ------------
* The propel.map classes are abstract building-block classes for modeling
* the database at runtime. These classes are similar (a lite version) to the
* propel.engine.database.model classes, which are build-time modeling classes.
* These classes in themselves do not do any database metadata lookups, but instead
* are used by the MapBuilder classes that were generated for your datamodel. The
* MapBuilder that was created for your datamodel build a representation of your
* database by creating instances of the DatabaseMap, TableMap, ColumnMap, etc.
* classes. See propel/templates/om/php5/MapBuilder.tpl and the classes generated
* by that template for your datamodel to further understand how these are put
* together.
*
* @author Hans Lellelid <hans@xmpl.org> (Propel)
* @author John D. McNally <jmcnally@collab.net> (Torque)
* @author Daniel Rall <dlr@finemaltcoding.com> (Torque)
* @version $Revision: 536 $
* @package propel.map
*/
class TableMap {
/** The columns in the table. */
private $columns;
/** The database this table belongs to. */
private $dbMap;
/** The name of the table. */
private $tableName;
/** The PHP name of the table. */
private $phpName;
/** The prefix on the table name. */
private $prefix;
/** Whether to use an id generator for pkey. */
private $useIdGenerator;
/**
* Object to store information that is needed if the
* for generating primary keys.
*/
private $pkInfo;
/**
* Construct a new TableMap.
*
* @param string $tableName The name of the table.
* @param DatabaseMap $containingDB A DatabaseMap that this table belongs to.
*/
public function __construct($tableName, DatabaseMap $containingDB)
{
$this->tableName = $tableName;
$this->dbMap = $containingDB;
$this->columns = array();
}
/**
* Normalizes the column name, removing table prefix and uppercasing.
* @param string $name
* @return string Normalized column name.
*/
private function normalizeColName($name) {
if (false !== ($pos = strpos($name, '.'))) {
$name = substr($name, $pos + 1);
}
$name = strtoupper($name);
return $name;
}
/**
* Does this table contain the specified column?
*
* @param string $name name of the column
* @return boolean True if the table contains the column.
*/
public function containsColumn($name)
{
if (!is_string($name)) {
$name = $name->getColumnName();
}
return isset($this->columns[$this->normalizeColName($name)]);
}
/**
* Get the DatabaseMap containing this TableMap.
*
* @return DatabaseMap A DatabaseMap.
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* Get the name of the Table.
*
* @return string A String with the name of the table.
*/
public function getName()
{
return $this->tableName;
}
/**
* Get the PHP name of the Table.
*
* @return string A String with the name of the table.
*/
public function getPhpName()
{
return $this->phpName;
}
/**
* Set the PHP name of the Table.
*
* @param string $phpName The PHP Name for this table
*/
public function setPhpName($phpName)
{
$this->phpName = $phpName;
}
/**
* Get table prefix name.
*
* @return string A String with the prefix.
*/
public function getPrefix()
{
return $this->prefix;
}
/**
* Set table prefix name.
*
* @param string $prefix The prefix for the table name (ie: SCARAB for
* SCARAB_PROJECT).
* @return void
*/
public function setPrefix($prefix)
{
$this->prefix = $prefix;
}
/**
* Whether to use Id generator for primary key.
* @return boolean
*/
public function isUseIdGenerator() {
return $this->useIdGenerator;
}
/**
* Get the information used to generate a primary key
*
* @return An Object.
*/
public function getPrimaryKeyMethodInfo()
{
return $this->pkInfo;
}
/**
* Get a ColumnMap[] of the columns in this table.
*
* @return array A ColumnMap[].
*/
public function getColumns()
{
return $this->columns;
}
/**
* Get a ColumnMap for the named table.
*
* @param string $name A String with the name of the table.
* @return ColumnMap A ColumnMap.
* @throws PropelException if the column is undefined
*/
public function getColumn($name)
{
$name = $this->normalizeColName($name);
if (!isset($this->columns[$name])) {
throw new PropelException("Cannot fetch ColumnMap for undefined column: " . $name);
}
return $this->columns[$name];
}
/**
* Add a primary key column to this Table.
*
* @param string $columnName A String with the column name.
* @param string $type A string specifying the PHP native type.
* @param int $creoleType The integer representing the Creole type.
* @param boolean $isNotNull Whether column does not allow NULL values.
* @param $size An int specifying the size.
* @return ColumnMap Newly added PrimaryKey column.
*/
public function addPrimaryKey($columnName, $phpName, $type, $creoleType, $isNotNull = false, $size = null)
{
return $this->addColumn($columnName, $phpName, $type, $creoleType, $isNotNull, $size, true, null, null);
}
/**
* Add a foreign key column to the table.
*
* @param string $columnName A String with the column name.
* @param string $type A string specifying the PHP native type.
* @param int $creoleType The integer representing the Creole type.
* @param string $fkTable A String with the foreign key table name.
* @param string $fkColumn A String with the foreign key column name.
* @param boolean $isNotNull Whether column does not allow NULL values.
* @param int $size An int specifying the size.
* @param string $defaultValue The default value for this column.
* @return ColumnMap Newly added ForeignKey column.
*/
public function addForeignKey($columnName, $phpName, $type, $creoleType, $fkTable, $fkColumn, $isNotNull = false, $size = 0)
{
return $this->addColumn($columnName, $phpName, $type, $creoleType, $isNotNull, $size, false, $fkTable, $fkColumn);
}
/**
* Add a foreign primary key column to the table.
*
* @param string $columnName A String with the column name.
* @param string $type A string specifying the PHP native type.
* @param int $creoleType The integer representing the Creole type.
* @param string $fkTable A String with the foreign key table name.
* @param string $fkColumn A String with the foreign key column name.
* @param boolean $isNotNull Whether column does not allow NULL values.
* @param int $size An int specifying the size.
* @param string $defaultValue The default value for this column.
* @return ColumnMap Newly created foreign pkey column.
*/
public function addForeignPrimaryKey($columnName, $phpName, $type, $creoleType, $fkTable, $fkColumn, $isNotNull = false, $size = 0)
{
return $this->addColumn($columnName, $phpName, $type, $creoleType, $isNotNull, $size, true, $fkTable, $fkColumn);
}
/**
* Add a pre-created column to this table. It will replace any
* existing column.
*
* @param ColumnMap $cmap A ColumnMap.
* @return ColumnMap The added column map.
*/
public function addConfiguredColumn($cmap)
{
$this->columns[ $cmap->getColumnName() ] = $cmap;
return $cmap;
}
/**
* Add a column to the table.
*
* @param string name A String with the column name.
* @param string $type A string specifying the PHP native type.
* @param int $creoleType The integer representing the Creole type.
* @param boolean $isNotNull Whether column does not allow NULL values.
* @param int $size An int specifying the size.
* @param boolean $pk True if column is a primary key.
* @param string $fkTable A String with the foreign key table name.
* @param $fkColumn A String with the foreign key column name.
* @param string $defaultValue The default value for this column.
* @return ColumnMap The newly created column.
*/
public function addColumn($name, $phpName, $type, $creoleType, $isNotNull = false, $size = null, $pk = null, $fkTable = null, $fkColumn = null)
{
$col = new ColumnMap($name, $this);
if ($fkTable && $fkColumn) {
if (substr($fkColumn, '.') > 0 && substr($fkColumn, $fkTable) !== false) {
$fkColumn = substr($fkColumn, strlen($fkTable) + 1);
}
$col->setForeignKey($fkTable, $fkColumn);
}
$col->setType($type);
$col->setCreoleType($creoleType);
$col->setPrimaryKey($pk);
$col->setSize($size);
$col->setPhpName($phpName);
$col->setNotNull($isNotNull);
$this->columns[$name] = $col;
return $this->columns[$name];
}
/**
* Add a validator to a table's column
*
* @param string $columnName The name of the validator's column
* @param string $name The rule name of this validator
* @param string $classname The dot-path name of class to use (e.g. myapp.propel.MyValidator)
* @param string $value
* @param string $message The error message which is returned on invalid values
* @return void
*/
public function addValidator($columnName, $name, $classname, $value, $message)
{
if (false !== ($pos = strpos($columnName, '.'))) {
$columnName = substr($columnName, $pos + 1);
}
$col = $this->getColumn($columnName);
if ($col !== null) {
$validator = new ValidatorMap($col);
$validator->setName($name);
$validator->setClass($classname);
$validator->setValue($value);
$validator->setMessage($message);
$col->addValidator($validator);
}
}
/**
* Set whether or not to use Id generator for primary key.
* @param boolean $bit
*/
public function setUseIdGenerator($bit) {
$this->useIdGenerator = $bit;
}
/**
* Sets the pk information needed to generate a key
*
* @param $pkInfo information needed to generate a key
*/
public function setPrimaryKeyMethodInfo($pkInfo)
{
$this->pkInfo = $pkInfo;
}
//---Utility methods for doing intelligent lookup of table names
/**
* Tell me if i have PREFIX in my string.
*
* @param data A String.
* @return boolean True if prefix is contained in data.
*/
private function hasPrefix($data)
{
return (substr($data, $this->getPrefix()) !== false);
}
/**
* Removes the PREFIX.
*
* @param string $data A String.
* @return string A String with data, but with prefix removed.
*/
private function removePrefix($data)
{
return substr($data, strlen($this->getPrefix()));
}
/**
* Removes the PREFIX, removes the underscores and makes
* first letter caps.
*
* SCARAB_FOO_BAR becomes FooBar.
*
* @param data A String.
* @return string A String with data processed.
*/
public final function removeUnderScores($data)
{
$tmp = null;
$out = "";
if ($this->hasPrefix($data)) {
$tmp = $this->removePrefix($data);
} else {
$tmp = $data;
}
$tok = strtok($tmp, "_");
while ($tok) {
$out .= ucfirst($tok);
$tok = strtok("_");
}
return $out;
}
/**
* Makes the first letter caps and the rest lowercase.
*
* @param string $data A String.
* @return string A String with data processed.
*/
private function firstLetterCaps($data)
{
return(ucfirst(strtolower($data)));
}
}

109
lib/symfony/vendor/propel/map/ValidatorMap.php vendored Executable file
View File

@ -0,0 +1,109 @@
<?php
/*
* $Id: ValidatorMap.php 536 2007-01-10 14:30:38Z heltem $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information please see
* <http://propel.phpdb.org>.
*/
/**
* ValidatorMap is used to model a column validator.
*
* GENERAL NOTE
* ------------
* The propel.map classes are abstract building-block classes for modeling
* the database at runtime. These classes are similar (a lite version) to the
* propel.engine.database.model classes, which are build-time modeling classes.
* These classes in themselves do not do any database metadata lookups, but instead
* are used by the MapBuilder classes that were generated for your datamodel. The
* MapBuilder that was created for your datamodel build a representation of your
* database by creating instances of the DatabaseMap, TableMap, ColumnMap, etc.
* classes. See propel/templates/om/php5/MapBuilder.tpl and the classes generated
* by that template for your datamodel to further understand how these are put
* together.
*
* @author Michael Aichler <aichler@mediacluster.de>
* @version $Revision: 536 $
* @package propel.map
*/
class ValidatorMap
{
/** rule name of this validator */
private $name;
/** the dot-path to class to use for validator */
private $classname;
/** value to check against */
private $value;
/** execption message thrown on invalid input */
private $message;
/** related column */
private $column;
public function __construct($containingColumn)
{
$this->column = $containingColumn;
}
public function getColumn()
{
return $this->column;
}
public function getColumnName()
{
return $this->column->getColumnName();
}
public function setName($name)
{
$this->name = $name;
}
public function setClass($classname)
{
$this->classname = $classname;
}
public function setValue($value)
{
$this->value = $value;
}
public function setMessage($message)
{
$this->message = $message;
}
public function getName()
{
return $this->name;
}
public function getClass()
{
return $this->classname;
}
public function getValue()
{
return $this->value;
}
public function getMessage()
{
return $this->message;
}
}