Пример #1
0
 /**
  * Constructor.
  * <pre>Configuration options are:
  *  - datasource : Data source configuration, passed to GetDataSource.
  *  - storage-method : Storage method configuration, passed to
  *  GetStorageMethod.
  *  - create-on-save : indicates that the object should be created in the
  *  data source if it doesn't already exist.
  * </pre>
  * @param mixed $config Configuration data for this persistent object.
  * @param mixed $initialData Core object or array with initial data.
  * If $initialData is atomic, and a single identifier (i.e. primary
  * key) is defined by the storage method for the default data souce,
  * then this data is routed to be associated with the field
  * corresponding to that identifier rather than becoming the core
  * object itself.
  */
 function ChunsuObject(&$config, &$initialData)
 {
     // there is too much stuff inside of a chunsu object that might get
     // clobbered, so ensure that the core is not null.
     // TODO: ??? if ( $initialData == NULL ) $initialData = array();
     $this->AtsumiObject($initialData);
     $this->config =& GetConfiguration($config);
     $this->datasource =& GetDataSource($this->config->get('datasource'));
     $this->storage_method =& GetStorageMethod($this, $this->config->get('storage-method'));
     $this->is_loaded = FALSE;
     $this->is_new = $this->config->get('create-on-save');
     $this->changeset = NULL;
 }
Пример #2
0
/**
 * Get all of the configured data sources.
 * @return Configuration All configured data sources.
 */
function &GetDataSources()
{
    global $CONFIGURED_DATASOURCES;
    if (is_null($CONFIGURED_DATASOURCES)) {
        $CONFIGURED_DATASOURCES = GetConfiguration();
    }
    return $CONFIGURED_DATASOURCES;
}
Пример #3
0
/**
 * Get all of the configured storage methods .
 * @param string $pclass Persistent object class.
 * @return Configuration All configured data sources.
 */
function &GetStorageMethods($pclass)
{
    global $CONFIGURED_STORAGEMETHODS;
    $pclass = strtolower($pclass);
    if (!class_exists($pclass)) {
        if (IsLogEnabled('WARN')) {
            LogWarning("Persistent object class {$pclass} does not exist");
        }
    }
    if (is_null($CONFIGURED_STORAGEMETHODS)) {
        $CONFIGURED_STORAGEMETHODS = GetConfiguration();
    }
    if (!$CONFIGURED_STORAGEMETHODS->has($pclass)) {
        $CONFIGURED_STORAGEMETHODS->set(GetConfiguration(), $pclass);
    }
    return $CONFIGURED_STORAGEMETHODS->get($pclass);
}