-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update IslandoraServiceProvider.php * Just using EntityMapper instead of Gemini * Updates from testing * Coding standards and tests
- Loading branch information
Showing
6 changed files
with
1,815 additions
and
1,053 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Islandora\Crayfish\Commons\EntityMapper; | ||
|
||
class EntityMapper implements EntityMapperInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFedoraPath($uuid) | ||
{ | ||
if (strlen($uuid) < 8) { | ||
throw new \InvalidArgumentException( | ||
"Provided UUID must be at least of length 8 to account for pair-trees", | ||
400 | ||
); | ||
} | ||
|
||
$segments = str_split(substr($uuid, 0, 8), 2); | ||
return implode("/", $segments) . "/$uuid"; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getDrupalUuid($fedora_path) | ||
{ | ||
if (empty($fedora_path)) { | ||
throw new \InvalidArgumentException( | ||
"Empty string provided fedora path", | ||
400 | ||
); | ||
} | ||
$segments = explode("/", $fedora_path); | ||
return end($segments); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Islandora\Crayfish\Commons\EntityMapper; | ||
|
||
interface EntityMapperInterface | ||
{ | ||
/** | ||
* Gets a fedora path given a uuid. | ||
* | ||
* @param string $uuid | ||
* @return string | ||
*/ | ||
public function getFedoraPath($uuid); | ||
|
||
/** | ||
* Gets a drupal uuid from a fedora path. | ||
* | ||
* @param string $fedora_path | ||
* @return string | ||
*/ | ||
public function getDrupalUuid($fedora_path); | ||
} |
Oops, something went wrong.