Browse Source

Update templates, white spacings and code format.

pull/11/head
Roman Axelrod 3 years ago
parent
commit
9f5c157e54
  1. 6
      platforms/php/build.php
  2. 4
      platforms/wordpress/templates/Template_Basic_Component.php
  3. 10
      platforms/wordpress/templates/Template_Component.php

6
platforms/php/build.php

@ -59,8 +59,8 @@ class Component_Builder {
private string $dist_path = ''; private string $dist_path = '';
function __construct( $args = [] ) { function __construct( $args = [] ) {
if ( empty( $args['backPath'] ) || empty( $args['projectPath'] ) || empty( $args['blockName'] ) || empty( $args['platform'] ) ) { if ( ! isset( $args['backPath'] ) || ! isset( $args['projectPath'] ) || ! isset( $args['blockName'] ) || ! isset( $args['platform'] ) ) {
die( 'Error: Missing arguments. Make sure all parameter passed.' ); throw new \Exception( 'Error: Missing arguments. Make sure all parameter passed.' );
} }
$this->module_path = $args['backPath']; $this->module_path = $args['backPath'];
@ -121,7 +121,7 @@ class Component_Builder {
$t = file_put_contents( $file_path, '<?php ' . $comment . $content . ' ?>' ); $t = file_put_contents( $file_path, '<?php ' . $comment . $content . ' ?>' );
if ( $t === false ) { if ( $t === false ) {
die( "Error: Can't generate HBS template to PHP file. Cache folder is not accessible." ); throw new \Exception( "Error: Can't generate HBS template to PHP file. Cache folder is not accessible." );
} }
return $file_path; return $file_path;

4
platforms/wordpress/templates/Template_Basic_Component.php

@ -44,8 +44,8 @@ class <%= blockClassModel %>_Component <% if (isComponentManager || isElementor)
function register_elementor_widget( $widgets_manager ): void { function register_elementor_widget( $widgets_manager ): void {
require_once "helpers/<%= blockClassModel %>_Elementor_Widget.php"; require_once "helpers/<%= blockClassModel %>_Elementor_Widget.php";
$widgets_manager->register_widget_type( new Helpers\<%= blockClassModel %>_Elementor_Widget() ); $widgets_manager->register_widget_type( new Helpers\<%= blockClassModel %>_Elementor_Widget() );
} }<% } %>
<% } %>
} }
<% if (isComponentManager) { %><%= blockClassModel %>_Component::get_instance();<% } else { <% if (isComponentManager) { %><%= blockClassModel %>_Component::get_instance();<% } else {

10
platforms/wordpress/templates/Template_Component.php

@ -24,15 +24,7 @@ class <%= blockClassModel %>_Component extends \Core\Component {
wp_enqueue_script( 'script-block-<%= blockFilename %>' ); wp_enqueue_script( 'script-block-<%= blockFilename %>' );
}<% } %> }<% } %>
<% if (include_elementor_widget) { %>function register_custom_logic(): void { <% if (include_acf_block) { %> function register_acf_block() {
add_action( 'elementor/widgets/widgets_registered', [ $this, 'register_elementor_widget' ] );
}
<% } %><% if (include_elementor_widget) { %> function register_elementor_widget( $widgets_manager ) {
$widgets_manager->register_widget_type( new Helpers\<%= blockClassModel %>_Elementor_Widget() );
}
<% } %><% if (include_acf_block) { %> function register_acf_block() {
$this->register_block( __DIR__ . "/<%= blockFilename %>.block.json", [ $this->register_block( __DIR__ . "/<%= blockFilename %>.block.json", [
'style_assets' => [ 'style_assets' => [
[ [

Loading…
Cancel
Save