1
0
mirror of synced 2024-12-15 07:36:03 +03:00
doctrine2/lib/Doctrine/I18n.php

92 lines
3.1 KiB
PHP
Raw Normal View History

2007-09-02 15:55:12 +04:00
<?php
/*
* $Id$
*
* 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, see
* <http://www.phpdoctrine.org>.
2007-09-02 15:55:12 +04:00
*/
2007-09-02 15:55:12 +04:00
/**
* Doctrine_I18n
*
* @package Doctrine
* @subpackage I18n
2007-09-02 15:55:12 +04:00
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
2007-11-29 01:56:45 +03:00
class Doctrine_I18n extends Doctrine_Record_Generator
2007-09-02 15:55:12 +04:00
{
protected $_options = array(
'className' => '%CLASS%Translation',
'fields' => array(),
'generateFiles' => false,
'table' => false,
2007-09-07 00:23:52 +04:00
'pluginTable' => false,
2007-11-14 01:28:37 +03:00
'children' => array(),
2007-09-02 15:55:12 +04:00
);
/**
* __construct
*
* @param string $options
* @return void
*/
2007-09-02 15:55:12 +04:00
public function __construct($options)
{
$this->_options = array_merge($this->_options, $options);
}
public function buildRelation()
{
$this->buildForeignRelation('Translation');
$this->buildLocalRelation();
}
/**
* buildDefinition
*
* @param object $Doctrine_Table
* @return void
*/
public function setTableDefinition()
2007-09-02 15:55:12 +04:00
{
if (empty($this->_options['fields'])) {
throw new Doctrine_I18n_Exception('Fields not set.');
}
2007-09-05 00:56:16 +04:00
$options = array('className' => $this->_options['className']);
2007-09-02 15:55:12 +04:00
2007-11-25 15:34:37 +03:00
$cols = $this->_options['table']->getColumns();
2007-09-02 15:55:12 +04:00
foreach ($cols as $column => $definition) {
if (in_array($column, $this->_options['fields'])) {
$columns[$column] = $definition;
2007-11-25 15:34:37 +03:00
$this->_options['table']->removeColumn($column);
2007-09-02 15:55:12 +04:00
}
}
2007-11-25 15:34:37 +03:00
$this->hasColumns($columns);
2007-09-07 00:23:52 +04:00
$this->hasColumn('lang', 'string', 2, array('fixed' => true,
'primary' => true));
$this->bindQueryParts(array('indexBy' => 'lang'));
2007-09-02 15:55:12 +04:00
}
2007-11-14 01:28:37 +03:00
}