本文整理汇总了PHP中FLEA::registry方法的典型用法代码示例。如果您正苦于以下问题:PHP FLEA::registry方法的具体用法?PHP FLEA::registry怎么用?PHP FLEA::registry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FLEA
的用法示例。
在下文中一共展示了FLEA::registry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
/**
* 从对象实例容其中取出指定名字的对象实例(已经过时,用 FLEA::registry() 代替)
*
* @param string $name
*
* @return object
* @deprecated
*/
function &ref($name = null)
{
return FLEA::registry($name);
}
示例2: init
/**
* 初始化关联对象
*/
function init()
{
if ($this->init) {
return;
}
if (FLEA::isRegistered($this->assocTDGObjectId)) {
$this->assocTDG =& FLEA::registry($this->assocTDGObjectId);
} else {
if ($this->assocTDGObjectId) {
FLEA::loadClass($this->tableClass);
$this->assocTDG =& new $this->tableClass(array('dbo' => &$this->dbo));
FLEA::register($this->assocTDG, $this->assocTDGObjectId);
} else {
$this->assocTDG =& FLEA::getSingleton($this->tableClass);
}
}
$this->init = true;
}
示例3: init
/**
* 初始化
*
* @param array $options
*/
function init()
{
if ($this->init) {
return;
}
$this->init = true;
$myclass = get_class($this);
$options = call_user_func(array($myclass, 'define'));
$tableClass = $options['tableClass'];
$objid = "{$myclass}_tdg";
if (FLEA::isRegistered($objid)) {
$this->_table =& FLEA::registry($objid);
} else {
FLEA::loadClass($tableClass);
$this->_table =& new $tableClass(array('skipCreateLinks' => true));
FLEA::register($this->_table, $objid);
}
if (!empty($options['propertiesMapping'])) {
$this->_mapping = array('p2f' => $options['propertiesMapping'], 'f2p' => array_flip($options['propertiesMapping']));
$this->_idname = $this->_mapping['f2p'][$this->_table->primaryKey];
} else {
$this->_mapping = array('p2f' => array(), 'f2p' => array());
foreach ($this->_table->meta as $field) {
$this->_mapping['p2f'][$field['name']] = $field['name'];
$this->_mapping['f2p'][$field['name']] = $field['name'];
}
$this->_idname = $this->_table->primaryKey;
}
if (!isset($options['aggregation']) || !is_array($options['aggregation'])) {
$options['aggregation'] = array();
}
foreach ($options['aggregation'] as $offset => $define) {
if (!isset($define['mappingName'])) {
$define['mappingName'] = substr(strtolower($define['tableClass']), 0, 1) . substr($define['tableClass'], 1);
}
if ($define['mappingType'] == HAS_MANY || $define['mappingType'] == MANY_TO_MANY) {
$this->{$define['mappingName']} = array();
} else {
$this->{$define['mappingName']} = null;
}
/**
* 获得聚合对象的定义信息
*/
FLEA::loadClass($define['class']);
$options = call_user_func(array($define['class'], 'define'));
$link = array('tableClass' => $options['tableClass'], 'mappingName' => $define['mappingName'], 'foreignKey' => isset($define['foreignKey']) ? $define['foreignKey'] : null);
if ($define['mappingType'] == MANY_TO_MANY) {
$link['joinTable'] = isset($define['joinTable']) ? $define['joinTable'] : null;
$link['assocForeignKey'] = isset($define['assocForeignKey']) ? $define['assocForeignKey'] : null;
}
$this->_table->createLink($link, $define['mappingType']);
$define['link'] =& $this->_table->getLink($link['mappingName']);
$this->_aggregation[$offset] = $define;
}
}