Skip to content

Commit

Permalink
Move app Injector/Factory to just Factory/
Browse files Browse the repository at this point in the history
Mirrors use of Horde_Core_Factory.
Additionally, these factory injectors don't extend any Horde_Injector
class.
  • Loading branch information
slusarz committed Jan 27, 2011
1 parent e4b7e63 commit e308281
Show file tree
Hide file tree
Showing 28 changed files with 62 additions and 62 deletions.
2 changes: 1 addition & 1 deletion add.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/* A source has been selected, connect and set up the fields. */
if ($source) {
try {
$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
} catch (Turba_Exception $e) {
$notification->push($e, 'horde.error');
$driver = null;
Expand Down
2 changes: 1 addition & 1 deletion contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

/* Set the contact from the key requested. */
try {
$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
} catch (Turba_Exception $e) {
$notification->push($e, 'horde.error');
Horde::url($prefs->getValue('initial_page'), true)->redirect();
Expand Down
6 changes: 3 additions & 3 deletions data.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ function _getBareEmail($address, $allow_multi = false)
foreach ($sources as $source => $objectkeys) {
/* Create a Turba storage instance. */
try {
$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $injector->getInstance('Turba_Factory_Driver')->create($source);
} catch (Turba_Exception $e) {
$notification->push($e, 'horde.error');
$error = true;
Expand Down Expand Up @@ -335,7 +335,7 @@ function _getBareEmail($address, $allow_multi = false)
case Horde_Data::IMPORT_FILE:
$dest = Horde_Util::getFormData('dest');
try {
$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($dest);
$driver = $injector->getInstance('Turba_Factory_Driver')->create($dest);
} catch (Turba_Exception $e) {
$notification->push($e, 'horde.error');
$error = true;
Expand Down Expand Up @@ -423,7 +423,7 @@ function _getBareEmail($address, $allow_multi = false)
/* Create a Turba storage instance. */
$dest = $session->get('horde', 'import_data/target');
try {
$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($dest);
$driver = $injector->getInstance('Turba_Factory_Driver')->create($dest);
} catch (Turba_Exception $e) {
$notification->push($e, 'horde.error');
$driver = null;
Expand Down
2 changes: 1 addition & 1 deletion delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

$source = Horde_Util::getFormData('source');
$key = Horde_Util::getFormData('key');
$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $injector->getInstance('Turba_Factory_Driver')->create($source);

if ($conf['documents']['type'] != 'none') {
try {
Expand Down
2 changes: 1 addition & 1 deletion deletefile.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
Horde::url($prefs->getValue('initial_page'), true)->redirect();
}

$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $injector->getInstance('Turba_Factory_Driver')->create($source);

try {
$contact = $driver->getObject(Horde_Util::getPost('key'));
Expand Down
2 changes: 1 addition & 1 deletion edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
$url->redirect();
}

$driver = $injector->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $injector->getInstance('Turba_Factory_Driver')->create($source);

/* Set the contact from the requested key. */
try {
Expand Down
44 changes: 22 additions & 22 deletions lib/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function commentCallback($id)
@list($source, $key) = explode('.', $id, 2);
if (isset($GLOBALS['cfgSources'][$source]) && $key) {
try {
$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
$object = $driver->getObject($key)->getValue('name');
} catch (Turba_Exception $e) {}
}
Expand Down Expand Up @@ -134,7 +134,7 @@ public function getDefaultShare()
}

try {
$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($params['source']);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($params['source']);
if ($driver->checkDefaultShare($share, $cfgSources[$params['source']])) {
return $uid;
}
Expand Down Expand Up @@ -322,7 +322,7 @@ public function browse($path = '', $properties = array())
}

// Load the Turba driver.
$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($parts[1]);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($parts[1]);

$contacts = $driver->search(array());

Expand Down Expand Up @@ -371,7 +371,7 @@ public function browse($path = '', $properties = array())
}

// Load the Turba driver.
$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($parts[1]);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($parts[1]);

$contact = $driver->getObject($parts[2]);

Expand Down Expand Up @@ -418,7 +418,7 @@ public function path_delete($path)
}

// Load the Turba driver.
$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($parts[1]);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($parts[1]);

return $driver->delete($parts[2]);
}
Expand Down Expand Up @@ -458,7 +458,7 @@ public function listUids($sources = null)
throw new Turba_Exception(sprintf(_("Invalid address book: %s"), $source));
}

$storage = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
$storage = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);

try {
$results = $storage->search(array());
Expand Down Expand Up @@ -518,7 +518,7 @@ public function listBy($action, $timestamp, $sources = null, $end = null)
throw new Turba_Exception(sprintf(_("Invalid address book: %s"), $source));
}

$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);

$histories = $history->getByTimestamp(
'>', $timestamp, $filter,
Expand Down Expand Up @@ -589,7 +589,7 @@ public function getActionTimestamp($uid, $action, $sources = null)
throw new Turba_Exception(sprintf(_("Invalid address book: %s"), $source));
}

$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);

$ts = $history->getActionTimestamp('turba:' . $driver->getName()
. ':' . $uid,
Expand Down Expand Up @@ -635,7 +635,7 @@ public function import($content, $contentType = 'array',
throw new Turba_Exception(sprintf(_("Invalid address book: %s"), $import_source));
}

$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($import_source);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($import_source);

if (!$driver->hasPermission(Horde_Perms::EDIT)) {
throw new Turba_Exception(_("Permission denied"));
Expand Down Expand Up @@ -763,7 +763,7 @@ public function export($uid, $contentType, $sources = null, $fields = null)
throw new Turba_Exception(_("Invalid ID"));
}

$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);

if (!$driver->hasPermission(Horde_Perms::READ)) {
continue;
Expand Down Expand Up @@ -827,7 +827,7 @@ public function export($uid, $contentType, $sources = null, $fields = null)
public function ownVCard()
{
$contact = $this->getOwnContactObject();
$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($contact['source']);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($contact['source']);

$vcard = $driver->tovCard($contact['contact'], '3.0', null, true);
$vcard->setAttribute('VERSION', '3.0');
Expand Down Expand Up @@ -868,7 +868,7 @@ public function getOwnContactObject()
throw new Turba_Exception(_("The address book with your own contact doesn't exist anymore."));
}

$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);

if (!$driver->hasPermission(Horde_Perms::READ)) {
throw new Turba_Exception(_("You don't have sufficient permissions to read the address book that contains your own contact."));
Expand Down Expand Up @@ -933,7 +933,7 @@ public function delete($uid, $sources = null)
throw new Turba_Exception(_("Invalid ID"));
}

$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);

