Skip to content

Commit 0996df6

Browse files
committed
Functions.php file added that contains facade functions
1 parent 2293c4e commit 0996df6

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
],
77
"psr-4": {
88
"Themeum\\TutorLMSMigrationTool\\": "inc/"
9-
}
9+
},
10+
"files": [
11+
"inc/Functions.php"
12+
]
1013
},
1114
"authors": [
1215
{

inc/Factories/PostMetaFactory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
* @since 2.3.0
99
*/
1010

11-
namespace Themeum\TutorLMSMigrationTool;
11+
namespace Themeum\TutorLMSMigrationTool\Factories;
1212

1313
use InvalidArgumentException;
14+
use Themeum\TutorLMSMigrationTool\ContentTypes;
1415
use Themeum\TutorLMSMigrationTool\Interfaces\PostMeta;
1516
use Themeum\TutorLMSMigrationTool\LDMigration\PostMeta\CourseMeta;
17+
use Themeum\TutorLMSMigrationTool\MigrationTypes;
1618

1719
/**
1820
* Create the post meta objects based on migration type and meta type

inc/Functions.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Helper functions
4+
*
5+
* Facades of complex logics
6+
*
7+
* @package TutorLMSMigrationTool
8+
* @author Themeum <support@themeum.com>
9+
* @link https://themeum.com
10+
* @since 2.3.0
11+
*/
12+
13+
use Themeum\TutorLMSMigrationTool\Factories\PostMetaFactory;
14+
15+
if ( ! function_exists( 'tlmt_has_tutor_pro' ) ) {
16+
/**
17+
* Check whether tutor pro is installed or not
18+
*
19+
* @since 2.3.0
20+
*
21+
* @return bool
22+
*/
23+
function tlmt_has_tutor_pro() {
24+
return function_exists( 'tutor_pro' );
25+
}
26+
}
27+
28+
if ( ! function_exists( 'get_meta_obj' ) ) {
29+
/**
30+
* Check whether tutor pro is installed or not
31+
*
32+
* @since 2.3.0
33+
*
34+
* @param string $meta_type Meta type like: course, lesson, etc.
35+
* @param string $migration_type Migration type like: ld_to_tutor.
36+
*
37+
* @see MigrationTypes & ContentTypes class
38+
*
39+
* @throws \Throwable If the migration type is not supported.
40+
*
41+
* @return PostMeta object
42+
*/
43+
function get_meta_obj( $meta_type, $migration_type ) {
44+
try {
45+
$obj = PostMetaFactory::create( $meta_type, $migration_type );
46+
return $obj;
47+
} catch ( \Throwable $th ) {
48+
throw $th;
49+
}
50+
}
51+
}
52+
53+

0 commit comments

Comments
 (0)