aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/sfIsisImporter.class.php17
-rw-r--r--lib/sfIsisImporterEntities.class.php25
-rw-r--r--lib/sfIsisImporterManager.class.php4
-rw-r--r--lib/sfIsisImporterRelations.class.php8
4 files changed, 31 insertions, 23 deletions
diff --git a/lib/sfIsisImporter.class.php b/lib/sfIsisImporter.class.php
index 6119d35..acdf137 100644
--- a/lib/sfIsisImporter.class.php
+++ b/lib/sfIsisImporter.class.php
@@ -21,8 +21,9 @@ class sfIsisImporter extends sfIsisImporterRelations
* Constructor.
*/
public function __construct($config = null) {
- parent::__construct($config);
- $this->stats = sfIsisImporterStats::getInstance();
+ $this->stats = sfIsisImporterStats::getInstance();
+ $this->isis = new IsisConnector($config);
+ $this->relations = new sfIsisImporterRelations($this->isis);
// Get a logger instance.
$this->logger = sfIsisImporterLog::getInstance();
@@ -92,7 +93,7 @@ class sfIsisImporter extends sfIsisImporterRelations
public function addEntry($base_model, $entry)
{
// Get data and setup the model.
- $this->read($entry);
+ $this->isis->read($entry);
$model = $this->newModel($base_model, $entry);
if ($model)
@@ -100,7 +101,7 @@ class sfIsisImporter extends sfIsisImporterRelations
$this->log("Importing $base_model $entry...");
// Dispatch to custom import procedures.
- foreach (new IsisMethodIterator($this) as $method => $field)
+ foreach (new IsisMethodIterator($this->isis, $this) as $method => $field)
{
if (!$this->hasDeniedCombinations($base_model, $field))
{
@@ -159,9 +160,9 @@ class sfIsisImporter extends sfIsisImporterRelations
*/
public function skipExisting()
{
- if (isset($this->format['import']['skip_existing']))
+ if (isset($this->isis->format['import']['skip_existing']))
{
- return $this->format['import']['skip_existing'];
+ return $this->isis->format['import']['skip_existing'];
}
return true;
@@ -212,7 +213,7 @@ class sfIsisImporter extends sfIsisImporterRelations
foreach ($combination as $item)
{
- foreach (new IsisRowIterator($this, $field) as $row)
+ foreach (new IsisRowIterator($this->isis, $field) as $row)
{
if (!$this->hasDeniedItem($field, $item, $row))
{
@@ -266,7 +267,7 @@ class sfIsisImporter extends sfIsisImporterRelations
}
// Check if the item exists.
- $has = $this->hasItem($field, $item, $row);
+ $has = $this->isis->hasItem($field, $item, $row);
if ($condition == true)
{
diff --git a/lib/sfIsisImporterEntities.class.php b/lib/sfIsisImporterEntities.class.php
index cd66afd..73fe3af 100644
--- a/lib/sfIsisImporterEntities.class.php
+++ b/lib/sfIsisImporterEntities.class.php
@@ -4,7 +4,14 @@
* IsisImporterEntities: provides ISIS import methods for importing data
* into model entities.
*/
-class sfIsisImporterEntities extends IsisConnector {
+class sfIsisImporterEntities {
+ /**
+ * Constructor.
+ */
+ public function __construct($isis) {
+ $this->isis = $isis;
+ }
+
/**
* Get the entity name from a subfield.
*
@@ -25,11 +32,11 @@ class sfIsisImporterEntities extends IsisConnector {
*/
public function addMain(&$model, $field, $row = 0)
{
- $value = $this->filterBrackets($this->getMainItem($field, $row));
+ $value = $this->isis->filterBrackets($this->isis->getMainItem($field, $row));
if ($value != null)
{
- $map = $this->getMap($field);
+ $map = $this->isis->getMap($field);
$model->{$map}($value);
}
}
@@ -44,11 +51,11 @@ class sfIsisImporterEntities extends IsisConnector {
*/
public function addSubfield(&$model, $field, $subfield, $row = 0)
{
- $value = $this->filterBrackets($this->getSubfield($field, $subfield, $row));
+ $value = $this->isis->filterBrackets($this->isis->getSubfield($field, $subfield, $row));
if ($value != null)
{
- $map = $this->getMap($field, $subfield);
+ $map = $this->isis->getMap($field, $subfield);
$model->{$map}($value);
}
}
@@ -62,7 +69,7 @@ class sfIsisImporterEntities extends IsisConnector {
*/
public function addSubfields(&$model, $field, $row = 0)
{
- foreach ($this->getSubfieldList($field) as $subfield)
+ foreach ($this->isis->getSubfieldList($field) as $subfield)
{
$this->addSubfield($model, $field, $subfield, $row);
}
@@ -85,14 +92,14 @@ class sfIsisImporterEntities extends IsisConnector {
*/
public function importValues(&$model, array $field)
{
- if ($this->fieldHasMap($field))
+ if ($this->isis->fieldHasMap($field))
{
$this->addMain($model, $field);
}
- foreach ($this->getSubfieldList($field) as $subfield)
+ foreach ($this->isis->getSubfieldList($field) as $subfield)
{
- if ($this->subfieldHasMap($field, $subfield))
+ if ($this->isis->subfieldHasMap($field, $subfield))
{
$this->addSubfield($model, $field, $subfield);
}
diff --git a/lib/sfIsisImporterManager.class.php b/lib/sfIsisImporterManager.class.php
index c808ea8..1a2d1ff 100644
--- a/lib/sfIsisImporterManager.class.php
+++ b/lib/sfIsisImporterManager.class.php
@@ -145,8 +145,8 @@ class sfIsisImporterManager extends IsisConnector
{
// Determine base model and max entries.
$this->log('Starting mass import procedure for database schema "'. $database .'".', 'notice');
- $base_model = $importer->format['import']['base_model'];
- $this->entries = ($entries != NULL && $entries <= $importer->entries) ? $entries : $importer->entries;
+ $base_model = $importer->isis->format['import']['base_model'];
+ $this->entries = ($entries != NULL && $entries <= $importer->isis->entries) ? $entries : $importer->entries;
if ($base_model) {
for ($entry = 1; $entry <= $this->entries; $entry++)
diff --git a/lib/sfIsisImporterRelations.class.php b/lib/sfIsisImporterRelations.class.php
index 6912305..956d287 100644
--- a/lib/sfIsisImporterRelations.class.php
+++ b/lib/sfIsisImporterRelations.class.php
@@ -14,7 +14,7 @@ class sfIsisImporterRelations extends sfIsisImporterEntities {
*/
public function addOneToOne(&$model, array $field, $relation)
{
- foreach (new IsisRowIterator($this, $field) as $row)
+ foreach (new IsisRowIterator($this->isis, $field) as $row)
{
$data = new $relation();
@@ -51,7 +51,7 @@ class sfIsisImporterRelations extends sfIsisImporterEntities {
*/
public function addOneToManyMain(&$model, array $field, $entity, $key = 'name')
{
- foreach (new IsisMainItemIterator($this, $field) as $row => $value)
+ foreach (new IsisMainItemIterator($this->isis, $field) as $row => $value)
{
$this->log("Entity: $entity; Value: $value", 'debug');
$data = $this->addOneToMany($model, $entity);
@@ -136,9 +136,9 @@ class sfIsisImporterRelations extends sfIsisImporterEntities {
*/
public function addManyToManyMain(&$model, array $field, $relation, $key = 'name')
{
- foreach (new IsisMainItemIterator($this, $field) as $value)
+ foreach (new IsisMainItemIterator($this->isis, $field) as $value)
{
- $this->addManyToManyEntities($model, $this->explodeBrackets($value), $relation, $key);
+ $this->addManyToManyEntities($model, $this->isis->explodeBrackets($value), $relation, $key);
}
}
}