if (!$GLOBALS['registry']->isAdmin() &&
!$driver->hasPermission(Horde_Perms::DELETE)) {
Expand Down Expand Up @@ -996,7 +996,7 @@ public function replace($uid, $content, $contentType, $sources = null)
}

// Check permissions.
$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
if (!$driver->hasPermission(Horde_Perms::EDIT)) {
continue;
}
Expand Down Expand Up @@ -1121,7 +1121,7 @@ public function search($names = array(), $sources = array(),
continue;
}

$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);

// Determine the name of the column to sort by.
$columns = isset($sort_columns[$source])
Expand Down Expand Up @@ -1274,7 +1274,7 @@ public function getContact($source = null, $objectId = '')
}

if (isset($cfgSources[$source])) {
$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);

$object = $driver->getObject($objectId);

Expand Down Expand Up @@ -1310,7 +1310,7 @@ public function getContacts($source = '', $objectIds = array())
}

if (isset($cfgSources[$source])) {
$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);

$objects = $driver->getObjects($objectIds);

Expand Down Expand Up @@ -1351,7 +1351,7 @@ public function getAllAttributeValues($field = '', $sources = array())
$results = array();
foreach ($sources as $source) {
if (isset($cfgSources[$source])) {
$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);

$res = $driver->search(array());
if (!($res instanceof Turba_List)) {
Expand Down Expand Up @@ -1419,7 +1419,7 @@ public function listTimeObjects($time_categories, $start, $end)
$objects = array();
foreach ($time_categories as $category) {
list($category, $source) = explode('/', $category, 2);
$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
$objects = array_merge($objects, $driver->listTimeObjects($start, $end, $category));
}

Expand Down Expand Up @@ -1563,7 +1563,7 @@ public function addField($address = '', $name = '', $field = '',
throw new Turba_Exception(_("Invalid entry"));
}

$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);

if (!$driver->hasPermission(Horde_Perms::EDIT)) {
throw new Turba_Exception(_("Permission denied"));
Expand Down Expand Up @@ -1654,7 +1654,7 @@ public function getField($address = '', $field = '', $sources = array(),
continue;
}

$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
$criterium = array('email' => $address);
if (!isset($driver->map['email'])) {
if (isset($driver->map['emails'])) {
Expand Down Expand Up @@ -1719,7 +1719,7 @@ public function deleteField($address = '', $field = '', $sources = array())

foreach ($sources as $source) {
if (isset($cfgSources[$source])) {
$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
if (!$driver->hasPermission(Horde_Perms::EDIT)) {
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ public function removeUserData($user)
if (empty($source['use_shares'])) {
// Shares not enabled for this source
try {
$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
} catch (Turba_Exception $e) {
Horde::logMessage($e, 'ERR');
throw new Turba_Exception(sprintf(_("There was an error removing an address book for %s"), $user));
Expand Down Expand Up @@ -433,7 +433,7 @@ public function removeUserData($user)
if (!empty($params['default'])) {
$config = Turba::getSourceFromShare($share);
try {
$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($config);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($config);
} catch (Turba_Exception $e) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Driver/Share.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct($name = '', array $params = array())
{
parent::__construct($name, $params);
$this->_share = $this->_params['config']['params']['share'];
$this->_driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($this->_params['config']);
$this->_driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($this->_params['config']);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Driver/Vbook.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct($name = '', array $params = array())
$this->_share = $this->_params['share'];

/* Load the underlying driver. */
$this->_driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($this->_params['source']);
$this->_driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($this->_params['source']);

$this->searchCriteria = empty($this->_params['criteria'])
? array()
Expand Down
2 changes: 1 addition & 1 deletion lib/Injector/Factory/Driver.php → lib/Factory/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @link http://pear.horde.org/index.php?package=Turba
* @package Turba
*/
class Turba_Injector_Factory_Driver
class Turba_Factory_Driver
{
/**
* Instances.
Expand Down
2 changes: 1 addition & 1 deletion lib/Form/CreateAddressBook.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function execute()
// Need a clean cfgSources array
include TURBA_BASE . '/config/backends.php';

$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($cfgSources[$GLOBALS['conf']['shares']['source']]);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($cfgSources[$GLOBALS['conf']['shares']['source']]);

$params = array(
'params' => array('source' => $GLOBALS['conf']['shares']['source']),
Expand Down
2 changes: 1 addition & 1 deletion lib/Form/DeleteAddressBook.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function execute()
throw new Turba_Exception(_("You do not have permissions to delete this address book."));
}

$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($this->_addressbook->getName());
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($this->_addressbook->getName());

// We have a Turba_Driver, try to delete the address book.
$driver->deleteAll();
Expand Down
2 changes: 1 addition & 1 deletion lib/List.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(array $ids = array())
foreach ($ids as $value) {
list($source, $key) = explode(':', $value);
try {
$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
$this->insert($driver->getObject($key));
} catch (Turba_Exception $e) {}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/LoginTasks/SystemTask/UpgradeLists.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function execute()
$sources = array_keys($GLOBALS['cfgSources']);
foreach ($sources as $sourcekey) {
try {
$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($sourcekey);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($sourcekey);
$lists = $driver->search($criteria);
} catch (Turba_Exception $e) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions lib/Object/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function addMember($contactId, $sourceId = null)
if ($sourceId == $this->getSource()) {
$contact = $this->driver->getObject($contactId);
} else {
$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($sourceId);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($sourceId);
$contact = $driver->getObject($contactId);
}

Expand Down Expand Up @@ -172,7 +172,7 @@ public function listMembers($sort = null)
}

try {
$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($sourceId);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($sourceId);
} catch (Turba_Exception $e) {
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Turba.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ static public function permissionsFilter(array $in, $permission = Horde_Perms::R

foreach ($in as $sourceId => $source) {
try {
$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($sourceId);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($sourceId);
} catch (Turba_Exception $e) {
Horde::logMessage($e, 'ERR');
continue;
Expand Down Expand Up @@ -454,7 +454,7 @@ static public function getConfigFromShares(array $sources)
if ($GLOBALS['registry']->getAuth() && !$personal) {
// User's default share is missing.
try {
$driver = $GLOBALS['injector']->getInstance('Turba_Injector_Factory_Driver')->create($source);
$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($source);
} catch (Turba_Exception $e) {
$GLOBALS['notification']->push($driver, 'horde.error');
continue;
Expand Down
Loading

0 comments on commit e308281

Please sign in to comment.