Commit 2b32b9a1 authored by Nigel McNie's avatar Nigel McNie
Browse files

Change method signatures to use PluginImportLeap instead of PluginImport.


Signed-off-by: default avatarNigel McNie <nigel@catalyst.net.nz>
parent 162df085
......@@ -50,7 +50,7 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
*/
const STRATEGY_IMPORT_AS_ENTRY = 2;
public static function get_import_strategies_for_entry(SimpleXMLElement $entry, PluginImport $importer) {
public static function get_import_strategies_for_entry(SimpleXMLElement $entry, PluginImportLeap $importer) {
$strategies = array();
if (PluginImportLeap::is_rdf_type($entry, $importer, 'selection')
......@@ -87,7 +87,7 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
return $strategies;
}
public static function import_using_strategy(SimpleXMLElement $entry, PluginImport $importer, $strategy, array $otherentries) {
public static function import_using_strategy(SimpleXMLElement $entry, PluginImportLeap $importer, $strategy, array $otherentries) {
$artefactmapping = array();
switch ($strategy) {
case self::STRATEGY_IMPORT_AS_BLOG:
......@@ -137,7 +137,7 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
* If importing an entry resulted in importing a new file (caused by the
* entry having out-of-line content), we attach that file to the entry.
*/
public static function setup_relationships(SimpleXMLElement $entry, PluginImport $importer, $strategy, array $otherentries) {
public static function setup_relationships(SimpleXMLElement $entry, PluginImportLeap $importer, $strategy, array $otherentries) {
switch ($strategy) {
case self::STRATEGY_IMPORT_AS_BLOG:
foreach ($otherentries as $entryid) {
......
......@@ -47,7 +47,7 @@ class LeapImportFile extends LeapImportArtefactPlugin {
*/
const STRATEGY_IMPORT_AS_FOLDER = 2;
public static function get_import_strategies_for_entry(SimpleXMLElement $entry, PluginImport $importer) {
public static function get_import_strategies_for_entry(SimpleXMLElement $entry, PluginImportLeap $importer) {
$strategies = array();
if (!self::has_parent_folder($entry, $importer)) {
......@@ -77,7 +77,7 @@ class LeapImportFile extends LeapImportArtefactPlugin {
// TODO: we're assuming an empty files area to work with, but that might
// not be the case, in which case we have conflicting file/folder names to
// deal with!
public static function import_using_strategy(SimpleXMLElement $entry, PluginImport $importer, $strategy, array $otherentries) {
public static function import_using_strategy(SimpleXMLElement $entry, PluginImportLeap $importer, $strategy, array $otherentries) {
$artefactmapping = array();
switch ($strategy) {
case self::STRATEGY_IMPORT_AS_FILE:
......@@ -99,11 +99,11 @@ class LeapImportFile extends LeapImportArtefactPlugin {
* if it's of rdf:type rdf:resource. This may be more strict than necessary
* - possibly just having the content ouf of line should be enough.
*
* @param SimpleXMLElement $entry The entry to check
* @param PluginImport $importer The importer
* @param SimpleXMLElement $entry The entry to check
* @param PluginImportLeap $importer The importer
* @return boolean Whether the entry is a file
*/
private static function is_file(SimpleXMLElement $entry, PluginImport $importer) {
private static function is_file(SimpleXMLElement $entry, PluginImportLeap $importer) {
return PluginImportLeap::is_rdf_type($entry, $importer, 'resource')
&& isset($entry->content['src']);
}
......@@ -111,11 +111,11 @@ class LeapImportFile extends LeapImportArtefactPlugin {
/**
* Returns whether the given entry is a folder
*
* @param SimpleXMLElement $entry The entry to check
* @param PluginImport $importer The importer
* @param SimpleXMLElement $entry The entry to check
* @param PluginImportLeap $importer The importer
* @return boolean Whether the entry is a folder
*/
private static function is_folder(SimpleXMLElement $entry, PluginImport $importer) {
private static function is_folder(SimpleXMLElement $entry, PluginImportLeap $importer) {
static $cache = array();
$id = (string)$entry->id;
if (isset($cache[$id])) {
......@@ -132,11 +132,11 @@ class LeapImportFile extends LeapImportArtefactPlugin {
* The entry itself can be any entry, although in the context of this
* plugin, it is a file or folder.
*
* @param SimpleXMLElement $entry The entry to check
* @param PluginImport $importer The importer
* @param SimpleXMLElement $entry The entry to check
* @param PluginImportLeap $importer The importer
* @return boolean Whether this entry is in a folder
*/
private static function has_parent_folder(SimpleXMLElement $entry, PluginImport $importer) {
private static function has_parent_folder(SimpleXMLElement $entry, PluginImportLeap $importer) {
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], PluginImportLeap::NS_LEAP, 'is_part_of') && isset($link['href'])) {
$potentialfolder = $importer->get_entry_by_id((string)$link['href']);
......@@ -156,12 +156,12 @@ class LeapImportFile extends LeapImportArtefactPlugin {
*
* TODO: protection against circular references
*
* @param SimpleXMLElement $entry The folder to get children for
* @param PluginImport $importer The importer
* @param boolean $recurse Whether to return children at all levels below this folder
* @param SimpleXMLElement $entry The folder to get children for
* @param PluginImportLeap $importer The importer
* @param boolean $recurse Whether to return children at all levels below this folder
* @return array A list of the entry IDs of children in this folder
*/
private static function get_children_of_folder(SimpleXMLElement $entry, PluginImport $importer, $recurse=false) {
private static function get_children_of_folder(SimpleXMLElement $entry, PluginImportLeap $importer, $recurse=false) {
$children = array();
// Get entries that this folder feels are a part of it
......@@ -197,13 +197,13 @@ class LeapImportFile extends LeapImportArtefactPlugin {
/**
* Creates a file artefact based on the given entry.
*
* @param SimpleXMLElement $entry The entry to base the file's data on
* @param PluginImport $importer The importer
* @param int $parent The ID of the parent artefact for this file
* @param SimpleXMLElement $entry The entry to base the file's data on
* @param PluginImportLeap $importer The importer
* @param int $parent The ID of the parent artefact for this file
* @throws ImportException If the given entry is not detected as being a file
* @return ArtefactTypeFile The file artefact created
*/
public static function create_file(SimpleXMLElement $entry, PluginImport $importer, $parent=null) {
public static function create_file(SimpleXMLElement $entry, PluginImportLeap $importer, $parent=null) {
if (!self::is_file($entry, $importer)) {
throw new ImportException($importer, "create_file(): Cannot create a file artefact from an entry we don't recognise as a file");
}
......@@ -283,13 +283,13 @@ class LeapImportFile extends LeapImportArtefactPlugin {
/**
* Creates a folder artefact based on the given entry.
*
* @param SimpleXMLElement $entry The entry to base the folder's data on
* @param PluginImport $importer The importer
* @param int $parent The ID of the parent artefact for this folder
* @param SimpleXMLElement $entry The entry to base the folder's data on
* @param PluginImportLeap $importer The importer
* @param int $parent The ID of the parent artefact for this folder
* @throws ImportException If the given entry is not detected as being a folder
* @return int The ID of the folder artefact created
*/
private static function create_folder(SimpleXMLElement $entry, PluginImport $importer, $parent=null) {
private static function create_folder(SimpleXMLElement $entry, PluginImportLeap $importer, $parent=null) {
if (!self::is_folder($entry, $importer)) {
throw new ImportException($importer, "create_folder(): Cannot create a folder artefact from an entry we don't recognise as a folder");
}
......@@ -315,15 +315,15 @@ class LeapImportFile extends LeapImportArtefactPlugin {
/**
* Creates a folder, and recursively, all folders and files under it.
*
* @param SimpleXMLElement $entry The entry to base the folder's data on
* @param PluginImport $importer The importer
* @param int $parent The ID of the parent artefact for this folder
* @param SimpleXMLElement $entry The entry to base the folder's data on
* @param PluginImportLeap $importer The importer
* @param int $parent The ID of the parent artefact for this folder
* @throws ImportException If the given entry is not detected as being a folder
* @return array The artefact mapping for the folder and all children - a
* list of entry ID => artefact IDs for each entry processed. See
* PluginImport::import_from_load_mapping() for more information
*/
private static function create_folder_and_children(SimpleXMLElement $entry, PluginImport $importer, $parent=null) {
private static function create_folder_and_children(SimpleXMLElement $entry, PluginImportLeap $importer, $parent=null) {
if (!self::is_folder($entry, $importer)) {
throw new ImportException($importer, "create_folder(): Cannot create a folder artefact from an entry we don't recognise as a folder");
}
......
......@@ -145,7 +145,7 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
* - these can be used to populate some of our profile fields that aren't
* explicitly mapped in LEAP2A.
*/
public static function get_import_strategies_for_entry(SimpleXMLElement $entry, PluginImport $importer) {
public static function get_import_strategies_for_entry(SimpleXMLElement $entry, PluginImportLeap $importer) {
$strategies = array();
// If it's a raw entry with the right mahara:plugin and mahara:type
......@@ -162,7 +162,7 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
return $strategies;
}
public static function import_using_strategy(SimpleXMLElement $entry, PluginImport $importer, $strategy, array $otherentries) {
public static function import_using_strategy(SimpleXMLElement $entry, PluginImportLeap $importer, $strategy, array $otherentries) {
$artefactmapping = array();
switch ($strategy) {
case self::STRATEGY_IMPORT_AS_PROFILE_FIELD:
......@@ -199,9 +199,9 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
* Otherwise, we can only import some very basic information from the
* <author> element.
*
* @param PluginImport $importer The importer
* @param PluginImportLeap $importer The importer
*/
public static function import_author_data(PluginImport $importer, $persondataid) {
public static function import_author_data(PluginImportLeap $importer, $persondataid) {
if ($persondataid) {
// Grab all the leap:persondata elements and import them
$person = $importer->get_entry_by_id($persondataid);
......@@ -271,7 +271,7 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
/**
* Attempts to import a persondata element
*/
private static function import_persondata(PluginImport $importer, SimpleXMLElement $item, array $leapattributes) {
private static function import_persondata(PluginImportLeap $importer, SimpleXMLElement $item, array $leapattributes) {
$field = $leapattributes['field'];
if (isset(self::$persondatafields[$field]['mahara_fieldname'])) {
......@@ -299,7 +299,7 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
/**
* Attempts to import a persondata field with leap:field="id"
*/
public static function import_persondata_id(PluginImport $importer, SimpleXMLElement $item, array $leapattributes) {
public static function import_persondata_id(PluginImportLeap $importer, SimpleXMLElement $item, array $leapattributes) {
if ($leapattributes['field'] == 'id' && !isset($leapattributes['service'])) {
// 'id' must have a service set
// http://wiki.cetis.ac.uk/2009-03/LEAP2A_personal_data#service
......@@ -321,7 +321,7 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
/**
* Attempts to import a persondata field with leap:field="website"
*/
private static function import_persondata_website(PluginImport $importer, SimpleXMLEntry $item, array $leapattributes) {
private static function import_persondata_website(PluginImportLeap $importer, SimpleXMLEntry $item, array $leapattributes) {
// We've been given a 'website' field, but Mahara has three profile
// fields for website. So we need to examine it deeper to establish
// which field it should import into
......@@ -353,7 +353,7 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
/**
* Attempts to import a persondata field with leap:field="other"
*/
private static function import_persondata_other(PluginImport $importer, SimpleXMLEntry $item, array $leapattributes) {
private static function import_persondata_other(PluginImportLeap $importer, SimpleXMLEntry $item, array $leapattributes) {
// The only 'other' field we can actually import is one we recognise as
// 'student ID'
$maharaattributes = PluginImportLeap::get_attributes($item, PluginImportLeap::NS_MAHARA);
......@@ -375,7 +375,7 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
* Imports info from a leap:spatial element as a user's address-related
* profile fields
*/
private static function import_addressdata(PluginImport $importer, SimpleXMLElement $addressdata) {
private static function import_addressdata(PluginImportLeap $importer, SimpleXMLElement $addressdata) {
// TODO: this xpath doesn't respect the namespace prefix - we should
// look it up from $importer->namespaces[NS_LEAP]
$addresslines = $addressdata->xpath('leap:addressline');
......@@ -429,7 +429,7 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
}
}
private static function import_namedata(PluginImport $importer, array $persondata) {
private static function import_namedata(PluginImportLeap $importer, array $persondata) {
$namefields = array(
'full_name' => false,
'legal_family_name' => false,
......@@ -489,13 +489,13 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
* Creates an artefact in the manner required to overwrite existing profile
* artefacts
*
* @param PluginImport $importer The importer
* @param string $artefacttype The type of artefact to create
* @param string $title The title for the artefact (with profile
* fields, this is the main data)
* @param PluginImportLeap $importer The importer
* @param string $artefacttype The type of artefact to create
* @param string $title The title for the artefact (with profile
* fields, this is the main data)
* @return int The ID of the artefact created
*/
private static function create_artefact(PluginImport $importer, $artefacttype, $title) {
private static function create_artefact(PluginImportLeap $importer, $artefacttype, $title) {
$classname = 'ArtefactType' . ucfirst($artefacttype);
$artefact = new $classname(0, array('owner' => $importer->get('usr')));
$artefact->set('title', $title);
......
......@@ -75,7 +75,7 @@ class LeapImportResume extends LeapImportArtefactPlugin {
/**
* Description of strategies used
*/
public static function get_import_strategies_for_entry(SimpleXMLElement $entry, PluginImport $importer) {
public static function get_import_strategies_for_entry(SimpleXMLElement $entry, PluginImportLeap $importer) {
$strategies = array();
$correctplugintype = count($entry->xpath('mahara:artefactplugin[@mahara:plugin="resume"]')) == 1;
......@@ -205,7 +205,7 @@ class LeapImportResume extends LeapImportArtefactPlugin {
return array();
}
public static function import_using_strategy(SimpleXMLElement $entry, PluginImport $importer, $strategy, array $otherentries) {
public static function import_using_strategy(SimpleXMLElement $entry, PluginImportLeap $importer, $strategy, array $otherentries) {
$artefactmapping = array();
switch ($strategy) {
case self::STRATEGY_IMPORT_AS_ENTRY:
......@@ -411,13 +411,13 @@ class LeapImportResume extends LeapImportArtefactPlugin {
* Creates an artefact in the manner required to overwrite existing profile
* artefacts
*
* @param PluginImport $importer The importer
* @param string $artefacttype The type of artefact to create
* @param string $title The title for the artefact
* @param string $content The content for the artefact
* @param PluginImportLeap $importer The importer
* @param string $artefacttype The type of artefact to create
* @param string $title The title for the artefact
* @param string $content The content for the artefact
* @return int The ID of the artefact created
*/
private static function create_artefact(PluginImport $importer, $artefacttype, $title, $content) {
private static function create_artefact(PluginImportLeap $importer, $artefacttype, $title, $content) {
$classname = 'ArtefactType' . ucfirst($artefacttype);
$artefact = new $classname(0, array('owner' => $importer->get('usr')));
$artefact->set('title', $title);
......@@ -447,11 +447,11 @@ class LeapImportResume extends LeapImportArtefactPlugin {
* Given an entry link, see whether it's a relationship referring to a
* supporting organisation, and if so, returns the ID of the organisation
*
* @param PluginImport $importer The importer
* @param array $link The link to check
* @param PluginImportLeap $importer The importer
* @param array $link The link to check
* @return string The ID of the organisation if there is one, else an empty string
*/
private static function check_for_supporting_organisation(PluginImport $importer, $link) {
private static function check_for_supporting_organisation(PluginImportLeap $importer, $link) {
if ($importer->curie_equals($link['rel'], PluginImportLeap::NS_LEAP, 'is_supported_by') && isset($link['href'])) {
if ($potentialorganisation = $importer->get_entry_by_id((string)$link['href'])) {
if (PluginImportLeap::is_rdf_type($potentialorganisation, $importer, 'organisation')) {
......@@ -470,15 +470,15 @@ class LeapImportResume extends LeapImportArtefactPlugin {
* We look for the special Mahara selections only, because entries could be
* in more than one selection, with different display orders in each.
*
* @param SimpleXMLElement $entry The entry to check
* @param PluginImport $importer The importer
* @param string $selectiontype The type of selection we're checking to
* see if the entry is part of - one of the
* special Mahara resume selections
* @param SimpleXMLElement $entry The entry to check
* @param PluginImportLeap $importer The importer
* @param string $selectiontype The type of selection we're checking to
* see if the entry is part of - one of the
* special Mahara resume selections
* @return int The display order of the element in the selection, should it
* be in one - else null
*/
private static function get_display_order_for_entry(SimpleXMLElement $entry, PluginImport $importer, $selectiontype) {
private static function get_display_order_for_entry(SimpleXMLElement $entry, PluginImportLeap $importer, $selectiontype) {
static $cache = array();
$found = false;
......
......@@ -704,11 +704,11 @@ abstract class LeapImportArtefactPlugin {
* best match, as the user may choose the less obvious method of importing
* for some reason.
*
* @param SimpleXMLElement $entry The entry to find import strategies for
* @param PluginImport $importer The importer
* @param SimpleXMLElement $entry The entry to find import strategies for
* @param PluginImportLeap $importer The importer
* @return array A list of strategies that could be used to import this entry
*/
abstract public static function get_import_strategies_for_entry(SimpleXMLElement $entry, PluginImport $importer);
abstract public static function get_import_strategies_for_entry(SimpleXMLElement $entry, PluginImportLeap $importer);
/**
* Converts an entry into the appropriate artefacts using the given
......@@ -750,25 +750,25 @@ abstract class LeapImportArtefactPlugin {
* attached to blog posts even though the files and blog posts were
* imported by different plugins.
*
* @param SimpleXMLElement $entry The entry to import
* @param PluginImport $importer The importer
* @param int $strategy The strategy to use (should be a class
* constant on your class, see the
* documentation of get_import_strategies_for_entry
* for more information)
* @param array $otherentries A list of entry IDs that this class
* previously said were required to import
* the entry
* @param SimpleXMLElement $entry The entry to import
* @param PluginImportLeap $importer The importer
* @param int $strategy The strategy to use (should be a class
* constant on your class, see the documentation
* of get_import_strategies_for_entry for more
* information)
* @param array $otherentries A list of entry IDs that this class
* previously said were required to import
* the entry
* @throws ImportException If the strategy is unrecognised
* @return array A list describing what artefacts were created by the
* import of each entry
*/
abstract public static function import_using_strategy(SimpleXMLElement $entry, PluginImport $importer, $strategy, array $otherentries);
abstract public static function import_using_strategy(SimpleXMLElement $entry, PluginImportLeap $importer, $strategy, array $otherentries);
/**
* Gives plugins a chance to import author data
*/
public static function import_author_data(PluginImport $importer, $persondataid) {
public static function import_author_data(PluginImportLeap $importer, $persondataid) {
}
/**
......@@ -784,18 +784,18 @@ abstract class LeapImportArtefactPlugin {
*
* This method has no return value.
*
* @param SimpleXMLElement $entry The entry previously imported
* @param PluginImport $importer The importer
* @param int $strategy The strategy to use (should be a class
* constant on your class, see the
* documentation of get_import_strategies_for_entry
* for more information)
* @param SimpleXMLElement $entry The entry previously imported
* @param PluginImportLeap $importer The importer
* @param int $strategy The strategy to use (should be a class
* constant on your class, see the documentation
* of get_import_strategies_for_entry for more
* information)
* @param array $otherentries A list of entry IDs that this class
* previously said were required to import
* the entry
* @throws ImportException If the strategy is unrecognised
*/
public static function setup_relationships(SimpleXMLElement $entry, PluginImport $importer, $strategy, array $otherentries) {
public static function setup_relationships(SimpleXMLElement $entry, PluginImportLeap $importer, $strategy, array $otherentries) {
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment