This repository has been archived by the owner on Nov 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
9 changed files
with
231 additions
and
5 deletions.
There are no files selected for viewing
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
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,54 @@ | ||
<?php # -*- coding: utf-8 -*- | ||
|
||
namespace W2M\Import\Service; | ||
|
||
use | ||
W2M\Import\Type, | ||
W2M\Import\Data, | ||
Mlp_Language_Api_Interface, | ||
WP_Error, | ||
WP_Post; | ||
|
||
class MlpTranslationConnector implements TranslationConnectorInterface { | ||
|
||
/** | ||
* @var Mlp_Language_Api_Interface | ||
*/ | ||
private $mlp_language_api; | ||
|
||
/** | ||
* @var Data\IdMapperInterface | ||
*/ | ||
private $id_mapper; | ||
|
||
/** | ||
* @param Mlp_Language_Api_Interface $mlp_language_api | ||
* @param Data\IdMapperInterface $id_mapper | ||
*/ | ||
public function __construct( | ||
Mlp_Language_Api_Interface $mlp_language_api, | ||
Data\IdMapperInterface $id_mapper | ||
) { | ||
|
||
$this->mlp_language_api = $mlp_language_api; | ||
$this->id_mapper = $id_mapper; | ||
} | ||
/** | ||
* @param $new_term | ||
* @param Type\ImportTermInterface $import_term | ||
* @return bool|WP_Error | ||
*/ | ||
public function link_term( $new_term, Type\ImportTermInterface $import_term ) { | ||
// TODO: Implement link_term() method. | ||
} | ||
|
||
/** | ||
* @param WP_Post $new_post | ||
* @param Type\ImportPostInterface $import_post | ||
* @return bool|WP_Error | ||
*/ | ||
public function link_post( WP_Post $new_post, Type\ImportPostInterface $import_post ) { | ||
// TODO: Implement link_post() method. | ||
} | ||
|
||
} |
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,24 @@ | ||
<?php # -*- coding: utf-8 -*- | ||
|
||
namespace W2M\Import\Service; | ||
|
||
use | ||
W2M\Import\Type; | ||
|
||
interface ObjectImporterInterface { | ||
|
||
/** | ||
* @param Type\ImportTermInterface $term | ||
* | ||
* @return bool|\WP_Error | ||
*/ | ||
public function import_term( Type\ImportTermInterface $term ); | ||
|
||
/** | ||
* @param Type\ImportPostInterface $post | ||
* | ||
* @return bool|\WP_Error | ||
*/ | ||
public function import_post( Type\ImportPostInterface $post ); | ||
|
||
} |
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,27 @@ | ||
<?php # -*- coding: utf-8 -*- | ||
|
||
namespace W2M\Import\Service; | ||
|
||
use | ||
W2M\Import\Type, | ||
WP_Error, | ||
WP_Post; | ||
|
||
interface TranslationConnectorInterface { | ||
|
||
/** | ||
* @param $new_term | ||
* @param Type\ImportTermInterface $import_term | ||
* | ||
* @return bool|WP_Error | ||
*/ | ||
public function link_term( $new_term, Type\ImportTermInterface $import_term ); | ||
|
||
/** | ||
* @param WP_Post $new_post | ||
* @param Type\ImportPostInterface $import_post | ||
* | ||
* @return bool|WP_Error | ||
*/ | ||
public function link_post( WP_Post $new_post, Type\ImportPostInterface $import_post ); | ||
} |
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,81 @@ | ||
<?php # -*- coding: utf-8 -*- | ||
|
||
namespace W2M\Import\Service; | ||
|
||
use | ||
W2M\Import\Type, | ||
W2M\Import\Data; | ||
|
||
class WpObjectImporter implements ObjectImporterInterface { | ||
|
||
/** | ||
* @var TranslationConnectorInterface | ||
*/ | ||
private $translation_connector; | ||
|
||
/** | ||
* @var Data\IdMapperInterface | ||
*/ | ||
private $id_mapper; | ||
|
||
/** | ||
* Todo: specify this | ||
*/ | ||
private $ancestor_resolver; | ||
|
||
/** | ||
* @param TranslationConnectorInterface $translation_connector | ||
* @param Data\IdMapperInterface $id_mapper | ||
* @param $ancestor_resolver (Not specified yet) | ||
*/ | ||
public function __construct( | ||
TranslationConnectorInterface $translation_connector, | ||
Data\IdMapperInterface $id_mapper, | ||
$ancestor_resolver | ||
) { | ||
|
||
$this->translation_connector = $translation_connector; | ||
$this->id_mapper = $id_mapper; | ||
$this->ancestor_resolver = $ancestor_resolver; | ||
} | ||
|
||
/** | ||
* @param Type\ImportTermInterface $term | ||
* @return bool|\WP_Error | ||
*/ | ||
public function import_term( Type\ImportTermInterface $term ) { | ||
|
||
// TODO: Implement import_term() method. | ||
|
||
// 1. Insert Term via wp_insert_term() | ||
// 2. set the new term_id(!) via $term->id( $new_term_id ); | ||
// 3. connect translations $this->translation_connector->link_term( $new_term, $term ); | ||
|
||
/** | ||
* Todo: resolve ancestor relation | ||
* Here we don't know and should not depend on whether the parent was already | ||
* imported or not. | ||
* | ||
* $ansestor_resolver->resolve_term( $new_term, $term ); | ||
*/ | ||
} | ||
|
||
/** | ||
* @param Type\ImportPostInterface $post | ||
* @return bool|\WP_Error | ||
*/ | ||
public function import_post( Type\ImportPostInterface $post ) { | ||
|
||
// 1. Insert Term via wp_insert_term() | ||
// 2. set the new term_id(!) via $term->id( $new_term_id ); | ||
// 3. connect translations $this->translation_connector->link_term( $new_post, $post ); | ||
|
||
/** | ||
* Todo: resolve ancestor relation | ||
* Here we don't know and should not depend on whether the parent was already | ||
* imported or not. | ||
* | ||
* $ansestor_resolver->resolve_term( $new_post, $post ); | ||
*/ | ||
} | ||
} |
File renamed without changes.
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
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,41 @@ | ||
<?php # -*- coding: utf-8 -*- | ||
|
||
namespace W2M\Import\Type; | ||
|
||
/** | ||
* Interface ImportTermInterface | ||
* | ||
* @package W2M\Import\Type | ||
*/ | ||
interface ImportTermInterface extends ImportElementInterface { | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function taxonomy(); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function name(); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function slug(); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function description(); | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function origin_parent_term_id(); | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function locale_relations(); | ||
} |
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