| 1 |
<?php |
| 2 |
|
| 3 |
namespace Templately\Builder\Factory; |
| 4 |
|
| 5 |
use Elementor\Core\Base\Document; |
| 6 |
use Templately\Builder\Source; |
| 7 |
|
| 8 |
class TemplateFactory { |
| 9 |
protected $platform; |
| 10 |
|
| 11 |
protected $template; |
| 12 |
protected $template_manager; |
| 13 |
|
| 14 |
public function __construct( $platform = 'elementor' ) { |
| 15 |
$this->platform = $platform; |
| 16 |
$this->template_manager = templately()->theme_builder::$templates_manager; |
| 17 |
} |
| 18 |
|
| 19 |
public function create( $type, $data, $meta = [] ) { |
| 20 |
$data = wp_parse_args( $data ); |
| 21 |
|
| 22 |
$meta = wp_parse_args( $meta, [ |
| 23 |
Source::PLATFORM_META_KEY => $this->platform, |
| 24 |
Source::TYPE_META_KEY => $type, |
| 25 |
] ); |
| 26 |
|
| 27 |
if ( $this->platform === 'elementor' ) { |
| 28 |
$meta[ Document::BUILT_WITH_ELEMENTOR_META_KEY ] = 'builder'; |
| 29 |
} |
| 30 |
|
| 31 |
return $this->template_manager->create( $type, $data, $meta ); |
| 32 |
} |
| 33 |
|
| 34 |
} |